2 * Copyright (C) 2007 PA Semi, Inc
4 * Parts based on arch/powerpc/sysdev/fsl_soc.c:
6 * 2006 (c) MontaVista Software, Inc.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <linux/errno.h>
15 #include <linux/kernel.h>
16 #include <linux/pci.h>
18 #include <linux/i2c.h>
20 #ifdef CONFIG_I2C_BOARDINFO
21 /* The below is from fsl_soc.c. It's copied because since there are no
22 * official bus bindings at this time it doesn't make sense to share across
23 * the platforms, even though they happen to be common.
25 struct i2c_driver_device {
31 static struct i2c_driver_device i2c_devices[] __initdata = {
32 {"dallas,ds1338", "rtc-ds1307", "ds1338"},
35 static int __init find_i2c_driver(struct device_node *node,
36 struct i2c_board_info *info)
40 for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
41 if (!of_device_is_compatible(node, i2c_devices[i].of_device))
43 if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver,
44 KOBJ_NAME_LEN) >= KOBJ_NAME_LEN ||
45 strlcpy(info->type, i2c_devices[i].i2c_type,
46 I2C_NAME_SIZE) >= I2C_NAME_SIZE)
53 static int __init pasemi_register_i2c_devices(void)
56 struct device_node *adap_node;
57 struct device_node *node;
60 while ((pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa003, pdev))) {
61 adap_node = pci_device_to_OF_node(pdev);
67 while ((node = of_get_next_child(adap_node, node))) {
68 struct i2c_board_info info = {};
72 addr = of_get_property(node, "reg", &len);
73 if (!addr || len < sizeof(int) ||
74 *addr > (1 << 10) - 1) {
76 "pasemi_register_i2c_devices: "
77 "invalid i2c device entry\n");
81 info.irq = irq_of_parse_and_map(node, 0);
82 if (info.irq == NO_IRQ)
85 if (find_i2c_driver(node, &info) < 0)
90 i2c_register_board_info(PCI_FUNC(pdev->devfn), &info,
96 device_initcall(pasemi_register_i2c_devices);