[PATCH 4/5 v2] Add RapidIO support to powerpc architecture.

2007-06-27 Thread Zhang Wei
This patch adds the RapidIO support to the powerpc architecture.
Some files are moved from ppc. OF-tree and OF-device supports are added.
New silicons such as MPC8548, MPC8641 with serial RapidIO controller are
all supported.
Memory driver hardware operations are added.
Global mport variables are changed to master port private variables.
Multi master ports are supported.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/Kconfig  |8 +
 arch/powerpc/kernel/Makefile  |1 +
 arch/powerpc/kernel/rio.c |   64 ++
 arch/powerpc/sysdev/Makefile  |1 +
 arch/powerpc/sysdev/fsl_rio.c | 1455 +
 arch/powerpc/sysdev/fsl_rio.h |   20 +
 6 files changed, 1549 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/kernel/rio.c
 create mode 100644 arch/powerpc/sysdev/fsl_rio.c
 create mode 100644 arch/powerpc/sysdev/fsl_rio.h

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e683668..a41aaac 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -742,6 +742,14 @@ source "drivers/pci/Kconfig"
 
 source "drivers/pcmcia/Kconfig"
 
+config RAPIDIO
+   bool "RapidIO support" if MPC8540 || MPC8560 || MPC8641 || MPC8548
+   help
+ If you say Y here, the kernel will include drivers and
+ infrastructure code to support RapidIO interconnect devices.
+
+source "drivers/rapidio/Kconfig"
+
 source "drivers/pci/hotplug/Kconfig"
 
 endmenu
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 3e779f0..9ed2367 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -69,6 +69,7 @@ pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o
 pci32-$(CONFIG_PPC32)  := pci_32.o
 obj-$(CONFIG_PCI)  += $(pci64-y) $(pci32-y)
 obj-$(CONFIG_PCI_MSI)  += msi.o
+obj-$(CONFIG_RAPIDIO)  += rio.o
 kexec-$(CONFIG_PPC64)  := machine_kexec_64.o
 kexec-$(CONFIG_PPC32)  := machine_kexec_32.o
 obj-$(CONFIG_KEXEC)+= machine_kexec.o crash.o $(kexec-y)
diff --git a/arch/powerpc/kernel/rio.c b/arch/powerpc/kernel/rio.c
new file mode 100644
index 000..8d41e93
--- /dev/null
+++ b/arch/powerpc/kernel/rio.c
@@ -0,0 +1,64 @@
+/*
+ * RapidIO PowerPC support
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ * Zhang Wei <[EMAIL PROTECTED]>, Jun 2007
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ * New RapidIO peer-to-peer network initialize with of-device supoort.
+ *
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include <../sysdev/fsl_rio.h>
+
+
+/* The probe function for RapidIO peer-to-peer network.
+ */
+static int __devinit of_rio_rpn_probe(struct of_device *dev,
+const struct of_device_id *match)
+{
+   int rc;
+   printk(KERN_INFO "Setting up RapidIO peer-to-peer network %s\n",
+   dev->node->full_name);
+
+   rc = fsl_rio_setup(dev);
+   if (rc)
+   goto out;
+
+   /* Enumerate all registered ports */
+   rc = rio_init_mports();
+out:
+   return rc;
+};
+
+static struct of_device_id of_rio_rpn_ids[] = {
+   {
+   .compatible = "fsl,rapidio-delta",
+   },
+   {},
+};
+
+static struct of_platform_driver of_rio_rpn_driver = {
+   .name = "of-rio",
+   .match_table = of_rio_rpn_ids,
+   .probe = of_rio_rpn_probe,
+};
+
+static __init int of_rio_rpn_init(void)
+{
+   return of_register_platform_driver(_rio_rpn_driver);
+}
+
+subsys_initcall(of_rio_rpn_init);
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index c3ce0bd..5d6d66b 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_U3_DART) += dart_iommu.o
 obj-$(CONFIG_MMIO_NVRAM)   += mmio_nvram.o
 obj-$(CONFIG_FSL_SOC)  += fsl_soc.o
 obj-$(CONFIG_FSL_PCIE) += fsl_pcie.o
+obj-$(CONFIG_RAPIDIO)  += fsl_rio.o
 obj-$(CONFIG_TSI108_BRIDGE)+= tsi108_pci.o tsi108_dev.o
 obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
 mv64x60-$(CONFIG_PCI)  += mv64x60_pci.o
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
new file mode 100644
index 000..1608138
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -0,0 +1,1455 @@
+/*
+ * PowerPC RapidIO support
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ * Zhang Wei <[EMAIL PROTECTED]>, Jun 2007
+ *
+ * Copyright 2005 MontaVista Software, Inc.
+ * Matt Porter <[EMAIL PROTECTED]>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software 

[PATCH 4/5 v2] Add RapidIO support to powerpc architecture.

2007-06-27 Thread Zhang Wei
This patch adds the RapidIO support to the powerpc architecture.
Some files are moved from ppc. OF-tree and OF-device supports are added.
New silicons such as MPC8548, MPC8641 with serial RapidIO controller are
all supported.
Memory driver hardware operations are added.
Global mport variables are changed to master port private variables.
Multi master ports are supported.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/Kconfig  |8 +
 arch/powerpc/kernel/Makefile  |1 +
 arch/powerpc/kernel/rio.c |   64 ++
 arch/powerpc/sysdev/Makefile  |1 +
 arch/powerpc/sysdev/fsl_rio.c | 1455 +
 arch/powerpc/sysdev/fsl_rio.h |   20 +
 6 files changed, 1549 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/kernel/rio.c
 create mode 100644 arch/powerpc/sysdev/fsl_rio.c
 create mode 100644 arch/powerpc/sysdev/fsl_rio.h

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e683668..a41aaac 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -742,6 +742,14 @@ source drivers/pci/Kconfig
 
 source drivers/pcmcia/Kconfig
 
+config RAPIDIO
+   bool RapidIO support if MPC8540 || MPC8560 || MPC8641 || MPC8548
+   help
+ If you say Y here, the kernel will include drivers and
+ infrastructure code to support RapidIO interconnect devices.
+
+source drivers/rapidio/Kconfig
+
 source drivers/pci/hotplug/Kconfig
 
 endmenu
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 3e779f0..9ed2367 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -69,6 +69,7 @@ pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o
 pci32-$(CONFIG_PPC32)  := pci_32.o
 obj-$(CONFIG_PCI)  += $(pci64-y) $(pci32-y)
 obj-$(CONFIG_PCI_MSI)  += msi.o
+obj-$(CONFIG_RAPIDIO)  += rio.o
 kexec-$(CONFIG_PPC64)  := machine_kexec_64.o
 kexec-$(CONFIG_PPC32)  := machine_kexec_32.o
 obj-$(CONFIG_KEXEC)+= machine_kexec.o crash.o $(kexec-y)
diff --git a/arch/powerpc/kernel/rio.c b/arch/powerpc/kernel/rio.c
new file mode 100644
index 000..8d41e93
--- /dev/null
+++ b/arch/powerpc/kernel/rio.c
@@ -0,0 +1,64 @@
+/*
+ * RapidIO PowerPC support
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ * Zhang Wei [EMAIL PROTECTED], Jun 2007
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ * New RapidIO peer-to-peer network initialize with of-device supoort.
+ *
+ */
+
+#include linux/init.h
+#include linux/kernel.h
+#include linux/rio.h
+
+#include asm/rio.h
+#include asm/of_device.h
+#include asm/of_platform.h
+
+#include ../sysdev/fsl_rio.h
+
+
+/* The probe function for RapidIO peer-to-peer network.
+ */
+static int __devinit of_rio_rpn_probe(struct of_device *dev,
+const struct of_device_id *match)
+{
+   int rc;
+   printk(KERN_INFO Setting up RapidIO peer-to-peer network %s\n,
+   dev-node-full_name);
+
+   rc = fsl_rio_setup(dev);
+   if (rc)
+   goto out;
+
+   /* Enumerate all registered ports */
+   rc = rio_init_mports();
+out:
+   return rc;
+};
+
+static struct of_device_id of_rio_rpn_ids[] = {
+   {
+   .compatible = fsl,rapidio-delta,
+   },
+   {},
+};
+
+static struct of_platform_driver of_rio_rpn_driver = {
+   .name = of-rio,
+   .match_table = of_rio_rpn_ids,
+   .probe = of_rio_rpn_probe,
+};
+
+static __init int of_rio_rpn_init(void)
+{
+   return of_register_platform_driver(of_rio_rpn_driver);
+}
+
+subsys_initcall(of_rio_rpn_init);
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index c3ce0bd..5d6d66b 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_U3_DART) += dart_iommu.o
 obj-$(CONFIG_MMIO_NVRAM)   += mmio_nvram.o
 obj-$(CONFIG_FSL_SOC)  += fsl_soc.o
 obj-$(CONFIG_FSL_PCIE) += fsl_pcie.o
+obj-$(CONFIG_RAPIDIO)  += fsl_rio.o
 obj-$(CONFIG_TSI108_BRIDGE)+= tsi108_pci.o tsi108_dev.o
 obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
 mv64x60-$(CONFIG_PCI)  += mv64x60_pci.o
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
new file mode 100644
index 000..1608138
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -0,0 +1,1455 @@
+/*
+ * PowerPC RapidIO support
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ * Zhang Wei [EMAIL PROTECTED], Jun 2007
+ *
+ * Copyright 2005 MontaVista Software, Inc.
+ * Matt Porter [EMAIL PROTECTED]
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General