diff options
-rw-r--r-- | arch/mips/bcm47xx/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/bcm47xx/gpio.c | 79 | ||||
-rw-r--r-- | include/asm-mips/mach-bcm47xx/gpio.h | 59 |
3 files changed, 139 insertions, 1 deletions
diff --git a/arch/mips/bcm47xx/Makefile b/arch/mips/bcm47xx/Makefile index dc035f90d363..0afe09703e3f 100644 --- a/arch/mips/bcm47xx/Makefile +++ b/arch/mips/bcm47xx/Makefile | |||
@@ -3,4 +3,4 @@ | |||
3 | # under Linux. | 3 | # under Linux. |
4 | # | 4 | # |
5 | 5 | ||
6 | obj-y := irq.o prom.o serial.o setup.o time.o | 6 | obj-y := gpio.o irq.o prom.o serial.o setup.o time.o |
diff --git a/arch/mips/bcm47xx/gpio.c b/arch/mips/bcm47xx/gpio.c new file mode 100644 index 000000000000..f5a53acf995a --- /dev/null +++ b/arch/mips/bcm47xx/gpio.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
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 | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net> | ||
7 | */ | ||
8 | |||
9 | #include <linux/ssb/ssb.h> | ||
10 | #include <linux/ssb/ssb_driver_chipcommon.h> | ||
11 | #include <linux/ssb/ssb_driver_extif.h> | ||
12 | #include <asm/mach-bcm47xx/bcm47xx.h> | ||
13 | #include <asm/mach-bcm47xx/gpio.h> | ||
14 | |||
15 | int bcm47xx_gpio_to_irq(unsigned gpio) | ||
16 | { | ||
17 | if (ssb_bcm47xx.chipco.dev) | ||
18 | return ssb_mips_irq(ssb_bcm47xx.chipco.dev) + 2; | ||
19 | else if (ssb_bcm47xx.extif.dev) | ||
20 | return ssb_mips_irq(ssb_bcm47xx.extif.dev) + 2; | ||
21 | else | ||
22 | return -EINVAL; | ||
23 | } | ||
24 | EXPORT_SYMBOL_GPL(bcm47xx_gpio_to_irq); | ||
25 | |||
26 | int bcm47xx_gpio_get_value(unsigned gpio) | ||
27 | { | ||
28 | if (ssb_bcm47xx.chipco.dev) | ||
29 | return ssb_chipco_gpio_in(&ssb_bcm47xx.chipco, 1 << gpio); | ||
30 | else if (ssb_bcm47xx.extif.dev) | ||
31 | return ssb_extif_gpio_in(&ssb_bcm47xx.extif, 1 << gpio); | ||
32 | else | ||
33 | return 0; | ||
34 | } | ||
35 | EXPORT_SYMBOL_GPL(bcm47xx_gpio_get_value); | ||
36 | |||
37 | void bcm47xx_gpio_set_value(unsigned gpio, int value) | ||
38 | { | ||
39 | if (ssb_bcm47xx.chipco.dev) | ||
40 | ssb_chipco_gpio_out(&ssb_bcm47xx.chipco, | ||
41 | 1 << gpio, | ||
42 | value ? 1 << gpio : 0); | ||
43 | else if (ssb_bcm47xx.extif.dev) | ||
44 | ssb_extif_gpio_out(&ssb_bcm47xx.extif, | ||
45 | 1 << gpio, | ||
46 | value ? 1 << gpio : 0); | ||
47 | } | ||
48 | EXPORT_SYMBOL_GPL(bcm47xx_gpio_set_value); | ||
49 | |||
50 | int bcm47xx_gpio_direction_input(unsigned gpio) | ||
51 | { | ||
52 | if (ssb_bcm47xx.chipco.dev && (gpio < BCM47XX_CHIPCO_GPIO_LINES)) | ||
53 | ssb_chipco_gpio_outen(&ssb_bcm47xx.chipco, | ||
54 | 1 << gpio, 0); | ||
55 | else if (ssb_bcm47xx.extif.dev && (gpio < BCM47XX_EXTIF_GPIO_LINES)) | ||
56 | ssb_extif_gpio_outen(&ssb_bcm47xx.extif, | ||
57 | 1 << gpio, 0); | ||
58 | else | ||
59 | return -EINVAL; | ||
60 | return 0; | ||
61 | } | ||
62 | EXPORT_SYMBOL_GPL(bcm47xx_gpio_direction_input); | ||
63 | |||
64 | int bcm47xx_gpio_direction_output(unsigned gpio, int value) | ||
65 | { | ||
66 | bcm47xx_gpio_set_value(gpio, value); | ||
67 | |||
68 | if (ssb_bcm47xx.chipco.dev && (gpio < BCM47XX_CHIPCO_GPIO_LINES)) | ||
69 | ssb_chipco_gpio_outen(&ssb_bcm47xx.chipco, | ||
70 | 1 << gpio, 1 << gpio); | ||
71 | else if (ssb_bcm47xx.extif.dev && (gpio < BCM47XX_EXTIF_GPIO_LINES)) | ||
72 | ssb_extif_gpio_outen(&ssb_bcm47xx.extif, | ||
73 | 1 << gpio, 1 << gpio); | ||
74 | else | ||
75 | return -EINVAL; | ||
76 | return 0; | ||
77 | } | ||
78 | EXPORT_SYMBOL_GPL(bcm47xx_gpio_direction_output); | ||
79 | |||
diff --git a/include/asm-mips/mach-bcm47xx/gpio.h b/include/asm-mips/mach-bcm47xx/gpio.h new file mode 100644 index 000000000000..cfc8f4d618ce --- /dev/null +++ b/include/asm-mips/mach-bcm47xx/gpio.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
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 | ||
4 | * for more details. | ||
5 | * | ||
6 | * Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net> | ||
7 | */ | ||
8 | |||
9 | #ifndef __BCM47XX_GPIO_H | ||
10 | #define __BCM47XX_GPIO_H | ||
11 | |||
12 | #define BCM47XX_EXTIF_GPIO_LINES 5 | ||
13 | #define BCM47XX_CHIPCO_GPIO_LINES 16 | ||
14 | |||
15 | extern int bcm47xx_gpio_to_irq(unsigned gpio); | ||
16 | extern int bcm47xx_gpio_get_value(unsigned gpio); | ||
17 | extern void bcm47xx_gpio_set_value(unsigned gpio, int value); | ||
18 | extern int bcm47xx_gpio_direction_input(unsigned gpio); | ||
19 | extern int bcm47xx_gpio_direction_output(unsigned gpio, int value); | ||
20 | |||
21 | static inline int gpio_request(unsigned gpio, const char *label) | ||
22 | { | ||
23 | return 0; | ||
24 | } | ||
25 | |||
26 | static inline void gpio_free(unsigned gpio) | ||
27 | { | ||
28 | } | ||
29 | |||
30 | static inline int gpio_to_irq(unsigned gpio) | ||
31 | { | ||
32 | return bcm47xx_gpio_to_irq(gpio); | ||
33 | } | ||
34 | |||
35 | static inline int gpio_get_value(unsigned gpio) | ||
36 | { | ||
37 | return bcm47xx_gpio_get_value(gpio); | ||
38 | } | ||
39 | |||
40 | static inline void gpio_set_value(unsigned gpio, int value) | ||
41 | { | ||
42 | bcm47xx_gpio_set_value(gpio, value); | ||
43 | } | ||
44 | |||
45 | static inline int gpio_direction_input(unsigned gpio) | ||
46 | { | ||
47 | return bcm47xx_gpio_direction_input(gpio); | ||
48 | } | ||
49 | |||
50 | static inline int gpio_direction_output(unsigned gpio, int value) | ||
51 | { | ||
52 | return bcm47xx_gpio_direction_output(gpio, value); | ||
53 | } | ||
54 | |||
55 | |||
56 | /* cansleep wrappers */ | ||
57 | #include <asm-generic/gpio.h> | ||
58 | |||
59 | #endif /* __BCM47XX_GPIO_H */ | ||