All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/10] Mainly 52xx patches for 2.6.21 (but not only)
@ 2007-02-12 22:13 Sylvain Munaut
  2007-02-12 22:13 ` [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c Sylvain Munaut
  2007-02-15 22:18 ` [PATCH] " Sylvain Munaut
  0 siblings, 2 replies; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML

Hi Paul,


This patchset is against a recent linus clone (it relies on recent
additions) + the two patches Grant posted today.

This patch set starts with 52xx specific stuff. They've been tested
on the EFIKA and lite5200 by Grant and myself.

The last 4 patches add a unified uevent handler for bus relying on
of_device. This patch has been tested on the efika as well.
It has been posted here before and was tested then by some other
people. The problems reported then have been fixed in this version.

I hope this will make it to 2.6.21.


	Sylvain

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c
  2007-02-12 22:13 [PATCH 00/10] Mainly 52xx patches for 2.6.21 (but not only) Sylvain Munaut
@ 2007-02-12 22:13 ` Sylvain Munaut
  2007-02-12 22:13   ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Sylvain Munaut
  2007-02-12 23:10   ` [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c Benjamin Herrenschmidt
  2007-02-15 22:18 ` [PATCH] " Sylvain Munaut
  1 sibling, 2 replies; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
---
 drivers/serial/mpc52xx_uart.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 6999816..ee4ebaf 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -999,6 +999,9 @@ mpc52xx_uart_of_remove(struct of_device 
 	if (port)
 		uart_remove_one_port(&mpc52xx_uart_driver, port);
 
+	if (port->irq != NO_IRQ)
+		irq_dispose_mapping(port->irq);
+
 	return 0;
 }
 
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA
  2007-02-12 22:13 ` [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c Sylvain Munaut
@ 2007-02-12 22:13   ` Sylvain Munaut
  2007-02-12 22:13     ` [PATCH 03/10] powerpc: Restore 'proper' link order in platform Sylvain Munaut
                       ` (2 more replies)
  2007-02-12 23:10   ` [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c Benjamin Herrenschmidt
  1 sibling, 3 replies; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

We make the efika device tree compliant with the defined bindings
(at least compliant enough). This is mostly done by mangling
the device_type and compatible properties, but also adding
some missing bits.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/powerpc/kernel/prom_init.c |   81 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 520ef42..4fb5938 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2117,11 +2117,92 @@ #else
 #define fixup_device_tree_pmac()
 #endif
 
+#ifdef CONFIG_PPC_EFIKA
+/* The current fw of the Efika has a device tree needs quite a few
+ * fixups to be compliant with the mpc52xx bindings. It's currently
+ * unknown if it will ever be compliant (come on bPlan ...) so we do fixups.
+ * NOTE that we (barely) tolerate it because the EFIKA was out before
+ * the bindings were finished, for any new boards -> RTFM ! */
+
+struct subst_entry {
+	char *path;
+	char *property;
+	void *value;
+	int value_len;
+};
+
+static void __init fixup_device_tree_efika(void)
+{
+	/* Substitution table */
+	#define prop_cstr(x) x, sizeof(x)
+	int prop_sound_irq[3] = { 2, 2, 0 };
+	int prop_bcomm_irq[3*16] = { 3,0,0, 3,1,0, 3,2,0, 3,3,0,
+	                             3,4,0, 3,5,0, 3,6,0, 3,7,0,
+	                             3,8,0, 3,9,0, 3,10,0, 3,11,0,
+	                             3,12,0, 3,13,0, 3,14,0, 3,15,0 };
+	struct subst_entry efika_subst_table[] = {
+		{ "/",			"device_type",	prop_cstr("efika") },
+		{ "/builtin",		"compatible",	prop_cstr("soc") },
+		{ "/builtin/ata",	"compatible",	prop_cstr("mpc5200b-ata\0mpc5200-ata"), },
+		{ "/builtin/bestcomm",	"compatible",	prop_cstr("mpc5200b-bestcomm\0mpc5200-bestcomm") },
+		{ "/builtin/bestcomm",	"interrupts",	prop_bcomm_irq, sizeof(prop_bcomm_irq) },
+		{ "/builtin/ethernet",	"compatible",	prop_cstr("mpc5200b-fec\0mpc5200-fec") },
+		{ "/builtin/pic",	"compatible",	prop_cstr("mpc5200b-pic\0mpc5200-pic") },
+		{ "/builtin/serial",	"compatible",	prop_cstr("mpc5200b-psc-uart\0mpc5200-psc-uart") },
+		{ "/builtin/sound",	"compatible",	prop_cstr("mpc5200b-psc-ac97\0mpc5200-psc-ac97") },
+		{ "/builtin/sound",	"interrupts",	prop_sound_irq, sizeof(prop_sound_irq) },
+		{ "/builtin/sram",	"compatible",	prop_cstr("mpc5200b-sram\0mpc5200-sram") },
+		{ "/builtin/sram",	"device_type",	prop_cstr("sram") },
+		{}
+	};
+	#undef prop_cstr
+
+	/* Vars */
+	u32 node;
+	char prop[64];
+	int rv, i;
+
+	/* Check if we're really running on a EFIKA */
+	node = call_prom("finddevice", 1, 1, ADDR("/"));
+	if (!PHANDLE_VALID(node))
+		return;
+
+	rv = prom_getprop(node, "model", prop, sizeof(prop));
+	if (rv == PROM_ERROR)
+		return;
+	if (strcmp(prop, "EFIKA5K2"))
+		return;
+
+	prom_printf("Applying EFIKA device tree fixups\n");
+
+	/* Process substitution table */
+	for (i=0; efika_subst_table[i].path; i++) {
+		struct subst_entry *se = &efika_subst_table[i];
+
+		node = call_prom("finddevice", 1, 1, ADDR(se->path));
+		if (!PHANDLE_VALID(node)) {
+			prom_printf("fixup_device_tree_efika: ",
+				"skipped entry %x - not found\n", i);
+			continue;
+		}
+
+		rv = prom_setprop(node, se->path, se->property,
+					se->value, se->value_len );
+		if (rv == PROM_ERROR)
+			prom_printf("fixup_device_tree_efika: ",
+				"skipped entry %x - setprop error\n", i);
+	}
+}
+#else
+#define fixup_device_tree_efika()
+#endif
+
 static void __init fixup_device_tree(void)
 {
 	fixup_device_tree_maple();
 	fixup_device_tree_chrp();
 	fixup_device_tree_pmac();
+	fixup_device_tree_efika();
 }
 
 static void __init prom_find_boot_cpu(void)
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 03/10] powerpc: Restore 'proper' link order in platform
  2007-02-12 22:13   ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Sylvain Munaut
@ 2007-02-12 22:13     ` Sylvain Munaut
  2007-02-12 22:13       ` [PATCH 04/10] powerpc: Use common 52xx of_platform probe code for EFIKA Sylvain Munaut
  2007-02-12 23:06     ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Kumar Gala
  2007-02-12 23:12     ` Benjamin Herrenschmidt
  2 siblings, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

The 52xx was put before CHRP to allow EFIKA to be recognized
properly. Now the efika tree is fixed up in prom_init so
no need for this ugly hack. So we restore the 'normal'
order.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/powerpc/platforms/Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 65e6123..4520042 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -5,9 +5,9 @@ ifeq ($(CONFIG_PPC64),y)
 obj-$(CONFIG_PPC_PMAC)		+= powermac/
 endif
 endif
-obj-$(CONFIG_PPC_MPC52xx)	+= 52xx/
 obj-$(CONFIG_PPC_CHRP)		+= chrp/
 obj-$(CONFIG_4xx)		+= 4xx/
+obj-$(CONFIG_PPC_MPC52xx)	+= 52xx/
 obj-$(CONFIG_PPC_8xx)		+= 8xx/
 obj-$(CONFIG_PPC_82xx)		+= 82xx/
 obj-$(CONFIG_PPC_83xx)		+= 83xx/
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 04/10] powerpc: Use common 52xx of_platform probe code for EFIKA
  2007-02-12 22:13     ` [PATCH 03/10] powerpc: Restore 'proper' link order in platform Sylvain Munaut
@ 2007-02-12 22:13       ` Sylvain Munaut
  2007-02-12 22:13         ` [PATCH 05/10] powerpc: Fix unbalanced of_node_{get, put} in efika-setup.c Sylvain Munaut
  0 siblings, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

Now that the device tree has the good properties, we can
remove all the efika_init code by a single call to common code.

While we're modifying that file, a few whitespaces/alignement/typo
fixes are made (nothing significant).

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/powerpc/platforms/52xx/efika-setup.c |   64 ++++++++---------------------
 1 files changed, 18 insertions(+), 46 deletions(-)

diff --git a/arch/powerpc/platforms/52xx/efika-setup.c b/arch/powerpc/platforms/52xx/efika-setup.c
index 110c980..d61ce84 100644
--- a/arch/powerpc/platforms/52xx/efika-setup.c
+++ b/arch/powerpc/platforms/52xx/efika-setup.c
@@ -2,7 +2,7 @@
  *
  * Efika 5K2 platform setup
  * Some code really inspired from the lite5200b platform.
- * 
+ *
  * Copyright (C) 2006 bplan GmbH
  *
  * This file is licensed under the terms of the GNU General Public License
@@ -81,35 +81,7 @@ #endif
 	efika_pcisetup();
 
 	if (ppc_md.progress)
-		ppc_md.progress("Linux/PPC " UTS_RELEASE " runnung on Efika ;-)\n", 0x0);
-}
-
-static void __init efika_init(void)
-{
-	struct device_node *np;
-	struct device_node *cnp = NULL;
-	const u32 *base;
-
-	/* Find every child of the SOC node and add it to of_platform */
-	np = of_find_node_by_name(NULL, "builtin");
-	if (np) {
-		char name[BUS_ID_SIZE];
-		while ((cnp = of_get_next_child(np, cnp))) {
-			strcpy(name, cnp->name);
-
-			base = get_property(cnp, "reg", NULL);
-			if (base == NULL)
-				continue;
-
-			snprintf(name+strlen(name), BUS_ID_SIZE, "@%x", *base);
-			of_platform_device_create(cnp, name, NULL);
-
-			printk(KERN_INFO EFIKA_PLATFORM_NAME" : Added %s (type '%s' at '%s') to the known devices\n", name, cnp->type, cnp->full_name);
-		}
-	}
-
-	if (ppc_md.progress)
-		ppc_md.progress("  Have fun with your Efika!    ", 0x7777);
+		ppc_md.progress("Linux/PPC " UTS_RELEASE " running on Efika ;-)\n", 0x0);
 }
 
 static int __init efika_probe(void)
@@ -131,20 +103,20 @@ static int __init efika_probe(void)
 
 define_machine(efika)
 {
-	.name = EFIKA_PLATFORM_NAME,
-	.probe = efika_probe,
-	.setup_arch = efika_setup_arch,
-	.init = efika_init,
-	.show_cpuinfo = efika_show_cpuinfo,
-	.init_IRQ = mpc52xx_init_irq,
-	.get_irq = mpc52xx_get_irq,
-	.restart = rtas_restart,
-	.power_off = rtas_power_off,
-	.halt = rtas_halt,
-	.set_rtc_time = rtas_set_rtc_time,
-	.get_rtc_time = rtas_get_rtc_time,
-	.progress = rtas_progress,
-	.get_boot_time = rtas_get_boot_time,
-	.calibrate_decr = generic_calibrate_decr,
-	.phys_mem_access_prot = pci_phys_mem_access_prot,
+	.name			= EFIKA_PLATFORM_NAME,
+	.probe			= efika_probe,
+	.setup_arch		= efika_setup_arch,
+	.init			= mpc52xx_declare_of_platform_devices,
+	.show_cpuinfo		= efika_show_cpuinfo,
+	.init_IRQ		= mpc52xx_init_irq,
+	.get_irq		= mpc52xx_get_irq,
+	.restart		= rtas_restart,
+	.power_off		= rtas_power_off,
+	.halt			= rtas_halt,
+	.set_rtc_time		= rtas_set_rtc_time,
+	.get_rtc_time		= rtas_get_rtc_time,
+	.progress		= rtas_progress,
+	.get_boot_time		= rtas_get_boot_time,
+	.calibrate_decr		= generic_calibrate_decr,
+	.phys_mem_access_prot	= pci_phys_mem_access_prot,
 };
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 05/10] powerpc: Fix unbalanced of_node_{get, put} in efika-setup.c
  2007-02-12 22:13       ` [PATCH 04/10] powerpc: Use common 52xx of_platform probe code for EFIKA Sylvain Munaut
@ 2007-02-12 22:13         ` Sylvain Munaut
  2007-02-12 22:13           ` [PATCH 06/10] powerpc: Small cleanup of EFIKA platform Sylvain Munaut
  0 siblings, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/powerpc/platforms/52xx/efika-setup.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/platforms/52xx/efika-setup.c b/arch/powerpc/platforms/52xx/efika-setup.c
index d61ce84..b6945cb 100644
--- a/arch/powerpc/platforms/52xx/efika-setup.c
+++ b/arch/powerpc/platforms/52xx/efika-setup.c
@@ -42,14 +42,13 @@ static void efika_show_cpuinfo(struct se
 	const char *codegenvendor = NULL;
 
 	root = of_find_node_by_path("/");
-	if (root) {
-		revision = get_property(root, "revision", NULL);
-		codegendescription =
-		    get_property(root, "CODEGEN,description", NULL);
-		codegenvendor = get_property(root, "CODEGEN,vendor", NULL);
+	if (!root)
+		return;
 
-		of_node_put(root);
-	}
+	revision = get_property(root, "revision", NULL);
+	codegendescription =
+		    get_property(root, "CODEGEN,description", NULL);
+	codegenvendor = get_property(root, "CODEGEN,vendor", NULL);
 
 	if (codegendescription)
 		seq_printf(m, "machine\t\t: %s\n", codegendescription);
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 06/10] powerpc: Small cleanup of EFIKA platform
  2007-02-12 22:13         ` [PATCH 05/10] powerpc: Fix unbalanced of_node_{get, put} in efika-setup.c Sylvain Munaut
