chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver
Subsystems (4)
cover chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver
Hello,
this series depends on the series "[PATCH 0/3] otg-for-v3.10-v1: separate phy code and add DT helper" (a.k.a. tags/otg-for-v3.10-v1) posted earlier and is intended for v3.10. The chipidea driver is converted to make use of the DT helper functions.
regards,
Marc
The following changes since commit 8a4c9f8489b2fce9e7bf0eb43fdb160ab51adc2c:
USB mxs-phy: Register phy with framework (2013-02-27 13:48:21 +0100)
are available in the git repository at:
git://git.pengutronix.de/git/mkl/linux.git tags/chipidea-for-v3.10-v1
for you to fetch changes up to 5d837224ea36da50f3e744a65fb23af1fa0a480d:
USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy (2013-02-27 13:49:07 +0100)
----------------------------------------------------------------
USB chipidea: make use of DT helpers in chipidea driver
Make use of DT helper functions for handling the dr_mode and phy_type property.
----------------------------------------------------------------
Michael Grzeschik (2):
USB chipidea: ci13xxx-imx: create dynamic platformdata USB chipidea: add PTW and PTS handling
Sascha Hauer (3):
USB chipidea: introduce dual role mode pdata flags USB chipidea i.MX: introduce dr_mode property
USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
.../devicetree/bindings/usb/ci13xxx-imx.txt | 6 ++ drivers/usb/chipidea/bits.h | 14 +++- drivers/usb/chipidea/ci13xxx_imx.c | 67 +++++++++++--------- drivers/usb/chipidea/core.c | 61 ++++++++++++++++-- include/linux/usb/chipidea.h | 3 +- 5 files changed, 112 insertions(+), 39 deletions(-)
PATCH 1/5 USB chipidea: ci13xxx-imx: create dynamic platformdata
From: Michael Grzeschik <[email protected]>
This patch removes the limitation of having only one instance of the ci13xxx-imx platformdata and makes different configurations possible.
--- drivers/usb/chipidea/ci13xxx_imx.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/usb/chipidea/ci13xxx_imx.c +15 -10
@@ -85,17 +85,10 @@ EXPORT_SYMBOL_GPL(usbmisc_get_init_data);/* End of common functions shared by usbmisc drivers*/ -static struct ci13xxx_platform_data ci13xxx_imx_platdata = { - .name ="ci13xxx_imx" , - .flags =CI13XXX_REQUIRE_TRANSCEIVER | -CI13XXX_PULLUP_ON_VBUS | -CI13XXX_DISABLE_STREAMING , - .capoffset =DEF_CAPOFFSET , -}; -static int ci13xxx_imx_probe (struct platform_device *pdev) {struct ci13xxx_imx_data *data; +struct ci13xxx_platform_data *pdata;struct platform_device *plat_ci, *phy_pdev;struct device_node *phy_np;struct resource *res;
@@ -107,6 +100,18 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) && !usbmisc_ops)return -EPROBE_DEFER ; + pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); +if (!pdata) { +dev_err (&pdev->dev,"Failed to allocate CI13xxx-IMX pdata!\n" ); +return -ENOMEM ; + } + + pdata->name ="ci13xxx_imx" ; + pdata->capoffset =DEF_CAPOFFSET ; + pdata->flags =CI13XXX_REQUIRE_TRANSCEIVER | +CI13XXX_PULLUP_ON_VBUS | +CI13XXX_DISABLE_STREAMING ; + data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );if (!data) {dev_err (&pdev->dev,"Failed to allocate CI13xxx-IMX data!\n" );
@@ -168,7 +173,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) reg_vbus =NULL ; } - ci13xxx_imx_platdata.phy = data->phy; + pdata->phy = data->phy;if (!pdev->dev.dma_mask) { pdev->dev.dma_mask = devm_kzalloc(&pdev->dev,
@@ -193,7 +198,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) plat_ci =ci13xxx_add_device (&pdev->dev, pdev->resource, pdev->num_resources, - &ci13xxx_imx_platdata); + pdata);if (IS_ERR (plat_ci)) { ret =PTR_ERR (plat_ci); dev_err(&pdev->dev,
Signature · 1 line
1.7.10.4
PATCH 2/5 USB chipidea: add PTW and PTS handling
In reply to Marc Kleine-BuddeFrom: Michael Grzeschik <[email protected]>
This patch makes it possible to configure the PTW and PTS bits inside the portsc register for host and device mode before the driver starts and the phy can be addressed as hardware implementation is designed.
--- .../devicetree/bindings/usb/ci13xxx-imx.txt | 5 +++ drivers/usb/chipidea/bits.h | 14 ++++++- drivers/usb/chipidea/ci13xxx_imx.c | 3 ++ drivers/usb/chipidea/core.c | 39 ++++++++++++++++++++ include/linux/usb/chipidea.h | 1 + 5 files changed, 61 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +5 -0
@@ -5,6 +5,11 @@ Required properties: - reg: Should contain registers location and length - interrupts: Should contain controller interrupt +Recommended properies: +- phy_type: the type of the phy connected to the core. Should be one + of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this + property the PORTSC register won't be touched + Optional properties: - fsl,usbphy: phandler of usb phy that connects to the only one port - fsl,usbmisc: phandler of non-core register device, with one argument
drivers/usb/chipidea/bits.h +13 -1
@@ -48,10 +48,22 @@#define PORTSC_SUSP BIT(7)#define PORTSC_HSP BIT(9)#define PORTSC_PTC (0x0FUL << 16) +/* PTS and PTW for non lpm version only */ +#define PORTSC_PTS (d) ((((d) & 0x3) << 30) | (((d) & 0x4) ? BIT(25) : 0)) +#define PORTSC_PTW BIT(28)/* DEVLC */ #define DEVLC_PSPD (0x03UL << 25) -#define DEVLC_PSPD_HS (0x02UL << 25) +#define DEVLC_PSPD_HS (0x02UL << 25) +#define DEVLC_PTW BIT(27) +#define DEVLC_STS BIT(28) +#define DEVLC_PTS (d) (((d) & 0x7) << 29) + +/* Encoding for DEVLC_PTS and PORTSC_PTS */ +#define PTS_UTMI 0 +#define PTS_ULPI 2 +#define PTS_SERIAL 3 +#define PTS_HSIC 4/* OTGSC */ #define OTGSC_IDPU BIT(5)
drivers/usb/chipidea/ci13xxx_imx.c +3 -0
@@ -21,6 +21,7 @@#include <linux/clk.h> #include <linux/regulator/consumer.h> #include <linux/pinctrl/consumer.h> +#include <linux/usb/of.h> #include "ci.h" #include "ci13xxx_imx.h"
@@ -112,6 +113,8 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)CI13XXX_PULLUP_ON_VBUS |CI13XXX_DISABLE_STREAMING ; + pdata->phy_mode =of_usb_get_phy_mode (pdev->dev.of_node); + data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );if (!data) {dev_err (&pdev->dev,"Failed to allocate CI13xxx-IMX data!\n" );
drivers/usb/chipidea/core.c +39 -0
@@ -67,6 +67,8 @@#include <linux/usb/gadget.h> #include <linux/usb/otg.h> #include <linux/usb/chipidea.h> +#include <linux/usb/of.h> +#include <linux/phy.h> #include "ci.h" #include "udc.h"
@@ -211,6 +213,41 @@ static int hw_device_init(struct ci13xxx *ci, void __iomem *base)return 0 ; } +static void hw_phymode_configure (struct ci13xxx *ci) +{ +u32 portsc, lpm; + +switch (ci->platdata->phy_mode) { +case USBPHY_INTERFACE_MODE_UTMI : + portsc =PORTSC_PTS (PTS_UTMI ); + lpm =DEVLC_PTS (PTS_UTMI ); +break ; +case USBPHY_INTERFACE_MODE_UTMIW : + portsc =PORTSC_PTS (PTS_UTMI ) |PORTSC_PTW ; + lpm =DEVLC_PTS (PTS_UTMI ) |DEVLC_PTW ; +break ; +case USBPHY_INTERFACE_MODE_ULPI : + portsc =PORTSC_PTS (PTS_ULPI ); + lpm =DEVLC_PTS (PTS_ULPI ); +break ; +case USBPHY_INTERFACE_MODE_SERIAL : + portsc =PORTSC_PTS (PTS_SERIAL ); + lpm =DEVLC_PTS (PTS_SERIAL ); +break ; +case USBPHY_INTERFACE_MODE_HSIC : + portsc =PORTSC_PTS (PTS_HSIC ); + lpm =DEVLC_PTS (PTS_HSIC ); +break ; +default : +return ; + } + +if (ci->hw_bank.lpm) +hw_write (ci,OP_DEVLC ,DEVLC_PTS (7 ) |DEVLC_PTW , lpm); +else +hw_write (ci,OP_PORTSC ,PORTSC_PTS (7 ) |PORTSC_PTW , portsc); +} +/** * hw_device_reset: resets chip (execute without interruption) * @ci: the controller
@@ -476,6 +513,8 @@ static int ci_hdrc_probe(struct platform_device *pdev) : CI_ROLE_GADGET; } +hw_phymode_configure (ci); + ret =ci_role_start (ci, ci->role);if (ret) {dev_err (dev,"can't start %s role\n" ,ci_role (ci)->name);
include/linux/usb/chipidea.h +1 -0
@@ -14,6 +14,7 @@ struct ci13xxx_platform_data {uintptr_t capoffset;unsigned power_budget;struct usb_phy *phy; +enum usb_phy_interface phy_mode;unsigned long flags;#define CI13XXX_REGS_SHARED BIT(0)#define CI13XXX_REQUIRE_TRANSCEIVER BIT(1)
Signature · 1 line
1.7.10.4
PATCH 3/5 USB chipidea: introduce dual role mode pdata flags
In reply to Marc Kleine-BuddeFrom: Sascha Hauer <[email protected]>
Even if a chipidea core is otg capable the board may not. This allows to explicitly set the core to host/peripheral mode. Without these flags the driver falls back to the old behaviour.
--- drivers/usb/chipidea/core.c | 22 ++++++++++++++++------ include/linux/usb/chipidea.h | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/usb/chipidea/core.c +16 -6
@@ -435,6 +435,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)struct resource *res;void __iomem *base;int ret; +enum usb_dr_mode dr_mode;if (!dev->platform_data) {dev_err (dev,"platform data missing\n" );
@@ -487,14 +488,23 @@ static int ci_hdrc_probe(struct platform_device *pdev)return -ENODEV ; } +/* For now we treat dual-role as otg */ + dr_mode = ci->platdata->dr_mode; +if (dr_mode ==USB_DR_MODE_UNKNOWN || dr_mode ==USB_DR_MODE_DUAL_ROLE ) + dr_mode =USB_DR_MODE_OTG ; +/* initialize role(s) before the interrupt is requested */ - ret =ci_hdrc_host_init (ci); -if (ret) -dev_info (dev,"doesn't support host\n" ); +if (dr_mode ==USB_DR_MODE_OTG || dr_mode ==USB_DR_MODE_HOST ) { + ret =ci_hdrc_host_init (ci); +if (ret) +dev_info (dev,"doesn't support host\n" ); + } - ret =ci_hdrc_gadget_init (ci); -if (ret) -dev_info (dev,"doesn't support gadget\n" ); +if (dr_mode ==USB_DR_MODE_OTG || dr_mode ==USB_DR_MODE_PERIPHERAL ) { + ret =ci_hdrc_gadget_init (ci); +if (ret) +dev_info (dev,"doesn't support gadget\n" ); + }if (!ci->roles[CI_ROLE_HOST ] && !ci->roles[CI_ROLE_GADGET ]) {dev_err (dev,"no supported roles\n" );
include/linux/usb/chipidea.h +1 -1
@@ -20,7 +20,7 @@ struct ci13xxx_platform_data {#define CI13XXX_REQUIRE_TRANSCEIVER BIT(1)#define CI13XXX_PULLUP_ON_VBUS BIT(2)#define CI13XXX_DISABLE_STREAMING BIT(3) - +enum usb_dr_mode dr_mode;#define CI13XXX_CONTROLLER_RESET_EVENT 0#define CI13XXX_CONTROLLER_STOPPED_EVENT 1void (*notify_event) (struct ci13xxx *ci,unsigned event);
Signature · 1 line
1.7.10.4
PATCH 4/5 USB chipidea i.MX: introduce dr_mode property
In reply to Marc Kleine-BuddeFrom: Sascha Hauer <[email protected]>
The dr_mode devicetree property allows to explicitly specify the host/peripheral/otg mode. This is necessary for boards without proper ID pin handling.
--- Documentation/devicetree/bindings/usb/ci13xxx-imx.txt | 1 + drivers/usb/chipidea/ci13xxx_imx.c | 1 + 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/usb/ci13xxx-imx.txt +1 -0
@@ -9,6 +9,7 @@ Recommended properies: - phy_type: the type of the phy connected to the core. Should be one of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this property the PORTSC register won't be touched +- dr_mode: One of "host", "peripheral" or "otg". Defaults to "otg" Optional properties: - fsl,usbphy: phandler of usb phy that connects to the only one port
drivers/usb/chipidea/ci13xxx_imx.c +1 -0
@@ -114,6 +114,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)CI13XXX_DISABLE_STREAMING ; pdata->phy_mode =of_usb_get_phy_mode (pdev->dev.of_node); + pdata->dr_mode =of_usb_get_dr_mode (pdev->dev.of_node); data =devm_kzalloc (&pdev->dev,sizeof (*data),GFP_KERNEL );if (!data) {
Signature · 1 line
1.7.10.4
PATCH 5/5 USB chipidea i.MX: use devm_usb_get_phy_by_phandle to get phy
In reply to Marc Kleine-BuddeFrom: Sascha Hauer <[email protected]>
This patch replaces the hand crafted code to retrieve the phy's phandle from the DT by the helper function devm_usb_get_phy_by_phandle() which has been added in commit:
"5d3c28b usb: otg: add device tree support to otg library"
--- drivers/usb/chipidea/ci13xxx_imx.c | 38 ++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 21 deletions(-)
drivers/usb/chipidea/ci13xxx_imx.c +17 -21
@@ -30,7 +30,6 @@ ((struct usb_phy *)platform_get_drvdata(pdev))struct ci13xxx_imx_data { -struct device_node *phy_np;struct usb_phy *phy;struct platform_device *ci_pdev;struct clk *clk;
@@ -90,12 +89,12 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) {struct ci13xxx_imx_data *data;struct ci13xxx_platform_data *pdata; -struct platform_device *plat_ci, *phy_pdev; -struct device_node *phy_np; +struct platform_device *plat_ci;struct resource *res;struct regulator *reg_vbus;struct pinctrl *pinctrl;int ret; +struct usb_phy *phy;if (of_find_property (pdev->dev.of_node,"fsl,usbmisc" ,NULL ) && !usbmisc_ops)
@@ -147,19 +146,20 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)return ret; } - phy_np =of_parse_phandle (pdev->dev.of_node,"fsl,usbphy" ,0 ); -if (phy_np) { - data->phy_np = phy_np; - phy_pdev =of_find_device_by_node (phy_np); -if (phy_pdev) { -struct usb_phy *phy; - phy =pdev_to_phy (phy_pdev); -if (phy && -try_module_get (phy_pdev->dev.driver->owner)) { -usb_phy_init (phy); - data->phy = phy; - } + phy =devm_usb_get_phy_by_phandle (&pdev->dev,"fsl,usbphy" ,0 ); +if (PTR_ERR (phy) == -EPROBE_DEFER ) { + ret = -EPROBE_DEFER ; + goto err_clk; + } + +if (!IS_ERR (phy)) { + ret =usb_phy_init (phy); +if (ret) { +dev_err (&pdev->dev,"unable to init phy: %d\n" , ret); + goto err_clk; } + + data->phy = phy; }/* we only support host now, so enable vbus here */
@@ -170,7 +170,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Failed to enable vbus regulator, err=%d\n" , ret); - goto put_np; + goto err_clk; } data->reg_vbus = reg_vbus; }else {
@@ -222,9 +222,7 @@ static int ci13xxx_imx_probe(struct platform_device *pdev) err:if (reg_vbus)regulator_disable (reg_vbus); -put_np: -if (phy_np) -of_node_put (phy_np); +err_clk:clk_disable_unprepare (data->clk);return ret; }
@@ -244,8 +242,6 @@ static int ci13xxx_imx_remove(struct platform_device *pdev)module_put (data->phy->dev->driver->owner); } -of_node_put (data->phy_np); -clk_disable_unprepare (data->clk);platform_set_drvdata (pdev,NULL );
Signature · 1 line
1.7.10.4
cover chipidea-for-v3.10-v1: USB chipidea: make use of DT helpers in chipidea driver improve driver
In reply to Marc Kleine-BuddeQuoted 38 lines · Marc Kleine-Budde
Hello,
this series depends on the series "[PATCH 0/3] otg-for-v3.10-v1: separate phy code and add DT helper" (a.k.a. tags/otg-for-v3.10-v1) posted earlier and is intended for v3.10. The chipidea driver is converted to make use of the DT helper functions.
regards,
MarcThe following changes since commit
8a4c9f8489b2fce9e7bf0eb43fdb160ab51adc2c:USB mxs-phy: Register phy with framework (2013-02-27 13:48:21 +0100)
are available in the git repository at:
git://git.pengutronix.de/git/mkl/linux.gittags/chipidea-for-v3.10-v1for you to fetch changes up to
5d837224ea36da50f3e744a65fb23af1fa0a480d:USB chipidea i.MX: use
devm_usb_get_phy_by_phandleto get phy (2013-02-27 13:49:07 +0100)----------------------------------------------------------------
USB chipidea: make use of DT helpers in chipidea driverMake use of DT helper functions for handling the
dr_modeandphy_typeproperty.----------------------------------------------------------------
Michael Grzeschik (2):
USB chipidea: ci13xxx-imx: create dynamic platformdata USB chipidea: add PTW and PTS handlingSascha Hauer (3):
USB chipidea: introduce dual role mode pdata flags USB chipidea i.MX: introducedr_modeproperty
USB chipidea i.MX: usedevm_usb_get_phy_by_phandleto get phy
Quoted 10 lines
.../devicetree/bindings/usb/ci13xxx-imx.txt | 6 ++ drivers/usb/chipidea/bits.h | 14 +++- drivers/usb/chipidea/ci13xxx_imx.c | 67 +++++++++++--------- drivers/usb/chipidea/core.c | 61 ++++++++++++++++-- include/linux/usb/chipidea.h | 3 +- 5 files changed, 112 insertions(+), 39 deletions(-)
Hi,
with this series plus
otg-for-v3.9-v1: USB otg: fix usage of try_module_get() and module_put() otg-for-v3.10-v1: separate phy code and add DT helper
v9: Add tested id switch and vbus connect detect support for Chipidea
and
arch/arm/boot/dts/imx28.dtsi +4 -2
@@ -907,7 +907,8 @@ compatible = "fsl,imx28-usb", "fsl,imx27-usb"; reg = <0x80080000 0x10000>; interrupts = <93>; - clocks = <&clks 60>; + clocks = <&clks 60>, <&clks 60>, <&clks 60>; + clock-names = "ipg", "ahb", "per"; fsl,usbphy = <&usbphy0>; status = "disabled"; };
@@ -916,7 +917,8 @@ compatible = "fsl,imx28-usb", "fsl,imx27-usb"; reg = <0x80090000 0x10000>; interrupts = <92>; - clocks = <&clks 61>; + clocks = <&clks 61>, <&clks 61>, <&clks 61>; + clock-names = "ipg", "ahb", "per"; fsl,usbphy = <&usbphy1>; status = "disabled"; };
I have USB otg+host working on v3.8 on an i.MX28.
So,
Regards,
Steffen
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |