diff options
Diffstat (limited to 'arch/powerpc/platforms/44x/warp.c')
-rw-r--r-- | arch/powerpc/platforms/44x/warp.c | 63 |
1 files changed, 21 insertions, 42 deletions
diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c index 42e09a9f77e2..e5c1b096c3e1 100644 --- a/arch/powerpc/platforms/44x/warp.c +++ b/arch/powerpc/platforms/44x/warp.c | |||
@@ -16,6 +16,7 @@ | |||
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 | #include <linux/of_gpio.h> |
19 | #include <linux/of_i2c.h> | ||
19 | 20 | ||
20 | #include <asm/machdep.h> | 21 | #include <asm/machdep.h> |
21 | #include <asm/prom.h> | 22 | #include <asm/prom.h> |
@@ -63,9 +64,6 @@ define_machine(warp) { | |||
63 | }; | 64 | }; |
64 | 65 | ||
65 | 66 | ||
66 | static u32 post_info; | ||
67 | |||
68 | /* I am not sure this is the best place for this... */ | ||
69 | static int __init warp_post_info(void) | 67 | static int __init warp_post_info(void) |
70 | { | 68 | { |
71 | struct device_node *np; | 69 | struct device_node *np; |
@@ -87,10 +85,9 @@ static int __init warp_post_info(void) | |||
87 | 85 | ||
88 | iounmap(fpga); | 86 | iounmap(fpga); |
89 | 87 | ||
90 | if (post1 || post2) { | 88 | if (post1 || post2) |
91 | printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2); | 89 | printk(KERN_INFO "Warp POST %08x %08x\n", post1, post2); |
92 | post_info = 1; | 90 | else |
93 | } else | ||
94 | printk(KERN_INFO "Warp POST OK\n"); | 91 | printk(KERN_INFO "Warp POST OK\n"); |
95 | 92 | ||
96 | return 0; | 93 | return 0; |
@@ -166,6 +163,9 @@ static irqreturn_t temp_isr(int irq, void *context) | |||
166 | value ^= 1; | 163 | value ^= 1; |
167 | mdelay(500); | 164 | mdelay(500); |
168 | } | 165 | } |
166 | |||
167 | /* Not reached */ | ||
168 | return IRQ_HANDLED; | ||
169 | } | 169 | } |
170 | 170 | ||
171 | static int pika_setup_leds(void) | 171 | static int pika_setup_leds(void) |
@@ -179,24 +179,19 @@ static int pika_setup_leds(void) | |||
179 | } | 179 | } |
180 | 180 | ||
181 | for_each_child_of_node(np, child) | 181 | for_each_child_of_node(np, child) |
182 | if (strcmp(child->name, "green") == 0) { | 182 | if (strcmp(child->name, "green") == 0) |
183 | green_led = of_get_gpio(child, 0); | 183 | green_led = of_get_gpio(child, 0); |
184 | /* Turn back on the green LED */ | 184 | else if (strcmp(child->name, "red") == 0) |
185 | gpio_set_value(green_led, 1); | ||
186 | } else if (strcmp(child->name, "red") == 0) { | ||
187 | red_led = of_get_gpio(child, 0); | 185 | red_led = of_get_gpio(child, 0); |
188 | /* Set based on post */ | ||
189 | gpio_set_value(red_led, post_info); | ||
190 | } | ||
191 | 186 | ||
192 | of_node_put(np); | 187 | of_node_put(np); |
193 | 188 | ||
194 | return 0; | 189 | return 0; |
195 | } | 190 | } |
196 | 191 | ||
197 | static void pika_setup_critical_temp(struct i2c_client *client) | 192 | static void pika_setup_critical_temp(struct device_node *np, |
193 | struct i2c_client *client) | ||
198 | { | 194 | { |
199 | struct device_node *np; | ||
200 | int irq, rc; | 195 | int irq, rc; |
201 | 196 | ||
202 | /* Do this before enabling critical temp interrupt since we | 197 | /* Do this before enabling critical temp interrupt since we |
@@ -208,14 +203,7 @@ static void pika_setup_critical_temp(struct i2c_client *client) | |||
208 | i2c_smbus_write_byte_data(client, 2, 65); /* Thigh */ | 203 | i2c_smbus_write_byte_data(client, 2, 65); /* Thigh */ |
209 | i2c_smbus_write_byte_data(client, 3, 0); /* Tlow */ | 204 | i2c_smbus_write_byte_data(client, 3, 0); /* Tlow */ |
210 | 205 | ||
211 | np = of_find_compatible_node(NULL, NULL, "adi,ad7414"); | ||
212 | if (np == NULL) { | ||
213 | printk(KERN_ERR __FILE__ ": Unable to find ad7414\n"); | ||
214 | return; | ||
215 | } | ||
216 | |||
217 | irq = irq_of_parse_and_map(np, 0); | 206 | irq = irq_of_parse_and_map(np, 0); |
218 | of_node_put(np); | ||
219 | if (irq == NO_IRQ) { | 207 | if (irq == NO_IRQ) { |
220 | printk(KERN_ERR __FILE__ ": Unable to get ad7414 irq\n"); | 208 | printk(KERN_ERR __FILE__ ": Unable to get ad7414 irq\n"); |
221 | return; | 209 | return; |
@@ -244,32 +232,24 @@ static inline void pika_dtm_check_fan(void __iomem *fpga) | |||
244 | 232 | ||
245 | static int pika_dtm_thread(void __iomem *fpga) | 233 | static int pika_dtm_thread(void __iomem *fpga) |
246 | { | 234 | { |
247 | struct i2c_adapter *adap; | 235 | struct device_node *np; |
248 | struct i2c_client *client; | 236 | struct i2c_client *client; |
249 | 237 | ||
250 | /* We loop in case either driver was compiled as a module and | 238 | np = of_find_compatible_node(NULL, NULL, "adi,ad7414"); |
251 | * has not been insmoded yet. | 239 | if (np == NULL) |
252 | */ | 240 | return -ENOENT; |
253 | while (!(adap = i2c_get_adapter(0))) { | ||
254 | set_current_state(TASK_INTERRUPTIBLE); | ||
255 | schedule_timeout(HZ); | ||
256 | } | ||
257 | |||
258 | while (1) { | ||
259 | list_for_each_entry(client, &adap->clients, list) | ||
260 | if (client->addr == 0x4a) | ||
261 | goto found_it; | ||
262 | 241 | ||
263 | set_current_state(TASK_INTERRUPTIBLE); | 242 | client = of_find_i2c_device_by_node(np); |
264 | schedule_timeout(HZ); | 243 | if (client == NULL) { |
244 | of_node_put(np); | ||
245 | return -ENOENT; | ||
265 | } | 246 | } |
266 | 247 | ||
267 | found_it: | 248 | pika_setup_critical_temp(np, client); |
268 | pika_setup_critical_temp(client); | ||
269 | 249 | ||
270 | i2c_put_adapter(adap); | 250 | of_node_put(np); |
271 | 251 | ||
272 | printk(KERN_INFO "PIKA DTM thread running.\n"); | 252 | printk(KERN_INFO "Warp DTM thread running.\n"); |
273 | 253 | ||
274 | while (!kthread_should_stop()) { | 254 | while (!kthread_should_stop()) { |
275 | int val; | 255 | int val; |
@@ -291,7 +271,6 @@ found_it: | |||
291 | return 0; | 271 | return 0; |
292 | } | 272 | } |
293 | 273 | ||
294 | |||
295 | static int __init pika_dtm_start(void) | 274 | static int __init pika_dtm_start(void) |
296 | { | 275 | { |
297 | struct task_struct *dtm_thread; | 276 | struct task_struct *dtm_thread; |