@ 2007-02-12 22:13           ` Sylvain Munaut
  2007-02-12 22:13             ` [PATCH 07/10] powerpc: Add a unified uevent handler for bus based on of_device Sylvain Munaut
  0 siblings, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

The efika platform used three files efika-pci.c efika-setup.c and
a 2 line efika.h to link the two. The total of code in those is
really not much and therefore, I think they're better merged
in a single file.

There is absolutely _no_code_change_ at all, just merged the files.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/powerpc/platforms/52xx/Makefile      |    2 
 arch/powerpc/platforms/52xx/efika-pci.c   |  119 --------------
 arch/powerpc/platforms/52xx/efika-setup.c |  121 --------------
 arch/powerpc/platforms/52xx/efika.c       |  243 +++++++++++++++++++++++++++++
 arch/powerpc/platforms/52xx/efika.h       |   19 --
 5 files changed, 244 insertions(+), 260 deletions(-)

diff --git a/arch/powerpc/platforms/52xx/Makefile b/arch/powerpc/platforms/52xx/Makefile
index 795b713..07cdbca 100644
--- a/arch/powerpc/platforms/52xx/Makefile
+++ b/arch/powerpc/platforms/52xx/Makefile
@@ -6,5 +6,5 @@ obj-y				+= mpc52xx_pic.o mpc52xx_common
 obj-$(CONFIG_PCI)		+= mpc52xx_pci.o
 endif
 
-obj-$(CONFIG_PPC_EFIKA)		+= efika-setup.o efika-pci.o
+obj-$(CONFIG_PPC_EFIKA)		+= efika.o
 obj-$(CONFIG_PPC_LITE5200)	+= lite5200.o
