Re: [PATCH v5 0/5] mm/hugetlb: Early cow on fork, and a few cleanups

2021-03-01 Thread Zhang, Wei

Yes, such user includes libfabric (https://ofiwg.github.io/libfabric/) . which 
uses hugetlb pages.
 
On 3/1/21, 4:30 PM, "Jason Gunthorpe"  wrote:

CAUTION: This email originated from outside of the organization. Do not 
click links or open attachments unless you can confirm the sender and know the 
content is safe.



On Mon, Mar 01, 2021 at 04:28:46PM -0800, Andrew Morton wrote:
> On Mon, 1 Mar 2021 09:11:51 -0500 Peter Xu  wrote:
>
> > On Wed, Feb 17, 2021 at 06:35:42PM -0500, Peter Xu wrote:
> > > v5:
> > > - patch 4: change "int cow" into "bool cow"
> > > - collect r-bs for Jason
> >
> > Andrew,
> >
> > I just noticed 5.12-rc1 has released; is this series still possible to 
make it
> > for 5.12, or needs to wait for 5.13?
> >
>
> It has taken a while to settle down.  What is the case for
> fast-tracking it into 5.12?

IIRC hugetlb users and fork and DMA will get the unexpected VA
corruption that triggered all this work.

Jason



RE: dma engine drivers for 2.6.25?

2008-02-25 Thread Zhang Wei
Hi,

Sorry for missing lots of emails in my long vacation. :)

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Dan Williams
> Sent: Sunday, February 24, 2008 10:06 AM
> To: Kumar Gala
> Cc: LKML Kernel; Zhang Wei
> Subject: Re: dma engine drivers for 2.6.25?
> 
> On Thu, Feb 14, 2008 at 10:29 PM, Dan Williams 
> <[EMAIL PROTECTED]> wrote:
> > On Thu, Feb 14, 2008 at 8:44 PM, Kumar Gala 
> <[EMAIL PROTECTED]> wrote:
> >  >
> >  >  On Feb 14, 2008, at 12:14 PM, Dan Williams wrote:
> >  >
> >  >  > On Wed, Feb 13, 2008 at 8:52 PM, Kumar Gala
> >  >  > <[EMAIL PROTECTED]> wrote:
> >  >  >> Dan,
> >  >  >>
> >  >  >> What's going on with the dma engine drivers for 
> 2.6.25?  We had a
> >  >  >> Freescale dma driver from Zhang Wei queued up but 
> seems to have been
> >  >  >> lost.
> >  >  >
> >  >  > I pulled it into my tree and am holding it until Zhang has an
> >  >  > opportunity to address the pending review comments 
> [1].  I also did
> >  >  > not feel comfortable pushing it to Linus without a 
> PPC maintainer's
> >  >  > Acked-by/Reviewed-by.
> >  >  >
> >  >  > I have attached the version I am carrying.
> >  >
> >  >  What issues are still open.  I was under the belief 
> that Zhang had
> >  >  resolved all the issues.
> >  >
> >
> >  The high priority review item is that the driver performs operation
> >  completion callbacks in hardirq context.  Clients of the API assume
> >  that callbacks will happen in softirq context.  Of lesser 
> concern is
> >  the use of GFP_ATOMIC in fsl_dma_alloc_descriptor.  Other drivers
> >  preallocate a small pool of descriptors.
> >
> 
> Have not received a response, so let's try this the other way.  I took
> a closer look and found that my concern should be addressed by the
> following one-liner:
> 
> diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
> index 902e852..cc9a681 100644
> --- a/drivers/dma/fsldma.c
> +++ b/drivers/dma/fsldma.c
> @@ -685,7 +685,6 @@ static irqreturn_t fsl_dma_chan_do_interrupt(int
> irq, void *data)
> "nlndar 0x%016llx\n", 
> (u64)get_cdar(fsl_chan),
> (u64)get_ndar(fsl_chan));
> stat &= ~FSL_DMA_SR_EOSI;
> -   fsl_chan_ld_cleanup(fsl_chan);
> }
> 
> /* If it current transfer is the end-of-transfer,
> 
> With your ack I'll push the driver plus this fixlet for the 
> current kernel.

I agree with you to remove the fsl_chan_ld_cleanup() function calling in
Interrupt action, which is already called in tasklet. I forgot to remove it.
Thanks!

Cheers!
Wei.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: dma engine drivers for 2.6.25?

2008-02-25 Thread Zhang Wei
Hi,

Sorry for missing lots of emails in my long vacation. :)

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Dan Williams
 Sent: Sunday, February 24, 2008 10:06 AM
 To: Kumar Gala
 Cc: LKML Kernel; Zhang Wei
 Subject: Re: dma engine drivers for 2.6.25?
 
 On Thu, Feb 14, 2008 at 10:29 PM, Dan Williams 
 [EMAIL PROTECTED] wrote:
  On Thu, Feb 14, 2008 at 8:44 PM, Kumar Gala 
 [EMAIL PROTECTED] wrote:
   
 On Feb 14, 2008, at 12:14 PM, Dan Williams wrote:
   
  On Wed, Feb 13, 2008 at 8:52 PM, Kumar Gala
  [EMAIL PROTECTED] wrote:
  Dan,
 
  What's going on with the dma engine drivers for 
 2.6.25?  We had a
  Freescale dma driver from Zhang Wei queued up but 
 seems to have been
  lost.
 
  I pulled it into my tree and am holding it until Zhang has an
  opportunity to address the pending review comments 
 [1].  I also did
  not feel comfortable pushing it to Linus without a 
 PPC maintainer's
  Acked-by/Reviewed-by.
 
  I have attached the version I am carrying.
   
 What issues are still open.  I was under the belief 
 that Zhang had
 resolved all the issues.
   
 
   The high priority review item is that the driver performs operation
   completion callbacks in hardirq context.  Clients of the API assume
   that callbacks will happen in softirq context.  Of lesser 
 concern is
   the use of GFP_ATOMIC in fsl_dma_alloc_descriptor.  Other drivers
   preallocate a small pool of descriptors.
 
 
 Have not received a response, so let's try this the other way.  I took
 a closer look and found that my concern should be addressed by the
 following one-liner:
 
 diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
 index 902e852..cc9a681 100644
 --- a/drivers/dma/fsldma.c
 +++ b/drivers/dma/fsldma.c
 @@ -685,7 +685,6 @@ static irqreturn_t fsl_dma_chan_do_interrupt(int
 irq, void *data)
 nlndar 0x%016llx\n, 
 (u64)get_cdar(fsl_chan),
 (u64)get_ndar(fsl_chan));
 stat = ~FSL_DMA_SR_EOSI;
 -   fsl_chan_ld_cleanup(fsl_chan);
 }
 
 /* If it current transfer is the end-of-transfer,
 
 With your ack I'll push the driver plus this fixlet for the 
 current kernel.

I agree with you to remove the fsl_chan_ld_cleanup() function calling in
Interrupt action, which is already called in tasklet. I forgot to remove it.
Thanks!

Cheers!
Wei.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 4/6] Add multi mport support.

2008-02-17 Thread Zhang Wei
Hi, Matt,

So glad to see you again!

> -Original Message-
> From: Matt Porter [mailto:[EMAIL PROTECTED] 
> On Thu, Jan 31, 2008 at 02:30:13PM +0800, Zhang Wei wrote:
> > > -Original Message-
> > > From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> > > when we have multiple ports are the device IDs on the 
> ports intended  
> > > to be unique only to a port or unique across all ports?
> > > 
> > I consider each RIO controller will has its own network, 
> the device IDs
> > should be
> > unique only in its port network.
> 
> This is a bad assumption IMHO. It pushes policy on to the system
> designer of a RapidIO network.

I know it is a real bad assumption. However, the RIO initial ID is only
transported to
 driver by kernel parameter "riohdid", which can not distinguish the
multi
 rio controllers. It may be more better add a "rio-id" property in RIO
dts node, but
 the u-boot need some changes to support the rio-id assignment.

Cheers!
Wei.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 5/6] Add OF-tree support to RapidIO controller driver.

2008-02-17 Thread Zhang Wei
 

> -Original Message-
> From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> 
> 
> On Feb 4, 2008, at 11:44 PM, Stephen Rothwell wrote:
> 
> >>
> >> +  aw = *(u32 *)of_get_property(dev->node, "#address-cells", NULL);
> >> +  sw = *(u32 *)of_get_property(dev->node, "#size-cells", NULL);
> >
> > What happens if either of these properties is missing?
> 
> Should we add __must_check to of_get_property?
> 

You are right, I'll add the checking here.

Thanks!
Wei.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 5/6] Add OF-tree support to RapidIO controller driver.

2008-02-17 Thread Zhang Wei
 

 -Original Message-
 From: Kumar Gala [mailto:[EMAIL PROTECTED] 
 
 
 On Feb 4, 2008, at 11:44 PM, Stephen Rothwell wrote:
 
 
  +  aw = *(u32 *)of_get_property(dev-node, #address-cells, NULL);
  +  sw = *(u32 *)of_get_property(dev-node, #size-cells, NULL);
 
  What happens if either of these properties is missing?
 
 Should we add __must_check to of_get_property?
 

You are right, I'll add the checking here.

Thanks!
Wei.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 4/6] Add multi mport support.

2008-02-17 Thread Zhang Wei
Hi, Matt,

So glad to see you again!

 -Original Message-
 From: Matt Porter [mailto:[EMAIL PROTECTED] 
 On Thu, Jan 31, 2008 at 02:30:13PM +0800, Zhang Wei wrote:
   -Original Message-
   From: Kumar Gala [mailto:[EMAIL PROTECTED] 
   when we have multiple ports are the device IDs on the 
 ports intended  
   to be unique only to a port or unique across all ports?
   
  I consider each RIO controller will has its own network, 
 the device IDs
  should be
  unique only in its port network.
 
 This is a bad assumption IMHO. It pushes policy on to the system
 designer of a RapidIO network.

I know it is a real bad assumption. However, the RIO initial ID is only
transported to
 driver by kernel parameter riohdid, which can not distinguish the
multi
 rio controllers. It may be more better add a rio-id property in RIO
dts node, but
 the u-boot need some changes to support the rio-id assignment.

Cheers!
Wei.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 4/6] Add multi mport support.

2008-01-31 Thread Zhang Wei
Hi, Phil,

> -Original Message-
> From: Phil Terry [mailto:[EMAIL PROTECTED] 
> 
> On Thu, 2008-01-31 at 14:30 +0800, Zhang Wei wrote:
> >  
> > > >
> > I consider each RIO controller will has its own network, 
> the device IDs
> > should be
> > unique only in its port network.
> Hmmm, I see two cases:

Good questions! They are very important and also my concern now.

> 
> 1. I have two mport to two controllers each connected to different
> physical fabrics. This system can act as an application bridge between
> the two fabrics.
> 

The current driver just looks two mport as two independent fabrics.
We can add bridge driver to implement your idea.

> 2. I have two mports to two controllers each connected directly or
> indirectly to the same fabric. I want to use the extra bandwidth and
> load balance and/or have a fall back redundant connection via an
> alternate physical connection to the fabric etc.
> 

That's a terrible thing in the current driver. Two mports get the same
 ID in one fabric. About the port bound, it's a good idea, I also need
 a new driver to support it.

In fact, our first mission is to make the RapidIO driver ported from ppc
to powerpc can
 be compiled and run. Fortunately, there is no more than one port in
processor now,
 we have time to implement it.

> What should be the rules for allocating the initial IDs to the two
> mports to allow system wide enumeration to work in both of the above
> cases? 
> 

A choice is add ID option into dts node. I have some ideas about RapidIO
 driver in u-boot. U-boot can assign ID in dts and tell kernel.

> What do you expect the semantics of higher level addressing to be:
>  a pair , where  is a different device from ,
>  a pair , where  is the same device as ,or
>  a singleton n, where n is unique and identifies the first 
> routing step
> of which controller, x or y, to use.

It seems the address pair is a must-be selection as pci bus.
But now, no connection between ports. Every operations in only
 in its own port view.

> I smell a can of worms :-)

A good nose! Thanks! :)

Cheers!
Wei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 4/6] Add multi mport support.

2008-01-31 Thread Zhang Wei
Hi, Phil,

 -Original Message-
 From: Phil Terry [mailto:[EMAIL PROTECTED] 
 
 On Thu, 2008-01-31 at 14:30 +0800, Zhang Wei wrote:
   
   
  I consider each RIO controller will has its own network, 
 the device IDs
  should be
  unique only in its port network.
 Hmmm, I see two cases:

Good questions! They are very important and also my concern now.

 
 1. I have two mport to two controllers each connected to different
 physical fabrics. This system can act as an application bridge between
 the two fabrics.
 

The current driver just looks two mport as two independent fabrics.
We can add bridge driver to implement your idea.

 2. I have two mports to two controllers each connected directly or
 indirectly to the same fabric. I want to use the extra bandwidth and
 load balance and/or have a fall back redundant connection via an
 alternate physical connection to the fabric etc.
 

That's a terrible thing in the current driver. Two mports get the same
 ID in one fabric. About the port bound, it's a good idea, I also need
 a new driver to support it.

In fact, our first mission is to make the RapidIO driver ported from ppc
to powerpc can
 be compiled and run. Fortunately, there is no more than one port in
processor now,
 we have time to implement it.

 What should be the rules for allocating the initial IDs to the two
 mports to allow system wide enumeration to work in both of the above
 cases? 
 

A choice is add ID option into dts node. I have some ideas about RapidIO
 driver in u-boot. U-boot can assign ID in dts and tell kernel.

 What do you expect the semantics of higher level addressing to be:
  a pair mport,id, where x,n is a different device from y,n,
  a pair mport,id, where x,n is the same device as y,n,or
  a singleton n, where n is unique and identifies the first 
 routing step
 of which controller, x or y, to use.

It seems the address pair is a must-be selection as pci bus.
But now, no connection between ports. Every operations in only
 in its own port view.

 I smell a can of worms :-)

A good nose! Thanks! :)

Cheers!
Wei
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 4/6] Add multi mport support.

2008-01-30 Thread Zhang Wei
 

> -Original Message-
> From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> 
> On Jan 31, 2008, at 12:15 AM, Kumar Gala wrote:
> 
> >
> > On Jan 30, 2008, at 11:57 PM, Zhang Wei wrote:
> >
> >>
> >>
> >>> -Original Message-
> >>> From: Kumar Gala [mailto:[EMAIL PROTECTED]
> >>>
> >>> On Jan 30, 2008, at 4:30 AM, Zhang Wei wrote:
> >>>
> >>>> Change lots of static variable to mport private. And add
> >>> mport to some
> >>>> function declaration.
> >>>
> >>> Can you explain this patch further.  Its not clear 
> exactly from this
> >>> commit message why we are doing this.
> >>>
> >>> - k
> >>
> >> Sorry about I have a little hurry about it.
> >>
> >> The original RapidIO driver suppose there is only one mpc85xx RIO
> >> controller
> >> in system. So, some data structures are defined as mpc85xx_rio  
> >> global,
> >> such as 'regs_win', 'dbell_ring', 'msg_tx_ring'. Now, I 
> changed them
> >> to
> >> mport's private members. And you can define multi RIO 
> OF-nodes in dts
> >> file
> >> for multi RapidIO controller in one processor, such as PCI/PCI-Ex  
> >> host
> >> controllers
> >> in Freescale's silicon. And the mport operation function 
> declaration
> >> should be changed
> >> to know which RapidIO controller is target.
> >
> > thanks, this makes a lot of sense and now reviewing the patch will
> > make some sense to me :)
> 
> when we have multiple ports are the device IDs on the ports intended  
> to be unique only to a port or unique across all ports?
> 
I consider each RIO controller will has its own network, the device IDs
should be
unique only in its port network.

Cheers!
Wei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/6] Change RIO function mpc85xx_ to fsl_ .

2008-01-30 Thread Zhang Wei
All right, I'll give you another patch for 86xx dts file. :)

 Btw: Why the PCI and other nodes were moved from SOC? Just for clear?
If they are moved out, their register address must use full address not
offset address.

Thanks!
Wei.

> -Original Message-
> From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, January 30, 2008 10:44 PM
> To: Zhang Wei
> Cc: [EMAIL PROTECTED]; 
> linux-kernel@vger.kernel.org; [EMAIL PROTECTED]
> Subject: Re: [PATCH 1/6] Change RIO function mpc85xx_ to fsl_ .
> 
> Can you post a device tree update as well.
> 
> The older patches on the list for the 86xx .dts should NOT 
> put the rio  
> node under the soc.  It should be at the same level as PCI.
> 
> - k
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 4/6] Add multi mport support.

2008-01-30 Thread Zhang Wei
 

> -Original Message-
> From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> 
> On Jan 30, 2008, at 4:30 AM, Zhang Wei wrote:
> 
> > Change lots of static variable to mport private. And add 
> mport to some
> > function declaration.
> 
> Can you explain this patch further.  Its not clear exactly from this  
> commit message why we are doing this.
> 
> - k

Sorry about I have a little hurry about it.

The original RapidIO driver suppose there is only one mpc85xx RIO
controller
in system. So, some data structures are defined as mpc85xx_rio global,
such as 'regs_win', 'dbell_ring', 'msg_tx_ring'. Now, I changed them to
mport's private members. And you can define multi RIO OF-nodes in dts
file
for multi RapidIO controller in one processor, such as PCI/PCI-Ex host
controllers
in Freescale's silicon. And the mport operation function declaration
should be changed
to know which RapidIO controller is target.

Thanks!
Wei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 3/6] Move include/asm-ppc/rio.h to include/asm-powerpc/rio.h

2008-01-30 Thread Zhang Wei
 

> -Original Message-
> From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> On Jan 30, 2008, at 4:30 AM, Zhang Wei wrote:
> 
> > Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
> > ---
> > include/asm-powerpc/rio.h |   18 ++
> > include/asm-ppc/rio.h |   18 --
> > 2 files changed, 18 insertions(+), 18 deletions(-)
> > create mode 100644 include/asm-powerpc/rio.h
> > delete mode 100644 include/asm-ppc/rio.h
> 
> it seems with OF we can just git rid of this?
> 

Aha, yep :), The change just make the RIO driver in arch/powerpc can be
compiled with RapidIO OF patch.

If we have OF patch, you can drop this patch.

Thanks!
Wei.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] Move include/asm-ppc/rio.h to include/asm-powerpc/rio.h

2008-01-30 Thread Zhang Wei
Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 include/asm-powerpc/rio.h |   18 ++
 include/asm-ppc/rio.h |   18 --
 2 files changed, 18 insertions(+), 18 deletions(-)
 create mode 100644 include/asm-powerpc/rio.h
 delete mode 100644 include/asm-ppc/rio.h

diff --git a/include/asm-powerpc/rio.h b/include/asm-powerpc/rio.h
new file mode 100644
index 000..0018bf8
--- /dev/null
+++ b/include/asm-powerpc/rio.h
@@ -0,0 +1,18 @@
+/*
+ * RapidIO architecture support
+ *
+ * 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 Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#ifndef ASM_PPC_RIO_H
+#define ASM_PPC_RIO_H
+
+extern void platform_rio_init(void);
+
+#endif /* ASM_PPC_RIO_H */
diff --git a/include/asm-ppc/rio.h b/include/asm-ppc/rio.h
deleted file mode 100644
index 0018bf8..000
--- a/include/asm-ppc/rio.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * RapidIO architecture support
- *
- * 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 Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#ifndef ASM_PPC_RIO_H
-#define ASM_PPC_RIO_H
-
-extern void platform_rio_init(void);
-
-#endif /* ASM_PPC_RIO_H */
-- 
1.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] Add OF-tree support to RapidIO controller driver.

2008-01-30 Thread Zhang Wei
Now, RapidIO driver for powerpc architecture is also support OF-device.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/Makefile  |1 -
 arch/powerpc/kernel/rio.c |   52 -
 arch/powerpc/sysdev/fsl_rio.c |  101 +---
 arch/powerpc/sysdev/fsl_rio.h |   20 
 4 files changed, 93 insertions(+), 81 deletions(-)
 delete mode 100644 arch/powerpc/kernel/rio.c
 delete mode 100644 arch/powerpc/sysdev/fsl_rio.h

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 58dbfef..d9b3770 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -70,7 +70,6 @@ pci64-$(CONFIG_PPC64) += pci_dn.o isa-bridge.o
 obj-$(CONFIG_PCI)  += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \
   pci-common.o
 obj-$(CONFIG_PCI_MSI)  += msi.o
-obj-$(CONFIG_RAPIDIO)  += rio.o
 obj-$(CONFIG_KEXEC)+= machine_kexec.o crash.o \
   machine_kexec_$(CONFIG_WORD_SIZE).o
 obj-$(CONFIG_AUDIT)+= audit.o
diff --git a/arch/powerpc/kernel/rio.c b/arch/powerpc/kernel/rio.c
deleted file mode 100644
index 29487fe..000
--- a/arch/powerpc/kernel/rio.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * RapidIO PPC32 support
- *
- * 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 Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include 
-#include 
-#include 
-
-#include 
-
-/**
- * platform_rio_init - Do platform specific RIO init
- *
- * Any platform specific initialization of RapdIO
- * hardware is done here as well as registration
- * of any active master ports in the system.
- */
-void __attribute__ ((weak))
-platform_rio_init(void)
-{
-   printk(KERN_WARNING "RIO: No platform_rio_init() present\n");
-}
-
-/**
- * ppc_rio_init - Do PPC32 RIO init
- *
- * Calls platform-specific RIO init code and then calls
- * rio_init_mports() to initialize any master ports that
- * have been registered with the RIO subsystem.
- */
-static int __init ppc_rio_init(void)
-{
-   printk(KERN_INFO "RIO: RapidIO init\n");
-
-   /* Platform specific initialization */
-   platform_rio_init();
-
-   /* Enumerate all registered ports */
-   rio_init_mports();
-
-   return 0;
-}
-
-subsys_initcall(ppc_rio_init);
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 3907a2c..36b43ec 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -28,7 +29,6 @@
 #define IRQ_RIO_TX(m)  (((struct rio_priv *)(m->priv))->txirq)
 #define IRQ_RIO_RX(m)  (((struct rio_priv *)(m->priv))->rxirq)
 
-#define RIO_REGS_BASE  (CCSRBAR + 0xc)
 #define RIO_ATMU_REGS_OFFSET   0x10c00
 #define RIO_MSG_REGS_OFFSET0x11000
 #define RIO_MAINT_WIN_SIZE 0x40
@@ -908,19 +908,57 @@ __setup("riohdid=", fsl_rio_get_cmdline);
 
 /**
  * fsl_rio_setup - Setup MPC85xx RapidIO interface
- * @law_start: Starting physical address of RapidIO LAW
- * @law_size: Size of RapidIO LAW
+ * @fsl_rio_setup - Setup Freescale PowerPC RapidIO interface
  *
  * Initializes MPC85xx RapidIO hardware interface, configures
  * master port with system-specific info, and registers the
  * master port with the RapidIO subsystem.
  */
-void fsl_rio_setup(int law_start, int law_size)
+int fsl_rio_setup(struct of_device *dev)
 {
struct rio_ops *ops;
struct rio_mport *port;
-   struct rio_priv *priv = NULL;
-   int rc;
+   struct rio_priv *priv;
+   int rc = 0;
+   const u32 *dt_range;
+   struct resource regs;
+   int rlen;
+   u64 law_start, law_size;
+   int paw, aw, sw;
+
+   if (!dev->node) {
+   dev_err(>dev, "Device OF-Node is NULL");
+   return -EFAULT;
+   }
+
+   rc = of_address_to_resource(dev->node, 0, );
+   if (rc) {
+   dev_err(>dev, "Can't get %s property 'reg'\n",
+   dev->node->full_name);
+   return -EFAULT;
+   }
+   dev_info(>dev, "Of-device full name %s\n", dev->node->full_name);
+   dev_info(>dev, "Regs start 0x%08x size 0x%08x\n",  regs.start,
+   regs.end - regs.start + 1);
+
+   dt_range = of_get_property(dev->node, "ranges", );
+   if (!dt_range) {
+   dev_err(>dev, "Can't get %s property 'ranges'\n",
+   dev->node->full_name);
+  

[PATCH 4/6] Add multi mport support.

2008-01-30 Thread Zhang Wei
Change lots of static variable to mport private. And add mport to some
function declaration.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/fsl_rio.c |  353 +++--
 drivers/rapidio/rio-access.c  |   10 +-
 include/linux/rio.h   |   18 ++-
 3 files changed, 218 insertions(+), 163 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 36c4be4..3907a2c 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1,6 +1,9 @@
 /*
  * Freescale MPC85xx/MPC86xx RapidIO support
  *
+ * Copyright (C) 2007, 2008 Freescale Semiconductor, Inc.
+ * Zhang Wei <[EMAIL PROTECTED]>
+ *
  * Copyright 2005 MontaVista Software, Inc.
  * Matt Porter <[EMAIL PROTECTED]>
  *
@@ -20,6 +23,11 @@
 
 #include 
 
+/* 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 RIO_REGS_BASE  (CCSRBAR + 0xc)
 #define RIO_ATMU_REGS_OFFSET   0x10c00
 #define RIO_MSG_REGS_OFFSET0x11000
@@ -112,20 +120,12 @@ struct rio_tx_desc {
u32 res4;
 };
 
-static u32 regs_win;
-static struct rio_atmu_regs *atmu_regs;
-static struct rio_atmu_regs *maint_atmu_regs;
-static struct rio_atmu_regs *dbell_atmu_regs;
-static u32 dbell_win;
-static u32 maint_win;
-static struct rio_msg_regs *msg_regs;
-
-static struct rio_dbell_ring {
+struct rio_dbell_ring {
void *virt;
dma_addr_t phys;
-} dbell_ring;
+};
 
-static struct rio_msg_tx_ring {
+struct rio_msg_tx_ring {
void *virt;
dma_addr_t phys;
void *virt_buffer[RIO_MAX_TX_RING_SIZE];
@@ -133,16 +133,32 @@ static struct rio_msg_tx_ring {
int tx_slot;
int size;
void *dev_id;
-} msg_tx_ring;
+};
 
-static struct rio_msg_rx_ring {
+struct rio_msg_rx_ring {
void *virt;
dma_addr_t phys;
void *virt_buffer[RIO_MAX_RX_RING_SIZE];
int rx_slot;
int size;
void *dev_id;
-} msg_rx_ring;
+};
+
+struct rio_priv {
+   void __iomem *regs_win;
+   struct rio_atmu_regs __iomem *atmu_regs;
+   struct rio_atmu_regs __iomem *maint_atmu_regs;
+   struct rio_atmu_regs __iomem *dbell_atmu_regs;
+   void __iomem *dbell_win;
+   void __iomem *maint_win;
+   struct rio_msg_regs __iomem *msg_regs;
+   struct rio_dbell_ring dbell_ring;
+   struct rio_msg_tx_ring msg_tx_ring;
+   struct rio_msg_rx_ring msg_rx_ring;
+   int bellirq;
+   int txirq;
+   int rxirq;
+};
 
 /**
  * fsl_rio_doorbell_send - Send a MPC85xx doorbell message
@@ -153,12 +169,14 @@ static struct rio_msg_rx_ring {
  * Sends a MPC85xx doorbell message. Returns %0 on success or
  * %-EINVAL on failure.
  */
-static int fsl_rio_doorbell_send(int index, u16 destid, u16 data)
+static int fsl_rio_doorbell_send(struct rio_mport *mport,
+   int index, u16 destid, u16 data)
 {
+   struct rio_priv *priv = mport->priv;
pr_debug("fsl_doorbell_send: index %d destid %4.4x data %4.4x\n",
 index, destid, data);
-   out_be32((void *)_atmu_regs->rowtar, destid << 22);
-   out_be16((void *)(dbell_win), data);
+   out_be32(>dbell_atmu_regs->rowtar, destid << 22);
+   out_be16(priv->dbell_win, data);
 
return 0;
 }
@@ -173,11 +191,13 @@ static int fsl_rio_doorbell_send(int index, u16 destid, 
u16 data)
  * Generates a MPC85xx local configuration space read. Returns %0 on
  * success or %-EINVAL on failure.
  */
-static int fsl_local_config_read(int index, u32 offset, int len, u32 * data)
+static int fsl_local_config_read(struct rio_mport *mport,
+   int index, u32 offset, int len, u32 * data)
 {
+   struct rio_priv *priv = mport->priv;
pr_debug("fsl_local_config_read: index %d offset %8.8x\n", index,
 offset);
-   *data = in_be32((void *)(regs_win + offset));
+   *data = in_be32(priv->regs_win + offset);
 
return 0;
 }
@@ -192,12 +212,14 @@ static int fsl_local_config_read(int index, u32 offset, 
int len, u32 * data)
  * Generates a MPC85xx local configuration space write. Returns %0 on
  * success or %-EINVAL on failure.
  */
-static int fsl_local_config_write(int index, u32 offset, int len, u32 data)
+static int fsl_local_config_write(struct rio_mport *mport,
+   int index, u32 offset, int len, u32 data)
 {
+   struct rio_priv *priv = mport->priv;
pr_debug
("fsl_local_config_write: index %d offset %8.8x data %8.8x\n",
 index, offset, data);
-   out_be32((void *)(regs_win + offset), data);
+   out_be32(priv->regs_win + offset, da

[PATCH 6/6] Change the kernel configurated RapidIO system size to auto-probing.

2008-01-30 Thread Zhang Wei
The RapidIO system size will auto probe in RIO setup. The route
table and rionet_active in rionet.c are changed to be allocated
dynamically according the system size.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/fsl_rio.c |6 +
 drivers/net/rionet.c  |   16 +++-
 drivers/rapidio/Kconfig   |8 --
 drivers/rapidio/rio-scan.c|   51 +
 drivers/rapidio/rio-sysfs.c   |3 +-
 drivers/rapidio/rio.c |2 +-
 drivers/rapidio/rio.h |9 +-
 include/linux/rio.h   |   14 +-
 8 files changed, 68 insertions(+), 41 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 36b43ec..4877203 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1001,6 +1001,12 @@ int fsl_rio_setup(struct of_device *dev)
rio_register_mport(port);
 
priv->regs_win = (u32) ioremap(regs.start, regs.end - regs.start + 1);
+
+   port->sys_size = (in_be32((priv->regs_win + RIO_PEF_CAR))
+   & RIO_PEF_CTLS) >> 4;
+   dev_info(>dev, "RapidIO Common Transport System size: %d\n",
+   port->sys_size ? 65536 : 256);
+
priv->atmu_regs = (struct rio_atmu_regs *)(priv->regs_win
+ RIO_ATMU_REGS_OFFSET);
priv->maint_atmu_regs = priv->atmu_regs + 1;
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index e7fd08a..f2c103b 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -77,7 +77,7 @@ static int rionet_capable = 1;
  * could be made into a hash table to save memory depending
  * on system trade-offs.
  */
-static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES];
+static struct rio_dev **rionet_active;
 
 #define is_rionet_capable(pef, src_ops, dst_ops)   \
((pef & RIO_PEF_INB_MBOX) &&\
@@ -195,7 +195,8 @@ static int rionet_start_xmit(struct sk_buff *skb, struct 
net_device *ndev)
}
 
if (eth->h_dest[0] & 0x01) {
-   for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++)
+   for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->syssize);
+   i++)
if (rionet_active[i])
rionet_queue_tx_msg(skb, ndev,
rionet_active[i]);
@@ -385,6 +386,8 @@ static void rionet_remove(struct rio_dev *rdev)
struct net_device *ndev = NULL;
struct rionet_peer *peer, *tmp;
 
+   free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ?
+   __ilog2(sizeof(void *)) + 4 : 0);
unregister_netdev(ndev);
kfree(ndev);
 
