Skip to content

Commit

Permalink
[PATCH] powerpc: Fix old g5 issues with windfarm
Browse files Browse the repository at this point in the history
Some of the windfarm sensor modules can initialize on old machines that
don't have full windfarm support like non-dual core desktop G5s.
Unfortunately, by doing so, they would trigger a bug in their matching
algorithm causing them to attach to the wrong bus, thus triggering
issues with the i2c core and breaking the thermal driver.

This patch fixes the probing issue (so that they will work when a
windfarm port is done to these machines) and also prevents for now
windfarm to load at all on these machines that still use therm_pm72 to
avoid wasting resources.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Benjamin Herrenschmidt authored and Paul Mackerras committed Mar 3, 2006
1 parent 0c2aca8 commit b55fafc
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 17 deletions.
7 changes: 7 additions & 0 deletions drivers/macintosh/windfarm_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <linux/platform_device.h>
#include <linux/mutex.h>

#include <asm/prom.h>

#include "windfarm.h"

#define VERSION "0.2"
Expand Down Expand Up @@ -465,6 +467,11 @@ static int __init windfarm_core_init(void)
{
DBG("wf: core loaded\n");

/* Don't register on old machines that use therm_pm72 for now */
if (machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1"))
return -ENODEV;
platform_device_register(&wf_platform_device);
return 0;
}
Expand Down
8 changes: 8 additions & 0 deletions drivers/macintosh/windfarm_cpufreq_clamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <linux/wait.h>
#include <linux/cpufreq.h>

#include <asm/prom.h>

#include "windfarm.h"

#define VERSION "0.3"
Expand Down Expand Up @@ -74,6 +76,12 @@ static int __init wf_cpufreq_clamp_init(void)
{
struct wf_control *clamp;

/* Don't register on old machines that use therm_pm72 for now */
if (machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1"))
return -ENODEV;

clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL);
if (clamp == NULL)
return -ENOMEM;
Expand Down
32 changes: 23 additions & 9 deletions drivers/macintosh/windfarm_lm75_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "windfarm.h"

#define VERSION "0.1"
#define VERSION "0.2"

#undef DEBUG

Expand Down Expand Up @@ -113,6 +113,7 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
const char *loc)
{
struct wf_lm75_sensor *lm;
int rc;

DBG("wf_lm75: creating %s device at address 0x%02x\n",
ds1775 ? "ds1775" : "lm75", addr);
Expand All @@ -139,9 +140,11 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
lm->i2c.driver = &wf_lm75_driver;
strncpy(lm->i2c.name, lm->sens.name, I2C_NAME_SIZE-1);

if (i2c_attach_client(&lm->i2c)) {
printk(KERN_ERR "windfarm: failed to attach %s %s to i2c\n",
ds1775 ? "ds1775" : "lm75", lm->i2c.name);
rc = i2c_attach_client(&lm->i2c);
if (rc) {
printk(KERN_ERR "windfarm: failed to attach %s %s to i2c,"
" err %d\n", ds1775 ? "ds1775" : "lm75",
lm->i2c.name, rc);
goto fail;
}

Expand Down Expand Up @@ -175,16 +178,22 @@ static int wf_lm75_attach(struct i2c_adapter *adapter)
(dev = of_get_next_child(busnode, dev)) != NULL;) {
const char *loc =
get_property(dev, "hwsensor-location", NULL);
u32 *reg = (u32 *)get_property(dev, "reg", NULL);
DBG(" dev: %s... (loc: %p, reg: %p)\n", dev->name, loc, reg);
if (loc == NULL || reg == NULL)
u8 addr;

/* We must re-match the adapter in order to properly check
* the channel on multibus setups
*/
if (!pmac_i2c_match_adapter(dev, adapter))
continue;
addr = pmac_i2c_get_dev_addr(dev);
if (loc == NULL || addr == 0)
continue;
/* real lm75 */
if (device_is_compatible(dev, "lm75"))
wf_lm75_create(adapter, *reg, 0, loc);
wf_lm75_create(adapter, addr, 0, loc);
/* ds1775 (compatible, better resolution */
else if (device_is_compatible(dev, "ds1775"))
wf_lm75_create(adapter, *reg, 1, loc);
wf_lm75_create(adapter, addr, 1, loc);
}
return 0;
}
Expand All @@ -206,6 +215,11 @@ static int wf_lm75_detach(struct i2c_client *client)

static int __init wf_lm75_sensor_init(void)
{
/* Don't register on old machines that use therm_pm72 for now */
if (machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1"))
return -ENODEV;
return i2c_add_driver(&wf_lm75_driver);
}

Expand Down
25 changes: 18 additions & 7 deletions drivers/macintosh/windfarm_max6690_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "windfarm.h"

#define VERSION "0.1"
#define VERSION "0.2"

/* This currently only exports the external temperature sensor,
since that's all the control loops need. */
Expand Down Expand Up @@ -81,7 +81,7 @@ static struct wf_sensor_ops wf_max6690_ops = {
static void wf_max6690_create(struct i2c_adapter *adapter, u8 addr)
{
struct wf_6690_sensor *max;
char *name = "u4-temp";
char *name = "backside-temp";

max = kzalloc(sizeof(struct wf_6690_sensor), GFP_KERNEL);
if (max == NULL) {
Expand Down Expand Up @@ -118,24 +118,30 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
struct device_node *busnode, *dev = NULL;
struct pmac_i2c_bus *bus;
const char *loc;
u32 *reg;

bus = pmac_i2c_adapter_to_bus(adapter);
if (bus == NULL)
return -ENODEV;
busnode = pmac_i2c_get_bus_node(bus);

while ((dev = of_get_next_child(busnode, dev)) != NULL) {
u8 addr;

/* We must re-match the adapter in order to properly check
* the channel on multibus setups
*/
if (!pmac_i2c_match_adapter(dev, adapter))
continue;
if (!device_is_compatible(dev, "max6690"))
continue;
addr = pmac_i2c_get_dev_addr(dev);
loc = get_property(dev, "hwsensor-location", NULL);
reg = (u32 *) get_property(dev, "reg", NULL);
if (!loc || !reg)
if (loc == NULL || addr == 0)
continue;
printk("found max6690, loc=%s reg=%x\n", loc, *reg);
printk("found max6690, loc=%s addr=0x%02x\n", loc, addr);
if (strcmp(loc, "BACKSIDE"))
continue;
wf_max6690_create(adapter, *reg);
wf_max6690_create(adapter, addr);
}

return 0;
Expand All @@ -153,6 +159,11 @@ static int wf_max6690_detach(struct i2c_client *client)

static int __init wf_max6690_sensor_init(void)
{
/* Don't register on old machines that use therm_pm72 for now */
if (machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1"))
return -ENODEV;
return i2c_add_driver(&wf_max6690_driver);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/windfarm_pm112.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ static void pm112_new_sensor(struct wf_sensor *sr)
} else if (!strcmp(sr->name, "slots-power")) {
if (slots_power == NULL && wf_get_sensor(sr) == 0)
slots_power = sr;
} else if (!strcmp(sr->name, "u4-temp")) {
} else if (!strcmp(sr->name, "backside-temp")) {
if (u4_temp == NULL && wf_get_sensor(sr) == 0)
u4_temp = sr;
} else
Expand Down

0 comments on commit b55fafc

Please sign in to comment.