aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/macintosh/windfarm_lm75_sensor.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2006-03-03 01:03:21 -0500
committerPaul Mackerras <paulus@samba.org>2006-03-03 05:43:53 -0500
commitb55fafc5a800f27beedfdcf8bd1b6baa47e769a9 (patch)
treedc651c5738f20b72cb17ef3fc33e2e27977e6372 /drivers/macintosh/windfarm_lm75_sensor.c
parent0c2aca88bdac4254a13466fb108733d243a118b6 (diff)
[PATCH] powerpc: Fix old g5 issues with windfarm
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>
Diffstat (limited to 'drivers/macintosh/windfarm_lm75_sensor.c')
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index 906d3ecae6e6..423bfa2432c0 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -25,7 +25,7 @@
25 25
26#include "windfarm.h" 26#include "windfarm.h"
27 27
28#define VERSION "0.1" 28#define VERSION "0.2"
29 29
30#undef DEBUG 30#undef DEBUG
31 31
@@ -113,6 +113,7 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
113 const char *loc) 113 const char *loc)
114{ 114{
115 struct wf_lm75_sensor *lm; 115 struct wf_lm75_sensor *lm;
116 int rc;
116 117
117 DBG("wf_lm75: creating %s device at address 0x%02x\n", 118 DBG("wf_lm75: creating %s device at address 0x%02x\n",
118 ds1775 ? "ds1775" : "lm75", addr); 119 ds1775 ? "ds1775" : "lm75", addr);
@@ -139,9 +140,11 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter,
139 lm->i2c.driver = &wf_lm75_driver; 140 lm->i2c.driver = &wf_lm75_driver;
140 strncpy(lm->i2c.name, lm->sens.name, I2C_NAME_SIZE-1); 141 strncpy(lm->i2c.name, lm->sens.name, I2C_NAME_SIZE-1);
141 142
142 if (i2c_attach_client(&lm->i2c)) { 143 rc = i2c_attach_client(&lm->i2c);
143 printk(KERN_ERR "windfarm: failed to attach %s %s to i2c\n", 144 if (rc) {
144 ds1775 ? "ds1775" : "lm75", lm->i2c.name); 145 printk(KERN_ERR "windfarm: failed to attach %s %s to i2c,"
146 " err %d\n", ds1775 ? "ds1775" : "lm75",
147 lm->i2c.name, rc);
145 goto fail; 148 goto fail;
146 } 149 }
147 150
@@ -175,16 +178,22 @@ static int wf_lm75_attach(struct i2c_adapter *adapter)
175 (dev = of_get_next_child(busnode, dev)) != NULL;) { 178 (dev = of_get_next_child(busnode, dev)) != NULL;) {
176 const char *loc = 179 const char *loc =
177 get_property(dev, "hwsensor-location", NULL); 180 get_property(dev, "hwsensor-location", NULL);
178 u32 *reg = (u32 *)get_property(dev, "reg", NULL); 181 u8 addr;
179 DBG(" dev: %s... (loc: %p, reg: %p)\n", dev->name, loc, reg); 182
180 if (loc == NULL || reg == NULL) 183 /* We must re-match the adapter in order to properly check
184 * the channel on multibus setups
185 */
186 if (!pmac_i2c_match_adapter(dev, adapter))
187 continue;
188 addr = pmac_i2c_get_dev_addr(dev);
189 if (loc == NULL || addr == 0)
181 continue; 190 continue;
182 /* real lm75 */ 191 /* real lm75 */
183 if (device_is_compatible(dev, "lm75")) 192 if (device_is_compatible(dev, "lm75"))
184 wf_lm75_create(adapter, *reg, 0, loc); 193 wf_lm75_create(adapter, addr, 0, loc);
185 /* ds1775 (compatible, better resolution */ 194 /* ds1775 (compatible, better resolution */
186 else if (device_is_compatible(dev, "ds1775")) 195 else if (device_is_compatible(dev, "ds1775"))
187 wf_lm75_create(adapter, *reg, 1, loc); 196 wf_lm75_create(adapter, addr, 1, loc);
188 } 197 }
189 return 0; 198 return 0;
190} 199}
@@ -206,6 +215,11 @@ static int wf_lm75_detach(struct i2c_client *client)
206 215
207static int __init wf_lm75_sensor_init(void) 216static int __init wf_lm75_sensor_init(void)
208{ 217{
218 /* Don't register on old machines that use therm_pm72 for now */
219 if (machine_is_compatible("PowerMac7,2") ||
220 machine_is_compatible("PowerMac7,3") ||
221 machine_is_compatible("RackMac3,1"))
222 return -ENODEV;
209 return i2c_add_driver(&wf_lm75_driver); 223 return i2c_add_driver(&wf_lm75_driver);
210} 224}
211 225