Skip to contentSkip to conversation

pasemi: process i2c device tree entries at boot

PATCH Superseded Olof Johansson 2 participants 5 messages Oct 15, 2007 – Oct 16, 2007 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pasemi: process i2c device tree entries at boot

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
Index: k.org/arch/powerpc/platforms/pasemi/Makefile
===================================================================
@@ -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 +94 -0

94 lines not on this page · raw message

#1 lore raw

PATCH v2 1/1 pasemi: process i2c device tree entries at boot

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.

---

Turns out some old firmwares don't create the device node for the second and third function, so we need to check for it.

arch/powerpc/platforms/pasemi/Makefile +1 -1
Index: k.org/arch/powerpc/platforms/pasemi/Makefile
===================================================================
@@ -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 +97 -0

97 lines not on this page · raw message

#2 lore raw
Quoted 3 lines · Olof Johansson

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.

Can we factor at least some of this stuff out into common code?

We certainly shouldn't need more than one translation table, and this loop:

arch/powerpc/platforms/pasemi/misc.c line 61

Quoted 9 lines
arch/powerpc/platforms/pasemi/misc.c new file +9 -0
+static int __init pasemi_register_i2c_devices(void)
+{
+	struct pci_dev *pdev;
+	struct device_node *adap_node;
+	struct device_node *node;
+
+	pdev = NULL;
+	while ((pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa003, pdev))) {
+		adap_node = pci_device_to_OF_node(pdev);

Should be in the pasemi code, and pass a bus number and device node to generic code that does this:

arch/powerpc/platforms/pasemi/misc.c line 67

Quoted 2 lines
arch/powerpc/platforms/pasemi/misc.c new file +2 -0
+		node = NULL;
+		while ((node = of_get_next_child(adap_node, node))) {

-Scott

#3 lore raw
Quoted 6 lines · Scott Wood
Quoted 3 lines · Olof Johansson

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.

Can we factor at least some of this stuff out into common code?

I didn't really feel strong motivations to do so, given that the amount of shared code is quite small, and the official bindings are not yet determined.

Chances are whenever the bindings are done they might be incompatible with what we already have in our firmware, so the code would need to be separated out again.

Quoted 14 lines

We certainly shouldn't need more than one translation table, and this loop:

arch/powerpc/platforms/pasemi/misc.c line 61

Quoted 9 lines
arch/powerpc/platforms/pasemi/misc.c new file +9 -0
+static int __init pasemi_register_i2c_devices(void)
+{
+	struct pci_dev *pdev;
+	struct device_node *adap_node;
+	struct device_node *node;
+
+	pdev = NULL;
+	while ((pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa003, pdev))) {
+		adap_node = pci_device_to_OF_node(pdev);

Should be in the pasemi code, and pass a bus number and device node to generic code that does this:

Yeah, it'd be the natural way of doing it, if it was needed.

-Olof

#4 lore raw
Quoted 10 lines · Olof Johansson
Quoted 5 lines · Scott Wood
Quoted 3 lines · Olof Johansson

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.

Can we factor at least some of this stuff out into common code?

I didn't really feel strong motivations to do so, given that the amount of shared code is quite small, and the official bindings are not yet determined.

Enh... I'm just irked because I originally did it in a generic manner, and whoever it was that did further work on my patch shoved in into fsl_soc. :-P

Quoted 3 lines

Chances are whenever the bindings are done they might be incompatible with what we already have in our firmware, so the code would need to be separated out again.

Well, then it'd be better to just have one bit of code to fix, right? :-)

It'd suck to see different i2c controllers end up implementing the binding differently due to the forking, though. Already with this patch, we have a different set of i2c devices that will be recognized depending on the adapter.

-Scott