@@ -443,6 +446,15 @@ static int rionet_setup_netdev(struct rio_mport *mport)
goto out;
}
 
+   if (!(rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
+   mport->sys_size ? __ilog2(sizeof(void *)) + 4
+   : 0))) {
+   rc = -ENOMEM;
+   goto out;
+   }
+   memset((void *)rionet_active, 0, sizeof(void *) *
+   RIO_MAX_ROUTE_ENTRIES(mport->sys_size));
+
/* Set up private area */
rnet = (struct rionet_private *)ndev->priv;
rnet->mport = mport;
diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
index 4142115..c32822a 100644
--- a/drivers/rapidio/Kconfig
+++ b/drivers/rapidio/Kconfig
@@ -1,14 +1,6 @@
 #
 # RapidIO configuration
 #
-config RAPIDIO_8_BIT_TRANSPORT
-   bool "8-bit transport addressing"
-   depends on RAPIDIO
-   ---help---
- By default, the kernel assumes a 16-bit addressed RapidIO
- network. By selecting this option, the kernel will support
- an 8-bit addressed network.
-
 config RAPIDIO_DISC_TIMEOUT
int "Discovery timeout duration (seconds)"
depends on RAPIDIO
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 4442072..ca895d1 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -73,7 +73,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 
destid, u8 hopcount)
 
rio_mport_read_config_32(port, destid, hopcount, RIO_DID_CSR, );
 
-   return RIO_GET_DID(result);
+   return RIO_GET_DID(port->sys_size, result);
 }
 
 /**
@@ -88,7 +88,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 
destid, u8 hopcount)
 static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, 
u16 did)
 {
rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR,
- RIO_SET_DID(did));
+ RIO_SET_DID(por

[PATCH 2/6] Add RapidIO option to kernel configuration.

2008-01-30 Thread Zhang Wei
Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/Kconfig|   13 +
 arch/powerpc/platforms/86xx/Kconfig |1 +
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 47fe256..ad07964 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -535,6 +535,19 @@ source "drivers/pcmcia/Kconfig"
 
 source "drivers/pci/hotplug/Kconfig"
 
+config HAS_RAPIDIO
+   bool
+   default n
+
+config RAPIDIO
+   bool "RapidIO support"
+   depends on HAS_RAPIDIO
+   help
+ If you say Y here, the kernel will include drivers and
+ infrastructure code to support RapidIO interconnect devices.
+
+source "drivers/rapidio/Kconfig"
+
 endmenu
 
 menu "Advanced setup"
diff --git a/arch/powerpc/platforms/86xx/Kconfig 
b/arch/powerpc/platforms/86xx/Kconfig
index 21d1135..8c7c5ff 100644
--- a/arch/powerpc/platforms/86xx/Kconfig
+++ b/arch/powerpc/platforms/86xx/Kconfig
@@ -8,6 +8,7 @@ config MPC8641_HPCN
select PPC_I8259
select DEFAULT_UIMAGE
select FSL_ULI1575
+   select HAS_RAPIDIO
help
  This option enables support for the MPC8641 HPCN board.
 
-- 
1.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] Change RIO function mpc85xx_ to fsl_ .

2008-01-30 Thread Zhang Wei
The driver is also fit for Freescale MPC8641 processor.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/fsl_rio.c |   80 
 1 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index af2425e..36c4be4 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1,5 +1,5 @@
 /*
- * MPC85xx RapidIO support
+ * Freescale MPC85xx/MPC86xx RapidIO support
  *
  * Copyright 2005 MontaVista Software, Inc.
  * Matt Porter <[EMAIL PROTECTED]>
@@ -145,7 +145,7 @@ static struct rio_msg_rx_ring {
 } msg_rx_ring;
 
 /**
- * mpc85xx_rio_doorbell_send - Send a MPC85xx doorbell message
+ * fsl_rio_doorbell_send - Send a MPC85xx doorbell message
  * @index: ID of RapidIO interface
  * @destid: Destination ID of target device
  * @data: 16-bit info field of RapidIO doorbell message
@@ -153,9 +153,9 @@ static struct rio_msg_rx_ring {
  * Sends a MPC85xx doorbell message. Returns %0 on success or
  * %-EINVAL on failure.
  */
