[PATCH] Add USB to MPC8349 PB platform support

Li Yang-r58472 LeoLi at freescale.com
Thu Jul 20 16:32:43 EST 2006


> -----Original Message-----
> From: linuxppc-dev-bounces+leoli=freescale.com at ozlabs.org
> [mailto:linuxppc-dev-bounces+leoli=freescale.com at ozlabs.org] On Behalf
Of Kumar
> Gala
> Sent: Thursday, July 20, 2006 4:09 AM
> To: Li Yang-r58472
> Cc: linuxppc-dev at ozlabs.org; linux-usb-devel at lists.sourceforge.net
> Subject: Re: [PATCH] Add USB to MPC8349 PB platform support
> 
> 
> On Jul 14, 2006, at 6:52 AM, Li Yang wrote:
> 
> > This adds USB platform support to MPC8349 PB.  It works with the
> > fsl_usb2_udc driver.
> >
> > Signed-off-by: Li Yang <leoli at freescale.com>
> > ---
> >
> > arch/powerpc/platforms/83xx/Kconfig       |   4  ++
> > arch/powerpc/platforms/83xx/mpc834x_sys.c |   72 +++++++++++++++++++
> > ++++++++++
> > arch/powerpc/platforms/83xx/mpc834x_sys.h |   24 ++++++++++
> > 3 files changed, 113 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/
> > platforms/83xx/Kconfig
> > index 7675e67..8404cdf 100644
> > --- a/arch/powerpc/platforms/83xx/Kconfig
> > +++ b/arch/powerpc/platforms/83xx/Kconfig
> > @@ -24,4 +31,14 @@ config MPC834x
> > 	select PPC_INDIRECT_PCI
> > 	default y if MPC834x_SYS
> >
> > +config 834x_USB_SUPPORT
> > +	bool
> > +	default y if MPC834x_SYS && (USB || USB_GADGET)
> > +
> > endmenu
> 
> I dont think we need this, we should be able to use the USB, and 834x
> CONFIG options in the code.
> 
> > diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.c b/arch/
> > powerpc/platforms/83xx/mpc834x_sys.c
> > index 7e789d2..f10d4ae 100644
> > --- a/arch/powerpc/platforms/83xx/mpc834x_sys.c
> > +++ b/arch/powerpc/platforms/83xx/mpc834x_sys.c
> > @@ -36,6 +36,7 @@ #include <asm/irq.h>
> > #include <asm/prom.h>
> > #include <asm/udbg.h>
> > #include <sysdev/fsl_soc.h>
> > +#include <linux/fsl_devices.h>
> > #include "mpc83xx.h"
> > @@ -71,6 +72,72 @@ mpc83xx_map_irq(struct pci_dev *dev, uns
> > }
> > #endif				/* CONFIG_PCI */
> > +#ifdef CONFIG_834x_USB_SUPPORT
> 
> Just make it dependent on CONFIG_USB_EHCI_HCD or something like that.