diff --git a/arch/powerpc/platforms/52xx/efika-pci.c b/arch/powerpc/platforms/52xx/efika-pci.c
deleted file mode 100644
index 62e05b2..0000000
--- a/arch/powerpc/platforms/52xx/efika-pci.c
+++ /dev/null
@@ -1,119 +0,0 @@
-
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include <linux/string.h>
-#include <linux/init.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/prom.h>
-#include <asm/machdep.h>
-#include <asm/sections.h>
-#include <asm/pci-bridge.h>
-#include <asm/rtas.h>
-
-#include "efika.h"
-
-#ifdef CONFIG_PCI
-/*
- * Access functions for PCI config space using RTAS calls.
- */
-static int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
-			    int len, u32 * val)
-{
-	struct pci_controller *hose = bus->sysdata;
-	unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
-	    | (((bus->number - hose->first_busno) & 0xff) << 16)
-	    | (hose->index << 24);
-	int ret = -1;
-	int rval;
-
-	rval = rtas_call(rtas_token("read-pci-config"), 2, 2, &ret, addr, len);
-	*val = ret;
-	return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
-}
-
-static int rtas_write_config(struct pci_bus *bus, unsigned int devfn,
-			     int offset, int len, u32 val)
-{
-	struct pci_controller *hose = bus->sysdata;
-	unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
-	    | (((bus->number - hose->first_busno) & 0xff) << 16)
-	    | (hose->index << 24);
-	int rval;
-
-	rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL,
-			 addr, len, val);
-	return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
-}
-
-static struct pci_ops rtas_pci_ops = {
-	rtas_read_config,
-	rtas_write_config
-};
-
-void __init efika_pcisetup(void)
-{
-	const int *bus_range;
-	int len;
-	struct pci_controller *hose;
-	struct device_node *root;
-	struct device_node *pcictrl;
-
-	root = of_find_node_by_path("/");
-	if (root == NULL) {
-		printk(KERN_WARNING EFIKA_PLATFORM_NAME
-		       ": Unable to find the root node\n");
-		return;
-	}
-
-	for (pcictrl = NULL;;) {
-		pcictrl = of_get_next_child(root, pcictrl);
-		if ((pcictrl == NULL) || (strcmp(pcictrl->name, "pci") == 0))
-			break;
-	}
-
-	of_node_put(root);
-
-	if (pcictrl == NULL) {
-		printk(KERN_WARNING EFIKA_PLATFORM_NAME
-		       ": Unable to find the PCI bridge node\n");
-		return;
-	}
-
-	bus_range = get_property(pcictrl, "bus-range", &len);
-	if (bus_range == NULL || len < 2 * sizeof(int)) {
-		printk(KERN_WARNING EFIKA_PLATFORM_NAME
-		       ": Can't get bus-range for %s\n", pcictrl->full_name);
-		return;
-	}
-
-	if (bus_range[1] == bus_range[0])
-		printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI bus %d",
-		       bus_range[0]);
-	else
-		printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI buses %d..%d",
-		       bus_range[0], bus_range[1]);
-	printk(" controlled by %s\n", pcictrl->full_name);
-	printk("\n");
-
-	hose = pcibios_alloc_controller();
-	if (!hose) {
-		printk(KERN_WARNING EFIKA_PLATFORM_NAME
-		       ": Can't allocate PCI controller structure for %s\n",
-		       pcictrl->full_name);
-		return;
-	}
-
-	hose->arch_data = of_node_get(pcictrl);
-	hose->first_busno = bus_range[0];
-	hose->last_busno = bus_range[1];
-	hose->ops = &rtas_pci_ops;
-
-	pci_process_bridge_OF_ranges(hose, pcictrl, 0);
-}
-
-#else
-void __init efika_pcisetup(void)
-{}
-#endif
diff --git a/arch/powerpc/platforms/52xx/efika-setup.c b/arch/powerpc/platforms/52xx/efika-setup.c
deleted file mode 100644
index b6945cb..0000000
--- a/arch/powerpc/platforms/52xx/efika-setup.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- *
- * Efika 5K2 platform setup
- * Some code really inspired from the lite5200b platform.
- *
- * Copyright (C) 2006 bplan GmbH
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- *
- */
-
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/reboot.h>
-#include <linux/init.h>
-#include <linux/utsrelease.h>
-#include <linux/seq_file.h>
-#include <linux/root_dev.h>
-#include <linux/initrd.h>
-#include <linux/timer.h>
-#include <linux/pci.h>
-
-#include <asm/pgtable.h>
-#include <asm/prom.h>
-#include <asm/time.h>
-#include <asm/machdep.h>
-#include <asm/rtas.h>
-#include <asm/of_device.h>
-#include <asm/of_platform.h>
-#include <asm/mpc52xx.h>
-
-#include "efika.h"
-
-static void efika_show_cpuinfo(struct seq_file *m)
-{
-	struct device_node *root;
-	const char *revision = NULL;
-	const char *codegendescription = NULL;
-	const char *codegenvendor = NULL;
-
-	root = of_find_node_by_path("/");
-	if (!root)
-		return;
-
-	revision = get_property(root, "revision", NULL);
-	codegendescription =
-		    get_property(root, "CODEGEN,description", NULL);
-	codegenvendor = get_property(root, "CODEGEN,vendor", NULL);
-
-	if (codegendescription)
-		seq_printf(m, "machine\t\t: %s\n", codegendescription);
-	else
-		seq_printf(m, "machine\t\t: Efika\n");
-
-	if (revision)
-		seq_printf(m, "revision\t: %s\n", revision);
-
-	if (codegenvendor)
-		seq_printf(m, "vendor\t\t: %s\n", codegenvendor);
-
-	of_node_put(root);
-}
-
-static void __init efika_setup_arch(void)
-{
-	rtas_initialize();
-
-#ifdef CONFIG_BLK_DEV_INITRD
-	initrd_below_start_ok = 1;
-
-	if (initrd_start)
-		ROOT_DEV = Root_RAM0;
-	else
-#endif
-		ROOT_DEV = Root_SDA2;	/* sda2 (sda1 is for the kernel) */
-
-	efika_pcisetup();
-
-	if (ppc_md.progress)
-		ppc_md.progress("Linux/PPC " UTS_RELEASE " running on Efika ;-)\n", 0x0);
-}
-
-static int __init efika_probe(void)
-{
-	char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
-					  "model", NULL);
-
-	if (model == NULL)
-		return 0;
-	if (strcmp(model, "EFIKA5K2"))
-		return 0;
-
-	ISA_DMA_THRESHOLD = ~0L;
-	DMA_MODE_READ = 0x44;
-	DMA_MODE_WRITE = 0x48;
-
-	return 1;
-}
-
-define_machine(efika)
-{
-	.name			= EFIKA_PLATFORM_NAME,
-	.probe			= efika_probe,
-	.setup_arch		= efika_setup_arch,
-	.init			= mpc52xx_declare_of_platform_devices,
-	.show_cpuinfo		= efika_show_cpuinfo,
-	.init_IRQ		= mpc52xx_init_irq,
-	.get_irq		= mpc52xx_get_irq,
-	.restart		= rtas_restart,
-	.power_off		= rtas_power_off,
-	.halt			= rtas_halt,
-	.set_rtc_time		= rtas_set_rtc_time,
-	.get_rtc_time		= rtas_get_rtc_time,
-	.progress		= rtas_progress,
-	.get_boot_time		= rtas_get_boot_time,
-	.calibrate_decr		= generic_calibrate_decr,
-	.phys_mem_access_prot	= pci_phys_mem_access_prot,
-};
diff --git a/arch/powerpc/platforms/52xx/efika.c b/arch/powerpc/platforms/52xx/efika.c
new file mode 100644
index 0000000..8de0341
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/efika.c
@@ -0,0 +1,243 @@
+/*
+ * Efika 5K2 platform code
+ * Some code really inspired from the lite5200b platform.
+ *
+ * Copyright (C) 2006 bplan GmbH
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/errno.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/reboot.h>
+#include <linux/init.h>
+#include <linux/utsrelease.h>
+#include <linux/seq_file.h>
+#include <linux/string.h>
+#include <linux/root_dev.h>
+#include <linux/initrd.h>
+#include <linux/timer.h>
+#include <linux/pci.h>
+
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/sections.h>
+#include <asm/pci-bridge.h>
+#include <asm/pgtable.h>
+#include <asm/prom.h>
+#include <asm/time.h>
+#include <asm/machdep.h>
+#include <asm/rtas.h>
+#include <asm/of_device.h>
+#include <asm/of_platform.h>
+#include <asm/mpc52xx.h>
+
+
+#define EFIKA_PLATFORM_NAME "Efika"
+
+
+/* ------------------------------------------------------------------------ */
+/* PCI accesses thru RTAS                                                   */
+/* ------------------------------------------------------------------------ */
+
+#ifdef CONFIG_PCI
+
+/*
+ * Access functions for PCI config space using RTAS calls.
+ */
+static int rtas_read_config(struct pci_bus *bus, unsigned int devfn, int offset,
+			    int len, u32 * val)
+{
+	struct pci_controller *hose = bus->sysdata;
+	unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
+	    | (((bus->number - hose->first_busno) & 0xff) << 16)
+	    | (hose->index << 24);
+	int ret = -1;
+	int rval;
+
+	rval = rtas_call(rtas_token("read-pci-config"), 2, 2, &ret, addr, len);
+	*val = ret;
+	return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
+}
+
+static int rtas_write_config(struct pci_bus *bus, unsigned int devfn,
+			     int offset, int len, u32 val)
+{
+	struct pci_controller *hose = bus->sysdata;
+	unsigned long addr = (offset & 0xff) | ((devfn & 0xff) << 8)
+	    | (((bus->number - hose->first_busno) & 0xff) << 16)
+	    | (hose->index << 24);
+	int rval;
+
+	rval = rtas_call(rtas_token("write-pci-config"), 3, 1, NULL,
+			 addr, len, val);
+	return rval ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops rtas_pci_ops = {
+	rtas_read_config,
+	rtas_write_config
+};
+
+
+void __init efika_pcisetup(void)
+{
+	const int *bus_range;
+	int len;
+	struct pci_controller *hose;
+	struct device_node *root;
+	struct device_node *pcictrl;
+
+	root = of_find_node_by_path("/");
+	if (root == NULL) {
+		printk(KERN_WARNING EFIKA_PLATFORM_NAME
+		       ": Unable to find the root node\n");
+		return;
+	}
+
+	for (pcictrl = NULL;;) {
+		pcictrl = of_get_next_child(root, pcictrl);
+		if ((pcictrl == NULL) || (strcmp(pcictrl->name, "pci") == 0))
+			break;
+	}
+
+	of_node_put(root);
+
+	if (pcictrl == NULL) {
+		printk(KERN_WARNING EFIKA_PLATFORM_NAME
+		       ": Unable to find the PCI bridge node\n");
+		return;
+	}
+
+	bus_range = get_property(pcictrl, "bus-range", &len);
+	if (bus_range == NULL || len < 2 * sizeof(int)) {
+		printk(KERN_WARNING EFIKA_PLATFORM_NAME
+		       ": Can't get bus-range for %s\n", pcictrl->full_name);
+		return;
+	}
+
+	if (bus_range[1] == bus_range[0])
+		printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI bus %d",
+		       bus_range[0]);
+	else
+		printk(KERN_INFO EFIKA_PLATFORM_NAME ": PCI buses %d..%d",
+		       bus_range[0], bus_range[1]);
+	printk(" controlled by %s\n", pcictrl->full_name);
+	printk("\n");
+
+	hose = pcibios_alloc_controller();
+	if (!hose) {
+		printk(KERN_WARNING EFIKA_PLATFORM_NAME
+		       ": Can't allocate PCI controller structure for %s\n",
+		       pcictrl->full_name);
+		return;
+	}
+
+	hose->arch_data = of_node_get(pcictrl);
+	hose->first_busno = bus_range[0];
+	hose->last_busno = bus_range[1];
+	hose->ops = &rtas_pci_ops;
+
+	pci_process_bridge_OF_ranges(hose, pcictrl, 0);
+}
+
+#else
+void __init efika_pcisetup(void)
+{}
+#endif
+
+
+
+/* ------------------------------------------------------------------------ */
+/* Platform setup                                                           */
+/* ------------------------------------------------------------------------ */
+
+static void efika_show_cpuinfo(struct seq_file *m)
+{
+	struct device_node *root;
+	const char *revision = NULL;
+	const char *codegendescription = NULL;
+	const char *codegenvendor = NULL;
+
+	root = of_find_node_by_path("/");
+	if (!root)
+		return;
+
+	revision = get_property(root, "revision", NULL);
+	codegendescription =
+		    get_property(root, "CODEGEN,description", NULL);
+	codegenvendor = get_property(root, "CODEGEN,vendor", NULL);
+
+	if (codegendescription)
+		seq_printf(m, "machine\t\t: %s\n", codegendescription);
+	else
+		seq_printf(m, "machine\t\t: Efika\n");
+
+	if (revision)
+		seq_printf(m, "revision\t: %s\n", revision);
+
+	if (codegenvendor)
+		seq_printf(m, "vendor\t\t: %s\n", codegenvendor);
+
+	of_node_put(root);
+}
+
+static void __init efika_setup_arch(void)
+{
+	rtas_initialize();
+
+#ifdef CONFIG_BLK_DEV_INITRD
+	initrd_below_start_ok = 1;
+
+	if (initrd_start)
+		ROOT_DEV = Root_RAM0;
+	else
+#endif
+		ROOT_DEV = Root_SDA2;	/* sda2 (sda1 is for the kernel) */
+
+	efika_pcisetup();
+
+	if (ppc_md.progress)
+		ppc_md.progress("Linux/PPC " UTS_RELEASE " running on Efika ;-)\n", 0x0);
+}
+
+static int __init efika_probe(void)
+{
+	char *model = of_get_flat_dt_prop(of_get_flat_dt_root(),
+					  "model", NULL);
+
+	if (model == NULL)
+		return 0;
+	if (strcmp(model, "EFIKA5K2"))
+		return 0;
+
+	ISA_DMA_THRESHOLD = ~0L;
+	DMA_MODE_READ = 0x44;
+	DMA_MODE_WRITE = 0x48;
+
+	return 1;
+}
+
+define_machine(efika)
+{
+	.name			= EFIKA_PLATFORM_NAME,
+	.probe			= efika_probe,
+	.setup_arch		= efika_setup_arch,
+	.init			= mpc52xx_declare_of_platform_devices,
+	.show_cpuinfo		= efika_show_cpuinfo,
+	.init_IRQ		= mpc52xx_init_irq,
+	.get_irq		= mpc52xx_get_irq,
+	.restart		= rtas_restart,
+	.power_off		= rtas_power_off,
+	.halt			= rtas_halt,
+	.set_rtc_time		= rtas_set_rtc_time,
+	.get_rtc_time		= rtas_get_rtc_time,
+	.progress		= rtas_progress,
+	.get_boot_time		= rtas_get_boot_time,
+	.calibrate_decr		= generic_calibrate_decr,
+	.phys_mem_access_prot	= pci_phys_mem_access_prot,
+};
+
diff --git a/arch/powerpc/platforms/52xx/efika.h b/arch/powerpc/platforms/52xx/efika.h
deleted file mode 100644
index 2f060fd..0000000
--- a/arch/powerpc/platforms/52xx/efika.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Efika 5K2 platform setup - Header file
- *
- * Copyright (C) 2006 bplan GmbH
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- *
- */
-
-#ifndef __ARCH_POWERPC_EFIKA__
-#define __ARCH_POWERPC_EFIKA__
-
-#define EFIKA_PLATFORM_NAME "Efika"
-
-extern void __init efika_pcisetup(void);
-
-#endif
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 07/10] powerpc: Add a unified uevent handler for bus based on of_device
  2007-02-12 22:13           ` [PATCH 06/10] powerpc: Small cleanup of EFIKA platform Sylvain Munaut
@ 2007-02-12 22:13             ` Sylvain Munaut
  2007-02-12 22:13               ` [PATCH 08/10] macintosh: Use the new of_device common uevent handler Sylvain Munaut
  0 siblings, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

This common uevent handler allow the several bus types based on
of_device to generate the uevent properly and avoiding
code duplication.

This handlers take a struct device as argument and can therefore
be used as the uevent call directly if no special treatment is
needed for the bus.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
---
 arch/powerpc/kernel/of_device.c |  112 +++++++++++++++++++++++++++++++++++++++
 include/asm-powerpc/of_device.h |    3 +
 2 files changed, 115 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index e921514..e8aa1f3 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -120,6 +120,117 @@ void of_device_unregister(struct of_devi
 }
 
 
+static ssize_t of_device_get_modalias(struct of_device *ofdev,
+					char *str, ssize_t len)
+{
+	const char *compat;
+	int cplen, i;
+	ssize_t tsize, csize, repend;
+
+	/* Name & Type */
+	csize = snprintf(str, len, "of:N%sT%s",
+				ofdev->node->name, ofdev->node->type);
+
+	/* Get compatible property if any */
+	compat = get_property(ofdev->node, "compatible", &cplen);
+	if (!compat)
+		return csize;
+
+	/* Find true end (we tolerate multiple \0 at the end */
+	for (i=(cplen-1); i>=0 && !compat[i]; i--)
+		cplen--;
+	if (!cplen)
+		return csize;
+	cplen++;
+
+	/* Check space (need cplen+1 chars including final \0) */
+	tsize = csize + cplen;
+	repend = tsize;
+
+	if (csize>=len)		/* @ the limit, all is already filled */
+		return tsize;
+
+	if (tsize>=len) {		/* limit compat list */
+		cplen = len-csize-1;
+		repend = len;
+	}
+
+	/* Copy and do char replacement */
+	memcpy(&str[csize+1], compat, cplen);
+	for (i=csize; i<repend; i++) {
+		char c = str[i];
+		if (c=='\0')
+			str[i] = 'C';
+		else if (c==' ')
+			str[i] = '_';
+	}
+
+	return tsize;
+}
+
+int of_device_uevent(struct device *dev,
+		char **envp, int num_envp, char *buffer, int buffer_size)
+{
+	struct of_device *ofdev;
+	const char *compat;
+	int i = 0, length = 0, seen = 0, cplen, sl;
+
+	if (!dev)
+		return -ENODEV;
+
+	ofdev = to_of_device(dev);
+
+	if (add_uevent_var(envp, num_envp, &i,
+			   buffer, buffer_size, &length,
+			   "OF_NAME=%s", ofdev->node->name))
+		return -ENOMEM;
+
+	if (add_uevent_var(envp, num_envp, &i,
+			   buffer, buffer_size, &length,
+			   "OF_TYPE=%s", ofdev->node->type))
+		return -ENOMEM;
+
+        /* Since the compatible field can contain pretty much anything
+         * it's not really legal to split it out with commas. We split it
+         * up using a number of environment variables instead. */
+
+	compat = get_property(ofdev->node, "compatible", &cplen);
+	while (compat && *compat && cplen > 0) {
+		if (add_uevent_var(envp, num_envp, &i,
+				   buffer, buffer_size, &length,
+				   "OF_COMPATIBLE_%d=%s", seen, compat))
+			return -ENOMEM;
+
+		sl = strlen (compat) + 1;
+		compat += sl;
+		cplen -= sl;
+		seen++;
+	}
+
+	if (add_uevent_var(envp, num_envp, &i,
+			   buffer, buffer_size, &length,
+			   "OF_COMPATIBLE_N=%d", seen))
+		return -ENOMEM;
+
+	/* modalias is trickier, we add it in 2 steps */
+	if (add_uevent_var(envp, num_envp, &i,
+			   buffer, buffer_size, &length,
+			   "MODALIAS="))
+		return -ENOMEM;
+
+	sl = of_device_get_modalias(ofdev, &buffer[length-1],
+					buffer_size-length);
+	if (sl >= (buffer_size-length))
+		return -ENOMEM;
+
+	length += sl;
+
+	envp[i] = NULL;
+
+	return 0;
+}
+
+
 EXPORT_SYMBOL(of_match_node);
 EXPORT_SYMBOL(of_match_device);
 EXPORT_SYMBOL(of_device_register);
@@ -127,3 +238,4 @@ EXPORT_SYMBOL(of_device_unregister);
 EXPORT_SYMBOL(of_dev_get);
 EXPORT_SYMBOL(of_dev_put);
 EXPORT_SYMBOL(of_release_dev);
+EXPORT_SYMBOL(of_device_uevent);
diff --git a/include/asm-powerpc/of_device.h b/include/asm-powerpc/of_device.h
index a889b20..4f1aabe 100644
--- a/include/asm-powerpc/of_device.h
+++ b/include/asm-powerpc/of_device.h
@@ -32,5 +32,8 @@ extern int of_device_register(struct of_
 extern void of_device_unregister(struct of_device *ofdev);
 extern void of_release_dev(struct device *dev);
 
+extern int of_device_uevent(struct device *dev,
+	char **envp, int num_envp, char *buffer, int buffer_size);
+
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_OF_DEVICE_H */
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 08/10] macintosh: Use the new of_device common uevent handler
  2007-02-12 22:13             ` [PATCH 07/10] powerpc: Add a unified uevent handler for bus based on of_device Sylvain Munaut
