diff options
author | Sean MacLennan <smaclennan@pikatech.com> | 2009-04-06 07:58:25 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-05-21 01:42:56 -0400 |
commit | 805e324b7fbddf9f420f0ea09eb61c21777b0526 (patch) | |
tree | a162dd9f4e1b06ef85f3458eff869a3443915f74 /arch/powerpc/platforms/44x | |
parent | 54c181935d2a2d46a1b2f00cbb25acc35e4f5ee2 (diff) |
powerpc: Update Warp to use leds-gpio driver
Now that leds-gpio is a proper OF platform driver, the Warp can use
the leds-gpio driver rather than the old out-of-kernel driver.
One side-effect is the leds-gpio driver always turns the leds off
while the old driver left them alone. So we have to set them back to
the correct settings.
Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/platforms/44x')
-rw-r--r-- | arch/powerpc/platforms/44x/warp.c | 76 |
1 files changed, 35 insertions, 41 deletions
diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c index 960edf89be51..c5118802a281 100644 --- a/arch/powerpc/platforms/44x/warp.c +++ b/arch/powerpc/platforms/44x/warp.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * PIKA Warp(tm) board specific routines | 2 | * PIKA Warp(tm) board specific routines |
3 | * | 3 | * |
4 | * Copyright (c) 2008 PIKA Technologies | 4 | * Copyright (c) 2008-2009 PIKA Technologies |
5 | * Sean MacLennan <smaclennan@pikatech.com> | 5 | * Sean MacLennan <smaclennan@pikatech.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify it | 7 | * This program is free software; you can redistribute it and/or modify it |
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/i2c.h> | 15 | #include <linux/i2c.h> |
16 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
17 | #include <linux/delay.h> | 17 | #include <linux/delay.h> |
18 | #include <linux/of_gpio.h> | ||
18 | 19 | ||
19 | #include <asm/machdep.h> | 20 | #include <asm/machdep.h> |
20 | #include <asm/prom.h> | 21 | #include <asm/prom.h> |
@@ -23,6 +24,7 @@ | |||
23 | #include <asm/uic.h> | 24 | #include <asm/uic.h> |
24 | #include <asm/ppc4xx.h> | 25 | #include <asm/ppc4xx.h> |
25 | 26 | ||
27 | |||
26 | static __initdata struct of_device_id warp_of_bus[] = { | 28 | static __initdata struct of_device_id warp_of_bus[] = { |
27 | { .compatible = "ibm,plb4", }, | 29 | { .compatible = "ibm,plb4", }, |
28 | { .compatible = "ibm,opb", }, | 30 | { .compatible = "ibm,opb", }, |
@@ -55,6 +57,8 @@ define_machine(warp) { | |||
55 | }; | 57 | }; |
56 | 58 | ||
57 | 59 | ||
60 | static u32 post_info; | ||
61 | |||
58 | /* I am not sure this is the best place for this... */ | 62 | /* I am not sure this is the best place for this... */ |
59 | static int __init warp_post_info(void) | 63 | static int __init warp_post_info(void) |
60 | { | 64 | { |
@@ -77,21 +81,21 @@ static int __init warp_post_info(void) | |||
77 | 81 | ||
78 | iounmap(fpga); | 82 | iounmap(fpga); |
79 | 83 | ||
80 | if (post1 || post2) | 84 | if (post1 || post2) { |
81 | printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2); | 85 | printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2); |
82 | else | 86 | post_info = 1; |
87 | } else | ||
83 | printk(KERN_INFO "Warp POST OK\n"); | 88 | printk(KERN_INFO "Warp POST OK\n"); |
84 | 89 | ||
85 | return 0; | 90 | return 0; |
86 | } | 91 | } |
87 | machine_late_initcall(warp, warp_post_info); | ||
88 | 92 | ||
89 | 93 | ||
90 | #ifdef CONFIG_SENSORS_AD7414 | 94 | #ifdef CONFIG_SENSORS_AD7414 |
91 | 95 | ||
92 | static LIST_HEAD(dtm_shutdown_list); | 96 | static LIST_HEAD(dtm_shutdown_list); |
93 | static void __iomem *dtm_fpga; | 97 | static void __iomem *dtm_fpga; |
94 | static void __iomem *gpio_base; | 98 | static unsigned green_led, red_led; |
95 | 99 | ||
96 | 100 | ||
97 | struct dtm_shutdown { | 101 | struct dtm_shutdown { |
@@ -134,14 +138,17 @@ int pika_dtm_unregister_shutdown(void (*func)(void *arg), void *arg) | |||
134 | static irqreturn_t temp_isr(int irq, void *context) | 138 | static irqreturn_t temp_isr(int irq, void *context) |
135 | { | 139 | { |
136 | struct dtm_shutdown *shutdown; | 140 | struct dtm_shutdown *shutdown; |
141 | int value = 1; | ||
137 | 142 | ||
138 | local_irq_disable(); | 143 | local_irq_disable(); |
139 | 144 | ||
145 | gpio_set_value(green_led, 0); | ||
146 | |||
140 | /* Run through the shutdown list. */ | 147 | /* Run through the shutdown list. */ |
141 | list_for_each_entry(shutdown, &dtm_shutdown_list, list) | 148 | list_for_each_entry(shutdown, &dtm_shutdown_list, list) |
142 | shutdown->func(shutdown->arg); | 149 | shutdown->func(shutdown->arg); |
143 | 150 | ||
144 | printk(KERN_EMERG "\n\nCritical Temperature Shutdown\n"); | 151 | printk(KERN_EMERG "\n\nCritical Temperature Shutdown\n\n"); |
145 | 152 | ||
146 | while (1) { | 153 | while (1) { |
147 | if (dtm_fpga) { | 154 | if (dtm_fpga) { |
@@ -149,52 +156,34 @@ static irqreturn_t temp_isr(int irq, void *context) | |||
149 | out_be32(dtm_fpga + 0x14, reset); | 156 | out_be32(dtm_fpga + 0x14, reset); |
150 | } | 157 | } |
151 | 158 | ||
152 | if (gpio_base) { | 159 | gpio_set_value(red_led, value); |
153 | unsigned leds = in_be32(gpio_base); | 160 | value ^= 1; |
154 | |||
155 | /* green off, red toggle */ | ||
156 | leds &= ~0x80000000; | ||
157 | leds ^= 0x40000000; | ||
158 | |||
159 | out_be32(gpio_base, leds); | ||
160 | } | ||
161 | |||
162 | mdelay(500); | 161 | mdelay(500); |
163 | } | 162 | } |
164 | } | 163 | } |
165 | 164 | ||
166 | static int pika_setup_leds(void) | 165 | static int pika_setup_leds(void) |
167 | { | 166 | { |
168 | struct device_node *np; | 167 | struct device_node *np, *child; |
169 | const u32 *gpios; | ||
170 | int len; | ||
171 | 168 | ||
172 | np = of_find_compatible_node(NULL, NULL, "linux,gpio-led"); | 169 | np = of_find_compatible_node(NULL, NULL, "gpio-leds"); |
173 | if (!np) { | 170 | if (!np) { |
174 | printk(KERN_ERR __FILE__ ": Unable to find gpio-led\n"); | 171 | printk(KERN_ERR __FILE__ ": Unable to find leds\n"); |
175 | return -ENOENT; | ||
176 | } | ||
177 | |||
178 | gpios = of_get_property(np, "gpios", &len); | ||
179 | of_node_put(np); | ||
180 | if (!gpios || len < 4) { | ||
181 | printk(KERN_ERR __FILE__ | ||
182 | ": Unable to get gpios property (%d)\n", len); | ||
183 | return -ENOENT; | 172 | return -ENOENT; |
184 | } | 173 | } |
185 | 174 | ||
186 | np = of_find_node_by_phandle(gpios[0]); | 175 | for_each_child_of_node(np, child) |
187 | if (!np) { | 176 | if (strcmp(child->name, "green") == 0) { |
188 | printk(KERN_ERR __FILE__ ": Unable to find gpio\n"); | 177 | green_led = of_get_gpio(child, 0); |
189 | return -ENOENT; | 178 | /* Turn back on the green LED */ |
190 | } | 179 | gpio_set_value(green_led, 1); |
180 | } else if (strcmp(child->name, "red") == 0) { | ||
181 | red_led = of_get_gpio(child, 0); | ||
182 | /* Set based on post */ | ||
183 | gpio_set_value(red_led, post_info); | ||
184 | } | ||
191 | 185 | ||
192 | gpio_base = of_iomap(np, 0); | ||
193 | of_node_put(np); | 186 | of_node_put(np); |
194 | if (!gpio_base) { | ||
195 | printk(KERN_ERR __FILE__ ": Unable to map gpio"); | ||
196 | return -ENOMEM; | ||
197 | } | ||
198 | 187 | ||
199 | return 0; | 188 | return 0; |
200 | } | 189 | } |
@@ -270,10 +259,10 @@ static int pika_dtm_thread(void __iomem *fpga) | |||
270 | } | 259 | } |
271 | 260 | ||
272 | found_it: | 261 | found_it: |
273 | i2c_put_adapter(adap); | ||
274 | |||
275 | pika_setup_critical_temp(client); | 262 | pika_setup_critical_temp(client); |
276 | 263 | ||
264 | i2c_put_adapter(adap); | ||
265 | |||
277 | printk(KERN_INFO "PIKA DTM thread running.\n"); | 266 | printk(KERN_INFO "PIKA DTM thread running.\n"); |
278 | 267 | ||
279 | while (!kthread_should_stop()) { | 268 | while (!kthread_should_stop()) { |
@@ -311,6 +300,9 @@ static int __init pika_dtm_start(void) | |||
311 | if (dtm_fpga == NULL) | 300 | if (dtm_fpga == NULL) |
312 | return -ENOENT; | 301 | return -ENOENT; |
313 | 302 | ||
303 | /* Must get post info before thread starts. */ | ||
304 | warp_post_info(); | ||
305 | |||
314 | dtm_thread = kthread_run(pika_dtm_thread, dtm_fpga, "pika-dtm"); | 306 | dtm_thread = kthread_run(pika_dtm_thread, dtm_fpga, "pika-dtm"); |
315 | if (IS_ERR(dtm_thread)) { | 307 | if (IS_ERR(dtm_thread)) { |
316 | iounmap(dtm_fpga); | 308 | iounmap(dtm_fpga); |
@@ -333,6 +325,8 @@ int pika_dtm_unregister_shutdown(void (*func)(void *arg), void *arg) | |||
333 | return 0; | 325 | return 0; |
334 | } | 326 | } |
335 | 327 | ||
328 | machine_late_initcall(warp, warp_post_info); | ||
329 | |||
336 | #endif | 330 | #endif |
337 | 331 | ||
338 | EXPORT_SYMBOL(pika_dtm_register_shutdown); | 332 | EXPORT_SYMBOL(pika_dtm_register_shutdown); |