aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev/fsl_soc.c
diff options
context:
space:
mode:
authorJon Smirl <jonsmirl@gmail.com>2008-06-30 19:01:26 -0400
committerGrant Likely <grant.likely@secretlab.ca>2008-07-12 14:10:23 -0400
commit0d1cde235874b00905bce23f659690d060ebf475 (patch)
tree918cad848eb4d85a3ac909666b5639ff618b2bdc /arch/powerpc/sysdev/fsl_soc.c
parent6eb9d32298290b956693fd85c815b817d39a9505 (diff)
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 <jonsmirl@gmail.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/powerpc/sysdev/fsl_soc.c')
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c133
1 files changed, 0 insertions, 133 deletions
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index ca54563d5c7e..ebcec7362f95 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -414,139 +414,6 @@ err:
414 414
415arch_initcall(gfar_of_init); 415arch_initcall(gfar_of_init);
416 416
417#ifdef CONFIG_I2C_BOARDINFO
418#include <linux/i2c.h>
419struct i2c_driver_device {
420 char *of_device;
421 char *i2c_type;
422};
423
424static struct i2c_driver_device i2c_devices[] __initdata = {
425 {"ricoh,rs5c372a", "rs5c372a"},
426 {"ricoh,rs5c372b", "rs5c372b"},
427 {"ricoh,rv5c386", "rv5c386"},
428 {"ricoh,rv5c387a", "rv5c387a"},
429 {"dallas,ds1307", "ds1307"},
430 {"dallas,ds1337", "ds1337"},
431 {"dallas,ds1338", "ds1338"},
432 {"dallas,ds1339", "ds1339"},
433 {"dallas,ds1340", "ds1340"},
434 {"stm,m41t00", "m41t00"},
435 {"dallas,ds1374", "ds1374"},
436 {"cirrus,cs4270", "cs4270"},
437};
438
439static int __init of_find_i2c_driver(struct device_node *node,
440 struct i2c_board_info *info)
441{
442 int i;
443
444 for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
445 if (!of_device_is_compatible(node, i2c_devices[i].of_device))
446 continue;
447 if (strlcpy(info->type, i2c_devices[i].i2c_type,
448 I2C_NAME_SIZE) >= I2C_NAME_SIZE)
449 return -ENOMEM;
450 return 0;
451 }
452
453 pr_warning("fsl_soc.c: unrecognized i2c node %s\n",
454 (const char *) of_get_property(node, "compatible", NULL));
455
456 return -ENODEV;
457}
458
459static void __init of_register_i2c_devices(struct device_node *adap_node,
460 int bus_num)
461{
462 struct device_node *node = NULL;
463
464 while ((node = of_get_next_child(adap_node, node))) {
465 struct i2c_board_info info = {};
466 const u32 *addr;
467 int len;
468
469 addr = of_get_property(node, "reg", &len);
470 if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
471 printk(KERN_WARNING "fsl_soc.c: invalid i2c device entry\n");
472 continue;
473 }
474
475 info.irq = irq_of_parse_and_map(node, 0);
476 if (info.irq == NO_IRQ)
477 info.irq = -1;
478
479 if (of_find_i2c_driver(node, &info) < 0)
480 continue;
481
482 info.addr = *addr;
483
484 i2c_register_board_info(bus_num, &info, 1);
485 }
486}
487
488static int __init fsl_i2c_of_init(void)
489{
490 struct device_node *np;
491 unsigned int i = 0;
492 struct platform_device *i2c_dev;
493 int ret;
494
495 for_each_compatible_node(np, NULL, "fsl-i2c") {
496 struct resource r[2];
497 struct fsl_i2c_platform_data i2c_data;
498 const unsigned char *flags = NULL;
499 int idx;
500 const u32 *iprop;
501
502 memset(&r, 0, sizeof(r));
503 memset(&i2c_data, 0, sizeof(i2c_data));
504
505 ret = of_address_to_resource(np, 0, &r[0]);
506 if (ret)
507 goto err;
508
509 of_irq_to_resource(np, 0, &r[1]);
510
511 iprop = of_get_property(np, "cell-index", NULL);
512 idx = iprop ? *iprop : i;
513
514 i2c_dev = platform_device_register_simple("fsl-i2c", idx, r, 2);
515 if (IS_ERR(i2c_dev)) {
516 ret = PTR_ERR(i2c_dev);
517 goto err;
518 }
519
520 i2c_data.device_flags = 0;
521 flags = of_get_property(np, "dfsrr", NULL);
522 if (flags)
523 i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
524
525 flags = of_get_property(np, "fsl5200-clocking", NULL);
526 if (flags)
527 i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
528
529 ret =
530 platform_device_add_data(i2c_dev, &i2c_data,
531 sizeof(struct
532 fsl_i2c_platform_data));
533 if (ret)
534 goto unreg;
535
536 of_register_i2c_devices(np, idx);
537 i++;
538 }
539
540 return 0;
541
542unreg:
543 platform_device_unregister(i2c_dev);
544err:
545 return ret;
546}
547
548arch_initcall(fsl_i2c_of_init);
549#endif
550 417
551#ifdef CONFIG_PPC_83xx 418#ifdef CONFIG_PPC_83xx
552static int __init mpc83xx_wdt_init(void) 419static int __init mpc83xx_wdt_init(void)