All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] Patches to add dr_mode for dwc2
@ 2014-08-06  1:01 ` Kever Yang
  0 siblings, 0 replies; 10+ messages in thread
From: Kever Yang @ 2014-08-06  1:01 UTC (permalink / raw)
  To: Paul Zimmerman
  Cc: dianders, Heiko Stuebner, addy.ke, cf, xjq, olof, sonnyrao, wulf,
	lyz, jg1.han, hj, huangtao, Kever Yang, devicetree, Matt Porter,
	Paul Zimmerman, linux-usb, Kumar Gala, Stephen Warren,
	linux-kernel, Ian Campbell, Kishon Vijay Abraham I, Rob Herring,
	Pawel Moll, Greg Kroah-Hartman, Mark Rutland

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 v4:
- From Doug's suggestion:
 -- remove dr_mode init from Kconfig code
 -- change the commit meesage

Changes in v3:
- fix the odd spacing in dwc2_hsotg struct
- From Jingoo's suggestion:
    change the commit message
- add dr_mode init from Kconfig

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 'mode' which based on Kconfig select or dts setting

 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(+)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v4 0/2] Patches to add dr_mode for dwc2
@ 2014-08-06  1:01 ` Kever Yang
  0 siblings, 0 replies; 10+ messages in thread
From: Kever Yang @ 2014-08-06  1:01 UTC (permalink / raw)
  To: Paul Zimmerman
  Cc: dianders-F7+t8E8rja9g9hUCZPvPmw, Heiko Stuebner,
	addy.ke-TNX95d0MmH7DzftRWevZcw, cf-TNX95d0MmH7DzftRWevZcw,
	xjq-TNX95d0MmH7DzftRWevZcw, olof-nZhT3qVonbNeoWH0uzbU5w,
	sonnyrao-F7+t8E8rja9g9hUCZPvPmw, wulf-TNX95d0MmH7DzftRWevZcw,
	lyz-TNX95d0MmH7DzftRWevZcw, jg1.han-Sze3O3UU22JBDgjK7y7TUQ,
	hj-TNX95d0MmH7DzftRWevZcw, huangtao-TNX95d0MmH7DzftRWevZcw,
	Kever Yang, devicetree-u79uwXL29TY76Z2rM5mHXA, Matt Porter,
	Paul Zimmerman, linux-usb-u79uwXL29TY76Z2rM5mHXA, Kumar Gala,
	Stephen Warren, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	Ian Campbell, Kishon Vijay Abraham I, Rob Herring, Pawel Moll,
	Greg Kroah-Hartman, Mark Rutland

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 v4:
- From Doug's suggestion:
 -- remove dr_mode init from Kconfig code
 -- change the commit meesage

Changes in v3:
- fix the odd spacing in dwc2_hsotg struct
- From Jingoo's suggestion:
    change the commit message
- add dr_mode init from Kconfig

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 'mode' which based on Kconfig select or dts setting

 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(+)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v4 1/2] Documentation: dt-bindings: add dt binding info for dwc2 dr_mode
  2014-08-06  1:01 ` Kever Yang
  (?)
@ 2014-08-06  1:01 ` Kever Yang
  -1 siblings, 0 replies; 10+ messages in thread
From: Kever Yang @ 2014-08-06  1:01 UTC (permalink / raw)
  To: Paul Zimmerman
  Cc: dianders, Heiko Stuebner, addy.ke, cf, xjq, olof, sonnyrao, wulf,
	lyz, jg1.han, hj, huangtao, Kever Yang, Rob Herring, Pawel Moll,
	Mark Rutland, Ian Campbell, Kumar Gala, Greg Kroah-Hartman,
	Matt Porter, Stephen Warren, Kishon Vijay Abraham I,
	Paul Zimmerman, devicetree, linux-kernel

Indicate that the generic dr_mode binding should be used for dwc2.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Doug Anderson <dianders@chromium.org>
---

Changes in v4: None
Changes in v3: None
Changes in v2:
- Split out dr_mode and rk3288 bindings.

 Documentation/devicetree/bindings/usb/dwc2.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt
index 467ddd1..3cf92b6 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.txt
+++ b/Documentation/devicetree/bindings/usb/dwc2.txt
@@ -15,6 +15,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:
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting
  2014-08-06  1:01 ` Kever Yang
  (?)
  (?)
@ 2014-08-06  1:01 ` Kever Yang
  2014-08-06 22:24   ` Doug Anderson
                     ` (2 more replies)
  -1 siblings, 3 replies; 10+ messages in thread
From: Kever Yang @ 2014-08-06  1:01 UTC (permalink / raw)
  To: Paul Zimmerman
  Cc: dianders, Heiko Stuebner, addy.ke, cf, xjq, olof, sonnyrao, wulf,
	lyz, jg1.han, hj, huangtao, Kever Yang, Greg Kroah-Hartman,
	linux-usb, linux-kernel

According to the "dr_mode", the otg controller can work as
device role and host role. Some boards always want to use host mode
and some other boards want to use gadget mode. We use the dts setting
to set dwc2's mode, rather than fixing it to whatever hardware says.

Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Acked-by: Paul Zimmerman <paulz@synopsys.com>
---

Changes in v4:
- From Doug's suggestion:
 -- remove dr_mode init from Kconfig code
 -- change the commit meesage

Changes in v3:
- fix the odd spacing in dwc2_hsotg struct
- From Jingoo's suggestion:
    change the commit message
- add dr_mode init from Kconfig

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(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 27d2c9b..738bec2 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -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!
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 1efd10c..52a4fd2 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -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;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index a10e7a3..5f0c4bb 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -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"
 
@@ -171,6 +173,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.9.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting
  2014-08-06  1:01 ` [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting Kever Yang
@ 2014-08-06 22:24   ` Doug Anderson
  2014-08-06 22:48     ` Dinh Nguyen
  2014-08-06 22:57     ` Paul Zimmerman
  2014-08-07  3:34   ` Doug Anderson
  2014-08-19 18:56   ` Doug Anderson
  2 siblings, 2 replies; 10+ messages in thread
From: Doug Anderson @ 2014-08-06 22:24 UTC (permalink / raw)
  To: Kever Yang
  Cc: Paul Zimmerman, Heiko Stuebner, Addy Ke, Eddie Cai, Jianqun Xu,
	Olof Johansson, Sonny Rao, wulf, lyz, Jingoo Han, han jiang,
	Tao Huang, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Dinh Nguyen

Kever,

On Tue, Aug 5, 2014 at 6:01 PM, Kever Yang <kever.yang@rock-chips.com> wrote:
> According to the "dr_mode", the otg controller can work as
> device role and host role. Some boards always want to use host mode
> and some other boards want to use gadget mode. We use the dts setting
> to set dwc2's mode, rather than fixing it to whatever hardware says.
>
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> Acked-by: Paul Zimmerman <paulz@synopsys.com>
> ---
>
> Changes in v4:
> - From Doug's suggestion:
>  -- remove dr_mode init from Kconfig code
>  -- change the commit meesage
>
> Changes in v3:
> - fix the odd spacing in dwc2_hsotg struct
> - From Jingoo's suggestion:
>     change the commit message
> - add dr_mode init from Kconfig
>
> 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(+)

I think this patch still makes sense even though we don't have a
combined driver yet.  Perhaps Paul or Dihn can confirm.

We could potentially do something based on KConfig (like you did in
patch set #3), but it wouldn't really make sense to do that until
after Dihn's work lands.


> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
> index 27d2c9b..738bec2 100644
> --- a/drivers/usb/dwc2/core.c
> +++ b/drivers/usb/dwc2/core.c
> @@ -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);

I think the third case here won't be too useful until the combined
driver, but it shouldn't hurt, right?


-Doug

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting
  2014-08-06 22:24   ` Doug Anderson
@ 2014-08-06 22:48     ` Dinh Nguyen
  2014-08-06 22:57     ` Paul Zimmerman
  1 sibling, 0 replies; 10+ messages in thread
From: Dinh Nguyen @ 2014-08-06 22:48 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Kever Yang, Paul Zimmerman, Heiko Stuebner, Addy Ke, Eddie Cai,
	Jianqun Xu, Olof Johansson, Sonny Rao, wulf, lyz, Jingoo Han,
	han jiang, Tao Huang, Greg Kroah-Hartman, linux-usb,
	linux-kernel, Dinh Nguyen

On Wed, Aug 6, 2014 at 5:24 PM, Doug Anderson <dianders@chromium.org> wrote:
> Kever,
>
> On Tue, Aug 5, 2014 at 6:01 PM, Kever Yang <kever.yang@rock-chips.com> wrote:
>> According to the "dr_mode", the otg controller can work as
>> device role and host role. Some boards always want to use host mode
>> and some other boards want to use gadget mode. We use the dts setting
>> to set dwc2's mode, rather than fixing it to whatever hardware says.
>>
>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>> Acked-by: Paul Zimmerman <paulz@synopsys.com>
>> ---
>>
>> Changes in v4:
>> - From Doug's suggestion:
>>  -- remove dr_mode init from Kconfig code
>>  -- change the commit meesage
>>
>> Changes in v3:
>> - fix the odd spacing in dwc2_hsotg struct
>> - From Jingoo's suggestion:
>>     change the commit message
>> - add dr_mode init from Kconfig
>>
>> 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(+)
>
> I think this patch still makes sense even though we don't have a
> combined driver yet.  Perhaps Paul or Dihn can confirm.
>

I think this looks fine to me. I will rebase my v3 on top of this patch.

Dinh

> We could potentially do something based on KConfig (like you did in
> patch set #3), but it wouldn't really make sense to do that until
> after Dihn's work lands.
>
>
>> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
>> index 27d2c9b..738bec2 100644
>> --- a/drivers/usb/dwc2/core.c
>> +++ b/drivers/usb/dwc2/core.c
>> @@ -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);
>
> I think the third case here won't be too useful until the combined
> driver, but it shouldn't hurt, right?
>
>
> -Doug
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting
  2014-08-06 22:24   ` Doug Anderson
  2014-08-06 22:48     ` Dinh Nguyen
@ 2014-08-06 22:57     ` Paul Zimmerman
  2014-08-07  3:14       ` Dinh Nguyen
  1 sibling, 1 reply; 10+ messages in thread
From: Paul Zimmerman @ 2014-08-06 22:57 UTC (permalink / raw)
  To: Doug Anderson, Kever Yang
  Cc: Heiko Stuebner, Addy Ke, Eddie Cai, Jianqun Xu, Olof Johansson,
	Sonny Rao, wulf, lyz, Jingoo Han, han jiang, Tao Huang,
	Greg Kroah-Hartman, linux-usb, linux-kernel, Dinh Nguyen

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3504 bytes --]

> From: dianders@google.com [mailto:dianders@google.com] On Behalf Of Doug Anderson
> Sent: Wednesday, August 06, 2014 3:25 PM
> 
> On Tue, Aug 5, 2014 at 6:01 PM, Kever Yang <kever.yang@rock-chips.com> wrote:
> > According to the "dr_mode", the otg controller can work as
> > device role and host role. Some boards always want to use host mode
> > and some other boards want to use gadget mode. We use the dts setting
> > to set dwc2's mode, rather than fixing it to whatever hardware says.
> >
> > Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> > Acked-by: Paul Zimmerman <paulz@synopsys.com>
> > ---
> >
> > Changes in v4:
> > - From Doug's suggestion:
> >  -- remove dr_mode init from Kconfig code
> >  -- change the commit meesage
> >
> > Changes in v3:
> > - fix the odd spacing in dwc2_hsotg struct
> > - From Jingoo's suggestion:
> >     change the commit message
> > - add dr_mode init from Kconfig
> >
> > 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(+)
> 
> I think this patch still makes sense even though we don't have a
> combined driver yet.  Perhaps Paul or Dihn can confirm.

Yes, it should be fine.

> We could potentially do something based on KConfig (like you did in
> patch set #3), but it wouldn't really make sense to do that until
> after Dihn's work lands.
> 
> 
> > diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
> > index 27d2c9b..738bec2 100644
> > --- a/drivers/usb/dwc2/core.c
> > +++ b/drivers/usb/dwc2/core.c
> > @@ -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);
> 
> I think the third case here won't be too useful until the combined
> driver, but it shouldn't hurt, right?

Right. For the existing drivers, it shouldn't change anything, since
nothing currently sets dr_mode. And with Kever's other patches, it
forces host mode on the Rockchip platform, which is all that is required
for now, if I understand correctly.

-- 
Paul

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting
  2014-08-06 22:57     ` Paul Zimmerman
@ 2014-08-07  3:14       ` Dinh Nguyen
  0 siblings, 0 replies; 10+ messages in thread
From: Dinh Nguyen @ 2014-08-07  3:14 UTC (permalink / raw)
  To: Paul Zimmerman, Doug Anderson, Kever Yang
  Cc: Heiko Stuebner, Addy Ke, Eddie Cai, Jianqun Xu, Olof Johansson,
	Sonny Rao, wulf, lyz, Jingoo Han, han jiang, Tao Huang,
	Greg Kroah-Hartman, linux-usb, linux-kernel, Dinh Nguyen


On 8/6/14, 5:57 PM, Paul Zimmerman wrote:
>> From: dianders@google.com [mailto:dianders@google.com] On Behalf Of Doug Anderson
>> Sent: Wednesday, August 06, 2014 3:25 PM
>>
>> On Tue, Aug 5, 2014 at 6:01 PM, Kever Yang <kever.yang@rock-chips.com> wrote:
>>> According to the "dr_mode", the otg controller can work as
>>> device role and host role. Some boards always want to use host mode
>>> and some other boards want to use gadget mode. We use the dts setting
>>> to set dwc2's mode, rather than fixing it to whatever hardware says.
>>>
>>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>>> Acked-by: Paul Zimmerman <paulz@synopsys.com>
>>> ---
>>>
>>> Changes in v4:
>>> - From Doug's suggestion:
>>>  -- remove dr_mode init from Kconfig code
>>>  -- change the commit meesage
>>>
>>> Changes in v3:
>>> - fix the odd spacing in dwc2_hsotg struct
>>> - From Jingoo's suggestion:
>>>     change the commit message
>>> - add dr_mode init from Kconfig
>>>
>>> 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(+)
>> I think this patch still makes sense even though we don't have a
>> combined driver yet.  Perhaps Paul or Dihn can confirm.
> Yes, it should be fine.
>
>> We could potentially do something based on KConfig (like you did in
>> patch set #3), but it wouldn't really make sense to do that until
>> after Dihn's work lands.
>>
>>
>>> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
>>> index 27d2c9b..738bec2 100644
>>> --- a/drivers/usb/dwc2/core.c
>>> +++ b/drivers/usb/dwc2/core.c
>>> @@ -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);
>> I think the third case here won't be too useful until the combined
>> driver, but it shouldn't hurt, right?
> Right. For the existing drivers, it shouldn't change anything, since
> nothing currently sets dr_mode. And with Kever's other patches, it
> forces host mode on the Rockchip platform, which is all that is required
> for now, if I understand correctly.
>
I managed to test this patch on the SOCFPGA platform. So

Tested-by: Dinh Nguyen <dinguyen@opensource.altera.com>

Thanks,
DInh


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting
  2014-08-06  1:01 ` [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting Kever Yang
  2014-08-06 22:24   ` Doug Anderson
@ 2014-08-07  3:34   ` Doug Anderson
  2014-08-19 18:56   ` Doug Anderson
  2 siblings, 0 replies; 10+ messages in thread
From: Doug Anderson @ 2014-08-07  3:34 UTC (permalink / raw)
  To: Kever Yang
  Cc: Paul Zimmerman, Heiko Stuebner, Addy Ke, Eddie Cai, Jianqun Xu,
	Olof Johansson, Sonny Rao, wulf, lyz, Jingoo Han, han jiang,
	Tao Huang, Greg Kroah-Hartman, linux-usb, linux-kernel

Kever,

On Tue, Aug 5, 2014 at 6:01 PM, Kever Yang <kever.yang@rock-chips.com> wrote:
> According to the "dr_mode", the otg controller can work as
> device role and host role. Some boards always want to use host mode
> and some other boards want to use gadget mode. We use the dts setting
> to set dwc2's mode, rather than fixing it to whatever hardware says.
>
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> Acked-by: Paul Zimmerman <paulz@synopsys.com>
> ---
>
> Changes in v4:
> - From Doug's suggestion:
>  -- remove dr_mode init from Kconfig code
>  -- change the commit meesage
>
> Changes in v3:
> - fix the odd spacing in dwc2_hsotg struct
> - From Jingoo's suggestion:
>     change the commit message
> - add dr_mode init from Kconfig
>
> 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(+)

I don't know the driver well enough to feel like I can add my
Reviewed-by tag, but since you've already got an Ack from Paul it
doesn't matter much.  ...FWIW I'm happy with the current state of the
code now.  :)

-Doug

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting
  2014-08-06  1:01 ` [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting Kever Yang
  2014-08-06 22:24   ` Doug Anderson
  2014-08-07  3:34   ` Doug Anderson
@ 2014-08-19 18:56   ` Doug Anderson
  2 siblings, 0 replies; 10+ messages in thread
From: Doug Anderson @ 2014-08-19 18:56 UTC (permalink / raw)
  To: Kever Yang, Greg Kroah-Hartman
  Cc: Paul Zimmerman, Heiko Stuebner, Addy Ke, Eddie Cai, Jianqun Xu,
	Olof Johansson, Sonny Rao, wulf, lyz, Jingoo Han, han jiang,
	Tao Huang, linux-usb, linux-kernel

Kever,

On Tue, Aug 5, 2014 at 6:01 PM, Kever Yang <kever.yang@rock-chips.com> wrote:
> According to the "dr_mode", the otg controller can work as
> device role and host role. Some boards always want to use host mode
> and some other boards want to use gadget mode. We use the dts setting
> to set dwc2's mode, rather than fixing it to whatever hardware says.
>
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> Acked-by: Paul Zimmerman <paulz@synopsys.com>
> ---
>
> Changes in v4:
> - From Doug's suggestion:
>  -- remove dr_mode init from Kconfig code
>  -- change the commit meesage
>
> Changes in v3:
> - fix the odd spacing in dwc2_hsotg struct
> - From Jingoo's suggestion:
>     change the commit message
> - add dr_mode init from Kconfig
>
> 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(+)

In case it's useful, I've actually tested myself that this is
necessary and sufficient to get the OTG port to behave properly as a
host port on an rk3288 board.

Tested-by: Doug Anderson <dianders@chromium.org>


Greg: now that the merge window has closed, are you interested in
landing Kever's changes (with Paul's Ack).  There's this series and
another adding rk3288 support.  If you'd like Kever to repost with
Acks or want pointers to patches, please yell!  ;)

-Doug

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-08-19 18:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-06  1:01 [PATCH v4 0/2] Patches to add dr_mode for dwc2 Kever Yang
2014-08-06  1:01 ` Kever Yang
2014-08-06  1:01 ` [PATCH v4 1/2] Documentation: dt-bindings: add dt binding info for dwc2 dr_mode Kever Yang
2014-08-06  1:01 ` [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting Kever Yang
2014-08-06 22:24   ` Doug Anderson
2014-08-06 22:48     ` Dinh Nguyen
2014-08-06 22:57     ` Paul Zimmerman
2014-08-07  3:14       ` Dinh Nguyen
2014-08-07  3:34   ` Doug Anderson
2014-08-19 18:56   ` Doug Anderson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.