~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/arm/plat-iop/gpio.c

Version: ~ [ linux-5.15-rc7 ] ~ [ linux-5.14.14 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.75 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.155 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.213 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.252 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.287 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.289 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp