Skip to content

Commit 0365ba7

Browse files
ozbenhLinus Torvalds
authored andcommitted
[PATCH] ppc64: SMU driver update & i2c support
The SMU is the "system controller" chip used by Apple recent G5 machines including the iMac G5. It drives things like fans, i2c busses, real time clock, etc... The current kernel contains a very crude driver that doesn't do much more than reading the real time clock synchronously. This is a completely rewritten driver that provides interrupt based command queuing, a userland interface, and an i2c/smbus driver for accessing the devices hanging off the SMU i2c busses like temperature sensors. This driver is a basic block for upcoming work on thermal control for those machines, among others. Signed-off-by: Benjamin Herrenschmidt <[email protected]> Cc: Jean Delvare <[email protected]> Cc: Greg KH <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 0f32907 commit 0365ba7

File tree

15 files changed

+1618
-163
lines changed

15 files changed

+1618
-163
lines changed

arch/ppc/platforms/pmac_setup.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,25 +719,27 @@ pmac_declare_of_platform_devices(void)
719719
if (np) {
720720
for (np = np->child; np != NULL; np = np->sibling)
721721
if (strncmp(np->name, "i2c", 3) == 0) {
722-
of_platform_device_create(np, "uni-n-i2c");
722+
of_platform_device_create(np, "uni-n-i2c",
723+
NULL);
723724
break;
724725
}
725726
}
726727
np = find_devices("u3");
727728
if (np) {
728729
for (np = np->child; np != NULL; np = np->sibling)
729730
if (strncmp(np->name, "i2c", 3) == 0) {
730-
of_platform_device_create(np, "u3-i2c");
731+
of_platform_device_create(np, "u3-i2c",
732+
NULL);
731733
break;
732734
}
733735
}
734736

735737
np = find_devices("valkyrie");
736738
if (np)
737-
of_platform_device_create(np, "valkyrie");
739+
of_platform_device_create(np, "valkyrie", NULL);
738740
np = find_devices("platinum");
739741
if (np)
740-
of_platform_device_create(np, "platinum");
742+
of_platform_device_create(np, "platinum", NULL);
741743

742744
return 0;
743745
}

arch/ppc/syslib/of_device.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,9 @@ void of_device_unregister(struct of_device *ofdev)
234234
device_unregister(&ofdev->dev);
235235
}
236236

237-
struct of_device* of_platform_device_create(struct device_node *np, const char *bus_id)
237+
struct of_device* of_platform_device_create(struct device_node *np,
238+
const char *bus_id,
239+
struct device *parent)
238240
{
239241
struct of_device *dev;
240242
u32 *reg;
@@ -247,7 +249,7 @@ struct of_device* of_platform_device_create(struct device_node *np, const char *
247249
dev->node = of_node_get(np);
248250
dev->dma_mask = 0xffffffffUL;
249251
dev->dev.dma_mask = &dev->dma_mask;
250-
dev->dev.parent = NULL;
252+
dev->dev.parent = parent;
251253
dev->dev.bus = &of_platform_bus_type;
252254
dev->dev.release = of_release_dev;
253255

arch/ppc64/kernel/of_device.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ void of_device_unregister(struct of_device *ofdev)
233233
device_unregister(&ofdev->dev);
234234
}
235235

236-
struct of_device* of_platform_device_create(struct device_node *np, const char *bus_id)
236+
struct of_device* of_platform_device_create(struct device_node *np,
237+
const char *bus_id,
238+
struct device *parent)
237239
{
238240
struct of_device *dev;
239241

@@ -245,7 +247,7 @@ struct of_device* of_platform_device_create(struct device_node *np, const char *
245247
dev->node = np;
246248
dev->dma_mask = 0xffffffffUL;
247249
dev->dev.dma_mask = &dev->dma_mask;
248-
dev->dev.parent = NULL;
250+
dev->dev.parent = parent;
249251
dev->dev.bus = &of_platform_bus_type;
250252
dev->dev.release = of_release_dev;
251253

@@ -259,6 +261,7 @@ struct of_device* of_platform_device_create(struct device_node *np, const char *
259261
return dev;
260262
}
261263

264+
262265
EXPORT_SYMBOL(of_match_device);
263266
EXPORT_SYMBOL(of_platform_bus_type);
264267
EXPORT_SYMBOL(of_register_driver);

arch/ppc64/kernel/pmac_setup.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,23 @@ static int pmac_check_legacy_ioport(unsigned int baseport)
434434

435435
static int __init pmac_declare_of_platform_devices(void)
436436
{
437-
struct device_node *np;
437+
struct device_node *np, *npp;
438438

439-
np = find_devices("u3");
440-
if (np) {
441-
for (np = np->child; np != NULL; np = np->sibling)
439+
npp = of_find_node_by_name(NULL, "u3");
440+
if (npp) {
441+
for (np = NULL; (np = of_get_next_child(npp, np)) != NULL;) {
442442
if (strncmp(np->name, "i2c", 3) == 0) {
443-
of_platform_device_create(np, "u3-i2c");
443+
of_platform_device_create(np, "u3-i2c", NULL);
444+
of_node_put(np);
444445
break;
445446
}
447+
}
448+
of_node_put(npp);
449+
}
450+
npp = of_find_node_by_type(NULL, "smu");
451+
if (npp) {
452+
of_platform_device_create(npp, "smu", NULL);
453+
of_node_put(npp);
446454
}
447455

448456
return 0;

arch/ppc64/kernel/pmac_time.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void __pmac pmac_get_rtc_time(struct rtc_time *tm)
8484

8585
#ifdef CONFIG_PMAC_SMU
8686
case SYS_CTRLER_SMU:
87-
smu_get_rtc_time(tm);
87+
smu_get_rtc_time(tm, 1);
8888
break;
8989
#endif /* CONFIG_PMAC_SMU */
9090
default:
@@ -128,7 +128,7 @@ int __pmac pmac_set_rtc_time(struct rtc_time *tm)
128128

129129
#ifdef CONFIG_PMAC_SMU
130130
case SYS_CTRLER_SMU:
131-
return smu_set_rtc_time(tm);
131+
return smu_set_rtc_time(tm, 1);
132132
#endif /* CONFIG_PMAC_SMU */
133133
default:
134134
return -ENODEV;

drivers/i2c/busses/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,18 @@ config I2C_KEYWEST
245245
This support is also available as a module. If so, the module
246246
will be called i2c-keywest.
247247

248+
config I2C_PMAC_SMU
249+
tristate "Powermac SMU I2C interface"
250+
depends on I2C && PMAC_SMU
251+
help
252+
This supports the use of the I2C interface in the SMU
253+
chip on recent Apple machines like the iMac G5. It is used
254+
among others by the thermal control driver for those machines.
255+
Say Y if you have such a machine.
256+
257+
This support is also available as a module. If so, the module
258+
will be called i2c-pmac-smu.
259+
248260
config I2C_MPC
249261
tristate "MPC107/824x/85xx/52xx"
250262
depends on I2C && PPC32

drivers/i2c/busses/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ obj-$(CONFIG_I2C_ITE) += i2c-ite.o
2020
obj-$(CONFIG_I2C_IXP2000) += i2c-ixp2000.o
2121
obj-$(CONFIG_I2C_IXP4XX) += i2c-ixp4xx.o
2222
obj-$(CONFIG_I2C_KEYWEST) += i2c-keywest.o
23+
obj-$(CONFIG_I2C_PMAC_SMU) += i2c-pmac-smu.o
2324
obj-$(CONFIG_I2C_MPC) += i2c-mpc.o
2425
obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o
2526
obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o

0 commit comments

Comments
 (0)