Patches to add dr_mode for dwc2
Subsystems (3)
v2 cover Patches to add dr_mode for dwc2
These two patches enable the dr_mode for the dwc2 usb controller. These are split from the patch series adding rk3288 dwc2 support.
Changes in v2:
- Split out dr_mode and rk3288 bindings.
- put spaces around '+' operator
- expand the comment for dr_mode
- handle dr_mode is USB_DR_MODE_OTG
Kever Yang (2):
Documentation: dt-bindings: add dt binding info for dwc2 dr_mode
usb: dwc2: add dr_mode support for dwc2
Documentation/devicetree/bindings/usb/dwc2.txt | 2 ++ drivers/usb/dwc2/core.c | 18 ++++++++++++++++++ drivers/usb/dwc2/core.h | 5 +++++ drivers/usb/dwc2/platform.c | 4 ++++ 4 files changed, 29 insertions(+)
Signature · 1 line
1.7.9.5
PATCH v2 1/2 Documentation: dt-bindings: add dt binding info for dwc2 dr_mode
Indicate that the generic dr_mode binding should be used for dwc2.
---
Changes in v2:
- Split out dr_mode and rk3288 bindings.
Documentation/devicetree/bindings/usb/dwc2.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/usb/dwc2.txt +2 -0
@@ -18,6 +18,8 @@ Optional properties: - phys: phy provider specifier - phy-names: shall be "usb2-phy" Refer to phy/phy-bindings.txt for generic phy consumer properties +- dr_mode: shall be one of "host", "peripheral" and "otg" + Refer to usb/generic.txt Example:
Signature · 1 line
1.7.9.5
Re: [PATCH v2 1/2] Documentation: dt-bindings: add dt binding info for dwc2 dr_mode
Kever,
Quoted 10 lines · Kever Yang
Indicate that the generic
dr_modebinding should be used for dwc2.Signed-off-by Kever Yang <[email protected]>---
Changes in v2:
- Split outdr_modeand rk3288 bindings.Documentation/devicetree/bindings/usb/dwc2.txt | 2 ++ 1 file changed, 2 insertions(+)
PATCH v2 2/2 usb: dwc2: add dr_mode support for dwc2
In reply to Kever YangSome devices with A female host port and without use of usb_id pin will need this for the otg controller works as device role during firmware period and works as host role in rich os.
---
Changes in v2:
- put spaces around '+' operator
- expand the comment for dr_mode
- handle dr_mode is USB_DR_MODE_OTG
drivers/usb/dwc2/core.c | 18 ++++++++++++++++++ drivers/usb/dwc2/core.h | 5 +++++ drivers/usb/dwc2/platform.c | 4 ++++ 3 files changed, 27 insertions(+)
drivers/usb/dwc2/core.c +18 -0
@@ -118,6 +118,7 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg) {u32 greset;int count =0 ; +u32 gusbcfg;dev_vdbg (hsotg->dev,"%s()\n" , __func__);
@@ -148,6 +149,23 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg) } }while (greset &GRSTCTL_CSFTRST ); +if (hsotg->dr_mode ==USB_DR_MODE_HOST ) { + gusbcfg =readl (hsotg->regs +GUSBCFG ); + gusbcfg &= ~GUSBCFG_FORCEDEVMODE ; + gusbcfg |=GUSBCFG_FORCEHOSTMODE ; +writel (gusbcfg, hsotg->regs +GUSBCFG ); + }else if (hsotg->dr_mode ==USB_DR_MODE_PERIPHERAL ) { + gusbcfg =readl (hsotg->regs +GUSBCFG ); + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE ; + gusbcfg |=GUSBCFG_FORCEDEVMODE ; +writel (gusbcfg, hsotg->regs +GUSBCFG ); + }else if (hsotg->dr_mode ==USB_DR_MODE_OTG ) { + gusbcfg =readl (hsotg->regs +GUSBCFG ); + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE ; + gusbcfg &= ~GUSBCFG_FORCEDEVMODE ; +writel (gusbcfg, hsotg->regs +GUSBCFG ); + } +/* * NOTE: This long sleep is _very_ important, otherwise the core will * not stay in host mode after a connector ID change!
drivers/usb/dwc2/core.h +5 -0
@@ -501,6 +501,10 @@ struct dwc2_hw_params {* a_peripheral and b_device=>b_host) this may not match * the core, but allows the software to determine * transitions +* @dr_mode: Requested mode of operation, one of following: +* - USB_DR_MODE_PERIPHERAL +* - USB_DR_MODE_HOST +* - USB_DR_MODE_OTG * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth * transfer are in process of being queued * @srp_success: Stores status of SRP request in the case of a FS PHY
@@ -592,6 +596,7 @@ struct dwc2_hsotg {/** Params to actually use */ struct dwc2_core_params *core_params;enum usb_otg_state op_state; +enum usb_dr_mode dr_mode; unsigned int queuing_high_bandwidth:1; unsigned int srp_success:1;
drivers/usb/dwc2/platform.c +4 -0
@@ -42,6 +42,8 @@#include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/usb/of.h> +#include "core.h" #include "hcd.h"
@@ -200,6 +202,8 @@ static int dwc2_driver_probe(struct platform_device *dev)dev_dbg (&dev->dev,"mapped PA %08lx to VA %p\n" , (unsigned long )res->start, hsotg->regs); + hsotg->dr_mode =of_usb_get_dr_mode (dev->dev.of_node); + retval =dwc2_hcd_init (hsotg, irq, params);if (retval)return retval;
Signature · 1 line
1.7.9.5
Re: [PATCH v2 2/2] usb: dwc2: add dr_mode support for dwc2
Quoted 4 lines · Kever Yang
Some devices with A female host port and without use of
usb_idpin will need this for the otg controller works as device role during firmware period and works as host role in rich os.
Hi Kever Yang,
This commit message looks too specific. Please make it more general, as the commit "usb: dwc3: set 'mode' based on selected Kconfig choices".
Then, maybe, you can add this specific case. "According to the "dr_mode", the otg controller can work as device role during firmware period, and work as host role in the kernel, without use of usb_id pin."
Best regards,
Jingoo Han
Quoted 98 lines
Signed-off-by Kever Yang <[email protected]>---
Changes in v2:
- put spaces around '+' operator
- expand the comment fordr_mode
- handledr_modeisUSB_DR_MODE_OTGdrivers/usb/dwc2/core.c | 18 ++++++++++++++++++ drivers/usb/dwc2/core.h | 5 +++++ drivers/usb/dwc2/platform.c | 4 ++++ 3 files changed, 27 insertions(+)drivers/usb/dwc2/core.c +18
-0@@ -118,6 +118,7 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg) {u32 greset;int count =0 ; +u32 gusbcfg;dev_vdbg (hsotg->dev,"%s()\n" , __func__);@@ -148,6 +149,23 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg) } }while (greset &GRSTCTL_CSFTRST ); +if (hsotg->dr_mode ==USB_DR_MODE_HOST ) { + gusbcfg =readl (hsotg->regs +GUSBCFG ); + gusbcfg &= ~GUSBCFG_FORCEDEVMODE ; + gusbcfg |=GUSBCFG_FORCEHOSTMODE ; +writel (gusbcfg, hsotg->regs +GUSBCFG ); + }else if (hsotg->dr_mode ==USB_DR_MODE_PERIPHERAL ) { + gusbcfg =readl (hsotg->regs +GUSBCFG ); + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE ; + gusbcfg |=GUSBCFG_FORCEDEVMODE ; +writel (gusbcfg, hsotg->regs +GUSBCFG ); + }else if (hsotg->dr_mode ==USB_DR_MODE_OTG ) { + gusbcfg =readl (hsotg->regs +GUSBCFG ); + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE ; + gusbcfg &= ~GUSBCFG_FORCEDEVMODE ; +writel (gusbcfg, hsotg->regs +GUSBCFG ); + } +/* * NOTE: This long sleep is _very_ important, otherwise the core will * not stay in host mode after a connector ID change! drivers/usb/dwc2/core.h +5
-0@@ -501,6 +501,10 @@ struct dwc2_hw_params {* a_peripheral and b_device=>b_host) this may not match * the core, but allows the software to determine * transitions +* @dr_mode: Requested mode of operation, one of following: +* - USB_DR_MODE_PERIPHERAL +* - USB_DR_MODE_HOST +* - USB_DR_MODE_OTG * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth * transfer are in process of being queued * @srp_success: Stores status of SRP request in the case of a FS PHY @@ -592,6 +596,7 @@ struct dwc2_hsotg {/** Params to actually use */ struct dwc2_core_params *core_params;enum usb_otg_state op_state; +enum usb_dr_mode dr_mode; unsigned int queuing_high_bandwidth:1; unsigned int srp_success:1;drivers/usb/dwc2/platform.c +4
-1@@ -42,6 +42,8 @@#include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/usb/of.h> +#include "core.h" #include "hcd.h" @@ -200,6 +202,8 @@ static int dwc2_driver_probe(struct platform_device *dev)dev_dbg (&dev->dev,"mapped PA %08lx to VA %p\n" , (unsigned long )res->start, hsotg->regs); + hsotg->dr_mode =of_usb_get_dr_mode (dev->dev.of_node); + retval =dwc2_hcd_init (hsotg, irq, params);if (retval)return retval; --1.7.9.5
RE: [PATCH v2 2/2] usb: dwc2: add dr_mode support for dwc2
In reply to Kever YangQuoted 73 lines
From: Kever Yang [mailto:[email protected]]
Sent: Wednesday, July 30, 2014 6:06 PMSome devices with A female host port and without use of
usb_idpin will need this for the otg controller works as device role during firmware period and works as host role in rich os.Signed-off-by Kever Yang <[email protected]>---
Changes in v2:
- put spaces around '+' operator
- expand the comment fordr_mode
- handledr_modeisUSB_DR_MODE_OTGdrivers/usb/dwc2/core.c | 18 ++++++++++++++++++ drivers/usb/dwc2/core.h | 5 +++++ drivers/usb/dwc2/platform.c | 4 ++++ 3 files changed, 27 insertions(+)drivers/usb/dwc2/core.c +18
-0@@ -118,6 +118,7 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg) {u32 greset;int count =0 ; +u32 gusbcfg;dev_vdbg (hsotg->dev,"%s()\n" , __func__);@@ -148,6 +149,23 @@ static int dwc2_core_reset(struct dwc2_hsotg *hsotg) } }while (greset &GRSTCTL_CSFTRST ); +if (hsotg->dr_mode ==USB_DR_MODE_HOST ) { + gusbcfg =readl (hsotg->regs +GUSBCFG ); + gusbcfg &= ~GUSBCFG_FORCEDEVMODE ; + gusbcfg |=GUSBCFG_FORCEHOSTMODE ; +writel (gusbcfg, hsotg->regs +GUSBCFG ); + }else if (hsotg->dr_mode ==USB_DR_MODE_PERIPHERAL ) { + gusbcfg =readl (hsotg->regs +GUSBCFG ); + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE ; + gusbcfg |=GUSBCFG_FORCEDEVMODE ; +writel (gusbcfg, hsotg->regs +GUSBCFG ); + }else if (hsotg->dr_mode ==USB_DR_MODE_OTG ) { + gusbcfg =readl (hsotg->regs +GUSBCFG ); + gusbcfg &= ~GUSBCFG_FORCEHOSTMODE ; + gusbcfg &= ~GUSBCFG_FORCEDEVMODE ; +writel (gusbcfg, hsotg->regs +GUSBCFG ); + } +/* * NOTE: This long sleep is _very_ important, otherwise the core will * not stay in host mode after a connector ID change! drivers/usb/dwc2/core.h +4
-0@@ -501,6 +501,10 @@ struct dwc2_hw_params {* a_peripheral and b_device=>b_host) this may not match * the core, but allows the software to determine * transitions +* @dr_mode: Requested mode of operation, one of following: +* - USB_DR_MODE_PERIPHERAL +* - USB_DR_MODE_HOST +* - USB_DR_MODE_OTG * @queuing_high_bandwidth: True if multiple packets of a high-bandwidth * transfer are in process of being queued * @srp_success: Stores status of SRP request in the case of a FS PHY
drivers/usb/dwc2/core.h struct dwc2_hsotg { · line 599
Quoted 4 lines
drivers/usb/dwc2/core.h +1
-0@@ -592,6 +596,7 @@ struct dwc2_hsotg {/** Params to actually use */ struct dwc2_core_params *core_params;enum usb_otg_state op_state; +enum usb_dr_mode dr_mode;
Can you please fix the odd spacing here? Once you do that, you can add my acked-by.
Signature · 1 line
Paul