Skip to contentSkip to conversation

2/5 powerpc: Rework PowerMac i2c part 2

PATCH New Benjamin Herrenschmidt 1 participant 1 message Jan 7, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2/5 powerpc: Rework PowerMac i2c part 2

This is the continuation of the previous patch. This one removes the old PowerMac i2c drivers (i2c-keywest and i2c-pmac-smu) and replaces them both with a single stub driver that uses the new PowerMac low i2c layer.

Now that i2c-keywest is gone, the low-i2c code is extended to support interrupt driver transfers. All i2c busses now appear as platform devices. Compatibility with existing drivers should be maintained as the i2c bus names have been kept identical, except for the SMU bus but in that later case, all users has been fixed.

With that patch added, matching a device node to an i2c_adapter becomes trivial.

drivers/i2c/busses/Kconfig +7 -17
Index: linux-work/drivers/i2c/busses/Kconfig
===================================================================
@@ -236,27 +236,17 @@ config I2C_IXP2000
 	  This support is also available as a module. If so, the module
 	  will be called i2c-ixp2000.
 
-config I2C_KEYWEST
-	tristate "Powermac Keywest I2C interface"
+config I2C_POWERMAC
+	tristate "Powermac I2C interface"
 	depends on I2C && PPC_PMAC
+	default y
 	help
-	  This supports the use of the I2C interface in the combo-I/O
-	  chip on recent Apple machines.  Say Y if you have such a machine.
-
-	  This support is also available as a module.  If so, the module 
-	  will be called i2c-keywest.
-
-config I2C_PMAC_SMU
-	tristate "Powermac SMU I2C interface"
-	depends on I2C && PMAC_SMU
-	help
-	  This supports the use of the I2C interface in the SMU
-	  chip on recent Apple machines like the iMac G5.  It is used
-	  among others by the thermal control driver for those machines.
-	  Say Y if you have such a machine.
+	  This exposes the various PowerMac i2c interfaces to the linux i2c
+	  layer and to userland. It is used by various drivers on the powemac
+	  platform, thus should generally be enabled.
 
 	  This support is also available as a module.  If so, the module
-	  will be called i2c-pmac-smu.
+	  will be called i2c-powermac.
 
 config I2C_MPC
 	tristate "MPC107/824x/85xx/52xx"
drivers/i2c/busses/Makefile +1 -2
Index: linux-work/drivers/i2c/busses/Makefile
===================================================================
@@ -19,8 +19,7 @@ obj-$(CONFIG_I2C_ISA)		+= i2c-isa.o
 obj-$(CONFIG_I2C_ITE)		+= i2c-ite.o
 obj-$(CONFIG_I2C_IXP2000)	+= i2c-ixp2000.o
 obj-$(CONFIG_I2C_IXP4XX)	+= i2c-ixp4xx.o
-obj-$(CONFIG_I2C_KEYWEST)	+= i2c-keywest.o
-obj-$(CONFIG_I2C_PMAC_SMU)	+= i2c-pmac-smu.o
+obj-$(CONFIG_I2C_POWERMAC)	+= i2c-powermac.o
 obj-$(CONFIG_I2C_MPC)		+= i2c-mpc.o
 obj-$(CONFIG_I2C_MV64XXX)	+= i2c-mv64xxx.o
 obj-$(CONFIG_I2C_NFORCE2)	+= i2c-nforce2.o
drivers/i2c/busses/i2c-keywest.c deleted +0 -754

754 lines not on this page · raw message

drivers/i2c/busses/i2c-keywest.h deleted +0 -108

108 lines not on this page · raw message

drivers/i2c/busses/i2c-pmac-smu.c deleted +0 -324

324 lines not on this page · raw message

drivers/i2c/busses/i2c-powermac.c new file +290 -0

290 lines not on this page · raw message

arch/powerpc/platforms/powermac/low_i2c.c +246 -72

537 lines not on this page · raw message

include/asm-powerpc/pmac_low_i2c.h +2 -0
Index: linux-work/include/asm-powerpc/pmac_low_i2c.h
===================================================================
@@ -70,6 +70,7 @@ extern struct device_node *pmac_i2c_get_
 extern struct device_node *pmac_i2c_get_bus_node(struct pmac_i2c_bus *bus);
 extern int pmac_i2c_get_type(struct pmac_i2c_bus *bus);
 extern int pmac_i2c_get_flags(struct pmac_i2c_bus *bus);
+extern int pmac_i2c_get_channel(struct pmac_i2c_bus *bus);
 
 /* i2c layer adapter attach/detach */
 extern void pmac_i2c_attach_adapter(struct pmac_i2c_bus *bus,
@@ -77,6 +78,7 @@ extern void pmac_i2c_attach_adapter(stru
 extern void pmac_i2c_detach_adapter(struct pmac_i2c_bus *bus,
 				    struct i2c_adapter *adapter);
 extern struct i2c_adapter *pmac_i2c_get_adapter(struct pmac_i2c_bus *bus);
+extern struct pmac_i2c_bus *pmac_i2c_adapter_to_bus(struct i2c_adapter *adapter);
 
 /* March a device or bus with an i2c adapter structure, to be used by drivers
  * to match device-tree nodes with i2c adapters during adapter discovery
drivers/macintosh/smu.c +2 -22
Index: linux-work/drivers/macintosh/smu.c
===================================================================
@@ -584,34 +584,14 @@ core_initcall(smu_late_init);
  * sysfs visibility
  */
 
-static void smu_create_i2c(struct device_node *np)
-{
-	char name[32];
-	u32 *reg = (u32 *)get_property(np, "reg", NULL);
-
-	if (reg != NULL) {
-		sprintf(name, "smu-i2c-%02x", *reg);
-		of_platform_device_create(np, name, &smu->of_dev->dev);
-	}
-}
-
 static void smu_expose_childs(void *unused)
 {
-	struct device_node *np, *gp;
+	struct device_node *np;
 
-	for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;) {
-		if (device_is_compatible(np, "smu-i2c-control")) {
-			gp = NULL;
-			while ((gp = of_get_next_child(np, gp)) != NULL)
-				if (device_is_compatible(gp, "i2c-bus"))
-					smu_create_i2c(gp);
-		} else if (device_is_compatible(np, "smu-i2c"))
-			smu_create_i2c(np);
+	for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;)
 		if (device_is_compatible(np, "smu-sensors"))
 			of_platform_device_create(np, "smu-sensors",
 						  &smu->of_dev->dev);
-	}
-
 }
 
 static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL);
drivers/macintosh/windfarm_lm75_sensor.c +8 -42

76 lines not on this page · raw message

drivers/macintosh/Kconfig +5 -5
Index: linux-work/drivers/macintosh/Kconfig
===================================================================
@@ -149,14 +149,14 @@ config MAC_EMUMOUSEBTN
 
 config THERM_WINDTUNNEL
 	tristate "Support for thermal management on Windtunnel G4s"
-	depends on I2C && I2C_KEYWEST && PPC_PMAC && !PPC_PMAC64
+	depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64
 	help
 	  This driver provides some thermostat and fan control for the desktop
 	  G4 "Windtunnel"
 
 config THERM_ADT746X
 	tristate "Support for thermal mgmnt on laptops with ADT 746x chipset"
-	depends on I2C && I2C_KEYWEST && PPC_PMAC && !PPC_PMAC64
+	depends on I2C && I2C_POWERMAC && PPC_PMAC && !PPC_PMAC64
 	help
 	  This driver provides some thermostat and fan control for the
           iBook G4, and the ATI based aluminium PowerBooks, allowing slighlty
@@ -164,7 +164,7 @@ config THERM_ADT746X
 
 config THERM_PM72
 	tristate "Support for thermal management on PowerMac G5"
-	depends on I2C && I2C_KEYWEST && PPC_PMAC64
+	depends on I2C && I2C_POWERMAC && PPC_PMAC64
 	help
 	  This driver provides thermostat and fan control for the desktop
 	  G5 machines. 
@@ -175,14 +175,14 @@ config WINDFARM
 config WINDFARM_PM81
 	tristate "Support for thermal management on iMac G5"
 	depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU
-	select I2C_PMAC_SMU
+	select I2C_POWERMAC
 	help
 	  This driver provides thermal control for the iMacG5
 
 config WINDFARM_PM91
 	tristate "Support for thermal management on PowerMac9,1"
 	depends on WINDFARM && I2C && CPU_FREQ_PMAC64 && PMAC_SMU
-	select I2C_PMAC_SMU
+	select I2C_POWERMAC
 	help
 	  This driver provides thermal control for the PowerMac9,1
           which is the recent (SMU based) single CPU desktop G5
arch/powerpc/platforms/powermac/setup.c +1 -17
Index: linux-work/arch/powerpc/platforms/powermac/setup.c
===================================================================
@@ -656,7 +656,7 @@ static int pmac_check_legacy_ioport(unsi
 
 static int __init pmac_declare_of_platform_devices(void)
 {
-	struct device_node *np, *npp;
+	struct device_node *np;
 
 	np = of_find_node_by_name(NULL, "valkyrie");
 	if (np)
@@ -664,22 +664,6 @@ static int __init pmac_declare_of_platfo
 	np = of_find_node_by_name(NULL, "platinum");
 	if (np)
 		of_platform_device_create(np, "platinum", NULL);
-	npp = of_find_node_by_name(NULL, "uni-n");
-	if (npp == NULL)
-		npp = of_find_node_by_name(NULL, "u3");
-	if (npp == NULL)
-		npp = of_find_node_by_name(NULL, "u4");
-	if (npp) {
-		for (np = NULL; (np = of_get_next_child(npp, np)) != NULL;) {
-			if (strncmp(np->name, "i2c", 3) == 0) {
-				of_platform_device_create(np, "uni-n-i2c",
-							  NULL);
-				of_node_put(np);
-				break;
-			}
-		}
-		of_node_put(npp);
-	}
         np = of_find_node_by_type(NULL, "smu");
         if (np) {
 		of_platform_device_create(np, "smu", NULL);