@ 2007-02-12 22:13               ` Sylvain Munaut
  2007-02-12 22:13                 ` [PATCH 09/10] powerpc: Add uevent handler for of_platform_bus Sylvain Munaut
  2007-03-27  6:30                 ` [PATCH 08/10] macintosh: Use the new of_device common uevent handler Benjamin Herrenschmidt
  0 siblings, 2 replies; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

The generation of the uevent is now common to all bus using
of_device.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
---
 drivers/macintosh/macio_asic.c |   98 ----------------------------------------
 1 files changed, 1 insertions(+), 97 deletions(-)

diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index d562160..e851266 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -134,108 +134,12 @@ static int macio_device_resume(struct de
 	return 0;
 }
 
-static int macio_uevent(struct device *dev, char **envp, int num_envp,
-                          char *buffer, int buffer_size)
-{
-	struct macio_dev * macio_dev;
-	struct of_device * of;
-	char *scratch;
-	const char *compat, *compat2;
-
-	int i = 0;
-	int length, cplen, cplen2, seen = 0;
-
-	if (!dev)
-		return -ENODEV;
-
-	macio_dev = to_macio_device(dev);
-	if (!macio_dev)
-		return -ENODEV;
-
-	of = &macio_dev->ofdev;
-
-	/* stuff we want to pass to /sbin/hotplug */
-	envp[i++] = scratch = buffer;
-	length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
-	++length;
-	buffer_size -= length;
-	if ((buffer_size <= 0) || (i >= num_envp))
-		return -ENOMEM;
-	scratch += length;
-
-	envp[i++] = scratch;
-	length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
-	++length;
-	buffer_size -= length;
-	if ((buffer_size <= 0) || (i >= num_envp))
-		return -ENOMEM;
-	scratch += length;
-
-        /* Since the compatible field can contain pretty much anything
-         * it's not really legal to split it out with commas. We split it
-         * up using a number of environment variables instead. */
-
-	compat = get_property(of->node, "compatible", &cplen);
-	compat2 = compat;
-	cplen2= cplen;
-	while (compat && cplen > 0) {
-                envp[i++] = scratch;
-		length = scnprintf (scratch, buffer_size,
-		                     "OF_COMPATIBLE_%d=%s", seen, compat);
-		++length;
-		buffer_size -= length;
-		if ((buffer_size <= 0) || (i >= num_envp))
-			return -ENOMEM;
-		scratch += length;
-		length = strlen (compat) + 1;
-		compat += length;
-		cplen -= length;
-		seen++;
-	}
-
-	envp[i++] = scratch;
-	length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
-	++length;
-	buffer_size -= length;
-	if ((buffer_size <= 0) || (i >= num_envp))
-		return -ENOMEM;
-	scratch += length;
-
-	envp[i++] = scratch;
-	length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
-			of->node->name, of->node->type);
-	/* overwrite '\0' */
-	buffer_size -= length;
-	if ((buffer_size <= 0) || (i >= num_envp))
-		return -ENOMEM;
-	scratch += length;
-
-	if (!compat2) {
-		compat2 = "";
-		cplen2 = 1;
-	}
-	while (cplen2 > 0) {
-		length = snprintf (scratch, buffer_size, "C%s", compat2);
-		buffer_size -= length;
-		if (buffer_size <= 0)
-			return -ENOMEM;
-		scratch += length;
-		length = strlen (compat2) + 1;
-		compat2 += length;
-		cplen2 -= length;
-	}
-
-	envp[i] = NULL;
-
-	return 0;
-}
-
 extern struct device_attribute macio_dev_attrs[];
 
 struct bus_type macio_bus_type = {
        .name	= "macio",
        .match	= macio_bus_match,
-       .uevent = macio_uevent,
+       .uevent = of_device_uevent,
        .probe	= macio_device_probe,
        .remove	= macio_device_remove,
        .shutdown = macio_device_shutdown,
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 09/10] powerpc: Add uevent handler for of_platform_bus
  2007-02-12 22:13               ` [PATCH 08/10] macintosh: Use the new of_device common uevent handler Sylvain Munaut
