Re: [PATCH 4/6] powerpc: add USB peripheral support to MPC8272ADS

2008-08-07 Thread Scott Wood
On Thu, Aug 07, 2008 at 11:50:14AM +0800, Li Yang wrote:
 udc is a common name for USB device mode drivers to work with Linux
 gadget.  We will have two separate drivers for USB host and device.
 Probably we can have two compatibles fsl,qe_udc and fsl,qe-usb-host

1. If you have separate compatibles, what do you need the mode property
for?
2. mpc8272 is not QE.
3. fsl,cpm2-usb-slave would be much more readable than fsl,qe_udc.

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 4/6] powerpc: add USB peripheral support to MPC8272ADS

2008-08-06 Thread Li Yang
Signed-off-by: Li Yang [EMAIL PROTECTED]
---
 arch/powerpc/boot/dts/mpc8272ads.dts  |8 
 arch/powerpc/platforms/82xx/mpc8272_ads.c |   25 +
 arch/powerpc/platforms/82xx/pq2ads.h  |3 +++
 3 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/dts/mpc8272ads.dts 
b/arch/powerpc/boot/dts/mpc8272ads.dts
index b2ce4c0..75cc94c 100644
--- a/arch/powerpc/boot/dts/mpc8272ads.dts
+++ b/arch/powerpc/boot/dts/mpc8272ads.dts
@@ -256,6 +256,14 @@
#address-cells = 1;
#size-cells = 0;
};
+
+   [EMAIL PROTECTED] {
+   compatible = fsl,qe_udc;
+   reg = 0x11b60 0x40 0x8b00 0x100;
+   interrupts = 11 8;
+   interrupt-parent = PIC;
+   mode = slave;
+   };
};
 
