From 22fb7d9be593181e2f779cf7a8421703a6be713b Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Thu, 15 May 2008 17:04:57 -0500 Subject: [POWERPC] fsl: Add warning for unrecognized I2C nodes in the device tree Update of_find_i2c_driver in fsl_soc.c to display a warning message if an I2C node in the device tree isn't found in the i2c_devices[] array. Signed-off-by: Timur Tabi Signed-off-by: Kumar Gala --- arch/powerpc/sysdev/fsl_soc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'arch/powerpc/sysdev/fsl_soc.c') diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index 3a7054e2bb7..a38c364ea26 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -448,6 +448,10 @@ static int __init of_find_i2c_driver(struct device_node *node, return -ENOMEM; return 0; } + + pr_warning("fsl_soc.c: unrecognized i2c node %s\n", + (const char *) of_get_property(node, "compatible", NULL)); + return -ENODEV; } -- cgit v1.2.3 From 64f9b5ee17ee7974d7cc58d75221432d86960ba3 Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Thu, 15 May 2008 17:46:10 -0500 Subject: [POWERPC] fsl: Add CS4270 i2c data to fsl_soc.c The i2c_devices[] array in fsl_soc.c lists all the I2C nodes that are supported on Freescale boards. Add an entry for the Cirrus Logic CS4270 so that a new-style CS4270 driver will work. Signed-off-by: Timur Tabi Signed-off-by: Kumar Gala --- arch/powerpc/sysdev/fsl_soc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/powerpc/sysdev/fsl_soc.c') diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index a38c364ea26..167523e9e41 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -433,6 +433,7 @@ static struct i2c_driver_device i2c_devices[] __initdata = { {"dallas,ds1340", "ds1340"}, {"stm,m41t00", "m41t00"}, {"dallas,ds1374", "rtc-ds1374"}, + {"cirrus,cs4270", "cs4270"}, }; static int __init of_find_i2c_driver(struct device_node *node, -- cgit v1.2.3 From e026892c85571e12f11abffde5a90bcc704d663e Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Mon, 2 Jun 2008 15:09:35 -0500 Subject: [POWERPC] fsl: Update fsl_soc to use cell-index property of I2C nodes Currently, fsl_i2c_of_init() uses the order of the I2C adapter nodes in the device tree to enumerate the I2C adapters. Instead, let's check for the cell-index property and use it if it exists. This is handy for device drivers that need to identify the I2C adapters by specific numbers. The Freescale MPC8610 ASoC V2 sound drivers are an example. Signed-off-by: Timur Tabi Signed-off-by: Kumar Gala --- arch/powerpc/sysdev/fsl_soc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'arch/powerpc/sysdev/fsl_soc.c') diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index 167523e9e41..14616d5d12d 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -496,6 +496,8 @@ static int __init fsl_i2c_of_init(void) struct resource r[2]; struct fsl_i2c_platform_data i2c_data; const unsigned char *flags = NULL; + int idx; + const u32 *iprop; memset(&r, 0, sizeof(r)); memset(&i2c_data, 0, sizeof(i2c_data)); @@ -506,7 +508,10 @@ static int __init fsl_i2c_of_init(void) of_irq_to_resource(np, 0, &r[1]); - i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2); + iprop = of_get_property(np, "cell-index", NULL); + idx = iprop ? *iprop : i; + + i2c_dev = platform_device_register_simple("fsl-i2c", idx, r, 2); if (IS_ERR(i2c_dev)) { ret = PTR_ERR(i2c_dev); goto err; @@ -528,7 +533,8 @@ static int __init fsl_i2c_of_init(void) if (ret) goto unreg; - of_register_i2c_devices(np, i++); + of_register_i2c_devices(np, idx); + i++; } return 0; -- cgit v1.2.3 From 0d1cde235874b00905bce23f659690d060ebf475 Mon Sep 17 00:00:00 2001 From: Jon Smirl Date: Mon, 30 Jun 2008 19:01:26 -0400 Subject: powerpc/i2c: Convert i2c-mpc into an of_platform driver Convert i2c-mpc to an of_platform driver. Utilize the code in drivers/of-i2c.c to make i2c modules dynamically loadable by the device tree. Signed-off-by: Jon Smirl Signed-off-by: Grant Likely --- arch/powerpc/sysdev/fsl_soc.c | 133 ------------------------------------------ 1 file changed, 133 deletions(-) (limited to 'arch/powerpc/sysdev/fsl_soc.c') diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index ca54563d5c7..ebcec7362f9 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -414,139 +414,6 @@ err: arch_initcall(gfar_of_init); -#ifdef CONFIG_I2C_BOARDINFO -#include -struct i2c_driver_device { - char *of_device; - char *i2c_type; -}; - -static struct i2c_driver_device i2c_devices[] __initdata = { - {"ricoh,rs5c372a", "rs5c372a"}, - {"ricoh,rs5c372b", "rs5c372b"}, - {"ricoh,rv5c386", "rv5c386"}, - {"ricoh,rv5c387a", "rv5c387a"}, - {"dallas,ds1307", "ds1307"}, - {"dallas,ds1337", "ds1337"}, - {"dallas,ds1338", "ds1338"}, - {"dallas,ds1339", "ds1339"}, - {"dallas,ds1340", "ds1340"}, - {"stm,m41t00", "m41t00"}, - {"dallas,ds1374", "ds1374"}, - {"cirrus,cs4270", "cs4270"}, -}; - -static int __init of_find_i2c_driver(struct device_node *node, - struct i2c_board_info *info) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) { - if (!of_device_is_compatible(node, i2c_devices[i].of_device)) - continue; - if (strlcpy(info->type, i2c_devices[i].i2c_type, - I2C_NAME_SIZE) >= I2C_NAME_SIZE) - return -ENOMEM; - return 0; - } - - pr_warning("fsl_soc.c: unrecognized i2c node %s\n", - (const char *) of_get_property(node, "compatible", NULL)); - - return -ENODEV; -} - -static void __init of_register_i2c_devices(struct device_node *adap_node, - int bus_num) -{ - struct device_node *node = NULL; - - while ((node = of_get_next_child(adap_node, node))) { - struct i2c_board_info info = {}; - const u32 *addr; - int len; - - addr = of_get_property(node, "reg", &len); - if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) { - printk(KERN_WARNING "fsl_soc.c: invalid i2c device entry\n"); - continue; - } - - info.irq = irq_of_parse_and_map(node, 0); - if (info.irq == NO_IRQ) - info.irq = -1; - - if (of_find_i2c_driver(node, &info) < 0) - continue; - - info.addr = *addr; - - i2c_register_board_info(bus_num, &info, 1); - } -} - -static int __init fsl_i2c_of_init(void) -{ - struct device_node *np; - unsigned int i = 0; - struct platform_device *i2c_dev; - int ret; - - for_each_compatible_node(np, NULL, "fsl-i2c") { - struct resource r[2]; - struct fsl_i2c_platform_data i2c_data; - const unsigned char *flags = NULL; - int idx; - const u32 *iprop; - - memset(&r, 0, sizeof(r)); - memset(&i2c_data, 0, sizeof(i2c_data)); - - ret = of_address_to_resource(np, 0, &r[0]); - if (ret) - goto err; - - of_irq_to_resource(np, 0, &r[1]); - - iprop = of_get_property(np, "cell-index", NULL); - idx = iprop ? *iprop : i; - - i2c_dev = platform_device_register_simple("fsl-i2c", idx, r, 2); - if (IS_ERR(i2c_dev)) { - ret = PTR_ERR(i2c_dev); - goto err; - } - - i2c_data.device_flags = 0; - flags = of_get_property(np, "dfsrr", NULL); - if (flags) - i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR; - - flags = of_get_property(np, "fsl5200-clocking", NULL); - if (flags) - i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200; - - ret = - platform_device_add_data(i2c_dev, &i2c_data, - sizeof(struct - fsl_i2c_platform_data)); - if (ret) - goto unreg; - - of_register_i2c_devices(np, idx); - i++; - } - - return 0; - -unreg: - platform_device_unregister(i2c_dev); -err: - return ret; -} - -arch_initcall(fsl_i2c_of_init); -#endif #ifdef CONFIG_PPC_83xx static int __init mpc83xx_wdt_init(void) -- cgit v1.2.3 From 69ad7e73dee33f8e0680825006c801ca6b4bf470 Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Tue, 8 Jul 2008 21:36:40 +0400 Subject: powerpc/fsl_soc: gianfar: don't probe disabled devices Freescale ships MPC8315E-RDB boards in two variants: 1. With TSEC1 ethernet support and USB UTMI PHY; 2. Without TSEC1 support, but with USB ULPI PHY in addition. For the second case U-Boot will add status = "disabled"; property into the TSEC1 node, so Linux should not try to probe it. Signed-off-by: Anton Vorontsov Signed-off-by: Kumar Gala --- arch/powerpc/sysdev/fsl_soc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch/powerpc/sysdev/fsl_soc.c') diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index ebcec7362f9..ca180a93bca 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -296,6 +296,9 @@ static int __init gfar_of_init(void) const phandle *ph; int n_res = 2; + if (!of_device_is_available(np)) + continue; + memset(r, 0, sizeof(r)); memset(&gfar_data, 0, sizeof(gfar_data)); -- cgit v1.2.3 From 4cd7e1cbd43bb67927af2b8b4e0ffd43fd5ed6b4 Mon Sep 17 00:00:00 2001 From: Andy Fleming Date: Fri, 2 May 2008 13:03:50 -0500 Subject: powerpc: Add support for multiple gfar mdio interfaces The old code assumed there was only one, but the 8572 actually has 3. Also, our usual id, 0xe0024520, gets resolved to -1 somewhere, and this was preventing the multiple buses from having different ids. So we only keep the low 20 bits, which have the interesting info, anyway. Signed-off-by: Andy Fleming Signed-off-by: Kumar Gala --- arch/powerpc/sysdev/fsl_soc.c | 84 ++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 46 deletions(-) (limited to 'arch/powerpc/sysdev/fsl_soc.c') diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index ca180a93bca..ef4cb0d67a7 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -207,66 +207,58 @@ static int __init of_add_fixed_phys(void) arch_initcall(of_add_fixed_phys); #endif /* CONFIG_FIXED_PHY */ -static int __init gfar_mdio_of_init(void) +static int gfar_mdio_of_init_one(struct device_node *np) { - struct device_node *np = NULL; + int k; + struct device_node *child = NULL; + struct gianfar_mdio_data mdio_data; struct platform_device *mdio_dev; struct resource res; int ret; - np = of_find_compatible_node(np, NULL, "fsl,gianfar-mdio"); - - /* try the deprecated version */ - if (!np) - np = of_find_compatible_node(np, "mdio", "gianfar"); + memset(&res, 0, sizeof(res)); + memset(&mdio_data, 0, sizeof(mdio_data)); - if (np) { - int k; - struct device_node *child = NULL; - struct gianfar_mdio_data mdio_data; + ret = of_address_to_resource(np, 0, &res); + if (ret) + return ret; - memset(&res, 0, sizeof(res)); - memset(&mdio_data, 0, sizeof(mdio_data)); + mdio_dev = platform_device_register_simple("fsl-gianfar_mdio", + res.start&0xfffff, &res, 1); + if (IS_ERR(mdio_dev)) + return PTR_ERR(mdio_dev); - ret = of_address_to_resource(np, 0, &res); - if (ret) - goto err; + for (k = 0; k < 32; k++) + mdio_data.irq[k] = PHY_POLL; - mdio_dev = - platform_device_register_simple("fsl-gianfar_mdio", - res.start, &res, 1); - if (IS_ERR(mdio_dev)) { - ret = PTR_ERR(mdio_dev); - goto err; + while ((child = of_get_next_child(np, child)) != NULL) { + int irq = irq_of_parse_and_map(child, 0); + if (irq != NO_IRQ) { + const u32 *id = of_get_property(child, "reg", NULL); + mdio_data.irq[*id] = irq; } + } - for (k = 0; k < 32; k++) - mdio_data.irq[k] = PHY_POLL; + ret = platform_device_add_data(mdio_dev, &mdio_data, + sizeof(struct gianfar_mdio_data)); + if (ret) + platform_device_unregister(mdio_dev); - while ((child = of_get_next_child(np, child)) != NULL) { - int irq = irq_of_parse_and_map(child, 0); - if (irq != NO_IRQ) { - const u32 *id = of_get_property(child, - "reg", NULL); - mdio_data.irq[*id] = irq; - } - } + return ret; +} - ret = - platform_device_add_data(mdio_dev, &mdio_data, - sizeof(struct gianfar_mdio_data)); - if (ret) - goto unreg; - } +static int __init gfar_mdio_of_init(void) +{ + struct device_node *np = NULL; - of_node_put(np); - return 0; + for_each_compatible_node(np, NULL, "fsl,gianfar-mdio") + gfar_mdio_of_init_one(np); -unreg: - platform_device_unregister(mdio_dev); -err: - of_node_put(np); - return ret; + /* try the deprecated version */ + for_each_compatible_node(np, "mdio", "gianfar"); + gfar_mdio_of_init_one(np); + + return 0; } arch_initcall(gfar_mdio_of_init); @@ -393,7 +385,7 @@ static int __init gfar_of_init(void) gfar_data.phy_id = *id; snprintf(gfar_data.bus_id, MII_BUS_ID_SIZE, "%llx", - (unsigned long long)res.start); + (unsigned long long)res.start&0xfffff); of_node_put(phy); of_node_put(mdio); -- cgit v1.2.3 From d87eb12785c14de1586e3bad86ca2c0991300339 Mon Sep 17 00:00:00 2001 From: Scott Wood Date: Fri, 11 Jul 2008 18:04:45 -0500 Subject: gianfar: Add magic packet and suspend/resume support. Signed-off-by: Scott Wood Signed-off-by: Kumar Gala --- arch/powerpc/sysdev/fsl_soc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'arch/powerpc/sysdev/fsl_soc.c') diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index ef4cb0d67a7..214388e1180 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -352,6 +352,9 @@ static int __init gfar_of_init(void) else gfar_data.interface = PHY_INTERFACE_MODE_MII; + if (of_get_property(np, "fsl,magic-packet", NULL)) + gfar_data.device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET; + ph = of_get_property(np, "phy-handle", NULL); if (ph == NULL) { u32 *fixed_link; -- cgit v1.2.3