Consolidate compatible-to-i2c_boardinfo mapping code
PATCH 1/2 Consolidate compatible-to-i2c_boardinfo mapping code
[POWERPC] Consolidate compatible-to-i2c_boardinfo mapping code
Move the mapping from device tree compatible field to i2c_boardinfo structures for powerpc, since several platforms now use this.
---
arch/powerpc/sysdev/Makefile | 1 arch/powerpc/sysdev/fsl_soc.c | 38 --------------------- arch/powerpc/sysdev/i2c_of_mapping.c | 61 +++++++++++++++++++++++++++++++++++ include/asm-powerpc/i2c_of.h | 14 ++++++++ 4 files changed, 77 insertions(+), 37 deletions(-)
arch/powerpc/sysdev/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_MV64X60) += $(mv64x60-y) m mv64x60_udbg.o obj-$(CONFIG_RTC_DRV_CMOS) += rtc_cmos_setup.o obj-$(CONFIG_AXON_RAM) += axonram.o +obj-$(CONFIG_I2C_BOARDINFO) += i2c_of_mapping.o ifeq ($(CONFIG_PPC_MERGE),y) obj-$(CONFIG_PPC_INDIRECT_PCI) += indirect_pci.o
arch/powerpc/sysdev/i2c_of_mapping.c new file +61 -0
61 lines not on this page · raw message
include/asm-powerpc/i2c_of.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* Functions to map device tree compatible fields to values used by i2c +* board info structures +*/ + +#ifndef POWERPC_I2C_OF_H +#define POWERPC_I2C_OF_H + +#ifdef CONFIG_I2C_BOARDINFO +extern int __init of_fill_i2c_info (struct device_node *node, +struct i2c_board_info *info); +#endif + +#endif
arch/powerpc/sysdev/fsl_soc.c +1 -37
@@ -320,43 +320,7 @@ arch_initcall(gfar_of_init);#ifdef CONFIG_I2C_BOARDINFO #include <linux/i2c.h> -struct i2c_driver_device { -char *of_device; -char *i2c_driver; -char *i2c_type; -}; - -static struct i2c_driver_device i2c_devices[]__initdata = { - {"ricoh,rs5c372a" ,"rtc-rs5c372" ,"rs5c372a" ,}, - {"ricoh,rs5c372b" ,"rtc-rs5c372" ,"rs5c372b" ,}, - {"ricoh,rv5c386" ,"rtc-rs5c372" ,"rv5c386" ,}, - {"ricoh,rv5c387a" ,"rtc-rs5c372" ,"rv5c387a" ,}, - {"dallas,ds1307" ,"rtc-ds1307" ,"ds1307" ,}, - {"dallas,ds1337" ,"rtc-ds1307" ,"ds1337" ,}, - {"dallas,ds1338" ,"rtc-ds1307" ,"ds1338" ,}, - {"dallas,ds1339" ,"rtc-ds1307" ,"ds1339" ,}, - {"dallas,ds1340" ,"rtc-ds1307" ,"ds1340" ,}, - {"stm,m41t00" ,"rtc-ds1307" ,"m41t00" }, - {"dallas,ds1374" ,"rtc-ds1374" ,"rtc-ds1374" ,}, -}; - -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->driver_name, i2c_devices[i].i2c_driver, -KOBJ_NAME_LEN ) >=KOBJ_NAME_LEN || -strlcpy (info->type, i2c_devices[i].i2c_type, -I2C_NAME_SIZE ) >=I2C_NAME_SIZE ) -return -ENOMEM ; -return 0 ; - } -return -ENODEV ; -} +#include <asm/i2c_of.h> static void __init of_register_i2c_devices (struct device_node *adap_node,int bus_num)
PATCH 2/2 pasemi: Register i2c_board_info
[POWERPC] pasemi: Register i2c_board_info
Setup i2c_board_info based on device tree contents. This has to be a device_initcall since we need PCI to be probed by the time we run it, but before the actual driver is initialized.
arch/powerpc/platforms/pasemi/Makefile +1 -1
@@ -1,4 +1,4 @@ -obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o +obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o misc.o obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o obj-$(CONFIG_ELECTRA_IDE) += electra_ide.o obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += cpufreq.o
arch/powerpc/platforms/pasemi/misc.c new file +66 -0
66 lines not on this page · raw message
Re: [PATCH 2/2] [POWERPC] pasemi: Register i2c_board_info
arch/powerpc/platforms/pasemi/misc.c line 62
Quoted 9 lines · Olof Johansson
arch/powerpc/platforms/pasemi/misc.c new file +5
-0+continue ; + + info.addr = *addr; + + i2c_register_board_info(PCI_FUNC(pdev->devfn),&info,
arch/powerpc/platforms/pasemi/misc.c new file +3
-0+ 1); + } + }
+ /* Ensure that buses up to 2 are reserved */
+ i2c_register_board_info(2, NULL, 0);
+
arch/powerpc/platforms/pasemi/misc.c line 66
Quoted 4 lines
arch/powerpc/platforms/pasemi/misc.c new file +4
-0+ return 0; +} +device_initcall (pasemi_register_i2c_devices); +#endif
Otherwise when you make i2c-pasemi use i2c_add_numbered_adapter(), it might fail to register the third bus -- because there were no devices preregistered on it, so something else might have stolen that bus number already.
You might want to add the patch to use i2c_add_numbered_adapter() to your tree, btw.
Signature · 1 line
dwmw2
Re: [PATCH 2/2] [POWERPC] pasemi: Register i2c_board_info
Quoted 17 lines · David Woodhouse
Quoted 9 lines · Olof Johansson
arch/powerpc/platforms/pasemi/misc.c new file +5
-0+continue ; + + info.addr = *addr; + + i2c_register_board_info(PCI_FUNC(pdev->devfn),&info,
arch/powerpc/platforms/pasemi/misc.c new file +3
-0+ 1); + } + }(quoted diff) +3
-0+ /* Ensure that buses up to 2 are reserved */ + i2c_register_board_info(2, NULL, 0); +
Quoted 10 lines
arch/powerpc/platforms/pasemi/misc.c line 66
Quoted 4 lines
arch/powerpc/platforms/pasemi/misc.c new file +4
-0+ return 0; +} +device_initcall (pasemi_register_i2c_devices); +#endif Otherwise when you make i2c-pasemi use
i2c_add_numbered_adapter(), it might fail to register the third bus -- because there were no devices preregistered on it, so something else might have stolen that bus number already.
Good point, I'd missed that. Thanks!
Quoted 2 lines
You might want to add the patch to use
i2c_add_numbered_adapter()to your tree, btw.
Yep, I realized that after (re)asking Paul to pull though, and didn't want to do a third request before he's done it. :)
If he doesn't pull in the next few days I might just keep adding new patches as they come in though, and add it back.
-Olof
Re: [PATCH 2/2] [POWERPC] pasemi: Register i2c_board_info
Quoted 5 lines · Olof Johansson
Yep, I realized that after (re)asking Paul to pull though, and didn't want to do a third request before he's done it. :)
If he doesn't pull in the next few days I might just keep adding new patches as they come in though, and add it back.
I haven't pulled yet; sounds like I need to wait a few more days first. :)
Paul.
Re: [PATCH 2/2] [POWERPC] pasemi: Register i2c_board_info
Quoted 10 lines · Paul Mackerras
Quoted 5 lines · Olof Johansson
Yep, I realized that after (re)asking Paul to pull though, and didn't want to do a third request before he's done it. :)
If he doesn't pull in the next few days I might just keep adding new patches as they come in though, and add it back.
I haven't pulled yet; sounds like I need to wait a few more days first. :)
Heh, nah, just pull now, I'll have more going in before 2.6.25 as but it's good to get current contents into -mm sooner rather than later. :)
Thanks,
-Olof