-static int mpc85xx_rio_doorbell_send(int index, u16 destid, u16 data)
+static int fsl_rio_doorbell_send(int index, u16 destid, u16 data)
 {
-   pr_debug("mpc85xx_doorbell_send: index %d destid %4.4x data %4.4x\n",
+   pr_debug("fsl_doorbell_send: index %d destid %4.4x data %4.4x\n",
 index, destid, data);
out_be32((void *)_atmu_regs->rowtar, destid << 22);
out_be16((void *)(dbell_win), data);
@@ -164,7 +164,7 @@ static int mpc85xx_rio_doorbell_send(int index, u16 destid, 
u16 data)
 }
 
 /**
- * mpc85xx_local_config_read - Generate a MPC85xx local config space read
+ * fsl_local_config_read - Generate a MPC85xx local config space read
  * @index: ID of RapdiIO interface
  * @offset: Offset into configuration space
  * @len: Length (in bytes) of the maintenance transaction
@@ -173,9 +173,9 @@ static int mpc85xx_rio_doorbell_send(int index, u16 destid, 
u16 data)
  * Generates a MPC85xx local configuration space read. Returns %0 on
  * success or %-EINVAL on failure.
  */
-static int mpc85xx_local_config_read(int index, u32 offset, int len, u32 * 
data)
+static int fsl_local_config_read(int index, u32 offset, int len, u32 * data)
 {
-   pr_debug("mpc85xx_local_config_read: index %d offset %8.8x\n", index,
+   pr_debug("fsl_local_config_read: index %d offset %8.8x\n", index,
 offset);
*data = in_be32((void *)(regs_win + offset));
 
@@ -183,7 +183,7 @@ static int mpc85xx_local_config_read(int index, u32 offset, 
int len, u32 * data)
 }
 
 /**
- * mpc85xx_local_config_write - Generate a MPC85xx local config space write
+ * fsl_local_config_write - Generate a MPC85xx local config space write
  * @index: ID of RapdiIO interface
  * @offset: Offset into configuration space
  * @len: Length (in bytes) of the maintenance transaction
@@ -192,10 +192,10 @@ static int mpc85xx_local_config_read(int index, u32 
offset, int len, u32 * data)
  * Generates a MPC85xx local configuration space write. Returns %0 on
  * success or %-EINVAL on failure.
  */
-static int mpc85xx_local_config_write(int index, u32 offset, int len, u32 data)
+static int fsl_local_config_write(int index, u32 offset, int len, u32 data)
 {
pr_debug
-   ("mpc85xx_local_config_write: index %d offset %8.8x data %8.8x\n",
+   ("fsl_local_config_write: index %d offset %8.8x data %8.8x\n",
 index, offset, data);
out_be32((void *)(regs_win + offset), data);
 
@@ -203,7 +203,7 @@ static int mpc85xx_local_config_write(int index, u32 
offset, int len, u32 data)
 }
 
 /**
- * mpc85xx_rio_config_read - Generate a MPC85xx read maintenance transaction
+ * fsl_rio_config_read - Generate a MPC85xx read maintenance transaction
  * @index: ID of RapdiIO interface
  * @destid: Destination ID of transaction
  * @hopcount: Number of hops to target device
@@ -215,13 +215,13 @@ static int mpc85xx_local_config_write(int index, u32 
offset, int len, u32 data)
  * success or %-EINVAL on failure.
  */
 static int
-mpc85xx_rio_config_read(int index, u16 destid, u8 hopcount, u32 offset, int 
len,
+fsl_rio_config_read(int index, u16 destid, u8 hopcount, u32 offset, int len,
u32 * val)
 {
u8 *data;
 
pr_debug
-   ("mpc85xx_rio_config_read: index %d destid %d hopcount %d offset 
%8.8x len %d\n",
+   ("fsl_rio_config_read: index %d destid %d hopcount %d offset %8.8x 
len %d\n",
 index, destid, hopcount, offset, len);
out_be32((void *)_atmu_regs->rowtar,
 (destid << 22) | (hopcount << 12) | ((offset & ~0x3) >> 9));
@@ -243,7 +243,7 @@ mpc85xx_rio_config_read(int index, u16 destid, u8 hopcount, 
u32 offset, int len,
 }
 
 /**
- * mpc85xx_rio_config_write - Generate a MPC85xx write maintenance transacti

[PATCH 4/6] Add multi mport support.

2008-01-30 Thread Zhang Wei
Change lots of static variable to mport private. And add mport to some
function declaration.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/sysdev/fsl_rio.c |  353 +++--
 drivers/rapidio/rio-access.c  |   10 +-
 include/linux/rio.h   |   18 ++-
 3 files changed, 218 insertions(+), 163 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 36c4be4..3907a2c 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1,6 +1,9 @@
 /*
  * Freescale MPC85xx/MPC86xx RapidIO support
  *
+ * Copyright (C) 2007, 2008 Freescale Semiconductor, Inc.
+ * Zhang Wei [EMAIL PROTECTED]
+ *
  * Copyright 2005 MontaVista Software, Inc.
  * Matt Porter [EMAIL PROTECTED]
  *
@@ -20,6 +23,11 @@
 
 #include asm/io.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 RIO_REGS_BASE  (CCSRBAR + 0xc)
 #define RIO_ATMU_REGS_OFFSET   0x10c00
 #define RIO_MSG_REGS_OFFSET0x11000
@@ -112,20 +120,12 @@ struct rio_tx_desc {
u32 res4;
 };
 
-static u32 regs_win;
-static struct rio_atmu_regs *atmu_regs;
-static struct rio_atmu_regs *maint_atmu_regs;
-static struct rio_atmu_regs *dbell_atmu_regs;
-static u32 dbell_win;
-static u32 maint_win;
-static struct rio_msg_regs *msg_regs;
-
-static struct rio_dbell_ring {
+struct rio_dbell_ring {
void *virt;
dma_addr_t phys;
-} dbell_ring;
+};
 
-static struct rio_msg_tx_ring {
+struct rio_msg_tx_ring {
void *virt;
dma_addr_t phys;
void *virt_buffer[RIO_MAX_TX_RING_SIZE];
@@ -133,16 +133,32 @@ static struct rio_msg_tx_ring {
int tx_slot;
int size;
void *dev_id;
-} msg_tx_ring;
+};
 
-static struct rio_msg_rx_ring {
+struct rio_msg_rx_ring {
void *virt;
dma_addr_t phys;
void *virt_buffer[RIO_MAX_RX_RING_SIZE];
int rx_slot;
int size;
void *dev_id;
-} msg_rx_ring;
+};
+
+struct rio_priv {
+   void __iomem *regs_win;
+   struct rio_atmu_regs __iomem *atmu_regs;
+   struct rio_atmu_regs __iomem *maint_atmu_regs;
+   struct rio_atmu_regs __iomem *dbell_atmu_regs;
+   void __iomem *dbell_win;
+   void __iomem *maint_win;
+   struct rio_msg_regs __iomem *msg_regs;
+   struct rio_dbell_ring dbell_ring;
+   struct rio_msg_tx_ring msg_tx_ring;
+   struct rio_msg_rx_ring msg_rx_ring;
+   int bellirq;
+   int txirq;
+   int rxirq;
+};
 
 /**
  * fsl_rio_doorbell_send - Send a MPC85xx doorbell message
@@ -153,12 +169,14 @@ static struct rio_msg_rx_ring {
  * Sends a MPC85xx doorbell message. Returns %0 on success or
  * %-EINVAL on failure.
  */
-static int fsl_rio_doorbell_send(int index, u16 destid, u16 data)
+static int fsl_rio_doorbell_send(struct rio_mport *mport,
+   int index, u16 destid, u16 data)
 {
+   struct rio_priv *priv = mport-priv;
pr_debug(fsl_doorbell_send: index %d destid %4.4x data %4.4x\n,
 index, destid, data);
-   out_be32((void *)dbell_atmu_regs-rowtar, destid  22);
-   out_be16((void *)(dbell_win), data);
+   out_be32(priv-dbell_atmu_regs-rowtar, destid  22);
+   out_be16(priv-dbell_win, data);
 
return 0;
 }
@@ -173,11 +191,13 @@ static int fsl_rio_doorbell_send(int index, u16 destid, 
u16 data)
  * Generates a MPC85xx local configuration space read. Returns %0 on
  * success or %-EINVAL on failure.
  */
-static int fsl_local_config_read(int index, u32 offset, int len, u32 * data)
+static int fsl_local_config_read(struct rio_mport *mport,
+   int index, u32 offset, int len, u32 * data)
 {
+   struct rio_priv *priv = mport-priv;
pr_debug(fsl_local_config_read: index %d offset %8.8x\n, index,
 offset);
-   *data = in_be32((void *)(regs_win + offset));
+   *data = in_be32(priv-regs_win + offset);
 
return 0;
 }
@@ -192,12 +212,14 @@ static int fsl_local_config_read(int index, u32 offset, 
int len, u32 * data)
  * Generates a MPC85xx local configuration space write. Returns %0 on
  * success or %-EINVAL on failure.
  */
-static int fsl_local_config_write(int index, u32 offset, int len, u32 data)
+static int fsl_local_config_write(struct rio_mport *mport,
+   int index, u32 offset, int len, u32 data)
 {
+   struct rio_priv *priv = mport-priv;
pr_debug
(fsl_local_config_write: index %d offset %8.8x data %8.8x\n,
 index, offset, data);
-   out_be32((void *)(regs_win + offset), data);
+   out_be32(priv-regs_win + offset, data);
 
return 0;
 }
@@ -215,18 +237,19 @@ static int fsl_local_config_write(int index, u32 offset, 
int len

[PATCH 6/6] Change the kernel configurated RapidIO system size to auto-probing.

2008-01-30 Thread Zhang Wei
The RapidIO system size will auto probe in RIO setup. The route
table and rionet_active in rionet.c are changed to be allocated
dynamically according the system size.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/sysdev/fsl_rio.c |6 +
 drivers/net/rionet.c  |   16 +++-
 drivers/rapidio/Kconfig   |8 --
 drivers/rapidio/rio-scan.c|   51 +
 drivers/rapidio/rio-sysfs.c   |3 +-
 drivers/rapidio/rio.c |2 +-
 drivers/rapidio/rio.h |9 +-
 include/linux/rio.h   |   14 +-
 8 files changed, 68 insertions(+), 41 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 36b43ec..4877203 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1001,6 +1001,12 @@ int fsl_rio_setup(struct of_device *dev)
rio_register_mport(port);
 
priv-regs_win = (u32) ioremap(regs.start, regs.end - regs.start + 1);
+
+   port-sys_size = (in_be32((priv-regs_win + RIO_PEF_CAR))
+RIO_PEF_CTLS)  4;
+   dev_info(dev-dev, RapidIO Common Transport System size: %d\n,
+   port-sys_size ? 65536 : 256);
+
priv-atmu_regs = (struct rio_atmu_regs *)(priv-regs_win
+ RIO_ATMU_REGS_OFFSET);
priv-maint_atmu_regs = priv-atmu_regs + 1;
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index e7fd08a..f2c103b 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -77,7 +77,7 @@ static int rionet_capable = 1;
  * could be made into a hash table to save memory depending
  * on system trade-offs.
  */
-static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES];
+static struct rio_dev **rionet_active;
 
 #define is_rionet_capable(pef, src_ops, dst_ops)   \
((pef  RIO_PEF_INB_MBOX) \
@@ -195,7 +195,8 @@ static int rionet_start_xmit(struct sk_buff *skb, struct 
net_device *ndev)
}
 
if (eth-h_dest[0]  0x01) {
-   for (i = 0; i  RIO_MAX_ROUTE_ENTRIES; i++)
+   for (i = 0; i  RIO_MAX_ROUTE_ENTRIES(rnet-mport-syssize);
+   i++)
if (rionet_active[i])
rionet_queue_tx_msg(skb, ndev,
rionet_active[i]);
@@ -385,6 +386,8 @@ static void rionet_remove(struct rio_dev *rdev)
struct net_device *ndev = NULL;
struct rionet_peer *peer, *tmp;
 
+   free_pages((unsigned long)rionet_active, rdev-net-hport-sys_size ?
+   __ilog2(sizeof(void *)) + 4 : 0);
unregister_netdev(ndev);
kfree(ndev);
 
@@ -443,6 +446,15 @@ static int rionet_setup_netdev(struct rio_mport *mport)
goto out;
}
 
+   if (!(rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
+   mport-sys_size ? __ilog2(sizeof(void *)) + 4
+   : 0))) {
+   rc = -ENOMEM;
+   goto out;
+   }
+   memset((void *)rionet_active, 0, sizeof(void *) *
+   RIO_MAX_ROUTE_ENTRIES(mport-sys_size));
+
/* Set up private area */
rnet = (struct rionet_private *)ndev-priv;
rnet-mport = mport;
diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
index 4142115..c32822a 100644
--- a/drivers/rapidio/Kconfig
+++ b/drivers/rapidio/Kconfig
@@ -1,14 +1,6 @@
 #
 # RapidIO configuration
 #
-config RAPIDIO_8_BIT_TRANSPORT
-   bool 8-bit transport addressing
-   depends on RAPIDIO
-   ---help---
- By default, the kernel assumes a 16-bit addressed RapidIO
- network. By selecting this option, the kernel will support
- an 8-bit addressed network.
-
 config RAPIDIO_DISC_TIMEOUT
int Discovery timeout duration (seconds)
depends on RAPIDIO
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index 4442072..ca895d1 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -73,7 +73,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 
destid, u8 hopcount)
 
rio_mport_read_config_32(port, destid, hopcount, RIO_DID_CSR, result);
 
-   return RIO_GET_DID(result);
+   return RIO_GET_DID(port-sys_size, result);
 }
 
 /**
@@ -88,7 +88,7 @@ static u16 rio_get_device_id(struct rio_mport *port, u16 
destid, u8 hopcount)
 static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, 
u16 did)
 {
rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR,
- RIO_SET_DID(did));
+ RIO_SET_DID(port-sys_size, did));
 }
 
 /**
@@ -100,7 +100,8 @@ static void rio_set_device_id(struct rio_mport *port, u16 
destid, u8 hopcount, u
  */
 static void

[PATCH 1/6] Change RIO function mpc85xx_ to fsl_ .

2008-01-30 Thread Zhang Wei
The driver is also fit for Freescale MPC8641 processor.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/sysdev/fsl_rio.c |   80 
 1 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index af2425e..36c4be4 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -1,5 +1,5 @@
 /*
- * MPC85xx RapidIO support
+ * Freescale MPC85xx/MPC86xx RapidIO support
  *
  * Copyright 2005 MontaVista Software, Inc.
  * Matt Porter [EMAIL PROTECTED]
@@ -145,7 +145,7 @@ static struct rio_msg_rx_ring {
 } msg_rx_ring;
 
 /**
- * mpc85xx_rio_doorbell_send - Send a MPC85xx doorbell message
+ * fsl_rio_doorbell_send - Send a MPC85xx doorbell message
  * @index: ID of RapidIO interface
  * @destid: Destination ID of target device
  * @data: 16-bit info field of RapidIO doorbell message
@@ -153,9 +153,9 @@ static struct rio_msg_rx_ring {
  * Sends a MPC85xx doorbell message. Returns %0 on success or
  * %-EINVAL on failure.
  */
-static int mpc85xx_rio_doorbell_send(int index, u16 destid, u16 data)
+static int fsl_rio_doorbell_send(int index, u16 destid, u16 data)
 {
-   pr_debug(mpc85xx_doorbell_send: index %d destid %4.4x data %4.4x\n,
+   pr_debug(fsl_doorbell_send: index %d destid %4.4x data %4.4x\n,
 index, destid, data);
out_be32((void *)dbell_atmu_regs-rowtar, destid  22);
out_be16((void *)(dbell_win), data);
@@ -164,7 +164,7 @@ static int mpc85xx_rio_doorbell_send(int index, u16 destid, 
u16 data)
 }
 
 /**
- * mpc85xx_local_config_read - Generate a MPC85xx local config space read
+ * fsl_local_config_read - Generate a MPC85xx local config space read
  * @index: ID of RapdiIO interface
  * @offset: Offset into configuration space
  * @len: Length (in bytes) of the maintenance transaction
@@ -173,9 +173,9 @@ static int mpc85xx_rio_doorbell_send(int index, u16 destid, 
u16 data)
  * Generates a MPC85xx local configuration space read. Returns %0 on
  * success or %-EINVAL on failure.
  */
-static int mpc85xx_local_config_read(int index, u32 offset, int len, u32 * 
data)
+static int fsl_local_config_read(int index, u32 offset, int len, u32 * data)
 {
-   pr_debug(mpc85xx_local_config_read: index %d offset %8.8x\n, index,
+   pr_debug(fsl_local_config_read: index %d offset %8.8x\n, index,
 offset);
*data = in_be32((void *)(regs_win + offset));
 
@@ -183,7 +183,7 @@ static int mpc85xx_local_config_read(int index, u32 offset, 
int len, u32 * data)
 }
 
 /**
- * mpc85xx_local_config_write - Generate a MPC85xx local config space write
+ * fsl_local_config_write - Generate a MPC85xx local config space write
  * @index: ID of RapdiIO interface
  * @offset: Offset into configuration space
  * @len: Length (in bytes) of the maintenance transaction
@@ -192,10 +192,10 @@ static int mpc85xx_local_config_read(int index, u32 
offset, int len, u32 * data)
  * Generates a MPC85xx local configuration space write. Returns %0 on
  * success or %-EINVAL on failure.
  */
-static int mpc85xx_local_config_write(int index, u32 offset, int len, u32 data)
+static int fsl_local_config_write(int index, u32 offset, int len, u32 data)
 {
pr_debug
-   (mpc85xx_local_config_write: index %d offset %8.8x data %8.8x\n,
+   (fsl_local_config_write: index %d offset %8.8x data %8.8x\n,
 index, offset, data);
out_be32((void *)(regs_win + offset), data);
 
@@ -203,7 +203,7 @@ static int mpc85xx_local_config_write(int index, u32 
offset, int len, u32 data)
 }
 
 /**
- * mpc85xx_rio_config_read - Generate a MPC85xx read maintenance transaction
+ * fsl_rio_config_read - Generate a MPC85xx read maintenance transaction
  * @index: ID of RapdiIO interface
  * @destid: Destination ID of transaction
  * @hopcount: Number of hops to target device
@@ -215,13 +215,13 @@ static int mpc85xx_local_config_write(int index, u32 
offset, int len, u32 data)
  * success or %-EINVAL on failure.
  */
 static int
-mpc85xx_rio_config_read(int index, u16 destid, u8 hopcount, u32 offset, int 
len,
+fsl_rio_config_read(int index, u16 destid, u8 hopcount, u32 offset, int len,
u32 * val)
 {
u8 *data;
 
pr_debug
-   (mpc85xx_rio_config_read: index %d destid %d hopcount %d offset 
%8.8x len %d\n,
+   (fsl_rio_config_read: index %d destid %d hopcount %d offset %8.8x 
len %d\n,
 index, destid, hopcount, offset, len);
out_be32((void *)maint_atmu_regs-rowtar,
 (destid  22) | (hopcount  12) | ((offset  ~0x3)  9));
@@ -243,7 +243,7 @@ mpc85xx_rio_config_read(int index, u16 destid, u8 hopcount, 
u32 offset, int len,
 }
 
 /**
- * mpc85xx_rio_config_write - Generate a MPC85xx write maintenance transaction
+ * fsl_rio_config_write - Generate a MPC85xx write maintenance transaction
  * @index: ID of RapdiIO interface
  * @destid: Destination ID

[PATCH 2/6] Add RapidIO option to kernel configuration.

2008-01-30 Thread Zhang Wei
Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/Kconfig|   13 +
 arch/powerpc/platforms/86xx/Kconfig |1 +
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 47fe256..ad07964 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -535,6 +535,19 @@ source drivers/pcmcia/Kconfig
 
 source drivers/pci/hotplug/Kconfig
 
+config HAS_RAPIDIO
+   bool
+   default n
+
+config RAPIDIO
+   bool RapidIO support
+   depends on HAS_RAPIDIO
+   help
+ If you say Y here, the kernel will include drivers and
+ infrastructure code to support RapidIO interconnect devices.
+
+source drivers/rapidio/Kconfig
+
 endmenu
 
 menu Advanced setup
diff --git a/arch/powerpc/platforms/86xx/Kconfig 
b/arch/powerpc/platforms/86xx/Kconfig
index 21d1135..8c7c5ff 100644
--- a/arch/powerpc/platforms/86xx/Kconfig
+++ b/arch/powerpc/platforms/86xx/Kconfig
@@ -8,6 +8,7 @@ config MPC8641_HPCN
select PPC_I8259
select DEFAULT_UIMAGE
select FSL_ULI1575
+   select HAS_RAPIDIO
help
  This option enables support for the MPC8641 HPCN board.
 
-- 
1.5.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] Move include/asm-ppc/rio.h to include/asm-powerpc/rio.h

2008-01-30 Thread Zhang Wei
Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 include/asm-powerpc/rio.h |   18 ++
 include/asm-ppc/rio.h |   18 --
 2 files changed, 18 insertions(+), 18 deletions(-)
 create mode 100644 include/asm-powerpc/rio.h
 delete mode 100644 include/asm-ppc/rio.h

diff --git a/include/asm-powerpc/rio.h b/include/asm-powerpc/rio.h
new file mode 100644
index 000..0018bf8
--- /dev/null
+++ b/include/asm-powerpc/rio.h
@@ -0,0 +1,18 @@
+/*
+ * RapidIO architecture support
+ *
+ * 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 Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#ifndef ASM_PPC_RIO_H
+#define ASM_PPC_RIO_H
+
+extern void platform_rio_init(void);
+
+#endif /* ASM_PPC_RIO_H */
diff --git a/include/asm-ppc/rio.h b/include/asm-ppc/rio.h
deleted file mode 100644
index 0018bf8..000
--- a/include/asm-ppc/rio.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * RapidIO architecture support
- *
- * 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 Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#ifndef ASM_PPC_RIO_H
-#define ASM_PPC_RIO_H
-
-extern void platform_rio_init(void);
-
-#endif /* ASM_PPC_RIO_H */
-- 
1.5.2

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] Add OF-tree support to RapidIO controller driver.

2008-01-30 Thread Zhang Wei
Now, RapidIO driver for powerpc architecture is also support OF-device.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/kernel/Makefile  |1 -
 arch/powerpc/kernel/rio.c |   52 -
 arch/powerpc/sysdev/fsl_rio.c |  101 +---
 arch/powerpc/sysdev/fsl_rio.h |   20 
 4 files changed, 93 insertions(+), 81 deletions(-)
 delete mode 100644 arch/powerpc/kernel/rio.c
 delete mode 100644 arch/powerpc/sysdev/fsl_rio.h

diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 58dbfef..d9b3770 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -70,7 +70,6 @@ pci64-$(CONFIG_PPC64) += pci_dn.o isa-bridge.o
 obj-$(CONFIG_PCI)  += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \
   pci-common.o
 obj-$(CONFIG_PCI_MSI)  += msi.o
-obj-$(CONFIG_RAPIDIO)  += rio.o
 obj-$(CONFIG_KEXEC)+= machine_kexec.o crash.o \
   machine_kexec_$(CONFIG_WORD_SIZE).o
 obj-$(CONFIG_AUDIT)+= audit.o
diff --git a/arch/powerpc/kernel/rio.c b/arch/powerpc/kernel/rio.c
deleted file mode 100644
index 29487fe..000
--- a/arch/powerpc/kernel/rio.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * RapidIO PPC32 support
- *
- * 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 Foundation;  either version 2 of the  License, or (at your
- * option) any later version.
- */
-
-#include linux/init.h
-#include linux/kernel.h
-#include linux/rio.h
-
-#include asm/rio.h
-
-/**
- * platform_rio_init - Do platform specific RIO init
- *
- * Any platform specific initialization of RapdIO
- * hardware is done here as well as registration
- * of any active master ports in the system.
- */
-void __attribute__ ((weak))
-platform_rio_init(void)
-{
-   printk(KERN_WARNING RIO: No platform_rio_init() present\n);
-}
-
-/**
- * ppc_rio_init - Do PPC32 RIO init
- *
- * Calls platform-specific RIO init code and then calls
- * rio_init_mports() to initialize any master ports that
- * have been registered with the RIO subsystem.
- */
-static int __init ppc_rio_init(void)
-{
-   printk(KERN_INFO RIO: RapidIO init\n);
-
-   /* Platform specific initialization */
-   platform_rio_init();
-
-   /* Enumerate all registered ports */
-   rio_init_mports();
-
-   return 0;
-}
-
-subsys_initcall(ppc_rio_init);
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 3907a2c..36b43ec 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -20,6 +20,7 @@
 #include linux/interrupt.h
 #include linux/rio.h
 #include linux/rio_drv.h
+#include linux/of_platform.h
 
 #include asm/io.h
 
@@ -28,7 +29,6 @@
 #define IRQ_RIO_TX(m)  (((struct rio_priv *)(m-priv))-txirq)
 #define IRQ_RIO_RX(m)  (((struct rio_priv *)(m-priv))-rxirq)
 
-#define RIO_REGS_BASE  (CCSRBAR + 0xc)
 #define RIO_ATMU_REGS_OFFSET   0x10c00
 #define RIO_MSG_REGS_OFFSET0x11000
 #define RIO_MAINT_WIN_SIZE 0x40
@@ -908,19 +908,57 @@ __setup(riohdid=, fsl_rio_get_cmdline);
 
 /**
  * fsl_rio_setup - Setup MPC85xx RapidIO interface
- * @law_start: Starting physical address of RapidIO LAW
- * @law_size: Size of RapidIO LAW
+ * @fsl_rio_setup - Setup Freescale PowerPC RapidIO interface
  *
  * Initializes MPC85xx RapidIO hardware interface, configures
  * master port with system-specific info, and registers the
  * master port with the RapidIO subsystem.
  */
-void fsl_rio_setup(int law_start, int law_size)
+int fsl_rio_setup(struct of_device *dev)
 {
struct rio_ops *ops;
struct rio_mport *port;
-   struct rio_priv *priv = NULL;
-   int rc;
+   struct rio_priv *priv;
+   int rc = 0;
+   const u32 *dt_range;
+   struct resource regs;
+   int rlen;
+   u64 law_start, law_size;
+   int paw, aw, sw;
+
+   if (!dev-node) {
+   dev_err(dev-dev, Device OF-Node is NULL);
+   return -EFAULT;
+   }
+
+   rc = of_address_to_resource(dev-node, 0, regs);
+   if (rc) {
+   dev_err(dev-dev, Can't get %s property 'reg'\n,
+   dev-node-full_name);
+   return -EFAULT;
+   }
+   dev_info(dev-dev, Of-device full name %s\n, dev-node-full_name);
+   dev_info(dev-dev, Regs start 0x%08x size 0x%08x\n,  regs.start,
+   regs.end - regs.start + 1);
+
+   dt_range = of_get_property(dev-node, ranges, rlen);
+   if (!dt_range) {
+   dev_err(dev-dev, Can't get %s property 'ranges'\n,
+   dev-node-full_name);
+   return -EFAULT;
+   }
+
+   /* Get node

RE: [PATCH 3/6] Move include/asm-ppc/rio.h to include/asm-powerpc/rio.h

2008-01-30 Thread Zhang Wei
 

 -Original Message-
 From: Kumar Gala [mailto:[EMAIL PROTECTED] 
 On Jan 30, 2008, at 4:30 AM, Zhang Wei wrote:
 
  Signed-off-by: Zhang Wei [EMAIL PROTECTED]
  ---
  include/asm-powerpc/rio.h |   18 ++
  include/asm-ppc/rio.h |   18 --
  2 files changed, 18 insertions(+), 18 deletions(-)
  create mode 100644 include/asm-powerpc/rio.h
  delete mode 100644 include/asm-ppc/rio.h
 
 it seems with OF we can just git rid of this?
 

Aha, yep :), The change just make the RIO driver in arch/powerpc can be
compiled with RapidIO OF patch.

If we have OF patch, you can drop this patch.

Thanks!
Wei.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 4/6] Add multi mport support.

2008-01-30 Thread Zhang Wei
 

 -Original Message-
 From: Kumar Gala [mailto:[EMAIL PROTECTED] 
 
 On Jan 30, 2008, at 4:30 AM, Zhang Wei wrote:
 
  Change lots of static variable to mport private. And add 
 mport to some
  function declaration.
 
 Can you explain this patch further.  Its not clear exactly from this  
 commit message why we are doing this.
 
 - k

Sorry about I have a little hurry about it.

The original RapidIO driver suppose there is only one mpc85xx RIO
controller
in system. So, some data structures are defined as mpc85xx_rio global,
such as 'regs_win', 'dbell_ring', 'msg_tx_ring'. Now, I changed them to
mport's private members. And you can define multi RIO OF-nodes in dts
file
for multi RapidIO controller in one processor, such as PCI/PCI-Ex host
controllers
in Freescale's silicon. And the mport operation function declaration
should be changed
to know which RapidIO controller is target.

Thanks!
Wei

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/6] Change RIO function mpc85xx_ to fsl_ .

2008-01-30 Thread Zhang Wei
All right, I'll give you another patch for 86xx dts file. :)

 Btw: Why the PCI and other nodes were moved from SOC? Just for clear?
If they are moved out, their register address must use full address not
offset address.

Thanks!
Wei.

 -Original Message-
 From: Kumar Gala [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, January 30, 2008 10:44 PM
 To: Zhang Wei
 Cc: [EMAIL PROTECTED]; 
 linux-kernel@vger.kernel.org; [EMAIL PROTECTED]
 Subject: Re: [PATCH 1/6] Change RIO function mpc85xx_ to fsl_ .
 
 Can you post a device tree update as well.
 
 The older patches on the list for the 86xx .dts should NOT 
 put the rio  
 node under the soc.  It should be at the same level as PCI.
 
 - k
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v2] Add DMA engine driver for Freescale MPC85xx processors.

2008-01-22 Thread Zhang Wei
Hi, Dan, 

> -Original Message-
> From: [EMAIL PROTECTED] 
>
> I do not think all the review comments have been addressed, for
> example my earlier comments about GFP_ATOMIC and spin_lock_irqsave
> [1].  We have two options to take this forward:
> 

Thanks! Some comments need more study, I'll discuss them with you later.

> 1/ Continue to carry this in the async-tx tree and get an
> Acked-by/Reviewed-by tag from Kumar.
> 2/ Move this to Kumar's tree, and coordinate our pull requests to have
> the async-tx updates hit first.
> 
> I prefer option 1, but I will defer to Kumar.
> 

I also prefer option 1. How about now?

Cheers!
Wei.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v2] Add DMA engine driver for Freescale MPC85xx processors.

2008-01-22 Thread Zhang Wei
Hi, Dan, 

 -Original Message-
 From: [EMAIL PROTECTED] 

 I do not think all the review comments have been addressed, for
 example my earlier comments about GFP_ATOMIC and spin_lock_irqsave
 [1].  We have two options to take this forward:
 

Thanks! Some comments need more study, I'll discuss them with you later.

 1/ Continue to carry this in the async-tx tree and get an
 Acked-by/Reviewed-by tag from Kumar.
 2/ Move this to Kumar's tree, and coordinate our pull requests to have
 the async-tx updates hit first.
 
 I prefer option 1, but I will defer to Kumar.
 

I also prefer option 1. How about now?

Cheers!
Wei.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH v2] Add DMA engine driver for Freescale MPC85xxprocessors.

2008-01-10 Thread Zhang Wei
Hi, Dan,

Thanks so much for your help! 

> Since the fixups were straightforward I went ahead and pulled 
> this patch
> out of -mm and rebased it on my async-tx patch queue for 
> 2.6.25.  Could
> you double check the result, I have only compile tested it?
> 
>   git pull git://lost.foo-projects.org/~dwillia2/git/iop 
> md-for-linus
> 
> I also came across two more review items:
> 1/ Is there any issue with getting rid of CONFIG_FSL_DMA_SELFTEST?  It
> is always on in iop-adma and ioatdma.

I think it's no problem to remove CONFIG_FSL_DMA_SELFTEST.

> 
> 2/ I get the following compile warning:
> drivers/dma/fsldma.c:731: warning: 'fsl_dma_callback_test' 
> defined but not used
> 

I should add #ifdef FSL_DMA_CALLBACKTEST before fsl_dma_callback_test()
function to get rid of the warning.

I think your patch is good. What should I do next?

Cheers!
Wei.
> For reference the changes I made when I rebased are appended below.
> 
> Thanks,
> Dan
> 
>  fsldma.c |   66 
> +++
>  1 file changed, 20 insertions(+), 46 deletions(-)
> 
> diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
> index 899b0c0..902e852 100644
> --- a/drivers/dma/fsldma.c
> +++ b/drivers/dma/fsldma.c
> @@ -302,30 +302,6 @@ static void 
> fsl_chan_toggle_ext_start(struct fsl_dma_chan *fsl_chan, int enable)
>   fsl_chan->feature &= ~FSL_DMA_CHAN_START_EXT;
>  }
>  
> -static void fsl_dma_set_src(dma_addr_t addr,
> - struct dma_async_tx_descriptor 
> *tx, int index)
> -{
> - struct fsl_desc_sw *desc_node, *desc = tx_to_fsl_desc(tx);
> - struct fsl_dma_chan *fsl_chan = to_fsl_chan(tx->chan);
> -
> - list_for_each_entry(desc_node, >async_tx.tx_list, node) {
> - set_desc_src(fsl_chan, _node->hw, addr);
> - addr += FSL_DMA_BCR_MAX_CNT;
> - }
> -}
> -
> -static void fsl_dma_set_dest(dma_addr_t addr,
> - struct dma_async_tx_descriptor 
> *tx, int index)
> -{
> - struct fsl_desc_sw *desc_node, *desc = tx_to_fsl_desc(tx);
> - struct fsl_dma_chan *fsl_chan = to_fsl_chan(tx->chan);
> -
> - list_for_each_entry(desc_node, >async_tx.tx_list, node) {
> - set_desc_dest(fsl_chan, _node->hw, addr);
> - addr += FSL_DMA_BCR_MAX_CNT;
> - }
> -}
> -
>  static dma_cookie_t fsl_dma_tx_submit(struct 
> dma_async_tx_descriptor *tx)
>  {
>   struct fsl_desc_sw *desc = tx_to_fsl_desc(tx);
> @@ -368,8 +344,6 @@ static struct fsl_desc_sw 
> *fsl_dma_alloc_descriptor(
>   memset(desc_sw, 0, sizeof(struct fsl_desc_sw));
>   dma_async_tx_descriptor_init(_sw->async_tx,
>   _chan->common);
> - desc_sw->async_tx.tx_set_src = fsl_dma_set_src;
> - desc_sw->async_tx.tx_set_dest = fsl_dma_set_dest;
>   desc_sw->async_tx.tx_submit = fsl_dma_tx_submit;
>   INIT_LIST_HEAD(_sw->async_tx.tx_list);
>   desc_sw->async_tx.phys = pdesc;
> @@ -433,7 +407,8 @@ static void 
> fsl_dma_free_chan_resources(struct dma_chan *chan)
>  }
>  
>  static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy(
> - struct dma_chan *chan, size_t 
> len, int int_en)
> + struct dma_chan *chan, dma_addr_t dma_dest, dma_addr_t dma_src,
> + size_t len, unsigned long flags)
>  {
>   struct fsl_dma_chan *fsl_chan;
>   struct fsl_desc_sw *first = NULL, *prev = NULL, *new;
> @@ -464,6 +439,8 @@ static struct dma_async_tx_descriptor 
> *fsl_dma_prep_memcpy(
>   copy = min(len, FSL_DMA_BCR_MAX_CNT);
>  
>   set_desc_cnt(fsl_chan, >hw, copy);
> + set_desc_src(fsl_chan, >hw, dma_src);
> + set_desc_dest(fsl_chan, >hw, dma_dest);
>  
>   if (!first)
>   first = new;
> @@ -475,6 +452,8 @@ static struct dma_async_tx_descriptor 
> *fsl_dma_prep_memcpy(
>  
>   prev = new;
>   len -= copy;
> + dma_src += copy;
> + dma_dest += copy;
>  
>   /* Insert the link descriptor to the LD ring */
>   list_add_tail(>node, >async_tx.tx_list);
> @@ -758,7 +737,7 @@ static int fsl_dma_self_test(struct 
> fsl_dma_chan *fsl_chan)
>  {
>   struct dma_chan *chan;
>   int err = 0;
> - dma_addr_t addr;
> + dma_addr_t dma_dest, dma_src;
>   dma_cookie_t cookie;
>   u8 *src, *dest;
>   int i;
> @@ -790,13 +769,12 @@ static int fsl_dma_self_test(struct 
> fsl_dma_chan *fsl_chan)
>   }
>  
>   /* TX 1 */
> - tx1 = fsl_dma_prep_memcpy(chan, test_size / 2, 0);
> + dma_src = dma_map_single(fsl_chan->dev, src, test_size / 2,
> +  DMA_TO_DEVICE);
> + dma_dest = dma_map_single(fsl_chan->dev, dest, test_size / 2,
> +   DMA_FROM_DEVICE);
> + tx1 = fsl_dma_prep_memcpy(chan, dma_dest, dma_src, 
> test_size / 2, 0);
> 

RE: [PATCH v2] Add DMA engine driver for Freescale MPC85xxprocessors.

2008-01-10 Thread Zhang Wei
Hi, Dan,

Thanks so much for your help! 

 Since the fixups were straightforward I went ahead and pulled 
 this patch
 out of -mm and rebased it on my async-tx patch queue for 
 2.6.25.  Could
 you double check the result, I have only compile tested it?
 
   git pull git://lost.foo-projects.org/~dwillia2/git/iop 
 md-for-linus
 
 I also came across two more review items:
 1/ Is there any issue with getting rid of CONFIG_FSL_DMA_SELFTEST?  It
 is always on in iop-adma and ioatdma.

I think it's no problem to remove CONFIG_FSL_DMA_SELFTEST.

 
 2/ I get the following compile warning:
 drivers/dma/fsldma.c:731: warning: 'fsl_dma_callback_test' 
 defined but not used
 

I should add #ifdef FSL_DMA_CALLBACKTEST before fsl_dma_callback_test()
function to get rid of the warning.

I think your patch is good. What should I do next?

Cheers!
Wei.
 For reference the changes I made when I rebased are appended below.
 
 Thanks,
 Dan
 
  fsldma.c |   66 
 +++
  1 file changed, 20 insertions(+), 46 deletions(-)
 
 diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
 index 899b0c0..902e852 100644
 --- a/drivers/dma/fsldma.c
 +++ b/drivers/dma/fsldma.c
 @@ -302,30 +302,6 @@ static void 
 fsl_chan_toggle_ext_start(struct fsl_dma_chan *fsl_chan, int enable)
   fsl_chan-feature = ~FSL_DMA_CHAN_START_EXT;
  }
  
 -static void fsl_dma_set_src(dma_addr_t addr,
 - struct dma_async_tx_descriptor 
 *tx, int index)
 -{
 - struct fsl_desc_sw *desc_node, *desc = tx_to_fsl_desc(tx);
 - struct fsl_dma_chan *fsl_chan = to_fsl_chan(tx-chan);
 -
 - list_for_each_entry(desc_node, desc-async_tx.tx_list, node) {
 - set_desc_src(fsl_chan, desc_node-hw, addr);
 - addr += FSL_DMA_BCR_MAX_CNT;
 - }
 -}
 -
 -static void fsl_dma_set_dest(dma_addr_t addr,
 - struct dma_async_tx_descriptor 
 *tx, int index)
 -{
 - struct fsl_desc_sw *desc_node, *desc = tx_to_fsl_desc(tx);
 - struct fsl_dma_chan *fsl_chan = to_fsl_chan(tx-chan);
 -
 - list_for_each_entry(desc_node, desc-async_tx.tx_list, node) {
 - set_desc_dest(fsl_chan, desc_node-hw, addr);
 - addr += FSL_DMA_BCR_MAX_CNT;
 - }
 -}
 -
  static dma_cookie_t fsl_dma_tx_submit(struct 
 dma_async_tx_descriptor *tx)
  {
   struct fsl_desc_sw *desc = tx_to_fsl_desc(tx);
 @@ -368,8 +344,6 @@ static struct fsl_desc_sw 
 *fsl_dma_alloc_descriptor(
   memset(desc_sw, 0, sizeof(struct fsl_desc_sw));
   dma_async_tx_descriptor_init(desc_sw-async_tx,
   fsl_chan-common);
 - desc_sw-async_tx.tx_set_src = fsl_dma_set_src;
 - desc_sw-async_tx.tx_set_dest = fsl_dma_set_dest;
   desc_sw-async_tx.tx_submit = fsl_dma_tx_submit;
   INIT_LIST_HEAD(desc_sw-async_tx.tx_list);
   desc_sw-async_tx.phys = pdesc;
 @@ -433,7 +407,8 @@ static void 
 fsl_dma_free_chan_resources(struct dma_chan *chan)
  }
  
  static struct dma_async_tx_descriptor *fsl_dma_prep_memcpy(
 - struct dma_chan *chan, size_t 
 len, int int_en)
 + struct dma_chan *chan, dma_addr_t dma_dest, dma_addr_t dma_src,
 + size_t len, unsigned long flags)
  {
   struct fsl_dma_chan *fsl_chan;
   struct fsl_desc_sw *first = NULL, *prev = NULL, *new;
 @@ -464,6 +439,8 @@ static struct dma_async_tx_descriptor 
 *fsl_dma_prep_memcpy(
   copy = min(len, FSL_DMA_BCR_MAX_CNT);
  
   set_desc_cnt(fsl_chan, new-hw, copy);
 + set_desc_src(fsl_chan, new-hw, dma_src);
 + set_desc_dest(fsl_chan, new-hw, dma_dest);
  
   if (!first)
   first = new;
 @@ -475,6 +452,8 @@ static struct dma_async_tx_descriptor 
 *fsl_dma_prep_memcpy(
  
   prev = new;
   len -= copy;
 + dma_src += copy;
 + dma_dest += copy;
  
   /* Insert the link descriptor to the LD ring */
   list_add_tail(new-node, first-async_tx.tx_list);
 @@ -758,7 +737,7 @@ static int fsl_dma_self_test(struct 
 fsl_dma_chan *fsl_chan)
  {
   struct dma_chan *chan;
   int err = 0;
 - dma_addr_t addr;
 + dma_addr_t dma_dest, dma_src;
   dma_cookie_t cookie;
   u8 *src, *dest;
   int i;
 @@ -790,13 +769,12 @@ static int fsl_dma_self_test(struct 
 fsl_dma_chan *fsl_chan)
   }
  
   /* TX 1 */
 - tx1 = fsl_dma_prep_memcpy(chan, test_size / 2, 0);
 + dma_src = dma_map_single(fsl_chan-dev, src, test_size / 2,
 +  DMA_TO_DEVICE);
 + dma_dest = dma_map_single(fsl_chan-dev, dest, test_size / 2,
 +   DMA_FROM_DEVICE);
 + tx1 = fsl_dma_prep_memcpy(chan, dma_dest, dma_src, 
 test_size / 2, 0);
   async_tx_ack(tx1);
 - addr = dma_map_single(fsl_chan-dev, src, test_size / 
 2, 

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

2008-01-04 Thread Zhang Wei
Hi,  

Thanks!

Maybe I should make a clean and split them into small patches.

Cheers!
Wei.

> 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/
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2008-01-04 Thread Zhang Wei
Hi,  

Thanks!

Maybe I should make a clean and split them into small patches.

Cheers!
Wei.

 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/
 
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[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 

[PATCH 2/3] (Resend part #2) Add RapidIO memory mapping API and simple Bitmap allocation.

2007-12-21 Thread Zhang Wei
Add RapidIO memory mapping API and simple Bitmap allocation with fixed size.
Some bugs are fixed.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 drivers/rapidio/Kconfig |   18 +-
 drivers/rapidio/Makefile|1 +
 drivers/rapidio/rio-access.c|   10 +-
 drivers/rapidio/rio-scan.c  |   53 +++--
 drivers/rapidio/rio-sysfs.c |3 +-
 drivers/rapidio/rio.c   |  486 ++-
 drivers/rapidio/rio.h   |9 +-
 drivers/rapidio/sallocator/Kconfig  |9 +
 drivers/rapidio/sallocator/Makefile |   12 +
 drivers/rapidio/sallocator/bitmap.c |  383 +++
 10 files changed, 944 insertions(+), 40 deletions(-)
 create mode 100644 drivers/rapidio/sallocator/Kconfig
 create mode 100644 drivers/rapidio/sallocator/Makefile
 create mode 100644 drivers/rapidio/sallocator/bitmap.c

diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
index 4142115..f669108 100644
--- a/drivers/rapidio/Kconfig
+++ b/drivers/rapidio/Kconfig
@@ -1,14 +1,6 @@
 #
 # RapidIO configuration
 #
-config RAPIDIO_8_BIT_TRANSPORT
-   bool "8-bit transport addressing"
-   depends on RAPIDIO
-   ---help---
- By default, the kernel assumes a 16-bit addressed RapidIO
- network. By selecting this option, the kernel will support
- an 8-bit addressed network.
-
 config RAPIDIO_DISC_TIMEOUT
int "Discovery timeout duration (seconds)"
depends on RAPIDIO
@@ -16,3 +8,13 @@ config RAPIDIO_DISC_TIMEOUT
---help---
  Amount of time a discovery node waits for a host to complete
  enumeration before giving up.
+
+config RAPIDIO_PROC_FS
+   bool "I/O and Memory resource debug"
+   depends on RAPIDIO && PROC_FS
+   default y
+   ---help---
+ Enable this option, it will create a /proc/riores node for
+ monitoring the RapidIO I/O and Memory resource.
+
+source "drivers/rapidio/sallocator/Kconfig"
diff --git a/drivers/rapidio/Makefile b/drivers/rapidio/Makefile
index 7c0e181..e5b2f11 100644
--- a/drivers/rapidio/Makefile
+++ b/drivers/rapidio/Makefile
@@ -4,3 +4,4 @@
 obj-y += rio.o rio-access.o rio-driver.o rio-scan.o rio-sysfs.o
 
 obj-$(CONFIG_RAPIDIO)  += switches/
+obj-$(CONFIG_RAPIDIO)  += sallocator/
diff --git a/drivers/rapidio/rio-access.c b/drivers/rapidio/rio-access.c
index 8b56bbd..a3824ba 100644
--- a/drivers/rapidio/rio-access.c
+++ b/drivers/rapidio/rio-access.c
@@ -48,7 +48,7 @@ int __rio_local_read_config_##size \
u32 data = 0;   \
if (RIO_##size##_BAD) return RIO_BAD_SIZE;  \
spin_lock_irqsave(_config_lock, flags); \
-   res = mport->ops->lcread(mport->id, offset, len, );\
+   res = mport->ops->lcread(mport, mport->id, offset, len, ); \
*value = (type)data;\
spin_unlock_irqrestore(_config_lock, flags);\
return res; \
@@ -71,7 +71,7 @@ int __rio_local_write_config_##size \
unsigned long flags;\
if (RIO_##size##_BAD) return RIO_BAD_SIZE;  \
spin_lock_irqsave(_config_lock, flags); \
-   res = mport->ops->lcwrite(mport->id, offset, len, value);   \
+   res = mport->ops->lcwrite(mport, mport->id, offset, len, value);\
spin_unlock_irqrestore(_config_lock, flags);\
return res; \
 }
@@ -108,7 +108,7 @@ int rio_mport_read_config_##size \
u32 data = 0;   \
if (RIO_##size##_BAD) return RIO_BAD_SIZE;  \
spin_lock_irqsave(_config_lock, flags); \
-   res = mport->ops->cread(mport->id, destid, hopcount, offset, len, 
); \
+   res = mport->ops->cread(mport, mport->id, destid, hopcount, offset, 
len, ); \
*value = (type)data;\
spin_unlock_irqrestore(_config_lock, flags);\
return res; \
@@ -131,7 +131,7 @@ int rio_mport_write_config_##size \
unsigned long flags;\
if (RIO_##size##_BAD) return RIO_BAD_SIZE;  \
spin_lock_irqsave(_config_lock, flags); \
-   res = mport->ops->cwrite(mport->id, destid, hopcount, offset, len, 
value); \
+   res = mport->ops->cwrite(mport, mport->id, destid, hopcount, offset, 
len, value); \
spin_unlock_irqrestore(_config_lock,

[PATCH 2/3] (Resend part #2) Add RapidIO memory mapping API and simple Bitmap allocation.

2007-12-21 Thread Zhang Wei
Add RapidIO memory mapping API and simple Bitmap allocation with fixed size.
Some bugs are fixed.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 drivers/rapidio/Kconfig |   18 +-
 drivers/rapidio/Makefile|1 +
 drivers/rapidio/rio-access.c|   10 +-
 drivers/rapidio/rio-scan.c  |   53 +++--
 drivers/rapidio/rio-sysfs.c |3 +-
 drivers/rapidio/rio.c   |  486 ++-
 drivers/rapidio/rio.h   |9 +-
 drivers/rapidio/sallocator/Kconfig  |9 +
 drivers/rapidio/sallocator/Makefile |   12 +
 drivers/rapidio/sallocator/bitmap.c |  383 +++
 10 files changed, 944 insertions(+), 40 deletions(-)
 create mode 100644 drivers/rapidio/sallocator/Kconfig
 create mode 100644 drivers/rapidio/sallocator/Makefile
 create mode 100644 drivers/rapidio/sallocator/bitmap.c

diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
index 4142115..f669108 100644
--- a/drivers/rapidio/Kconfig
+++ b/drivers/rapidio/Kconfig
@@ -1,14 +1,6 @@
 #
 # RapidIO configuration
 #
-config RAPIDIO_8_BIT_TRANSPORT
-   bool 8-bit transport addressing
-   depends on RAPIDIO
-   ---help---
- By default, the kernel assumes a 16-bit addressed RapidIO
- network. By selecting this option, the kernel will support
- an 8-bit addressed network.
-
 config RAPIDIO_DISC_TIMEOUT
int Discovery timeout duration (seconds)
depends on RAPIDIO
@@ -16,3 +8,13 @@ config RAPIDIO_DISC_TIMEOUT
---help---
  Amount of time a discovery node waits for a host to complete
  enumeration before giving up.
+
+config RAPIDIO_PROC_FS
+   bool I/O and Memory resource debug
+   depends on RAPIDIO  PROC_FS
+   default y
+   ---help---
+ Enable this option, it will create a /proc/riores node for
+ monitoring the RapidIO I/O and Memory resource.
+
+source drivers/rapidio/sallocator/Kconfig
diff --git a/drivers/rapidio/Makefile b/drivers/rapidio/Makefile
index 7c0e181..e5b2f11 100644
--- a/drivers/rapidio/Makefile
+++ b/drivers/rapidio/Makefile
@@ -4,3 +4,4 @@
 obj-y += rio.o rio-access.o rio-driver.o rio-scan.o rio-sysfs.o
 
 obj-$(CONFIG_RAPIDIO)  += switches/
+obj-$(CONFIG_RAPIDIO)  += sallocator/
diff --git a/drivers/rapidio/rio-access.c b/drivers/rapidio/rio-access.c
index 8b56bbd..a3824ba 100644
--- a/drivers/rapidio/rio-access.c
+++ b/drivers/rapidio/rio-access.c
@@ -48,7 +48,7 @@ int __rio_local_read_config_##size \
u32 data = 0;   \
if (RIO_##size##_BAD) return RIO_BAD_SIZE;  \
spin_lock_irqsave(rio_config_lock, flags); \
-   res = mport-ops-lcread(mport-id, offset, len, data);\
+   res = mport-ops-lcread(mport, mport-id, offset, len, data); \
*value = (type)data;\
spin_unlock_irqrestore(rio_config_lock, flags);\
return res; \
@@ -71,7 +71,7 @@ int __rio_local_write_config_##size \
unsigned long flags;\
if (RIO_##size##_BAD) return RIO_BAD_SIZE;  \
spin_lock_irqsave(rio_config_lock, flags); \
-   res = mport-ops-lcwrite(mport-id, offset, len, value);   \
+   res = mport-ops-lcwrite(mport, mport-id, offset, len, value);\
spin_unlock_irqrestore(rio_config_lock, flags);\
return res; \
 }
@@ -108,7 +108,7 @@ int rio_mport_read_config_##size \
u32 data = 0;   \
if (RIO_##size##_BAD) return RIO_BAD_SIZE;  \
spin_lock_irqsave(rio_config_lock, flags); \
-   res = mport-ops-cread(mport-id, destid, hopcount, offset, len, 
data); \
+   res = mport-ops-cread(mport, mport-id, destid, hopcount, offset, 
len, data); \
*value = (type)data;\
spin_unlock_irqrestore(rio_config_lock, flags);\
return res; \
@@ -131,7 +131,7 @@ int rio_mport_write_config_##size \
unsigned long flags;\
if (RIO_##size##_BAD) return RIO_BAD_SIZE;  \
spin_lock_irqsave(rio_config_lock, flags); \
-   res = mport-ops-cwrite(mport-id, destid, hopcount, offset, len, 
value); \
+   res = mport-ops-cwrite(mport, mport-id, destid, hopcount, offset, 
len, value); \
spin_unlock_irqrestore(rio_config_lock, flags);\
return res; \
 }
@@ -166,7 +166,7 @@ int

[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 linux/init.h
@@ -17,14 +27,41 @@
 #include linux/interrupt.h
 #include linux/rio.h
 #include linux/rio_drv.h
+#include linux/of_device.h
+#include linux/of_platform.h
 
 #include asm/io.h
+#include asm/prom.h
+#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_R

[PATCH 3/3] Add memory mapping support to rionet driver.

2007-12-13 Thread Zhang Wei
Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 drivers/net/Kconfig  |   10 ++
 drivers/net/rionet.c |  337 +-
 2 files changed, 345 insertions(+), 2 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index e8d69b0..b1129cc 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2637,6 +2637,16 @@ config RIONET_RX_SIZE
depends on RIONET
default "128"
 
+config RIONET_MEMMAP
+   bool "Use memory map instead of message"
+   depends on RIONET
+   default n
+
+config RIONET_DMA
+   bool "Use DMA for memory mapping data transfer"
+   depends on RIONET_MEMMAP && FSL_DMA
+   default y
+
 config FDDI
bool "FDDI driver support"
depends on (PCI || EISA || TC)
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index e7fd08a..53b53a8 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -1,6 +1,13 @@
 /*
  * rionet - Ethernet driver over RapidIO messaging services
  *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ * Author: Zhang Wei, [EMAIL PROTECTED], Jun 2007
+ *
+ * Changelog:
+ * Jun 2007 Zhang Wei <[EMAIL PROTECTED]>
+ * - Added the support to RapidIO memory driver. 2007.
+ *
  * Copyright 2005 MontaVista Software, Inc.
  * Matt Porter <[EMAIL PROTECTED]>
  *
@@ -8,6 +15,7 @@
  * 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.
+ *
  */
 
 #include 
@@ -23,6 +31,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DRV_NAME"rionet"
 #define DRV_VERSION "0.2"
@@ -40,13 +49,47 @@ MODULE_LICENSE("GPL");
 NETIF_MSG_TX_ERR)
 
 #define RIONET_DOORBELL_JOIN   0x1000
+#ifdef CONFIG_RIONET_MEMMAP
+#define RIONET_DOORBELL_SEND   0x1001
+#define RIONET_DOORBELL_LEAVE  0x1002
+#else
 #define RIONET_DOORBELL_LEAVE  0x1001
+#endif
 
 #define RIONET_MAILBOX 0
 
 #define RIONET_TX_RING_SIZECONFIG_RIONET_TX_SIZE
 #define RIONET_RX_RING_SIZECONFIG_RIONET_RX_SIZE
 
+#define ERR(fmt, arg...) \
+   printk(KERN_ERR "ERROR %s - %s: " fmt,  __FILE__, __FUNCTION__, ## arg)
+
+#ifdef CONFIG_RIONET_MEMMAP
+/* Definitions for rionet memory map driver */
+#define RIONET_DRVID   0x101
+#define RIONET_MAX_SK_DATA_SIZE0x1000
+#define RIONET_TX_RX_BUFF_SIZE (0x1000 * (128 + 128))
+#define RIONET_QUEUE_NEXT(x)   (((x) < 127) ? ((x) + 1) : 0)
+#define RIONET_QUEUE_INC(x)(x = RIONET_QUEUE_NEXT(x))
+
+struct sk_data {
+   u8  data[0x1000];
+};
+
+#define RIONET_SKDATA_EN   0x8000
+struct rionet_tx_rx_buff {
+   volatile intenqueue;/* enqueue point */
+   volatile intdequeue;/* dequeue point */
+   u32 size[128];  /* size[i] is skdata[i] size
+* the most high bit [31] is
+* enable bit. The
+* max size is 4096.
+*/
+   u8  rev1[3576];
+   struct sk_data  skdata[128];/* all size are 0x1000 * 128 */
+};
+#endif /* CONFIG_RIONET_MEMMAP */
+
 static LIST_HEAD(rionet_peers);
 
 struct rionet_private {
@@ -60,6 +103,18 @@ struct rionet_private {
spinlock_t lock;
spinlock_t tx_lock;
u32 msg_enable;
+#ifdef CONFIG_RIONET_MEMMAP
+   struct rionet_tx_rx_buff *rxbuff;
+   struct rionet_tx_rx_buff __iomem *txbuff;
+   struct rio_mem *rxmem;
+   struct rio_mem *txmem;
+#ifdef CONFIG_RIONET_DMA
+   struct dma_chan *txdmachan;
+   struct dma_chan *rxdmachan;
+   struct dma_client rio_dma_client;
+   spinlock_t rio_dma_event_lock;
+#endif
+#endif
 };
 
 struct rionet_peer {
@@ -77,7 +132,7 @@ static int rionet_capable = 1;
  * could be made into a hash table to save memory depending
  * on system trade-offs.
  */
-static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES];
+static struct rio_dev **rionet_active;
 
 #define is_rionet_capable(pef, src_ops, dst_ops)   \
((pef & RIO_PEF_INB_MBOX) &&\
@@ -108,9 +163,11 @@ static int rionet_rx_clean(struct net_device *ndev)
 
rnet->rx_skb[i]->data = data;
skb_put(rnet->rx_skb[i], RIO_MAX_MSG_SIZE);
+   rnet->rx_skb[i]->dev = ndev;
rnet->rx_skb[i]->protocol =
eth_type_trans(rnet->rx_skb[i], ndev);
error = netif_rx(rnet->rx_skb[i]);
+   rnet->rx_skb[i] = NULL;
 
if (error == NET_RX_DROP) {
ndev->stats.rx_dropped++;
@@ -141,1

[PATCH 1/3] Move arch/ppc/syslib/ppc85xx_rio.c to arch/powerpc/sysdev/fsl_rio.c

2007-12-13 Thread Zhang Wei
Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/fsl_rio.c |  932 +
 1 files changed, 932 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/sysdev/fsl_rio.c

diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
new file mode 100644
index 000..af2425e
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -0,0 +1,932 @@
+/*
+ * MPC85xx RapidIO support
+ *
+ * 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 Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define RIO_REGS_BASE  (CCSRBAR + 0xc)
+#define RIO_ATMU_REGS_OFFSET   0x10c00
+#define RIO_MSG_REGS_OFFSET0x11000
+#define RIO_MAINT_WIN_SIZE 0x40
+#define RIO_DBELL_WIN_SIZE 0x1000
+
+#define RIO_MSG_OMR_MUI0x0002
+#define RIO_MSG_OSR_TE 0x0080
+#define RIO_MSG_OSR_QOI0x0020
+#define RIO_MSG_OSR_QFI0x0010
+#define RIO_MSG_OSR_MUB0x0004
+#define RIO_MSG_OSR_EOMI   0x0002
+#define RIO_MSG_OSR_QEI0x0001
+
+#define RIO_MSG_IMR_MI 0x0002
+#define RIO_MSG_ISR_TE 0x0080
+#define RIO_MSG_ISR_QFI0x0010
+#define RIO_MSG_ISR_DIQI   0x0001
+
+#define RIO_MSG_DESC_SIZE  32
+#define RIO_MSG_BUFFER_SIZE4096
+#define RIO_MIN_TX_RING_SIZE   2
+#define RIO_MAX_TX_RING_SIZE   2048
+#define RIO_MIN_RX_RING_SIZE   2
+#define RIO_MAX_RX_RING_SIZE   2048
+
+#define DOORBELL_DMR_DI0x0002
+#define DOORBELL_DSR_TE0x0080
+#define DOORBELL_DSR_QFI   0x0010
+#define DOORBELL_DSR_DIQI  0x0001
+#define DOORBELL_TID_OFFSET0x03
+#define DOORBELL_SID_OFFSET0x05
+#define DOORBELL_INFO_OFFSET   0x06
+
+#define DOORBELL_MESSAGE_SIZE  0x08
+#define DBELL_SID(x)   (*(u8 *)(x + DOORBELL_SID_OFFSET))
+#define DBELL_TID(x)   (*(u8 *)(x + DOORBELL_TID_OFFSET))
+#define DBELL_INF(x)   (*(u16 *)(x + DOORBELL_INFO_OFFSET))
+
+struct rio_atmu_regs {
+   u32 rowtar;
+   u32 pad1;
+   u32 rowbar;
+   u32 pad2;
+   u32 rowar;
+   u32 pad3[3];
+};
+
+struct rio_msg_regs {
+   u32 omr;
+   u32 osr;
+   u32 pad1;
+   u32 odqdpar;
+   u32 pad2;
+   u32 osar;
+   u32 odpr;
+   u32 odatr;
+   u32 odcr;
+   u32 pad3;
+   u32 odqepar;
+   u32 pad4[13];
+   u32 imr;
+   u32 isr;
+   u32 pad5;
+   u32 ifqdpar;
+   u32 pad6;
+   u32 ifqepar;
+   u32 pad7[250];
+   u32 dmr;
+   u32 dsr;
+   u32 pad8;
+   u32 dqdpar;
+   u32 pad9;
+   u32 dqepar;
+   u32 pad10[26];
+   u32 pwmr;
+   u32 pwsr;
+   u32 pad11;
+   u32 pwqbar;
+};
+
+struct rio_tx_desc {
+   u32 res1;
+   u32 saddr;
+   u32 dport;
+   u32 dattr;
+   u32 res2;
+   u32 res3;
+   u32 dwcnt;
+   u32 res4;
+};
+
+static u32 regs_win;
+static struct rio_atmu_regs *atmu_regs;
+static struct rio_atmu_regs *maint_atmu_regs;
+static struct rio_atmu_regs *dbell_atmu_regs;
+static u32 dbell_win;
+static u32 maint_win;
+static struct rio_msg_regs *msg_regs;
+
+static struct rio_dbell_ring {
+   void *virt;
+   dma_addr_t phys;
+} dbell_ring;
+
+static struct rio_msg_tx_ring {
+   void *virt;
+   dma_addr_t phys;
+   void *virt_buffer[RIO_MAX_TX_RING_SIZE];
+   dma_addr_t phys_buffer[RIO_MAX_TX_RING_SIZE];
+   int tx_slot;
+   int size;
+   void *dev_id;
+} msg_tx_ring;
+
+static struct rio_msg_rx_ring {
+   void *virt;
+   dma_addr_t phys;
+   void *virt_buffer[RIO_MAX_RX_RING_SIZE];
+   int rx_slot;
+   int size;
+   void *dev_id;
+} msg_rx_ring;
+
+/**
+ * mpc85xx_rio_doorbell_send - Send a MPC85xx doorbell message
+ * @index: ID of RapidIO interface
+ * @destid: Destination ID of target device
+ * @data: 16-bit info field of RapidIO doorbell message
+ *
+ * Sends a MPC85xx doorbell message. Returns %0 on success or
+ * %-EINVAL on failure.
+ */
+static int mpc85xx_rio_doorbell_send(int index, u16 destid, u16 data)
+{
+   pr_debug("mpc85xx_doorbell_send: index %d destid %4.4x data %4.4x\n",
+index, destid, data);
+   out_be32((void *)_atmu_regs->rowtar, destid << 22);
+   out_be16((void *)(dbell_win), data);
+
+   return 0;
+}
+
+/**
+ * mpc85xx_local_config_read - Generate a MPC85xx local config space read
+ * @index: ID of RapdiIO interface
+ * @offset: Offset into configuration space
+ * @len: Length (in bytes) of the maintenance transact

[0/3] Add RapidIO support to powerpc architecture with memory mapping

2007-12-13 Thread Zhang Wei
Hi,

Those patches add RapidIO support to powerpc archiecture with
memory mapping as below:

[1/3] Copy the arch/ppc RapidIO support to arch/powerpc
[2/3] Make the arch/powerpc RapidIO support workable with of-device
  and add memory mapping support.
[3/3] Add the memory mapping support to rionet driver.

Best Regards,
Zhang Wei


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[0/3] Add RapidIO support to powerpc architecture with memory mapping

2007-12-13 Thread Zhang Wei
Hi,

Those patches add RapidIO support to powerpc archiecture with
memory mapping as below:

[1/3] Copy the arch/ppc RapidIO support to arch/powerpc
[2/3] Make the arch/powerpc RapidIO support workable with of-device
  and add memory mapping support.
[3/3] Add the memory mapping support to rionet driver.

Best Regards,
Zhang Wei


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] Add memory mapping support to rionet driver.

2007-12-13 Thread Zhang Wei
Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 drivers/net/Kconfig  |   10 ++
 drivers/net/rionet.c |  337 +-
 2 files changed, 345 insertions(+), 2 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index e8d69b0..b1129cc 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2637,6 +2637,16 @@ config RIONET_RX_SIZE
depends on RIONET
default 128
 
+config RIONET_MEMMAP
+   bool Use memory map instead of message
+   depends on RIONET
+   default n
+
+config RIONET_DMA
+   bool Use DMA for memory mapping data transfer
+   depends on RIONET_MEMMAP  FSL_DMA
+   default y
+
 config FDDI
bool FDDI driver support
depends on (PCI || EISA || TC)
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index e7fd08a..53b53a8 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -1,6 +1,13 @@
 /*
  * rionet - Ethernet driver over RapidIO messaging services
  *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ * Author: Zhang Wei, [EMAIL PROTECTED], Jun 2007
+ *
+ * Changelog:
+ * Jun 2007 Zhang Wei [EMAIL PROTECTED]
+ * - Added the support to RapidIO memory driver. 2007.
+ *
  * Copyright 2005 MontaVista Software, Inc.
  * Matt Porter [EMAIL PROTECTED]
  *
@@ -8,6 +15,7 @@
  * 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.
+ *
  */
 
 #include linux/module.h
@@ -23,6 +31,7 @@
 #include linux/skbuff.h
 #include linux/crc32.h
 #include linux/ethtool.h
+#include linux/dmaengine.h
 
 #define DRV_NAMErionet
 #define DRV_VERSION 0.2
@@ -40,13 +49,47 @@ MODULE_LICENSE(GPL);
 NETIF_MSG_TX_ERR)
 
 #define RIONET_DOORBELL_JOIN   0x1000
+#ifdef CONFIG_RIONET_MEMMAP
+#define RIONET_DOORBELL_SEND   0x1001
+#define RIONET_DOORBELL_LEAVE  0x1002
+#else
 #define RIONET_DOORBELL_LEAVE  0x1001
+#endif
 
 #define RIONET_MAILBOX 0
 
 #define RIONET_TX_RING_SIZECONFIG_RIONET_TX_SIZE
 #define RIONET_RX_RING_SIZECONFIG_RIONET_RX_SIZE
 
+#define ERR(fmt, arg...) \
+   printk(KERN_ERR ERROR %s - %s:  fmt,  __FILE__, __FUNCTION__, ## arg)
+
+#ifdef CONFIG_RIONET_MEMMAP
+/* Definitions for rionet memory map driver */
+#define RIONET_DRVID   0x101
+#define RIONET_MAX_SK_DATA_SIZE0x1000
+#define RIONET_TX_RX_BUFF_SIZE (0x1000 * (128 + 128))
+#define RIONET_QUEUE_NEXT(x)   (((x)  127) ? ((x) + 1) : 0)
+#define RIONET_QUEUE_INC(x)(x = RIONET_QUEUE_NEXT(x))
+
+struct sk_data {
+   u8  data[0x1000];
+};
+
+#define RIONET_SKDATA_EN   0x8000
+struct rionet_tx_rx_buff {
+   volatile intenqueue;/* enqueue point */
+   volatile intdequeue;/* dequeue point */
+   u32 size[128];  /* size[i] is skdata[i] size
+* the most high bit [31] is
+* enable bit. The
+* max size is 4096.
+*/
+   u8  rev1[3576];
+   struct sk_data  skdata[128];/* all size are 0x1000 * 128 */
+};
+#endif /* CONFIG_RIONET_MEMMAP */
+
 static LIST_HEAD(rionet_peers);
 
 struct rionet_private {
@@ -60,6 +103,18 @@ struct rionet_private {
spinlock_t lock;
spinlock_t tx_lock;
u32 msg_enable;
+#ifdef CONFIG_RIONET_MEMMAP
+   struct rionet_tx_rx_buff *rxbuff;
+   struct rionet_tx_rx_buff __iomem *txbuff;
+   struct rio_mem *rxmem;
+   struct rio_mem *txmem;
+#ifdef CONFIG_RIONET_DMA
+   struct dma_chan *txdmachan;
+   struct dma_chan *rxdmachan;
+   struct dma_client rio_dma_client;
+   spinlock_t rio_dma_event_lock;
+#endif
+#endif
 };
 
 struct rionet_peer {
@@ -77,7 +132,7 @@ static int rionet_capable = 1;
  * could be made into a hash table to save memory depending
  * on system trade-offs.
  */
-static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES];
+static struct rio_dev **rionet_active;
 
 #define is_rionet_capable(pef, src_ops, dst_ops)   \
((pef  RIO_PEF_INB_MBOX) \
@@ -108,9 +163,11 @@ static int rionet_rx_clean(struct net_device *ndev)
 
rnet-rx_skb[i]-data = data;
skb_put(rnet-rx_skb[i], RIO_MAX_MSG_SIZE);
+   rnet-rx_skb[i]-dev = ndev;
rnet-rx_skb[i]-protocol =
eth_type_trans(rnet-rx_skb[i], ndev);
error = netif_rx(rnet-rx_skb[i]);
+   rnet-rx_skb[i] = NULL;
 
if (error == NET_RX_DROP) {
ndev-stats.rx_dropped++;
@@ -141,19 +198,96 @@ static void rionet_rx_fill(struct net_device *ndev, int 
end)
if (!rnet-rx_skb[i

[PATCH 1/3] Move arch/ppc/syslib/ppc85xx_rio.c to arch/powerpc/sysdev/fsl_rio.c

2007-12-13 Thread Zhang Wei
Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/sysdev/fsl_rio.c |  932 +
 1 files changed, 932 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/sysdev/fsl_rio.c

diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
new file mode 100644
index 000..af2425e
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -0,0 +1,932 @@
+/*
+ * MPC85xx RapidIO support
+ *
+ * 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 Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/types.h
+#include linux/dma-mapping.h
+#include linux/interrupt.h
+#include linux/rio.h
+#include linux/rio_drv.h
+
+#include asm/io.h
+
+#define RIO_REGS_BASE  (CCSRBAR + 0xc)
+#define RIO_ATMU_REGS_OFFSET   0x10c00
+#define RIO_MSG_REGS_OFFSET0x11000
+#define RIO_MAINT_WIN_SIZE 0x40
+#define RIO_DBELL_WIN_SIZE 0x1000
+
+#define RIO_MSG_OMR_MUI0x0002
+#define RIO_MSG_OSR_TE 0x0080
+#define RIO_MSG_OSR_QOI0x0020
+#define RIO_MSG_OSR_QFI0x0010
+#define RIO_MSG_OSR_MUB0x0004
+#define RIO_MSG_OSR_EOMI   0x0002
+#define RIO_MSG_OSR_QEI0x0001
+
+#define RIO_MSG_IMR_MI 0x0002
+#define RIO_MSG_ISR_TE 0x0080
+#define RIO_MSG_ISR_QFI0x0010
+#define RIO_MSG_ISR_DIQI   0x0001
+
+#define RIO_MSG_DESC_SIZE  32
+#define RIO_MSG_BUFFER_SIZE4096
+#define RIO_MIN_TX_RING_SIZE   2
+#define RIO_MAX_TX_RING_SIZE   2048
+#define RIO_MIN_RX_RING_SIZE   2
+#define RIO_MAX_RX_RING_SIZE   2048
+
+#define DOORBELL_DMR_DI0x0002
+#define DOORBELL_DSR_TE0x0080
+#define DOORBELL_DSR_QFI   0x0010
+#define DOORBELL_DSR_DIQI  0x0001
+#define DOORBELL_TID_OFFSET0x03
+#define DOORBELL_SID_OFFSET0x05
+#define DOORBELL_INFO_OFFSET   0x06
+
+#define DOORBELL_MESSAGE_SIZE  0x08
+#define DBELL_SID(x)   (*(u8 *)(x + DOORBELL_SID_OFFSET))
+#define DBELL_TID(x)   (*(u8 *)(x + DOORBELL_TID_OFFSET))
+#define DBELL_INF(x)   (*(u16 *)(x + DOORBELL_INFO_OFFSET))
+
+struct rio_atmu_regs {
+   u32 rowtar;
+   u32 pad1;
+   u32 rowbar;
+   u32 pad2;
+   u32 rowar;
+   u32 pad3[3];
+};
+
+struct rio_msg_regs {
+   u32 omr;
+   u32 osr;
+   u32 pad1;
+   u32 odqdpar;
+   u32 pad2;
+   u32 osar;
+   u32 odpr;
+   u32 odatr;
+   u32 odcr;
+   u32 pad3;
+   u32 odqepar;
+   u32 pad4[13];
+   u32 imr;
+   u32 isr;
+   u32 pad5;
+   u32 ifqdpar;
+   u32 pad6;
+   u32 ifqepar;
+   u32 pad7[250];
+   u32 dmr;
+   u32 dsr;
+   u32 pad8;
+   u32 dqdpar;
+   u32 pad9;
+   u32 dqepar;
+   u32 pad10[26];
+   u32 pwmr;
+   u32 pwsr;
+   u32 pad11;
+   u32 pwqbar;
+};
+
+struct rio_tx_desc {
+   u32 res1;
+   u32 saddr;
+   u32 dport;
+   u32 dattr;
+   u32 res2;
+   u32 res3;
+   u32 dwcnt;
+   u32 res4;
+};
+
+static u32 regs_win;
+static struct rio_atmu_regs *atmu_regs;
+static struct rio_atmu_regs *maint_atmu_regs;
+static struct rio_atmu_regs *dbell_atmu_regs;
+static u32 dbell_win;
+static u32 maint_win;
+static struct rio_msg_regs *msg_regs;
+
+static struct rio_dbell_ring {
+   void *virt;
+   dma_addr_t phys;
+} dbell_ring;
+
+static struct rio_msg_tx_ring {
+   void *virt;
+   dma_addr_t phys;
+   void *virt_buffer[RIO_MAX_TX_RING_SIZE];
+   dma_addr_t phys_buffer[RIO_MAX_TX_RING_SIZE];
+   int tx_slot;
+   int size;
+   void *dev_id;
+} msg_tx_ring;
+
+static struct rio_msg_rx_ring {
+   void *virt;
+   dma_addr_t phys;
+   void *virt_buffer[RIO_MAX_RX_RING_SIZE];
+   int rx_slot;
+   int size;
+   void *dev_id;
+} msg_rx_ring;
+
+/**
+ * mpc85xx_rio_doorbell_send - Send a MPC85xx doorbell message
+ * @index: ID of RapidIO interface
+ * @destid: Destination ID of target device
+ * @data: 16-bit info field of RapidIO doorbell message
+ *
+ * Sends a MPC85xx doorbell message. Returns %0 on success or
+ * %-EINVAL on failure.
+ */
+static int mpc85xx_rio_doorbell_send(int index, u16 destid, u16 data)
+{
+   pr_debug(mpc85xx_doorbell_send: index %d destid %4.4x data %4.4x\n,
+index, destid, data);
+   out_be32((void *)dbell_atmu_regs-rowtar, destid  22);
+   out_be16((void *)(dbell_win), data);
+
+   return 0;
+}
+
+/**
+ * mpc85xx_local_config_read - Generate a MPC85xx local config space read
+ * @index: ID of RapdiIO interface
+ * @offset: Offset

[PATCH] Fix the issue of fsldma driver's VIRT_TO_BUS dependence in Kconfig.

2007-11-14 Thread Zhang Wei
Remove virt_to_bus(), just using the saved phy address to match.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 drivers/dma/fsldma.c |   13 +
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 71e1c32..899b0c0 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -495,15 +495,20 @@ static struct dma_async_tx_descriptor 
*fsl_dma_prep_memcpy(
  */
 static void fsl_dma_update_completed_cookie(struct fsl_dma_chan *fsl_chan)
 {
-   struct fsl_desc_sw *cur_desc;
+   struct fsl_desc_sw *cur_desc, *desc;
dma_addr_t ld_phy;
 
ld_phy = get_cdar(fsl_chan) & FSL_DMA_NLDA_MASK;
 
if (ld_phy) {
-   cur_desc = (struct fsl_desc_sw *)bus_to_virt(ld_phy);
-
-   if (cur_desc->async_tx.cookie) {
+   cur_desc = NULL;
+   list_for_each_entry(desc, _chan->ld_queue, node)
+   if (desc->async_tx.phys == ld_phy) {
+   cur_desc = desc;
+   break;
+   }
+
+   if (cur_desc && cur_desc->async_tx.cookie) {
if (dma_is_idle(fsl_chan))
fsl_chan->completed_cookie =
cur_desc->async_tx.cookie;
-- 
1.5.2

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Fix the issue of fsldma driver's VIRT_TO_BUS dependence in Kconfig.

2007-11-14 Thread Zhang Wei
Remove virt_to_bus(), just using the saved phy address to match.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 drivers/dma/fsldma.c |   13 +
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 71e1c32..899b0c0 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -495,15 +495,20 @@ static struct dma_async_tx_descriptor 
*fsl_dma_prep_memcpy(
  */
 static void fsl_dma_update_completed_cookie(struct fsl_dma_chan *fsl_chan)
 {
-   struct fsl_desc_sw *cur_desc;
+   struct fsl_desc_sw *cur_desc, *desc;
dma_addr_t ld_phy;
 
ld_phy = get_cdar(fsl_chan)  FSL_DMA_NLDA_MASK;
 
if (ld_phy) {
-   cur_desc = (struct fsl_desc_sw *)bus_to_virt(ld_phy);
-
-   if (cur_desc-async_tx.cookie) {
+   cur_desc = NULL;
+   list_for_each_entry(desc, fsl_chan-ld_queue, node)
+   if (desc-async_tx.phys == ld_phy) {
+   cur_desc = desc;
+   break;
+   }
+
+   if (cur_desc  cur_desc-async_tx.cookie) {
if (dma_is_idle(fsl_chan))
fsl_chan-completed_cookie =
cur_desc-async_tx.cookie;
-- 
1.5.2

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] Add DMA engine driver for Freescale MPC85xx processors.

2007-10-30 Thread Zhang Wei
The driver implements DMA engine API for Freescale MPC85xx DMA
controller, which could be used by devices in the silicon.
The driver supports the Basic mode of Freescale MPC85xx DMA controller.
The MPC85xx processors supported include MPC8540/60, MPC8555, MPC8548,
MPC8641 and so on.
The MPC83xx(MPC8349, MPC8360) are also supported.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
Signed-off-by: Ebony Zhu <[EMAIL PROTECTED]>
---
 MAINTAINERS  |7 +
 drivers/dma/Kconfig  |   19 +-
 drivers/dma/Makefile |1 +
 drivers/dma/fsldma.c | 1089 ++
 drivers/dma/fsldma.h |  189 +
 5 files changed, 1304 insertions(+), 1 deletions(-)
 create mode 100644 drivers/dma/fsldma.c
 create mode 100644 drivers/dma/fsldma.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 231bda2..f713655 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1532,6 +1532,13 @@ L:   [EMAIL PROTECTED] (subscribers-only)
 W: http://linux-fbdev.sourceforge.net/
 S: Maintained
 
+FREESCALE DMA DRIVER
+P;     Zhang Wei
+M: [EMAIL PROTECTED]
+L: [EMAIL PROTECTED]
+L: linux-kernel@vger.kernel.org
+S: Maintained
+
 FREESCALE SOC FS_ENET DRIVER
 P: Pantelis Antoniou
 M: [EMAIL PROTECTED]
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 9c91b0f..6c930bd 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -4,7 +4,7 @@
 
 menuconfig DMADEVICES
bool "DMA Offload Engine support"
-   depends on (PCI && X86) || ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX
+   depends on (PCI && X86) || ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX 
|| PPC
help
  Intel(R) offload engines enable offloading memory copies in the
  network stack and RAID operations in the MD driver.
@@ -34,6 +34,23 @@ config INTEL_IOP_ADMA
help
  Enable support for the Intel(R) IOP Series RAID engines.
 
+config FSL_DMA
+   bool "Freescale MPC85xx/MPC83xx DMA support"
+   depends on PPC
+   select DMA_ENGINE
+   ---help---
+ Enable support for the Freescale DMA engine. Now, it support
+ MPC8560/40, MPC8555, MPC8548 and MPC8641 processors.
+ The MPC8349, MPC8360 is also supported.
+
+config FSL_DMA_SELFTEST
+   bool "Enable the self test for each DMA channel"
+   depends on FSL_DMA
+   default y
+   ---help---
+ Enable the self test for each DMA channel. A self test will be
+ performed after the channel probed to ensure the DMA works well.
+
 config DMA_ENGINE
bool
 
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index b152cd8..c8036d9 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_NET_DMA) += iovlock.o
 obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o
 ioatdma-objs := ioat.o ioat_dma.o ioat_dca.o
 obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
+obj-$(CONFIG_FSL_DMA) += fsldma.o
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
new file mode 100644
index 000..71e1c32
--- /dev/null
+++ b/drivers/dma/fsldma.c
@@ -0,0 +1,1089 @@
+/*
+ * Freescale MPC85xx, MPC83xx DMA Engine support
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author:
+ *   Zhang Wei <[EMAIL PROTECTED]>, Jul 2007
+ *   Ebony Zhu <[EMAIL PROTECTED]>, May 2007
+ *
+ * Description:
+ *   DMA engine driver for Freescale MPC8540 DMA controller, which is
+ *   also fit for MPC8560, MPC8555, MPC8548, MPC8641, and etc.
+ *   The support for MPC8349 DMA contorller is also added.
+ *
+ * This 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "fsldma.h"
+
+static void dma_init(struct fsl_dma_chan *fsl_chan)
+{
+   /* Reset the channel */
+   DMA_OUT(fsl_chan, _chan->reg_base->mr, 0, 32);
+
+   switch (fsl_chan->feature & FSL_DMA_IP_MASK) {
+   case FSL_DMA_IP_85XX:
+   /* Set the channel to below modes:
+* EIE - Error interrupt enable
+* EOSIE - End of segments interrupt enable (basic mode)
+* EOLNIE - End of links interrupt enable
+*/
+   DMA_OUT(fsl_chan, _chan->reg_base->mr, FSL_DMA_MR_EIE
+   | FSL_DMA_MR_EOLNIE | FSL_DMA_MR_EOSIE, 32);
+   break;
+   case FSL_DMA_IP_83XX:
+   /* Set the channel to below modes:
+* EOTIE - End-of-transfer interrupt enable
+*/
+   DMA_OUT(fsl_chan, _chan->reg_base->mr, FSL_DMA_MR_EOTIE,
+   32);
+   break;
+   }
+
+}
+
+static vo

RE: [PATCH 0/5 v3] Porting RapidIO driver from ppc to powerpc architecture and adding memory mapped RapidIO driver.

2007-10-30 Thread Zhang Wei-r63237
Yes, I'm working on it. Do not worry about it.

Wei. 

> -Original Message-
> From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, October 30, 2007 4:31 AM
> To: [EMAIL PROTECTED]
> Cc: Zhang Wei-r63237; [EMAIL PROTECTED]; 
> [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 0/5 v3] Porting RapidIO driver from ppc 
> to powerpc architecture and adding memory mapped RapidIO driver.
> 
> 
> On Oct 29, 2007, at 2:38 PM, Phil Terry wrote:
> 
> > Can anyone tell me what the status of these are? What kernel  
> > release are
> > they targetted for? Currently I'm trying to work with 2.6.23 plus  
> > these
> > patches locally.
> 
> hopefully 2.6.25.  I'd like to get the documentation updates in  
> 2.6.24 if we have agreement on them.
> 
> - k
> 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 0/5 v3] Porting RapidIO driver from ppc to powerpc architecture and adding memory mapped RapidIO driver.

2007-10-30 Thread Zhang Wei-r63237
Yes, I'm working on it. Do not worry about it.

Wei. 

 -Original Message-
 From: Kumar Gala [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, October 30, 2007 4:31 AM
 To: [EMAIL PROTECTED]
 Cc: Zhang Wei-r63237; [EMAIL PROTECTED]; 
 [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
 linux-kernel@vger.kernel.org
 Subject: Re: [PATCH 0/5 v3] Porting RapidIO driver from ppc 
 to powerpc architecture and adding memory mapped RapidIO driver.
 
 
 On Oct 29, 2007, at 2:38 PM, Phil Terry wrote:
 
  Can anyone tell me what the status of these are? What kernel  
  release are
  they targetted for? Currently I'm trying to work with 2.6.23 plus  
  these
  patches locally.
 
 hopefully 2.6.25.  I'd like to get the documentation updates in  
 2.6.24 if we have agreement on them.
 
 - k
 
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] Add DMA engine driver for Freescale MPC85xx processors.

2007-10-30 Thread Zhang Wei
The driver implements DMA engine API for Freescale MPC85xx DMA
controller, which could be used by devices in the silicon.
The driver supports the Basic mode of Freescale MPC85xx DMA controller.
The MPC85xx processors supported include MPC8540/60, MPC8555, MPC8548,
MPC8641 and so on.
The MPC83xx(MPC8349, MPC8360) are also supported.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
Signed-off-by: Ebony Zhu [EMAIL PROTECTED]
---
 MAINTAINERS  |7 +
 drivers/dma/Kconfig  |   19 +-
 drivers/dma/Makefile |1 +
 drivers/dma/fsldma.c | 1089 ++
 drivers/dma/fsldma.h |  189 +
 5 files changed, 1304 insertions(+), 1 deletions(-)
 create mode 100644 drivers/dma/fsldma.c
 create mode 100644 drivers/dma/fsldma.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 231bda2..f713655 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1532,6 +1532,13 @@ L:   [EMAIL PROTECTED] (subscribers-only)
 W: http://linux-fbdev.sourceforge.net/
 S: Maintained
 
+FREESCALE DMA DRIVER
+P; Zhang Wei
+M: [EMAIL PROTECTED]
+L: [EMAIL PROTECTED]
+L: linux-kernel@vger.kernel.org
+S: Maintained
+
 FREESCALE SOC FS_ENET DRIVER
 P: Pantelis Antoniou
 M: [EMAIL PROTECTED]
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 9c91b0f..6c930bd 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -4,7 +4,7 @@
 
 menuconfig DMADEVICES
bool DMA Offload Engine support
-   depends on (PCI  X86) || ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX
+   depends on (PCI  X86) || ARCH_IOP32X || ARCH_IOP33X || ARCH_IOP13XX 
|| PPC
help
  Intel(R) offload engines enable offloading memory copies in the
  network stack and RAID operations in the MD driver.
@@ -34,6 +34,23 @@ config INTEL_IOP_ADMA
help
  Enable support for the Intel(R) IOP Series RAID engines.
 
+config FSL_DMA
+   bool Freescale MPC85xx/MPC83xx DMA support
+   depends on PPC
+   select DMA_ENGINE
+   ---help---
+ Enable support for the Freescale DMA engine. Now, it support
+ MPC8560/40, MPC8555, MPC8548 and MPC8641 processors.
+ The MPC8349, MPC8360 is also supported.
+
+config FSL_DMA_SELFTEST
+   bool Enable the self test for each DMA channel
+   depends on FSL_DMA
+   default y
+   ---help---
+ Enable the self test for each DMA channel. A self test will be
+ performed after the channel probed to ensure the DMA works well.
+
 config DMA_ENGINE
bool
 
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index b152cd8..c8036d9 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_NET_DMA) += iovlock.o
 obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o
 ioatdma-objs := ioat.o ioat_dma.o ioat_dca.o
 obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
+obj-$(CONFIG_FSL_DMA) += fsldma.o
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
new file mode 100644
index 000..71e1c32
--- /dev/null
+++ b/drivers/dma/fsldma.c
@@ -0,0 +1,1089 @@
+/*
+ * Freescale MPC85xx, MPC83xx DMA Engine support
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author:
+ *   Zhang Wei [EMAIL PROTECTED], Jul 2007
+ *   Ebony Zhu [EMAIL PROTECTED], May 2007
+ *
+ * Description:
+ *   DMA engine driver for Freescale MPC8540 DMA controller, which is
+ *   also fit for MPC8560, MPC8555, MPC8548, MPC8641, and etc.
+ *   The support for MPC8349 DMA contorller is also added.
+ *
+ * This 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.
+ *
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/pci.h
+#include linux/interrupt.h
+#include linux/dmaengine.h
+#include linux/delay.h
+#include linux/dma-mapping.h
+#include linux/dmapool.h
+#include linux/of_platform.h
+
+#include fsldma.h
+
+static void dma_init(struct fsl_dma_chan *fsl_chan)
+{
+   /* Reset the channel */
+   DMA_OUT(fsl_chan, fsl_chan-reg_base-mr, 0, 32);
+
+   switch (fsl_chan-feature  FSL_DMA_IP_MASK) {
+   case FSL_DMA_IP_85XX:
+   /* Set the channel to below modes:
+* EIE - Error interrupt enable
+* EOSIE - End of segments interrupt enable (basic mode)
+* EOLNIE - End of links interrupt enable
+*/
+   DMA_OUT(fsl_chan, fsl_chan-reg_base-mr, FSL_DMA_MR_EIE
+   | FSL_DMA_MR_EOLNIE | FSL_DMA_MR_EOSIE, 32);
+   break;
+   case FSL_DMA_IP_83XX:
+   /* Set the channel to below modes:
+* EOTIE - End-of-transfer interrupt enable
+*/
+   DMA_OUT(fsl_chan, fsl_chan-reg_base-mr, FSL_DMA_MR_EOTIE,
+   32);
+   break

RE: [PATCH 5/5] Add DMA engine driver for Freescale MPC85xxprocessors.

2007-09-13 Thread Zhang Wei-r63237
Hi, 

> > +static void fsl_dma_set_src(dma_addr_t addr,
> > +   struct dma_async_tx_descriptor 
> *tx, int index)
> > +{
> 
> What is index supposed to mean?  It's not used, or documented 
> anywhere than
> I can see.

I've also got more document here. Hi, Dan, could you give me some
explanation about this API? :)

> 
> > +   else {
> > +   /* Run the link descriptor callback function */
> > +   if (desc->async_tx.callback) {
> > +   
> spin_unlock_irqrestore(_chan->desc_lock,
> > +   flags);
> > +   dev_dbg(fsl_chan->device->dev,
> > +   "link descriptor %p 
> callback\n", desc);
> > +   desc->async_tx.callback(
> > +   
> desc->async_tx.callback_param);
> > +   
> spin_lock_irqsave(_chan->desc_lock, flags);
> 
> After dropping the lock, you can no longer assume that your 
> iterator is
> still valid; you need to work off of the list head.
> 

list_for_each_entry_safe() is used here. I think the safe should be ok.
:P

> > +   /* Find the first un-transfer desciptor */
> > +   for (ld_node = fsl_chan->ld_queue.next;
> > +   (ld_node != _chan->ld_queue)
> > +   && (DMA_SUCCESS == dma_async_is_complete(
> > +   
> to_fsl_desc(ld_node)->async_tx.cookie,
> > +   fsl_chan->completed_cookie,
> > +   fsl_chan->common.cookie));
> > +   ld_node = ld_node->next);
> 
> Call fsl_dma_is_complete directly, don't waste time going through the
> virtual call.
> 
> And you have a recursive lock usage here; fsl_dma_is_complete calls
> fsl_chan_ld_cleanup, which acquires desc_lock, but you 
> already have it.
> 
> Couldn't you just call fsl_chan_ld_cleanup, and then check 
> what's at the
> head of the list?
> 

I'll split interrupt and poll here.

> > +static irqreturn_t fsl_dma_do_interrupt(int irq, void *data)
> > +{
> > +   struct fsl_dma_device *fdev = (struct fsl_dma_device *)data;
> > +   struct fsl_dma_chan *fsl_chan = NULL;
> > +   u32 gsr;
> > +   int ch_nr;
> > +   struct dma_chan *int_chan;
> > +
> > +   gsr = (fdev->feature & FSL_DMA_BIG_ENDIAN) ? 
> in_be32(fdev->reg_base)
> > +   : in_le32(fdev->reg_base);
> > +   ch_nr = (32 - ffs(gsr)) / 8;
> > +
> > +   list_for_each_entry(int_chan, >common.channels, 
> device_node)
> > +   if (to_fsl_chan(int_chan)->id == ch_nr)
> > +   fsl_chan = to_fsl_chan(int_chan);
> 
> Why not use an array of channels?

The list is used in dma engine core file. And it's possible that there
are not all channel listed in dts and array.

> > +
> > +   return fsl_chan ? fsl_dma_chan_do_interrupt(irq, 
> fsl_chan) : IRQ_NONE;
> > +
> > +}
> > +
> > +static void dma_do_tasklet(unsigned long unused)
> > +{
> > +   struct fsl_desc_sw *desc, *_desc;
> > +   unsigned long flags;
> > +
> > +   spin_lock_irqsave(_ln_lock, flags);
> > +   list_for_each_entry_safe(desc, _desc, _ln_chain, node) {
> > +   struct fsl_dma_chan *fsl_chan =
> > +   
> to_fsl_chan(desc->async_tx.chan);
> > +   /* Run the link descriptor callback function */
> > +   if (desc->async_tx.callback) {
> > +   spin_unlock_irqrestore(_ln_lock, flags);
> > +   dev_dbg(fsl_chan->device->dev,
> > +   "dma_tasklet: link descriptor 
> %p callback\n",
> > +   desc);
> > +   desc->async_tx.callback(
> > +   desc->async_tx.callback_param);
> > +   spin_lock_irqsave(_ln_lock, flags);
> > +   }
> > +   /* Recycle it! */
> > +   list_del(>node);
> 
> You should remove it from the list before dropping the lock, 
> as otherwise
> something else could come along and remove it again.

All right!

> 
> > +   if (strcmp(match->compatible, "fsl,mpc8540-dma-channel") == 0)
> > +   new_fsl_chan->feature = FSL_DMA_IP_86XX | 
> FSL_DMA_BIG_ENDIAN;
> 
> Shouldn't it be 85XX, to be consistent?
> 
> > +   else if (strcmp(match->compatible, 
> "fsl,mpc8349-dma-channel") == 0)
> > +   new_fsl_chan->feature = FSL_DMA_IP_83XX | 
> FSL_DMA_LITTLE_ENDIAN;
> 
> You could have the features be part of the match struct, so 
> you don't have
> to do extra strcmps.
> 

Can I use the data field of struct of_device_id?

> 
> > +static struct of_device_id of_fsl_dma_ids[] = {
> > +   { .compatible = "fsl,dma", },
> > +};
> 
> Why do we need to bind to the parent node at all?

Yes, the MPC83xx should get interrupt source from DMA device register.

> 
> > +/* There is no asm instructions for 64 bits reverse loads 
> and stores */
> > +static u64 in_le64(const u64 __iomem *addr)
> > +{
> 

RE: [PATCH 5/5] Add DMA engine driver for Freescale MPC85xxprocessors.

2007-09-13 Thread Zhang Wei-r63237
Hi, 

  +static void fsl_dma_set_src(dma_addr_t addr,
  +   struct dma_async_tx_descriptor 
 *tx, int index)
  +{
 
 What is index supposed to mean?  It's not used, or documented 
 anywhere than
 I can see.

I've also got more document here. Hi, Dan, could you give me some
explanation about this API? :)

 
  +   else {
  +   /* Run the link descriptor callback function */
  +   if (desc-async_tx.callback) {
  +   
 spin_unlock_irqrestore(fsl_chan-desc_lock,
  +   flags);
  +   dev_dbg(fsl_chan-device-dev,
  +   link descriptor %p 
 callback\n, desc);
  +   desc-async_tx.callback(
  +   
 desc-async_tx.callback_param);
  +   
 spin_lock_irqsave(fsl_chan-desc_lock, flags);
 
 After dropping the lock, you can no longer assume that your 
 iterator is
 still valid; you need to work off of the list head.
 

list_for_each_entry_safe() is used here. I think the safe should be ok.
:P

  +   /* Find the first un-transfer desciptor */
  +   for (ld_node = fsl_chan-ld_queue.next;
  +   (ld_node != fsl_chan-ld_queue)
  +(DMA_SUCCESS == dma_async_is_complete(
  +   
 to_fsl_desc(ld_node)-async_tx.cookie,
  +   fsl_chan-completed_cookie,
  +   fsl_chan-common.cookie));
  +   ld_node = ld_node-next);
 
 Call fsl_dma_is_complete directly, don't waste time going through the
 virtual call.
 
 And you have a recursive lock usage here; fsl_dma_is_complete calls
 fsl_chan_ld_cleanup, which acquires desc_lock, but you 
 already have it.
 
 Couldn't you just call fsl_chan_ld_cleanup, and then check 
 what's at the
 head of the list?
 

I'll split interrupt and poll here.

  +static irqreturn_t fsl_dma_do_interrupt(int irq, void *data)
  +{
  +   struct fsl_dma_device *fdev = (struct fsl_dma_device *)data;
  +   struct fsl_dma_chan *fsl_chan = NULL;
  +   u32 gsr;
  +   int ch_nr;
  +   struct dma_chan *int_chan;
  +
  +   gsr = (fdev-feature  FSL_DMA_BIG_ENDIAN) ? 
 in_be32(fdev-reg_base)
  +   : in_le32(fdev-reg_base);
  +   ch_nr = (32 - ffs(gsr)) / 8;
  +
  +   list_for_each_entry(int_chan, fdev-common.channels, 
 device_node)
  +   if (to_fsl_chan(int_chan)-id == ch_nr)
  +   fsl_chan = to_fsl_chan(int_chan);
 
 Why not use an array of channels?

The list is used in dma engine core file. And it's possible that there
are not all channel listed in dts and array.

  +
  +   return fsl_chan ? fsl_dma_chan_do_interrupt(irq, 
 fsl_chan) : IRQ_NONE;
  +
  +}
  +
  +static void dma_do_tasklet(unsigned long unused)
  +{
  +   struct fsl_desc_sw *desc, *_desc;
  +   unsigned long flags;
  +
  +   spin_lock_irqsave(recy_ln_lock, flags);
  +   list_for_each_entry_safe(desc, _desc, recy_ln_chain, node) {
  +   struct fsl_dma_chan *fsl_chan =
  +   
 to_fsl_chan(desc-async_tx.chan);
  +   /* Run the link descriptor callback function */
  +   if (desc-async_tx.callback) {
  +   spin_unlock_irqrestore(recy_ln_lock, flags);
  +   dev_dbg(fsl_chan-device-dev,
  +   dma_tasklet: link descriptor 
 %p callback\n,
  +   desc);
  +   desc-async_tx.callback(
  +   desc-async_tx.callback_param);
  +   spin_lock_irqsave(recy_ln_lock, flags);
  +   }
  +   /* Recycle it! */
  +   list_del(desc-node);
 
 You should remove it from the list before dropping the lock, 
 as otherwise
 something else could come along and remove it again.

All right!

 
  +   if (strcmp(match-compatible, fsl,mpc8540-dma-channel) == 0)
  +   new_fsl_chan-feature = FSL_DMA_IP_86XX | 
 FSL_DMA_BIG_ENDIAN;
 
 Shouldn't it be 85XX, to be consistent?
 
  +   else if (strcmp(match-compatible, 
 fsl,mpc8349-dma-channel) == 0)
  +   new_fsl_chan-feature = FSL_DMA_IP_83XX | 
 FSL_DMA_LITTLE_ENDIAN;
 
 You could have the features be part of the match struct, so 
 you don't have
 to do extra strcmps.
 

Can I use the data field of struct of_device_id?

 
  +static struct of_device_id of_fsl_dma_ids[] = {
  +   { .compatible = fsl,dma, },
  +};
 
 Why do we need to bind to the parent node at all?

Yes, the MPC83xx should get interrupt source from DMA device register.

 
  +/* There is no asm instructions for 64 bits reverse loads 
 and stores */
  +static u64 in_le64(const u64 __iomem *addr)
  +{
  +   return le64_to_cpu(in_be64(addr));
  +}
  +
  +static void out_le64(u64 __iomem *addr, u64 val)
  +{
  +   out_be64(addr, cpu_to_le64(val));
  +}
  +#endif
 
 You can use asm instructions for this, as 

RE: [PATCH 5/5] Add DMA engine driver for Freescale MPC85xx processors.

2007-09-11 Thread Zhang Wei-r63237
Hi, Dan,

Does I have followed your new API? :-)

> > ---
> Greetings,
> 
> Please copy me on any updates to this driver, drivers/dma, or 
> crypto/async_tx.

Ok.

> 
> Below are a few review comments...
> 
> Regards,
> Dan
> 
> > +/**
> > + * fsl_dma_alloc_descriptor - Allocate descriptor from 
> channel's DMA pool.
> > + *
> > + * Return - The descriptor allocated. NULL for failed.
> > + */
> > +static struct fsl_desc_sw *fsl_dma_alloc_descriptor(
> > +   struct fsl_dma_chan 
> *fsl_chan,
> > +   gfp_t flags)
> > +{
> > +   dma_addr_t pdesc;
> > +   struct fsl_desc_sw *desc_sw;
> > +
> > +   desc_sw = dma_pool_alloc(fsl_chan->desc_pool, 
> flags, );
> > +   if (desc_sw) {
> > +   memset(desc_sw, 0, sizeof(struct fsl_desc_sw));
> > +   dma_async_tx_descriptor_init(_sw->async_tx,
> > +   _chan->common);
> > +   desc_sw->async_tx.tx_set_src = fsl_dma_set_src;
> > +   desc_sw->async_tx.tx_set_dest = fsl_dma_set_dest;
> > +   desc_sw->async_tx.tx_submit = fsl_dma_tx_submit;
> > +   INIT_LIST_HEAD(_sw->async_tx.tx_list);
> > +   desc_sw->async_tx.phys = pdesc;
> > +   }
> > +
> > +   return desc_sw;
> > +}
> 
> I suggest pre-allocating the descriptors:
> 1/ It alleviates the need to initialize these async_tx fields 
> which never change

The dma pool has already stored the descriptors in it's list,

> 2/ The GFP_ATOMIC allocation can be removed.
> 

Ok.

> iop-adma gets by with one PAGE_SIZE buffer (128 descriptors).
> 
> [..]
> > +static irqreturn_t fsl_dma_chan_do_interrupt(int irq, void *data)
> > +{
> > +   struct fsl_dma_chan *fsl_chan = (struct fsl_dma_chan *)data;
> > +   dma_addr_t stat;
> > +
> > +   stat = get_sr(fsl_chan);
> > +   dev_dbg(fsl_chan->device->dev, "event: channel %d, 
> stat = 0x%x\n",
> > +   fsl_chan->id, stat);
> > +   set_sr(fsl_chan, stat); /* Clear the event 
> register */
> > +
> > +   stat &= ~(FSL_DMA_SR_CB | FSL_DMA_SR_CH);
> > +   if (!stat)
> > +   return IRQ_NONE;
> > +
> > +   /* If the link descriptor segment transfer finishes,
> > +* we will recycle the used descriptor.
> > +*/
> > +   if (stat & FSL_DMA_SR_EOSI) {
> > +   dev_dbg(fsl_chan->device->dev, "event: 
> End-of-segments INT\n");
> > +   dev_dbg(fsl_chan->device->dev, "event: 
> clndar 0x%016llx, "
> > +   "nlndar 0x%016llx\n", 
> (u64)get_cdar(fsl_chan),
> > +   (u64)get_ndar(fsl_chan));
> > +   stat &= ~FSL_DMA_SR_EOSI;
> > +   fsl_chan_ld_cleanup(fsl_chan, 1);
> > +   }
> > +
> > +   /* If it current transfer is the end-of-transfer,
> > +* we should clear the Channel Start bit for
> > +* prepare next transfer.
> > +*/
> > +   if (stat & (FSL_DMA_SR_EOLNI | FSL_DMA_SR_EOCDI)) {
> > +   dev_dbg(fsl_chan->device->dev, "event: 
> End-of-link INT\n");
> > +   stat &= ~FSL_DMA_SR_EOLNI;
> > +   fsl_chan_xfer_ld_queue(fsl_chan);
> > +   }
> > +
> > +   if (stat)
> > +   dev_dbg(fsl_chan->device->dev, "event: 
> unhandled sr 0x%02x\n",
> > +   stat);
> > +
> > +   dev_dbg(fsl_chan->device->dev, "event: Exit\n");
> > +   tasklet_hi_schedule(_tasklet);
> > +   return IRQ_HANDLED;
> > +}
> 
> This driver implements locking and callbacks inconsistently with how
> it is done in ioatdma and iop-adma.  The big changes are that all
> locks have been upgraded from 'spin_lock_bh' to 'spin_lock_irqsave',
> and async_tx callbacks can happen in irq context.  I would like to
> keep everything in bottom-half context to lessen the restrictions on
> what async_tx clients can perform in their callback routines.  What
> are the implications of moving 'fsl_chan_ld_cleanup' to the tasklet
> and changing the 'tasklet_hi_schedule' to 'tasklet_schedule'?

A good suggestion :), I need some investigation here.

> 
> [..]
> > +static struct dma_chan 
> *of_find_dma_chan_by_phandle(phandle phandle)
> > +{
> > +   struct device_node *np;
> > +   struct dma_chan *chan;
> > +   struct fsl_dma_device *fdev;
> > +
> > +   np = of_find_node_by_phandle(phandle);
> > +   if (!np || !of_device_is_compatible(np->parent, "fsl,dma"))
> > +   return NULL;
> > +
> > +   fdev = 
> dev_get_drvdata(_find_device_by_node(np->parent)->dev);
> > +
> > +   list_for_each_entry(chan, >common.channels, 
> device_node)
> > +   if 
> (to_of_device(to_fsl_chan(chan)->chan_dev)->node == np)
> > +   return chan;
> > +   return NULL;
> > +}
> > +EXPORT_SYMBOL(of_find_dma_chan_by_phandle);
> 
> This routine implies that there 

RE: [PATCH 5/5] Add DMA engine driver for Freescale MPC85xx processors.

2007-09-11 Thread Zhang Wei-r63237
> 
> If this is experimental, perhaps you should mark the depends line as
> such
>   depends on on DMA_ENGINE && PPC && EXPERIMENTAL

I'll add EXPERIMENTAL for MPC83xx only.

> 
> [...]
> 
> >+
> >+fsl_dma_memcpy_issue_pending(chan);
> >+while (fsl_dma_is_complete(chan, cookie, NULL, NULL)
> >+!= DMA_SUCCESS);
> 
> Again, is it possible to hang your thread here?
> 
> [...]

I'll add msleep here.

Thanks!

- zw
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 5/5] Add DMA engine driver for Freescale MPC85xx processors.

2007-09-11 Thread Zhang Wei-r63237
Hi, 
> --- /dev/null
> > +++ b/drivers/dma/fsldma.c
> > @@ -0,0 +1,995 @@
> 
> Thanks for using kernel-doc notation.  However, ...
> 
> > +/**
> > + * fsl_dma_alloc_descriptor - Allocate descriptor from 
> channel's DMA pool.
> 
> Function parameters need to be listed & described here.
> See Documentation/kernel-doc-nano-HOWTO.txt or other source files
> for examples.
> 
> (Applies to all documented function interfaces here.)

All right, I'll add full descriptions here. :P

> 
> > + *
> > + * Return - The descriptor allocated. NULL for failed.
> > + */
> > +static struct fsl_desc_sw *fsl_dma_alloc_descriptor(
> > +   struct fsl_dma_chan *fsl_chan,
> > +   gfp_t flags)
> > +{
> ...
> > +}
> 
> > +/**
> > + * fsl_chan_xfer_ld_queue -- Transfer the link descriptors 
> in channel
> > + *   ld_queue.
> 
> The function's "short description" (unfortunately) must be on only one
> line.  E.g.:
> 
>  * fsl_chan_xfer_ld_queue - Transfer link descriptors in 
> channel ld_queue.
> 

How about it's length greater than 80?

> > + */
> > +static void fsl_chan_xfer_ld_queue(struct fsl_dma_chan *fsl_chan)
> > +{
> ...
> > +}
> 
> > diff --git a/drivers/dma/fsldma.h b/drivers/dma/fsldma.h
> > new file mode 100644
> > index 000..05be9ed
> > --- /dev/null
> > +++ b/drivers/dma/fsldma.h
> > @@ -0,0 +1,188 @@
> > +struct fsl_dma_chan_regs {
> > +   __mix32 mr; /* 0x00 - Mode Register */
> > +   __mix32 sr; /* 0x04 - Status Register */
> > +   __mix64 cdar;   /* 0x08 - Cureent descriptor 
> address register */
> 
>   Current
> 

I'll fix it.

Thanks!
- zw
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 5/5] Add DMA engine driver for Freescale MPC85xx processors.

2007-09-11 Thread Zhang Wei-r63237
Hi, 
 --- /dev/null
  +++ b/drivers/dma/fsldma.c
  @@ -0,0 +1,995 @@
 
 Thanks for using kernel-doc notation.  However, ...
 
  +/**
  + * fsl_dma_alloc_descriptor - Allocate descriptor from 
 channel's DMA pool.
 
 Function parameters need to be listed  described here.
 See Documentation/kernel-doc-nano-HOWTO.txt or other source files
 for examples.
 
 (Applies to all documented function interfaces here.)

All right, I'll add full descriptions here. :P

 
  + *
  + * Return - The descriptor allocated. NULL for failed.
  + */
  +static struct fsl_desc_sw *fsl_dma_alloc_descriptor(
  +   struct fsl_dma_chan *fsl_chan,
  +   gfp_t flags)
  +{
 ...
  +}
 
  +/**
  + * fsl_chan_xfer_ld_queue -- Transfer the link descriptors 
 in channel
  + *   ld_queue.
 
 The function's short description (unfortunately) must be on only one
 line.  E.g.:
 
  * fsl_chan_xfer_ld_queue - Transfer link descriptors in 
 channel ld_queue.
 

How about it's length greater than 80?

  + */
  +static void fsl_chan_xfer_ld_queue(struct fsl_dma_chan *fsl_chan)
  +{
 ...
  +}
 
  diff --git a/drivers/dma/fsldma.h b/drivers/dma/fsldma.h
  new file mode 100644
  index 000..05be9ed
  --- /dev/null
  +++ b/drivers/dma/fsldma.h
  @@ -0,0 +1,188 @@
  +struct fsl_dma_chan_regs {
  +   __mix32 mr; /* 0x00 - Mode Register */
  +   __mix32 sr; /* 0x04 - Status Register */
  +   __mix64 cdar;   /* 0x08 - Cureent descriptor 
 address register */
 
   Current
 

I'll fix it.

Thanks!
- zw
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 5/5] Add DMA engine driver for Freescale MPC85xx processors.

2007-09-11 Thread Zhang Wei-r63237
 
 If this is experimental, perhaps you should mark the depends line as
 such
   depends on on DMA_ENGINE  PPC  EXPERIMENTAL

I'll add EXPERIMENTAL for MPC83xx only.

 
 [...]
 
 +
 +fsl_dma_memcpy_issue_pending(chan);
 +while (fsl_dma_is_complete(chan, cookie, NULL, NULL)
 +!= DMA_SUCCESS);
 
 Again, is it possible to hang your thread here?
 
 [...]

I'll add msleep here.

Thanks!

- zw
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 5/5] Add DMA engine driver for Freescale MPC85xx processors.

2007-09-11 Thread Zhang Wei-r63237
Hi, Dan,

Does I have followed your new API? :-)

  ---
 Greetings,
 
 Please copy me on any updates to this driver, drivers/dma, or 
 crypto/async_tx.

Ok.

 
 Below are a few review comments...
 
 Regards,
 Dan
 
  +/**
  + * fsl_dma_alloc_descriptor - Allocate descriptor from 
 channel's DMA pool.
  + *
  + * Return - The descriptor allocated. NULL for failed.
  + */
  +static struct fsl_desc_sw *fsl_dma_alloc_descriptor(
  +   struct fsl_dma_chan 
 *fsl_chan,
  +   gfp_t flags)
  +{
  +   dma_addr_t pdesc;
  +   struct fsl_desc_sw *desc_sw;
  +
  +   desc_sw = dma_pool_alloc(fsl_chan-desc_pool, 
 flags, pdesc);
  +   if (desc_sw) {
  +   memset(desc_sw, 0, sizeof(struct fsl_desc_sw));
  +   dma_async_tx_descriptor_init(desc_sw-async_tx,
  +   fsl_chan-common);
  +   desc_sw-async_tx.tx_set_src = fsl_dma_set_src;
  +   desc_sw-async_tx.tx_set_dest = fsl_dma_set_dest;
  +   desc_sw-async_tx.tx_submit = fsl_dma_tx_submit;
  +   INIT_LIST_HEAD(desc_sw-async_tx.tx_list);
  +   desc_sw-async_tx.phys = pdesc;
  +   }
  +
  +   return desc_sw;
  +}
 
 I suggest pre-allocating the descriptors:
 1/ It alleviates the need to initialize these async_tx fields 
 which never change

The dma pool has already stored the descriptors in it's list,

 2/ The GFP_ATOMIC allocation can be removed.
 

Ok.

 iop-adma gets by with one PAGE_SIZE buffer (128 descriptors).
 
 [..]
  +static irqreturn_t fsl_dma_chan_do_interrupt(int irq, void *data)
  +{
  +   struct fsl_dma_chan *fsl_chan = (struct fsl_dma_chan *)data;
  +   dma_addr_t stat;
  +
  +   stat = get_sr(fsl_chan);
  +   dev_dbg(fsl_chan-device-dev, event: channel %d, 
 stat = 0x%x\n,
  +   fsl_chan-id, stat);
  +   set_sr(fsl_chan, stat); /* Clear the event 
 register */
  +
  +   stat = ~(FSL_DMA_SR_CB | FSL_DMA_SR_CH);
  +   if (!stat)
  +   return IRQ_NONE;
  +
  +   /* If the link descriptor segment transfer finishes,
  +* we will recycle the used descriptor.
  +*/
  +   if (stat  FSL_DMA_SR_EOSI) {
  +   dev_dbg(fsl_chan-device-dev, event: 
 End-of-segments INT\n);
  +   dev_dbg(fsl_chan-device-dev, event: 
 clndar 0x%016llx, 
  +   nlndar 0x%016llx\n, 
 (u64)get_cdar(fsl_chan),
  +   (u64)get_ndar(fsl_chan));
  +   stat = ~FSL_DMA_SR_EOSI;
  +   fsl_chan_ld_cleanup(fsl_chan, 1);
  +   }
  +
  +   /* If it current transfer is the end-of-transfer,
  +* we should clear the Channel Start bit for
  +* prepare next transfer.
  +*/
  +   if (stat  (FSL_DMA_SR_EOLNI | FSL_DMA_SR_EOCDI)) {
  +   dev_dbg(fsl_chan-device-dev, event: 
 End-of-link INT\n);
  +   stat = ~FSL_DMA_SR_EOLNI;
  +   fsl_chan_xfer_ld_queue(fsl_chan);
  +   }
  +
  +   if (stat)
  +   dev_dbg(fsl_chan-device-dev, event: 
 unhandled sr 0x%02x\n,
  +   stat);
  +
  +   dev_dbg(fsl_chan-device-dev, event: Exit\n);
  +   tasklet_hi_schedule(dma_tasklet);
  +   return IRQ_HANDLED;
  +}
 
 This driver implements locking and callbacks inconsistently with how
 it is done in ioatdma and iop-adma.  The big changes are that all
 locks have been upgraded from 'spin_lock_bh' to 'spin_lock_irqsave',
 and async_tx callbacks can happen in irq context.  I would like to
 keep everything in bottom-half context to lessen the restrictions on
 what async_tx clients can perform in their callback routines.  What
 are the implications of moving 'fsl_chan_ld_cleanup' to the tasklet
 and changing the 'tasklet_hi_schedule' to 'tasklet_schedule'?

A good suggestion :), I need some investigation here.

 
 [..]
  +static struct dma_chan 
 *of_find_dma_chan_by_phandle(phandle phandle)
  +{
  +   struct device_node *np;
  +   struct dma_chan *chan;
  +   struct fsl_dma_device *fdev;
  +
  +   np = of_find_node_by_phandle(phandle);
  +   if (!np || !of_device_is_compatible(np-parent, fsl,dma))
  +   return NULL;
  +
  +   fdev = 
 dev_get_drvdata(of_find_device_by_node(np-parent)-dev);
  +
  +   list_for_each_entry(chan, fdev-common.channels, 
 device_node)
  +   if 
 (to_of_device(to_fsl_chan(chan)-chan_dev)-node == np)
  +   return chan;
  +   return NULL;
  +}
  +EXPORT_SYMBOL(of_find_dma_chan_by_phandle);
 
 This routine implies that there is a piece of code somewhere that
 wants to select which channels it can use.  A similar effect can be
 achieved by registering a dma_client with the dmaengine interface
 ('dma_async_client_register').  Then when the client code makes a call
 to 

[PATCH 5/5] Add DMA engine driver for Freescale MPC85xx processors.

2007-09-07 Thread Zhang Wei
The driver implements DMA engine API for Freescale MPC85xx DMA
controller, which could be used for MEM<-->MEM, IO_ADDR<-->MEM
and IO_ADDR<-->IO_ADDR data transfer.
The driver supports the Basic mode of Freescale MPC85xx DMA controller.
The MPC85xx processors supported include MPC8540/60, MPC8555, MPC8548,
MPC8641 and so on.
The support for MPC83xx(MPC8349, MPC8360) is experimental.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
Signed-off-by: Ebony Zhu <[EMAIL PROTECTED]>
---
 drivers/dma/Kconfig  |8 +
 drivers/dma/Makefile |1 +
 drivers/dma/fsldma.c |  995 ++
 drivers/dma/fsldma.h |  188 ++
 4 files changed, 1192 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dma/fsldma.c
 create mode 100644 drivers/dma/fsldma.h

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 8f670da..a99e925 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -40,4 +40,12 @@ config INTEL_IOP_ADMA
 ---help---
   Enable support for the Intel(R) IOP Series RAID engines.
 
+config FSL_DMA
+   bool "Freescale MPC85xx/MPC83xx DMA support"
+   depends on DMA_ENGINE && PPC
+   ---help---
+ Enable support for the Freescale DMA engine. Now, it support
+ MPC8560/40, MPC8555, MPC8548 and MPC8641 processors.
+ The MPC8349, MPC8360 support is experimental.
+
 endmenu
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index b3839b6..50ab26c 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_DMA_ENGINE) += dmaengine.o
 obj-$(CONFIG_NET_DMA) += iovlock.o
 obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o
 obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
+obj-$(CONFIG_FSL_DMA) += fsldma.o
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
new file mode 100644
index 000..9e2d56b
--- /dev/null
+++ b/drivers/dma/fsldma.c
@@ -0,0 +1,995 @@
+/*
+ * Freescale MPC85xx, MPC83xx DMA Engine support
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author:
+ *   Zhang Wei <[EMAIL PROTECTED]>, Jul 2007
+ *   Ebony Zhu <[EMAIL PROTECTED]>, May 2007
+ *
+ * Description:
+ *   DMA engine driver for Freescale MPC8540 DMA controller, which is
+ *   also fit for MPC8560, MPC8555, MPC8548, MPC8641, and etc.
+ *   The support for MPC8349 DMA contorller is also added. But it's
+ *   ONLY experimental for MPC8349 now.
+ *
+ * This 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.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "fsldma.h"
+
+static LIST_HEAD(recy_ln_chain);   /* ld chain for recycle */
+static spinlock_t recy_ln_lock = SPIN_LOCK_UNLOCKED;
+
+static void dma_do_tasklet(unsigned long unused);
+static DECLARE_TASKLET(dma_tasklet, dma_do_tasklet, 0);
+
+#define to_fsl_chan(chan) container_of(chan, struct fsl_dma_chan, common)
+#define to_fsl_desc(lh) container_of(lh, struct fsl_desc_sw, node)
+#define tx_to_fsl_desc(tx) container_of(tx, struct fsl_desc_sw, async_tx)
+
+static void dma_init(struct fsl_dma_chan *fsl_chan)
+{
+   /* Reset the channel */
+   MIX_OUT(fsl_chan, _chan->reg_base->mr, 0, 32);
+
+   switch (fsl_chan->feature & FSL_DMA_IP_MASK) {
+   case FSL_DMA_IP_86XX:
+   /* Set the channel to below modes:
+* EIE - Error interrupt enable
+* EOSIE - End of segments interrupt enable (basic mode)
+* EOLNIE - End of links interrupt enable
+*/
+   MIX_OUT(fsl_chan, _chan->reg_base->mr, FSL_DMA_MR_EIE
+   | FSL_DMA_MR_EOLNIE | FSL_DMA_MR_EOSIE, 32);
+   break;
+   case FSL_DMA_IP_83XX:
+   /* Set the channel to below modes:
+* EOTIE - End-of-transfer interrupt enable
+*/
+   MIX_OUT(fsl_chan, _chan->reg_base->mr, FSL_DMA_MR_EOTIE,
+   32);
+   break;
+   }
+
+}
+
+static void set_sr(struct fsl_dma_chan *fsl_chan, dma_addr_t val)
+{
+   MIX_OUT(fsl_chan, _chan->reg_base->sr, val, 32);
+}
+
+static dma_addr_t get_sr(struct fsl_dma_chan *fsl_chan)
+{
+   return MIX_IN(fsl_chan, _chan->reg_base->sr, 32);
+}
+
+static void get_desc(struct fsl_dma_chan *fsl_chan, struct fsl_dma_ld_hw *hw,
+   struct fsl_ld_desc *ld)
+{
+   BUG_ON(!hw);
+
+   ld->src = MIX_TO_CPU(fsl_chan, hw->src_addr, 64);
+   ld->dest = MIX_TO_CPU(fsl_chan, hw->dst_addr, 64);
+   ld->count = MIX_TO_CPU(fsl_chan, hw->count, 32);
+   ld->next_ld_desc = MIX_TO_CPU(fsl_chan, hw->next_ln_addr,

[PATCH 5/5] Add DMA engine driver for Freescale MPC85xx processors.

2007-09-07 Thread Zhang Wei
The driver implements DMA engine API for Freescale MPC85xx DMA
controller, which could be used for MEM--MEM, IO_ADDR--MEM
and IO_ADDR--IO_ADDR data transfer.
The driver supports the Basic mode of Freescale MPC85xx DMA controller.
The MPC85xx processors supported include MPC8540/60, MPC8555, MPC8548,
MPC8641 and so on.
The support for MPC83xx(MPC8349, MPC8360) is experimental.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
Signed-off-by: Ebony Zhu [EMAIL PROTECTED]
---
 drivers/dma/Kconfig  |8 +
 drivers/dma/Makefile |1 +
 drivers/dma/fsldma.c |  995 ++
 drivers/dma/fsldma.h |  188 ++
 4 files changed, 1192 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dma/fsldma.c
 create mode 100644 drivers/dma/fsldma.h

diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 8f670da..a99e925 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -40,4 +40,12 @@ config INTEL_IOP_ADMA
 ---help---
   Enable support for the Intel(R) IOP Series RAID engines.
 
+config FSL_DMA
+   bool Freescale MPC85xx/MPC83xx DMA support
+   depends on DMA_ENGINE  PPC
+   ---help---
+ Enable support for the Freescale DMA engine. Now, it support
+ MPC8560/40, MPC8555, MPC8548 and MPC8641 processors.
+ The MPC8349, MPC8360 support is experimental.
+
 endmenu
diff --git a/drivers/dma/Makefile b/drivers/dma/Makefile
index b3839b6..50ab26c 100644
--- a/drivers/dma/Makefile
+++ b/drivers/dma/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_DMA_ENGINE) += dmaengine.o
 obj-$(CONFIG_NET_DMA) += iovlock.o
 obj-$(CONFIG_INTEL_IOATDMA) += ioatdma.o
 obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
+obj-$(CONFIG_FSL_DMA) += fsldma.o
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
new file mode 100644
index 000..9e2d56b
--- /dev/null
+++ b/drivers/dma/fsldma.c
@@ -0,0 +1,995 @@
+/*
+ * Freescale MPC85xx, MPC83xx DMA Engine support
+ *
+ * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
+ *
+ * Author:
+ *   Zhang Wei [EMAIL PROTECTED], Jul 2007
+ *   Ebony Zhu [EMAIL PROTECTED], May 2007
+ *
+ * Description:
+ *   DMA engine driver for Freescale MPC8540 DMA controller, which is
+ *   also fit for MPC8560, MPC8555, MPC8548, MPC8641, and etc.
+ *   The support for MPC8349 DMA contorller is also added. But it's
+ *   ONLY experimental for MPC8349 now.
+ *
+ * This 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.
+ *
+ */
+
+#include linux/init.h
+#include linux/module.h
+#include linux/pci.h
+#include linux/interrupt.h
+#include linux/dmaengine.h
+#include linux/delay.h
+#include linux/dma-mapping.h
+#include linux/dmapool.h
+#include linux/of_platform.h
+
+#include fsldma.h
+
+static LIST_HEAD(recy_ln_chain);   /* ld chain for recycle */
+static spinlock_t recy_ln_lock = SPIN_LOCK_UNLOCKED;
+
+static void dma_do_tasklet(unsigned long unused);
+static DECLARE_TASKLET(dma_tasklet, dma_do_tasklet, 0);
+
+#define to_fsl_chan(chan) container_of(chan, struct fsl_dma_chan, common)
+#define to_fsl_desc(lh) container_of(lh, struct fsl_desc_sw, node)
+#define tx_to_fsl_desc(tx) container_of(tx, struct fsl_desc_sw, async_tx)
+
+static void dma_init(struct fsl_dma_chan *fsl_chan)
+{
+   /* Reset the channel */
+   MIX_OUT(fsl_chan, fsl_chan-reg_base-mr, 0, 32);
+
+   switch (fsl_chan-feature  FSL_DMA_IP_MASK) {
+   case FSL_DMA_IP_86XX:
+   /* Set the channel to below modes:
+* EIE - Error interrupt enable
+* EOSIE - End of segments interrupt enable (basic mode)
+* EOLNIE - End of links interrupt enable
+*/
+   MIX_OUT(fsl_chan, fsl_chan-reg_base-mr, FSL_DMA_MR_EIE
+   | FSL_DMA_MR_EOLNIE | FSL_DMA_MR_EOSIE, 32);
+   break;
+   case FSL_DMA_IP_83XX:
+   /* Set the channel to below modes:
+* EOTIE - End-of-transfer interrupt enable
+*/
+   MIX_OUT(fsl_chan, fsl_chan-reg_base-mr, FSL_DMA_MR_EOTIE,
+   32);
+   break;
+   }
+
+}
+
+static void set_sr(struct fsl_dma_chan *fsl_chan, dma_addr_t val)
+{
+   MIX_OUT(fsl_chan, fsl_chan-reg_base-sr, val, 32);
+}
+
+static dma_addr_t get_sr(struct fsl_dma_chan *fsl_chan)
+{
+   return MIX_IN(fsl_chan, fsl_chan-reg_base-sr, 32);
+}
+
+static void get_desc(struct fsl_dma_chan *fsl_chan, struct fsl_dma_ld_hw *hw,
+   struct fsl_ld_desc *ld)
+{
+   BUG_ON(!hw);
+
+   ld-src = MIX_TO_CPU(fsl_chan, hw-src_addr, 64);
+   ld-dest = MIX_TO_CPU(fsl_chan, hw-dst_addr, 64);
+   ld-count = MIX_TO_CPU(fsl_chan, hw-count, 32);
+   ld-next_ld_desc = MIX_TO_CPU(fsl_chan, hw-next_ln_addr, 64);
+
+   switch

RE: [PATCH 3/5 v3] Add the platform device support with RapidIO to MPC8641HPCN platform.

2007-07-30 Thread Zhang Wei-r63237
Hi, Arnd,

I can change it as you metioned now.

Thanks!
-zw

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Arnd Bergmann
> Sent: Sunday, July 29, 2007 9:57 PM
> To: [EMAIL PROTECTED]
> Cc: Zhang Wei-r63237; [EMAIL PROTECTED]; 
> [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 3/5 v3] Add the platform device support 
> with RapidIO to MPC8641HPCN platform.
> 
> On Thursday 26 July 2007, Zhang Wei wrote:
> > +
> > +static struct of_device_id mpc86xx_of_ids[] = {
> > +   { .type = "soc", },
> > +   { .compatible = "fsl,rapidio-delta", },
> > +   {},
> > +};
> 
> With the device tree source you have posted in 2/5, the 
> rapidio node is
> a child of the soc bus, and it doesn't have any children of its own.
> Therefore it is completely equivalent to _only_ add the soc type
> to mpc86xx_of_ids[], as in 
> 
> static struct of_device_id mpc86xx_of_ids[] = {
>{ .type = "soc", },
>{},
> };
> 
> Even if you intend to add children to the rapidio node in the future,
> I'd think it would be more appropriate to have those scanned by
> the rapidio bus driver, not by of_platform.
> 
>   Arnd <><
> 
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-kernel" in
> the body of a message to [EMAIL PROTECTED]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 3/5 v3] Add the platform device support with RapidIO to MPC8641HPCN platform.

2007-07-30 Thread Zhang Wei-r63237
Hi, Arnd,

I can change it as you metioned now.

Thanks!
-zw

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Arnd Bergmann
 Sent: Sunday, July 29, 2007 9:57 PM
 To: [EMAIL PROTECTED]
 Cc: Zhang Wei-r63237; [EMAIL PROTECTED]; 
 [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
 linux-kernel@vger.kernel.org
 Subject: Re: [PATCH 3/5 v3] Add the platform device support 
 with RapidIO to MPC8641HPCN platform.
 
 On Thursday 26 July 2007, Zhang Wei wrote:
  +
  +static struct of_device_id mpc86xx_of_ids[] = {
  +   { .type = soc, },
  +   { .compatible = fsl,rapidio-delta, },
  +   {},
  +};
 
 With the device tree source you have posted in 2/5, the 
 rapidio node is
 a child of the soc bus, and it doesn't have any children of its own.
 Therefore it is completely equivalent to _only_ add the soc type
 to mpc86xx_of_ids[], as in 
 
 static struct of_device_id mpc86xx_of_ids[] = {
{ .type = soc, },
{},
 };
 
 Even if you intend to add children to the rapidio node in the future,
 I'd think it would be more appropriate to have those scanned by
 the rapidio bus driver, not by of_platform.
 
   Arnd 
 
 -
 To unsubscribe from this list: send the line unsubscribe 
 linux-kernel in
 the body of a message to [EMAIL PROTECTED]
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 Please read the FAQ at  http://www.tux.org/lkml/
 
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/5 v3] Add the explanation and a sample of RapidIO OF node to the document of booting-without-of.txt file.

2007-07-27 Thread Zhang Wei-r63237
Hi, Kumar, 
> +   RapidIO is a definition of a system interconnect. This node add
> > +   the support for RapidIO processor in kernel. The node name is
> > +   suggested to be 'rapidio'.
> > +
> > +   Required properties:
> > +
> > +- compatible : Using "fsl,rapidio-delta" for Freescale PowerPC
> > +  RapidIO controller.
> > +- #address-cells : Address representation for 
> "rapidio" devices.
> > +  This field represents the number of cells needed to represent
> > +  the RapidIO address of the registers.
> 
> Can you explain this a little further.  I'm a bit confused by  
> 'RapidIO address of the registers'.
> 
I want to present "This field represents the number of cells [needed to
represent the RapidIO address] of the registers."
Maybe I should remove 'of the registers' to be more clear.

Thanks!
-zw
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 4/5 v3] Add RapidIO support to powerpc architecture.

2007-07-27 Thread Zhang Wei-r63237
Hi, Kumar, 

> -Original Message-
> From: Kumar Gala [mailto:[EMAIL PROTECTED] 
> On Jul 26, 2007, at 3:42 AM, Zhang Wei wrote:
> 
> > 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 
> ++ 
> > +++
> 
> how much of this moved from ppc85xx_rio.c?

>From the code size, 2/3 are moved from pcc85xx_rio.c with clean up, 1/3
are new coding.

> 
> >  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 00099ef..45f32f1 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -492,6 +492,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.
> 
> why not make this depend on something like HAS_RAPIDIO and let the  
> boards select HAS_RAPIDIO if they have it

It's more clear, We can know how many and which processors support
RapidIO. :-)

> 
> > +
> > +source "drivers/rapidio/Kconfig"
> > +
> >  source "drivers/pci/hotplug/Kconfig"
> >
> >  endmenu
> > diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/ 
> > Makefile
> > index 42c42ec..02d4100 100644
> > --- a/arch/powerpc/kernel/Makefile
> > +++ b/arch/powerpc/kernel/Makefile
> > @@ -70,6 +70,7 @@ pci64-$(CONFIG_PPC64) += 
> pci_64.o pci_dn.o isa- 
> > bridge.o
> >  pci32-$(CONFIG_PPC32)  := pci_32.o
> >  obj-$(CONFIG_PCI)  += $(pci64-y) $(pci32-y) pci-common.o
> >  obj-$(CONFIG_PCI_MSI)  += msi.o
> > +obj-$(CONFIG_RAPIDIO)  += rio.o
> 
> should probably live in sysdev/rio.c

This just keep the same position of ppc arch.

Thanks!
-zw
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 4/5 v3] Add RapidIO support to powerpc architecture.

2007-07-27 Thread Zhang Wei-r63237
Hi, Kumar, 

 -Original Message-
 From: Kumar Gala [mailto:[EMAIL PROTECTED] 
 On Jul 26, 2007, at 3:42 AM, Zhang Wei wrote:
 
  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 
 ++ 
  +++
 
 how much of this moved from ppc85xx_rio.c?

From the code size, 2/3 are moved from pcc85xx_rio.c with clean up, 1/3
are new coding.

 
   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 00099ef..45f32f1 100644
  --- a/arch/powerpc/Kconfig
  +++ b/arch/powerpc/Kconfig
  @@ -492,6 +492,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.
 
 why not make this depend on something like HAS_RAPIDIO and let the  
 boards select HAS_RAPIDIO if they have it

It's more clear, We can know how many and which processors support
RapidIO. :-)

 
  +
  +source drivers/rapidio/Kconfig
  +
   source drivers/pci/hotplug/Kconfig
 
   endmenu
  diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/ 
  Makefile
  index 42c42ec..02d4100 100644
  --- a/arch/powerpc/kernel/Makefile
  +++ b/arch/powerpc/kernel/Makefile
  @@ -70,6 +70,7 @@ pci64-$(CONFIG_PPC64) += 
 pci_64.o pci_dn.o isa- 
  bridge.o
   pci32-$(CONFIG_PPC32)  := pci_32.o
   obj-$(CONFIG_PCI)  += $(pci64-y) $(pci32-y) pci-common.o
   obj-$(CONFIG_PCI_MSI)  += msi.o
  +obj-$(CONFIG_RAPIDIO)  += rio.o
 
 should probably live in sysdev/rio.c

This just keep the same position of ppc arch.

Thanks!
-zw
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/5 v3] Add the explanation and a sample of RapidIO OF node to the document of booting-without-of.txt file.

2007-07-27 Thread Zhang Wei-r63237
Hi, Kumar, 
 +   RapidIO is a definition of a system interconnect. This node add
  +   the support for RapidIO processor in kernel. The node name is
  +   suggested to be 'rapidio'.
  +
  +   Required properties:
  +
  +- compatible : Using fsl,rapidio-delta for Freescale PowerPC
  +  RapidIO controller.
  +- #address-cells : Address representation for 
 rapidio devices.
  +  This field represents the number of cells needed to represent
  +  the RapidIO address of the registers.
 
 Can you explain this a little further.  I'm a bit confused by  
 'RapidIO address of the registers'.
 
I want to present This field represents the number of cells [needed to
represent the RapidIO address] of the registers.
Maybe I should remove 'of the registers' to be more clear.

Thanks!
-zw
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5 v3] Add the memory management driver to RapidIO.

2007-07-26 Thread Zhang Wei
This patch adds the memory management driver to RapidIO.
The RapidIO system size is changed to automatically detection.
Add the memory mapping driver to RapidIO basic driver.
Multi master ports are supported.
Add a simple Bitmap RapidIO space allocator driver.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 drivers/net/rionet.c|   17 +-
 drivers/rapidio/Kconfig |   18 +-
 drivers/rapidio/Makefile|1 +
 drivers/rapidio/rio-access.c|   10 +-
 drivers/rapidio/rio-scan.c  |   53 +++--
 drivers/rapidio/rio-sysfs.c |3 +-
 drivers/rapidio/rio.c   |  479 ++-
 drivers/rapidio/rio.h   |9 +-
 drivers/rapidio/sallocator/Kconfig  |9 +
 drivers/rapidio/sallocator/Makefile |   12 +
 drivers/rapidio/sallocator/bitmap.c |  382 
 include/linux/rio.h |   71 +-
 include/linux/rio_drv.h |   41 +++-
 13 files changed, 1046 insertions(+), 59 deletions(-)
 create mode 100644 drivers/rapidio/sallocator/Kconfig
 create mode 100644 drivers/rapidio/sallocator/Makefile
 create mode 100644 drivers/rapidio/sallocator/bitmap.c

diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index df6b738..8dcda4d 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -78,7 +78,7 @@ static int rionet_capable = 1;
  * could be made into a hash table to save memory depending
  * on system trade-offs.
  */
-static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES];
+static struct rio_dev **rionet_active;
 
 #define is_rionet_capable(pef, src_ops, dst_ops)   \
((pef & RIO_PEF_INB_MBOX) &&\
@@ -115,6 +115,7 @@ static int rionet_rx_clean(struct net_device *ndev)
 
rnet->rx_skb[i]->data = data;
skb_put(rnet->rx_skb[i], RIO_MAX_MSG_SIZE);
+   rnet->rx_skb[i]->dev = ndev;
rnet->rx_skb[i]->protocol =
eth_type_trans(rnet->rx_skb[i], ndev);
error = netif_rx(rnet->rx_skb[i]);
@@ -202,7 +203,8 @@ static int rionet_start_xmit(struct sk_buff *skb, struct 
net_device *ndev)
}
 
if (eth->h_dest[0] & 0x01) {
-   for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++)
+   for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size);
+   i++)
if (rionet_active[i])
rionet_queue_tx_msg(skb, ndev,
rionet_active[i]);
@@ -392,6 +394,8 @@ static void rionet_remove(struct rio_dev *rdev)
struct net_device *ndev = NULL;
struct rionet_peer *peer, *tmp;
 
+   free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ?
+   __ilog2(sizeof(void *)) + 4 : 0);
unregister_netdev(ndev);
kfree(ndev);
 
@@ -449,6 +453,15 @@ static int rionet_setup_netdev(struct rio_mport *mport)
goto out;
}
 
+   if (!(rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
+   mport->sys_size ? __ilog2(sizeof(void *)) + 4
+   : 0))) {
+   rc = -ENOMEM;
+   goto out;
+   }
+   memset((void *)rionet_active, 0, sizeof(void *) *
+   RIO_MAX_ROUTE_ENTRIES(mport->sys_size));
+
/* Set up private area */
rnet = (struct rionet_private *)ndev->priv;
rnet->mport = mport;
diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
index 4142115..f669108 100644
--- a/drivers/rapidio/Kconfig
+++ b/drivers/rapidio/Kconfig
@@ -1,14 +1,6 @@
 #
 # RapidIO configuration
 #
-config RAPIDIO_8_BIT_TRANSPORT
-   bool "8-bit transport addressing"
-   depends on RAPIDIO
-   ---help---
- By default, the kernel assumes a 16-bit addressed RapidIO
- network. By selecting this option, the kernel will support
- an 8-bit addressed network.
-
 config RAPIDIO_DISC_TIMEOUT
int "Discovery timeout duration (seconds)"
depends on RAPIDIO
@@ -16,3 +8,13 @@ config RAPIDIO_DISC_TIMEOUT
---help---
  Amount of time a discovery node waits for a host to complete
  enumeration before giving up.
+
+config RAPIDIO_PROC_FS
+   bool "I/O and Memory resource debug"
+   depends on RAPIDIO && PROC_FS
+   default y
+   ---help---
+ Enable this option, it will create a /proc/riores node for
+ monitoring the RapidIO I/O and Memory resource.
+
+source "drivers/rapidio/sallocator/Kconfig"
diff --git a/drivers/rapidio/Makefile b/drivers/rapidio/Makefile
index 7c0e181..e5b2f11 100644
--- a/drivers/rapidio/Makefile
+++ b/drivers/rapidio/Makefile
@@ -4,3 +4,4 @@

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

2007-07-26 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 00099ef..45f32f1 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -492,6 +492,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 42c42ec..02d4100 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -70,6 +70,7 @@ pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o 
isa-bridge.o
 pci32-$(CONFIG_PPC32)  := pci_32.o
 obj-$(CONFIG_PCI)  += $(pci64-y) $(pci32-y) pci-common.o
 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 08ce31e..0dd6b6a 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_PPC_PMI) += pmi.o
 obj-$(CONFIG_U3_DART)  += dart_iommu.o
 obj-$(CONFIG_MMIO_NVRAM)   += mmio_nvram.o
 obj-$(CONFIG_FSL_SOC)  += fsl_soc.o
+obj-$(CONFIG_RAPIDIO)  += fsl_rio.o
 obj-$(CONFIG_FSL_PCI)  += fsl_pci.o
 obj-$(CONFIG_TSI108_BRIDGE)+= tsi108_pci.o tsi108_dev.o
 obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
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 softw

[PATCH 3/5 v3] Add the platform device support with RapidIO to MPC8641HPCN platform.

2007-07-26 Thread Zhang Wei
Add the platform device support with RapidIO to MPC8641HPCN platform.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/86xx/mpc86xx_hpcn.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c 
b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index e9eaa07..7693adc 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -28,6 +28,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -444,3 +446,17 @@ define_machine(mpc86xx_hpcn) {
.progress   = udbg_progress,
.pcibios_fixup_bus  = fsl_pcibios_fixup_bus,
 };
+
+
+static struct of_device_id mpc86xx_of_ids[] = {
+   { .type = "soc", },
+   { .compatible = "fsl,rapidio-delta", },
+   {},
+};
+
+static __init int mpc86xx_of_device_init(void)
+{
+   return of_platform_bus_probe(NULL, mpc86xx_of_ids, NULL);
+}
+
+device_initcall(mpc86xx_of_device_init);
-- 
1.5.1

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5 v3] Add RapidIO OF-node to the MPC8641HPCN board dts file.

2007-07-26 Thread Zhang Wei
Add RapidIO OF-node to the MPC8641HPCN board dts file.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/boot/dts/mpc8641_hpcn.dts |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn.dts 
b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
index 5d82709..080ba8a 100644
--- a/arch/powerpc/boot/dts/mpc8641_hpcn.dts
+++ b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
@@ -422,6 +422,19 @@
>;
};
 
+   [EMAIL PROTECTED] {
+   compatible = "fsl,rapidio-delta";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   reg = ;
+   ranges = <0 0 c000 2000>;
+   interrupt-parent = <>;
+   /* err_irq bell_outb_irq bell_inb_irq
+   msg1_tx_irq msg1_rx_irq
+   msg2_tx_irq msg2_rx_irq */
+   interrupts = <30 2 31 2 32 2 35 2 36 2 37 2 38 2>;
+   };
+
mpic: [EMAIL PROTECTED] {
clock-frequency = <0>;
interrupt-controller;
-- 
1.5.1

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5 v3] Add the explanation and a sample of RapidIO OF node to the document of booting-without-of.txt file.

2007-07-26 Thread Zhang Wei
Add the explanation and a sample of RapidIO OF node to the document of 
booting-without-of.txt file.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 Documentation/powerpc/booting-without-of.txt |   37 ++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/Documentation/powerpc/booting-without-of.txt 
b/Documentation/powerpc/booting-without-of.txt
index 76733a3..d89b805 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1824,6 +1824,43 @@ platforms are moved over to use the 
flattened-device-tree model.
fsl,has-rstcr;
};
 
+   l) RapidIO
+
+   RapidIO is a definition of a system interconnect. This node add
+   the support for RapidIO processor in kernel. The node name is
+   suggested to be 'rapidio'.
+
+   Required properties:
+
+- compatible : Using "fsl,rapidio-delta" for Freescale PowerPC
+  RapidIO controller.
+- #address-cells : Address representation for "rapidio" devices.
+  This field represents the number of cells needed to represent
+  the RapidIO address of the registers.
+  See 1) above for more details on defining #address-cells.
+- reg : Offset and length of the register set for the device
+- ranges : Should be defined as specified in 1) to describe the
+  translation of addresses for memory mapped RapidIO memory
+  space.
+- interrupts : binding interrupts for this device node,
+  please follow below orders:
+  .
+
+  Example:
+
+   [EMAIL PROTECTED] {
+   compatible = "fsl,rapidio-delta";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   reg = ;
+   ranges = <0 0 c000 2000>;
+   interrupt-parent = <>;
+   /* err_irq bell_outb_irq bell_inb_irq msg1_tx_irq msg1_rx_irq
+ msg2_tx_irq msg2_rx_irq */
+   interrupts = <30 2 31 2 32 2 35 2 36 2 37 2 38 2>;
+   };
+
More devices will be defined as this spec matures.
 
 VII - Specifying interrupt information for devices
-- 
1.5.1

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5 v3] Porting RapidIO driver from ppc to powerpc architecture and adding memory mapped RapidIO driver.

2007-07-26 Thread Zhang Wei
These patches are the version 3 patches for RapidIO with dts update and some 
minor fixups.

These patches are used for supporting RapidIO controllers of Freescale. I 
ported them from ppc architecture to powerpc architecture and added some new 
features, such as memory mapped driver.

[PATCH 1/5] Add the explanation and sample of RapidIO DTS OF-node to the 
document of booting-without-of.txt file.
[PATCH 2/5] Add RapidIO OF-node to MPC8641HPCN board dts file.
[PATCH 3/5] Add the platform device support with RapidIO to MPC8641HPCN 
platform.
[PATCH 4/5] Add RapidIO support to powerpc architecture.
[PATCH 5/5] Add the memory management driver to RapidIO.

Please see below descriptions of these patches:
1. Add the RapidIO driver of-device support.
2. Add the RapidIO driver support to MPC8641HPCN board.
3. Port the RapidIO from ppc to powerpc architecture.
4. Add Memory mapped RapidIO driver.
5. Add the support to multi master ports.
6. Add a simple bitmap RapidIO space allocator driver.
7. Change the RapidIO system size of menuconfig to automatically detection.

Thanks!

Best Regards,
Zhang Wei



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5 v3] Add the memory management driver to RapidIO.

2007-07-26 Thread Zhang Wei
This patch adds the memory management driver to RapidIO.
The RapidIO system size is changed to automatically detection.
Add the memory mapping driver to RapidIO basic driver.
Multi master ports are supported.
Add a simple Bitmap RapidIO space allocator driver.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 drivers/net/rionet.c|   17 +-
 drivers/rapidio/Kconfig |   18 +-
 drivers/rapidio/Makefile|1 +
 drivers/rapidio/rio-access.c|   10 +-
 drivers/rapidio/rio-scan.c  |   53 +++--
 drivers/rapidio/rio-sysfs.c |3 +-
 drivers/rapidio/rio.c   |  479 ++-
 drivers/rapidio/rio.h   |9 +-
 drivers/rapidio/sallocator/Kconfig  |9 +
 drivers/rapidio/sallocator/Makefile |   12 +
 drivers/rapidio/sallocator/bitmap.c |  382 
 include/linux/rio.h |   71 +-
 include/linux/rio_drv.h |   41 +++-
 13 files changed, 1046 insertions(+), 59 deletions(-)
 create mode 100644 drivers/rapidio/sallocator/Kconfig
 create mode 100644 drivers/rapidio/sallocator/Makefile
 create mode 100644 drivers/rapidio/sallocator/bitmap.c

diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index df6b738..8dcda4d 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -78,7 +78,7 @@ static int rionet_capable = 1;
  * could be made into a hash table to save memory depending
  * on system trade-offs.
  */
-static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES];
+static struct rio_dev **rionet_active;
 
 #define is_rionet_capable(pef, src_ops, dst_ops)   \
((pef  RIO_PEF_INB_MBOX) \
@@ -115,6 +115,7 @@ static int rionet_rx_clean(struct net_device *ndev)
 
rnet-rx_skb[i]-data = data;
skb_put(rnet-rx_skb[i], RIO_MAX_MSG_SIZE);
+   rnet-rx_skb[i]-dev = ndev;
rnet-rx_skb[i]-protocol =
eth_type_trans(rnet-rx_skb[i], ndev);
error = netif_rx(rnet-rx_skb[i]);
@@ -202,7 +203,8 @@ static int rionet_start_xmit(struct sk_buff *skb, struct 
net_device *ndev)
}
 
if (eth-h_dest[0]  0x01) {
-   for (i = 0; i  RIO_MAX_ROUTE_ENTRIES; i++)
+   for (i = 0; i  RIO_MAX_ROUTE_ENTRIES(rnet-mport-sys_size);
+   i++)
if (rionet_active[i])
rionet_queue_tx_msg(skb, ndev,
rionet_active[i]);
@@ -392,6 +394,8 @@ static void rionet_remove(struct rio_dev *rdev)
struct net_device *ndev = NULL;
struct rionet_peer *peer, *tmp;
 
+   free_pages((unsigned long)rionet_active, rdev-net-hport-sys_size ?
+   __ilog2(sizeof(void *)) + 4 : 0);
unregister_netdev(ndev);
kfree(ndev);
 
@@ -449,6 +453,15 @@ static int rionet_setup_netdev(struct rio_mport *mport)
goto out;
}
 
+   if (!(rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
+   mport-sys_size ? __ilog2(sizeof(void *)) + 4
+   : 0))) {
+   rc = -ENOMEM;
+   goto out;
+   }
+   memset((void *)rionet_active, 0, sizeof(void *) *
+   RIO_MAX_ROUTE_ENTRIES(mport-sys_size));
+
/* Set up private area */
rnet = (struct rionet_private *)ndev-priv;
rnet-mport = mport;
diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
index 4142115..f669108 100644
--- a/drivers/rapidio/Kconfig
+++ b/drivers/rapidio/Kconfig
@@ -1,14 +1,6 @@
 #
 # RapidIO configuration
 #
-config RAPIDIO_8_BIT_TRANSPORT
-   bool 8-bit transport addressing
-   depends on RAPIDIO
-   ---help---
- By default, the kernel assumes a 16-bit addressed RapidIO
- network. By selecting this option, the kernel will support
- an 8-bit addressed network.
-
 config RAPIDIO_DISC_TIMEOUT
int Discovery timeout duration (seconds)
depends on RAPIDIO
@@ -16,3 +8,13 @@ config RAPIDIO_DISC_TIMEOUT
---help---
  Amount of time a discovery node waits for a host to complete
  enumeration before giving up.
+
+config RAPIDIO_PROC_FS
+   bool I/O and Memory resource debug
+   depends on RAPIDIO  PROC_FS
+   default y
+   ---help---
+ Enable this option, it will create a /proc/riores node for
+ monitoring the RapidIO I/O and Memory resource.
+
+source drivers/rapidio/sallocator/Kconfig
diff --git a/drivers/rapidio/Makefile b/drivers/rapidio/Makefile
index 7c0e181..e5b2f11 100644
--- a/drivers/rapidio/Makefile
+++ b/drivers/rapidio/Makefile
@@ -4,3 +4,4 @@
 obj-y += rio.o rio-access.o rio-driver.o rio-scan.o rio-sysfs.o
 
 obj-$(CONFIG_RAPIDIO)  += switches/
+obj-$(CONFIG_RAPIDIO)  += sallocator/
diff --git

[PATCH 0/5 v3] Porting RapidIO driver from ppc to powerpc architecture and adding memory mapped RapidIO driver.

2007-07-26 Thread Zhang Wei
These patches are the version 3 patches for RapidIO with dts update and some 
minor fixups.

These patches are used for supporting RapidIO controllers of Freescale. I 
ported them from ppc architecture to powerpc architecture and added some new 
features, such as memory mapped driver.

[PATCH 1/5] Add the explanation and sample of RapidIO DTS OF-node to the 
document of booting-without-of.txt file.
[PATCH 2/5] Add RapidIO OF-node to MPC8641HPCN board dts file.
[PATCH 3/5] Add the platform device support with RapidIO to MPC8641HPCN 
platform.
[PATCH 4/5] Add RapidIO support to powerpc architecture.
[PATCH 5/5] Add the memory management driver to RapidIO.

Please see below descriptions of these patches:
1. Add the RapidIO driver of-device support.
2. Add the RapidIO driver support to MPC8641HPCN board.
3. Port the RapidIO from ppc to powerpc architecture.
4. Add Memory mapped RapidIO driver.
5. Add the support to multi master ports.
6. Add a simple bitmap RapidIO space allocator driver.
7. Change the RapidIO system size of menuconfig to automatically detection.

Thanks!

Best Regards,
Zhang Wei



-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5 v3] Add RapidIO OF-node to the MPC8641HPCN board dts file.

2007-07-26 Thread Zhang Wei
Add RapidIO OF-node to the MPC8641HPCN board dts file.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/boot/dts/mpc8641_hpcn.dts |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn.dts 
b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
index 5d82709..080ba8a 100644
--- a/arch/powerpc/boot/dts/mpc8641_hpcn.dts
+++ b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
@@ -422,6 +422,19 @@
;
};
 
+   [EMAIL PROTECTED] {
+   compatible = fsl,rapidio-delta;
+   #address-cells = 2;
+   #size-cells = 2;
+   reg = c 2;
+   ranges = 0 0 c000 2000;
+   interrupt-parent = mpic;
+   /* err_irq bell_outb_irq bell_inb_irq
+   msg1_tx_irq msg1_rx_irq
+   msg2_tx_irq msg2_rx_irq */
+   interrupts = 30 2 31 2 32 2 35 2 36 2 37 2 38 2;
+   };
+
mpic: [EMAIL PROTECTED] {
clock-frequency = 0;
interrupt-controller;
-- 
1.5.1

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/5 v3] Add the explanation and a sample of RapidIO OF node to the document of booting-without-of.txt file.

2007-07-26 Thread Zhang Wei
Add the explanation and a sample of RapidIO OF node to the document of 
booting-without-of.txt file.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 Documentation/powerpc/booting-without-of.txt |   37 ++
 1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/Documentation/powerpc/booting-without-of.txt 
b/Documentation/powerpc/booting-without-of.txt
index 76733a3..d89b805 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1824,6 +1824,43 @@ platforms are moved over to use the 
flattened-device-tree model.
fsl,has-rstcr;
};
 
+   l) RapidIO
+
+   RapidIO is a definition of a system interconnect. This node add
+   the support for RapidIO processor in kernel. The node name is
+   suggested to be 'rapidio'.
+
+   Required properties:
+
+- compatible : Using fsl,rapidio-delta for Freescale PowerPC
+  RapidIO controller.
+- #address-cells : Address representation for rapidio devices.
+  This field represents the number of cells needed to represent
+  the RapidIO address of the registers.
+  See 1) above for more details on defining #address-cells.
+- reg : Offset and length of the register set for the device
+- ranges : Should be defined as specified in 1) to describe the
+  translation of addresses for memory mapped RapidIO memory
+  space.
+- interrupts : binding interrupts for this device node,
+  please follow below orders:
+  err_irq bell_outb_irq bell_inb_irq msg1_tx_irq msg1_rx_irq
+  msg2_tx_irq msg2_rx_irq ... msgN_tx_irq msgN_rx_irq.
+
+  Example:
+
+   [EMAIL PROTECTED] {
+   compatible = fsl,rapidio-delta;
+   #address-cells = 2;
+   #size-cells = 2;
+   reg = c 2;
+   ranges = 0 0 c000 2000;
+   interrupt-parent = mpic;
+   /* err_irq bell_outb_irq bell_inb_irq msg1_tx_irq msg1_rx_irq
+ msg2_tx_irq msg2_rx_irq */
+   interrupts = 30 2 31 2 32 2 35 2 36 2 37 2 38 2;
+   };
+
More devices will be defined as this spec matures.
 
 VII - Specifying interrupt information for devices
-- 
1.5.1

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5 v3] Add the platform device support with RapidIO to MPC8641HPCN platform.

2007-07-26 Thread Zhang Wei
Add the platform device support with RapidIO to MPC8641HPCN platform.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/platforms/86xx/mpc86xx_hpcn.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c 
b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index e9eaa07..7693adc 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -28,6 +28,8 @@
 #include mm/mmu_decl.h
 #include asm/udbg.h
 #include asm/i8259.h
+#include asm/of_device.h
+#include asm/of_platform.h
 
 #include asm/mpic.h
 
@@ -444,3 +446,17 @@ define_machine(mpc86xx_hpcn) {
.progress   = udbg_progress,
.pcibios_fixup_bus  = fsl_pcibios_fixup_bus,
 };
+
+
+static struct of_device_id mpc86xx_of_ids[] = {
+   { .type = soc, },
+   { .compatible = fsl,rapidio-delta, },
+   {},
+};
+
+static __init int mpc86xx_of_device_init(void)
+{
+   return of_platform_bus_probe(NULL, mpc86xx_of_ids, NULL);
+}
+
+device_initcall(mpc86xx_of_device_init);
-- 
1.5.1

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


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

2007-07-26 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 00099ef..45f32f1 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -492,6 +492,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 42c42ec..02d4100 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -70,6 +70,7 @@ pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o 
isa-bridge.o
 pci32-$(CONFIG_PPC32)  := pci_32.o
 obj-$(CONFIG_PCI)  += $(pci64-y) $(pci32-y) pci-common.o
 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 08ce31e..0dd6b6a 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_PPC_PMI) += pmi.o
 obj-$(CONFIG_U3_DART)  += dart_iommu.o
 obj-$(CONFIG_MMIO_NVRAM)   += mmio_nvram.o
 obj-$(CONFIG_FSL_SOC)  += fsl_soc.o
+obj-$(CONFIG_RAPIDIO)  += fsl_rio.o
 obj-$(CONFIG_FSL_PCI)  += fsl_pci.o
 obj-$(CONFIG_TSI108_BRIDGE)+= tsi108_pci.o tsi108_dev.o
 obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
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

RE: [PATCH 3/4] Extend the DMA-engine API.

2007-07-12 Thread Zhang Wei-r63237
Hi, Dan,

Thanks! I get it.
It's so lucky we have the same target.
When your patch could be accepted?

Cheers,
Wei. 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Dan Williams
> Sent: Thursday, July 12, 2007 12:57 AM
> To: Zhang Wei-r63237
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
> [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
> linux-kernel@vger.kernel.org; [EMAIL PROTECTED]
> Subject: Re: [PATCH 3/4] Extend the DMA-engine API.
> 
> On 7/11/07, Zhang Wei-r63237 <[EMAIL PROTECTED]> wrote:
> > Hi, Dan,
> >
> > Do you mention here: 
> http://marc.info/?l=linux-raid=118290909614463=2 ?
> > I see the async_tx is located at crypto/ of the above page, 
> but my patch is for DMA engine in drivers/dma and for DMA 
> engine driver.
> >
> > Thanks!
> > Wei.
> 
> Hi Wei,
> 
> I was referring to:
> http://marc.info/?l=linux-raid=118290909528910=2
> 
> async_tx is an api that exploits the raw capabilities of the new
> dmaengine interface.  For your case when the existing api calls do not
> provide the proper interface you can open code something like the
> following:
> 
> tx = dev->device_prep_dma_(chan, len, int_flag)
> tx->tx_set_src(dma_addr_t, tx, index /* for multi-source ops */)
> tx->tx_set_dest(dma_addr_t, tx, index)
> tx->tx_submit(tx)
> 
> The expectation is that the most common usages of dmaengines will use
> async_tx calls, or the 'dma_async_memcpy_foo_to_bar' helper routines.
> 
> --
> Dan
> 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 3/4] Extend the DMA-engine API.

2007-07-12 Thread Zhang Wei-r63237
Hi, Dan,

Thanks! I get it.
It's so lucky we have the same target.
When your patch could be accepted?

Cheers,
Wei. 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Dan Williams
 Sent: Thursday, July 12, 2007 12:57 AM
 To: Zhang Wei-r63237
 Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
 [EMAIL PROTECTED]; [EMAIL PROTECTED]; 
 linux-kernel@vger.kernel.org; [EMAIL PROTECTED]
 Subject: Re: [PATCH 3/4] Extend the DMA-engine API.
 
 On 7/11/07, Zhang Wei-r63237 [EMAIL PROTECTED] wrote:
  Hi, Dan,
 
  Do you mention here: 
 http://marc.info/?l=linux-raidm=118290909614463w=2 ?
  I see the async_tx is located at crypto/ of the above page, 
 but my patch is for DMA engine in drivers/dma and for DMA 
 engine driver.
 
  Thanks!
  Wei.
 
 Hi Wei,
 
 I was referring to:
 http://marc.info/?l=linux-raidm=118290909528910w=2
 
 async_tx is an api that exploits the raw capabilities of the new
 dmaengine interface.  For your case when the existing api calls do not
 provide the proper interface you can open code something like the
 following:
 
 tx = dev-device_prep_dma_operation(chan, len, int_flag)
 tx-tx_set_src(dma_addr_t, tx, index /* for multi-source ops */)
 tx-tx_set_dest(dma_addr_t, tx, index)
 tx-tx_submit(tx)
 
 The expectation is that the most common usages of dmaengines will use
 async_tx calls, or the 'dma_async_memcpy_foo_to_bar' helper routines.
 
 --
 Dan
 
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 3/4] Extend the DMA-engine API.

2007-07-11 Thread Zhang Wei-r63237
Hi, Dan, 

Do you mention here: http://marc.info/?l=linux-raid=118290909614463=2 ?
I see the async_tx is located at crypto/ of the above page, but my patch is for 
DMA engine in drivers/dma and for DMA engine driver.

Thanks!
Wei.
> -Original Message-
> Subject: Re: [PATCH 3/4] Extend the DMA-engine API.
> 
> On 7/10/07, Zhang Wei <[EMAIL PROTECTED]> wrote:
> > Add channel wait queue and transfer callback dma_xfer_callback().
> > If the DMA controller and driver support interrupt, when the
> > transfer is finished, it will wakeup the wait queue
> > and call the callback function of the channel.
> >
> > Add dma_async_raw_xfer() to API and device_raw_xfer() to 
> struct dma_device
> > for RAW physical address DMA transfer, which will be used 
> at transfer
> > between I/O address and memory address.
> >
> 
> Please review the async_tx API patch series[1], it should meet your
> needs.  What you call "raw" mode support is now default for the
> dmaengine driver interface.  I plan to request that this series be
> merged for 2.6.23.
> 
> Regards,
> Dan
> 
> [1]http://marc.info/?l=linux-raid=2=1=md-accel=b
> 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 3/4] Extend the DMA-engine API.

2007-07-11 Thread Zhang Wei-r63237
Hi, Dan, 

Do you mention here: http://marc.info/?l=linux-raidm=118290909614463w=2 ?
I see the async_tx is located at crypto/ of the above page, but my patch is for 
DMA engine in drivers/dma and for DMA engine driver.

Thanks!
Wei.
 -Original Message-
 Subject: Re: [PATCH 3/4] Extend the DMA-engine API.
 
 On 7/10/07, Zhang Wei [EMAIL PROTECTED] wrote:
  Add channel wait queue and transfer callback dma_xfer_callback().
  If the DMA controller and driver support interrupt, when the
  transfer is finished, it will wakeup the wait queue
  and call the callback function of the channel.
 
  Add dma_async_raw_xfer() to API and device_raw_xfer() to 
 struct dma_device
  for RAW physical address DMA transfer, which will be used 
 at transfer
  between I/O address and memory address.
 
 
 Please review the async_tx API patch series[1], it should meet your
 needs.  What you call raw mode support is now default for the
 dmaengine driver interface.  I plan to request that this series be
 merged for 2.6.23.
 
 Regards,
 Dan
 
 [1]http://marc.info/?l=linux-raidw=2r=1s=md-accelq=b
 
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] Extend the DMA-engine API.

2007-07-10 Thread Zhang Wei
Add channel wait queue and transfer callback dma_xfer_callback().
If the DMA controller and driver support interrupt, when the
transfer is finished, it will wakeup the wait queue
and call the callback function of the channel.

Add dma_async_raw_xfer() to API and device_raw_xfer() to struct dma_device
for RAW physical address DMA transfer, which will be used at transfer
between I/O address and memory address.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 include/linux/dmaengine.h |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index c94d8f1..d9dfc57 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * enum dma_event - resource PNP/power managment events
@@ -108,6 +109,8 @@ struct dma_chan {
struct list_head client_node;
struct list_head device_node;
struct dma_chan_percpu *local;
+
+   wait_queue_head_t wait_q;
 };
 
 void dma_chan_cleanup(struct kref *kref);
@@ -138,6 +141,12 @@ static inline void dma_chan_put(struct dma_chan *chan)
 typedef void (*dma_event_callback) (struct dma_client *client,
struct dma_chan *chan, enum dma_event event);
 
+/*
+ * typedef dma_xfer_callback
+ *   - function pointer to a DMA transfer callback when finished
+ */
+typedef void (*dma_xfer_callback) (struct dma_chan *chan, void *data);
+
 /**
  * struct dma_client - info on the entity making use of DMA services
  * @event_callback: func ptr to call when something happens
@@ -187,6 +196,9 @@ struct dma_device {
 
int (*device_alloc_chan_resources)(struct dma_chan *chan);
void (*device_free_chan_resources)(struct dma_chan *chan);
+   dma_cookie_t (*device_raw_xfer)(struct dma_chan *chan,
+   dma_addr_t dest, dma_addr_t src, size_t len,
+   dma_xfer_callback cb, void *data);
dma_cookie_t (*device_memcpy_buf_to_buf)(struct dma_chan *chan,
void *dest, void *src, size_t len);
dma_cookie_t (*device_memcpy_buf_to_pg)(struct dma_chan *chan,
@@ -209,6 +221,29 @@ void dma_async_client_chan_request(struct dma_client 
*client,
unsigned int number);
 
 /**
+ * dma_async_raw_xfer - transfor data between physical addresses with callback
+ * @chan: DMA channel to be used
+ * @dest: destination address (physical)
+ * @src: source address (physical)
+ * @len: length
+ */
+static inline dma_cookie_t dma_async_raw_xfer(struct dma_chan *chan,
+   dma_addr_t dest, dma_addr_t src, size_t len,
+   dma_xfer_callback cb, void *data)
+{
+   int cpu = get_cpu();
+   per_cpu_ptr(chan->local, cpu)->bytes_transferred += len;
+   per_cpu_ptr(chan->local, cpu)->memcpy_count++;
+   put_cpu();
+
+   if (chan->device->device_raw_xfer)
+   return chan->device->device_raw_xfer(chan, dest, src, len,
+   cb, data);
+   else
+   return -EPERM;
+}
+
+/**
  * dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses
  * @chan: DMA channel to offload copy to
  * @dest: destination address (virtual)
-- 
1.5.1

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] Extend the DMA-engine API.

2007-07-10 Thread Zhang Wei
Add channel wait queue and transfer callback dma_xfer_callback().
If the DMA controller and driver support interrupt, when the
transfer is finished, it will wakeup the wait queue
and call the callback function of the channel.

Add dma_async_raw_xfer() to API and device_raw_xfer() to struct dma_device
for RAW physical address DMA transfer, which will be used at transfer
between I/O address and memory address.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 include/linux/dmaengine.h |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index c94d8f1..d9dfc57 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -28,6 +28,7 @@
 #include linux/kref.h
 #include linux/completion.h
 #include linux/rcupdate.h
+#include linux/wait.h
 
 /**
  * enum dma_event - resource PNP/power managment events
@@ -108,6 +109,8 @@ struct dma_chan {
struct list_head client_node;
struct list_head device_node;
struct dma_chan_percpu *local;
+
+   wait_queue_head_t wait_q;
 };
 
 void dma_chan_cleanup(struct kref *kref);
@@ -138,6 +141,12 @@ static inline void dma_chan_put(struct dma_chan *chan)
 typedef void (*dma_event_callback) (struct dma_client *client,
struct dma_chan *chan, enum dma_event event);
 
+/*
+ * typedef dma_xfer_callback
+ *   - function pointer to a DMA transfer callback when finished
+ */
+typedef void (*dma_xfer_callback) (struct dma_chan *chan, void *data);
+
 /**
  * struct dma_client - info on the entity making use of DMA services
  * @event_callback: func ptr to call when something happens
@@ -187,6 +196,9 @@ struct dma_device {
 
int (*device_alloc_chan_resources)(struct dma_chan *chan);
void (*device_free_chan_resources)(struct dma_chan *chan);
+   dma_cookie_t (*device_raw_xfer)(struct dma_chan *chan,
+   dma_addr_t dest, dma_addr_t src, size_t len,
+   dma_xfer_callback cb, void *data);
dma_cookie_t (*device_memcpy_buf_to_buf)(struct dma_chan *chan,
void *dest, void *src, size_t len);
dma_cookie_t (*device_memcpy_buf_to_pg)(struct dma_chan *chan,
@@ -209,6 +221,29 @@ void dma_async_client_chan_request(struct dma_client 
*client,
unsigned int number);
 
 /**
+ * dma_async_raw_xfer - transfor data between physical addresses with callback
+ * @chan: DMA channel to be used
+ * @dest: destination address (physical)
+ * @src: source address (physical)
+ * @len: length
+ */
+static inline dma_cookie_t dma_async_raw_xfer(struct dma_chan *chan,
+   dma_addr_t dest, dma_addr_t src, size_t len,
+   dma_xfer_callback cb, void *data)
+{
+   int cpu = get_cpu();
+   per_cpu_ptr(chan-local, cpu)-bytes_transferred += len;
+   per_cpu_ptr(chan-local, cpu)-memcpy_count++;
+   put_cpu();
+
+   if (chan-device-device_raw_xfer)
+   return chan-device-device_raw_xfer(chan, dest, src, len,
+   cb, data);
+   else
+   return -EPERM;
+}
+
+/**
  * dma_async_memcpy_buf_to_buf - offloaded copy between virtual addresses
  * @chan: DMA channel to offload copy to
  * @dest: destination address (virtual)
-- 
1.5.1

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/5 v2] Add the explanation and a sample of RapidIO DTS sector to the document of booting-without-of.txt file.

2007-06-29 Thread Zhang Wei-r63237
Hi, Segher, 

> DTS sector to the document of booting-without-of.txt file.
> 
> >>> +- #address-cells : Address representation for
> >> "rapidio" devices.
> >>> +  This field represents the number of cells needed 
> to represent
> >>> +  the RapidIO address of the registers.  For
> >> supporting more than
> >>> +  32-bits RapidIO address, this field should be <2>.
> >>> +  See 1) above for more details on defining #address-cells.
> >>
> >> What does the RapidIO standard say about number of address
> >> bits?  You want to follow that, so all RapidIO devices can
> >> use the same #address-cells, not just the FSL ones.  Also,
> >> are there different kinds of address spaces on the bus, or
> >> is it just one big memory-like space?
> >
> > I've checked the specification of RapidIO. The supporting of RapidIO
> > extended address modes are 66, 50 and 34 bit.
> 
> These three are all two bits more than some "regular" size --
> do those two extra bits have some special meaning perhaps,
> like an address space identifier or something?
> 
> > The Freescale's silicons is only support 34 bit address now.
> > Do you mean I should not use words -- 'should be <2>'?
> > The #address-cells should be assigned according the address mode
> > supported by silicon.
> 
> No.  The #address-cells is determined by the bus binding,
> so that all RapidIO busses on the planet can be represented
> in a similar way in the OF device tree.  Take for example
> the PCI binding, which gives you three address cells -- one
> to distinguish between different address spaces (configuration
> space, legacy I/O space, memory mapped space) and to contain
> some flags (prefetchable vs. non-prefetchable, etc.); the
> other two 32-bit cells contain a 64-bit address, although
> config and legacy I/O never are more than 32 bit, and many
> PCI devices can't do 64-bit addressing at all.
> 
> Now, there is no OF binding for RapidIO yet of course, but
> it would be good to start thinking about one while doing
> the binding for your specific controller -- it will make
> life easier down the line for everyone, including yourself.
> 
How about I add more words here for more clear expression?
Such as "<2> for 34 and 50 bit address, <3> for 66 bit address".

Thanks!
Wei.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/5 v2] Add the explanation and a sample of RapidIO DTS sector to the document of booting-without-of.txt file.

2007-06-29 Thread Zhang Wei-r63237
Hi, Segher, 

 DTS sector to the document of booting-without-of.txt file.
 
  +- #address-cells : Address representation for
  rapidio devices.
  +  This field represents the number of cells needed 
 to represent
  +  the RapidIO address of the registers.  For
  supporting more than
  +  32-bits RapidIO address, this field should be 2.
  +  See 1) above for more details on defining #address-cells.
 
  What does the RapidIO standard say about number of address
  bits?  You want to follow that, so all RapidIO devices can
  use the same #address-cells, not just the FSL ones.  Also,
  are there different kinds of address spaces on the bus, or
  is it just one big memory-like space?
 
  I've checked the specification of RapidIO. The supporting of RapidIO
  extended address modes are 66, 50 and 34 bit.
 
 These three are all two bits more than some regular size --
 do those two extra bits have some special meaning perhaps,
 like an address space identifier or something?
 
  The Freescale's silicons is only support 34 bit address now.
  Do you mean I should not use words -- 'should be 2'?
  The #address-cells should be assigned according the address mode
  supported by silicon.
 
 No.  The #address-cells is determined by the bus binding,
 so that all RapidIO busses on the planet can be represented
 in a similar way in the OF device tree.  Take for example
 the PCI binding, which gives you three address cells -- one
 to distinguish between different address spaces (configuration
 space, legacy I/O space, memory mapped space) and to contain
 some flags (prefetchable vs. non-prefetchable, etc.); the
 other two 32-bit cells contain a 64-bit address, although
 config and legacy I/O never are more than 32 bit, and many
 PCI devices can't do 64-bit addressing at all.
 
 Now, there is no OF binding for RapidIO yet of course, but
 it would be good to start thinking about one while doing
 the binding for your specific controller -- it will make
 life easier down the line for everyone, including yourself.
 
How about I add more words here for more clear expression?
Such as 2 for 34 and 50 bit address, 3 for 66 bit address.

Thanks!
Wei.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/5 v2] Add the explanation and a sample of RapidIO DTS sector to the document of booting-without-of.txt file.

2007-06-28 Thread Zhang Wei-r63237
Hi, Segher, 
 
> > +- #address-cells : Address representation for 
> "rapidio" devices.
> > +  This field represents the number of cells needed to represent
> > +  the RapidIO address of the registers.  For 
> supporting more than
> > +  32-bits RapidIO address, this field should be <2>.
> > +  See 1) above for more details on defining #address-cells.
> 
> What does the RapidIO standard say about number of address
> bits?  You want to follow that, so all RapidIO devices can
> use the same #address-cells, not just the FSL ones.  Also,
> are there different kinds of address spaces on the bus, or
> is it just one big memory-like space?
> 
> 

I've checked the specification of RapidIO. The supporting of RapidIO
extended address modes are 66, 50 and 34 bit.
The Freescale's silicons is only support 34 bit address now.
Do you mean I should not use words -- 'should be <2>'?
The #address-cells should be assigned according the address mode
supported by silicon.

Thanks!
Wei.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 3/5 v2] Add the platform device support with RapidIO to MPC8641HPCN platform.

2007-06-28 Thread Zhang Wei-r63237
Hi, Arnd,


> 
> On Wednesday 27 June 2007, Zhang Wei wrote:
> > +static struct of_device_id mpc86xx_of_ids[] = {
> > +   { .type = "soc", },
> > +   { .compatible = "fsl,rapidio-delta", },
> > +   {},
> > +};
> > +
> > +static __init int mpc86xx_of_device_init(void)
> > +{
> > +   return of_platform_bus_probe(NULL, mpc86xx_of_ids, NULL);
> > +}
> 
> This will add any devices below the "fsl,rapidio-delta" device
> as an of_device. Is that what you actually want? I would guess that
> you want to add the bridge itself, not the devices below it.
> 
> Is the rapidio device at the root of the device tree, and if so, why
> not under the soc bus?
> 

RapidIO is rather a bus that a device although these is no other nodes defined 
in its sector now.

Thanks!
Wei.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 3/5 v2] Add the platform device support with RapidIO to MPC8641HPCN platform.

2007-06-28 Thread Zhang Wei-r63237
Hi, Arnd,


 
 On Wednesday 27 June 2007, Zhang Wei wrote:
  +static struct of_device_id mpc86xx_of_ids[] = {
  +   { .type = soc, },
  +   { .compatible = fsl,rapidio-delta, },
  +   {},
  +};
  +
  +static __init int mpc86xx_of_device_init(void)
  +{
  +   return of_platform_bus_probe(NULL, mpc86xx_of_ids, NULL);
  +}
 
 This will add any devices below the fsl,rapidio-delta device
 as an of_device. Is that what you actually want? I would guess that
 you want to add the bridge itself, not the devices below it.
 
 Is the rapidio device at the root of the device tree, and if so, why
 not under the soc bus?
 

RapidIO is rather a bus that a device although these is no other nodes defined 
in its sector now.

Thanks!
Wei.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH 1/5 v2] Add the explanation and a sample of RapidIO DTS sector to the document of booting-without-of.txt file.

2007-06-28 Thread Zhang Wei-r63237
Hi, Segher, 
 
  +- #address-cells : Address representation for 
 rapidio devices.
  +  This field represents the number of cells needed to represent
  +  the RapidIO address of the registers.  For 
 supporting more than
  +  32-bits RapidIO address, this field should be 2.
  +  See 1) above for more details on defining #address-cells.
 
 What does the RapidIO standard say about number of address
 bits?  You want to follow that, so all RapidIO devices can
 use the same #address-cells, not just the FSL ones.  Also,
 are there different kinds of address spaces on the bus, or
 is it just one big memory-like space?
 
 

I've checked the specification of RapidIO. The supporting of RapidIO
extended address modes are 66, 50 and 34 bit.
The Freescale's silicons is only support 34 bit address now.
Do you mean I should not use words -- 'should be 2'?
The #address-cells should be assigned according the address mode
supported by silicon.

Thanks!
Wei.
-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/5 v2] Add the memory management driver to RapidIO.

2007-06-27 Thread Zhang Wei
This patch adds the memory management driver to RapidIO.
The RapidIO system size is changed to automatically detection.
Add the memory mapping driver to RapidIO basic driver.
Multi master ports are supported.
Add a simple Bitmap RapidIO space allocator driver.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 drivers/net/rionet.c|   17 +-
 drivers/rapidio/Kconfig |   18 +-
 drivers/rapidio/Makefile|1 +
 drivers/rapidio/rio-access.c|   10 +-
 drivers/rapidio/rio-scan.c  |   53 +++--
 drivers/rapidio/rio-sysfs.c |3 +-
 drivers/rapidio/rio.c   |  479 ++-
 drivers/rapidio/rio.h   |9 +-
 drivers/rapidio/sallocator/Kconfig  |9 +
 drivers/rapidio/sallocator/Makefile |   12 +
 drivers/rapidio/sallocator/bitmap.c |  384 
 include/linux/rio.h |   71 +-
 include/linux/rio_drv.h |   41 +++-
 13 files changed, 1048 insertions(+), 59 deletions(-)
 create mode 100644 drivers/rapidio/sallocator/Kconfig
 create mode 100644 drivers/rapidio/sallocator/Makefile
 create mode 100644 drivers/rapidio/sallocator/bitmap.c

diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index df6b738..8dcda4d 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -78,7 +78,7 @@ static int rionet_capable = 1;
  * could be made into a hash table to save memory depending
  * on system trade-offs.
  */
-static struct rio_dev *rionet_active[RIO_MAX_ROUTE_ENTRIES];
+static struct rio_dev **rionet_active;
 
 #define is_rionet_capable(pef, src_ops, dst_ops)   \
((pef & RIO_PEF_INB_MBOX) &&\
@@ -115,6 +115,7 @@ static int rionet_rx_clean(struct net_device *ndev)
 
rnet->rx_skb[i]->data = data;
skb_put(rnet->rx_skb[i], RIO_MAX_MSG_SIZE);
+   rnet->rx_skb[i]->dev = ndev;
rnet->rx_skb[i]->protocol =
eth_type_trans(rnet->rx_skb[i], ndev);
error = netif_rx(rnet->rx_skb[i]);
@@ -202,7 +203,8 @@ static int rionet_start_xmit(struct sk_buff *skb, struct 
net_device *ndev)
}
 
if (eth->h_dest[0] & 0x01) {
-   for (i = 0; i < RIO_MAX_ROUTE_ENTRIES; i++)
+   for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rnet->mport->sys_size);
+   i++)
if (rionet_active[i])
rionet_queue_tx_msg(skb, ndev,
rionet_active[i]);
@@ -392,6 +394,8 @@ static void rionet_remove(struct rio_dev *rdev)
struct net_device *ndev = NULL;
struct rionet_peer *peer, *tmp;
 
+   free_pages((unsigned long)rionet_active, rdev->net->hport->sys_size ?
+   __ilog2(sizeof(void *)) + 4 : 0);
unregister_netdev(ndev);
kfree(ndev);
 
@@ -449,6 +453,15 @@ static int rionet_setup_netdev(struct rio_mport *mport)
goto out;
}
 
+   if (!(rionet_active = (struct rio_dev **)__get_free_pages(GFP_KERNEL,
+   mport->sys_size ? __ilog2(sizeof(void *)) + 4
+   : 0))) {
+   rc = -ENOMEM;
+   goto out;
+   }
+   memset((void *)rionet_active, 0, sizeof(void *) *
+   RIO_MAX_ROUTE_ENTRIES(mport->sys_size));
+
/* Set up private area */
rnet = (struct rionet_private *)ndev->priv;
rnet->mport = mport;
diff --git a/drivers/rapidio/Kconfig b/drivers/rapidio/Kconfig
index 4142115..f669108 100644
--- a/drivers/rapidio/Kconfig
+++ b/drivers/rapidio/Kconfig
@@ -1,14 +1,6 @@
 #
 # RapidIO configuration
 #
-config RAPIDIO_8_BIT_TRANSPORT
-   bool "8-bit transport addressing"
-   depends on RAPIDIO
-   ---help---
- By default, the kernel assumes a 16-bit addressed RapidIO
- network. By selecting this option, the kernel will support
- an 8-bit addressed network.
-
 config RAPIDIO_DISC_TIMEOUT
int "Discovery timeout duration (seconds)"
depends on RAPIDIO
@@ -16,3 +8,13 @@ config RAPIDIO_DISC_TIMEOUT
---help---
  Amount of time a discovery node waits for a host to complete
  enumeration before giving up.
+
+config RAPIDIO_PROC_FS
+   bool "I/O and Memory resource debug"
+   depends on RAPIDIO && PROC_FS
+   default y
+   ---help---
+ Enable this option, it will create a /proc/riores node for
+ monitoring the RapidIO I/O and Memory resource.
+
+source "drivers/rapidio/sallocator/Kconfig"
diff --git a/drivers/rapidio/Makefile b/drivers/rapidio/Makefile
index 7c0e181..e5b2f11 100644
--- a/drivers/rapidio/Makefile
+++ b/drivers/rapidio/Makefile
@@ -4,3 +4,4 @@

[PATCH 1/5 v2] Add the explanation and a sample of RapidIO DTS sector to the document of booting-without-of.txt file.

2007-06-27 Thread Zhang Wei
Add the explanation and a sample of RapidIO DTS sector to the document of 
booting-without-of.txt file.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 Documentation/powerpc/booting-without-of.txt |   34 ++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/Documentation/powerpc/booting-without-of.txt 
b/Documentation/powerpc/booting-without-of.txt
index b49ce16..98692ca 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1727,6 +1727,40 @@ platforms are moved over to use the 
flattened-device-tree model.
partition-names = "fs\0firmware";
};
 
+   k) RapidIO
+
+   Required properties:
+
+- compatible : Should be "fsl,rapidio-delta" for Freescale
+  PowerPC RapidIO controller.
+- #address-cells : Address representation for "rapidio" devices.
+  This field represents the number of cells needed to represent
+  the RapidIO address of the registers.  For supporting more than
+  32-bits RapidIO address, this field should be <2>.
+  See 1) above for more details on defining #address-cells.
+- reg : Offset and length of the register set for the device
+- ranges : Should be defined as specified in 1) to describe the
+  translation of addresses for memory mapped RapidIO memory
+  space.
+- interrupts : binding interrupts for this device sector,
+  please follow below orders:
+  .
+
+  Example:
+
+   [EMAIL PROTECTED]
+   compatible = "fsl,rapidio-delta";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   reg = ;
+   ranges = <0 0 c000 2000>;
+   interrupt-parent = <>;
+   /* err_irq bell_outb_irq bell_inb_irq msg1_tx_irq msg1_rx_irq
+ msg2_tx_irq msg2_rx_irq */
+   interrupts = <30 2 31 2 32 2 35 2 36 2 37 2 38 2>;
+   };
+
More devices will be defined as this spec matures.
 
 VII - Specifying interrupt information for devices
-- 
1.5.1

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/5 v2] Add the platform device support with RapidIO to MPC8641HPCN platform.

2007-06-27 Thread Zhang Wei
Add the platform device support with RapidIO to MPC8641HPCN platform.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/86xx/mpc86xx_hpcn.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c 
b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 7034bca..5518ed3 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -28,6 +28,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
@@ -467,3 +469,17 @@ define_machine(mpc86xx_hpcn) {
.calibrate_decr = generic_calibrate_decr,
.progress   = udbg_progress,
 };
+
+
+static struct of_device_id mpc86xx_of_ids[] = {
+   { .type = "soc", },
+   { .compatible = "fsl,rapidio-delta", },
+   {},
+};
+
+static __init int mpc86xx_of_device_init(void)
+{
+   return of_platform_bus_probe(NULL, mpc86xx_of_ids, NULL);
+}
+
+device_initcall(mpc86xx_of_device_init);
-- 
1.5.1

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[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

[PATCH 0/5 v2] Porting RapidIO driver from ppc to powerpc architecture and adding memory mapped RapidIO driver.

2007-06-27 Thread Zhang Wei
Hi, Matt Porter,

These are the version 2 patches for RapidIO with dts update and some minor 
fixups.

These patches are used for supporting RapidIO controllers of Freescale. I 
ported them from ppc architecture to powerpc architecture and added some new 
features, such as memory mapped driver.

[PATCH 1/5] Add the explanation and sample of RapidIO DTS sector to the 
document of booting-without-of.txt file.
[PATCH 2/5] Add RapidIO sector to MPC8641HPCN board dts file.
[PATCH 3/5] Add the platform device support with RapidIO to MPC8641HPCN 
platform.
[PATCH 4/5] Add RapidIO support to powerpc architecture.
[PATCH 5/5] Add the memory management driver to RapidIO.

Please see below descriptions of these patches:
1. Add the RapidIO driver of-device support.
2. Add the RapidIO driver support to MPC8641HPCN board.
3. Port the RapidIO from ppc to powerpc architecture.
4. Add Memory mapped RapidIO driver.
5. Add the support to multi master ports.
6. Add a simple bitmap RapidIO space allocator driver.
7. Change the RapidIO system size of menuconfig to automatically detection.

Thanks!

Best Regards,
Zhang Wei




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5 v2] Add RapidIO sector to the MPC8641HPCN board dts file.

2007-06-27 Thread Zhang Wei
Add RapidIO sector to the MPC8641HPCN board dts file.

Signed-off-by: Zhang Wei <[EMAIL PROTECTED]>
---
 arch/powerpc/boot/dts/mpc8641_hpcn.dts |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn.dts 
b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
index 04626b1..abc9ff3 100644
--- a/arch/powerpc/boot/dts/mpc8641_hpcn.dts
+++ b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
@@ -329,6 +329,19 @@
>;
};
 
