Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  * arch/arm/plat-iop/gpio.c
  3  * GPIO handling for Intel IOP3xx processors.
  4  *
  5  * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
  6  *
  7  * This program is free software; you can redistribute it and/or modify
  8  * it under the terms of the GNU General Public License as published by
  9  * the Free Software Foundation; either version 2 of the License, or (at
 10  * your option) any later version.
 11  */
 12 
 13 #include <linux/device.h>
 14 #include <linux/init.h>
 15 #include <linux/types.h>
 16 #include <linux/errno.h>
 17 #include <linux/gpio.h>
 18 #include <asm/hardware/iop3xx.h>
 19 
 20 void gpio_line_config(int line, int direction)
 21 {
 22         unsigned long flags;
 23 
 24         local_irq_save(flags);
 25         if (direction == GPIO_IN) {
 26                 *IOP3XX_GPOE |= 1 << line;
 27         } else if (direction == GPIO_OUT) {
 28                 *IOP3XX_GPOE &= ~(1 << line);
 29         }
 30         local_irq_restore(flags);
 31 }
 32 EXPORT_SYMBOL(gpio_line_config);
 33 
 34 int gpio_line_get(int line)
 35 {
 36         return !!(*IOP3XX_GPID & (1 << line));
 37 }
 38 EXPORT_SYMBOL(gpio_line_get);
 39 
 40 void gpio_line_set(int line, int value)
 41 {
 42         unsigned long flags;
 43 
 44         local_irq_save(flags);
 45         if (value == GPIO_LOW) {
 46                 *IOP3XX_GPOD &= ~(1 << line);
 47         } else if (value == GPIO_HIGH) {
 48                 *IOP3XX_GPOD |= 1 << line;
 49         }
 50         local_irq_restore(flags);
 51 }
 52 EXPORT_SYMBOL(gpio_line_set);
 53 
 54 static int iop3xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
 55 {
 56         gpio_line_config(gpio, GPIO_IN);
 57         return 0;
 58 }
 59 
 60 static int iop3xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
 61 {
 62         gpio_line_set(gpio, level);
 63         gpio_line_config(gpio, GPIO_OUT);
 64         return 0;
 65 }
 66 
 67 static int iop3xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
 68 {
 69         return gpio_line_get(gpio);
 70 }
 71 
 72 static void iop3xx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
 73 {
 74         gpio_line_set(gpio, value);
 75 }
 76 
 77 static struct gpio_chip iop3xx_chip = {
 78         .label                  = "iop3xx",
 79         .direction_input        = iop3xx_gpio_direction_input,
 80         .get                    = iop3xx_gpio_get_value,
 81         .direction_output       = iop3xx_gpio_direction_output,
 82         .set                    = iop3xx_gpio_set_value,
 83         .base                   = 0,
 84         .ngpio                  = IOP3XX_N_GPIOS,
 85 };
 86 
 87 static int __init iop3xx_gpio_setup(void)
 88 {
 89         return gpiochip_add(&iop3xx_chip);
 90 }
 91 arch_initcall(iop3xx_gpio_setup);
 92 
  This page was automatically generated by the LXR engine.