[PATCH 2/3] (Resend part #1) Add the RapidIO support to powerpc architecture with memory mapping support.

2007-12-21 Thread Zhang Wei
The patch adds the RapidIO support to powerpc with of-device support.
New Serial RapidIO of new Freescale processor, such as MPC8548, MPC8568,
is also added.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/Kconfig|   12 +
 arch/powerpc/platforms/85xx/Kconfig |1 +
 arch/powerpc/platforms/86xx/Kconfig |1 +
 arch/powerpc/sysdev/Makefile|1 +
 arch/powerpc/sysdev/fsl_rio.c   | 1130 ++-
 5 files changed, 861 insertions(+), 284 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 18f397c..ee27b77 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -523,6 +523,18 @@ source "drivers/pci/Kconfig"
 
 source "drivers/pcmcia/Kconfig"
 
+config FSL_RAPIDIO
+   bool
+   default n
+
+config RAPIDIO
+   bool "RapidIO support" if FSL_RAPIDIO
+   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/platforms/85xx/Kconfig 
b/arch/powerpc/platforms/85xx/Kconfig
index 7748a3a..09c522d 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -56,6 +56,7 @@ config MPC85xx
select PPC_UDBG_16550
select PPC_INDIRECT_PCI if PCI
select MPIC
+   select FSL_RAPIDIO
select FSL_PCI if PCI
select SERIAL_8250_SHARE_IRQ if SERIAL_8250
default y if MPC8540_ADS || MPC85xx_CDS || MPC8560_ADS \
diff --git a/arch/powerpc/platforms/86xx/Kconfig 
b/arch/powerpc/platforms/86xx/Kconfig
index 21d1135..a6a6593 100644
--- a/arch/powerpc/platforms/86xx/Kconfig
+++ b/arch/powerpc/platforms/86xx/Kconfig
@@ -24,6 +24,7 @@ config MPC8641
select FSL_PCI if PCI
select PPC_UDBG_16550
select MPIC
+   select FSL_RAPIDIO
default y if MPC8641_HPCN
 
 config MPC8610
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 99a77d7..073d197 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -12,6 +12,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_PCI)  += fsl_pci.o
+obj-$(CONFIG_FSL_RAPIDIO)  += fsl_rio.o
 obj-$(CONFIG_TSI108_BRIDGE)+= tsi108_pci.o tsi108_dev.o
 obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
 obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index af2425e..525066c 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1,5 +1,8 @@
 /*
- * MPC85xx RapidIO support
+ * Freescale 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]>
@@ -8,6 +11,13 @@
  * 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.
+ *
+ * Changelog:
+ * Jun 2007 Zhang Wei <[EMAIL PROTECTED]>
+ * - This file is moved from arch/ppc/ppc85xx_rio.c. And the OF-tree support
+ *   is added. New silicons such as MPC8548, MPC8641 are all supported.
+ *   Memory driver hardware operations are added.
+ *
  */
 
 #include 
@@ -17,14 +27,41 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
+#include 
+#include "fsl_soc.h"
+
+/* RapidIO definition irq, which read from OF-tree */
+#define IRQ_RIO_BELL(m)(((struct rio_priv 
*)(m->priv))->bellirq)
+#define IRQ_RIO_TX(m)  (((struct rio_priv *)(m->priv))->txirq)
+#define IRQ_RIO_RX(m)  (((struct rio_priv *)(m->priv))->rxirq)
+
+#define ERR(fmt, arg...) \
+   printk(KERN_ERR "RIO %s: " fmt, __FUNCTION__, ## arg)
+#define INFO(fmt...) printk(KERN_INFO "RIO: " fmt)
+#define IS_64BIT_RES ((sizeof(resource_size_t) == 8) ? 1 : 0)
 
-#define RIO_REGS_BASE  (CCSRBAR + 0xc)
 #define RIO_ATMU_REGS_OFFSET   0x10c00
-#define RIO_MSG_REGS_OFFSET0x11000
+#define RIO_P_MSG_REGS_OFFSET  0x11000
+#define RIO_S_MSG_REGS_OFFSET  0x13000
+#define RIO_ESCSR  0x158
+#define RIO_CCSR   0x15c
+#define RIO_ISR_AACR   0x10120
+#define RIO_ISR_AACR_AA0x1 /* Accept All ID */
 #define RIO_MAINT_WIN_SIZE 0x40
 #define RIO_DBELL_WIN_SIZE 0x1000
+#define RIO_MAX_INB_ATMU   4
+#define RIO_MAX_OUTB_ATMU  8
+#define RIO_INB_ATMU_REGS_OFFSET   0x10de0
+#define RIO_ATMU_EN_MASK   0x8000
+
+#define RIO_NREAD  0x4
+#define RIO_NWRITE 0x4
+#define RIO_NWRITE_R   0x5
+#define RIO_NREAD_R0x5
 
 #define RIO_MSG_OMR_MUI0x0002
 #define RIO_MSG_OSR_TE  

Re: [PATCH 2/3] (Resend part #1) Add the RapidIO support to powerpc architecture with memory mapping support.

2007-12-22 Thread Stephen Rothwell
Hi,

This is a very large patch.  It may be easier to review if it could be
split on some logical way, that is at all possible (I don't know either
way).  This is just a quick note about some more trivial things.

On Fri, 21 Dec 2007 17:58:43 +0800 Zhang Wei <[EMAIL PROTECTED]> wrote:
>
> +struct rio_priv {
> + volatile void __iomem *regs_win;
> + volatile struct rio_atmu_regs __iomem *atmu_regs;
> + volatile struct rio_atmu_regs __iomem *maint_atmu_regs;
> + volatile struct rio_atmu_regs __iomem *dbell_atmu_regs;
> + volatile void __iomem *dbell_win;
> + volatile void __iomem *maint_win;
> + volatile struct rio_msg_regs __iomem *msg_regs;

Paulus has said that any pointer marked __iomem does not need to be
volatile ...

> +static int of_cells_get(struct device_node *np, const char *str)
> +{
> + struct device_node *tmp = NULL;
> + const int *var = NULL;

These initializations are unnecessary.

> + var = of_get_property(np, str, NULL);
> + tmp = of_get_parent(np);
> +
> + while (!var && tmp) {
> + var = (int *)of_get_property(tmp, str, NULL);

While I applaud the number of casts remove by this patch, this one is an
unnecessary addition.

> + of_node_put(tmp);
> + tmp = of_get_parent(np);

You should do the above two line in the opposite order. Also do you
really want to keep getting the parent of the same node over and over
(i.e. you never change np)?

> + }

You probably want a final of_node_put(tmp).


> + INFO("Phy type: ");
> + switch (phy_type) {
> + case RIO_PHY_SERIAL:
> + printk("serial\n");
> + break;
> + case RIO_PHY_PARALLEL:
> + printk("parallel");

Missing \n

> + port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
> + if (!port) {
> + ERR("Can't alloc memory for 'port'\n");
> + rc = -ENOMEM;
> + goto err;
> + }
>   port->id = 0;
>   port->index = 0;

These two could go as you just allocated zeroed memory.

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


pgpRi7Fgxso5X.pgp
Description: PGP signature