83xx USB platform code rework
Subsystems (2)
PATCH v3 1/1 83xx USB platform code rework
Add 831x USB platform setup code and rework 834x USB platform setup code. Move USB platform code to usb.c for different boards with CPU of the same series to share the USB initialization code.
---
Change to use of_get_property instead of get_property.
arch/powerpc/platforms/83xx/Kconfig | 2 + arch/powerpc/platforms/83xx/Makefile | 2 +- arch/powerpc/platforms/83xx/mpc8313_rdb.c | 1 + arch/powerpc/platforms/83xx/mpc834x_mds.c | 49 +------- arch/powerpc/platforms/83xx/mpc83xx.h | 28 ++++- arch/powerpc/platforms/83xx/usb.c | 175 +++++++++++++++++++++++++++++ 6 files changed, 209 insertions(+), 48 deletions(-)
create mode 100644 arch/powerpc/platforms/83xx/usb.c
arch/powerpc/platforms/83xx/Kconfig +0 -0
@@ -51,6 +51,7 @@ config PPC_MPC831x
bool select PPC_UDBG_16550 select PPC_INDIRECT_PCI
+ select USB_EHCI_FSL
default y if MPC8313_RDB
config PPC_MPC832x
@@ -63,6 +64,7 @@ config MPC834x
bool select PPC_UDBG_16550 select PPC_INDIRECT_PCI + select USB_EHCI_FSL default y if MPC834x_MDS || MPC834x_ITX
config PPC_MPC836x
arch/powerpc/platforms/83xx/Makefile +0 -0
@@ -1,7 +1,7 @@
#
# Makefile for the PowerPC 83xx linux kernel.
#
-obj-y := misc.o
+obj-y := misc.o usb.o
obj-$(CONFIG_PCI) += pci.o
obj-$(CONFIG_MPC8313_RDB) += mpc8313_rdb.o
obj-$(CONFIG_MPC834x_MDS) += mpc834x_mds.o
arch/powerpc/platforms/83xx/mpc8313_rdb.c +0 -0
@@ -53,6 +53,7 @@ static void __init mpc8313_rdb_setup_arch(void)
ppc_md.pci_exclude_device = mpc83xx_exclude_device;
#endif
+ mpc831x_usb_cfg();
}
void __init mpc8313_rdb_init_IRQ(void)
arch/powerpc/platforms/83xx/mpc834x_mds.c +0 -0
@@ -44,55 +44,16 @@ unsigned long isa_mem_base = 0;
#endif
#define BCSR5_INT_USB 0x02
-/* Note: This is only for PB, not for PB+PIB
- * On PB only port0 is connected using ULPI */
-static int mpc834x_usb_cfg(void)
+static int mpc834xemds_usb_cfg(void)
{
- unsigned long sccr, sicrl;
- void __iomem *immap;
+ struct device_node *np; void __iomem *bcsr_regs = NULL; u8 bcsr5;
- struct device_node *np = NULL;
- int port0_is_dr = 0;
-
- if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr")) != NULL)
- port0_is_dr = 1;
- if ((np = of_find_compatible_node(NULL, "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(), 0x1000);
- if (!immap)
- return -1;
-
- /* Configure clock */
- sccr = in_be32(immap + MPC83XX_SCCR_OFFS);
- if (port0_is_dr)
- sccr |= MPC83XX_SCCR_USB_DRCM_11; /* 1:3 */
- else
- sccr |= MPC83XX_SCCR_USB_MPHCM_11; /* 1:3 */
- out_be32(immap + MPC83XX_SCCR_OFFS, sccr);
-
- /* Configure Pin */
- sicrl = in_be32(immap + MPC83XX_SICRL_OFFS);
- /* set port0 only */
- if (port0_is_dr)
- sicrl |= MPC83XX_SICRL_USB0;
- else
- sicrl &= ~(MPC83XX_SICRL_USB0);
- out_be32(immap + MPC83XX_SICRL_OFFS, sicrl);
-
- iounmap(immap);
+ mpc834x_usb_cfg();
/* Map BCSR area */
np = of_find_node_by_name(NULL, "bcsr");
- if (np != 0) {
+ if (np) {
struct resource res;
of_address_to_resource(np, 0, &res);
@@ -134,7 +95,7 @@ static void __init mpc834x_mds_setup_arch(void)
ppc_md.pci_exclude_device = mpc83xx_exclude_device;#endif
- mpc834x_usb_cfg();
+ mpc834xemds_usb_cfg();
}
static void __init mpc834x_mds_init_IRQ(void)
arch/powerpc/platforms/83xx/mpc83xx.h +0 -0
@@ -6,6 +6,7 @@
/* System Clock Control Register */
#define MPC83XX_SCCR_OFFS 0xA08
+#define MPC83XX_SCCR_USB_MASK 0x00f00000
#define MPC83XX_SCCR_USB_MPHCM_11 0x00c00000 #define MPC83XX_SCCR_USB_MPHCM_01 0x00400000 #define MPC83XX_SCCR_USB_MPHCM_10 0x00800000
@@ -15,12 +16,31 @@
/* system i/o configuration register low */
#define MPC83XX_SICRL_OFFS 0x114
-#define MPC83XX_SICRL_USB0 0x40000000 -#define MPC83XX_SICRL_USB1 0x20000000 +#define MPC834X_SICRL_USB_MASK 0x60000000 +#define MPC834X_SICRL_USB0 0x40000000 +#define MPC834X_SICRL_USB1 0x20000000 +#define MPC831X_SICRL_USB_MASK 0x00000c00 +#define MPC831X_SICRL_USB_ULPI 0x00000800
/* system i/o configuration register high */
#define MPC83XX_SICRH_OFFS 0x118
-#define MPC83XX_SICRH_USB_UTMI 0x00020000 +#define MPC834X_SICRH_USB_UTMI 0x00020000 +#define MPC831X_SICRH_USB_MASK 0x000000e0 +#define MPC831X_SICRH_USB_ULPI 0x000000a0 + +/* USB Control Register */ +#define FSL_USB2_CONTROL_OFFS 0x500 +#define CONTROL_UTMI_PHY_EN 0x00000200 +#define CONTROL_REFSEL_48MHZ 0x00000080 +#define CONTROL_PHY_CLK_SEL_ULPI 0x00000400 +#define CONTROL_OTG_PORT 0x00000020 + +/* USB PORTSC Registers */ +#define FSL_USB2_PORTSC1_OFFS 0x184 +#define FSL_USB2_PORTSC2_OFFS 0x188 +#define PORTSCX_PTW_16BIT 0x10000000 +#define PORTSCX_PTS_UTMI 0x00000000 +#define PORTSCX_PTS_ULPI 0x80000000
/*
* Declaration for the various functions exported by the
@@ -31,5 +51,7 @@ extern int add_bridge(struct device_node *dev); extern int mpc83xx_exclude_device(u_char bus, u_char devfn); extern void mpc83xx_restart(char *cmd);
extern long mpc83xx_time_init(void);
+extern int mpc834x_usb_cfg(void);
+extern int mpc831x_usb_cfg(void);
#endif /* __MPC83XX_H__ */
arch/powerpc/platforms/83xx/usb.c new file +175 -0
175 lines not on this page · raw message
Review
Quoted 3 lines · On Fri, 11 May 2007 19:32:37 +0800 Li Yang <[email protected]> wrote:
(quoted diff) +2
-0+ if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr")) + != NULL) {
Normally we like to separate the assignment from the test. There are a couple of other places like this.
arch/powerpc/platforms/83xx/usb.c line 55
Quoted 2 lines
arch/powerpc/platforms/83xx/usb.c new file +2
-0+ }else if (prop && !strcmp (prop,"serial" )) { +if (!strcmp (of_get_property (np,"dr_mode" ,NULL ),"otg" )) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Is there any chance that np doesn't have a "dr_mode" property?
arch/powerpc/platforms/83xx/usb.c line 162
Quoted 3 lines
arch/powerpc/platforms/83xx/usb.c new file +3
-0+#ifdef CONFIG_USB_OTG +/* Set OTG_PORT */ +if (!strcmp (of_get_property (np,"dr_mode" ,NULL ),"otg" ))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Again.
--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/
Quoted 5 lines
arch/powerpc/platforms/83xx/usb.c line 55
Quoted 2 lines
arch/powerpc/platforms/83xx/usb.c new file +2
-0+ }else if (prop && !strcmp (prop,"serial" )) { +if (!strcmp (of_get_property (np,"dr_mode" ,NULL ),"otg" )) {^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Is there any chance that np doesn't have a "dr_mode" property?
Yes, of course -- you can never trust the incoming device tree to be "correct".
Also, please no underscores in property names.
Segher