2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
9 #ifndef __BCM47XX_GPIO_H
10 #define __BCM47XX_GPIO_H
12 #include <linux/ssb/ssb_embedded.h>
13 #include <linux/bcma/bcma.h>
14 #include <asm/mach-bcm47xx/bcm47xx.h>
16 #define BCM47XX_EXTIF_GPIO_LINES 5
17 #define BCM47XX_CHIPCO_GPIO_LINES 16
19 extern int gpio_request(unsigned gpio
, const char *label
);
20 extern void gpio_free(unsigned gpio
);
21 extern int gpio_to_irq(unsigned gpio
);
23 static inline int gpio_get_value(unsigned gpio
)
25 switch (bcm47xx_bus_type
) {
26 #ifdef CONFIG_BCM47XX_SSB
27 case BCM47XX_BUS_TYPE_SSB
:
28 return ssb_gpio_in(&bcm47xx_bus
.ssb
, 1 << gpio
);
30 #ifdef CONFIG_BCM47XX_BCMA
31 case BCM47XX_BUS_TYPE_BCMA
:
32 return bcma_chipco_gpio_in(&bcm47xx_bus
.bcma
.bus
.drv_cc
,
39 static inline void gpio_set_value(unsigned gpio
, int value
)
41 switch (bcm47xx_bus_type
) {
42 #ifdef CONFIG_BCM47XX_SSB
43 case BCM47XX_BUS_TYPE_SSB
:
44 ssb_gpio_out(&bcm47xx_bus
.ssb
, 1 << gpio
,
45 value
? 1 << gpio
: 0);
48 #ifdef CONFIG_BCM47XX_BCMA
49 case BCM47XX_BUS_TYPE_BCMA
:
50 bcma_chipco_gpio_out(&bcm47xx_bus
.bcma
.bus
.drv_cc
, 1 << gpio
,
51 value
? 1 << gpio
: 0);
57 static inline int gpio_direction_input(unsigned gpio
)
59 switch (bcm47xx_bus_type
) {
60 #ifdef CONFIG_BCM47XX_SSB
61 case BCM47XX_BUS_TYPE_SSB
:
62 ssb_gpio_outen(&bcm47xx_bus
.ssb
, 1 << gpio
, 0);
65 #ifdef CONFIG_BCM47XX_BCMA
66 case BCM47XX_BUS_TYPE_BCMA
:
67 bcma_chipco_gpio_outen(&bcm47xx_bus
.bcma
.bus
.drv_cc
, 1 << gpio
,
75 static inline int gpio_direction_output(unsigned gpio
, int value
)
77 switch (bcm47xx_bus_type
) {
78 #ifdef CONFIG_BCM47XX_SSB
79 case BCM47XX_BUS_TYPE_SSB
:
80 /* first set the gpio out value */
81 ssb_gpio_out(&bcm47xx_bus
.ssb
, 1 << gpio
,
82 value
? 1 << gpio
: 0);
83 /* then set the gpio mode */
84 ssb_gpio_outen(&bcm47xx_bus
.ssb
, 1 << gpio
, 1 << gpio
);
87 #ifdef CONFIG_BCM47XX_BCMA
88 case BCM47XX_BUS_TYPE_BCMA
:
89 /* first set the gpio out value */
90 bcma_chipco_gpio_out(&bcm47xx_bus
.bcma
.bus
.drv_cc
, 1 << gpio
,
91 value
? 1 << gpio
: 0);
92 /* then set the gpio mode */
93 bcma_chipco_gpio_outen(&bcm47xx_bus
.bcma
.bus
.drv_cc
, 1 << gpio
,
101 static inline int gpio_intmask(unsigned gpio
, int value
)
103 switch (bcm47xx_bus_type
) {
104 #ifdef CONFIG_BCM47XX_SSB
105 case BCM47XX_BUS_TYPE_SSB
:
106 ssb_gpio_intmask(&bcm47xx_bus
.ssb
, 1 << gpio
,
107 value
? 1 << gpio
: 0);
110 #ifdef CONFIG_BCM47XX_BCMA
111 case BCM47XX_BUS_TYPE_BCMA
:
112 bcma_chipco_gpio_intmask(&bcm47xx_bus
.bcma
.bus
.drv_cc
,
113 1 << gpio
, value
? 1 << gpio
: 0);
120 static inline int gpio_polarity(unsigned gpio
, int value
)
122 switch (bcm47xx_bus_type
) {
123 #ifdef CONFIG_BCM47XX_SSB
124 case BCM47XX_BUS_TYPE_SSB
:
125 ssb_gpio_polarity(&bcm47xx_bus
.ssb
, 1 << gpio
,
126 value
? 1 << gpio
: 0);
129 #ifdef CONFIG_BCM47XX_BCMA
130 case BCM47XX_BUS_TYPE_BCMA
:
131 bcma_chipco_gpio_polarity(&bcm47xx_bus
.bcma
.bus
.drv_cc
,
132 1 << gpio
, value
? 1 << gpio
: 0);
140 /* cansleep wrappers */
141 #include <asm-generic/gpio.h>
143 #endif /* __BCM47XX_GPIO_H */