vf610: Add USB support
Subsystems (8)
Stefan Agner
reviewerv2 cover vf610: Add USB support
This patchset adds USB support for Vybrid VF610 SoC. It extends the clock framework to support the USB PHY cocks, extends the device tree files and adds support for the non-core registers in the usbmisc_imx driver.
This patchset needs the eSDHC registers length fix available in Shawn's for-next branch, since that overlapped by chance the USB areas.
The whole patchset proved to be working on a Colibri VF61 and Freescale Tower VF65GS10. The first USB controller runs in peripheral mode. I could successfully use RNDIS, however with some stability issues: Suddenly the other side was not reachable anymore and the interface needed to brought down and back up again. I'm still investigating this.
The second USB controller, running in USB host mode, showed errors when connecting devices behind a USB hub:
[ 215.163507] usb usb1-port1: cannot reset (err = -32) [ 215.170498] usb usb1-port1: cannot reset (err = -32) [ 215.185120] usb usb1-port1: cannot reset (err = -32) [ 215.191345] usb usb1-port1: cannot reset (err = -32) [ 215.202487] usb usb1-port1: cannot reset (err = -32) [ 215.207718] usb usb1-port1: Cannot enable. Maybe the USB cable is bad? [ 215.219317] usb usb1-port1: unable to enumerate USB device
By extending the PHY driver with the MXS_PHY_NEED_IP_FIX flag, this issue is resolved.
Changes in v2:
- Extended usbmisc_imx to support multiple instances
- Update DT documentation and compatible strings where necessary
- Add USB PHY flag MXS_PHY_NEED_IP_FIX
- Added patches to enable USB on Tower
Stefan Agner (7):
ARM: dts: vf610: Add USB PHY and controller
ARM: imx: clk-vf610: Add USBPHY clocks
usb: phy: mxs: Add VF610 USB PHY support
ARM: dts: vf610: Add usbmisc for non-core registers
chipidea: usbmisc_imx: Add USB support for VF610 SoCs
ARM: dts: vf610-colibri: Add USB support
ARM: dts: vf610-twr: Add USB support
Documentation/devicetree/bindings/usb/mxs-phy.txt | 1 + .../devicetree/bindings/usb/usbmisc-imx.txt | 1 + arch/arm/boot/dts/vf610-colibri.dts | 10 ++++ arch/arm/boot/dts/vf610-twr.dts | 10 ++++ arch/arm/boot/dts/vf610.dtsi | 60 ++++++++++++++++++++-- arch/arm/mach-imx/clk-vf610.c | 12 ++++- drivers/usb/chipidea/ci_hdrc_imx.c | 8 +++ drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 52 +++++++++++++++---- drivers/usb/phy/phy-mxs-usb.c | 6 +++ include/dt-bindings/clock/vf610-clock.h | 5 +- 11 files changed, 149 insertions(+), 17 deletions(-)
Signature · 1 line
2.0.2
Stefan Agner
reviewerPATCH v2 1/7 ARM: dts: vf610: Add USB PHY and controller
This adds USB PHY and USB controller nodes. Vybrid SoCs have two independent USB cores which each supports DR (dual role). However, real OTG is not supported since the OTG ID pin is not available.
The PHYs are located within the anadig register range, hence we need to change the length of the anadig registers.
--- arch/arm/boot/dts/vf610.dtsi | 46 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-)
arch/arm/boot/dts/vf610.dtsi +43 -3
@@ -25,6 +25,8 @@ gpio2 = &gpio3; gpio3 = &gpio4; gpio4 = &gpio5; + usbphy0 = &usbphy0; + usbphy1 = &usbphy1; }; cpus {
@@ -285,9 +287,25 @@ gpio-ranges = <&iomuxc 0 128 7>; }; - anatop at 40050000 { - compatible = "fsl,vf610-anatop"; - reg = <0x40050000 0x1000>; + anatop: anatop at 40050000 { + compatible = "fsl,vf610-anatop", "syscon"; + reg = <0x40050000 0x400>; + }; + + usbphy0: usbphy at 40050800 { + compatible = "fsl,vf610-usbphy"; + reg = <0x40050800 0x400>; + interrupts = <0 50 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks VF610_CLK_USBPHY0>; + fsl,anatop = <&anatop>; + }; + + usbphy1: usbphy at 40050c00 { + compatible = "fsl,vf610-usbphy"; + reg = <0x40050c00 0x400>; + interrupts = <0 51 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks VF610_CLK_USBPHY1>; + fsl,anatop = <&anatop>; }; i2c0: i2c at 40066000 {
@@ -309,6 +327,18 @@ reg = <0x4006b000 0x1000>; #clock-cells = <1>; }; + + usbdev0: usb at 40034000 { + compatible = "fsl,vf610-usb", "fsl,imx27-usb"; + reg = <0x40034000 0x800>; + interrupts = <0 75 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks VF610_CLK_USBC0>; + fsl,usbphy = <&usbphy0>; + dr_mode = "peripheral"; + status = "disabled"; + }; + + }; aips1: aips-bus at 40080000 {
@@ -371,6 +401,16 @@ status = "disabled"; }; + usbh1: usb at 400b4000 { + compatible = "fsl,vf610-usb", "fsl,imx27-usb"; + reg = <0x400b4000 0x800>; + interrupts = <0 76 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clks VF610_CLK_USBC1>; + fsl,usbphy = <&usbphy1>; + dr_mode = "host"; + status = "disabled"; + }; + ftm: ftm at 400b8000 { compatible = "fsl,ftm-timer"; reg = <0x400b8000 0x1000 0x400b9000 0x1000>;
Signature · 1 line
2.0.2
Stefan Agner
reviewerPATCH v2 2/7 ARM: imx: clk-vf610: Add USBPHY clocks
In reply to Stefan AgnerThis commit adds PLL7 which is required for USBPHY1. It also adds the USB PHY and USB Controller clocks and the gates to enable them.
--- arch/arm/mach-imx/clk-vf610.c | 12 ++++++++++-- include/dt-bindings/clock/vf610-clock.h | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-)
arch/arm/mach-imx/clk-vf610.c +10 -2
@@ -58,6 +58,8 @@#define PFD_PLL1_BASE (anatop_base + 0x2b0)#define PFD_PLL2_BASE (anatop_base + 0x100)#define PFD_PLL3_BASE (anatop_base + 0xf0) +#define PLL3_CTRL (anatop_base + 0x10) +#define PLL7_CTRL (anatop_base + 0x20)static void __iomem *anatop_base;static void __iomem *ccm_base;
@@ -148,6 +150,9 @@ static void __init vf610_clocks_init(struct device_node *ccm_node) clk[VF610_CLK_PLL5_MAIN ] =imx_clk_fixed_factor ("pll5_main" ,"fast_clk_sel" ,125 ,6 );/* pll6: default 960Mhz */ clk[VF610_CLK_PLL6_MAIN ] =imx_clk_fixed_factor ("pll6_main" ,"fast_clk_sel" ,40 ,1 ); +/* pll7: USB1 PLL at 480MHz */ + clk[VF610_CLK_PLL7_MAIN ] =imx_clk_pllv3 (IMX_PLLV3_USB ,"pll7_main" ,"fast_clk_sel" ,PLL7_CTRL ,0x2 ); + clk[VF610_CLK_PLL1_PFD_SEL ] =imx_clk_mux ("pll1_pfd_sel" ,CCM_CCSR ,16 ,3 , pll1_sels,5 ); clk[VF610_CLK_PLL2_PFD_SEL ] =imx_clk_mux ("pll2_pfd_sel" ,CCM_CCSR ,19 ,3 , pll2_sels,5 ); clk[VF610_CLK_SYS_SEL ] =imx_clk_mux ("sys_sel" ,CCM_CCSR ,0 ,3 , sys_sels,ARRAY_SIZE (sys_sels));
@@ -160,8 +165,11 @@ static void __init vf610_clocks_init(struct device_node *ccm_node) clk[VF610_CLK_PLL4_MAIN_DIV ] =clk_register_divider_table (NULL ,"pll4_main_div" ,"pll4_main" ,0 ,CCM_CACRR ,6 ,3 ,0 , pll4_main_div_table, &imx_ccm_lock); clk[VF610_CLK_PLL6_MAIN_DIV ] =imx_clk_divider ("pll6_main_div" ,"pll6_main" ,CCM_CACRR ,21 ,1 ); - clk[VF610_CLK_USBC0 ] =imx_clk_gate2 ("usbc0" ,"pll3_main" ,CCM_CCGR1 ,CCM_CCGRx_CGn (4 )); - clk[VF610_CLK_USBC1 ] =imx_clk_gate2 ("usbc1" ,"pll3_main" ,CCM_CCGR7 ,CCM_CCGRx_CGn (4 )); + clk[VF610_CLK_USBPHY0 ] =imx_clk_gate ("usbphy0" ,"pll3_main" ,PLL3_CTRL ,6 ); + clk[VF610_CLK_USBPHY1 ] =imx_clk_gate ("usbphy1" ,"pll7_main" ,PLL7_CTRL ,6 ); + + clk[VF610_CLK_USBC0 ] =imx_clk_gate2 ("usbc0" ,"ipg_bus" ,CCM_CCGR1 ,CCM_CCGRx_CGn (4 )); + clk[VF610_CLK_USBC1 ] =imx_clk_gate2 ("usbc1" ,"ipg_bus" ,CCM_CCGR7 ,CCM_CCGRx_CGn (4 )); clk[VF610_CLK_QSPI0_SEL ] =imx_clk_mux ("qspi0_sel" ,CCM_CSCMR1 ,22 ,2 , qspi_sels,4 ); clk[VF610_CLK_QSPI0_EN ] =imx_clk_gate ("qspi0_en" ,"qspi0_sel" ,CCM_CSCDR3 ,4 );
include/dt-bindings/clock/vf610-clock.h +4 -1
@@ -164,6 +164,9 @@#define VF610_CLK_DMAMUX1 151#define VF610_CLK_DMAMUX2 152#define VF610_CLK_DMAMUX3 153 -#define VF610_CLK_END 154 +#define VF610_CLK_PLL7_MAIN 154 +#define VF610_CLK_USBPHY0 155 +#define VF610_CLK_USBPHY1 156 +#define VF610_CLK_END 157#endif /* __DT_BINDINGS_CLOCK_VF610_H */
Signature · 1 line
2.0.2
Stefan Agner
reviewerPATCH v2 3/7 usb: phy: mxs: Add VF610 USB PHY support
In reply to Stefan AgnerThis adds support for the USB PHY in Vybrid VF610. We assume that the disconnection without VBUS is also needed for Vybrid.
Tests showed, without MXS_PHY_NEED_IP_FIX, enumeration of devices behind a USB Hub fails with errors:
[ 215.163507] usb usb1-port1: cannot reset (err = -32) [ 215.170498] usb usb1-port1: cannot reset (err = -32) [ 215.185120] usb usb1-port1: cannot reset (err = -32) [ 215.191345] usb usb1-port1: cannot reset (err = -32) [ 215.202487] usb usb1-port1: cannot reset (err = -32) [ 215.207718] usb usb1-port1: Cannot enable. Maybe the USB cable is bad? [ 215.219317] usb usb1-port1: unable to enumerate USB device
Hence we also enable the MXS_PHY_NEED_IP_FIX flag.
--- Documentation/devicetree/bindings/usb/mxs-phy.txt | 1 + drivers/usb/phy/phy-mxs-usb.c | 6 ++++++ 2 files changed, 7 insertions(+)
Documentation/devicetree/bindings/usb/mxs-phy.txt +1 -0
@@ -5,6 +5,7 @@ Required properties: * "fsl,imx23-usbphy" for imx23 and imx28 * "fsl,imx6q-usbphy" for imx6dq and imx6dl * "fsl,imx6sl-usbphy" for imx6sl + * "fsl,vf610-usbphy" for Vybrid vf610 "fsl,imx23-usbphy" is still a fallback for other strings - reg: Should contain registers location and length - interrupts: Should contain phy interrupt
drivers/usb/phy/phy-mxs-usb.c +6 -0
@@ -125,10 +125,16 @@ static const struct mxs_phy_data imx6sl_phy_data = { MXS_PHY_NEED_IP_FIX, }; +static const struct mxs_phy_data vf610_phy_data = { + .flags =MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | +MXS_PHY_NEED_IP_FIX , +}; +static const struct of_device_id mxs_phy_dt_ids[] = { { .compatible ="fsl,imx6sl-usbphy" , .data = &imx6sl_phy_data, }, { .compatible ="fsl,imx6q-usbphy" , .data = &imx6q_phy_data, }, { .compatible ="fsl,imx23-usbphy" , .data = &imx23_phy_data, }, + { .compatible ="fsl,vf610-usbphy" , .data = &vf610_phy_data, }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, mxs_phy_dt_ids);
Signature · 1 line
2.0.2
Re: [PATCH v2 3/7] usb: phy: mxs: Add VF610 USB PHY support
Quoted 58 lines · Stefan Agner
This adds support for the USB PHY in Vybrid VF610. We assume that the disconnection without VBUS is also needed for Vybrid.
Tests showed, without
MXS_PHY_NEED_IP_FIX, enumeration of devices behind a USB Hub fails with errors:[ 215.163507] usb usb1-port1: cannot reset (err = -32) [ 215.170498] usb usb1-port1: cannot reset (err = -32) [ 215.185120] usb usb1-port1: cannot reset (err = -32) [ 215.191345] usb usb1-port1: cannot reset (err = -32) [ 215.202487] usb usb1-port1: cannot reset (err = -32) [ 215.207718] usb usb1-port1: Cannot enable. Maybe the USB cable is bad? [ 215.219317] usb usb1-port1: unable to enumerate USB deviceHence we also enable the
MXS_PHY_NEED_IP_FIXflag.Signed-off-by Stefan Agner <[email protected]>--- Documentation/devicetree/bindings/usb/mxs-phy.txt | 1 + drivers/usb/phy/phy-mxs-usb.c | 6 ++++++ 2 files changed, 7 insertions(+)Documentation/devicetree/bindings/usb/mxs-phy.txt +1
-0@@ -5,6 +5,7 @@ Required properties: * "fsl,imx23-usbphy" for imx23 and imx28 * "fsl,imx6q-usbphy" for imx6dq and imx6dl * "fsl,imx6sl-usbphy" for imx6sl + * "fsl,vf610-usbphy" for Vybrid vf610 "fsl,imx23-usbphy" is still a fallback for other strings - reg: Should contain registers location and length - interrupts: Should contain phy interruptdrivers/usb/phy/phy-mxs-usb.c +6
-0@@ -125,10 +125,16 @@ static const struct mxs_phy_data imx6sl_phy_data = { MXS_PHY_NEED_IP_FIX, }; +static const struct mxs_phy_data vf610_phy_data = { + .flags =MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | +MXS_PHY_NEED_IP_FIX , +}; +static const struct of_device_id mxs_phy_dt_ids[] = { { .compatible ="fsl,imx6sl-usbphy" , .data = &imx6sl_phy_data, }, { .compatible ="fsl,imx6q-usbphy" , .data = &imx6q_phy_data, }, { .compatible ="fsl,imx23-usbphy" , .data = &imx23_phy_data, }, + { .compatible ="fsl,vf610-usbphy" , .data = &vf610_phy_data, }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, mxs_phy_dt_ids);Signature · 1 line
2.0.2
Signature · 2 lines
Best Regards, Peter Chen
Stefan Agner
reviewerRe: [PATCH v2 3/7] usb: phy: mxs: Add VF610 USB PHY support
Am 2014-08-02 02:36, schrieb Peter Chen:
Quoted 53 lines · Stefan Agner
Quoted 52 lines
This adds support for the USB PHY in Vybrid VF610. We assume that the disconnection without VBUS is also needed for Vybrid.
Tests showed, without
MXS_PHY_NEED_IP_FIX, enumeration of devices behind a USB Hub fails with errors:[ 215.163507] usb usb1-port1: cannot reset (err = -32) [ 215.170498] usb usb1-port1: cannot reset (err = -32) [ 215.185120] usb usb1-port1: cannot reset (err = -32) [ 215.191345] usb usb1-port1: cannot reset (err = -32) [ 215.202487] usb usb1-port1: cannot reset (err = -32) [ 215.207718] usb usb1-port1: Cannot enable. Maybe the USB cable is bad? [ 215.219317] usb usb1-port1: unable to enumerate USB deviceHence we also enable the
MXS_PHY_NEED_IP_FIXflag.Signed-off-by Stefan Agner <[email protected]>--- Documentation/devicetree/bindings/usb/mxs-phy.txt | 1 + drivers/usb/phy/phy-mxs-usb.c | 6 ++++++ 2 files changed, 7 insertions(+)Documentation/devicetree/bindings/usb/mxs-phy.txt +1
-0@@ -5,6 +5,7 @@ Required properties: * "fsl,imx23-usbphy" for imx23 and imx28 * "fsl,imx6q-usbphy" for imx6dq and imx6dl * "fsl,imx6sl-usbphy" for imx6sl + * "fsl,vf610-usbphy" for Vybrid vf610 "fsl,imx23-usbphy" is still a fallback for other strings - reg: Should contain registers location and length - interrupts: Should contain phy interruptdrivers/usb/phy/phy-mxs-usb.c +6
-0@@ -125,10 +125,16 @@ static const struct mxs_phy_data imx6sl_phy_data = { MXS_PHY_NEED_IP_FIX, }; +static const struct mxs_phy_data vf610_phy_data = { + .flags =MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | +MXS_PHY_NEED_IP_FIX , +}; +static const struct of_device_id mxs_phy_dt_ids[] = { { .compatible ="fsl,imx6sl-usbphy" , .data = &imx6sl_phy_data, }, { .compatible ="fsl,imx6q-usbphy" , .data = &imx6q_phy_data, }, { .compatible ="fsl,imx23-usbphy" , .data = &imx23_phy_data, }, + { .compatible ="fsl,vf610-usbphy" , .data = &vf610_phy_data, },
Quoted 8 lines
Quoted 6 lines
drivers/usb/phy/phy-mxs-usb.c +0
-1{/* sentinel */ } };MODULE_DEVICE_TABLE (of, mxs_phy_dt_ids); --2.0.2
Acked-by Peter Chen <[email protected]>
Thanks Peter.
Just realized that I missed USB PHY maintainer Felipe Balbi, sorry! Felipe, I guess this goes through your tree?
--
Stefan
Stefan Agner
reviewerPATCH v2 4/7 ARM: dts: vf610: Add usbmisc for non-core registers
In reply to Stefan AgnerAdd device tree node for usbmisc which controls the non-core USB registers. This is required to use the property to disable the over- current detection.
--- arch/arm/boot/dts/vf610.dtsi | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
arch/arm/boot/dts/vf610.dtsi +15 -1
@@ -334,11 +334,17 @@ interrupts = <0 75 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks VF610_CLK_USBC0>; fsl,usbphy = <&usbphy0>; + fsl,usbmisc = <&usbmisc0 0>; dr_mode = "peripheral"; status = "disabled"; }; - + usbmisc0: usb at 40034800 { + #index-cells = <1>; + compatible = "fsl,vf610-usbmisc"; + reg = <0x40034800 0x200>; + clocks = <&clks VF610_CLK_USBC0>; + }; }; aips1: aips-bus at 40080000 {
@@ -407,10 +413,18 @@ interrupts = <0 76 IRQ_TYPE_LEVEL_HIGH>; clocks = <&clks VF610_CLK_USBC1>; fsl,usbphy = <&usbphy1>; + fsl,usbmisc = <&usbmisc1 0>; dr_mode = "host"; status = "disabled"; }; + usbmisc1: usb at 400b4800 { + #index-cells = <1>; + compatible = "fsl,vf610-usbmisc"; + reg = <0x400b4800 0x200>; + clocks = <&clks VF610_CLK_USBC1>; + }; + ftm: ftm at 400b8000 { compatible = "fsl,ftm-timer"; reg = <0x400b8000 0x1000 0x400b9000 0x1000>;
Signature · 1 line
2.0.2
Stefan Agner
reviewerPATCH v2 5/7 chipidea: usbmisc_imx: Add USB support for VF610 SoCs
In reply to Stefan AgnerThis adds Vybrid VF610 SoC support. The IP is very similar to i.MX6, however, the non-core registers are spread in two different register areas. Hence we support multiple instances of the USB misc driver and add the driver instance to the imx_usbmisc_data structure.
---
In the end, I decieded against the advice of Peter to integrate the multi-instance functionality in a second driver. To support multiple instances, I needed to extend the imx_usbmisc_data to point to the instance. Since this is part of the ci_hdrc_imx driver, I feel it's cleaner to extend the current driver rather to add a second driver and implement two different handlings in the ci_hdrc_imx driver.
Also, the current approach has a slight advantage for current users
too: EPROBE_DEFER is returned earlier, when initializing the imx_usbmisc_data structure rather than later on, when accessing the driver by using imx_usbmisc_init/imx_usbmisc_init_post.
As a free bonus, this driver would now also support the mixed case:
multiple non-core registers in different areas which each support multiple USB controllers...
Tell me if this is ok for you too.
.../devicetree/bindings/usb/usbmisc-imx.txt | 1 + drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++ drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 52 +++++++++++++++++----- 4 files changed, 51 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/usb/usbmisc-imx.txt +1 -0
@@ -4,6 +4,7 @@ Required properties: - #index-cells: Cells used to descibe usb controller index. Should be <1> - compatible: Should be one of below: "fsl,imx6q-usbmisc" for imx6q + "fsl,vf610-usbmisc" for Vybrid vf610 - reg: Should contain registers location and length Examples:
drivers/usb/chipidea/ci_hdrc_imx.c +8 -0
@@ -54,6 +54,7 @@ struct ci_hdrc_imx_data {static struct imx_usbmisc_data *usbmisc_get_init_data (struct device *dev) { +struct platform_device *misc_pdev;struct device_node *np = dev->of_node;struct of_phandle_args args;struct imx_usbmisc_data *data;
@@ -79,8 +80,15 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) } data->index = args.args[0 ]; + + misc_pdev =of_find_device_by_node (args.np);of_node_put (args.np); +if (!misc_pdev) +return ERR_PTR (-EPROBE_DEFER ); + + data->dev = &misc_pdev->dev; +if (of_find_property (np,"disable-over-current" ,NULL )) data->disable_oc =1 ;
drivers/usb/chipidea/ci_hdrc_imx.h +1 -0
@@ -13,6 +13,7 @@#define __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_Hstruct imx_usbmisc_data { +struct device *dev;int index;unsigned int disable_oc:1 ;/* over current detect disabled */
drivers/usb/chipidea/usbmisc_imx.c +41 -11
135 lines not on this page · raw message
Signature · 1 line
2.0.2
Re: [PATCH v2 5/7] chipidea: usbmisc_imx: Add USB support for VF610 SoCs
Quoted 237 lines · Stefan Agner
This adds Vybrid VF610 SoC support. The IP is very similar to i.MX6, however, the non-core registers are spread in two different register areas. Hence we support multiple instances of the USB misc driver and add the driver instance to the
imx_usbmisc_datastructure.Signed-off-by Stefan Agner <[email protected]>---
In the end, I decieded against the advice of Peter to integrate the multi-instance functionality in a second driver. To support multiple instances, I needed to extend theimx_usbmisc_datato point to the instance. Since this is part of theci_hdrc_imxdriver, I feel it's cleaner to extend the current driver rather to add a second driver and implement two different handlings in theci_hdrc_imxdriver.Also, the current approach has a slight advantage for current users
too:EPROBE_DEFERis returned earlier, when initializing theimx_usbmisc_datastructure rather than later on, when accessing the driver by using imx_usbmisc_init/imx_usbmisc_init_post.As a free bonus, this driver would now also support the mixed case:
multiple non-core registers in different areas which each support multiple USB controllers...Tell me if this is ok for you too.
.../devicetree/bindings/usb/usbmisc-imx.txt | 1 + drivers/usb/chipidea/ci_hdrc_imx.c | 8 ++++ drivers/usb/chipidea/ci_hdrc_imx.h | 1 + drivers/usb/chipidea/usbmisc_imx.c | 52 +++++++++++++++++----- 4 files changed, 51 insertions(+), 11 deletions(-)Documentation/devicetree/bindings/usb/usbmisc-imx.txt +1
-0@@ -4,6 +4,7 @@ Required properties: - #index-cells: Cells used to descibe usb controller index. Should be <1> - compatible: Should be one of below: "fsl,imx6q-usbmisc" for imx6q + "fsl,vf610-usbmisc" for Vybrid vf610 - reg: Should contain registers location and length Examples:drivers/usb/chipidea/ci_hdrc_imx.c +8
-0@@ -54,6 +54,7 @@ struct ci_hdrc_imx_data {static struct imx_usbmisc_data *usbmisc_get_init_data (struct device *dev) { +struct platform_device *misc_pdev;struct device_node *np = dev->of_node;struct of_phandle_args args;struct imx_usbmisc_data *data;@@ -79,8 +80,15 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) } data->index = args.args[0 ]; + + misc_pdev =of_find_device_by_node (args.np);of_node_put (args.np); +if (!misc_pdev) +return ERR_PTR (-EPROBE_DEFER ); + + data->dev = &misc_pdev->dev; +if (of_find_property (np,"disable-over-current" ,NULL )) data->disable_oc =1 ;drivers/usb/chipidea/ci_hdrc_imx.h +1
-0@@ -13,6 +13,7 @@#define __DRIVER_USB_CHIPIDEA_CI_HDRC_IMX_Hstruct imx_usbmisc_data { +struct device *dev;int index;unsigned int disable_oc:1 ;/* over current detect disabled */ drivers/usb/chipidea/usbmisc_imx.c +41
-11@@ -57,6 +57,8 @@#define MX6_BM_OVER_CUR_DIS BIT(7) +#define VF610_OVER_CUR_DIS BIT(7) +struct usbmisc_ops {/* It's called once when probe a usb device */ int (*init)(struct imx_usbmisc_data *data);@@ -71,10 +73,9 @@ struct imx_usbmisc {const struct usbmisc_ops *ops; }; -static struct imx_usbmisc *usbmisc; -static int usbmisc_imx25_init (struct imx_usbmisc_data *data) { +struct imx_usbmisc *usbmisc =dev_get_drvdata (data->dev);unsigned long flags;u32 val =0 ;@@ -108,6 +109,7 @@ static int usbmisc_imx25_init(struct imx_usbmisc_data *data)static int usbmisc_imx25_post (struct imx_usbmisc_data *data) { +struct imx_usbmisc *usbmisc =dev_get_drvdata (data->dev);void __iomem *reg;unsigned long flags;u32 val;@@ -130,6 +132,7 @@ static int usbmisc_imx25_post(struct imx_usbmisc_data *data)static int usbmisc_imx27_init (struct imx_usbmisc_data *data) { +struct imx_usbmisc *usbmisc =dev_get_drvdata (data->dev);unsigned long flags;u32 val;@@ -160,6 +163,7 @@ static int usbmisc_imx27_init(struct imx_usbmisc_data *data)static int usbmisc_imx53_init (struct imx_usbmisc_data *data) { +struct imx_usbmisc *usbmisc =dev_get_drvdata (data->dev);void __iomem *reg =NULL ;unsigned long flags;u32 val =0 ;@@ -204,6 +208,7 @@ static int usbmisc_imx53_init(struct imx_usbmisc_data *data)static int usbmisc_imx6q_init (struct imx_usbmisc_data *data) { +struct imx_usbmisc *usbmisc =dev_get_drvdata (data->dev);unsigned long flags;u32 reg;@@ -221,6 +226,26 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)return 0 ; } +static int usbmisc_vf610_init (struct imx_usbmisc_data *data) +{ +struct imx_usbmisc *usbmisc =dev_get_drvdata (data->dev); +u32 reg; + +/* +* Vybrid only has one misc register set, but in two different +* areas. These is reflected in two instances of this driver. +*/ +if (data->index >=1 ) +return -EINVAL ; + +if (data->disable_oc) { + reg =readl (usbmisc->base); +writel (reg |VF610_OVER_CUR_DIS , usbmisc->base); + } + +return 0 ; +} +static const struct usbmisc_ops imx25_usbmisc_ops = { .init = usbmisc_imx25_init, .post = usbmisc_imx25_post,@@ -238,10 +263,14 @@ static const struct usbmisc_ops imx6q_usbmisc_ops = { .init = usbmisc_imx6q_init, }; +static const struct usbmisc_ops vf610_usbmisc_ops = { + .init = usbmisc_vf610_init, +}; +int imx_usbmisc_init (struct imx_usbmisc_data *data) { -if (!usbmisc) -return -EPROBE_DEFER ; +struct imx_usbmisc *usbmisc =dev_get_drvdata (data->dev); +if (!usbmisc->ops->init)return 0 ;return usbmisc->ops->init (data);@@ -250,8 +279,8 @@ EXPORT_SYMBOL_GPL(imx_usbmisc_init);int imx_usbmisc_init_post (struct imx_usbmisc_data *data) { -if (!usbmisc) -return -EPROBE_DEFER ; +struct imx_usbmisc *usbmisc =dev_get_drvdata (data->dev); +if (!usbmisc->ops->post)return 0 ;return usbmisc->ops->post (data);@@ -283,6 +312,10 @@ static const struct of_device_id usbmisc_imx_dt_ids[] = { .compatible = "fsl,imx6q-usbmisc", .data = &imx6q_usbmisc_ops, }, + { + .compatible = "fsl,vf610-usbmisc", + .data = &vf610_usbmisc_ops, + }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, usbmisc_imx_dt_ids);@@ -294,9 +327,6 @@ static int usbmisc_imx_probe(struct platform_device *pdev)int ret;struct of_device_id *tmp_dev; -if (usbmisc) -return -EBUSY ; - data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ;@@ -325,15 +355,15 @@ static int usbmisc_imx_probe(struct platform_device *pdev) tmp_dev = (struct of_device_id *)of_match_device (usbmisc_imx_dt_ids, &pdev->dev); data->ops = (const struct usbmisc_ops *)tmp_dev->data; - usbmisc = data; +platform_set_drvdata (pdev, data);return 0 ; }static int usbmisc_imx_remove (struct platform_device *pdev) { +struct imx_usbmisc *usbmisc =dev_get_drvdata (&pdev->dev);clk_disable_unprepare (usbmisc->clk); - usbmisc =NULL ;return 0 ; }Signature · 1 line
2.0.2
Great patch, applied to my local tree, thanks.
Signature · 2 lines
Best Regards, Peter Chen
Stefan Agner
reviewerPATCH v2 6/7 ARM: dts: vf610-colibri: Add USB support
In reply to Stefan AgnerAdd USB support for Colibri VF61 modules. The Colibri standard pinout defines a pin for USB over-current. However, due to lack of pinmux options, the USB hosts over-current protection signal of the Colibri standard could not be connected to the PHY's over-current protection. Hence we need to disable the over-current functionality of the USB controller.
--- arch/arm/boot/dts/vf610-colibri.dts | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/boot/dts/vf610-colibri.dts +10 -0
@@ -69,6 +69,16 @@ status = "okay"; }; +&usbdev0 { + disable-over-current; + status = "okay"; +}; + +&usbh1 { + disable-over-current; + status = "okay"; +}; + &iomuxc { vf610-colibri { pinctrl_esdhc1: esdhc1grp {
Signature · 1 line
2.0.2
Stefan Agner
reviewerPATCH v2 7/7 ARM: dts: vf610-twr: Add USB support
In reply to Stefan AgnerAdd USB support for Freescale Vybrid tower. The USB hosts over-current protection signal is not connected is not connected to the PHY's over- current protection, hence we need to disable it.
--- arch/arm/boot/dts/vf610-twr.dts | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/arm/boot/dts/vf610-twr.dts +10 -0
@@ -265,3 +265,13 @@ pinctrl-0 = <&pinctrl_uart1>; status = "okay"; }; + +&usbdev0 { + disable-over-current; + status = "okay"; +}; + +&usbh1 { + disable-over-current; + status = "okay"; +};
Signature · 1 line
2.0.2
Quoted 3 lines · Stefan Agner
Stefan Agner (7):
ARM: dts: vf610: Add USB PHY and controller
ARM: imx: clk-vf610: Add USBPHY clocks
...
Quoted 1 line
ARM: dts: vf610: Add usbmisc for non-core registers
...
Quoted 2 lines
ARM: dts: vf610-colibri: Add USB support
ARM: dts: vf610-twr: Add USB support
These 'ARM: ...' patches look fine to me, and I will apply them on IMX tree once the driver changes are accepted.
Shawn