diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-09 13:03:44 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-09 13:03:44 -0500 |
commit | 6150c32589d1976ca8a5c987df951088c05a7542 (patch) | |
tree | 94073696576323ff966e365d8c47b8ecd8372f97 /drivers/macintosh | |
parent | 44637a12f80b80157d9c1bc5b7d6ef09c9e05713 (diff) | |
parent | be42d5fa3772241b8ecebd443f1fb36247959c54 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc-merge
Diffstat (limited to 'drivers/macintosh')
-rw-r--r-- | drivers/macintosh/Kconfig | 10 | ||||
-rw-r--r-- | drivers/macintosh/macio_asic.c | 254 | ||||
-rw-r--r-- | drivers/macintosh/mediabay.c | 8 | ||||
-rw-r--r-- | drivers/macintosh/smu.c | 50 | ||||
-rw-r--r-- | drivers/macintosh/via-cuda.c | 52 | ||||
-rw-r--r-- | drivers/macintosh/via-pmu.c | 364 | ||||
-rw-r--r-- | drivers/macintosh/windfarm_lm75_sensor.c | 50 |
7 files changed, 282 insertions, 506 deletions
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig index a0ea44c3e8b1..7d4a0ac28c06 100644 --- a/drivers/macintosh/Kconfig +++ b/drivers/macintosh/Kconfig | |||
@@ -149,14 +149,14 @@ config MAC_EMUMOUSEBTN | |||
149 | 149 | ||
150 | config THERM_WINDTUNNEL | 150 | config THERM_WINDTUNNEL |
151 | tristate "Support for thermal management on Windtunnel G4s" | 151 | tristate "Support for thermal management on Windtunnel G4s" |
152 | depends on I2C && I2C_KEYWEST && PPC_PMAC && !PPC_PMAC64 | 152 | depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64 |
153 | help | 153 | help |
154 | This driver provides some thermostat and fan control for the desktop | 154 | This driver provides some thermostat and fan control for the desktop |
155 | G4 "Windtunnel" | 155 | G4 "Windtunnel" |
156 | 156 | ||
157 | config THERM_ADT746X | 157 | config THERM_ADT746X |
158 | tristate "Support for thermal mgmnt on laptops with ADT 746x chipset" | 158 | tristate "Support for thermal mgmnt on laptops with ADT 746x chipset" |
159 | depends on I2C && I2C_KEYWEST && PPC_PMAC && !PPC_PMAC64 | 159 | depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64 |
160 | help | 160 | help |
161 | This driver provides some thermostat and fan control for the | 161 | This driver provides some thermostat and fan control for the |
162 | iBook G4, and the ATI based aluminium PowerBooks, allowing slighlty | 162 | iBook G4, and the ATI based aluminium PowerBooks, allowing slighlty |
@@ -164,7 +164,7 @@ config THERM_ADT746X | |||
164 | 164 | ||
165 | config THERM_PM72 | 165 | config THERM_PM72 |
166 | tristate "Support for thermal management on PowerMac G5" | 166 | tristate "Support for thermal management on PowerMac G5" |
167 | depends on I2C && I2C_KEYWEST && PPC_PMAC64 | 167 | depends on I2C && I2C_POWERMAC && PPC_PMAC64 |
168 | help | 168 | help |
169 | This driver provides thermostat and fan control for the desktop | 169 | This driver provides thermostat and fan control for the desktop |
170 | G5 machines. | 170 | G5 machines. |
@@ -175,14 +175,14 @@ config WINDFARM | |||
175 | config WINDFARM_PM81 | 175 | config WINDFARM_PM81 |
176 | tristate "Support for thermal management on iMac G5" | 176 | tristate "Support for thermal management on iMac G5" |
177 | depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU | 177 | depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU |
178 | select I2C_PMAC_SMU | 178 | select I2C_POWERMAC |
179 | help | 179 | help |
180 | This driver provides thermal control for the iMacG5 | 180 | This driver provides thermal control for the iMacG5 |
181 | 181 | ||
182 | config WINDFARM_PM91 | 182 | config WINDFARM_PM91 |
183 | tristate "Support for thermal management on PowerMac9,1" | 183 | tristate "Support for thermal management on PowerMac9,1" |
184 | depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU | 184 | depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU |
185 | select I2C_PMAC_SMU | 185 | select I2C_POWERMAC |
186 | help | 186 | help |
187 | This driver provides thermal control for the PowerMac9,1 | 187 | This driver provides thermal control for the PowerMac9,1 |
188 | which is the recent (SMU based) single CPU desktop G5 | 188 | which is the recent (SMU based) single CPU desktop G5 |
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c index 228e1852a836..2a545ceb523b 100644 --- a/drivers/macintosh/macio_asic.c +++ b/drivers/macintosh/macio_asic.c | |||
@@ -3,6 +3,13 @@ | |||
3 | * a MacIO ASIC. Interface to new driver model mostly | 3 | * a MacIO ASIC. Interface to new driver model mostly |
4 | * stolen from the PCI version. | 4 | * stolen from the PCI version. |
5 | * | 5 | * |
6 | * Copyright (C) 2005 Ben. Herrenschmidt (benh@kernel.crashing.org) | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | * | ||
6 | * TODO: | 13 | * TODO: |
7 | * | 14 | * |
8 | * - Don't probe below media bay by default, but instead provide | 15 | * - Don't probe below media bay by default, but instead provide |
@@ -218,12 +225,14 @@ postcore_initcall(macio_bus_driver_init); | |||
218 | 225 | ||
219 | 226 | ||
220 | /** | 227 | /** |
221 | * macio_release_dev - free a macio device structure when all users of it are finished. | 228 | * macio_release_dev - free a macio device structure when all users of it are |
229 | * finished. | ||
222 | * @dev: device that's been disconnected | 230 | * @dev: device that's been disconnected |
223 | * | 231 | * |
224 | * Will be called only by the device core when all users of this macio device are | 232 | * Will be called only by the device core when all users of this macio device |
225 | * done. This currently means never as we don't hot remove any macio device yet, | 233 | * are done. This currently means never as we don't hot remove any macio |
226 | * though that will happen with mediabay based devices in a later implementation. | 234 | * device yet, though that will happen with mediabay based devices in a later |
235 | * implementation. | ||
227 | */ | 236 | */ |
228 | static void macio_release_dev(struct device *dev) | 237 | static void macio_release_dev(struct device *dev) |
229 | { | 238 | { |
@@ -242,49 +251,114 @@ static void macio_release_dev(struct device *dev) | |||
242 | * If this routine returns non-null, then the resource is completely | 251 | * If this routine returns non-null, then the resource is completely |
243 | * skipped. | 252 | * skipped. |
244 | */ | 253 | */ |
245 | static int macio_resource_quirks(struct device_node *np, struct resource *res, int index) | 254 | static int macio_resource_quirks(struct device_node *np, struct resource *res, |
255 | int index) | ||
246 | { | 256 | { |
247 | if (res->flags & IORESOURCE_MEM) { | 257 | if (res->flags & IORESOURCE_MEM) { |
248 | /* Grand Central has too large resource 0 on some machines */ | 258 | /* Grand Central has too large resource 0 on some machines */ |
249 | if (index == 0 && !strcmp(np->name, "gc")) { | 259 | if (index == 0 && !strcmp(np->name, "gc")) |
250 | np->addrs[0].size = 0x20000; | ||
251 | res->end = res->start + 0x1ffff; | 260 | res->end = res->start + 0x1ffff; |
252 | } | 261 | |
253 | /* Airport has bogus resource 2 */ | 262 | /* Airport has bogus resource 2 */ |
254 | if (index >= 2 && !strcmp(np->name, "radio")) | 263 | if (index >= 2 && !strcmp(np->name, "radio")) |
255 | return 1; | 264 | return 1; |
265 | |||
266 | #ifndef CONFIG_PPC64 | ||
256 | /* DBDMAs may have bogus sizes */ | 267 | /* DBDMAs may have bogus sizes */ |
257 | if ((res->start & 0x0001f000) == 0x00008000) { | 268 | if ((res->start & 0x0001f000) == 0x00008000) |
258 | np->addrs[index].size = 0x100; | ||
259 | res->end = res->start + 0xff; | 269 | res->end = res->start + 0xff; |
260 | } | 270 | #endif /* CONFIG_PPC64 */ |
261 | /* ESCC parent eats child resources. We could have added a level of hierarchy, | 271 | |
262 | * but I don't really feel the need for it */ | 272 | /* ESCC parent eats child resources. We could have added a |
273 | * level of hierarchy, but I don't really feel the need | ||
274 | * for it | ||
275 | */ | ||
263 | if (!strcmp(np->name, "escc")) | 276 | if (!strcmp(np->name, "escc")) |
264 | return 1; | 277 | return 1; |
278 | |||
265 | /* ESCC has bogus resources >= 3 */ | 279 | /* ESCC has bogus resources >= 3 */ |
266 | if (index >= 3 && !(strcmp(np->name, "ch-a") && strcmp(np->name, "ch-b"))) | 280 | if (index >= 3 && !(strcmp(np->name, "ch-a") && |
281 | strcmp(np->name, "ch-b"))) | ||
267 | return 1; | 282 | return 1; |
283 | |||
268 | /* Media bay has too many resources, keep only first one */ | 284 | /* Media bay has too many resources, keep only first one */ |
269 | if (index > 0 && !strcmp(np->name, "media-bay")) | 285 | if (index > 0 && !strcmp(np->name, "media-bay")) |
270 | return 1; | 286 | return 1; |
287 | |||
271 | /* Some older IDE resources have bogus sizes */ | 288 | /* Some older IDE resources have bogus sizes */ |
272 | if (!(strcmp(np->name, "IDE") && strcmp(np->name, "ATA") && | 289 | if (!(strcmp(np->name, "IDE") && strcmp(np->name, "ATA") && |
273 | strcmp(np->type, "ide") && strcmp(np->type, "ata"))) { | 290 | strcmp(np->type, "ide") && strcmp(np->type, "ata"))) { |
274 | if (index == 0 && np->addrs[0].size > 0x1000) { | 291 | if (index == 0 && (res->end - res->start) > 0xfff) |
275 | np->addrs[0].size = 0x1000; | ||
276 | res->end = res->start + 0xfff; | 292 | res->end = res->start + 0xfff; |
277 | } | 293 | if (index == 1 && (res->end - res->start) > 0xff) |
278 | if (index == 1 && np->addrs[1].size > 0x100) { | ||
279 | np->addrs[1].size = 0x100; | ||
280 | res->end = res->start + 0xff; | 294 | res->end = res->start + 0xff; |
281 | } | ||
282 | } | 295 | } |
283 | } | 296 | } |
284 | return 0; | 297 | return 0; |
285 | } | 298 | } |
286 | 299 | ||
287 | 300 | ||
301 | static void macio_setup_interrupts(struct macio_dev *dev) | ||
302 | { | ||
303 | struct device_node *np = dev->ofdev.node; | ||
304 | int i,j; | ||
305 | |||
306 | /* For now, we use pre-parsed entries in the device-tree for | ||
307 | * interrupt routing and addresses, but we should change that | ||
308 | * to dynamically parsed entries and so get rid of most of the | ||
309 | * clutter in struct device_node | ||
310 | */ | ||
311 | for (i = j = 0; i < np->n_intrs; i++) { | ||
312 | struct resource *res = &dev->interrupt[j]; | ||
313 | |||
314 | if (j >= MACIO_DEV_COUNT_IRQS) | ||
315 | break; | ||
316 | res->start = np->intrs[i].line; | ||
317 | res->flags = IORESOURCE_IO; | ||
318 | if (np->intrs[j].sense) | ||
319 | res->flags |= IORESOURCE_IRQ_LOWLEVEL; | ||
320 | else | ||
321 | res->flags |= IORESOURCE_IRQ_HIGHEDGE; | ||
322 | res->name = dev->ofdev.dev.bus_id; | ||
323 | if (macio_resource_quirks(np, res, i)) | ||
324 | memset(res, 0, sizeof(struct resource)); | ||
325 | else | ||
326 | j++; | ||
327 | } | ||
328 | dev->n_interrupts = j; | ||
329 | } | ||
330 | |||
331 | static void macio_setup_resources(struct macio_dev *dev, | ||
332 | struct resource *parent_res) | ||
333 | { | ||
334 | struct device_node *np = dev->ofdev.node; | ||
335 | struct resource r; | ||
336 | int index; | ||
337 | |||
338 | for (index = 0; of_address_to_resource(np, index, &r) == 0; index++) { | ||
339 | struct resource *res = &dev->resource[index]; | ||
340 | if (index >= MACIO_DEV_COUNT_RESOURCES) | ||
341 | break; | ||
342 | *res = r; | ||
343 | res->name = dev->ofdev.dev.bus_id; | ||
344 | |||
345 | if (macio_resource_quirks(np, res, index)) { | ||
346 | memset(res, 0, sizeof(struct resource)); | ||
347 | continue; | ||
348 | } | ||
349 | /* Currently, we consider failure as harmless, this may | ||
350 | * change in the future, once I've found all the device | ||
351 | * tree bugs in older machines & worked around them | ||
352 | */ | ||
353 | if (insert_resource(parent_res, res)) { | ||
354 | printk(KERN_WARNING "Can't request resource " | ||
355 | "%d for MacIO device %s\n", | ||
356 | index, dev->ofdev.dev.bus_id); | ||
357 | } | ||
358 | } | ||
359 | dev->n_resources = index; | ||
360 | } | ||
361 | |||
288 | /** | 362 | /** |
289 | * macio_add_one_device - Add one device from OF node to the device tree | 363 | * macio_add_one_device - Add one device from OF node to the device tree |
290 | * @chip: pointer to the macio_chip holding the device | 364 | * @chip: pointer to the macio_chip holding the device |
@@ -294,12 +368,13 @@ static int macio_resource_quirks(struct device_node *np, struct resource *res, i | |||
294 | * When media-bay is changed to hotswap drivers, this function will | 368 | * When media-bay is changed to hotswap drivers, this function will |
295 | * be exposed to the bay driver some way... | 369 | * be exposed to the bay driver some way... |
296 | */ | 370 | */ |
297 | static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct device *parent, | 371 | static struct macio_dev * macio_add_one_device(struct macio_chip *chip, |
298 | struct device_node *np, struct macio_dev *in_bay, | 372 | struct device *parent, |
373 | struct device_node *np, | ||
374 | struct macio_dev *in_bay, | ||
299 | struct resource *parent_res) | 375 | struct resource *parent_res) |
300 | { | 376 | { |
301 | struct macio_dev *dev; | 377 | struct macio_dev *dev; |
302 | int i, j; | ||
303 | u32 *reg; | 378 | u32 *reg; |
304 | 379 | ||
305 | if (np == NULL) | 380 | if (np == NULL) |
@@ -326,7 +401,8 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct d | |||
326 | 401 | ||
327 | /* MacIO itself has a different reg, we use it's PCI base */ | 402 | /* MacIO itself has a different reg, we use it's PCI base */ |
328 | if (np == chip->of_node) { | 403 | if (np == chip->of_node) { |
329 | sprintf(dev->ofdev.dev.bus_id, "%1d.%08lx:%.*s", chip->lbus.index, | 404 | sprintf(dev->ofdev.dev.bus_id, "%1d.%08lx:%.*s", |
405 | chip->lbus.index, | ||
330 | #ifdef CONFIG_PCI | 406 | #ifdef CONFIG_PCI |
331 | pci_resource_start(chip->lbus.pdev, 0), | 407 | pci_resource_start(chip->lbus.pdev, 0), |
332 | #else | 408 | #else |
@@ -335,57 +411,16 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip, struct d | |||
335 | MAX_NODE_NAME_SIZE, np->name); | 411 | MAX_NODE_NAME_SIZE, np->name); |
336 | } else { | 412 | } else { |
337 | reg = (u32 *)get_property(np, "reg", NULL); | 413 | reg = (u32 *)get_property(np, "reg", NULL); |
338 | sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s", chip->lbus.index, | 414 | sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s", |
415 | chip->lbus.index, | ||
339 | reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name); | 416 | reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name); |
340 | } | 417 | } |
341 | 418 | ||
342 | /* For now, we use pre-parsed entries in the device-tree for | 419 | /* Setup interrupts & resources */ |
343 | * interrupt routing and addresses, but we should change that | 420 | macio_setup_interrupts(dev); |
344 | * to dynamically parsed entries and so get rid of most of the | 421 | macio_setup_resources(dev, parent_res); |
345 | * clutter in struct device_node | ||
346 | */ | ||
347 | for (i = j = 0; i < np->n_intrs; i++) { | ||
348 | struct resource *res = &dev->interrupt[j]; | ||
349 | |||
350 | if (j >= MACIO_DEV_COUNT_IRQS) | ||
351 | break; | ||
352 | res->start = np->intrs[i].line; | ||
353 | res->flags = IORESOURCE_IO; | ||
354 | if (np->intrs[j].sense) | ||
355 | res->flags |= IORESOURCE_IRQ_LOWLEVEL; | ||
356 | else | ||
357 | res->flags |= IORESOURCE_IRQ_HIGHEDGE; | ||
358 | res->name = dev->ofdev.dev.bus_id; | ||
359 | if (macio_resource_quirks(np, res, i)) | ||
360 | memset(res, 0, sizeof(struct resource)); | ||
361 | else | ||
362 | j++; | ||
363 | } | ||
364 | dev->n_interrupts = j; | ||
365 | for (i = j = 0; i < np->n_addrs; i++) { | ||
366 | struct resource *res = &dev->resource[j]; | ||
367 | |||
368 | if (j >= MACIO_DEV_COUNT_RESOURCES) | ||
369 | break; | ||
370 | res->start = np->addrs[i].address; | ||
371 | res->end = np->addrs[i].address + np->addrs[i].size - 1; | ||
372 | res->flags = IORESOURCE_MEM; | ||
373 | res->name = dev->ofdev.dev.bus_id; | ||
374 | if (macio_resource_quirks(np, res, i)) | ||
375 | memset(res, 0, sizeof(struct resource)); | ||
376 | else { | ||
377 | j++; | ||
378 | /* Currently, we consider failure as harmless, this may | ||
379 | * change in the future, once I've found all the device | ||
380 | * tree bugs in older machines & worked around them | ||
381 | */ | ||
382 | if (insert_resource(parent_res, res)) | ||
383 | printk(KERN_WARNING "Can't request resource %d for MacIO" | ||
384 | " device %s\n", i, dev->ofdev.dev.bus_id); | ||
385 | } | ||
386 | } | ||
387 | dev->n_resources = j; | ||
388 | 422 | ||
423 | /* Register with core */ | ||
389 | if (of_device_register(&dev->ofdev) != 0) { | 424 | if (of_device_register(&dev->ofdev) != 0) { |
390 | printk(KERN_DEBUG"macio: device registration error for %s!\n", | 425 | printk(KERN_DEBUG"macio: device registration error for %s!\n", |
391 | dev->ofdev.dev.bus_id); | 426 | dev->ofdev.dev.bus_id); |
@@ -442,36 +477,42 @@ static void macio_pci_add_devices(struct macio_chip *chip) | |||
442 | 477 | ||
443 | /* First scan 1st level */ | 478 | /* First scan 1st level */ |
444 | for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) { | 479 | for (np = NULL; (np = of_get_next_child(pnode, np)) != NULL;) { |
445 | if (!macio_skip_device(np)) { | 480 | if (macio_skip_device(np)) |
446 | of_node_get(np); | 481 | continue; |
447 | mdev = macio_add_one_device(chip, &rdev->ofdev.dev, np, NULL, root_res); | 482 | of_node_get(np); |
448 | if (mdev == NULL) | 483 | mdev = macio_add_one_device(chip, &rdev->ofdev.dev, np, NULL, |
449 | of_node_put(np); | 484 | root_res); |
450 | else if (strncmp(np->name, "media-bay", 9) == 0) | 485 | if (mdev == NULL) |
451 | mbdev = mdev; | 486 | of_node_put(np); |
452 | else if (strncmp(np->name, "escc", 4) == 0) | 487 | else if (strncmp(np->name, "media-bay", 9) == 0) |
453 | sdev = mdev; | 488 | mbdev = mdev; |
454 | } | 489 | else if (strncmp(np->name, "escc", 4) == 0) |
490 | sdev = mdev; | ||
455 | } | 491 | } |
456 | 492 | ||
457 | /* Add media bay devices if any */ | 493 | /* Add media bay devices if any */ |
458 | if (mbdev) | 494 | if (mbdev) |
459 | for (np = NULL; (np = of_get_next_child(mbdev->ofdev.node, np)) != NULL;) | 495 | for (np = NULL; (np = of_get_next_child(mbdev->ofdev.node, np)) |
460 | if (!macio_skip_device(np)) { | 496 | != NULL;) { |
461 | of_node_get(np); | 497 | if (macio_skip_device(np)) |
462 | if (macio_add_one_device(chip, &mbdev->ofdev.dev, np, mbdev, | 498 | continue; |
463 | root_res) == NULL) | 499 | of_node_get(np); |
464 | of_node_put(np); | 500 | if (macio_add_one_device(chip, &mbdev->ofdev.dev, np, |
465 | } | 501 | mbdev, root_res) == NULL) |
502 | of_node_put(np); | ||
503 | } | ||
504 | |||
466 | /* Add serial ports if any */ | 505 | /* Add serial ports if any */ |
467 | if (sdev) { | 506 | if (sdev) { |
468 | for (np = NULL; (np = of_get_next_child(sdev->ofdev.node, np)) != NULL;) | 507 | for (np = NULL; (np = of_get_next_child(sdev->ofdev.node, np)) |
469 | if (!macio_skip_device(np)) { | 508 | != NULL;) { |
470 | of_node_get(np); | 509 | if (macio_skip_device(np)) |
471 | if (macio_add_one_device(chip, &sdev->ofdev.dev, np, NULL, | 510 | continue; |
472 | root_res) == NULL) | 511 | of_node_get(np); |
473 | of_node_put(np); | 512 | if (macio_add_one_device(chip, &sdev->ofdev.dev, np, |
474 | } | 513 | NULL, root_res) == NULL) |
514 | of_node_put(np); | ||
515 | } | ||
475 | } | 516 | } |
476 | } | 517 | } |
477 | 518 | ||
@@ -519,7 +560,8 @@ void macio_unregister_driver(struct macio_driver *drv) | |||
519 | * Returns 0 on success, or %EBUSY on error. A warning | 560 | * Returns 0 on success, or %EBUSY on error. A warning |
520 | * message is also printed on failure. | 561 | * message is also printed on failure. |
521 | */ | 562 | */ |
522 | int macio_request_resource(struct macio_dev *dev, int resource_no, const char *name) | 563 | int macio_request_resource(struct macio_dev *dev, int resource_no, |
564 | const char *name) | ||
523 | { | 565 | { |
524 | if (macio_resource_len(dev, resource_no) == 0) | 566 | if (macio_resource_len(dev, resource_no) == 0) |
525 | return 0; | 567 | return 0; |
@@ -606,20 +648,20 @@ static int __devinit macio_pci_probe(struct pci_dev *pdev, const struct pci_devi | |||
606 | if (ent->vendor != PCI_VENDOR_ID_APPLE) | 648 | if (ent->vendor != PCI_VENDOR_ID_APPLE) |
607 | return -ENODEV; | 649 | return -ENODEV; |
608 | 650 | ||
609 | /* Note regarding refcounting: We assume pci_device_to_OF_node() is ported | 651 | /* Note regarding refcounting: We assume pci_device_to_OF_node() is |
610 | * to new OF APIs and returns a node with refcount incremented. This isn't | 652 | * ported to new OF APIs and returns a node with refcount incremented. |
611 | * the case today, but on the other hand ppc32 doesn't do refcounting. This | ||
612 | * will have to be fixed when going to ppc64. --BenH. | ||
613 | */ | 653 | */ |
614 | np = pci_device_to_OF_node(pdev); | 654 | np = pci_device_to_OF_node(pdev); |
615 | if (np == NULL) | 655 | if (np == NULL) |
616 | return -ENODEV; | 656 | return -ENODEV; |
617 | 657 | ||
618 | /* This assumption is wrong, fix that here for now until I fix the arch */ | 658 | /* The above assumption is wrong !!! |
659 | * fix that here for now until I fix the arch code | ||
660 | */ | ||
619 | of_node_get(np); | 661 | of_node_get(np); |
620 | 662 | ||
621 | /* We also assume that pmac_feature will have done a get() on nodes stored | 663 | /* We also assume that pmac_feature will have done a get() on nodes |
622 | * in the macio chips array | 664 | * stored in the macio chips array |
623 | */ | 665 | */ |
624 | chip = macio_find(np, macio_unknown); | 666 | chip = macio_find(np, macio_unknown); |
625 | of_node_put(np); | 667 | of_node_put(np); |
@@ -639,9 +681,9 @@ static int __devinit macio_pci_probe(struct pci_dev *pdev, const struct pci_devi | |||
639 | 681 | ||
640 | /* | 682 | /* |
641 | * HACK ALERT: The WallStreet PowerBook and some OHare based machines | 683 | * HACK ALERT: The WallStreet PowerBook and some OHare based machines |
642 | * have 2 macio ASICs. I must probe the "main" one first or IDE ordering | 684 | * have 2 macio ASICs. I must probe the "main" one first or IDE |
643 | * will be incorrect. So I put on "hold" the second one since it seem to | 685 | * ordering will be incorrect. So I put on "hold" the second one since |
644 | * appear first on PCI | 686 | * it seem to appear first on PCI |
645 | */ | 687 | */ |
646 | if (chip->type == macio_gatwick || chip->type == macio_ohareII) | 688 | if (chip->type == macio_gatwick || chip->type == macio_ohareII) |
647 | if (macio_chips[0].lbus.pdev == NULL) { | 689 | if (macio_chips[0].lbus.pdev == NULL) { |
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c index b856bb67169c..8dbf2852bae0 100644 --- a/drivers/macintosh/mediabay.c +++ b/drivers/macintosh/mediabay.c | |||
@@ -647,6 +647,7 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de | |||
647 | struct media_bay_info* bay; | 647 | struct media_bay_info* bay; |
648 | u32 __iomem *regbase; | 648 | u32 __iomem *regbase; |
649 | struct device_node *ofnode; | 649 | struct device_node *ofnode; |
650 | unsigned long base; | ||
650 | int i; | 651 | int i; |
651 | 652 | ||
652 | ofnode = mdev->ofdev.node; | 653 | ofnode = mdev->ofdev.node; |
@@ -656,10 +657,11 @@ static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_de | |||
656 | if (macio_request_resources(mdev, "media-bay")) | 657 | if (macio_request_resources(mdev, "media-bay")) |
657 | return -EBUSY; | 658 | return -EBUSY; |
658 | /* Media bay registers are located at the beginning of the | 659 | /* Media bay registers are located at the beginning of the |
659 | * mac-io chip, we get the parent address for now (hrm...) | 660 | * mac-io chip, for now, we trick and align down the first |
661 | * resource passed in | ||
660 | */ | 662 | */ |
661 | regbase = (u32 __iomem *) | 663 | base = macio_resource_start(mdev, 0) & 0xffff0000u; |
662 | ioremap(ofnode->parent->addrs[0].address, 0x100); | 664 | regbase = (u32 __iomem *)ioremap(base, 0x100); |
663 | if (regbase == NULL) { | 665 | if (regbase == NULL) { |
664 | macio_release_resources(mdev); | 666 | macio_release_resources(mdev); |
665 | return -ENOMEM; | 667 | return -ENOMEM; |
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index e8378274d710..db2ae71d07ef 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c | |||
@@ -53,7 +53,7 @@ | |||
53 | #undef DEBUG_SMU | 53 | #undef DEBUG_SMU |
54 | 54 | ||
55 | #ifdef DEBUG_SMU | 55 | #ifdef DEBUG_SMU |
56 | #define DPRINTK(fmt, args...) do { udbg_printf(KERN_DEBUG fmt , ##args); } while (0) | 56 | #define DPRINTK(fmt, args...) do { printk(KERN_DEBUG fmt , ##args); } while (0) |
57 | #else | 57 | #else |
58 | #define DPRINTK(fmt, args...) do { } while (0) | 58 | #define DPRINTK(fmt, args...) do { } while (0) |
59 | #endif | 59 | #endif |
@@ -94,6 +94,8 @@ struct smu_device { | |||
94 | static struct smu_device *smu; | 94 | static struct smu_device *smu; |
95 | static DECLARE_MUTEX(smu_part_access); | 95 | static DECLARE_MUTEX(smu_part_access); |
96 | 96 | ||
97 | static void smu_i2c_retry(unsigned long data); | ||
98 | |||
97 | /* | 99 | /* |
98 | * SMU driver low level stuff | 100 | * SMU driver low level stuff |
99 | */ | 101 | */ |
@@ -469,7 +471,6 @@ int __init smu_init (void) | |||
469 | smu->of_node = np; | 471 | smu->of_node = np; |
470 | smu->db_irq = NO_IRQ; | 472 | smu->db_irq = NO_IRQ; |
471 | smu->msg_irq = NO_IRQ; | 473 | smu->msg_irq = NO_IRQ; |
472 | init_timer(&smu->i2c_timer); | ||
473 | 474 | ||
474 | /* smu_cmdbuf_abs is in the low 2G of RAM, can be converted to a | 475 | /* smu_cmdbuf_abs is in the low 2G of RAM, can be converted to a |
475 | * 32 bits value safely | 476 | * 32 bits value safely |
@@ -544,6 +545,10 @@ static int smu_late_init(void) | |||
544 | if (!smu) | 545 | if (!smu) |
545 | return 0; | 546 | return 0; |
546 | 547 | ||
548 | init_timer(&smu->i2c_timer); | ||
549 | smu->i2c_timer.function = smu_i2c_retry; | ||
550 | smu->i2c_timer.data = (unsigned long)smu; | ||
551 | |||
547 | /* | 552 | /* |
548 | * Try to request the interrupts | 553 | * Try to request the interrupts |
549 | */ | 554 | */ |
@@ -570,7 +575,10 @@ static int smu_late_init(void) | |||
570 | 575 | ||
571 | return 0; | 576 | return 0; |
572 | } | 577 | } |
573 | arch_initcall(smu_late_init); | 578 | /* This has to be before arch_initcall as the low i2c stuff relies on the |
579 | * above having been done before we reach arch_initcalls | ||
580 | */ | ||
581 | core_initcall(smu_late_init); | ||
574 | 582 | ||
575 | /* | 583 | /* |
576 | * sysfs visibility | 584 | * sysfs visibility |
@@ -580,20 +588,10 @@ static void smu_expose_childs(void *unused) | |||
580 | { | 588 | { |
581 | struct device_node *np; | 589 | struct device_node *np; |
582 | 590 | ||
583 | for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;) { | 591 | for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;) |
584 | if (device_is_compatible(np, "smu-i2c")) { | ||
585 | char name[32]; | ||
586 | u32 *reg = (u32 *)get_property(np, "reg", NULL); | ||
587 | |||
588 | if (reg == NULL) | ||
589 | continue; | ||
590 | sprintf(name, "smu-i2c-%02x", *reg); | ||
591 | of_platform_device_create(np, name, &smu->of_dev->dev); | ||
592 | } | ||
593 | if (device_is_compatible(np, "smu-sensors")) | 592 | if (device_is_compatible(np, "smu-sensors")) |
594 | of_platform_device_create(np, "smu-sensors", &smu->of_dev->dev); | 593 | of_platform_device_create(np, "smu-sensors", |
595 | } | 594 | &smu->of_dev->dev); |
596 | |||
597 | } | 595 | } |
598 | 596 | ||
599 | static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL); | 597 | static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL); |
@@ -712,13 +710,13 @@ static void smu_i2c_complete_command(struct smu_i2c_cmd *cmd, int fail) | |||
712 | 710 | ||
713 | static void smu_i2c_retry(unsigned long data) | 711 | static void smu_i2c_retry(unsigned long data) |
714 | { | 712 | { |
715 | struct smu_i2c_cmd *cmd = (struct smu_i2c_cmd *)data; | 713 | struct smu_i2c_cmd *cmd = smu->cmd_i2c_cur; |
716 | 714 | ||
717 | DPRINTK("SMU: i2c failure, requeuing...\n"); | 715 | DPRINTK("SMU: i2c failure, requeuing...\n"); |
718 | 716 | ||
719 | /* requeue command simply by resetting reply_len */ | 717 | /* requeue command simply by resetting reply_len */ |
720 | cmd->pdata[0] = 0xff; | 718 | cmd->pdata[0] = 0xff; |
721 | cmd->scmd.reply_len = 0x10; | 719 | cmd->scmd.reply_len = sizeof(cmd->pdata); |
722 | smu_queue_cmd(&cmd->scmd); | 720 | smu_queue_cmd(&cmd->scmd); |
723 | } | 721 | } |
724 | 722 | ||
@@ -747,10 +745,8 @@ static void smu_i2c_low_completion(struct smu_cmd *scmd, void *misc) | |||
747 | */ | 745 | */ |
748 | if (fail && --cmd->retries > 0) { | 746 | if (fail && --cmd->retries > 0) { |
749 | DPRINTK("SMU: i2c failure, starting timer...\n"); | 747 | DPRINTK("SMU: i2c failure, starting timer...\n"); |
750 | smu->i2c_timer.function = smu_i2c_retry; | 748 | BUG_ON(cmd != smu->cmd_i2c_cur); |
751 | smu->i2c_timer.data = (unsigned long)cmd; | 749 | mod_timer(&smu->i2c_timer, jiffies + msecs_to_jiffies(5)); |
752 | smu->i2c_timer.expires = jiffies + msecs_to_jiffies(5); | ||
753 | add_timer(&smu->i2c_timer); | ||
754 | return; | 750 | return; |
755 | } | 751 | } |
756 | 752 | ||
@@ -764,7 +760,7 @@ static void smu_i2c_low_completion(struct smu_cmd *scmd, void *misc) | |||
764 | 760 | ||
765 | /* Ok, initial command complete, now poll status */ | 761 | /* Ok, initial command complete, now poll status */ |
766 | scmd->reply_buf = cmd->pdata; | 762 | scmd->reply_buf = cmd->pdata; |
767 | scmd->reply_len = 0x10; | 763 | scmd->reply_len = sizeof(cmd->pdata); |
768 | scmd->data_buf = cmd->pdata; | 764 | scmd->data_buf = cmd->pdata; |
769 | scmd->data_len = 1; | 765 | scmd->data_len = 1; |
770 | cmd->pdata[0] = 0; | 766 | cmd->pdata[0] = 0; |
@@ -786,7 +782,7 @@ int smu_queue_i2c(struct smu_i2c_cmd *cmd) | |||
786 | cmd->scmd.done = smu_i2c_low_completion; | 782 | cmd->scmd.done = smu_i2c_low_completion; |
787 | cmd->scmd.misc = cmd; | 783 | cmd->scmd.misc = cmd; |
788 | cmd->scmd.reply_buf = cmd->pdata; | 784 | cmd->scmd.reply_buf = cmd->pdata; |
789 | cmd->scmd.reply_len = 0x10; | 785 | cmd->scmd.reply_len = sizeof(cmd->pdata); |
790 | cmd->scmd.data_buf = (u8 *)(char *)&cmd->info; | 786 | cmd->scmd.data_buf = (u8 *)(char *)&cmd->info; |
791 | cmd->scmd.status = 1; | 787 | cmd->scmd.status = 1; |
792 | cmd->stage = 0; | 788 | cmd->stage = 0; |
@@ -909,10 +905,13 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id) | |||
909 | struct property *prop; | 905 | struct property *prop; |
910 | 906 | ||
911 | /* First query the partition info */ | 907 | /* First query the partition info */ |
908 | DPRINTK("SMU: Query partition infos ... (irq=%d)\n", smu->db_irq); | ||
912 | smu_queue_simple(&cmd, SMU_CMD_PARTITION_COMMAND, 2, | 909 | smu_queue_simple(&cmd, SMU_CMD_PARTITION_COMMAND, 2, |
913 | smu_done_complete, &comp, | 910 | smu_done_complete, &comp, |
914 | SMU_CMD_PARTITION_LATEST, id); | 911 | SMU_CMD_PARTITION_LATEST, id); |
915 | wait_for_completion(&comp); | 912 | wait_for_completion(&comp); |
913 | DPRINTK("SMU: done, status: %d, reply_len: %d\n", | ||
914 | cmd.cmd.status, cmd.cmd.reply_len); | ||
916 | 915 | ||
917 | /* Partition doesn't exist (or other error) */ | 916 | /* Partition doesn't exist (or other error) */ |
918 | if (cmd.cmd.status != 0 || cmd.cmd.reply_len != 6) | 917 | if (cmd.cmd.status != 0 || cmd.cmd.reply_len != 6) |
@@ -975,6 +974,8 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size, | |||
975 | 974 | ||
976 | sprintf(pname, "sdb-partition-%02x", id); | 975 | sprintf(pname, "sdb-partition-%02x", id); |
977 | 976 | ||
977 | DPRINTK("smu_get_sdb_partition(%02x)\n", id); | ||
978 | |||
978 | if (interruptible) { | 979 | if (interruptible) { |
979 | int rc; | 980 | int rc; |
980 | rc = down_interruptible(&smu_part_access); | 981 | rc = down_interruptible(&smu_part_access); |
@@ -986,6 +987,7 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size, | |||
986 | part = (struct smu_sdbp_header *)get_property(smu->of_node, | 987 | part = (struct smu_sdbp_header *)get_property(smu->of_node, |
987 | pname, size); | 988 | pname, size); |
988 | if (part == NULL) { | 989 | if (part == NULL) { |
990 | DPRINTK("trying to extract from SMU ...\n"); | ||
989 | part = smu_create_sdb_partition(id); | 991 | part = smu_create_sdb_partition(id); |
990 | if (part != NULL && size) | 992 | if (part != NULL && size) |
991 | *size = part->len << 2; | 993 | *size = part->len << 2; |
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c index d843a6c9c6df..2d9d79150403 100644 --- a/drivers/macintosh/via-cuda.c +++ b/drivers/macintosh/via-cuda.c | |||
@@ -127,39 +127,34 @@ struct adb_driver via_cuda_driver = { | |||
127 | #endif /* CONFIG_ADB */ | 127 | #endif /* CONFIG_ADB */ |
128 | 128 | ||
129 | #ifdef CONFIG_PPC | 129 | #ifdef CONFIG_PPC |
130 | int __init | 130 | int __init find_via_cuda(void) |
131 | find_via_cuda(void) | ||
132 | { | 131 | { |
133 | int err; | ||
134 | struct adb_request req; | 132 | struct adb_request req; |
133 | phys_addr_t taddr; | ||
134 | u32 *reg; | ||
135 | int err; | ||
135 | 136 | ||
136 | if (vias != 0) | 137 | if (vias != 0) |
137 | return 1; | 138 | return 1; |
138 | vias = find_devices("via-cuda"); | 139 | vias = of_find_node_by_name(NULL, "via-cuda"); |
139 | if (vias == 0) | 140 | if (vias == 0) |
140 | return 0; | 141 | return 0; |
141 | if (vias->next != 0) | ||
142 | printk(KERN_WARNING "Warning: only using 1st via-cuda\n"); | ||
143 | |||
144 | #if 0 | ||
145 | { int i; | ||
146 | |||
147 | printk("find_via_cuda: node = %p, addrs =", vias->node); | ||
148 | for (i = 0; i < vias->n_addrs; ++i) | ||
149 | printk(" %x(%x)", vias->addrs[i].address, vias->addrs[i].size); | ||
150 | printk(", intrs ="); | ||
151 | for (i = 0; i < vias->n_intrs; ++i) | ||
152 | printk(" %x", vias->intrs[i].line); | ||
153 | printk("\n"); } | ||
154 | #endif | ||
155 | 142 | ||
156 | if (vias->n_addrs != 1 || vias->n_intrs != 1) { | 143 | reg = (u32 *)get_property(vias, "reg", NULL); |
157 | printk(KERN_ERR "via-cuda: expecting 1 address (%d) and 1 interrupt (%d)\n", | 144 | if (reg == NULL) { |
158 | vias->n_addrs, vias->n_intrs); | 145 | printk(KERN_ERR "via-cuda: No \"reg\" property !\n"); |
159 | if (vias->n_addrs < 1 || vias->n_intrs < 1) | 146 | goto fail; |
160 | return 0; | 147 | } |
148 | taddr = of_translate_address(vias, reg); | ||
149 | if (taddr == 0) { | ||
150 | printk(KERN_ERR "via-cuda: Can't translate address !\n"); | ||
151 | goto fail; | ||
152 | } | ||
153 | via = ioremap(taddr, 0x2000); | ||
154 | if (via == NULL) { | ||
155 | printk(KERN_ERR "via-cuda: Can't map address !\n"); | ||
156 | goto fail; | ||
161 | } | 157 | } |
162 | via = ioremap(vias->addrs->address, 0x2000); | ||
163 | 158 | ||
164 | cuda_state = idle; | 159 | cuda_state = idle; |
165 | sys_ctrler = SYS_CTRLER_CUDA; | 160 | sys_ctrler = SYS_CTRLER_CUDA; |
@@ -185,6 +180,11 @@ find_via_cuda(void) | |||
185 | cuda_poll(); | 180 | cuda_poll(); |
186 | 181 | ||
187 | return 1; | 182 | return 1; |
183 | |||
184 | fail: | ||
185 | of_node_put(vias); | ||
186 | vias = NULL; | ||
187 | return 0; | ||
188 | } | 188 | } |
189 | #endif /* CONFIG_PPC */ | 189 | #endif /* CONFIG_PPC */ |
190 | 190 | ||
@@ -193,10 +193,6 @@ static int __init via_cuda_start(void) | |||
193 | if (via == NULL) | 193 | if (via == NULL) |
194 | return -ENODEV; | 194 | return -ENODEV; |
195 | 195 | ||
196 | #ifdef CONFIG_PPC | ||
197 | request_OF_resource(vias, 0, NULL); | ||
198 | #endif | ||
199 | |||
200 | if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) { | 196 | if (request_irq(CUDA_IRQ, cuda_interrupt, 0, "ADB", cuda_interrupt)) { |
201 | printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ); | 197 | printk(KERN_ERR "cuda_init: can't get irq %d\n", CUDA_IRQ); |
202 | return -EAGAIN; | 198 | return -EAGAIN; |
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 564043508569..6eb93e45fcd3 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -55,6 +55,8 @@ | |||
55 | #include <asm/sections.h> | 55 | #include <asm/sections.h> |
56 | #include <asm/irq.h> | 56 | #include <asm/irq.h> |
57 | #include <asm/pmac_feature.h> | 57 | #include <asm/pmac_feature.h> |
58 | #include <asm/pmac_pfunc.h> | ||
59 | #include <asm/pmac_low_i2c.h> | ||
58 | #include <asm/uaccess.h> | 60 | #include <asm/uaccess.h> |
59 | #include <asm/mmu_context.h> | 61 | #include <asm/mmu_context.h> |
60 | #include <asm/cputable.h> | 62 | #include <asm/cputable.h> |
@@ -147,6 +149,7 @@ static struct device_node *vias; | |||
147 | static int pmu_kind = PMU_UNKNOWN; | 149 | static int pmu_kind = PMU_UNKNOWN; |
148 | static int pmu_fully_inited = 0; | 150 | static int pmu_fully_inited = 0; |
149 | static int pmu_has_adb; | 151 | static int pmu_has_adb; |
152 | static struct device_node *gpio_node; | ||
150 | static unsigned char __iomem *gpio_reg = NULL; | 153 | static unsigned char __iomem *gpio_reg = NULL; |
151 | static int gpio_irq = -1; | 154 | static int gpio_irq = -1; |
152 | static int gpio_irq_enabled = -1; | 155 | static int gpio_irq_enabled = -1; |
@@ -157,8 +160,8 @@ static int pmu_version; | |||
157 | static int drop_interrupts; | 160 | static int drop_interrupts; |
158 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) | 161 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) |
159 | static int option_lid_wakeup = 1; | 162 | static int option_lid_wakeup = 1; |
160 | static int sleep_in_progress; | ||
161 | #endif /* CONFIG_PM && CONFIG_PPC32 */ | 163 | #endif /* CONFIG_PM && CONFIG_PPC32 */ |
164 | static int sleep_in_progress; | ||
162 | static unsigned long async_req_locks; | 165 | static unsigned long async_req_locks; |
163 | static unsigned int pmu_irq_stats[11]; | 166 | static unsigned int pmu_irq_stats[11]; |
164 | 167 | ||
@@ -196,7 +199,6 @@ static int pmu_adb_reset_bus(void); | |||
196 | #endif /* CONFIG_ADB */ | 199 | #endif /* CONFIG_ADB */ |
197 | 200 | ||
198 | static int init_pmu(void); | 201 | static int init_pmu(void); |
199 | static int pmu_queue_request(struct adb_request *req); | ||
200 | static void pmu_start(void); | 202 | static void pmu_start(void); |
201 | static irqreturn_t via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs); | 203 | static irqreturn_t via_pmu_interrupt(int irq, void *arg, struct pt_regs *regs); |
202 | static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs); | 204 | static irqreturn_t gpio1_interrupt(int irq, void *arg, struct pt_regs *regs); |
@@ -295,22 +297,26 @@ static struct backlight_controller pmu_backlight_controller = { | |||
295 | }; | 297 | }; |
296 | #endif /* CONFIG_PMAC_BACKLIGHT */ | 298 | #endif /* CONFIG_PMAC_BACKLIGHT */ |
297 | 299 | ||
298 | int | 300 | int __init find_via_pmu(void) |
299 | find_via_pmu(void) | ||
300 | { | 301 | { |
302 | u64 taddr; | ||
303 | u32 *reg; | ||
304 | |||
301 | if (via != 0) | 305 | if (via != 0) |
302 | return 1; | 306 | return 1; |
303 | vias = find_devices("via-pmu"); | 307 | vias = of_find_node_by_name(NULL, "via-pmu"); |
304 | if (vias == 0) | 308 | if (vias == NULL) |
305 | return 0; | 309 | return 0; |
306 | if (vias->next != 0) | ||
307 | printk(KERN_WARNING "Warning: only using 1st via-pmu\n"); | ||
308 | 310 | ||
309 | if (vias->n_addrs < 1 || vias->n_intrs < 1) { | 311 | reg = (u32 *)get_property(vias, "reg", NULL); |
310 | printk(KERN_ERR "via-pmu: %d addresses, %d interrupts!\n", | 312 | if (reg == NULL) { |
311 | vias->n_addrs, vias->n_intrs); | 313 | printk(KERN_ERR "via-pmu: No \"reg\" property !\n"); |
312 | if (vias->n_addrs < 1 || vias->n_intrs < 1) | 314 | goto fail; |
313 | return 0; | 315 | } |
316 | taddr = of_translate_address(vias, reg); | ||
317 | if (taddr == OF_BAD_ADDR) { | ||
318 | printk(KERN_ERR "via-pmu: Can't translate address !\n"); | ||
319 | goto fail; | ||
314 | } | 320 | } |
315 | 321 | ||
316 | spin_lock_init(&pmu_lock); | 322 | spin_lock_init(&pmu_lock); |
@@ -331,7 +337,8 @@ find_via_pmu(void) | |||
331 | pmu_kind = PMU_HEATHROW_BASED; | 337 | pmu_kind = PMU_HEATHROW_BASED; |
332 | else if (device_is_compatible(vias->parent, "Keylargo") | 338 | else if (device_is_compatible(vias->parent, "Keylargo") |
333 | || device_is_compatible(vias->parent, "K2-Keylargo")) { | 339 | || device_is_compatible(vias->parent, "K2-Keylargo")) { |
334 | struct device_node *gpio, *gpiop; | 340 | struct device_node *gpiop; |
341 | u64 gaddr = OF_BAD_ADDR; | ||
335 | 342 | ||
336 | pmu_kind = PMU_KEYLARGO_BASED; | 343 | pmu_kind = PMU_KEYLARGO_BASED; |
337 | pmu_has_adb = (find_type_devices("adb") != NULL); | 344 | pmu_has_adb = (find_type_devices("adb") != NULL); |
@@ -341,19 +348,24 @@ find_via_pmu(void) | |||
341 | PMU_INT_TICK | | 348 | PMU_INT_TICK | |
342 | PMU_INT_ENVIRONMENT; | 349 | PMU_INT_ENVIRONMENT; |
343 | 350 | ||
344 | gpiop = find_devices("gpio"); | 351 | gpiop = of_find_node_by_name(NULL, "gpio"); |
345 | if (gpiop && gpiop->n_addrs) { | 352 | if (gpiop) { |
346 | gpio_reg = ioremap(gpiop->addrs->address, 0x10); | 353 | reg = (u32 *)get_property(gpiop, "reg", NULL); |
347 | gpio = find_devices("extint-gpio1"); | 354 | if (reg) |
348 | if (gpio == NULL) | 355 | gaddr = of_translate_address(gpiop, reg); |
349 | gpio = find_devices("pmu-interrupt"); | 356 | if (gaddr != OF_BAD_ADDR) |
350 | if (gpio && gpio->parent == gpiop && gpio->n_intrs) | 357 | gpio_reg = ioremap(gaddr, 0x10); |
351 | gpio_irq = gpio->intrs[0].line; | ||
352 | } | 358 | } |
359 | if (gpio_reg == NULL) | ||
360 | printk(KERN_ERR "via-pmu: Can't find GPIO reg !\n"); | ||
353 | } else | 361 | } else |
354 | pmu_kind = PMU_UNKNOWN; | 362 | pmu_kind = PMU_UNKNOWN; |
355 | 363 | ||
356 | via = ioremap(vias->addrs->address, 0x2000); | 364 | via = ioremap(taddr, 0x2000); |
365 | if (via == NULL) { | ||
366 | printk(KERN_ERR "via-pmu: Can't map address !\n"); | ||
367 | goto fail; | ||
368 | } | ||
357 | 369 | ||
358 | out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */ | 370 | out_8(&via[IER], IER_CLR | 0x7f); /* disable all intrs */ |
359 | out_8(&via[IFR], 0x7f); /* clear IFR */ | 371 | out_8(&via[IFR], 0x7f); /* clear IFR */ |
@@ -365,23 +377,25 @@ find_via_pmu(void) | |||
365 | return 0; | 377 | return 0; |
366 | } | 378 | } |
367 | 379 | ||
368 | printk(KERN_INFO "PMU driver %d initialized for %s, firmware: %02x\n", | 380 | printk(KERN_INFO "PMU driver v%d initialized for %s, firmware: %02x\n", |
369 | PMU_DRIVER_VERSION, pbook_type[pmu_kind], pmu_version); | 381 | PMU_DRIVER_VERSION, pbook_type[pmu_kind], pmu_version); |
370 | 382 | ||
371 | sys_ctrler = SYS_CTRLER_PMU; | 383 | sys_ctrler = SYS_CTRLER_PMU; |
372 | 384 | ||
373 | return 1; | 385 | return 1; |
386 | fail: | ||
387 | of_node_put(vias); | ||
388 | vias = NULL; | ||
389 | return 0; | ||
374 | } | 390 | } |
375 | 391 | ||
376 | #ifdef CONFIG_ADB | 392 | #ifdef CONFIG_ADB |
377 | static int | 393 | static int pmu_probe(void) |
378 | pmu_probe(void) | ||
379 | { | 394 | { |
380 | return vias == NULL? -ENODEV: 0; | 395 | return vias == NULL? -ENODEV: 0; |
381 | } | 396 | } |
382 | 397 | ||
383 | static int __init | 398 | static int __init pmu_init(void) |
384 | pmu_init(void) | ||
385 | { | 399 | { |
386 | if (vias == NULL) | 400 | if (vias == NULL) |
387 | return -ENODEV; | 401 | return -ENODEV; |
@@ -405,7 +419,7 @@ static int __init via_pmu_start(void) | |||
405 | bright_req_2.complete = 1; | 419 | bright_req_2.complete = 1; |
406 | batt_req.complete = 1; | 420 | batt_req.complete = 1; |
407 | 421 | ||
408 | #if defined(CONFIG_PPC32) && !defined(CONFIG_PPC_MERGE) | 422 | #ifndef CONFIG_PPC_MERGE |
409 | if (pmu_kind == PMU_KEYLARGO_BASED) | 423 | if (pmu_kind == PMU_KEYLARGO_BASED) |
410 | openpic_set_irq_priority(vias->intrs[0].line, | 424 | openpic_set_irq_priority(vias->intrs[0].line, |
411 | OPENPIC_PRIORITY_DEFAULT + 1); | 425 | OPENPIC_PRIORITY_DEFAULT + 1); |
@@ -418,10 +432,22 @@ static int __init via_pmu_start(void) | |||
418 | return -EAGAIN; | 432 | return -EAGAIN; |
419 | } | 433 | } |
420 | 434 | ||
421 | if (pmu_kind == PMU_KEYLARGO_BASED && gpio_irq != -1) { | 435 | if (pmu_kind == PMU_KEYLARGO_BASED) { |
422 | if (request_irq(gpio_irq, gpio1_interrupt, 0, "GPIO1 ADB", (void *)0)) | 436 | gpio_node = of_find_node_by_name(NULL, "extint-gpio1"); |
423 | printk(KERN_ERR "pmu: can't get irq %d (GPIO1)\n", gpio_irq); | 437 | if (gpio_node == NULL) |
424 | gpio_irq_enabled = 1; | 438 | gpio_node = of_find_node_by_name(NULL, |
439 | "pmu-interrupt"); | ||
440 | if (gpio_node && gpio_node->n_intrs > 0) | ||
441 | gpio_irq = gpio_node->intrs[0].line; | ||
442 | |||
443 | if (gpio_irq != -1) { | ||
444 | if (request_irq(gpio_irq, gpio1_interrupt, 0, | ||
445 | "GPIO1 ADB", (void *)0)) | ||
446 | printk(KERN_ERR "pmu: can't get irq %d" | ||
447 | " (GPIO1)\n", gpio_irq); | ||
448 | else | ||
449 | gpio_irq_enabled = 1; | ||
450 | } | ||
425 | } | 451 | } |
426 | 452 | ||
427 | /* Enable interrupts */ | 453 | /* Enable interrupts */ |
@@ -454,9 +480,6 @@ static int __init via_pmu_dev_init(void) | |||
454 | if (vias == NULL) | 480 | if (vias == NULL) |
455 | return -ENODEV; | 481 | return -ENODEV; |
456 | 482 | ||
457 | #ifndef CONFIG_PPC64 | ||
458 | request_OF_resource(vias, 0, NULL); | ||
459 | #endif | ||
460 | #ifdef CONFIG_PMAC_BACKLIGHT | 483 | #ifdef CONFIG_PMAC_BACKLIGHT |
461 | /* Enable backlight */ | 484 | /* Enable backlight */ |
462 | register_backlight_controller(&pmu_backlight_controller, NULL, "pmu"); | 485 | register_backlight_controller(&pmu_backlight_controller, NULL, "pmu"); |
@@ -1371,7 +1394,6 @@ next: | |||
1371 | } | 1394 | } |
1372 | pmu_done(req); | 1395 | pmu_done(req); |
1373 | } else { | 1396 | } else { |
1374 | #if defined(CONFIG_XMON) && !defined(CONFIG_PPC64) | ||
1375 | if (len == 4 && data[1] == 0x2c) { | 1397 | if (len == 4 && data[1] == 0x2c) { |
1376 | extern int xmon_wants_key, xmon_adb_keycode; | 1398 | extern int xmon_wants_key, xmon_adb_keycode; |
1377 | if (xmon_wants_key) { | 1399 | if (xmon_wants_key) { |
@@ -1379,7 +1401,6 @@ next: | |||
1379 | return; | 1401 | return; |
1380 | } | 1402 | } |
1381 | } | 1403 | } |
1382 | #endif /* defined(CONFIG_XMON) && !defined(CONFIG_PPC64) */ | ||
1383 | #ifdef CONFIG_ADB | 1404 | #ifdef CONFIG_ADB |
1384 | /* | 1405 | /* |
1385 | * XXX On the [23]400 the PMU gives us an up | 1406 | * XXX On the [23]400 the PMU gives us an up |
@@ -1782,258 +1803,6 @@ pmu_present(void) | |||
1782 | return via != 0; | 1803 | return via != 0; |
1783 | } | 1804 | } |
1784 | 1805 | ||
1785 | struct pmu_i2c_hdr { | ||
1786 | u8 bus; | ||
1787 | u8 mode; | ||
1788 | u8 bus2; | ||
1789 | u8 address; | ||
1790 | u8 sub_addr; | ||
1791 | u8 comb_addr; | ||
1792 | u8 count; | ||
1793 | }; | ||
1794 | |||
1795 | int | ||
1796 | pmu_i2c_combined_read(int bus, int addr, int subaddr, u8* data, int len) | ||
1797 | { | ||
1798 | struct adb_request req; | ||
1799 | struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; | ||
1800 | int retry; | ||
1801 | int rc; | ||
1802 | |||
1803 | for (retry=0; retry<16; retry++) { | ||
1804 | memset(&req, 0, sizeof(req)); | ||
1805 | |||
1806 | hdr->bus = bus; | ||
1807 | hdr->address = addr & 0xfe; | ||
1808 | hdr->mode = PMU_I2C_MODE_COMBINED; | ||
1809 | hdr->bus2 = 0; | ||
1810 | hdr->sub_addr = subaddr; | ||
1811 | hdr->comb_addr = addr | 1; | ||
1812 | hdr->count = len; | ||
1813 | |||
1814 | req.nbytes = sizeof(struct pmu_i2c_hdr) + 1; | ||
1815 | req.reply_expected = 0; | ||
1816 | req.reply_len = 0; | ||
1817 | req.data[0] = PMU_I2C_CMD; | ||
1818 | req.reply[0] = 0xff; | ||
1819 | rc = pmu_queue_request(&req); | ||
1820 | if (rc) | ||
1821 | return rc; | ||
1822 | while(!req.complete) | ||
1823 | pmu_poll(); | ||
1824 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
1825 | break; | ||
1826 | mdelay(15); | ||
1827 | } | ||
1828 | if (req.reply[0] != PMU_I2C_STATUS_OK) | ||
1829 | return -1; | ||
1830 | |||
1831 | for (retry=0; retry<16; retry++) { | ||
1832 | memset(&req, 0, sizeof(req)); | ||
1833 | |||
1834 | mdelay(15); | ||
1835 | |||
1836 | hdr->bus = PMU_I2C_BUS_STATUS; | ||
1837 | req.reply[0] = 0xff; | ||
1838 | |||
1839 | req.nbytes = 2; | ||
1840 | req.reply_expected = 0; | ||
1841 | req.reply_len = 0; | ||
1842 | req.data[0] = PMU_I2C_CMD; | ||
1843 | rc = pmu_queue_request(&req); | ||
1844 | if (rc) | ||
1845 | return rc; | ||
1846 | while(!req.complete) | ||
1847 | pmu_poll(); | ||
1848 | if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) { | ||
1849 | memcpy(data, &req.reply[1], req.reply_len - 1); | ||
1850 | return req.reply_len - 1; | ||
1851 | } | ||
1852 | } | ||
1853 | return -1; | ||
1854 | } | ||
1855 | |||
1856 | int | ||
1857 | pmu_i2c_stdsub_write(int bus, int addr, int subaddr, u8* data, int len) | ||
1858 | { | ||
1859 | struct adb_request req; | ||
1860 | struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; | ||
1861 | int retry; | ||
1862 | int rc; | ||
1863 | |||
1864 | for (retry=0; retry<16; retry++) { | ||
1865 | memset(&req, 0, sizeof(req)); | ||
1866 | |||
1867 | hdr->bus = bus; | ||
1868 | hdr->address = addr & 0xfe; | ||
1869 | hdr->mode = PMU_I2C_MODE_STDSUB; | ||
1870 | hdr->bus2 = 0; | ||
1871 | hdr->sub_addr = subaddr; | ||
1872 | hdr->comb_addr = addr & 0xfe; | ||
1873 | hdr->count = len; | ||
1874 | |||
1875 | req.data[0] = PMU_I2C_CMD; | ||
1876 | memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len); | ||
1877 | req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1; | ||
1878 | req.reply_expected = 0; | ||
1879 | req.reply_len = 0; | ||
1880 | req.reply[0] = 0xff; | ||
1881 | rc = pmu_queue_request(&req); | ||
1882 | if (rc) | ||
1883 | return rc; | ||
1884 | while(!req.complete) | ||
1885 | pmu_poll(); | ||
1886 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
1887 | break; | ||
1888 | mdelay(15); | ||
1889 | } | ||
1890 | if (req.reply[0] != PMU_I2C_STATUS_OK) | ||
1891 | return -1; | ||
1892 | |||
1893 | for (retry=0; retry<16; retry++) { | ||
1894 | memset(&req, 0, sizeof(req)); | ||
1895 | |||
1896 | mdelay(15); | ||
1897 | |||
1898 | hdr->bus = PMU_I2C_BUS_STATUS; | ||
1899 | req.reply[0] = 0xff; | ||
1900 | |||
1901 | req.nbytes = 2; | ||
1902 | req.reply_expected = 0; | ||
1903 | req.reply_len = 0; | ||
1904 | req.data[0] = PMU_I2C_CMD; | ||
1905 | rc = pmu_queue_request(&req); | ||
1906 | if (rc) | ||
1907 | return rc; | ||
1908 | while(!req.complete) | ||
1909 | pmu_poll(); | ||
1910 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
1911 | return len; | ||
1912 | } | ||
1913 | return -1; | ||
1914 | } | ||
1915 | |||
1916 | int | ||
1917 | pmu_i2c_simple_read(int bus, int addr, u8* data, int len) | ||
1918 | { | ||
1919 | struct adb_request req; | ||
1920 | struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; | ||
1921 | int retry; | ||
1922 | int rc; | ||
1923 | |||
1924 | for (retry=0; retry<16; retry++) { | ||
1925 | memset(&req, 0, sizeof(req)); | ||
1926 | |||
1927 | hdr->bus = bus; | ||
1928 | hdr->address = addr | 1; | ||
1929 | hdr->mode = PMU_I2C_MODE_SIMPLE; | ||
1930 | hdr->bus2 = 0; | ||
1931 | hdr->sub_addr = 0; | ||
1932 | hdr->comb_addr = 0; | ||
1933 | hdr->count = len; | ||
1934 | |||
1935 | req.data[0] = PMU_I2C_CMD; | ||
1936 | req.nbytes = sizeof(struct pmu_i2c_hdr) + 1; | ||
1937 | req.reply_expected = 0; | ||
1938 | req.reply_len = 0; | ||
1939 | req.reply[0] = 0xff; | ||
1940 | rc = pmu_queue_request(&req); | ||
1941 | if (rc) | ||
1942 | return rc; | ||
1943 | while(!req.complete) | ||
1944 | pmu_poll(); | ||
1945 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
1946 | break; | ||
1947 | mdelay(15); | ||
1948 | } | ||
1949 | if (req.reply[0] != PMU_I2C_STATUS_OK) | ||
1950 | return -1; | ||
1951 | |||
1952 | for (retry=0; retry<16; retry++) { | ||
1953 | memset(&req, 0, sizeof(req)); | ||
1954 | |||
1955 | mdelay(15); | ||
1956 | |||
1957 | hdr->bus = PMU_I2C_BUS_STATUS; | ||
1958 | req.reply[0] = 0xff; | ||
1959 | |||
1960 | req.nbytes = 2; | ||
1961 | req.reply_expected = 0; | ||
1962 | req.reply_len = 0; | ||
1963 | req.data[0] = PMU_I2C_CMD; | ||
1964 | rc = pmu_queue_request(&req); | ||
1965 | if (rc) | ||
1966 | return rc; | ||
1967 | while(!req.complete) | ||
1968 | pmu_poll(); | ||
1969 | if (req.reply[0] == PMU_I2C_STATUS_DATAREAD) { | ||
1970 | memcpy(data, &req.reply[1], req.reply_len - 1); | ||
1971 | return req.reply_len - 1; | ||
1972 | } | ||
1973 | } | ||
1974 | return -1; | ||
1975 | } | ||
1976 | |||
1977 | int | ||
1978 | pmu_i2c_simple_write(int bus, int addr, u8* data, int len) | ||
1979 | { | ||
1980 | struct adb_request req; | ||
1981 | struct pmu_i2c_hdr *hdr = (struct pmu_i2c_hdr *)&req.data[1]; | ||
1982 | int retry; | ||
1983 | int rc; | ||
1984 | |||
1985 | for (retry=0; retry<16; retry++) { | ||
1986 | memset(&req, 0, sizeof(req)); | ||
1987 | |||
1988 | hdr->bus = bus; | ||
1989 | hdr->address = addr & 0xfe; | ||
1990 | hdr->mode = PMU_I2C_MODE_SIMPLE; | ||
1991 | hdr->bus2 = 0; | ||
1992 | hdr->sub_addr = 0; | ||
1993 | hdr->comb_addr = 0; | ||
1994 | hdr->count = len; | ||
1995 | |||
1996 | req.data[0] = PMU_I2C_CMD; | ||
1997 | memcpy(&req.data[sizeof(struct pmu_i2c_hdr) + 1], data, len); | ||
1998 | req.nbytes = sizeof(struct pmu_i2c_hdr) + len + 1; | ||
1999 | req.reply_expected = 0; | ||
2000 | req.reply_len = 0; | ||
2001 | req.reply[0] = 0xff; | ||
2002 | rc = pmu_queue_request(&req); | ||
2003 | if (rc) | ||
2004 | return rc; | ||
2005 | while(!req.complete) | ||
2006 | pmu_poll(); | ||
2007 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
2008 | break; | ||
2009 | mdelay(15); | ||
2010 | } | ||
2011 | if (req.reply[0] != PMU_I2C_STATUS_OK) | ||
2012 | return -1; | ||
2013 | |||
2014 | for (retry=0; retry<16; retry++) { | ||
2015 | memset(&req, 0, sizeof(req)); | ||
2016 | |||
2017 | mdelay(15); | ||
2018 | |||
2019 | hdr->bus = PMU_I2C_BUS_STATUS; | ||
2020 | req.reply[0] = 0xff; | ||
2021 | |||
2022 | req.nbytes = 2; | ||
2023 | req.reply_expected = 0; | ||
2024 | req.reply_len = 0; | ||
2025 | req.data[0] = PMU_I2C_CMD; | ||
2026 | rc = pmu_queue_request(&req); | ||
2027 | if (rc) | ||
2028 | return rc; | ||
2029 | while(!req.complete) | ||
2030 | pmu_poll(); | ||
2031 | if (req.reply[0] == PMU_I2C_STATUS_OK) | ||
2032 | return len; | ||
2033 | } | ||
2034 | return -1; | ||
2035 | } | ||
2036 | |||
2037 | #ifdef CONFIG_PM | 1806 | #ifdef CONFIG_PM |
2038 | 1807 | ||
2039 | static LIST_HEAD(sleep_notifiers); | 1808 | static LIST_HEAD(sleep_notifiers); |
@@ -2338,8 +2107,9 @@ pmac_suspend_devices(void) | |||
2338 | return -EBUSY; | 2107 | return -EBUSY; |
2339 | } | 2108 | } |
2340 | 2109 | ||
2341 | /* Disable clock spreading on some machines */ | 2110 | /* Call platform functions marked "on sleep" */ |
2342 | pmac_tweak_clock_spreading(0); | 2111 | pmac_pfunc_i2c_suspend(); |
2112 | pmac_pfunc_base_suspend(); | ||
2343 | 2113 | ||
2344 | /* Stop preemption */ | 2114 | /* Stop preemption */ |
2345 | preempt_disable(); | 2115 | preempt_disable(); |
@@ -2411,8 +2181,9 @@ pmac_wakeup_devices(void) | |||
2411 | mdelay(10); | 2181 | mdelay(10); |
2412 | preempt_enable(); | 2182 | preempt_enable(); |
2413 | 2183 | ||
2414 | /* Re-enable clock spreading on some machines */ | 2184 | /* Call platform functions marked "on wake" */ |
2415 | pmac_tweak_clock_spreading(1); | 2185 | pmac_pfunc_base_resume(); |
2186 | pmac_pfunc_i2c_resume(); | ||
2416 | 2187 | ||
2417 | /* Resume devices */ | 2188 | /* Resume devices */ |
2418 | device_resume(); | 2189 | device_resume(); |
@@ -3130,16 +2901,13 @@ static int __init init_pmu_sysfs(void) | |||
3130 | subsys_initcall(init_pmu_sysfs); | 2901 | subsys_initcall(init_pmu_sysfs); |
3131 | 2902 | ||
3132 | EXPORT_SYMBOL(pmu_request); | 2903 | EXPORT_SYMBOL(pmu_request); |
2904 | EXPORT_SYMBOL(pmu_queue_request); | ||
3133 | EXPORT_SYMBOL(pmu_poll); | 2905 | EXPORT_SYMBOL(pmu_poll); |
3134 | EXPORT_SYMBOL(pmu_poll_adb); | 2906 | EXPORT_SYMBOL(pmu_poll_adb); |
3135 | EXPORT_SYMBOL(pmu_wait_complete); | 2907 | EXPORT_SYMBOL(pmu_wait_complete); |
3136 | EXPORT_SYMBOL(pmu_suspend); | 2908 | EXPORT_SYMBOL(pmu_suspend); |
3137 | EXPORT_SYMBOL(pmu_resume); | 2909 | EXPORT_SYMBOL(pmu_resume); |
3138 | EXPORT_SYMBOL(pmu_unlock); | 2910 | EXPORT_SYMBOL(pmu_unlock); |
3139 | EXPORT_SYMBOL(pmu_i2c_combined_read); | ||
3140 | EXPORT_SYMBOL(pmu_i2c_stdsub_write); | ||
3141 | EXPORT_SYMBOL(pmu_i2c_simple_read); | ||
3142 | EXPORT_SYMBOL(pmu_i2c_simple_write); | ||
3143 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) | 2911 | #if defined(CONFIG_PM) && defined(CONFIG_PPC32) |
3144 | EXPORT_SYMBOL(pmu_enable_irled); | 2912 | EXPORT_SYMBOL(pmu_enable_irled); |
3145 | EXPORT_SYMBOL(pmu_battery_count); | 2913 | EXPORT_SYMBOL(pmu_battery_count); |
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c index 57460e46c89f..906d3ecae6e6 100644 --- a/drivers/macintosh/windfarm_lm75_sensor.c +++ b/drivers/macintosh/windfarm_lm75_sensor.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <asm/io.h> | 21 | #include <asm/io.h> |
22 | #include <asm/system.h> | 22 | #include <asm/system.h> |
23 | #include <asm/sections.h> | 23 | #include <asm/sections.h> |
24 | #include <asm/pmac_low_i2c.h> | ||
24 | 25 | ||
25 | #include "windfarm.h" | 26 | #include "windfarm.h" |
26 | 27 | ||
@@ -157,53 +158,21 @@ static struct wf_lm75_sensor *wf_lm75_create(struct i2c_adapter *adapter, | |||
157 | 158 | ||
158 | static int wf_lm75_attach(struct i2c_adapter *adapter) | 159 | static int wf_lm75_attach(struct i2c_adapter *adapter) |
159 | { | 160 | { |
160 | u8 bus_id; | 161 | struct device_node *busnode, *dev; |
161 | struct device_node *smu, *bus, *dev; | 162 | struct pmac_i2c_bus *bus; |
162 | |||
163 | /* We currently only deal with LM75's hanging off the SMU | ||
164 | * i2c busses. If we extend that driver to other/older | ||
165 | * machines, we should split this function into SMU-i2c, | ||
166 | * keywest-i2c, PMU-i2c, ... | ||
167 | */ | ||
168 | 163 | ||
169 | DBG("wf_lm75: adapter %s detected\n", adapter->name); | 164 | DBG("wf_lm75: adapter %s detected\n", adapter->name); |
170 | 165 | ||
171 | if (strncmp(adapter->name, "smu-i2c-", 8) != 0) | 166 | bus = pmac_i2c_adapter_to_bus(adapter); |
172 | return 0; | 167 | if (bus == NULL) |
173 | smu = of_find_node_by_type(NULL, "smu"); | 168 | return -ENODEV; |
174 | if (smu == NULL) | 169 | busnode = pmac_i2c_get_bus_node(bus); |
175 | return 0; | ||
176 | |||
177 | /* Look for the bus in the device-tree */ | ||
178 | bus_id = (u8)simple_strtoul(adapter->name + 8, NULL, 16); | ||
179 | |||
180 | DBG("wf_lm75: bus ID is %x\n", bus_id); | ||
181 | |||
182 | /* Look for sensors subdir */ | ||
183 | for (bus = NULL; | ||
184 | (bus = of_get_next_child(smu, bus)) != NULL;) { | ||
185 | u32 *reg; | ||
186 | |||
187 | if (strcmp(bus->name, "i2c")) | ||
188 | continue; | ||
189 | reg = (u32 *)get_property(bus, "reg", NULL); | ||
190 | if (reg == NULL) | ||
191 | continue; | ||
192 | if (bus_id == *reg) | ||
193 | break; | ||
194 | } | ||
195 | of_node_put(smu); | ||
196 | if (bus == NULL) { | ||
197 | printk(KERN_WARNING "windfarm: SMU i2c bus 0x%x not found" | ||
198 | " in device-tree !\n", bus_id); | ||
199 | return 0; | ||
200 | } | ||
201 | 170 | ||
202 | DBG("wf_lm75: bus found, looking for device...\n"); | 171 | DBG("wf_lm75: bus found, looking for device...\n"); |
203 | 172 | ||
204 | /* Now look for lm75(s) in there */ | 173 | /* Now look for lm75(s) in there */ |
205 | for (dev = NULL; | 174 | for (dev = NULL; |
206 | (dev = of_get_next_child(bus, dev)) != NULL;) { | 175 | (dev = of_get_next_child(busnode, dev)) != NULL;) { |
207 | const char *loc = | 176 | const char *loc = |
208 | get_property(dev, "hwsensor-location", NULL); | 177 | get_property(dev, "hwsensor-location", NULL); |
209 | u32 *reg = (u32 *)get_property(dev, "reg", NULL); | 178 | u32 *reg = (u32 *)get_property(dev, "reg", NULL); |
@@ -217,9 +186,6 @@ static int wf_lm75_attach(struct i2c_adapter *adapter) | |||
217 | else if (device_is_compatible(dev, "ds1775")) | 186 | else if (device_is_compatible(dev, "ds1775")) |
218 | wf_lm75_create(adapter, *reg, 1, loc); | 187 | wf_lm75_create(adapter, *reg, 1, loc); |
219 | } | 188 | } |
220 | |||
221 | of_node_put(bus); | ||
222 | |||
223 | return 0; | 189 | return 0; |
224 | } | 190 | } |
225 | 191 | ||