Will need to check EHCI_HCD/GADGET and their _MODULE variations though.
Not very neat I think.  Anyway, it's your call.
> 
> > +void mpc834x_usb_board_cfg(void)
> > +{
> > +	unsigned char __iomem *bcsr;
> > +	volatile unsigned char *bcsr5_p;
> > +
> > +	/*
> > +	 * if SYS board is plug into PIB board,
> > +	 * force to use the PHY on SYS board
> > +	 * */
> > +	bcsr = ioremap(BCSR_PHYS_ADDR, BCSR_SIZE);
> > +	bcsr5_p = bcsr + BCSR5_OFF;
> > +	if ( (*bcsr5_p & BCSR5_INT_USB) == 0 )
> > +		*bcsr5_p = (*bcsr5_p | BCSR5_INT_USB);
> > +	iounmap(bcsr);
> > +}
> > +
> > +/* Note: This is only for PB, not for PB+PIB
> > + * On PB only port0 is connected using ULPI */
> > +static int mpc834x_usb_cfg(void)
> > +{
> > +	unsigned long sccr, sicrl;
> > +	volatile unsigned long *p;
> > +	unsigned long __iomem *immap;
> > +	struct device_node *np = NULL;
> > +	int port0_is_dr = 0;
> > +
> > +	if ((np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) !=
> > NULL)
> > +		port0_is_dr = 1;
> > +	if ((np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) !=
> > NULL){
> > +		if (port0_is_dr) {
> > +			printk(KERN_WARNING
> > +				"There is only one USB port on PB board!
\n");
> > +			return -1;
> > +		} else if (!port0_is_dr)
> > +			/* No usb port enabled */
> > +			return -1;
> > +	}
> > +
> > +	immap = ioremap(get_immrbase(), 0x100000);
> > +
> > +	/* Configure clock */
> > +	p = (volatile unsigned long *)((u32)immap + MPC83XX_SCCR_OFFS);
> > +	sccr = *p;
> > +	if (port0_is_dr)
> > +		sccr |= MPC83XX_SCCR_USB_DRCM_11;  /* 1:3 */
> > +	else
> > +		sccr |= MPC83XX_SCCR_USB_MPHCM_11; /* 1:3 */
> > +	*p = sccr;
> 
> This really needs to take into account the platform frequency.  I
> guess technically, at 1:3 we will always be below the max 133Mhz.

Generally, I assume the user is using a core frequency around the
recommended frequency in spec.  In some special cases, they do need to
use a lower core frequency.  But, I think it's too special to be
addressed here.  Anyway it's easy to change for users.
> 
> > +
> > +	/* Configure Pin */
> > +	p = (volatile unsigned long *)((u32)immap + MPC83XX_SICRL_OFFS);
> > +	sicrl = *p;
> > +	/* set port0 only */
> > +	if (port0_is_dr) +		sicrl |= MPC83XX_SICRL_USB0;
> > +	else +		sicrl &= ~(MPC83XX_SICRL_USB0);
> > +	*p = sicrl;
> > +
> 
> Why dont we just do all this in fsl_usb_of_init

It's easier to do in fsl_usb_of_init.  But do you think it's ok to put
834x specific code there?
> 
> > +	iounmap(immap);
> > +	return 0;
> > +}
> > +
> > +#endif /* CONFIG_834x_USB_SUPPORT */
> > +
> > /*
> >
**********************************************************************
> > **
> >  *
> >  * Setup the architecture
> > @@ -102,6 +169,11 @@ #ifdef CONFIG_PCI
> > 	ppc_md.pci_exclude_device = mpc83xx_exclude_device;
> > #endif
> > +#ifdef CONFIG_834x_USB_SUPPORT
> > +	mpc834x_usb_cfg();
> > +	mpc834x_usb_board_cfg();
> > +#endif
> > +
> > #ifdef  CONFIG_ROOT_NFS
> > 	ROOT_DEV = Root_NFS;
> > #else
> > diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.h b/arch/
> > powerpc/platforms/83xx/mpc834x_sys.h
> > index fedecb7..30e45e8 100644
> > --- a/arch/powerpc/platforms/83xx/mpc834x_sys.h
> > +++ b/arch/powerpc/platforms/83xx/mpc834x_sys.h
> > @@ -20,4 +20,28 @@ #define PIRQB	MPC83xx_IRQ_EXT5
> > #define PIRQC	MPC83xx_IRQ_EXT6
> > #define PIRQD	MPC83xx_IRQ_EXT7
> > +#define BCSR_PHYS_ADDR		((uint)0xf8000000)
> > +#define BCSR_SIZE		((uint)(32 * 1024))
> > + +#define BCSR5_OFF		0x05
> > +#define BCSR5_INT_USB		0x02
> > +
> > +#define MPC83XX_SCCR_OFFS          0xA08
> > +#define MPC83XX_SCCR_USB_MPHCM_11  0x00c00000
> > +#define MPC83XX_SCCR_USB_MPHCM_01  0x00400000
> > +#define MPC83XX_SCCR_USB_MPHCM_10  0x00800000
> > +#define MPC83XX_SCCR_USB_DRCM_11   0x00300000
> > +#define MPC83XX_SCCR_USB_DRCM_01   0x00100000
> > +#define MPC83XX_SCCR_USB_DRCM_10   0x00200000
> > +
> > +/* system i/o configuration register low */
> > +#define MPC83XX_SICRL_OFFS         0x114
> > +#define MPC83XX_SICRL_USB0         0x40000000
> > +#define MPC83XX_SICRL_USB1         0x20000000
> > +
> > +/* system i/o configuration register high */
> > +#define MPC83XX_SICRH_OFFS         0x118
> > +#define MPC83XX_SICRH_USB_UTMI     0x00020000
> 
> Are these really generic to all MPC83XX?  We should move these to
> include something like asm-ppc/mpc83xx.h

No, probably need to change the naming to MPC834x_*.  The offsets are
generic, but the USB bits are not.  If there is an asm/mpc834x.h, it
will be better there.
> 
> > +
> > +
> > #endif				/* __MACH_MPC83XX_SYS_H__ */
> 
> - kumar
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev at ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev



More information about the Linuxppc-dev mailing list