Skip to contentSkip to conversation

powerpc: publish 85xx soc dts entries as of_device on cds and ads platforms

PATCH Superseded Dave Jiang 1 participant 5 messages Jul 26, 2007 – Aug 2, 2007

Subsystems (4)
lore
Share & tools
lore

Dave Jiang

author
#0 lore raw

PATCH 1/2 powerpc: publish 85xx soc dts entries as of_device on cds and ads platforms

Publish the devices listed in dts under SOC as of_device just like what mpc85xx_mds platforms do. The 85xx cds and ads platforms currently do not export the devices in dts as of_device.

I need the memory controller, L2 cache-controller, and the PCI controller published as of_device so the mpc85xx EDAC driver can claim them for usage.

---
commit 8a80b43ddd3a4f7694df75869e13c3fc6e6c89f6
tree 772b956da2f4a1a55564519ececaf2e54be32248
parent 46b2835771ad8ef19b8e081e8c90439408c7645f
author Dave Jiang <[email protected]> Thu, 26 Jul 2007 10:59:00 -0700 committer Dave Jiang <djiang@blade.(none)> Thu, 26 Jul 2007 10:59:00 -0700

 arch/powerpc/platforms/85xx/mpc85xx_ads.c |   19 +++++++++++++++++++
 arch/powerpc/platforms/85xx/mpc85xx_cds.c |   19 +++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
arch/powerpc/platforms/85xx/mpc85xx_ads.c +19 -0
index 40a8286..599d7f7 100644
@@ -18,6 +18,8 @@
 #include <linux/delay.h>
 #include <linux/seq_file.h>
 
+#include <asm/of_device.h>
+#include <asm/of_platform.h>
 #include <asm/system.h>
 #include <asm/time.h>
 #include <asm/machdep.h>
@@ -254,6 +256,23 @@ static int __init mpc85xx_ads_probe(void)
         return of_flat_dt_is_compatible(root, "MPC85xxADS");
 }
 
+static struct of_device_id mpc85xx_ids[] = {
+	{ .type = "soc", },
+	{ .compatible = "soc", },
+	{},
+};
+
+static int __init mpc85xx_publish_devices(void)
+{
+	if (!machine_is(mpc85xx_ads))
+		return 0;
+
+	of_platform_bus_probe(NULL, mpc85xx_ids, NULL);
+
+	return 0;
+}
+device_initcall(mpc85xx_publish_devices);
+
 define_machine(mpc85xx_ads) {
 	.name			= "MPC85xx ADS",
 	.probe			= mpc85xx_ads_probe,
arch/powerpc/platforms/85xx/mpc85xx_cds.c +19 -0
index 6a171e9..5294884 100644
@@ -27,6 +27,8 @@
 #include <linux/interrupt.h>
 #include <linux/fsl_devices.h>
 
+#include <asm/of_device.h>
+#include <asm/of_platform.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
 #include <asm/page.h>
@@ -342,6 +344,23 @@ static int __init mpc85xx_cds_probe(void)
         return of_flat_dt_is_compatible(root, "MPC85xxCDS");
 }
 
+static struct of_device_id mpc85xx_ids[] = {
+	{ .type = "soc", },
+	{ .compatible = "soc", },
+	{},
+};
+
+static int __init mpc85xx_publish_devices(void)
+{
+	if (!machine_is(mpc85xx_cds))
+		return 0;
+
+	of_platform_bus_probe(NULL, mpc85xx_ids, NULL);
+
+	return 0;
+}
+device_initcall(mpc85xx_publish_devices);
+
 define_machine(mpc85xx_cds) {
 	.name		= "MPC85xx CDS",
 	.probe		= mpc85xx_cds_probe,
author
#1 lore raw

PATCH v2 1/3 powerpc: publish 85xx soc dts entries as of_device on cds and ads platforms

Publish the devices listed in dts under SOC as of_device just like what mpc85xx_mds platforms do. The 85xx cds and ads platforms currently do not export the devices in dts as of_device.

I need the memory controller, L2 cache-controller, and the PCI controller published as of_device so the mpc85xx EDAC driver can claim them for usage.

---

Same as the earlier posted patch. Reposting to keep patch numbers consistent since there are 3 patches in the series now.

 arch/powerpc/platforms/85xx/mpc85xx_ads.c |   19 +++++++++++++++++++
 arch/powerpc/platforms/85xx/mpc85xx_cds.c |   19 +++++++++++++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
arch/powerpc/platforms/85xx/mpc85xx_ads.c +19 -0
index 40a8286..599d7f7 100644
@@ -18,6 +18,8 @@
 #include <linux/delay.h>
 #include <linux/seq_file.h>
 
+#include <asm/of_device.h>
+#include <asm/of_platform.h>
 #include <asm/system.h>
 #include <asm/time.h>
 #include <asm/machdep.h>
@@ -254,6 +256,23 @@ static int __init mpc85xx_ads_probe(void)
         return of_flat_dt_is_compatible(root, "MPC85xxADS");
 }
 