+   [EMAIL PROTECTED] {
+   compatible = "fsl,rapidio-delta";
+   #address-cells = <2>;
+   #size-cells = <2>;
+   reg = ;
+   ranges = <0 0 c000 2000>;
+   interrupt-parent = <>;
+   /* err_irq bell_outb_irq bell_inb_irq
+   msg1_tx_irq msg1_rx_irq
+   msg2_tx_irq msg2_rx_irq */
+   interrupts = <30 2 31 2 32 2 35 2 36 2 37 2 38 2>;
+   };
+
mpic: [EMAIL PROTECTED] {
clock-frequency = <0>;
interrupt-controller;
-- 
1.5.1

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/5 v2] Porting RapidIO driver from ppc to powerpc architecture and adding memory mapped RapidIO driver.

2007-06-27 Thread Zhang Wei
Hi, Matt Porter,

These are the version 2 patches for RapidIO with dts update and some minor 
fixups.

These patches are used for supporting RapidIO controllers of Freescale. I 
ported them from ppc architecture to powerpc architecture and added some new 
features, such as memory mapped driver.

[PATCH 1/5] Add the explanation and sample of RapidIO DTS sector to the 
document of booting-without-of.txt file.
[PATCH 2/5] Add RapidIO sector to MPC8641HPCN board dts file.
[PATCH 3/5] Add the platform device support with RapidIO to MPC8641HPCN 
platform.
[PATCH 4/5] Add RapidIO support to powerpc architecture.
[PATCH 5/5] Add the memory management driver to RapidIO.

