From: Dinh Nguyen <dinh.linux@gmail.com>
To: Paul Zimmerman <Paul.Zimmerman@synopsys.com>,
Doug Anderson <dianders@chromium.org>,
Kever Yang <kever.yang@rock-chips.com>
Cc: Heiko Stuebner <heiko@sntech.de>,
Addy Ke <addy.ke@rock-chips.com>, Eddie Cai <cf@rock-chips.com>,
Jianqun Xu <xjq@rock-chips.com>, Olof Johansson <olof@lixom.net>,
Sonny Rao <sonnyrao@chromium.org>, wulf <wulf@rock-chips.com>,
lyz <lyz@rock-chips.com>, Jingoo Han <jg1.han@samsung.com>,
han jiang <hj@rock-chips.com>,
Tao Huang <huangtao@rock-chips.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Dinh Nguyen <dinguyen@altera.com>
Subject: Re: [PATCH v4 2/2] usb: dwc2: add 'mode' which based on Kconfig select or dts setting
Date: Wed, 06 Aug 2014 22:14:21 -0500 [thread overview]
Message-ID: <53E2EF0D.8090302@gmail.com> (raw)
In-Reply-To: <A2CA0424C0A6F04399FB9E1CD98E0304844C4A45@US01WEMBX2.internal.synopsys.com>
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
next prev parent reply other threads:[~2014-08-07 3:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-06 1:01 [PATCH v4 0/2] Patches to add dr_mode for dwc2 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 [this message]
2014-08-07 3:34 ` Doug Anderson
2014-08-19 18:56 ` Doug Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53E2EF0D.8090302@gmail.com \
--to=dinh.linux@gmail.com \
--cc=Paul.Zimmerman@synopsys.com \
--cc=addy.ke@rock-chips.com \
--cc=cf@rock-chips.com \
--cc=dianders@chromium.org \
--cc=dinguyen@altera.com \
--cc=gregkh@linuxfoundation.org \
--cc=heiko@sntech.de \
--cc=hj@rock-chips.com \
--cc=huangtao@rock-chips.com \
--cc=jg1.han@samsung.com \
--cc=kever.yang@rock-chips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lyz@rock-chips.com \
--cc=olof@lixom.net \
--cc=sonnyrao@chromium.org \
--cc=wulf@rock-chips.com \
--cc=xjq@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox