diff options
Diffstat (limited to 'arch/arm/mach-ep93xx/gpio.c')
-rw-r--r-- | arch/arm/mach-ep93xx/gpio.c | 65 |
1 files changed, 56 insertions, 9 deletions
diff --git a/arch/arm/mach-ep93xx/gpio.c b/arch/arm/mach-ep93xx/gpio.c index 482cf3d2fbcd..1ea8871e03a9 100644 --- a/arch/arm/mach-ep93xx/gpio.c +++ b/arch/arm/mach-ep93xx/gpio.c | |||
@@ -17,15 +17,16 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/seq_file.h> | 18 | #include <linux/seq_file.h> |
19 | #include <linux/io.h> | 19 | #include <linux/io.h> |
20 | #include <linux/gpio.h> | ||
21 | #include <linux/irq.h> | ||
20 | 22 | ||
21 | #include <mach/ep93xx-regs.h> | 23 | #include <mach/hardware.h> |
22 | #include <asm/gpio.h> | ||
23 | 24 | ||
24 | struct ep93xx_gpio_chip { | 25 | struct ep93xx_gpio_chip { |
25 | struct gpio_chip chip; | 26 | struct gpio_chip chip; |
26 | 27 | ||
27 | unsigned int data_reg; | 28 | void __iomem *data_reg; |
28 | unsigned int data_dir_reg; | 29 | void __iomem *data_dir_reg; |
29 | }; | 30 | }; |
30 | 31 | ||
31 | #define to_ep93xx_gpio_chip(c) container_of(c, struct ep93xx_gpio_chip, chip) | 32 | #define to_ep93xx_gpio_chip(c) container_of(c, struct ep93xx_gpio_chip, chip) |
@@ -111,15 +112,61 @@ static void ep93xx_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | |||
111 | { | 112 | { |
112 | struct ep93xx_gpio_chip *ep93xx_chip = to_ep93xx_gpio_chip(chip); | 113 | struct ep93xx_gpio_chip *ep93xx_chip = to_ep93xx_gpio_chip(chip); |
113 | u8 data_reg, data_dir_reg; | 114 | u8 data_reg, data_dir_reg; |
114 | int i; | 115 | int gpio, i; |
115 | 116 | ||
116 | data_reg = __raw_readb(ep93xx_chip->data_reg); | 117 | data_reg = __raw_readb(ep93xx_chip->data_reg); |
117 | data_dir_reg = __raw_readb(ep93xx_chip->data_dir_reg); | 118 | data_dir_reg = __raw_readb(ep93xx_chip->data_dir_reg); |
118 | 119 | ||
119 | for (i = 0; i < chip->ngpio; i++) | 120 | gpio = ep93xx_chip->chip.base; |
120 | seq_printf(s, "GPIO %s%d: %s %s\n", chip->label, i, | 121 | for (i = 0; i < chip->ngpio; i++, gpio++) { |
121 | (data_reg & (1 << i)) ? "set" : "clear", | 122 | int is_out = data_dir_reg & (1 << i); |
122 | (data_dir_reg & (1 << i)) ? "out" : "in"); | 123 | |
124 | seq_printf(s, " %s%d gpio-%-3d (%-12s) %s %s", | ||
125 | chip->label, i, gpio, | ||
126 | gpiochip_is_requested(chip, i) ? : "", | ||
127 | is_out ? "out" : "in ", | ||
128 | (data_reg & (1 << i)) ? "hi" : "lo"); | ||
129 | |||
130 | if (!is_out) { | ||
131 | int irq = gpio_to_irq(gpio); | ||
132 | struct irq_desc *desc = irq_desc + irq; | ||
133 | |||
134 | if (irq >= 0 && desc->action) { | ||
135 | char *trigger; | ||
136 | |||
137 | switch (desc->status & IRQ_TYPE_SENSE_MASK) { | ||
138 | case IRQ_TYPE_NONE: | ||
139 | trigger = "(default)"; | ||
140 | break; | ||
141 | case IRQ_TYPE_EDGE_FALLING: | ||
142 | trigger = "edge-falling"; | ||
143 | break; | ||
144 | case IRQ_TYPE_EDGE_RISING: | ||
145 | trigger = "edge-rising"; | ||
146 | break; | ||
147 | case IRQ_TYPE_EDGE_BOTH: | ||
148 | trigger = "edge-both"; | ||
149 | break; | ||
150 | case IRQ_TYPE_LEVEL_HIGH: | ||
151 | trigger = "level-high"; | ||
152 | break; | ||
153 | case IRQ_TYPE_LEVEL_LOW: | ||
154 | trigger = "level-low"; | ||
155 | break; | ||
156 | default: | ||
157 | trigger = "?trigger?"; | ||
158 | break; | ||
159 | } | ||
160 | |||
161 | seq_printf(s, " irq-%d %s%s", | ||
162 | irq, trigger, | ||
163 | (desc->status & IRQ_WAKEUP) | ||
164 | ? " wakeup" : ""); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | seq_printf(s, "\n"); | ||
169 | } | ||
123 | } | 170 | } |
124 | 171 | ||
125 | #define EP93XX_GPIO_BANK(name, dr, ddr, base_gpio) \ | 172 | #define EP93XX_GPIO_BANK(name, dr, ddr, base_gpio) \ |