@ 2007-02-12 22:13                 ` Sylvain Munaut
  2007-02-12 22:13                   ` [PATCH 10/10] powerpc: Add uevent handler for ibmebus Sylvain Munaut
  2007-03-27  6:30                 ` [PATCH 08/10] macintosh: Use the new of_device common uevent handler Benjamin Herrenschmidt
  1 sibling, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

Adding this handler allow userspace to properly handle the module
autoloading. The generation of the uevent itself is now common to
all bus using of_device, so not much code here.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
---
 arch/powerpc/kernel/of_platform.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
index b734517..da78e44 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -133,6 +133,7 @@ static int of_platform_device_resume(str
 struct bus_type of_platform_bus_type = {
        .name	= "of_platform",
        .match	= of_platform_bus_match,
+       .uevent	= of_device_uevent,
        .probe	= of_platform_device_probe,
        .remove	= of_platform_device_remove,
        .suspend	= of_platform_device_suspend,
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH 10/10] powerpc: Add uevent handler for ibmebus
  2007-02-12 22:13                 ` [PATCH 09/10] powerpc: Add uevent handler for of_platform_bus Sylvain Munaut
@ 2007-02-12 22:13                   ` Sylvain Munaut
  2007-03-29 14:46                     ` Olaf Hering
  0 siblings, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 22:13 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: Linux PPC Dev ML, Sylvain Munaut

Adding this handler allow userspace to properly handle the module
autoloading. The generation of the uevent itself is now common to
all bus using of_device, so not much code here.

But we still need a small wrapper to filter out the dummy root
device node used by this bus.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
---
 arch/powerpc/kernel/ibmebus.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 82bd2f1..2e8d9fd 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -361,9 +361,25 @@ static int ibmebus_bus_match(struct devi
 	return 0;
 }
 
+static int ibmebus_bus_uevent(struct device *dev,
+		char **envp, int num_envp, char *buffer, int buffer_size)
+{
+	struct ibmebus_dev *ebus_dev;
+
+	if (!dev)
+		return -ENODEV;
+
+	ebus_dev = to_ibmebus_dev(dev);
+	if (ebus_dev==ibmebus_bus_device)	/* filter dummy root device */
+		return -ENODEV;
+
+	return of_device_uevent(dev, envp, num_envp, buffer, buffer_size);
+}
+
 struct bus_type ibmebus_bus_type = {
 	.name = "ibmebus",
 	.match = ibmebus_bus_match,
+	.uevent = ibmebus_bus_uevent,
 };
 EXPORT_SYMBOL(ibmebus_bus_type);
 
