aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms
diff options
context:
space:
mode:
authorSean MacLennan <smaclennan@pikatech.com>2009-06-19 15:43:59 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-06-26 00:37:23 -0400
commit3984114f056203d833251af85501721f7b00fd18 (patch)
tree4d71c231f803d8ececa5c81fc07332f11dd7e996 /arch/powerpc/platforms
parentb810c6ec5c659c80b3641580b112db877a0f1f45 (diff)
powerpc/warp: Platform fix for i2c change
A change to the i2c subsystem breaks the warp platform code. The patch is cleaner anyway, the old way was a bit crufty. For those with keen eyes, the gratuitous change in the string from PIKA to Warp is just so the logs look a bit nicer. The following two lines tend to be printed one after another. Warp POST OK Warp DTM thread running. Yeah, this will be the third patch to warp.c submitted in this release.... Cheers, Sean The i2c_client struct changed, breaking the code that looked for the ad7414 chip. Use the new of_find_i2c_device_by_node function added in 2.6.29. Signed-off-by: Sean MacLennan <smaclennan@pikatech.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r--arch/powerpc/platforms/44x/warp.c44
1 files changed, 14 insertions, 30 deletions
diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
index 42e09a9f77e2..0362c88f47d7 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>
@@ -65,7 +66,6 @@ define_machine(warp) {
65 66
66static u32 post_info; 67static u32 post_info;
67 68
68/* I am not sure this is the best place for this... */
69static int __init warp_post_info(void) 69static int __init warp_post_info(void)
70{ 70{
71 struct device_node *np; 71 struct device_node *np;
@@ -194,9 +194,9 @@ static int pika_setup_leds(void)
194 return 0; 194 return 0;
195} 195}
196 196
197static void pika_setup_critical_temp(struct i2c_client *client) 197static void pika_setup_critical_temp(struct device_node *np,
198 struct i2c_client *client)
198{ 199{
199 struct device_node *np;
200 int irq, rc; 200 int irq, rc;
201 201
202 /* Do this before enabling critical temp interrupt since we 202 /* Do this before enabling critical temp interrupt since we
@@ -208,14 +208,7 @@ static void pika_setup_critical_temp(struct i2c_client *client)
208 i2c_smbus_write_byte_data(client, 2, 65); /* Thigh */ 208 i2c_smbus_write_byte_data(client, 2, 65); /* Thigh */
209 i2c_smbus_write_byte_data(client, 3, 0); /* Tlow */ 209 i2c_smbus_write_byte_data(client, 3, 0); /* Tlow */
210 210
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); 211 irq = irq_of_parse_and_map(np, 0);
218 of_node_put(np);
219 if (irq == NO_IRQ) { 212 if (irq == NO_IRQ) {
220 printk(KERN_ERR __FILE__ ": Unable to get ad7414 irq\n"); 213 printk(KERN_ERR __FILE__ ": Unable to get ad7414 irq\n");
221 return; 214 return;
@@ -244,32 +237,24 @@ static inline void pika_dtm_check_fan(void __iomem *fpga)
244 237
245static int pika_dtm_thread(void __iomem *fpga) 238static int pika_dtm_thread(void __iomem *fpga)
246{ 239{
247 struct i2c_adapter *adap; 240 struct device_node *np;
248 struct i2c_client *client; 241 struct i2c_client *client;
249 242
250 /* We loop in case either driver was compiled as a module and 243 np = of_find_compatible_node(NULL, NULL, "adi,ad7414");
251 * has not been insmoded yet. 244 if (np == NULL)
252 */ 245 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 246
263 set_current_state(TASK_INTERRUPTIBLE); 247 client = of_find_i2c_device_by_node(np);
264 schedule_timeout(HZ); 248 if (client == NULL) {
249 of_node_put(np);
250 return -ENOENT;
265 } 251 }
266 252
267found_it: 253 pika_setup_critical_temp(np, client);
268 pika_setup_critical_temp(client);
269 254
270 i2c_put_adapter(adap); 255 of_node_put(np);
271 256
272 printk(KERN_INFO "PIKA DTM thread running.\n"); 257 printk(KERN_INFO "Warp DTM thread running.\n");
273 258
274 while (!kthread_should_stop()) { 259 while (!kthread_should_stop()) {
275 int val; 260 int val;
@@ -291,7 +276,6 @@ found_it:
291 return 0; 276 return 0;
292} 277}
293 278
294
295static int __init pika_dtm_start(void) 279static int __init pika_dtm_start(void)
296{ 280{
297 struct task_struct *dtm_thread; 281 struct task_struct *dtm_thread;