+static struct of_device_id mpc85xx_ids[] = {
+	{ .type = "soc", },
+	{ .compatible = "soc", },
+	{},
+};
+
+static int __init mpc85xx_publish_devices(void)
+{
+	if (!machine_is(mpc85xx_ads))
+		return 0;
+
+	of_platform_bus_probe(NULL, mpc85xx_ids, NULL);
+
+	return 0;
+}
+device_initcall(mpc85xx_publish_devices);
+
 define_machine(mpc85xx_ads) {
 	.name			= "MPC85xx ADS",
 	.probe			= mpc85xx_ads_probe,
arch/powerpc/platforms/85xx/mpc85xx_cds.c +19 -0
index 6a171e9..5294884 100644
@@ -27,6 +27,8 @@
 #include <linux/interrupt.h>
 #include <linux/fsl_devices.h>
 
+#include <asm/of_device.h>
+#include <asm/of_platform.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
 #include <asm/page.h>
@@ -342,6 +344,23 @@ static int __init mpc85xx_cds_probe(void)
         return of_flat_dt_is_compatible(root, "MPC85xxCDS");
 }
 
+static struct of_device_id mpc85xx_ids[] = {
+	{ .type = "soc", },
+	{ .compatible = "soc", },
+	{},
+};
+
+static int __init mpc85xx_publish_devices(void)
+{
+	if (!machine_is(mpc85xx_cds))
+		return 0;
+
+	of_platform_bus_probe(NULL, mpc85xx_ids, NULL);
+
+	return 0;
+}
+device_initcall(mpc85xx_publish_devices);
+
 define_machine(mpc85xx_cds) {
 	.name		= "MPC85xx CDS",
 	.probe		= mpc85xx_cds_probe,
author
#2 lore raw

PATCH v2 2/3 powerpc: create pci err platform device for EDAC on mpc85xx

In reply to Dave Jiang

Creating a platform device for the PCI error registers in order for the mpc85xx EDAC driver to pick up proper resources. This is to prevent the EDAC driver from monopolizing the of_device and thus preventing future PCI code from using the PCI of_device(s).

---

 fsl_soc.c |   29 +++++++++++++++++++++++++++++
  1 file changed, 29 insertions(+)
arch/powerpc/sysdev/fsl_soc.c +29 -0
index 727453d..fff7c91 100644
@@ -1186,3 +1186,32 @@ err:
 arch_initcall(cpm_smc_uart_of_init);
 
 #endif /* CONFIG_8xx */
+
+#ifdef CONFIG_85xx
+
+/* setting up 85xx PCI error platform device for EDAC consumption */
+static int __init mpc85xx_pcierr_setup(void)
+{
+	struct device_node *np = NULL;
+	int id = 0;
+	struct resource res[2];
+
+	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci") {
+		memset(res, 0, sizeof(struct resource) * 2);
+		if (of_address_to_resource(np, 0, &res[0])) {
+			printk(KERN_WARNING "Can't get pci register base!\n");
+			continue;
+		}
+
+		/* move start to where the error registers are */
+		res[0].start += 0xe00;
+
+		of_irq_to_resource(np, 0, &res[1]);
+		platform_device_register_simple("mpc85xx_pci_err", id, res, 2);
+		id++;
+	}
+	return 0;
+}
+arch_initcall(mpc85xx_pcierr_setup);
+
+#endif
author
#4 lore raw

PATCH v2 3/3 powerpc: MPC85xx EDAC device driver

In reply to Dave Jiang

Freescale MPC85xx SoC support for EDAC. Used on PPC platforms. Development and testing done on PPC Freescale MPC8548CDS.

