linux/drivers/gpio/gpio-ucb1400.c
<<
>>
Prefs
   1/*
   2 * Philips UCB1400 GPIO driver
   3 *
   4 * Author: Marek Vasut <marek.vasut@gmail.com>
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License version 2 as
   8 * published by the Free Software Foundation.
   9 *
  10 */
  11
  12#include <linux/module.h>
  13#include <linux/ucb1400.h>
  14
  15struct ucb1400_gpio_data *ucbdata;
  16
  17static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off)
  18{
  19        struct ucb1400_gpio *gpio;
  20        gpio = container_of(gc, struct ucb1400_gpio, gc);
  21        ucb1400_gpio_set_direction(gpio->ac97, off, 0);
  22        return 0;
  23}
  24
  25static int ucb1400_gpio_dir_out(struct gpio_chip *gc, unsigned off, int val)
  26{
  27        struct ucb1400_gpio *gpio;
  28        gpio = container_of(gc, struct ucb1400_gpio, gc);
  29        ucb1400_gpio_set_direction(gpio->ac97, off, 1);
  30        ucb1400_gpio_set_value(gpio->ac97, off, val);
  31        return 0;
  32}
  33
  34static int ucb1400_gpio_get(struct gpio_chip *gc, unsigned off)
  35{
  36        struct ucb1400_gpio *gpio;
  37        gpio = container_of(gc, struct ucb1400_gpio, gc);
  38        return ucb1400_gpio_get_value(gpio->ac97, off);
  39}
  40
  41static void ucb1400_gpio_set(struct gpio_chip *gc, unsigned off, int val)
  42{
  43        struct ucb1400_gpio *gpio;
  44        gpio = container_of(gc, struct ucb1400_gpio, gc);
  45        ucb1400_gpio_set_value(gpio->ac97, off, val);
  46}
  47
  48static int ucb1400_gpio_probe(struct platform_device *dev)
  49{
  50        struct ucb1400_gpio *ucb = dev->dev.platform_data;
  51        int err = 0;
  52
  53        if (!(ucbdata && ucbdata->gpio_offset)) {
  54                err = -EINVAL;
  55                goto err;
  56        }
  57
  58        platform_set_drvdata(dev, ucb);
  59
  60        ucb->gc.label = "ucb1400_gpio";
  61        ucb->gc.base = ucbdata->gpio_offset;
  62        ucb->gc.ngpio = 10;
  63        ucb->gc.owner = THIS_MODULE;
  64
  65        ucb->gc.direction_input = ucb1400_gpio_dir_in;
  66        ucb->gc.direction_output = ucb1400_gpio_dir_out;
  67        ucb->gc.get = ucb1400_gpio_get;
  68        ucb->gc.set = ucb1400_gpio_set;
  69        ucb->gc.can_sleep = 1;
  70
  71        err = gpiochip_add(&ucb->gc);
  72        if (err)
  73                goto err;
  74
  75        if (ucbdata && ucbdata->gpio_setup)
  76                err = ucbdata->gpio_setup(&  56        }
ucbname="L71">  71        err =   57/a>;
  76            :7" id="L57" class="line" name="L57">  57/a>;
                goto err8= 1;
  78
  468a>);
  58/a>)
  4remov>static int ucb1400_gpio_probe(struct platform_device *dev8/a>;
  498
  51        int err8/a>)
  36        struct ucb1400_gpio *  58        platform_set_drvdataerr =   58span>
  75        if (ucbdata &&  = gpio_offset;
  76                err =  = gpio_setup(&  56        }
ucbname="L71">  71        err =   72        if (err9
                goto err9a>);
  469/a>)
  39/a>;
  71        static int code=gpiochip_add" class="sref">gpiochip_add(&ucb->gc<9
                goto err9/a>)
  469pi value9"v2.6.27.ucbdata  59span>
ucb1400_gpi clasbe(struct directio clasbe(struct directio clas       gpio_offset" class="sref">gpio_offset
static int .   9 *
static int code/a>._gpi,"L9">   9 *
(struct gpio_offset
name="L71">  71label = gpio_offset   9 *ucbdata<0
  510/a>;
set = directiplatf  15struct usref">directio  15struct off<0
  4910/a>)
  75        if ( *ucbdata<0/a>{
  391span>
  71span>
(struct <"inclu_cb1400_gpi clast_drvdata" class="srsref">directio clasbe(struct directio clas    >->gc<11
  51>>
   2 = ->gc<11>
owner href=_LICENS"t_drvdref="+code=label" class="sGPLa> = ->gc<11
   8LXRslassuniey/a>   h" m experis="lal the term>  gt;to:lxs@href=.no">lxs@href=.nob
h_resuls" cl="drivesubfootasb>
lxs.href=.no kindly hostL8">  gt;Redpill Lrepro AS/a>   provi="L7of Lreuxslan   s serde=ps since 1995.
h_results/bodyuls/htmlor