Add USB Host support for MPC5121 SoC
Subsystems (4)
v2 cover Add USB Host support for MPC5121 SoC
This is version 2 of patches to add MPC512x USB support in mainline kernel. USB OTG support is not included in this patch series, it will be submitted later.
The patches have been rebased on current linux-next tree and reworked to address comments from Grant.
Anatolij Gustschin (3):
powerpc/fsl_soc.c: remove FSL USB platform code
USB: add of_platform glue driver for FSL USB DR controller
USB: add USB EHCI support for MPC5121 SoC
Documentation/powerpc/dts-bindings/fsl/usb.txt | 22 ++ arch/powerpc/sysdev/fsl_soc.c | 163 ------------- drivers/usb/Kconfig | 1 + drivers/usb/gadget/Kconfig | 1 + drivers/usb/host/Kconfig | 10 +- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-fsl.c | 99 ++++++--- drivers/usb/host/ehci-fsl.h | 13 +- drivers/usb/host/ehci-mem.c | 2 +- drivers/usb/host/fsl-mph-dr-of.c | 302 ++++++++++++++++++++++++ include/linux/fsl_devices.h | 15 ++ 11 files changed, 434 insertions(+), 195 deletions(-) create mode 100644 drivers/usb/host/fsl-mph-dr-of.c
PATCH v2 1/3 powerpc/fsl_soc.c: remove FSL USB platform code
This removed code will be replaced by simple of_platform driver for creation of FSL USB platform devices which is added by next patch of the series.
--- arch/powerpc/sysdev/fsl_soc.c | 163 ----------------------------------------- 1 files changed, 0 insertions(+), 163 deletions(-)
arch/powerpc/sysdev/fsl_soc.c +0 -163
@@ -209,169 +209,6 @@ static int __init of_add_fixed_phys(void)arch_initcall (of_add_fixed_phys);#endif /* CONFIG_FIXED_PHY */ -static enum fsl_usb2_phy_modes determine_usb_phy (const char *phy_type) -{ -if (!phy_type) -return FSL_USB2_PHY_NONE ; -if (!strcasecmp (phy_type,"ulpi" )) -return FSL_USB2_PHY_ULPI ; -if (!strcasecmp (phy_type,"utmi" )) -return FSL_USB2_PHY_UTMI ; -if (!strcasecmp (phy_type,"utmi_wide" )) -return FSL_USB2_PHY_UTMI_WIDE ; -if (!strcasecmp (phy_type,"serial" )) -return FSL_USB2_PHY_SERIAL ; - -return FSL_USB2_PHY_NONE ; -} - -static int __init fsl_usb_of_init (void ) -{ -struct device_node *np; -unsigned int i =0 ; -struct platform_device *usb_dev_mph =NULL , *usb_dev_dr_host =NULL , - *usb_dev_dr_client =NULL ; -int ret; - -for_each_compatible_node (np,NULL ,"fsl-usb2-mph" ) { -struct resource r[2 ]; -struct fsl_usb2_platform_data usb_data; -const unsigned char *prop =NULL ; - -memset (&r,0 ,sizeof (r)); -memset (&usb_data,0 ,sizeof (usb_data)); - - ret =of_address_to_resource (np,0 , &r[0 ]); -if (ret) - goto err; - -of_irq_to_resource (np,0 , &r[1 ]); - - usb_dev_mph = -platform_device_register_simple ("fsl-ehci" , i, r,2 ); -if (IS_ERR (usb_dev_mph)) { - ret =PTR_ERR (usb_dev_mph); - goto err; - } - - usb_dev_mph->dev.coherent_dma_mask =0xffffffffUL ; - usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask; - - usb_data.operating_mode =FSL_USB2_MPH_HOST ; - - prop =of_get_property (np,"port0" ,NULL ); -if (prop) - usb_data.port_enables |=FSL_USB2_PORT0_ENABLED ; - - prop =of_get_property (np,"port1" ,NULL ); -if (prop) - usb_data.port_enables |=FSL_USB2_PORT1_ENABLED ; - - prop =of_get_property (np,"phy_type" ,NULL ); - usb_data.phy_mode =determine_usb_phy (prop); - - ret = -platform_device_add_data (usb_dev_mph, &usb_data, -sizeof (struct -fsl_usb2_platform_data )); -if (ret) - goto unreg_mph; - i++; - } - -for_each_compatible_node (np,NULL ,"fsl-usb2-dr" ) { -struct resource r[2 ]; -struct fsl_usb2_platform_data usb_data; -const unsigned char *prop =NULL ; - -if (!of_device_is_available (np)) -continue ; - -memset (&r,0 ,sizeof (r)); -memset (&usb_data,0 ,sizeof (usb_data)); - - ret =of_address_to_resource (np,0 , &r[0 ]); -if (ret) - goto unreg_mph; - -of_irq_to_resource (np,0 , &r[1 ]); - - prop =of_get_property (np,"dr_mode" ,NULL ); - -if (!prop || !strcmp (prop,"host" )) { - usb_data.operating_mode =FSL_USB2_DR_HOST ; - usb_dev_dr_host =platform_device_register_simple ( -"fsl-ehci" , i, r,2 ); -if (IS_ERR (usb_dev_dr_host)) { - ret =PTR_ERR (usb_dev_dr_host); - goto err; - } - }else if (prop && !strcmp (prop,"peripheral" )) { - usb_data.operating_mode =FSL_USB2_DR_DEVICE ; - usb_dev_dr_client =platform_device_register_simple ( -"fsl-usb2-udc" , i, r,2 ); -if (IS_ERR (usb_dev_dr_client)) { - ret =PTR_ERR (usb_dev_dr_client); - goto err; - } - }else if (prop && !strcmp (prop,"otg" )) { - usb_data.operating_mode =FSL_USB2_DR_OTG ; - usb_dev_dr_host =platform_device_register_simple ( -"fsl-ehci" , i, r,2 ); -if (IS_ERR (usb_dev_dr_host)) { - ret =PTR_ERR (usb_dev_dr_host); - goto err; - } - usb_dev_dr_client =platform_device_register_simple ( -"fsl-usb2-udc" , i, r,2 ); -if (IS_ERR (usb_dev_dr_client)) { - ret =PTR_ERR (usb_dev_dr_client); - goto err; - } - }else { - ret = -EINVAL ; - goto err; - } - - prop =of_get_property (np,"phy_type" ,NULL ); - usb_data.phy_mode =determine_usb_phy (prop); - -if (usb_dev_dr_host) { - usb_dev_dr_host->dev.coherent_dma_mask =0xffffffffUL ; - usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host-> - dev.coherent_dma_mask; -if ((ret =platform_device_add_data (usb_dev_dr_host, - &usb_data,sizeof (struct -fsl_usb2_platform_data )))) - goto unreg_dr; - } -if (usb_dev_dr_client) { - usb_dev_dr_client->dev.coherent_dma_mask =0xffffffffUL ; - usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client-> - dev.coherent_dma_mask; -if ((ret =platform_device_add_data (usb_dev_dr_client, - &usb_data,sizeof (struct -fsl_usb2_platform_data )))) - goto unreg_dr; - } - i++; - } -return 0 ; - -unreg_dr: -if (usb_dev_dr_host) -platform_device_unregister (usb_dev_dr_host); -if (usb_dev_dr_client) -platform_device_unregister (usb_dev_dr_client); -unreg_mph: -if (usb_dev_mph) -platform_device_unregister (usb_dev_mph); -err: -return ret; -} - -arch_initcall (fsl_usb_of_init); -#if defined(CONFIG_FSL_SOC_BOOKE ) || defined(CONFIG_PPC_86xx)static __be32 __iomem *rstcr;
Signature · 1 line
1.7.0.4
Re: [PATCH v2 1/3] powerpc/fsl_soc.c: remove FSL USB platform code
Quoted 8 lines · Anatolij Gustschin
This removed code will be replaced by simple
of_platformdriver for creation of FSL USB platform devices which is added by next patch of the series.Signed-off-by Anatolij Gustschin <[email protected]>Cc Kumar Gala <[email protected]>Cc Grant Likely <[email protected]>---
This is not bisectable. You have to merge 1/3 and 2/3.
Thanks,
Signature · 3 lines
Anton Vorontsov email: [email protected] irc://irc.freenode.net/bd2
PATCH v2 2/3 USB: add of_platform glue driver for FSL USB DR controller
In reply to Anatolij GustschinThe driver creates platform devices based on the information from USB nodes in the flat device tree. This is the replacement for old arch fsl_soc usb code removed by the previous patch. It uses usual of-style binding, available EHCI-HCD and UDC drivers can be bound to the created devices. The new of-style driver additionaly instantiates USB OTG platform device, as the appropriate USB OTG driver will be added soon.
---
v2:
- drop unneeded PPC_OF dependency
- fix spelling bug in mode table and fix coding style
- print a warning if no valid dr_mode found
- add remove hook to unregister platform devices created by probe. So the driver can be unbound
- fix OTG platform device creation order
- drop fs_initcall, replaced by module_init() now
- add module_exit(), MODULE_DESCRIPTION, MODULE_LICENSE
drivers/usb/gadget/Kconfig | 1 + drivers/usb/host/Kconfig | 4 + drivers/usb/host/Makefile | 1 + drivers/usb/host/fsl-mph-dr-of.c | 213 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 219 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/host/fsl-mph-dr-of.c
drivers/usb/gadget/Kconfig +1 -0
@@ -158,6 +158,7 @@ config USB_GADGET_FSL_USB2 boolean "Freescale Highspeed USB DR Peripheral Controller" depends on FSL_SOC || ARCH_MXC select USB_GADGET_DUALSPEED + select USB_FSL_MPH_DR_OF help Some of Freescale PowerPC processors have a High Speed Dual-Role(DR) USB controller, which supports device mode.
drivers/usb/host/Kconfig +4 -0
@@ -112,10 +112,14 @@ config XPS_USB_HCD_XILINX support both high speed and full speed devices, or high speed devices only. +config USB_FSL_MPH_DR_OF + tristate + config USB_EHCI_FSL bool "Support for Freescale on-chip EHCI USB controller" depends on USB_EHCI_HCD && FSL_SOC select USB_EHCI_ROOT_HUB_TT + select USB_FSL_MPH_DR_OF ---help--- Variation of ARC USB block used in some Freescale chips.
drivers/usb/host/Makefile +1 -0
@@ -33,4 +33,5 @@ obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o +obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o
drivers/usb/host/fsl-mph-dr-of.c new file +213 -0
213 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Re: [PATCH v2 2/3] USB: add of_platform glue driver for FSL USB DR controller
Hi Anatolij
Looks pretty good. Comments below. Main comment is that with the recent changes in mainline, this no longer needs to be an of_platform_driver. It can be a plain old platform_driver instead. It gets registered as a platform_driver anyway, but of_platform_driver is a shim that adds a bit of overhead, so it is best to avoid it. I'll detail the changes you need to make in my comments below.
Quoted 22 lines · Anatolij Gustschin
The driver creates platform devices based on the information from USB nodes in the flat device tree. This is the replacement for old arch
fsl_socusb code removed by the previous patch. It uses usual of-style binding, available EHCI-HCD and UDC drivers can be bound to the created devices. The new of-style driver additionaly instantiates USB OTG platform device, as the appropriate USB OTG driver will be added soon.Signed-off-by Anatolij Gustschin <[email protected]>Cc Kumar Gala <[email protected]>Cc Grant Likely <[email protected]>---
v2:
=A0- drop unneededPPC_OFdependency
=A0- fix spelling bug in mode table and fix coding style =A0- print a warning if no validdr_modefound =A0- add remove hook to unregister platform devices =A0 created by probe. So the driver can be unbound =A0- fix OTG platform device creation order
=A0- dropfs_initcall, replaced bymodule_init()now =A0- addmodule_exit(),MODULE_DESCRIPTION,MODULE_LICENSE
Quoted 4 lines
=A0drivers/usb/gadget/Kconfig =A0 =A0 =A0 | =A0 =A01 + =A0drivers/usb/host/Kconfig =A0 =A0 =A0 =A0 | =A0 =A04 + =A0drivers/usb/host/Makefile =A0 =A0 =A0 =A0| =A0 =A01 + =A0drivers/usb/host/fsl-mph-dr-of.c | =A0213 ++++++++++++++++++++++++++++=
++++++++++
Quoted 8 lines
=A04 files changed, 219 insertions(+), 0 deletions(-) =A0create mode 100644
drivers/usb/host/fsl-mph-dr-of.cdrivers/usb/gadget/Kconfig +0
-0@@ -158,6 +158,7 @@ config USB_GADGET_FSL_USB2
Quoted 6 lines
=A0 =A0 =A0 =A0boolean "Freescale Highspeed USB DR Peripheral Controller" =A0 =A0 =A0 =A0depends on
FSL_SOC||ARCH_MXC
=A0 =A0 =A0 =A0selectUSB_GADGET_DUALSPEED
+ =A0 =A0 =A0 selectUSB_FSL_MPH_DR_OF
=A0 =A0 =A0 =A0help
=A0 =A0 =A0 =A0 =A0 Some of Freescale PowerPC processors have a High Spee=
d
Quoted 1 line
=A0 =A0 =A0 =A0 =A0 Dual-Role(DR) USB controller, which supports device m=
ode.
Quoted 6 lines
drivers/usb/host/Kconfig +0
-0@@ -112,10 +112,14 @@ config XPS_USB_HCD_XILINX=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0support both high speed and full speed dev=
ices, or high speed
Quoted 5 lines
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0devices only.
drivers/usb/host/Kconfig +3
-0+config USB_FSL_MPH_DR_OF + =A0 =A0 =A0 tristate +
Quoted 7 lines
=A0config
USB_EHCI_FSL
=A0 =A0 =A0 =A0bool "Support for Freescale on-chip EHCI USB controller" =A0 =A0 =A0 =A0depends onUSB_EHCI_HCD&&FSL_SOC
=A0 =A0 =A0 =A0selectUSB_EHCI_ROOT_HUB_TT
+ =A0 =A0 =A0 selectUSB_FSL_MPH_DR_OF
=A0 =A0 =A0 =A0---help---
=A0 =A0 =A0 =A0 =A0Variation of ARC USB block used in some Freescale chip=
s.
drivers/usb/host/Makefile obj-$(CONFIG_USB_R8A66597_HCD) =A0 =A0 =A0 =A0+=3D r8a6=
Quoted 6 lines
drivers/usb/host/Makefile +0
-0@@ -33,4 +33,5 @@ obj-$(CONFIG_USB_R8A66597_HCD) =A0 =A0 =A0 =A0+=3D r8a6=
6597-hcd.o
drivers/usb/host/fsl-mph-=
Quoted 6 lines
=A0obj-$(CONFIG_USB_ISP1760_HCD) =A0+=3D isp1760.o =A0obj-$(CONFIG_USB_HWA_HCD) =A0 =A0 =A0+=3D hwa-hc.o =A0obj-$(CONFIG_USB_IMX21_HCD) =A0 =A0+=3D imx21-hcd.o
drivers/usb/host/Makefile +1
-0+obj-$(CONFIG_USB_FSL_MPH_DR_OF) =A0 =A0 =A0 =A0+=3D fsl-mph-dr-of.odrivers/usb/host/fsl-mph-= renamed from drivers/usb/host/fsl-mph-dr-of.c +0
-0
dr-of.c
drivers/usb/host/fsl-mph-dr-of.c line 6
Quoted 11 lines
new file mode 100644
index 0000000..ee8cb94drivers/usb/host/fsl-mph-dr-of.c new file +6
-0@@ -0,0 +1,213 @@ +/* +* Setup platform devices needed by the Freescale multi-port host +* and/or dual-role USB controller modules based on the description +* in flat device tree. +* +* This program is free software; you can redistribute =A0it and/or modi=
fy it
drivers/usb/host/fsl-mph-dr-of.c line 7
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+* under =A0the terms of =A0the GNU General =A0Public License as publish=
ed by the
drivers/usb/host/fsl-mph-dr-of.c line 8
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+* Free Software Foundation; =A0either version 2 of the =A0License, or (=
at your
drivers/usb/host/fsl-mph-dr-of.c
Quoted 13 lines
drivers/usb/host/fsl-mph-dr-of.c new file +13
-0+* option) any later version. +*/ + +#include <linux/kernel.h> +#include <linux/platform_device.h> +#include <linux/fsl_devices.h> +#include <linux/err.h> +#include <linux/io.h> +#include <linux/of_platform.h> + +struct fsl_usb2_dev_data { + =A0 =A0 =A0 char *dr_mode; =A0 =A0 =A0 =A0 =A0/* controller mode */ + =A0 =A0 =A0 char *drivers[3]; =A0 =A0 =A0 /* drivers to instantiate for=
this mode */
drivers/usb/host/fsl-mph-dr-of.c line 22
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+ =A0 =A0 =A0 enum fsl_usb2_operating_modes op_mode; =A0/* operating mode=
*/
drivers/usb/host/fsl-mph-dr-of.c line 33
Quoted 11 lines
drivers/usb/host/fsl-mph-dr-of.c new file +11
-0+}; + +struct fsl_usb2_dev_data dr_mode_data[] __devinitdata =3D { + =A0 =A0 =A0 { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .dr_mode =3D "host", + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .drivers =3D { "fsl-ehci", NULL, NULL, }, + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .op_mode =3D FSL_USB2_DR_HOST, + =A0 =A0 =A0 }, + =A0 =A0 =A0 { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .dr_mode =3D "otg", + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .drivers =3D { "fsl-usb2-otg", "fsl-ehci", =
"fsl-usb2-udc", },
drivers/usb/host/fsl-mph-dr-of.c line 38
Quoted 5 lines
drivers/usb/host/fsl-mph-dr-of.c new file +5
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 .op_mode =3D FSL_USB2_DR_OTG, + =A0 =A0 =A0 }, + =A0 =A0 =A0 { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .dr_mode =3D "peripheral", + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .drivers =3D { "fsl-usb2-udc", NULL, NULL, =
},
drivers/usb/host/fsl-mph-dr-of.c line 43
Quoted 5 lines
drivers/usb/host/fsl-mph-dr-of.c new file +5
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 .op_mode =3D FSL_USB2_DR_DEVICE, + =A0 =A0 =A0 }, +}; + +struct fsl_usb2_dev_data * __devinit get_dr_mode_data(struct device_node=
*np)
drivers/usb/host/fsl-mph-dr-of.c line 50
Quoted 7 lines
drivers/usb/host/fsl-mph-dr-of.c new file +7
-0+{ + =A0 =A0 =A0 const unsigned char *prop; + =A0 =A0 =A0 int i; + + =A0 =A0 =A0 prop =3D of_get_property(np, "dr_mode", NULL); + =A0 =A0 =A0 if (prop) { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 for (i =3D 0; i < ARRAY_SIZE(dr_mode_data);=
i++) {
drivers/usb/host/fsl-mph-dr-of.c line 51
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!strcmp(prop, dr_mode_d=
ata[i].dr_mode))
drivers/usb/host/fsl-mph-dr-of.c line 52
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return &dr_=
mode_data[i];
drivers/usb/host/fsl-mph-dr-of.c line 55
Quoted 3 lines
drivers/usb/host/fsl-mph-dr-of.c new file +3
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 } + =A0 =A0 =A0 } + =A0 =A0 =A0 pr_warn("%s: Invalid 'dr_mode' property, fallback to host m=
ode\n",
drivers/usb/host/fsl-mph-dr-of.c line 60
Quoted 5 lines
drivers/usb/host/fsl-mph-dr-of.c new file +5
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 np->full_name); + =A0 =A0 =A0 return &dr_mode_data[0]; /* mode not specified, use host */ +} + +static enum fsl_usb2_phy_modes __devinit determine_usb_phy(const char *p=
hy_type)
Quoted 7 lines
drivers/usb/host/fsl-mph-dr-of.c new file +7
-0+{ + =A0 =A0 =A0 if (!phy_type) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return FSL_USB2_PHY_NONE; + =A0 =A0 =A0 if (!strcasecmp(phy_type, "ulpi")) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return FSL_USB2_PHY_ULPI; + =A0 =A0 =A0 if (!strcasecmp(phy_type, "utmi")) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return FSL_USB2_PHY_UTMI;
drivers/usb/host/fsl-mph-dr-of.c line 77
Quoted 10 lines
drivers/usb/host/fsl-mph-dr-of.c new file +10
-0+ =A0 =A0 =A0 if (!strcasecmp(phy_type, "utmi_wide")) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return FSL_USB2_PHY_UTMI_WIDE; + =A0 =A0 =A0 if (!strcasecmp(phy_type, "serial")) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return FSL_USB2_PHY_SERIAL; + + =A0 =A0 =A0 return FSL_USB2_PHY_NONE; +} + +struct platform_device * __devinit fsl_usb2_device_register( + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 struct platform_device *ofdev,
drivers/usb/host/fsl-mph-dr-of.c line 78
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 struct fsl_usb2_platform_data *pdata,
drivers/usb/host/fsl-mph-dr-of.c line 79
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 const char *name, int id)
Quoted 5 lines
drivers/usb/host/fsl-mph-dr-of.c new file +5
-0+{ + =A0 =A0 =A0 struct platform_device *pdev; + =A0 =A0 =A0 const struct resource *res =3D ofdev->resource; + =A0 =A0 =A0 unsigned int num =3D ofdev->num_resources; + =A0 =A0 =A0 int retval;
drivers/usb/host/fsl-mph-dr-of.c line 94
Quoted 10 lines
drivers/usb/host/fsl-mph-dr-of.c new file +10
-0+ + =A0 =A0 =A0 pdev =3D platform_device_alloc(name, id); + =A0 =A0 =A0 if (!pdev) { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 retval =3D -ENOMEM; + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto error; + =A0 =A0 =A0 } + + =A0 =A0 =A0 pdev->dev.parent =3D &ofdev->dev; + + =A0 =A0 =A0 pdev->dev.coherent_dma_mask =3D ofdev->dev.coherent_dma_mas=
k;
drivers/usb/host/fsl-mph-dr-of.c line 98
Quoted 4 lines
drivers/usb/host/fsl-mph-dr-of.c new file +4
-0+ =A0 =A0 =A0 pdev->dev.dma_mask =3D &pdev->archdata.dma_mask; + =A0 =A0 =A0 *pdev->dev.dma_mask =3D *ofdev->dev.dma_mask; + + =A0 =A0 =A0 retval =3D platform_device_add_data(pdev, pdata, sizeof(*pd=
ata));
drivers/usb/host/fsl-mph-dr-of.c line 103
Quoted 5 lines
drivers/usb/host/fsl-mph-dr-of.c new file +5
-0+ =A0 =A0 =A0 if (retval) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto error; + + =A0 =A0 =A0 if (num) { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 retval =3D platform_device_add_resources(pd=
ev, res, num);
Quoted 6 lines
drivers/usb/host/fsl-mph-dr-of.c new file +6
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (retval) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto error; + =A0 =A0 =A0 } + + =A0 =A0 =A0 retval =3D platform_device_add(pdev); + =A0 =A0 =A0 if (retval)
drivers/usb/host/fsl-mph-dr-of.c line 119
Quoted 10 lines
drivers/usb/host/fsl-mph-dr-of.c new file +10
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto error; + + =A0 =A0 =A0 return pdev; + +error: + =A0 =A0 =A0 platform_device_put(pdev); + =A0 =A0 =A0 return ERR_PTR(retval); +} + +static int __devinit fsl_usb2_mph_dr_of_probe(struct platform_device *of=
dev,
drivers/usb/host/fsl-mph-dr-of.c line 120
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0const struct of_device_id *match)
Change to:
static int __devinit fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev= )
You can get the 'match' pointer by calling of_match_device().
Quoted 7 lines
drivers/usb/host/fsl-mph-dr-of.c new file +7
-0+{ + =A0 =A0 =A0 struct device_node *np =3D ofdev->dev.of_node; + =A0 =A0 =A0 struct platform_device *usb_dev; + =A0 =A0 =A0 struct fsl_usb2_platform_data data, *pdata; + =A0 =A0 =A0 struct fsl_usb2_dev_data *dev_data; + =A0 =A0 =A0 const unsigned char *prop; + =A0 =A0 =A0 static unsigned int idx;
drivers/usb/host/fsl-mph-dr-of.c line 137
Quoted 10 lines
drivers/usb/host/fsl-mph-dr-of.c new file +10
-0+ =A0 =A0 =A0 int i; + + =A0 =A0 =A0 if (!of_device_is_available(np)) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV; + + =A0 =A0 =A0 pdata =3D match->data; + =A0 =A0 =A0 if (!pdata) { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 memset(&data, 0, sizeof(data)); + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata =3D &data; + =A0 =A0 =A0 }
This is bad behaviour. *match->data must not be modified in probe because multiple instances of the device can exist. The target of pdata is modified later in the probe routine.
However, the above 4 lines can be removed entirely since none of the fsl_usb2_mph_dr_of_match entries actually set the data pointer. The local 'data' structure can be used directly.
drivers/usb/host/fsl-mph-dr-of.c line 143
Quoted 6 lines
drivers/usb/host/fsl-mph-dr-of.c new file +6
-0+ + =A0 =A0 =A0 dev_data =3D get_dr_mode_data(np); + + =A0 =A0 =A0 if (of_device_is_compatible(np, "fsl-usb2-mph")) { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (of_get_property(np, "port0", NULL)) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->port_enables |=3D FS=
L_USB2_PORT0_ENABLED;
drivers/usb/host/fsl-mph-dr-of.c line 146
Quoted 3 lines
drivers/usb/host/fsl-mph-dr-of.c new file +3
-0+ + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (of_get_property(np, "port1", NULL)) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->port_enables |=3D FS=
L_USB2_PORT1_ENABLED;
drivers/usb/host/fsl-mph-dr-of.c line 148
Quoted 2 lines
drivers/usb/host/fsl-mph-dr-of.c new file +2
-0+ + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->operating_mode =3D FSL_USB2_MPH_HOST=
;
drivers/usb/host/fsl-mph-dr-of.c line 150
Quoted 2 lines
drivers/usb/host/fsl-mph-dr-of.c new file +2
-0+ =A0 =A0 =A0 } else { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* setup mode selected in the device tree *=
/
drivers/usb/host/fsl-mph-dr-of.c line 151
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata->operating_mode =3D dev_data->op_mode=
;
drivers/usb/host/fsl-mph-dr-of.c line 160
Quoted 9 lines
drivers/usb/host/fsl-mph-dr-of.c new file +9
-0+ =A0 =A0 =A0 } + + =A0 =A0 =A0 prop =3D of_get_property(np, "phy_type", NULL); + =A0 =A0 =A0 pdata->phy_mode =3D determine_usb_phy(prop); + + =A0 =A0 =A0 for (i =3D 0; i < ARRAY_SIZE(dev_data->drivers); i++) { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!dev_data->drivers[i]) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 continue; + =A0 =A0 =A0 =A0 =A0 =A0 =A0 usb_dev =3D fsl_usb2_device_register(ofdev,=
pdata,
drivers/usb/host/fsl-mph-dr-of.c line 161
Quoted 1 line
drivers/usb/host/fsl-mph-dr-of.c new file +1
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 dev_data->drivers[i], idx);
drivers/usb/host/fsl-mph-dr-of.c line 163
Quoted 2 lines
drivers/usb/host/fsl-mph-dr-of.c new file +2
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (IS_ERR(usb_dev)) { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_err(&ofdev->dev, "Can't=
register usb device\n");
Quoted 4 lines
drivers/usb/host/fsl-mph-dr-of.c new file +4
-0+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return PTR_ERR(usb_dev); + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } + =A0 =A0 =A0 } + =A0 =A0 =A0 idx++;
drivers/usb/host/fsl-mph-dr-of.c line 177
Quoted 10 lines
drivers/usb/host/fsl-mph-dr-of.c new file +10
-0+ =A0 =A0 =A0 return 0; +} + +static int __devexit __unregister_subdev(struct device *dev, void *d) +{ + =A0 =A0 =A0 platform_device_unregister(to_platform_device(dev)); + =A0 =A0 =A0 return 0; +} + +static int __devexit fsl_usb2_mph_dr_of_remove(struct platform_device *o=
fdev)
drivers/usb/host/fsl-mph-dr-of.c line 179
Quoted 2 lines
drivers/usb/host/fsl-mph-dr-of.c new file +2
-0+{ + =A0 =A0 =A0 device_for_each_child(&ofdev->dev, NULL, __unregister_subde=
v);
Quoted 4 lines
drivers/usb/host/fsl-mph-dr-of.c new file +4
-0+ =A0 =A0 =A0 return 0; +} + +static const struct of_device_id fsl_usb2_mph_dr_of_match[] =3D {
drivers/usb/host/fsl-mph-dr-of.c line 193
Quoted 10 lines
drivers/usb/host/fsl-mph-dr-of.c new file +10
-0+ =A0 =A0 =A0 { .compatible =3D "fsl-usb2-mph", }, + =A0 =A0 =A0 { .compatible =3D "fsl-usb2-dr", }, + =A0 =A0 =A0 {}, +}; + +static struct of_platform_driver fsl_usb2_mph_dr_driver =3D { + =A0 =A0 =A0 .driver =3D { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .name =3D "fsl-usb2-mph-dr", + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .owner =3D THIS_MODULE, + =A0 =A0 =A0 =A0 =A0 =A0 =A0 .of_match_table =3D fsl_usb2_mph_dr_of_matc=
h,
drivers/usb/host/fsl-mph-dr-of.c line 197
Quoted 4 lines
drivers/usb/host/fsl-mph-dr-of.c new file +4
-0+ =A0 =A0 =A0 }, + =A0 =A0 =A0 .probe =A0=3D fsl_usb2_mph_dr_of_probe, + =A0 =A0 =A0 .remove =3D __devexit_p(fsl_usb2_mph_dr_of_remove), +};
Change of_platform_driver to platform_driver
drivers/usb/host/fsl-mph-dr-of.c
Quoted 4 lines
drivers/usb/host/fsl-mph-dr-of.c new file +4
-0+ +static int __init fsl_usb2_mph_dr_init (void ) +{ + =A0 =A0 =A0 return of_register_platform_driver(&fsl_usb2_mph_dr_driver)=
;
change to platform_driver_register()
drivers/usb/host/fsl-mph-dr-of.c
Quoted 6 lines
drivers/usb/host/fsl-mph-dr-of.c new file +6
-0+} +module_init (fsl_usb2_mph_dr_init); + +static void __exit fsl_usb2_mph_dr_exit(void) +{ + =A0 =A0 =A0 of_unregister_platform_driver(&fsl_usb2_mph_dr_driver);
change to platform_driver_unregister()
Quoted 10 lines
drivers/usb/host/fsl-mph-dr-of.c new file +6
-1+} +module_exit (fsl_usb2_mph_dr_exit); + +MODULE_DESCRIPTION ("FSL MPH DR OF devices driver" ); +MODULE_AUTHOR ("Anatolij Gustschin <[email protected]>" ); +MODULE_LICENSE ("GPL" ); --1.7.0.4
--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
Re: [PATCH v2 2/3] USB: add of_platform glue driver for FSL USB DR controller
Hi Grant,
On Tue, 28 Sep 2010 19:01:28 +0900
Grant Likely <[email protected]> wrote:
...
Quoted 6 lines
Looks pretty good. Comments below. Main comment is that with the recent changes in mainline, this no longer needs to be an
of_platform_driver. It can be a plain oldplatform_driverinstead. It gets registered as aplatform_driveranyway, butof_platform_driveris a shim that adds a bit of overhead, so it is best to avoid it. I'll detail the changes you need to make in my comments below.
Thanks. I'll change to platform_driver. My reply below.
...
Quoted 17 lines
Quoted 7 lines
(quoted diff) +7
-0+{ + =A0 =A0 =A0 struct device_node *np =3D ofdev->dev.of_node; + =A0 =A0 =A0 struct platform_device *usb_dev; + =A0 =A0 =A0 struct fsl_usb2_platform_data data, *pdata; + =A0 =A0 =A0 struct fsl_usb2_dev_data *dev_data; + =A0 =A0 =A0 const unsigned char *prop; + =A0 =A0 =A0 static unsigned int idx;Review
Quoted 10 lines
(quoted diff) +10
-0+ =A0 =A0 =A0 int i; + + =A0 =A0 =A0 if (!of_device_is_available(np)) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ENODEV; + + =A0 =A0 =A0 pdata =3D match->data; + =A0 =A0 =A0 if (!pdata) { + =A0 =A0 =A0 =A0 =A0 =A0 =A0 memset(&data, 0, sizeof(data)); + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pdata =3D &data; + =A0 =A0 =A0 }
Quoted 8 lines
=20
This is bad behaviour.*match->datamust not be modified in probe because multiple instances of the device can exist. The target of pdata is modified later in the probe routine.
=20
However, the above 4 lines can be removed entirely since none of thefsl_usb2_mph_dr_of_matchentries actually set the data pointer. The local 'data' structure can be used directly.
A match entry for mpc5121 is added by the third patch. I'll fix this so that only local 'data' structure is modified later in the probe routine.
Thanks,
Anatolij
PATCH v2 3/3 USB: add USB EHCI support for MPC5121 SoC
In reply to Anatolij GustschinExtends FSL EHCI platform driver glue layer to support MPC5121 USB controllers. MPC5121 Rev 2.0 silicon EHCI registers are in big endian format. The appropriate flags are set using the information in the platform data structure. MPC83xx system interface registers are not available on MPC512x, so the access to these registers is isolated in MPC512x case. Furthermore the USB controller clocks must be enabled before 512x register accesses which is done by providing platform specific init callback.
The MPC512x internal USB PHY doesn't provide supply voltage. For boards using different power switches allow specifying DRVVBUS and PWR_FAULT signal polarity of the MPC5121 internal PHY using "fsl,invert-drvvbus" and "fsl,invert-pwr-fault" properties in the device tree USB nodes. Adds documentation for this new device tree bindings.
---
v2:
- rebased on linux-next
- remove host mode setting in usb_hcd_fsl_probe() since this is set in tdi_reset() anyway
- drop now unneeded defines previously used for host mode setting
Documentation/powerpc/dts-bindings/fsl/usb.txt | 22 +++++ drivers/usb/Kconfig | 1 + drivers/usb/host/Kconfig | 6 +- drivers/usb/host/ehci-fsl.c | 99 +++++++++++++++++------- drivers/usb/host/ehci-fsl.h | 13 +++- drivers/usb/host/ehci-mem.c | 2 +- drivers/usb/host/fsl-mph-dr-of.c | 89 +++++++++++++++++++++ include/linux/fsl_devices.h | 15 ++++ 8 files changed, 215 insertions(+), 32 deletions(-)
Documentation/powerpc/dts-bindings/fsl/usb.txt +22 -0
@@ -8,6 +8,7 @@ and additions : Required properties : - compatible : Should be "fsl-usb2-mph" for multi port host USB controllers, or "fsl-usb2-dr" for dual role USB controllers + or "fsl,mpc5121-usb2-dr" for dual role USB controllers of MPC5121 - phy_type : For multi port host USB controllers, should be one of "ulpi", or "serial". For dual role USB controllers, should be one of "ulpi", "utmi", "utmi_wide", or "serial".
@@ -33,6 +34,12 @@ Recommended properties : - interrupt-parent : the phandle for the interrupt controller that services interrupts for this device. +Optional properties : + - fsl,invert-drvvbus : boolean; for MPC5121 USB0 only. Indicates the + port power polarity of internal PHY signal DRVVBUS is inverted. + - fsl,invert-pwr-fault : boolean; for MPC5121 USB0 only. Indicates + the PWR_FAULT signal polarity is inverted. + Example multi port host USB controller device node : usb@22000 { compatible = "fsl-usb2-mph";
@@ -57,3 +64,18 @@ Example dual role USB controller device node : dr_mode = "otg"; phy = "ulpi"; }; + +Example dual role USB controller device node for MPC5121ADS: + + usb@4000 { + compatible = "fsl,mpc5121-usb2-dr"; + reg = <0x4000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + interrupt-parent = < &ipic >; + interrupts = <44 0x8>; + dr_mode = "otg"; + phy_type = "utmi_wide"; + fsl,invert-drvvbus; + fsl,invert-pwr-fault; + };
drivers/usb/Kconfig +1 -0
@@ -59,6 +59,7 @@ config USB_ARCH_HAS_OHCI config USB_ARCH_HAS_EHCI boolean default y if PPC_83xx + default y if PPC_MPC512x default y if SOC_AU1200 default y if ARCH_IXP4XX default y if ARCH_W90X900
drivers/usb/host/Kconfig +4 -2
@@ -93,12 +93,14 @@ config USB_EHCI_TT_NEWSCHED config USB_EHCI_BIG_ENDIAN_MMIO bool - depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX) + depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || \ + XPS_USB_HCD_XILINX || PPC_MPC512x) default y config USB_EHCI_BIG_ENDIAN_DESC bool - depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX) + depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX || \ + PPC_MPC512x) default y config XPS_USB_HCD_XILINX
drivers/usb/host/ehci-fsl.c +71 -28
172 lines not on this page · raw message
drivers/usb/host/ehci-fsl.h +12 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2005 freescale semiconductor +/* Copyright (C) 2005-2010 Freescale Semiconductor, Inc. * Copyright (c) 2005 MontaVista Software * * This program is free software; you can redistribute it and/or modify it
@@ -19,6 +19,9 @@#define _EHCI_FSL_H/* offsets for the non-ehci registers in the FSL SOC USB controller */ +#define FSL_SOC_USB_ID 0x0 +#define ID_MSK 0x3f +#define NID_MSK 0x3f00#define FSL_SOC_USB_ULPIVP 0x170#define FSL_SOC_USB_PORTSC1 0x184#define PORT_PTS_MSK (3<<30)
@@ -27,6 +30,14 @@#define PORT_PTS_SERIAL (3<<30)#define PORT_PTS_PTW (1<<28)#define FSL_SOC_USB_PORTSC2 0x188 + +#define FSL_SOC_USB_USBGENCTRL 0x200 +#define USBGENCTRL_PPP (1 << 3) +#define USBGENCTRL_PFP (1 << 2) +#define FSL_SOC_USB_ISIPHYCTRL 0x204 +#define ISIPHYCTRL_PXE (1) +#define ISIPHYCTRL_PHYE (1 << 4) +#define FSL_SOC_USB_SNOOP1 0x400/* NOTE: big-endian */ #define FSL_SOC_USB_SNOOP2 0x404/* NOTE: big-endian */ #define FSL_SOC_USB_AGECNTTHRSH 0x408/* NOTE: big-endian */
drivers/usb/host/ehci-mem.c +1 -1
@@ -40,7 +40,7 @@ static inline void ehci_qtd_init(struct ehci_hcd *ehci, struct ehci_qtd *qtd, {memset (qtd,0 ,sizeof *qtd); qtd->qtd_dma = dma; - qtd->hw_token =cpu_to_le32 (QTD_STS_HALT ); + qtd->hw_token =cpu_to_hc32 (ehci,QTD_STS_HALT ); qtd->hw_next =EHCI_LIST_END (ehci); qtd->hw_alt_next =EHCI_LIST_END (ehci);INIT_LIST_HEAD (&qtd->qtd_list);
drivers/usb/host/fsl-mph-dr-of.c +89 -0
110 lines not on this page · raw message
include/linux/fsl_devices.h +15 -0
@@ -58,11 +58,26 @@ enum fsl_usb2_phy_modes { FSL_USB2_PHY_SERIAL, }; +struct clk ; +struct platform_device ; +struct fsl_usb2_platform_data {/* board specific information */ enum fsl_usb2_operating_modes operating_mode;enum fsl_usb2_phy_modes phy_mode;unsigned int port_enables; + +int (*init)(struct platform_device *); +void (*exit)(struct platform_device *); +void __iomem *regs;/* ioremap'd register base */ +struct clk *clk; +unsigned big_endian_mmio:1 ; +unsigned big_endian_desc:1 ; +unsigned es:1 ;/* need USBMODE:ES */ +unsigned le_setup_buf:1 ; +unsigned have_sysif_regs:1 ; +unsigned invert_drvvbus:1 ; +unsigned invert_pwr_fault:1 ; };/* Flags in fsl_usb2_mph_platform_data */
Signature · 1 line
1.7.0.4
v3 cover Add USB Host support for MPC5121 SoC
In reply to Anatolij GustschinVersion 3 of the patches to add MPC512x USB support in mainline kernel. USB OTG support is not included in this patch series, it will be submitted later.
There are only two patches now: patches 1/3 and 2/3 of the previous version are merged into the first patch and now bisectable. Additionally the 2nd patch of the previous version is changed as requested by Grant. Please consider for inclusion in 2.6.37.
Anatolij Gustschin (2):
USB: add platform glue driver for FSL USB DR controller
USB: add USB EHCI support for MPC5121 SoC
Documentation/powerpc/dts-bindings/fsl/usb.txt | 22 ++ arch/powerpc/sysdev/fsl_soc.c | 163 ------------- drivers/usb/Kconfig | 1 + drivers/usb/gadget/Kconfig | 1 + drivers/usb/host/Kconfig | 10 +- drivers/usb/host/Makefile | 1 + drivers/usb/host/ehci-fsl.c | 99 ++++++--- drivers/usb/host/ehci-fsl.h | 13 +- drivers/usb/host/ehci-mem.c | 2 +- drivers/usb/host/fsl-mph-dr-of.c | 308 ++++++++++++++++++++++++ include/linux/fsl_devices.h | 15 ++ 11 files changed, 440 insertions(+), 195 deletions(-) create mode 100644 drivers/usb/host/fsl-mph-dr-of.c
PATCH v3 1/2 USB: add platform glue driver for FSL USB DR controller
In reply to Anatolij GustschinReplace FSL USB platform code by simple platform driver for creation of FSL USB platform devices.
The driver creates platform devices based on the information from USB nodes in the flat device tree. This is the replacement for old arch fsl_soc usb code removed by this patch. The driver uses usual of-style binding, available EHCI-HCD and UDC drivers can be bound to the created devices. The new of-style driver additionaly instantiates USB OTG platform device, as the appropriate USB OTG driver will be added soon.
---
v3:
- merged patches 1/3 and 2/3 of the previous version
- changed to platform_driver as requested
- fixed probe() to avoid modification of driver's shared platform data struct pointed to by 'data' in the match table which is added by the next patch of the series
arch/powerpc/sysdev/fsl_soc.c | 163 ---------------------------- drivers/usb/gadget/Kconfig | 1 + drivers/usb/host/Kconfig | 4 + drivers/usb/host/Makefile | 1 + drivers/usb/host/fsl-mph-dr-of.c | 219 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 225 insertions(+), 163 deletions(-) create mode 100644 drivers/usb/host/fsl-mph-dr-of.c
arch/powerpc/sysdev/fsl_soc.c +0 -163
@@ -209,169 +209,6 @@ static int __init of_add_fixed_phys(void)arch_initcall (of_add_fixed_phys);#endif /* CONFIG_FIXED_PHY */ -static enum fsl_usb2_phy_modes determine_usb_phy (const char *phy_type) -{ -if (!phy_type) -return FSL_USB2_PHY_NONE ; -if (!strcasecmp (phy_type,"ulpi" )) -return FSL_USB2_PHY_ULPI ; -if (!strcasecmp (phy_type,"utmi" )) -return FSL_USB2_PHY_UTMI ; -if (!strcasecmp (phy_type,"utmi_wide" )) -return FSL_USB2_PHY_UTMI_WIDE ; -if (!strcasecmp (phy_type,"serial" )) -return FSL_USB2_PHY_SERIAL ; - -return FSL_USB2_PHY_NONE ; -} - -static int __init fsl_usb_of_init (void ) -{ -struct device_node *np; -unsigned int i =0 ; -struct platform_device *usb_dev_mph =NULL , *usb_dev_dr_host =NULL , - *usb_dev_dr_client =NULL ; -int ret; - -for_each_compatible_node (np,NULL ,"fsl-usb2-mph" ) { -struct resource r[2 ]; -struct fsl_usb2_platform_data usb_data; -const unsigned char *prop =NULL ; - -memset (&r,0 ,sizeof (r)); -memset (&usb_data,0 ,sizeof (usb_data)); - - ret =of_address_to_resource (np,0 , &r[0 ]); -if (ret) - goto err; - -of_irq_to_resource (np,0 , &r[1 ]); - - usb_dev_mph = -platform_device_register_simple ("fsl-ehci" , i, r,2 ); -if (IS_ERR (usb_dev_mph)) { - ret =PTR_ERR (usb_dev_mph); - goto err; - } - - usb_dev_mph->dev.coherent_dma_mask =0xffffffffUL ; - usb_dev_mph->dev.dma_mask = &usb_dev_mph->dev.coherent_dma_mask; - - usb_data.operating_mode =FSL_USB2_MPH_HOST ; - - prop =of_get_property (np,"port0" ,NULL ); -if (prop) - usb_data.port_enables |=FSL_USB2_PORT0_ENABLED ; - - prop =of_get_property (np,"port1" ,NULL ); -if (prop) - usb_data.port_enables |=FSL_USB2_PORT1_ENABLED ; - - prop =of_get_property (np,"phy_type" ,NULL ); - usb_data.phy_mode =determine_usb_phy (prop); - - ret = -platform_device_add_data (usb_dev_mph, &usb_data, -sizeof (struct -fsl_usb2_platform_data )); -if (ret) - goto unreg_mph; - i++; - } - -for_each_compatible_node (np,NULL ,"fsl-usb2-dr" ) { -struct resource r[2 ]; -struct fsl_usb2_platform_data usb_data; -const unsigned char *prop =NULL ; - -if (!of_device_is_available (np)) -continue ; - -memset (&r,0 ,sizeof (r)); -memset (&usb_data,0 ,sizeof (usb_data)); - - ret =of_address_to_resource (np,0 , &r[0 ]); -if (ret) - goto unreg_mph; - -of_irq_to_resource (np,0 , &r[1 ]); - - prop =of_get_property (np,"dr_mode" ,NULL ); - -if (!prop || !strcmp (prop,"host" )) { - usb_data.operating_mode =FSL_USB2_DR_HOST ; - usb_dev_dr_host =platform_device_register_simple ( -"fsl-ehci" , i, r,2 ); -if (IS_ERR (usb_dev_dr_host)) { - ret =PTR_ERR (usb_dev_dr_host); - goto err; - } - }else if (prop && !strcmp (prop,"peripheral" )) { - usb_data.operating_mode =FSL_USB2_DR_DEVICE ; - usb_dev_dr_client =platform_device_register_simple ( -"fsl-usb2-udc" , i, r,2 ); -if (IS_ERR (usb_dev_dr_client)) { - ret =PTR_ERR (usb_dev_dr_client); - goto err; - } - }else if (prop && !strcmp (prop,"otg" )) { - usb_data.operating_mode =FSL_USB2_DR_OTG ; - usb_dev_dr_host =platform_device_register_simple ( -"fsl-ehci" , i, r,2 ); -if (IS_ERR (usb_dev_dr_host)) { - ret =PTR_ERR (usb_dev_dr_host); - goto err; - } - usb_dev_dr_client =platform_device_register_simple ( -"fsl-usb2-udc" , i, r,2 ); -if (IS_ERR (usb_dev_dr_client)) { - ret =PTR_ERR (usb_dev_dr_client); - goto err; - } - }else { - ret = -EINVAL ; - goto err; - } - - prop =of_get_property (np,"phy_type" ,NULL ); - usb_data.phy_mode =determine_usb_phy (prop); - -if (usb_dev_dr_host) { - usb_dev_dr_host->dev.coherent_dma_mask =0xffffffffUL ; - usb_dev_dr_host->dev.dma_mask = &usb_dev_dr_host-> - dev.coherent_dma_mask; -if ((ret =platform_device_add_data (usb_dev_dr_host, - &usb_data,sizeof (struct -fsl_usb2_platform_data )))) - goto unreg_dr; - } -if (usb_dev_dr_client) { - usb_dev_dr_client->dev.coherent_dma_mask =0xffffffffUL ; - usb_dev_dr_client->dev.dma_mask = &usb_dev_dr_client-> - dev.coherent_dma_mask; -if ((ret =platform_device_add_data (usb_dev_dr_client, - &usb_data,sizeof (struct -fsl_usb2_platform_data )))) - goto unreg_dr; - } - i++; - } -return 0 ; - -unreg_dr: -if (usb_dev_dr_host) -platform_device_unregister (usb_dev_dr_host); -if (usb_dev_dr_client) -platform_device_unregister (usb_dev_dr_client); -unreg_mph: -if (usb_dev_mph) -platform_device_unregister (usb_dev_mph); -err: -return ret; -} - -arch_initcall (fsl_usb_of_init); -#if defined(CONFIG_FSL_SOC_BOOKE ) || defined(CONFIG_PPC_86xx)static __be32 __iomem *rstcr;
drivers/usb/gadget/Kconfig +1 -0
@@ -158,6 +158,7 @@ config USB_GADGET_FSL_USB2 boolean "Freescale Highspeed USB DR Peripheral Controller" depends on FSL_SOC || ARCH_MXC select USB_GADGET_DUALSPEED + select USB_FSL_MPH_DR_OF help Some of Freescale PowerPC processors have a High Speed Dual-Role(DR) USB controller, which supports device mode.
drivers/usb/host/Kconfig +4 -0
@@ -112,10 +112,14 @@ config XPS_USB_HCD_XILINX support both high speed and full speed devices, or high speed devices only. +config USB_FSL_MPH_DR_OF + tristate + config USB_EHCI_FSL bool "Support for Freescale on-chip EHCI USB controller" depends on USB_EHCI_HCD && FSL_SOC select USB_EHCI_ROOT_HUB_TT + select USB_FSL_MPH_DR_OF ---help--- Variation of ARC USB block used in some Freescale chips.
drivers/usb/host/Makefile +1 -0
@@ -33,4 +33,5 @@ obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o +obj-$(CONFIG_USB_FSL_MPH_DR_OF) += fsl-mph-dr-of.o
drivers/usb/host/fsl-mph-dr-of.c new file +219 -0
219 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH v3 2/2 USB: add USB EHCI support for MPC5121 SoC
In reply to Anatolij GustschinExtends FSL EHCI platform driver glue layer to support MPC5121 USB controllers. MPC5121 Rev 2.0 silicon EHCI registers are in big endian format. The appropriate flags are set using the information in the platform data structure. MPC83xx system interface registers are not available on MPC512x, so the access to these registers is isolated in MPC512x case. Furthermore the USB controller clocks must be enabled before 512x register accesses which is done by providing platform specific init callback.
The MPC512x internal USB PHY doesn't provide supply voltage. For boards using different power switches allow specifying DRVVBUS and PWR_FAULT signal polarity of the MPC5121 internal PHY using "fsl,invert-drvvbus" and "fsl,invert-pwr-fault" properties in the device tree USB nodes. Adds documentation for this new device tree bindings.
---
v3:
- rebased after changing of_platform_driver to platform_driver
Documentation/powerpc/dts-bindings/fsl/usb.txt | 22 +++++ drivers/usb/Kconfig | 1 + drivers/usb/host/Kconfig | 6 +- drivers/usb/host/ehci-fsl.c | 99 +++++++++++++++++------- drivers/usb/host/ehci-fsl.h | 13 +++- drivers/usb/host/ehci-mem.c | 2 +- drivers/usb/host/fsl-mph-dr-of.c | 89 +++++++++++++++++++++ include/linux/fsl_devices.h | 15 ++++ 8 files changed, 215 insertions(+), 32 deletions(-)
Documentation/powerpc/dts-bindings/fsl/usb.txt +22 -0
@@ -8,6 +8,7 @@ and additions : Required properties : - compatible : Should be "fsl-usb2-mph" for multi port host USB controllers, or "fsl-usb2-dr" for dual role USB controllers + or "fsl,mpc5121-usb2-dr" for dual role USB controllers of MPC5121 - phy_type : For multi port host USB controllers, should be one of "ulpi", or "serial". For dual role USB controllers, should be one of "ulpi", "utmi", "utmi_wide", or "serial".
@@ -33,6 +34,12 @@ Recommended properties : - interrupt-parent : the phandle for the interrupt controller that services interrupts for this device. +Optional properties : + - fsl,invert-drvvbus : boolean; for MPC5121 USB0 only. Indicates the + port power polarity of internal PHY signal DRVVBUS is inverted. + - fsl,invert-pwr-fault : boolean; for MPC5121 USB0 only. Indicates + the PWR_FAULT signal polarity is inverted. + Example multi port host USB controller device node : usb@22000 { compatible = "fsl-usb2-mph";
@@ -57,3 +64,18 @@ Example dual role USB controller device node : dr_mode = "otg"; phy = "ulpi"; }; + +Example dual role USB controller device node for MPC5121ADS: + + usb@4000 { + compatible = "fsl,mpc5121-usb2-dr"; + reg = <0x4000 0x1000>; + #address-cells = <1>; + #size-cells = <0>; + interrupt-parent = < &ipic >; + interrupts = <44 0x8>; + dr_mode = "otg"; + phy_type = "utmi_wide"; + fsl,invert-drvvbus; + fsl,invert-pwr-fault; + };
drivers/usb/Kconfig +1 -0
@@ -59,6 +59,7 @@ config USB_ARCH_HAS_OHCI config USB_ARCH_HAS_EHCI boolean default y if PPC_83xx + default y if PPC_MPC512x default y if SOC_AU1200 default y if ARCH_IXP4XX default y if ARCH_W90X900
drivers/usb/host/Kconfig +4 -2
@@ -93,12 +93,14 @@ config USB_EHCI_TT_NEWSCHED config USB_EHCI_BIG_ENDIAN_MMIO bool - depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX) + depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || \ + XPS_USB_HCD_XILINX || PPC_MPC512x) default y config USB_EHCI_BIG_ENDIAN_DESC bool - depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX) + depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX || \ + PPC_MPC512x) default y config XPS_USB_HCD_XILINX
drivers/usb/host/ehci-fsl.c +71 -28
172 lines not on this page · raw message
drivers/usb/host/ehci-fsl.h +12 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2005 freescale semiconductor +/* Copyright (C) 2005-2010 Freescale Semiconductor, Inc. * Copyright (c) 2005 MontaVista Software * * This program is free software; you can redistribute it and/or modify it
@@ -19,6 +19,9 @@#define _EHCI_FSL_H/* offsets for the non-ehci registers in the FSL SOC USB controller */ +#define FSL_SOC_USB_ID 0x0 +#define ID_MSK 0x3f +#define NID_MSK 0x3f00#define FSL_SOC_USB_ULPIVP 0x170#define FSL_SOC_USB_PORTSC1 0x184#define PORT_PTS_MSK (3<<30)
@@ -27,6 +30,14 @@#define PORT_PTS_SERIAL (3<<30)#define PORT_PTS_PTW (1<<28)#define FSL_SOC_USB_PORTSC2 0x188 + +#define FSL_SOC_USB_USBGENCTRL 0x200 +#define USBGENCTRL_PPP (1 << 3) +#define USBGENCTRL_PFP (1 << 2) +#define FSL_SOC_USB_ISIPHYCTRL 0x204 +#define ISIPHYCTRL_PXE (1) +#define ISIPHYCTRL_PHYE (1 << 4) +#define FSL_SOC_USB_SNOOP1 0x400/* NOTE: big-endian */ #define FSL_SOC_USB_SNOOP2 0x404/* NOTE: big-endian */ #define FSL_SOC_USB_AGECNTTHRSH 0x408/* NOTE: big-endian */
drivers/usb/host/ehci-mem.c +1 -1
@@ -40,7 +40,7 @@ static inline void ehci_qtd_init(struct ehci_hcd *ehci, struct ehci_qtd *qtd, {memset (qtd,0 ,sizeof *qtd); qtd->qtd_dma = dma; - qtd->hw_token =cpu_to_le32 (QTD_STS_HALT ); + qtd->hw_token =cpu_to_hc32 (ehci,QTD_STS_HALT ); qtd->hw_next =EHCI_LIST_END (ehci); qtd->hw_alt_next =EHCI_LIST_END (ehci);INIT_LIST_HEAD (&qtd->qtd_list);
drivers/usb/host/fsl-mph-dr-of.c +89 -0
110 lines not on this page · raw message
include/linux/fsl_devices.h +15 -0
@@ -58,11 +58,26 @@ enum fsl_usb2_phy_modes { FSL_USB2_PHY_SERIAL, }; +struct clk ; +struct platform_device ; +struct fsl_usb2_platform_data {/* board specific information */ enum fsl_usb2_operating_modes operating_mode;enum fsl_usb2_phy_modes phy_mode;unsigned int port_enables; + +int (*init)(struct platform_device *); +void (*exit)(struct platform_device *); +void __iomem *regs;/* ioremap'd register base */ +struct clk *clk; +unsigned big_endian_mmio:1 ; +unsigned big_endian_desc:1 ; +unsigned es:1 ;/* need USBMODE:ES */ +unsigned le_setup_buf:1 ; +unsigned have_sysif_regs:1 ; +unsigned invert_drvvbus:1 ; +unsigned invert_pwr_fault:1 ; };/* Flags in fsl_usb2_mph_platform_data */
Signature · 1 line
1.7.0.4