The driver provides error reporting for L2 cache error registers, the memory controller error registers, and the PCI error registers. The error reporting can be done two ways, via interrupts or polling.

---

Made PCI error devices as platform devices as per suggestion. Also fixed up init routine error handling so that some sort of warning is posted if failure to register one of the devices is detected.

 Kconfig        |    6
 Makefile       |    1
 mpc85xx_edac.c | 1043 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 mpc85xx_edac.h |  162 ++++++++
 4 files changed, 1212 insertions(+)
drivers/edac/Kconfig +6 -0
index 1724c41..cc50ab6 100644
@@ -131,5 +131,11 @@ config EDAC_PASEMI
 	  Support for error detection and correction on PA Semi
 	  PWRficient.
 
+config EDAC_MPC85XX
+	tristate "Freescale MPC85xx"
+	depends on EDAC_MM_EDAC && FSL_SOC && MPC85xx
+	help
+	  Support for error detection and correction on the Freescale
+	  MPC8560, MPC8540, MPC8548
 
 endif # EDAC
drivers/edac/Makefile +1 -0
index 02c09f0..62696aa 100644
@@ -28,4 +28,5 @@ obj-$(CONFIG_EDAC_I3000)		+= i3000_edac.o
 obj-$(CONFIG_EDAC_I82860)		+= i82860_edac.o
 obj-$(CONFIG_EDAC_R82600)		+= r82600_edac.o
 obj-$(CONFIG_EDAC_PASEMI)		+= pasemi_edac.o
+obj-$(CONFIG_EDAC_MPC85XX)		+= mpc85xx_edac.o
 
drivers/edac/mpc85xx_edac.c new file +1043 -0

1,043 lines not on this page · raw message

drivers/edac/mpc85xx_edac.h new file +162 -0

162 lines not on this page · raw message

author
#3 lore raw

PATCH v3 2/3 powerpc: create pci err platform device for EDAC on mpc85xx

In reply to Dave Jiang

Creating a platform device for the PCI error registers in order for the mpc85xx EDAC driver to pick up proper resources. This is to prevent the EDAC driver from monopolizing the of_device and thus preventing future PCI code from using the PCI of_device(s).

---
Code reworked to setup the platform device as a child of the PCI of_device. The routine has to be called after device_initcall() due to having to wait for the of_device to be setup first in order to pick up the parent.

 arch/powerpc/sysdev/fsl_pci.c |   52 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
arch/powerpc/sysdev/fsl_pci.c +52 -0
index 9fb0ce5..a769bbb 100644
@@ -19,6 +19,8 @@
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/bootmem.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
 
 #include <asm/io.h>
 #include <asm/prom.h>
@@ -27,6 +29,56 @@
 #include <sysdev/fsl_soc.h>
 #include <sysdev/fsl_pci.h>
 
+#ifdef CONFIG_85xx
+/* setting up 85xx PCI error platform device for EDAC consumption */
+static int __init mpc85xx_pcierr_setup(void)
+{
+	struct device_node *np = NULL;
+	struct of_device *of_dev;
+	struct platform_device *pdev;
+	struct resource res[2];
+	int id = 0;
+	int err;
+
+	for_each_compatible_node(np, "pci", "fsl,mpc8540-pci") {
+		memset(res, 0, sizeof(struct resource) * 2);
+		if (of_address_to_resource(np, 0, &res[0])) {
+			printk(KERN_WARNING "Can't get pci register base!\n");
+			continue;
+		}
+
+		/* move start to where the error registers are */
+		res[0].start += 0xe00;
+
+		of_irq_to_resource(np, 0, &res[1]);
+
+		of_dev = of_find_device_by_node(np);
+		if (!of_dev)
+			return -ENODEV;
+
+		pdev = platform_device_alloc("mpc85xx_pci_err", id++);
+		if (!pdev)
+			return -ENOMEM;
+
+		err = platform_device_add_resources(pdev, res, 2);
+		if (err)
+			goto error;
+
+		pdev->dev.parent = &of_dev->dev;
+
+		err = platform_device_add(pdev);
+		if (err)
+			goto error;
+	}
+	return 0;
+
+error:
+	platform_device_put(pdev);
+	return err;
+}
+late_initcall(mpc85xx_pcierr_setup);
+#endif
+
 /* atmu setup for fsl pci/pcie controller */
 void __init setup_pci_atmu(struct pci_controller *hose, struct resource *rsrc)
 {