diff options
Diffstat (limited to 'arch/arm/mach-davinci/include/mach/gpio.h')
-rw-r--r-- | arch/arm/mach-davinci/include/mach/gpio.h | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h index f3b8ef878158..504cc180a60b 100644 --- a/arch/arm/mach-davinci/include/mach/gpio.h +++ b/arch/arm/mach-davinci/include/mach/gpio.h | |||
@@ -14,6 +14,8 @@ | |||
14 | #define __DAVINCI_GPIO_H | 14 | #define __DAVINCI_GPIO_H |
15 | 15 | ||
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/spinlock.h> | ||
18 | |||
17 | #include <asm-generic/gpio.h> | 19 | #include <asm-generic/gpio.h> |
18 | 20 | ||
19 | #include <mach/irqs.h> | 21 | #include <mach/irqs.h> |
@@ -21,6 +23,10 @@ | |||
21 | 23 | ||
22 | #define DAVINCI_GPIO_BASE 0x01C67000 | 24 | #define DAVINCI_GPIO_BASE 0x01C67000 |
23 | 25 | ||
26 | enum davinci_gpio_type { | ||
27 | GPIO_TYPE_DAVINCI = 0, | ||
28 | }; | ||
29 | |||
24 | /* | 30 | /* |
25 | * basic gpio routines | 31 | * basic gpio routines |
26 | * | 32 | * |
@@ -45,17 +51,14 @@ | |||
45 | /* Convert GPIO signal to GPIO pin number */ | 51 | /* Convert GPIO signal to GPIO pin number */ |
46 | #define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio)) | 52 | #define GPIO_TO_PIN(bank, gpio) (16 * (bank) + (gpio)) |
47 | 53 | ||
48 | struct gpio_controller { | 54 | struct davinci_gpio_controller { |
49 | u32 dir; | 55 | struct gpio_chip chip; |
50 | u32 out_data; | 56 | int irq_base; |
51 | u32 set_data; | 57 | spinlock_t lock; |
52 | u32 clr_data; | 58 | void __iomem *regs; |
53 | u32 in_data; | 59 | void __iomem *set_data; |
54 | u32 set_rising; | 60 | void __iomem *clr_data; |
55 | u32 clr_rising; | 61 | void __iomem *in_data; |
56 | u32 set_falling; | ||
57 | u32 clr_falling; | ||
58 | u32 intstat; | ||
59 | }; | 62 | }; |
60 | 63 | ||
61 | /* The __gpio_to_controller() and __gpio_mask() functions inline to constants | 64 | /* The __gpio_to_controller() and __gpio_mask() functions inline to constants |
@@ -67,25 +70,16 @@ struct gpio_controller { | |||
67 | * | 70 | * |
68 | * These are NOT part of the cross-platform GPIO interface | 71 | * These are NOT part of the cross-platform GPIO interface |
69 | */ | 72 | */ |
70 | static inline struct gpio_controller *__iomem | 73 | static inline struct davinci_gpio_controller * |
71 | __gpio_to_controller(unsigned gpio) | 74 | __gpio_to_controller(unsigned gpio) |
72 | { | 75 | { |
73 | void *__iomem ptr; | 76 | struct davinci_gpio_controller *ctlrs = davinci_soc_info.gpio_ctlrs; |
74 | void __iomem *base = davinci_soc_info.gpio_base; | 77 | int index = gpio / 32; |
75 | 78 | ||
76 | if (gpio < 32 * 1) | 79 | if (!ctlrs || index >= davinci_soc_info.gpio_ctlrs_num) |
77 | ptr = base + 0x10; | 80 | return NULL; |
78 | else if (gpio < 32 * 2) | 81 | |
79 | ptr = base + 0x38; | 82 | return ctlrs + index; |
80 | else if (gpio < 32 * 3) | ||
81 | ptr = base + 0x60; | ||
82 | else if (gpio < 32 * 4) | ||
83 | ptr = base + 0x88; | ||
84 | else if (gpio < 32 * 5) | ||
85 | ptr = base + 0xb0; | ||
86 | else | ||
87 | ptr = NULL; | ||
88 | return ptr; | ||
89 | } | 83 | } |
90 | 84 | ||
91 | static inline u32 __gpio_mask(unsigned gpio) | 85 | static inline u32 __gpio_mask(unsigned gpio) |
@@ -101,16 +95,16 @@ static inline u32 __gpio_mask(unsigned gpio) | |||
101 | */ | 95 | */ |
102 | static inline void gpio_set_value(unsigned gpio, int value) | 96 | static inline void gpio_set_value(unsigned gpio, int value) |
103 | { | 97 | { |
104 | if (__builtin_constant_p(value) && gpio < DAVINCI_N_GPIO) { | 98 | if (__builtin_constant_p(value) && gpio < davinci_soc_info.gpio_num) { |
105 | struct gpio_controller *__iomem g; | 99 | struct davinci_gpio_controller *ctlr; |
106 | u32 mask; | 100 | u32 mask; |
107 | 101 | ||
108 | g = __gpio_to_controller(gpio); | 102 | ctlr = __gpio_to_controller(gpio); |
109 | mask = __gpio_mask(gpio); | 103 | mask = __gpio_mask(gpio); |
110 | if (value) | 104 | if (value) |
111 | __raw_writel(mask, &g->set_data); | 105 | __raw_writel(mask, ctlr->set_data); |
112 | else | 106 | else |
113 | __raw_writel(mask, &g->clr_data); | 107 | __raw_writel(mask, ctlr->clr_data); |
114 | return; | 108 | return; |
115 | } | 109 | } |
116 | 110 | ||
@@ -128,18 +122,18 @@ static inline void gpio_set_value(unsigned gpio, int value) | |||
128 | */ | 122 | */ |
129 | static inline int gpio_get_value(unsigned gpio) | 123 | static inline int gpio_get_value(unsigned gpio) |
130 | { | 124 | { |
131 | struct gpio_controller *__iomem g; | 125 | struct davinci_gpio_controller *ctlr; |
132 | 126 | ||
133 | if (!__builtin_constant_p(gpio) || gpio >= DAVINCI_N_GPIO) | 127 | if (!__builtin_constant_p(gpio) || gpio >= davinci_soc_info.gpio_num) |
134 | return __gpio_get_value(gpio); | 128 | return __gpio_get_value(gpio); |
135 | 129 | ||
136 | g = __gpio_to_controller(gpio); | 130 | ctlr = __gpio_to_controller(gpio); |
137 | return __gpio_mask(gpio) & __raw_readl(&g->in_data); | 131 | return __gpio_mask(gpio) & __raw_readl(ctlr->in_data); |
138 | } | 132 | } |
139 | 133 | ||
140 | static inline int gpio_cansleep(unsigned gpio) | 134 | static inline int gpio_cansleep(unsigned gpio) |
141 | { | 135 | { |
142 | if (__builtin_constant_p(gpio) && gpio < DAVINCI_N_GPIO) | 136 | if (__builtin_constant_p(gpio) && gpio < davinci_soc_info.gpio_num) |
143 | return 0; | 137 | return 0; |
144 | else | 138 | else |
145 | return __gpio_cansleep(gpio); | 139 | return __gpio_cansleep(gpio); |