Please see below descriptions of these patches:
1. Add the RapidIO driver of-device support.
2. Add the RapidIO driver support to MPC8641HPCN board.
3. Port the RapidIO from ppc to powerpc architecture.
4. Add Memory mapped RapidIO driver.
5. Add the support to multi master ports.
6. Add a simple bitmap RapidIO space allocator driver.
7. Change the RapidIO system size of menuconfig to automatically detection.

Thanks!

Best Regards,
Zhang Wei




-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/5 v2] Add RapidIO sector to the MPC8641HPCN board dts file.

2007-06-27 Thread Zhang Wei
Add RapidIO sector to the MPC8641HPCN board dts file.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 arch/powerpc/boot/dts/mpc8641_hpcn.dts |   13 +
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn.dts 
b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
index 04626b1..abc9ff3 100644
--- a/arch/powerpc/boot/dts/mpc8641_hpcn.dts
+++ b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
@@ -329,6 +329,19 @@
;
};
 
+   [EMAIL PROTECTED] {
+   compatible = fsl,rapidio-delta;
+   #address-cells = 2;
+   #size-cells = 2;
+   reg = c 2;
+   ranges = 0 0 c000 2000;
+   interrupt-parent = mpic;
+   /* err_irq bell_outb_irq bell_inb_irq
+   msg1_tx_irq msg1_rx_irq
+   msg2_tx_irq msg2_rx_irq */
+   interrupts = 30 2 31 2 32 2 35 2 36 2 37 2 38 2;
+   };
+
mpic: [EMAIL PROTECTED] {
clock-frequency = 0;
interrupt-controller;
-- 
1.5.1

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[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

[PATCH 1/5 v2] Add the explanation and a sample of RapidIO DTS sector to the document of booting-without-of.txt file.

2007-06-27 Thread Zhang Wei
Add the explanation and a sample of RapidIO DTS sector to the document of 
booting-without-of.txt file.

Signed-off-by: Zhang Wei [EMAIL PROTECTED]
---
 Documentation/powerpc/booting-without-of.txt |   34 ++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/Documentation/powerpc/booting-without-of.txt 
b/Documentation/powerpc/booting-without-of.txt
index b49ce16..98692ca 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1727,6 +1727,40 @@ platforms are moved over to use the 
flattened-device-tree model.
partition-names = fs\0firmware;
};
 
+   k) RapidIO
+
+   Required properties:
+
+- compatible : Should be fsl,rapidio-delta for Freescale
+  PowerPC RapidIO controller.
+- #address-cells : Address representation for rapidio devices.
+  This field represents the number of cells needed to represent
+  the RapidIO address of the registers.  For supporting more than
+  32-bits RapidIO address, this field should be 2.
+  See 1) above for more details on defining #address-cells.
+- reg : Offset and length of the register set for the device
+- ranges : Should be defined as specified in 1) to describe the
+  translation of addresses for memory mapped RapidIO memory
+  space.
+- interrupts : binding interrupts for this device sector,
+  please follow below orders:
+  err_irq bell_outb_irq bell_inb_irq msg1_tx_irq msg1_rx_irq
+  msg2_tx_irq msg2_rx_irq ... msgN_tx_irq msgN_rx_irq.
+
+  Example:
+
+   [EMAIL PROTECTED]
+   compatible = fsl,rapidio-delta;
+   #address-cells = 2;
+   #size-cells = 2;
+   reg = c 2;
+   ranges = 0 0 c000 2000;
+   interrupt-parent = mpic;
+   /* err_irq bell_outb_irq bell_inb_irq msg1_tx_irq msg1_rx_irq
+ msg2_tx_irq msg2_rx_irq */
+   interrupts = 30 2 31 2 32 2 35 2 36 2 37 2 38 2;
+   };
+
More devices will be defined as this spec matures.
 
 VII - Specifying interrupt information for devices
-- 
1.5.1

-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   >