aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/44x/warp.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/platforms/44x/warp.c')
-rw-r--r--arch/powerpc/platforms/44x/warp.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
index 960edf89be51..42e09a9f77e2 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
26static __initdata struct of_device_id warp_of_bus[] = { 28static __initdata struct of_device_id warp_of_bus[] = {
27 { .compatible = "ibm,plb4", }, 29 { .compatible = "ibm,plb4", },
28 { .compatible = "ibm,opb", }, 30 { .compatible = "ibm,opb", },
@@ -41,7 +43,13 @@ static int __init warp_probe(void)
41{ 43{
42 unsigned long root = of_get_flat_dt_root(); 44 unsigned long root = of_get_flat_dt_root();
43 45
44 return of_flat_dt_is_compatible(root, "pika,warp"); 46 if (!of_flat_dt_is_compatible(root, "pika,warp"))
47 return 0;
48
49 /* For __dma_alloc_coherent */
50 ISA_DMA_THRESHOLD = ~0L;
51
52 return 1;
45} 53}
46 54
47define_machine(warp) { 55define_machine(warp) {
@@ -55,6 +63,8 @@ define_machine(warp) {
55}; 63};
56 64
57 65
66static u32 post_info;
67
58/* I am not sure this is the best place for this... */ 68/* I am not sure this is the best place for this... */
59static int __init warp_post_info(void) 69static int __init warp_post_info(void)
60{ 70{
@@ -77,21 +87,21 @@ static int __init warp_post_info(void)
77 87
78 iounmap(fpga); 88 iounmap(fpga);
79 89
80 if (post1 || post2) 90 if (post1 || post2) {
81 printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2); 91 printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2);
82 else 92 post_info = 1;
93 } else
83 printk(KERN_INFO "Warp POST OK\n"); 94 printk(KERN_INFO "Warp POST OK\n");
84 95
85 return 0; 96 return 0;
86} 97}
87machine_late_initcall(warp, warp_post_info);
88 98
89 99
90#ifdef CONFIG_SENSORS_AD7414 100#ifdef CONFIG_SENSORS_AD7414
91 101
92static LIST_HEAD(dtm_shutdown_list); 102static LIST_HEAD(dtm_shutdown_list);
93static void __iomem *dtm_fpga; 103static void __iomem *dtm_fpga;
94static void __iomem *gpio_base; 104static unsigned green_led, red_led;
95 105
96 106
97struct dtm_shutdown { 107struct dtm_shutdown {
@@ -134,14 +144,17 @@ int pika_dtm_unregister_shutdown(void (*func)(void *arg), void *arg)
134static irqreturn_t temp_isr(int irq, void *context) 144static irqreturn_t temp_isr(int irq, void *context)
135{ 145{
136 struct dtm_shutdown *shutdown; 146 struct dtm_shutdown *shutdown;
147 int value = 1;
137 148
138 local_irq_disable(); 149 local_irq_disable();
139 150
151 gpio_set_value(green_led, 0);
152
140 /* Run through the shutdown list. */ 153 /* Run through the shutdown list. */
141 list_for_each_entry(shutdown, &dtm_shutdown_list, list) 154 list_for_each_entry(shutdown, &dtm_shutdown_list, list)
142 shutdown->func(shutdown->arg); 155 shutdown->func(shutdown->arg);
143 156
144 printk(KERN_EMERG "\n\nCritical Temperature Shutdown\n"); 157 printk(KERN_EMERG "\n\nCritical Temperature Shutdown\n\n");
145 158
146 while (1) { 159 while (1) {
147 if (dtm_fpga) { 160 if (dtm_fpga) {
@@ -149,52 +162,34 @@ static irqreturn_t temp_isr(int irq, void *context)
149 out_be32(dtm_fpga + 0x14, reset); 162 out_be32(dtm_fpga + 0x14, reset);
150 } 163 }
151 164
152 if (gpio_base) { 165 gpio_set_value(red_led, value);
153 unsigned leds = in_be32(gpio_base); 166 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); 167 mdelay(500);
163 } 168 }
164} 169}
165 170
166static int pika_setup_leds(void) 171static int pika_setup_leds(void)
167{ 172{
168 struct device_node *np; 173 struct device_node *np, *child;
169 const u32 *gpios;
170 int len;
171 174
172 np = of_find_compatible_node(NULL, NULL, "linux,gpio-led"); 175 np = of_find_compatible_node(NULL, NULL, "gpio-leds");
173 if (!np) { 176 if (!np) {
174 printk(KERN_ERR __FILE__ ": Unable to find gpio-led\n"); 177 printk(KERN_ERR __FILE__ ": Unable to find leds\n");
175 return -ENOENT; 178 return -ENOENT;
176 } 179 }
177 180
178 gpios = of_get_property(np, "gpios", &len); 181 for_each_child_of_node(np, child)
179 of_node_put(np); 182 if (strcmp(child->name, "green") == 0) {
180 if (!gpios || len < 4) { 183 green_led = of_get_gpio(child, 0);
181 printk(KERN_ERR __FILE__ 184 /* Turn back on the green LED */
182 ": Unable to get gpios property (%d)\n", len); 185 gpio_set_value(green_led, 1);
183 return -ENOENT; 186 } else if (strcmp(child->name, "red") == 0) {
184 } 187 red_led = of_get_gpio(child, 0);
185 188 /* Set based on post */
186 np = of_find_node_by_phandle(gpios[0]); 189 gpio_set_value(red_led, post_info);
187 if (!np) { 190 }
188 printk(KERN_ERR __FILE__ ": Unable to find gpio\n");
189 return -ENOENT;
190 }
191 191
192 gpio_base = of_iomap(np, 0);
193 of_node_put(np); 192 of_node_put(np);
194 if (!gpio_base) {
195 printk(KERN_ERR __FILE__ ": Unable to map gpio");
196 return -ENOMEM;
197 }
198 193
199 return 0; 194 return 0;
200} 195}
@@ -270,10 +265,10 @@ static int pika_dtm_thread(void __iomem *fpga)
270 } 265 }
271 266
272found_it: 267found_it:
273 i2c_put_adapter(adap);
274
275 pika_setup_critical_temp(client); 268 pika_setup_critical_temp(client);
276 269
270 i2c_put_adapter(adap);
271
277 printk(KERN_INFO "PIKA DTM thread running.\n"); 272 printk(KERN_INFO "PIKA DTM thread running.\n");
278 273
279 while (!kthread_should_stop()) { 274 while (!kthread_should_stop()) {
@@ -311,6 +306,9 @@ static int __init pika_dtm_start(void)
311 if (dtm_fpga == NULL) 306 if (dtm_fpga == NULL)
312 return -ENOENT; 307 return -ENOENT;
313 308
309 /* Must get post info before thread starts. */
310 warp_post_info();
311
314 dtm_thread = kthread_run(pika_dtm_thread, dtm_fpga, "pika-dtm"); 312 dtm_thread = kthread_run(pika_dtm_thread, dtm_fpga, "pika-dtm");
315 if (IS_ERR(dtm_thread)) { 313 if (IS_ERR(dtm_thread)) {
316 iounmap(dtm_fpga); 314 iounmap(dtm_fpga);
@@ -333,6 +331,8 @@ int pika_dtm_unregister_shutdown(void (*func)(void *arg), void *arg)
333 return 0; 331 return 0;
334} 332}
335 333
334machine_late_initcall(warp, warp_post_info);
335
336#endif 336#endif
337 337
338EXPORT_SYMBOL(pika_dtm_register_shutdown); 338EXPORT_SYMBOL(pika_dtm_register_shutdown);