PIC: [EMAIL PROTECTED] {
diff --git a/arch/powerpc/platforms/82xx/mpc8272_ads.c 
b/arch/powerpc/platforms/82xx/mpc8272_ads.c
index 8054c68..69781e6 100644
--- a/arch/powerpc/platforms/82xx/mpc8272_ads.c
+++ b/arch/powerpc/platforms/82xx/mpc8272_ads.c
@@ -23,6 +23,7 @@
 #include asm/udbg.h
 #include asm/machdep.h
 #include asm/time.h
+#include asm/fs_pd.h
 
 #include platforms/82xx/pq2.h
 
@@ -100,11 +101,22 @@ static struct cpm_pin mpc8272_ads_pins[] = {
/* I2C */
{3, 14, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
{3, 15, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_OPENDRAIN},
+
+   /* USB */
+   {2, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* output enable */
+   {2, 11, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* RP */
+   {2, 10, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* RN */
+   {3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* Rxd */
+   {3, 24, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* TN */
+   {3, 23, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY}, /* TP */
+   {2, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY},  /* Usb_clk */
 };
 
 static void __init init_ioports(void)
 {
int i;
+   cpmux_t __iomem *im_cpmux;
+   u32 reg;
 
for (i = 0; i  ARRAY_SIZE(mpc8272_ads_pins); i++) {
struct cpm_pin *pin = mpc8272_ads_pins[i];
@@ -119,6 +131,13 @@ static void __init init_ioports(void)
cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_TX);
cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK15, CPM_CLK_RX);
cpm2_clk_setup(CPM_CLK_FCC2, CPM_CLK16, CPM_CLK_TX);
+
+   /* USB use clock of SCC3 */
+   cpm2_clk_setup(CPM_CLK_SCC3, CPM_CLK8, CPM_CLK_TX);
+   /* SCC3 cannot be used in NMSI mode */
+   im_cpmux = cpm2_map(im_cpmux);
+   reg = in_be32(im_cpmux-cmx_scr);
+   out_be32(im_cpmux-cmx_scr, reg | CMXSCR_SC3);
 }
 
 static void __init mpc8272_ads_setup_arch(void)
@@ -150,6 +169,12 @@ static void __init mpc8272_ads_setup_arch(void)
clrbits32(bcsr[3], BCSR3_FETHIEN2);
setbits32(bcsr[3], BCSR3_FETH2_RST);
 
+   /* Enabling USB support in BCSR */
+   np = of_find_compatible_node(NULL, NULL, fsl,qe_udc);
+   if (np != NULL) {
+   clrbits32(bcsr[3], BCSR3_USB_EN);
+   clrbits32(bcsr[3], BCSR3_USB_HI_SPEED);
+   }
iounmap(bcsr);
 
init_ioports();
diff --git a/arch/powerpc/platforms/82xx/pq2ads.h 
b/arch/powerpc/platforms/82xx/pq2ads.h
index 984db42..d0e82e2 100644
--- a/arch/powerpc/platforms/82xx/pq2ads.h
+++ b/arch/powerpc/platforms/82xx/pq2ads.h
@@ -43,6 +43,9 @@
 #define BCSR1_RS232_EN2((uint)0x0100)  /* 0 ==enable */
 #define BCSR3_FETHIEN2 ((uint)0x1000)  /* 0 == enable*/
 #define BCSR3_FETH2_RST((uint)0x8000)  /* 0 == reset */
+#define BCSR3_USB_EN  ((uint)0x8000)/* 0 == enable*/
+#define BCSR3_USB_HI_SPEED ((uint)0x4000)   /* 0 == highspeed */
+#define BCSR3_USBVCC ((uint)0x2000) /* 0 == disable */
 
 /* cpm serial driver works with constants below */
 
-- 
1.5.5.1.248.g4b17

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 4/6] powerpc: add USB peripheral support to MPC8272ADS

2008-08-06 Thread Stephen Rothwell
Hi Li,

On Wed,  6 Aug 2008 15:04:43 +0800 Li Yang [EMAIL PROTECTED] wrote:

 @@ -150,6 +169,12 @@ static void __init mpc8272_ads_setup_arch(void)
   clrbits32(bcsr[3], BCSR3_FETHIEN2);
   setbits32(bcsr[3], BCSR3_FETH2_RST);
  
 + /* Enabling USB support in BCSR */
 + np = of_find_compatible_node(NULL, NULL, fsl,qe_udc);
 + if (np != NULL) {

of_node_put(np);

 + clrbits32(bcsr[3], BCSR3_USB_EN);
 + clrbits32(bcsr[3], BCSR3_USB_HI_SPEED);
 + }
-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


pgp8ccU0tfaOE.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Re: [PATCH 4/6] powerpc: add USB peripheral support to MPC8272ADS

2008-08-06 Thread Scott Wood
On Wed, Aug 06, 2008 at 03:04:43PM +0800, Li Yang wrote:
 Signed-off-by: Li Yang [EMAIL PROTECTED]
 ---
  arch/powerpc/boot/dts/mpc8272ads.dts  |8 
  arch/powerpc/platforms/82xx/mpc8272_ads.c |   25 +
  arch/powerpc/platforms/82xx/pq2ads.h  |3 +++
  3 files changed, 36 insertions(+), 0 deletions(-)
 
 diff --git a/arch/powerpc/boot/dts/mpc8272ads.dts 
 b/arch/powerpc/boot/dts/mpc8272ads.dts
 index b2ce4c0..75cc94c 100644
 --- a/arch/powerpc/boot/dts/mpc8272ads.dts
 +++ b/arch/powerpc/boot/dts/mpc8272ads.dts
 @@ -256,6 +256,14 @@
   #address-cells = 1;
   #size-cells = 0;
   };
 +
 + [EMAIL PROTECTED] {
 + compatible = fsl,qe_udc;

fsl,mpc8272-usb, fsl,cpm2-usb.

Where is fsl,qe_udc documented or used (other than in the BCSR setup)?
What does udc mean (the only reference to it in the 8272 manual is
under ATM)?

 + mode = slave;

Please document this property.

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 4/6] powerpc: add USB peripheral support to MPC8272ADS

2008-08-06 Thread Li Yang
On Wed, 2008-08-06 at 12:19 -0500, Scott Wood wrote:
 On Wed, Aug 06, 2008 at 03:04:43PM +0800, Li Yang wrote:
  Signed-off-by: Li Yang [EMAIL PROTECTED]
  ---
   arch/powerpc/boot/dts/mpc8272ads.dts  |8 
   arch/powerpc/platforms/82xx/mpc8272_ads.c |   25 +
   arch/powerpc/platforms/82xx/pq2ads.h  |3 +++
   3 files changed, 36 insertions(+), 0 deletions(-)
  
  diff --git a/arch/powerpc/boot/dts/mpc8272ads.dts 
  b/arch/powerpc/boot/dts/mpc8272ads.dts
  index b2ce4c0..75cc94c 100644
  --- a/arch/powerpc/boot/dts/mpc8272ads.dts
  +++ b/arch/powerpc/boot/dts/mpc8272ads.dts
  @@ -256,6 +256,14 @@
  #address-cells = 1;
  #size-cells = 0;
  };
  +
  +   [EMAIL PROTECTED] {
  +   compatible = fsl,qe_udc;
 
 fsl,mpc8272-usb, fsl,cpm2-usb.
 
 Where is fsl,qe_udc documented or used (other than in the BCSR setup)?
 What does udc mean (the only reference to it in the 8272 manual is
 under ATM)?

udc is a common name for USB device mode drivers to work with Linux
gadget.  We will have two separate drivers for USB host and device.
Probably we can have two compatibles fsl,qe_udc and fsl,qe-usb-host

- Leo

___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev