Skip to content

Commit

Permalink
powerpc/warp: Platform fix for i2c change
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sean MacLennan authored and Benjamin Herrenschmidt committed Jun 26, 2009
1 parent b810c6e commit 3984114
Showing 1 changed file with 14 additions and 30 deletions.
44 changes: 14 additions & 30 deletions arch/powerpc/platforms/44x/warp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/of_gpio.h>
#include <linux/of_i2c.h>

#include <asm/machdep.h>
#include <asm/prom.h>
Expand Down Expand Up @@ -65,7 +66,6 @@ define_machine(warp) {

static u32 post_info;

/* I am not sure this is the best place for this... */
static int __init warp_post_info(void)
{
struct device_node *np;
Expand Down Expand Up @@ -194,9 +194,9 @@ static int pika_setup_leds(void)
return 0;
}

static void pika_setup_critical_temp(struct i2c_client *client)
static void pika_setup_critical_temp(struct device_node *np,
struct i2c_client *client)
{
struct device_node *np;
int irq, rc;

/* Do this before enabling critical temp interrupt since we
Expand All @@ -208,14 +208,7 @@ static void pika_setup_critical_temp(struct i2c_client *client)
i2c_smbus_write_byte_data(client, 2, 65); /* Thigh */
i2c_smbus_write_byte_data(client, 3, 0); /* Tlow */

np = of_find_compatible_node(NULL, NULL, "adi,ad7414");
if (np == NULL) {
printk(KERN_ERR __FILE__ ": Unable to find ad7414\n");
return;
}

irq = irq_of_parse_and_map(np, 0);
of_node_put(np);
if (irq == NO_IRQ) {
printk(KERN_ERR __FILE__ ": Unable to get ad7414 irq\n");
return;
Expand Down Expand Up @@ -244,32 +237,24 @@ static inline void pika_dtm_check_fan(void __iomem *fpga)

static int pika_dtm_thread(void __iomem *fpga)
{
struct i2c_adapter *adap;
struct device_node *np;
struct i2c_client *client;

/* We loop in case either driver was compiled as a module and
* has not been insmoded yet.
*/
while (!(adap = i2c_get_adapter(0))) {
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ);
}

while (1) {
list_for_each_entry(client, &adap->clients, list)
if (client->addr == 0x4a)
goto found_it;
np = of_find_compatible_node(NULL, NULL, "adi,ad7414");
if (np == NULL)
return -ENOENT;

set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ);
client = of_find_i2c_device_by_node(np);
if (client == NULL) {
of_node_put(np);
return -ENOENT;
}

found_it:
pika_setup_critical_temp(client);
pika_setup_critical_temp(np, client);

i2c_put_adapter(adap);
of_node_put(np);

printk(KERN_INFO "PIKA DTM thread running.\n");
printk(KERN_INFO "Warp DTM thread running.\n");

while (!kthread_should_stop()) {
int val;
Expand All @@ -291,7 +276,6 @@ static int pika_dtm_thread(void __iomem *fpga)
return 0;
}


static int __init pika_dtm_start(void)
{
struct task_struct *dtm_thread;
Expand Down

0 comments on commit 3984114

Please sign in to comment.