Skip to content

Commit

Permalink
powerpc/powermac: Make auto-loading of therm_pm72 possible
Browse files Browse the repository at this point in the history
The therm_pm72 driver, used on the PowerMac G5 range, cannot be
auto-loaded, since the driver itself creates both the device node
and the driver instance.

Moving the device node creation to the platform setup code and
adding the necessary MODULE_DEVICE_TABLE() information allows the
driver to be automatically loaded by udev on any semi-modern
distribution.

It "fixes" a major source of problem on G5 machines where the
driver wasn't explicitely loaded by default, and the system
would automatically shutdown under load.

Tested on an Xserve G5.

Signed-off-by: Marc Zyngier <maz@misterjones.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
  • Loading branch information
Marc Zyngier authored and Benjamin Herrenschmidt committed Dec 9, 2010
1 parent 982cf00 commit 98b14d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
9 changes: 9 additions & 0 deletions arch/powerpc/platforms/powermac/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,15 @@ static int __init pmac_declare_of_platform_devices(void)
of_platform_device_create(np, "smu", NULL);
of_node_put(np);
}
np = of_find_node_by_type(NULL, "fcu");
if (np == NULL) {
/* Some machines have strangely broken device-tree */
np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e");
}
if (np) {
of_platform_device_create(np, "temperature", NULL);
of_node_put(np);
}

return 0;
}
Expand Down
30 changes: 5 additions & 25 deletions drivers/macintosh/therm_pm72.c
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,9 @@ static void fcu_lookup_fans(struct device_node *fcu_node)
static int fcu_of_probe(struct platform_device* dev, const struct of_device_id *match)
{
state = state_detached;
of_dev = dev;

dev_info(&dev->dev, "PowerMac G5 Thermal control driver %s\n", VERSION);

/* Lookup the fans in the device tree */
fcu_lookup_fans(dev->dev.of_node);
Expand All @@ -2235,6 +2238,7 @@ static const struct of_device_id fcu_match[] =
},
{},
};
MODULE_DEVICE_TABLE(of, fcu_match);

static struct of_platform_driver fcu_of_platform_driver =
{
Expand All @@ -2252,43 +2256,19 @@ static struct of_platform_driver fcu_of_platform_driver =
*/
static int __init therm_pm72_init(void)
{
struct device_node *np;

rackmac = of_machine_is_compatible("RackMac3,1");

if (!of_machine_is_compatible("PowerMac7,2") &&
!of_machine_is_compatible("PowerMac7,3") &&
!rackmac)
return -ENODEV;

printk(KERN_INFO "PowerMac G5 Thermal control driver %s\n", VERSION);

np = of_find_node_by_type(NULL, "fcu");
if (np == NULL) {
/* Some machines have strangely broken device-tree */
np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e");
if (np == NULL) {
printk(KERN_ERR "Can't find FCU in device-tree !\n");
return -ENODEV;
}
}
of_dev = of_platform_device_create(np, "temperature", NULL);
if (of_dev == NULL) {
printk(KERN_ERR "Can't register FCU platform device !\n");
return -ENODEV;
}

of_register_platform_driver(&fcu_of_platform_driver);

return 0;
return of_register_platform_driver(&fcu_of_platform_driver);
}

static void __exit therm_pm72_exit(void)
{
of_unregister_platform_driver(&fcu_of_platform_driver);

if (of_dev)
of_device_unregister(of_dev);
}

module_init(therm_pm72_init);
Expand Down

0 comments on commit 98b14d6

Please sign in to comment.