aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2013-09-27 08:46:56 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-09-27 08:46:56 -0400
commit060c83fa0e8b4d2407d9d58e58917c343bfc29ce (patch)
tree1bce194264736e38240db0e807a4feb8ec759ed9 /arch/arm
parent44d94e8de54035e9f8584a92ed1ced68d0d8bb67 (diff)
parent098e30f6558f8950ed851e874d08bab91c9d4be7 (diff)
Merge branch 'ixp4-cleanup' into devel
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-ixp4xx/common.c49
-rw-r--r--arch/arm/mach-ixp4xx/dsmg600-setup.c65
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/platform.h39
-rw-r--r--arch/arm/mach-ixp4xx/ixdp425-setup.c8
-rw-r--r--arch/arm/mach-ixp4xx/nas100d-setup.c49
-rw-r--r--arch/arm/mach-ixp4xx/nslu2-setup.c17
6 files changed, 123 insertions, 104 deletions
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 5327decde5a0..9edaf4734fa8 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -81,6 +81,44 @@ void __init ixp4xx_map_io(void)
81 iotable_init(ixp4xx_io_desc, ARRAY_SIZE(ixp4xx_io_desc)); 81 iotable_init(ixp4xx_io_desc, ARRAY_SIZE(ixp4xx_io_desc));
82} 82}
83 83
84/*
85 * GPIO-functions
86 */
87/*
88 * The following converted to the real HW bits the gpio_line_config
89 */
90/* GPIO pin types */
91#define IXP4XX_GPIO_OUT 0x1
92#define IXP4XX_GPIO_IN 0x2
93
94/* GPIO signal types */
95#define IXP4XX_GPIO_LOW 0
96#define IXP4XX_GPIO_HIGH 1
97
98/* GPIO Clocks */
99#define IXP4XX_GPIO_CLK_0 14
100#define IXP4XX_GPIO_CLK_1 15
101
102static void gpio_line_config(u8 line, u32 direction)
103{
104 if (direction == IXP4XX_GPIO_IN)
105 *IXP4XX_GPIO_GPOER |= (1 << line);
106 else
107 *IXP4XX_GPIO_GPOER &= ~(1 << line);
108}
109
110static void gpio_line_get(u8 line, int *value)
111{
112 *value = (*IXP4XX_GPIO_GPINR >> line) & 0x1;
113}
114
115static void gpio_line_set(u8 line, int value)
116{
117 if (value == IXP4XX_GPIO_HIGH)
118 *IXP4XX_GPIO_GPOUTR |= (1 << line);
119 else if (value == IXP4XX_GPIO_LOW)
120 *IXP4XX_GPIO_GPOUTR &= ~(1 << line);
121}
84 122
85/************************************************************************* 123/*************************************************************************
86 * IXP4xx chipset IRQ handling 124 * IXP4xx chipset IRQ handling
@@ -117,17 +155,6 @@ static int ixp4xx_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
117 return -EINVAL; 155 return -EINVAL;
118} 156}
119 157
120int irq_to_gpio(unsigned int irq)
121{
122 int gpio = (irq < 32) ? irq2gpio[irq] : -EINVAL;
123
124 if (gpio == -1)
125 return -EINVAL;
126
127 return gpio;
128}
129EXPORT_SYMBOL(irq_to_gpio);
130
131static int ixp4xx_set_irq_type(struct irq_data *d, unsigned int type) 158static int ixp4xx_set_irq_type(struct irq_data *d, unsigned int type)
132{ 159{
133 int line = irq2gpio[d->irq]; 160 int line = irq2gpio[d->irq];
diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c
index 63de1b3fd06b..736dc692d540 100644
--- a/arch/arm/mach-ixp4xx/dsmg600-setup.c
+++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c
@@ -26,6 +26,7 @@
26#include <linux/reboot.h> 26#include <linux/reboot.h>
27#include <linux/i2c.h> 27#include <linux/i2c.h>
28#include <linux/i2c-gpio.h> 28#include <linux/i2c-gpio.h>
29#include <linux/gpio.h>
29 30
30#include <mach/hardware.h> 31#include <mach/hardware.h>
31 32
@@ -161,11 +162,8 @@ static struct platform_device *dsmg600_devices[] __initdata = {
161 162
162static void dsmg600_power_off(void) 163static void dsmg600_power_off(void)
163{ 164{
164 /* enable the pwr cntl gpio */ 165 /* enable the pwr cntl and drive it high */
165 gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT); 166 gpio_direction_output(DSMG600_PO_GPIO, 1);
166
167 /* poweroff */
168 gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
169} 167}
170 168
171/* This is used to make sure the power-button pusher is serious. The button 169/* This is used to make sure the power-button pusher is serious. The button
@@ -202,7 +200,7 @@ static void dsmg600_power_handler(unsigned long data)
202 ctrl_alt_del(); 200 ctrl_alt_del();
203 201
204 /* Change the state of the power LED to "blink" */ 202 /* Change the state of the power LED to "blink" */
205 gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW); 203 gpio_set_value(DSMG600_LED_PWR_GPIO, 0);
206 } else { 204 } else {
207 power_button_countdown = PBUTTON_HOLDDOWN_COUNT; 205 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
208 } 206 }
@@ -228,6 +226,40 @@ static void __init dsmg600_timer_init(void)
228 ixp4xx_timer_init(); 226 ixp4xx_timer_init();
229} 227}
230 228
229static int __init dsmg600_gpio_init(void)
230{
231 if (!machine_is_dsmg600())
232 return 0;
233
234 gpio_request(DSMG600_RB_GPIO, "reset button");
235 if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
236 IRQF_DISABLED | IRQF_TRIGGER_LOW,
237 "DSM-G600 reset button", NULL) < 0) {
238
239 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
240 gpio_to_irq(DSMG600_RB_GPIO));
241 }
242
243 /*
244 * The power button on the D-Link DSM-G600 is on GPIO 15, but
245 * it cannot handle interrupts on that GPIO line. So we'll
246 * have to poll it with a kernel timer.
247 */
248
249 /* Make sure that the power button GPIO is set up as an input */
250 gpio_request(DSMG600_PB_GPIO, "power button");
251 gpio_direction_input(DSMG600_PB_GPIO);
252 /* Request poweroff GPIO line */
253 gpio_request(DSMG600_PO_GPIO, "power off button");
254
255 /* Set the initial value for the power button IRQ handler */
256 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
257
258 mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
259 return 0;
260}
261device_initcall(dsmg600_gpio_init);
262
231static void __init dsmg600_init(void) 263static void __init dsmg600_init(void)
232{ 264{
233 ixp4xx_sys_init(); 265 ixp4xx_sys_init();
@@ -251,27 +283,6 @@ static void __init dsmg600_init(void)
251 platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices)); 283 platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
252 284
253 pm_power_off = dsmg600_power_off; 285 pm_power_off = dsmg600_power_off;
254
255 if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
256 IRQF_DISABLED | IRQF_TRIGGER_LOW,
257 "DSM-G600 reset button", NULL) < 0) {
258
259 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
260 gpio_to_irq(DSMG600_RB_GPIO));
261 }
262
263 /* The power button on the D-Link DSM-G600 is on GPIO 15, but
264 * it cannot handle interrupts on that GPIO line. So we'll
265 * have to poll it with a kernel timer.
266 */
267
268 /* Make sure that the power button GPIO is set up as an input */
269 gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
270
271 /* Set the initial value for the power button IRQ handler */
272 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
273
274 mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
275} 286}
276 287
277MACHINE_START(DSMG600, "D-Link DSM-G600 RevA") 288MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
diff --git a/arch/arm/mach-ixp4xx/include/mach/platform.h b/arch/arm/mach-ixp4xx/include/mach/platform.h
index 4c4c6a6f4526..75c4c6572ad0 100644
--- a/arch/arm/mach-ixp4xx/include/mach/platform.h
+++ b/arch/arm/mach-ixp4xx/include/mach/platform.h
@@ -131,44 +131,5 @@ struct pci_sys_data;
131extern int ixp4xx_setup(int nr, struct pci_sys_data *sys); 131extern int ixp4xx_setup(int nr, struct pci_sys_data *sys);
132extern struct pci_ops ixp4xx_ops; 132extern struct pci_ops ixp4xx_ops;
133 133
134/*
135 * GPIO-functions
136 */
137/*
138 * The following converted to the real HW bits the gpio_line_config
139 */
140/* GPIO pin types */
141#define IXP4XX_GPIO_OUT 0x1
142#define IXP4XX_GPIO_IN 0x2
143
144/* GPIO signal types */
145#define IXP4XX_GPIO_LOW 0
146#define IXP4XX_GPIO_HIGH 1
147
148/* GPIO Clocks */
149#define IXP4XX_GPIO_CLK_0 14
150#define IXP4XX_GPIO_CLK_1 15
151
152static inline void gpio_line_config(u8 line, u32 direction)
153{
154 if (direction == IXP4XX_GPIO_IN)
155 *IXP4XX_GPIO_GPOER |= (1 << line);
156 else
157 *IXP4XX_GPIO_GPOER &= ~(1 << line);
158}
159
160static inline void gpio_line_get(u8 line, int *value)
161{
162 *value = (*IXP4XX_GPIO_GPINR >> line) & 0x1;
163}
164
165static inline void gpio_line_set(u8 line, int value)
166{
167 if (value == IXP4XX_GPIO_HIGH)
168 *IXP4XX_GPIO_GPOUTR |= (1 << line);
169 else if (value == IXP4XX_GPIO_LOW)
170 *IXP4XX_GPIO_GPOUTR &= ~(1 << line);
171}
172
173#endif // __ASSEMBLY__ 134#endif // __ASSEMBLY__
174 135
diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c
index 22d688b7d513..e7b8befa8729 100644
--- a/arch/arm/mach-ixp4xx/ixdp425-setup.c
+++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c
@@ -20,6 +20,7 @@
20#include <linux/mtd/nand.h> 20#include <linux/mtd/nand.h>
21#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/gpio.h>
23#include <asm/types.h> 24#include <asm/types.h>
24#include <asm/setup.h> 25#include <asm/setup.h>
25#include <asm/memory.h> 26#include <asm/memory.h>
@@ -80,10 +81,10 @@ ixdp425_flash_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
80 81
81 if (ctrl & NAND_CTRL_CHANGE) { 82 if (ctrl & NAND_CTRL_CHANGE) {
82 if (ctrl & NAND_NCE) { 83 if (ctrl & NAND_NCE) {
83 gpio_line_set(IXDP425_NAND_NCE_PIN, IXP4XX_GPIO_LOW); 84 gpio_set_value(IXDP425_NAND_NCE_PIN, 0);
84 udelay(5); 85 udelay(5);
85 } else 86 } else
86 gpio_line_set(IXDP425_NAND_NCE_PIN, IXP4XX_GPIO_HIGH); 87 gpio_set_value(IXDP425_NAND_NCE_PIN, 1);
87 88
88 offset = (ctrl & NAND_CLE) ? IXDP425_NAND_CMD_BYTE : 0; 89 offset = (ctrl & NAND_CLE) ? IXDP425_NAND_CMD_BYTE : 0;
89 offset |= (ctrl & NAND_ALE) ? IXDP425_NAND_ADDR_BYTE : 0; 90 offset |= (ctrl & NAND_ALE) ? IXDP425_NAND_ADDR_BYTE : 0;
@@ -227,7 +228,8 @@ static void __init ixdp425_init(void)
227 ixdp425_flash_nand_resource.start = IXP4XX_EXP_BUS_BASE(3), 228 ixdp425_flash_nand_resource.start = IXP4XX_EXP_BUS_BASE(3),
228 ixdp425_flash_nand_resource.end = IXP4XX_EXP_BUS_BASE(3) + 0x10 - 1; 229 ixdp425_flash_nand_resource.end = IXP4XX_EXP_BUS_BASE(3) + 0x10 - 1;
229 230
230 gpio_line_config(IXDP425_NAND_NCE_PIN, IXP4XX_GPIO_OUT); 231 gpio_request(IXDP425_NAND_NCE_PIN, "NAND NCE pin");
232 gpio_direction_output(IXDP425_NAND_NCE_PIN, 0);
231 233
232 /* Configure expansion bus for NAND Flash */ 234 /* Configure expansion bus for NAND Flash */
233 *IXP4XX_EXP_CS3 = IXP4XX_EXP_BUS_CS_EN | 235 *IXP4XX_EXP_CS3 = IXP4XX_EXP_BUS_CS_EN |
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c
index ed667ce9f576..507cb5233537 100644
--- a/arch/arm/mach-ixp4xx/nas100d-setup.c
+++ b/arch/arm/mach-ixp4xx/nas100d-setup.c
@@ -184,11 +184,8 @@ static void nas100d_power_off(void)
184{ 184{
185 /* This causes the box to drop the power and go dead. */ 185 /* This causes the box to drop the power and go dead. */
186 186
187 /* enable the pwr cntl gpio */ 187 /* enable the pwr cntl gpio and assert power off */
188 gpio_line_config(NAS100D_PO_GPIO, IXP4XX_GPIO_OUT); 188 gpio_direction_output(NAS100D_PO_GPIO, 1);
189
190 /* do the deed */
191 gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH);
192} 189}
193 190
194/* This is used to make sure the power-button pusher is serious. The button 191/* This is used to make sure the power-button pusher is serious. The button
@@ -225,7 +222,7 @@ static void nas100d_power_handler(unsigned long data)
225 ctrl_alt_del(); 222 ctrl_alt_del();
226 223
227 /* Change the state of the power LED to "blink" */ 224 /* Change the state of the power LED to "blink" */
228 gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW); 225 gpio_set_value(NAS100D_LED_PWR_GPIO, 0);
229 } else { 226 } else {
230 power_button_countdown = PBUTTON_HOLDDOWN_COUNT; 227 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
231 } 228 }
@@ -242,6 +239,33 @@ static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
242 return IRQ_HANDLED; 239 return IRQ_HANDLED;
243} 240}
244 241
242static int __init nas100d_gpio_init(void)
243{
244 if (!machine_is_nas100d())
245 return 0;
246
247 /*
248 * The power button on the Iomega NAS100d is on GPIO 14, but
249 * it cannot handle interrupts on that GPIO line. So we'll
250 * have to poll it with a kernel timer.
251 */
252
253 /* Request the power off GPIO */
254 gpio_request(NAS100D_PO_GPIO, "power off");
255
256 /* Make sure that the power button GPIO is set up as an input */
257 gpio_request(NAS100D_PB_GPIO, "power button");
258 gpio_direction_input(NAS100D_PB_GPIO);
259
260 /* Set the initial value for the power button IRQ handler */
261 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
262
263 mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
264
265 return 0;
266}
267device_initcall(nas100d_gpio_init);
268
245static void __init nas100d_init(void) 269static void __init nas100d_init(void)
246{ 270{
247 uint8_t __iomem *f; 271 uint8_t __iomem *f;
@@ -278,19 +302,6 @@ static void __init nas100d_init(void)
278 gpio_to_irq(NAS100D_RB_GPIO)); 302 gpio_to_irq(NAS100D_RB_GPIO));
279 } 303 }
280 304
281 /* The power button on the Iomega NAS100d is on GPIO 14, but
282 * it cannot handle interrupts on that GPIO line. So we'll
283 * have to poll it with a kernel timer.
284 */
285
286 /* Make sure that the power button GPIO is set up as an input */
287 gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
288
289 /* Set the initial value for the power button IRQ handler */
290 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
291
292 mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
293
294 /* 305 /*
295 * Map in a portion of the flash and read the MAC address. 306 * Map in a portion of the flash and read the MAC address.
296 * Since it is stored in BE in the flash itself, we need to 307 * Since it is stored in BE in the flash itself, we need to
diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c
index 7e55236c26ea..ba5f1cda2a9d 100644
--- a/arch/arm/mach-ixp4xx/nslu2-setup.c
+++ b/arch/arm/mach-ixp4xx/nslu2-setup.c
@@ -197,11 +197,8 @@ static void nslu2_power_off(void)
197{ 197{
198 /* This causes the box to drop the power and go dead. */ 198 /* This causes the box to drop the power and go dead. */
199 199
200 /* enable the pwr cntl gpio */ 200 /* enable the pwr cntl gpio and assert power off */
201 gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT); 201 gpio_direction_output(NSLU2_PO_GPIO, 1);
202
203 /* do the deed */
204 gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
205} 202}
206 203
207static irqreturn_t nslu2_power_handler(int irq, void *dev_id) 204static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
@@ -223,6 +220,16 @@ static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
223 return IRQ_HANDLED; 220 return IRQ_HANDLED;
224} 221}
225 222
223static int __init nslu2_gpio_init(void)
224{
225 if (!machine_is_nslu2())
226 return 0;
227
228 /* Request the power off GPIO */
229 return gpio_request(NSLU2_PO_GPIO, "power off");
230}
231device_initcall(nslu2_gpio_init);
232
226static void __init nslu2_timer_init(void) 233static void __init nslu2_timer_init(void)
227{ 234{
228 /* The xtal on this machine is non-standard. */ 235 /* The xtal on this machine is non-standard. */