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

TOMOYO Linux Cross Reference
Linux/arch/mips/include/asm/mach-au1x00/gpio-au1300.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * gpio-au1300.h -- GPIO control for Au1300 GPIC and compatibles.
  4  *
  5  * Copyright (c) 2009-2011 Manuel Lauss <manuel.lauss@googlemail.com>
  6  */
  7 
  8 #ifndef _GPIO_AU1300_H_
  9 #define _GPIO_AU1300_H_
 10 
 11 #include <asm/addrspace.h>
 12 #include <asm/io.h>
 13 #include <asm/mach-au1x00/au1000.h>
 14 
 15 struct gpio;
 16 struct gpio_chip;
 17 
 18 /* with the current GPIC design, up to 128 GPIOs are possible.
 19  * The only implementation so far is in the Au1300, which has 75 externally
 20  * available GPIOs.
 21  */
 22 #define AU1300_GPIO_BASE        0
 23 #define AU1300_GPIO_NUM         75
 24 #define AU1300_GPIO_MAX         (AU1300_GPIO_BASE + AU1300_GPIO_NUM - 1)
 25 
 26 #define AU1300_GPIC_ADDR        \
 27         (void __iomem *)KSEG1ADDR(AU1300_GPIC_PHYS_ADDR)
 28 
 29 static inline int au1300_gpio_get_value(unsigned int gpio)
 30 {
 31         void __iomem *roff = AU1300_GPIC_ADDR;
 32         int bit;
 33 
 34         gpio -= AU1300_GPIO_BASE;
 35         roff += GPIC_GPIO_BANKOFF(gpio);
 36         bit = GPIC_GPIO_TO_BIT(gpio);
 37         return __raw_readl(roff + AU1300_GPIC_PINVAL) & bit;
 38 }
 39 
 40 static inline int au1300_gpio_direction_input(unsigned int gpio)
 41 {
 42         void __iomem *roff = AU1300_GPIC_ADDR;
 43         unsigned long bit;
 44 
 45         gpio -= AU1300_GPIO_BASE;
 46 
 47         roff += GPIC_GPIO_BANKOFF(gpio);
 48         bit = GPIC_GPIO_TO_BIT(gpio);
 49         __raw_writel(bit, roff + AU1300_GPIC_DEVCLR);
 50         wmb();
 51 
 52         return 0;
 53 }
 54 
 55 static inline int au1300_gpio_set_value(unsigned int gpio, int v)
 56 {
 57         void __iomem *roff = AU1300_GPIC_ADDR;
 58         unsigned long bit;
 59 
 60         gpio -= AU1300_GPIO_BASE;
 61 
 62         roff += GPIC_GPIO_BANKOFF(gpio);
 63         bit = GPIC_GPIO_TO_BIT(gpio);
 64         __raw_writel(bit, roff + (v ? AU1300_GPIC_PINVAL
 65                                     : AU1300_GPIC_PINVALCLR));
 66         wmb();
 67 
 68         return 0;
 69 }
 70 
 71 static inline int au1300_gpio_direction_output(unsigned int gpio, int v)
 72 {
 73         /* hw switches to output automatically */
 74         return au1300_gpio_set_value(gpio, v);
 75 }
 76 
 77 static inline int au1300_gpio_to_irq(unsigned int gpio)
 78 {
 79         return AU1300_FIRST_INT + (gpio - AU1300_GPIO_BASE);
 80 }
 81 
 82 static inline int au1300_irq_to_gpio(unsigned int irq)
 83 {
 84         return (irq - AU1300_FIRST_INT) + AU1300_GPIO_BASE;
 85 }
 86 
 87 static inline int au1300_gpio_is_valid(unsigned int gpio)
 88 {
 89         int ret;
 90 
 91         switch (alchemy_get_cputype()) {
 92         case ALCHEMY_CPU_AU1300:
 93                 ret = ((gpio >= AU1300_GPIO_BASE) && (gpio <= AU1300_GPIO_MAX));
 94                 break;
 95         default:
 96                 ret = 0;
 97         }
 98         return ret;
 99 }
100 
101 /* hardware remembers gpio 0-63 levels on powerup */
102 static inline int au1300_gpio_getinitlvl(unsigned int gpio)
103 {
104         void __iomem *roff = AU1300_GPIC_ADDR;
105         unsigned long v;
106 
107         if (unlikely(gpio > 63))
108                 return 0;
109         else if (gpio > 31) {
110                 gpio -= 32;
111                 roff += 4;
112         }
113 
114         v = __raw_readl(roff + AU1300_GPIC_RSTVAL);
115         return (v >> gpio) & 1;
116 }
117 
118 #endif /* _GPIO_AU1300_H_ */
119 

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

kernel.org | git.kernel.org | LWN.net | Project Home | 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.

sflogo.php