-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA
  2007-02-12 22:13   ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Sylvain Munaut
  2007-02-12 22:13     ` [PATCH 03/10] powerpc: Restore 'proper' link order in platform Sylvain Munaut
@ 2007-02-12 23:06     ` Kumar Gala
  2007-02-12 23:11       ` Sylvain Munaut
  2007-02-12 23:18       ` Benjamin Herrenschmidt
  2007-02-12 23:12     ` Benjamin Herrenschmidt
  2 siblings, 2 replies; 28+ messages in thread
From: Kumar Gala @ 2007-02-12 23:06 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Linux PPC Dev ML, Paul Mackerras


On Feb 12, 2007, at 4:13 PM, Sylvain Munaut wrote:

> We make the efika device tree compliant with the defined bindings
> (at least compliant enough). This is mostly done by mangling
> the device_type and compatible properties, but also adding
> some missing bits.
>
> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
> Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
>  arch/powerpc/kernel/prom_init.c |   81 ++++++++++++++++++++++++++++ 
> +++++++++++
>  1 files changed, 81 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/ 
> prom_init.c
> index 520ef42..4fb5938 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -2117,11 +2117,92 @@ #else
>  #define fixup_device_tree_pmac()
>  #endif
>
> +#ifdef CONFIG_PPC_EFIKA
>

can't this EFIKA fixup live in efika board code (platforms/52xx/efika*)

- k

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c
  2007-02-12 22:13 ` [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c Sylvain Munaut
  2007-02-12 22:13   ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Sylvain Munaut
@ 2007-02-12 23:10   ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 28+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-12 23:10 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Linux PPC Dev ML, Paul Mackerras

On Mon, 2007-02-12 at 23:13 +0100, Sylvain Munaut wrote:
> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
> Acked-by: Grant Likely <grant.likely@secretlab.ca>
> ---
>  drivers/serial/mpc52xx_uart.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
> index 6999816..ee4ebaf 100644
> --- a/drivers/serial/mpc52xx_uart.c
> +++ b/drivers/serial/mpc52xx_uart.c
> @@ -999,6 +999,9 @@ mpc52xx_uart_of_remove(struct of_device 
>  	if (port)
>  		uart_remove_one_port(&mpc52xx_uart_driver, port);
>  
> +	if (port->irq != NO_IRQ)
> +		irq_dispose_mapping(port->irq);
> +
>  	return 0;
>  }

The NO_IRQ test isn't useful.

Cheers,
Ben

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA
  2007-02-12 23:06     ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Kumar Gala
@ 2007-02-12 23:11       ` Sylvain Munaut
  2007-02-12 23:18       ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 23:11 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Linux PPC Dev ML, Paul Mackerras

Kumar Gala wrote:
>
> On Feb 12, 2007, at 4:13 PM, Sylvain Munaut wrote:
>
>> We make the efika device tree compliant with the defined bindings
>> (at least compliant enough). This is mostly done by mangling
>> the device_type and compatible properties, but also adding
>> some missing bits.
>>
>> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
>> Acked-by: Grant Likely <grant.likely@secretlab.ca>
>> ---
>>  arch/powerpc/kernel/prom_init.c |   81
>> +++++++++++++++++++++++++++++++++++++++
>>  1 files changed, 81 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/powerpc/kernel/prom_init.c
>> b/arch/powerpc/kernel/prom_init.c
>> index 520ef42..4fb5938 100644
>> --- a/arch/powerpc/kernel/prom_init.c
>> +++ b/arch/powerpc/kernel/prom_init.c
>> @@ -2117,11 +2117,92 @@ #else
>>  #define fixup_device_tree_pmac()
>>  #endif
>>
>> +#ifdef CONFIG_PPC_EFIKA
>>
>
> can't this EFIKA fixup live in efika board code (platforms/52xx/efika*)

It's too late by then.
Since some of these are needed just to make the board recognized as an
efika and not chrp.
Or for the sram not to be assimilated to normal RAM ...

Some of them probably could by "hacking" the tree after it's been built
I guess that would be possible.
But since some of them are needed in prom_init anyway I think it's
better to keep it grouped there.


    Sylvain

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA
  2007-02-12 22:13   ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Sylvain Munaut
  2007-02-12 22:13     ` [PATCH 03/10] powerpc: Restore 'proper' link order in platform Sylvain Munaut
  2007-02-12 23:06     ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Kumar Gala
@ 2007-02-12 23:12     ` Benjamin Herrenschmidt
  2007-02-12 23:25       ` Sylvain Munaut
  2 siblings, 1 reply; 28+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-12 23:12 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Linux PPC Dev ML, Paul Mackerras


> +static void __init fixup_device_tree_efika(void)
> +{
> +	/* Substitution table */
> +	#define prop_cstr(x) x, sizeof(x)
> +	int prop_sound_irq[3] = { 2, 2, 0 };
> +	int prop_bcomm_irq[3*16] = { 3,0,0, 3,1,0, 3,2,0, 3,3,0,
> +	                             3,4,0, 3,5,0, 3,6,0, 3,7,0,
> +	                             3,8,0, 3,9,0, 3,10,0, 3,11,0,
> +	                             3,12,0, 3,13,0, 3,14,0, 3,15,0 };
> +	struct subst_entry efika_subst_table[] = {
> +		{ "/",			"device_type",	prop_cstr("efika") },
> +		{ "/builtin",		"compatible",	prop_cstr("soc") },
> +		{ "/builtin/ata",	"compatible",	prop_cstr("mpc5200b-ata\0mpc5200-ata"), },
> +		{ "/builtin/bestcomm",	"compatible",	prop_cstr("mpc5200b-bestcomm\0mpc5200-bestcomm") },
> +		{ "/builtin/bestcomm",	"interrupts",	prop_bcomm_irq, sizeof(prop_bcomm_irq) },
> +		{ "/builtin/ethernet",	"compatible",	prop_cstr("mpc5200b-fec\0mpc5200-fec") },
> +		{ "/builtin/pic",	"compatible",	prop_cstr("mpc5200b-pic\0mpc5200-pic") },
> +		{ "/builtin/serial",	"compatible",	prop_cstr("mpc5200b-psc-uart\0mpc5200-psc-uart") },
> +		{ "/builtin/sound",	"compatible",	prop_cstr("mpc5200b-psc-ac97\0mpc5200-psc-ac97") },
> +		{ "/builtin/sound",	"interrupts",	prop_sound_irq, sizeof(prop_sound_irq) },
> +		{ "/builtin/sram",	"compatible",	prop_cstr("mpc5200b-sram\0mpc5200-sram") },
> +		{ "/builtin/sram",	"device_type",	prop_cstr("sram") },
> +		{}
> +	};
> +	#undef prop_cstr

What about making all of the above const ? Also I wonder wether it's
useful to mark the tables as static and __initdata  too...

> +
> +	rv = prom_getprop(node, "model", prop, sizeof(prop));
> +	if (rv == PROM_ERROR)
> +		return;
> +	if (strcmp(prop, "EFIKA5K2"))
> +		return;

Is there a version in their device-tree ? We might want to check in case
they ever fix it ...

Ben.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA
  2007-02-12 23:06     ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Kumar Gala
  2007-02-12 23:11       ` Sylvain Munaut
@ 2007-02-12 23:18       ` Benjamin Herrenschmidt
  1 sibling, 0 replies; 28+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-12 23:18 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Linux PPC Dev ML, Sylvain Munaut, Paul Mackerras

On Mon, 2007-02-12 at 17:06 -0600, Kumar Gala wrote:
> On Feb 12, 2007, at 4:13 PM, Sylvain Munaut wrote:
> 
> > We make the efika device tree compliant with the defined bindings
> > (at least compliant enough). This is mostly done by mangling
> > the device_type and compatible properties, but also adding
> > some missing bits.
> >
> > Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
> > Acked-by: Grant Likely <grant.likely@secretlab.ca>
> > ---
> >  arch/powerpc/kernel/prom_init.c |   81 ++++++++++++++++++++++++++++ 
> > +++++++++++
> >  1 files changed, 81 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/ 
> > prom_init.c
> > index 520ef42..4fb5938 100644
> > --- a/arch/powerpc/kernel/prom_init.c
> > +++ b/arch/powerpc/kernel/prom_init.c
> > @@ -2117,11 +2117,92 @@ #else
> >  #define fixup_device_tree_pmac()
> >  #endif
> >
> > +#ifdef CONFIG_PPC_EFIKA
> >
> 
> can't this EFIKA fixup live in efika board code (platforms/52xx/efika*)

Nah, those fixups belong in prom_init which itself may endup being split
in the boot wrappers on day ...

Ben.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA
  2007-02-12 23:12     ` Benjamin Herrenschmidt
@ 2007-02-12 23:25       ` Sylvain Munaut
  2007-02-13  0:20         ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-12 23:25 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Linux PPC Dev ML, Paul Mackerras

Benjamin Herrenschmidt wrote:
>> +static void __init fixup_device_tree_efika(void)
>> +{
>> +	/* Substitution table */
>> +	#define prop_cstr(x) x, sizeof(x)
>> +	int prop_sound_irq[3] = { 2, 2, 0 };
>> +	int prop_bcomm_irq[3*16] = { 3,0,0, 3,1,0, 3,2,0, 3,3,0,
>> +	                             3,4,0, 3,5,0, 3,6,0, 3,7,0,
>> +	                             3,8,0, 3,9,0, 3,10,0, 3,11,0,
>> +	                             3,12,0, 3,13,0, 3,14,0, 3,15,0 };
>> +	struct subst_entry efika_subst_table[] = {
>> +		{ "/",			"device_type",	prop_cstr("efika") },
>> +		{ "/builtin",		"compatible",	prop_cstr("soc") },
>> +		{ "/builtin/ata",	"compatible",	prop_cstr("mpc5200b-ata\0mpc5200-ata"), },
>> +		{ "/builtin/bestcomm",	"compatible",	prop_cstr("mpc5200b-bestcomm\0mpc5200-bestcomm") },
>> +		{ "/builtin/bestcomm",	"interrupts",	prop_bcomm_irq, sizeof(prop_bcomm_irq) },
>> +		{ "/builtin/ethernet",	"compatible",	prop_cstr("mpc5200b-fec\0mpc5200-fec") },
>> +		{ "/builtin/pic",	"compatible",	prop_cstr("mpc5200b-pic\0mpc5200-pic") },
>> +		{ "/builtin/serial",	"compatible",	prop_cstr("mpc5200b-psc-uart\0mpc5200-psc-uart") },
>> +		{ "/builtin/sound",	"compatible",	prop_cstr("mpc5200b-psc-ac97\0mpc5200-psc-ac97") },
>> +		{ "/builtin/sound",	"interrupts",	prop_sound_irq, sizeof(prop_sound_irq) },
>> +		{ "/builtin/sram",	"compatible",	prop_cstr("mpc5200b-sram\0mpc5200-sram") },
>> +		{ "/builtin/sram",	"device_type",	prop_cstr("sram") },
>> +		{}
>> +	};
>> +	#undef prop_cstr
>>     
>
> What about making all of the above const ? Also I wonder wether it's
> useful to mark the tables as static and __initdata  too...
>   
Interesting remark.

The const might cause a warning because prop_set_prop takes a void
*value and not
a const void *value. I don't know if does need to modify the value or
not though.

About static, that might achieve the same effect as const without the
warning and since the function is called only once anyway ...

I would have hoped that being local to a __init function the memory for
the initial values would be freed but I might me over optimistic.


>> +
>> +	rv = prom_getprop(node, "model", prop, sizeof(prop));
>> +	if (rv == PROM_ERROR)
>> +		return;
>> +	if (strcmp(prop, "EFIKA5K2"))
>> +		return;
>>     
>
> Is there a version in their device-tree ? We might want to check in case
> they ever fix it ...
>   
Yes there is a "revision" that's "2B3" for the moment. I'm not too sure
if it's a firmware
revision or a board revision though ...


    Sylvain

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA
  2007-02-12 23:25       ` Sylvain Munaut
@ 2007-02-13  0:20         ` Benjamin Herrenschmidt
  2007-02-16 16:44           ` Segher Boessenkool
  0 siblings, 1 reply; 28+ messages in thread
From: Benjamin Herrenschmidt @ 2007-02-13  0:20 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Linux PPC Dev ML, Paul Mackerras


> The const might cause a warning because prop_set_prop takes a void
> *value and not
> a const void *value. I don't know if does need to modify the value or
> not though.

Ok, there's room for another patch to constify prom_set_prop and all
callers then :-)

> About static, that might achieve the same effect as const without the
> warning and since the function is called only once anyway ...
> 
> I would have hoped that being local to a __init function the memory for
> the initial values would be freed but I might me over optimistic.

Yeah, worth checking the ELF output but I think you are over
optimistic :-)
> 
> >> +
> >> +	rv = prom_getprop(node, "model", prop, sizeof(prop));
> >> +	if (rv == PROM_ERROR)
> >> +		return;
> >> +	if (strcmp(prop, "EFIKA5K2"))
> >> +		return;
> >>     
> >
> > Is there a version in their device-tree ? We might want to check in case
> > they ever fix it ...
> >   
> Yes there is a "revision" that's "2B3" for the moment. I'm not too sure
> if it's a firmware
> revision or a board revision though ...

Hrm... let's ignore it for now, we can always fixup the fixups if
necessary :-)

Ben.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c
  2007-02-12 22:13 [PATCH 00/10] Mainly 52xx patches for 2.6.21 (but not only) Sylvain Munaut
  2007-02-12 22:13 ` [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c Sylvain Munaut
@ 2007-02-15 22:18 ` Sylvain Munaut
  1 sibling, 0 replies; 28+ messages in thread
From: Sylvain Munaut @ 2007-02-15 22:18 UTC (permalink / raw)
  To: Paul Mackerras, Linux PPC dev

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
---
Hi Paulus,

This is a 'fixed' version of the uart patch. The test on port->irq != NO_IRQ is
removed. But I added a check for port because it might be NULL ...

	Sylvain
---
 drivers/serial/mpc52xx_uart.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 955bbd6..8d24cd5 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -995,8 +995,10 @@ mpc52xx_uart_of_remove(struct of_device 
 	struct uart_port *port = dev_get_drvdata(&op->dev);
 	dev_set_drvdata(&op->dev, NULL);
 
-	if (port)
+	if (port) {
 		uart_remove_one_port(&mpc52xx_uart_driver, port);
+		irq_dispose_mapping(port->irq);
+	}
 
 	return 0;
 }

-- 
1.4.2

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA
  2007-02-13  0:20         ` Benjamin Herrenschmidt
@ 2007-02-16 16:44           ` Segher Boessenkool
  0 siblings, 0 replies; 28+ messages in thread
From: Segher Boessenkool @ 2007-02-16 16:44 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Linux PPC Dev ML, Sylvain Munaut, Paul Mackerras

>> The const might cause a warning because prop_set_prop takes a void
>> *value and not
>> a const void *value. I don't know if does need to modify the value or
>> not though.
>
> Ok, there's room for another patch to constify prom_set_prop and all
> callers then :-)

No callers should need changing.  If they do then that's
some bonus bugs fixed ;-)

>> I would have hoped that being local to a __init function the memory 
>> for
>> the initial values would be freed but I might me over optimistic.
>
> Yeah, worth checking the ELF output but I think you are over
> optimistic :-)

There is nothing that makes data in a function in
the .init.text section automagically end up in the
.init.data section -- those names are just names,
for all the tools involved, with no attached meaning.


Segher

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 08/10] macintosh: Use the new of_device common uevent handler
  2007-02-12 22:13               ` [PATCH 08/10] macintosh: Use the new of_device common uevent handler Sylvain Munaut
  2007-02-12 22:13                 ` [PATCH 09/10] powerpc: Add uevent handler for of_platform_bus Sylvain Munaut
@ 2007-03-27  6:30                 ` Benjamin Herrenschmidt
  2007-03-27  7:11                   ` Sylvain Munaut
  1 sibling, 1 reply; 28+ messages in thread
From: Benjamin Herrenschmidt @ 2007-03-27  6:30 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Linux PPC Dev ML, Paul Mackerras

On Mon, 2007-02-12 at 23:13 +0100, Sylvain Munaut wrote:
> The generation of the uevent is now common to all bus using
> of_device.

I haven't managed to figure out why so far (a quick inspection of the
code didn't show anything obvious) but with your patch, the snd-aoa
driver fails to auto-load at boot... might be the modalias being broken,
dunno.

Ben.

> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
> ---
>  drivers/macintosh/macio_asic.c |   98 ----------------------------------------
>  1 files changed, 1 insertions(+), 97 deletions(-)
> 
> diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
> index d562160..e851266 100644
> --- a/drivers/macintosh/macio_asic.c
> +++ b/drivers/macintosh/macio_asic.c
> @@ -134,108 +134,12 @@ static int macio_device_resume(struct de
>  	return 0;
>  }
>  
> -static int macio_uevent(struct device *dev, char **envp, int num_envp,
> -                          char *buffer, int buffer_size)
> -{
> -	struct macio_dev * macio_dev;
> -	struct of_device * of;
> -	char *scratch;
> -	const char *compat, *compat2;
> -
> -	int i = 0;
> -	int length, cplen, cplen2, seen = 0;
> -
> -	if (!dev)
> -		return -ENODEV;
> -
> -	macio_dev = to_macio_device(dev);
> -	if (!macio_dev)
> -		return -ENODEV;
> -
> -	of = &macio_dev->ofdev;
> -
> -	/* stuff we want to pass to /sbin/hotplug */
> -	envp[i++] = scratch = buffer;
> -	length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
> -	++length;
> -	buffer_size -= length;
> -	if ((buffer_size <= 0) || (i >= num_envp))
> -		return -ENOMEM;
> -	scratch += length;
> -
> -	envp[i++] = scratch;
> -	length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
> -	++length;
> -	buffer_size -= length;
> -	if ((buffer_size <= 0) || (i >= num_envp))
> -		return -ENOMEM;
> -	scratch += length;
> -
> -        /* Since the compatible field can contain pretty much anything
> -         * it's not really legal to split it out with commas. We split it
> -         * up using a number of environment variables instead. */
> -
> -	compat = get_property(of->node, "compatible", &cplen);
> -	compat2 = compat;
> -	cplen2= cplen;
> -	while (compat && cplen > 0) {
> -                envp[i++] = scratch;
> -		length = scnprintf (scratch, buffer_size,
> -		                     "OF_COMPATIBLE_%d=%s", seen, compat);
> -		++length;
> -		buffer_size -= length;
> -		if ((buffer_size <= 0) || (i >= num_envp))
> -			return -ENOMEM;
> -		scratch += length;
> -		length = strlen (compat) + 1;
> -		compat += length;
> -		cplen -= length;
> -		seen++;
> -	}
> -
> -	envp[i++] = scratch;
> -	length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
> -	++length;
> -	buffer_size -= length;
> -	if ((buffer_size <= 0) || (i >= num_envp))
> -		return -ENOMEM;
> -	scratch += length;
> -
> -	envp[i++] = scratch;
> -	length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
> -			of->node->name, of->node->type);
> -	/* overwrite '\0' */
> -	buffer_size -= length;
> -	if ((buffer_size <= 0) || (i >= num_envp))
> -		return -ENOMEM;
> -	scratch += length;
> -
> -	if (!compat2) {
> -		compat2 = "";
> -		cplen2 = 1;
> -	}
> -	while (cplen2 > 0) {
> -		length = snprintf (scratch, buffer_size, "C%s", compat2);
> -		buffer_size -= length;
> -		if (buffer_size <= 0)
> -			return -ENOMEM;
> -		scratch += length;
> -		length = strlen (compat2) + 1;
> -		compat2 += length;
> -		cplen2 -= length;
> -	}
> -
> -	envp[i] = NULL;
> -
> -	return 0;
> -}
> -
>  extern struct device_attribute macio_dev_attrs[];
>  
>  struct bus_type macio_bus_type = {
>         .name	= "macio",
>         .match	= macio_bus_match,
> -       .uevent = macio_uevent,
> +       .uevent = of_device_uevent,
>         .probe	= macio_device_probe,
>         .remove	= macio_device_remove,
>         .shutdown = macio_device_shutdown,

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 08/10] macintosh: Use the new of_device common uevent handler
  2007-03-27  6:30                 ` [PATCH 08/10] macintosh: Use the new of_device common uevent handler Benjamin Herrenschmidt
@ 2007-03-27  7:11                   ` Sylvain Munaut
  2007-03-28 10:29                     ` Johannes Berg
  0 siblings, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-03-27  7:11 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Linux PPC Dev ML, Paul Mackerras

Benjamin Herrenschmidt wrote:
> On Mon, 2007-02-12 at 23:13 +0100, Sylvain Munaut wrote:
>   
>> The generation of the uevent is now common to all bus using
>> of_device.
>>     
>
> I haven't managed to figure out why so far (a quick inspection of the
> code didn't show anything obvious) but with your patch, the snd-aoa
> driver fails to auto-load at boot... might be the modalias being broken,
> dunno.
>
>   

Hi Ben,

Thanks for testing. That issue looks weird.

I had a look at sound/aoa/soundbus/i2sbus/i2sbus-core.c , which is the
only part of aoa with of_device_id and I see that it uses the
MODULE_ALIAS directly :
MODULE_ALIAS("of:Ni2sTi2sC");
instead of using
MODULE_DEVICE_TABLE(of, i2sbus_match);
and letting modpost do the job. Because that module alias is not the one
that's gonna be generated by modpost.

But that doesn't explain why it worked before and not now ...


      Sylvain

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 08/10] macintosh: Use the new of_device common uevent handler
  2007-03-27  7:11                   ` Sylvain Munaut
@ 2007-03-28 10:29                     ` Johannes Berg
  2007-03-28 10:58                       ` Sylvain Munaut
  0 siblings, 1 reply; 28+ messages in thread
From: Johannes Berg @ 2007-03-28 10:29 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Paul Mackerras, Linux PPC Dev ML

[-- Attachment #1: Type: text/plain, Size: 557 bytes --]

On Tue, 2007-03-27 at 09:11 +0200, Sylvain Munaut wrote:

> I had a look at sound/aoa/soundbus/i2sbus/i2sbus-core.c , which is the
> only part of aoa with of_device_id and I see that it uses the
> MODULE_ALIAS directly :
> MODULE_ALIAS("of:Ni2sTi2sC");
> instead of using
> MODULE_DEVICE_TABLE(of, i2sbus_match);
> and letting modpost do the job. Because that module alias is not the one
> that's gonna be generated by modpost.

Can you elaborate on that for me? If that's the incorrect thing to do I
should probably change that :)

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 08/10] macintosh: Use the new of_device common uevent handler
  2007-03-28 10:29                     ` Johannes Berg
@ 2007-03-28 10:58                       ` Sylvain Munaut
  2007-03-28 11:10                         ` Johannes Berg
  0 siblings, 1 reply; 28+ messages in thread
From: Sylvain Munaut @ 2007-03-28 10:58 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Paul Mackerras, Linux PPC Dev ML

Johannes Berg wrote:
> On Tue, 2007-03-27 at 09:11 +0200, Sylvain Munaut wrote:
>
>> I had a look at sound/aoa/soundbus/i2sbus/i2sbus-core.c , which is the
>> only part of aoa with of_device_id and I see that it uses the
>> MODULE_ALIAS directly :
>> MODULE_ALIAS("of:Ni2sTi2sC");
>> instead of using
>> MODULE_DEVICE_TABLE(of, i2sbus_match);
>> and letting modpost do the job. Because that module alias is not the one
>> that's gonna be generated by modpost.
>
> Can you elaborate on that for me? If that's the incorrect thing to do I
> should probably change that :)
To avoid to the driver writer the burden of writing the module_alias
himself, there is
a mechanism to do it automatically.

You just add

MODULE_DEVICE_TABLE(of, i2sbus_match);

to your driver, with "of" being the bus type and i2sbus_match the match table used when registering the driver.

And during the modpost step of module compilation, the module_device_table will be use to magically generate the module_alias string. This also has the advantages that if the format of that string changes, you don't have to go change all the driver code but just the "of" bus handler in modpost.


	Sylvain

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 08/10] macintosh: Use the new of_device common uevent handler
  2007-03-28 10:58                       ` Sylvain Munaut
@ 2007-03-28 11:10                         ` Johannes Berg
  0 siblings, 0 replies; 28+ messages in thread
From: Johannes Berg @ 2007-03-28 11:10 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Paul Mackerras, Linux PPC Dev ML

[-- Attachment #1: Type: text/plain, Size: 285 bytes --]

On Wed, 2007-03-28 at 12:58 +0200, Sylvain Munaut wrote:

> MODULE_DEVICE_TABLE(of, i2sbus_match);

Ok. That results in the alias of:Ni2sT*C* instead of of:Ni2sTi2sC as I
had it, but I assume * has some match-semantics here.

I'll submit a patch to the alsa folks.

johannes

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 10/10] powerpc: Add uevent handler for ibmebus
  2007-02-12 22:13                   ` [PATCH 10/10] powerpc: Add uevent handler for ibmebus Sylvain Munaut
@ 2007-03-29 14:46                     ` Olaf Hering
  2007-03-30 11:27                       ` Hoang-Nam Nguyen
  0 siblings, 1 reply; 28+ messages in thread
From: Olaf Hering @ 2007-03-29 14:46 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: Linux PPC Dev ML, Paul Mackerras

On Mon, Feb 12, Sylvain Munaut wrote:

>  arch/powerpc/kernel/ibmebus.c |   16 ++++++++++++++++

> +	if (ebus_dev==ibmebus_bus_device)	/* filter dummy root device */

Does that compile for you?
ibmebus_bus_device should be &ibmebus_bus_device

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 10/10] powerpc: Add uevent handler for ibmebus
  2007-03-29 14:46                     ` Olaf Hering
@ 2007-03-30 11:27                       ` Hoang-Nam Nguyen
  2007-03-30 11:45                         ` Sylvain Munaut
  0 siblings, 1 reply; 28+ messages in thread
From: Hoang-Nam Nguyen @ 2007-03-30 11:27 UTC (permalink / raw)
  To: Olaf Hering
  Cc: Linux PPC Dev ML, Sylvain Munaut, Paul Mackerras,
	linuxppc-dev-bounces+hnguyen=de.ibm.com

linuxppc-dev-bounces+hnguyen=de.ibm.com@ozlabs.org wrote on 29.03.2007
16:46:23:

> On Mon, Feb 12, Sylvain Munaut wrote:
>
> >  arch/powerpc/kernel/ibmebus.c |   16 ++++++++++++++++
>
> > +   if (ebus_dev==ibmebus_bus_device)   /* filter dummy root device */
>
> Does that compile for you?
> ibmebus_bus_device should be &ibmebus_bus_device
Can you tell me from which code base you're seeing this?
Is above change from Sylvain? I looked at Joachim's recent patches and did
not find that code line.
Thanks
Nam

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH 10/10] powerpc: Add uevent handler for ibmebus
  2007-03-30 11:27                       ` Hoang-Nam Nguyen
@ 2007-03-30 11:45                         ` Sylvain Munaut
  0 siblings, 0 replies; 28+ messages in thread
