Skip to content
Snippets Groups Projects
Select Git revision
  • b57e09b05cd260da70aaf992ec1a5c587d3e5439
  • master default protected
  • iopsys
  • develop
  • gh-pages
  • 0.4.x
  • v0.5.0-rc23
  • v0.5.0-rc22
  • v0.5.0-rc21
  • v0.5.0-rc20
  • v0.5.0-rc19
  • v0.5.0-rc18
  • v0.5.0-rc17
  • 0.5.0-rc16
  • v0.5.0-rc15
  • v0.4.7
  • v0.5.0-rc12
  • v0.5.0-rc11
  • v0.4.3
  • v0.5.0-rc10
  • v0.5.0-rc9
  • v0.5.0-rc8
  • v0.5.0-rc7
  • v0.5.0-rc6
  • v0.5.0-rc5
  • v0.5.0-rc4
26 results

words.js

Blame
  • leds-netxbig.c 14.35 KiB
    /*
     * leds-netxbig.c - Driver for the 2Big and 5Big Network series LEDs
     *
     * Copyright (C) 2010 LaCie
     *
     * Author: Simon Guinot <sguinot@lacie.com>
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 2 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     */
    
    #include <linux/module.h>
    #include <linux/irq.h>
    #include <linux/slab.h>
    #include <linux/spinlock.h>
    #include <linux/platform_device.h>
    #include <linux/gpio.h>
    #include <linux/of_gpio.h>
    #include <linux/leds.h>
    #include <linux/platform_data/leds-kirkwood-netxbig.h>
    
    /*
     * GPIO extension bus.
     */
    
    static DEFINE_SPINLOCK(gpio_ext_lock);
    
    static void gpio_ext_set_addr(struct netxbig_gpio_ext *gpio_ext, int addr)
    {
    	int pin;
    
    	for (pin = 0; pin < gpio_ext->num_addr; pin++)
    		gpio_set_value(gpio_ext->addr[pin], (addr >> pin) & 1);
    }
    
    static void gpio_ext_set_data(struct netxbig_gpio_ext *gpio_ext, int data)
    {
    	int pin;
    
    	for (pin = 0; pin < gpio_ext->num_data; pin++)
    		gpio_set_value(gpio_ext->data[pin], (data >> pin) & 1);
    }
    
    static void gpio_ext_enable_select(struct netxbig_gpio_ext *gpio_ext)
    {
    	/* Enable select is done on the raising edge. */
    	gpio_set_value(gpio_ext->enable, 0);
    	gpio_set_value(gpio_ext->enable, 1);
    }
    
    static void gpio_ext_set_value(struct netxbig_gpio_ext *gpio_ext,
    			       int addr, int value)
    {
    	unsigned long flags;
    
    	spin_lock_irqsave(&gpio_ext_lock, flags);
    	gpio_ext_set_addr(gpio_ext, addr);
    	gpio_ext_set_data(gpio_ext, value);
    	gpio_ext_enable_select(gpio_ext);