From: Sylvain Munaut @ 2007-03-30 11:45 UTC (permalink / raw)
  To: Hoang-Nam Nguyen
  Cc: Linux PPC Dev ML, Olaf Hering, Paul Mackerras,
	linuxppc-dev-bounces+hnguyen=de.ibm.com

Hoang-Nam Nguyen wrote:
> linuxppc-dev-bounces+hnguyen=de.ibm.com@ozlabs.org wrote on 29.03.2007
> 16:46:23:
>
>   
>> On Mon, Feb 12, Sylvain Munaut wrote:
>>
>>     
>>>  arch/powerpc/kernel/ibmebus.c |   16 ++++++++++++++++
>>>       
>>> +   if (ebus_dev==ibmebus_bus_device)   /* filter dummy root device */
>>>       
>> Does that compile for you?
>> ibmebus_bus_device should be &ibmebus_bus_device
>>     
> Can you tell me from which code base you're seeing this?
> Is above change from Sylvain? I looked at Joachim's recent patches and did
> not find that code line.
> Thanks
> Nam
>   
Yes it's a line my pacthe adds.

But IIRC, Joachim's patch remove the dummy root device which means
that's use less.

In fact my whole [PATCH 10/10]  should not be used and Joachim's version
is the good one.


    Sylvain

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2007-03-30 11:45 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-12 22:13 [PATCH 00/10] Mainly 52xx patches for 2.6.21 (but not only) Sylvain Munaut
2007-02-12 22:13 ` [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c Sylvain Munaut
2007-02-12 22:13   ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Sylvain Munaut
2007-02-12 22:13     ` [PATCH 03/10] powerpc: Restore 'proper' link order in platform Sylvain Munaut
2007-02-12 22:13       ` [PATCH 04/10] powerpc: Use common 52xx of_platform probe code for EFIKA Sylvain Munaut
2007-02-12 22:13         ` [PATCH 05/10] powerpc: Fix unbalanced of_node_{get, put} in efika-setup.c Sylvain Munaut
2007-02-12 22:13           ` [PATCH 06/10] powerpc: Small cleanup of EFIKA platform Sylvain Munaut
2007-02-12 22:13             ` [PATCH 07/10] powerpc: Add a unified uevent handler for bus based on of_device Sylvain Munaut
2007-02-12 22:13               ` [PATCH 08/10] macintosh: Use the new of_device common uevent handler Sylvain Munaut
2007-02-12 22:13                 ` [PATCH 09/10] powerpc: Add uevent handler for of_platform_bus Sylvain Munaut
2007-02-12 22:13                   ` [PATCH 10/10] powerpc: Add uevent handler for ibmebus Sylvain Munaut
2007-03-29 14:46                     ` Olaf Hering
2007-03-30 11:27                       ` Hoang-Nam Nguyen
2007-03-30 11:45                         ` Sylvain Munaut
2007-03-27  6:30                 ` [PATCH 08/10] macintosh: Use the new of_device common uevent handler Benjamin Herrenschmidt
2007-03-27  7:11                   ` Sylvain Munaut
2007-03-28 10:29                     ` Johannes Berg
2007-03-28 10:58                       ` Sylvain Munaut
2007-03-28 11:10                         ` Johannes Berg
2007-02-12 23:06     ` [PATCH 02/10] powerpc: Add device tree fixups for the EFIKA Kumar Gala
2007-02-12 23:11       ` Sylvain Munaut
2007-02-12 23:18       ` Benjamin Herrenschmidt
2007-02-12 23:12     ` Benjamin Herrenschmidt
2007-02-12 23:25       ` Sylvain Munaut
2007-02-13  0:20         ` Benjamin Herrenschmidt
2007-02-16 16:44           ` Segher Boessenkool
2007-02-12 23:10   ` [PATCH 01/10] powerpc/serial: Dispose irq mapping when done in mpc52xx_serial.c Benjamin Herrenschmidt
2007-02-15 22:18 ` [PATCH] " Sylvain Munaut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.