public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Stanley Chang[昌育德]" <stanley_chang@realtek.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2 1/2] usb: dwc3: add Realtek DHC RTD SoC dwc3 glue layer driver
Date: Wed, 2 Aug 2023 08:26:50 +0000	[thread overview]
Message-ID: <ff9ca6f15936450696bff502c0047708@realtek.com> (raw)
In-Reply-To: <20230802011400.v4jim6ajsqc3tvei@synopsys.com>

Hi Thinh,

> > +struct dwc3_rtk {
> > +     struct device *dev;
> > +     void __iomem *regs;
> > +     size_t regs_size;
> > +
> > +     struct dwc3 *dwc;
> > +
> > +     int cur_dr_mode; /* current dr mode */
> > +     bool support_drd_mode; /* if support Host/device switch */
> 
> I think we may not need this and do away the boolean support_drd_mode.

Yes, the initial flow should be simplified as
@@ -346,12 +342,7 @@ static int dwc3_rtk_probe_dwc3_core(struct dwc3_rtk *rtk)

        rtk->cur_dr_mode = dr_mode;

-       if (device_property_read_bool(dwc3_dev, "usb-role-switch"))
-               rtk->support_drd_mode = true;
-       else
-               rtk->support_drd_mode = false;
-
-       if (rtk->support_drd_mode) {
+       if (device_property_read_bool(dwc3_dev, "usb-role-switch")) {
                dwc3_rtk_setup_role_switch(rtk);
                rtk->cur_dr_mode = dwc3_rtk_get_dr_mode(rtk);
        }

> > +static int dwc3_rtk_set_dr_mode(struct dwc3_rtk *rtk, int dr_mode)
> 
> Why return the mode rather than status if the setting? You're not checking the
> return of this function in the caller anyway.

You are right, this return value is unnecessary.
I will remove it.

> > +{
> > +     if (!rtk->support_drd_mode)
> > +             return rtk->cur_dr_mode;
> > +
> > +     rtk->cur_dr_mode = dr_mode;
> > +
> > +     switch_dwc3_dr_mode(rtk, dr_mode);
> > +     mdelay(10);
> > +     switch_usb2_dr_mode(rtk, dr_mode);
> > +
> > +     return rtk->cur_dr_mode;
> > +}
> > +

> > +static int dwc3_rtk_setup_role_switch(struct dwc3_rtk *rtk)
> 
> Any reason why we're doing the role switch here and not what's implemented
> from the core?
> 
Because we have to set the usb 2.0 phy mode through switch_usb2_dr_mode in the function dwc3_rtk_set_dr_mode.
In fact, switch_dwc3_dr_mode will use the role switching implemented by core.

> > +
> > +module_platform_driver(dwc3_rtk_driver);
> > +
> > +MODULE_AUTHOR("Stanley Chang <stanley_chang@realtek.com>");
> > +MODULE_DESCRIPTION("DesignWare USB3 Realtek Glue Layer");
> > +MODULE_ALIAS("platform:rtk-dwc3");
> > +MODULE_LICENSE("GPL");
> 
> I'm not familiar with licensing much, but can the SPDX header indicates
> different version than the module license?
> 
Thanks Greg for your comment.
Either GPL or GPL v2 are suitable for our source code.

Thanks,
Stanley


  parent reply	other threads:[~2023-08-02  8:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01  9:25 [PATCH v2 1/2] usb: dwc3: add Realtek DHC RTD SoC dwc3 glue layer driver Stanley Chang
2023-08-01  9:25 ` [PATCH v2 2/2] dt-bindings: usb: dwc3: Add Realtek DHC RTD SoC DWC3 USB Stanley Chang
2023-08-02  1:14 ` [PATCH v2 1/2] usb: dwc3: add Realtek DHC RTD SoC dwc3 glue layer driver Thinh Nguyen
2023-08-02  5:27   ` Greg Kroah-Hartman
2023-08-02 23:03     ` Thinh Nguyen
2023-08-02  8:26   ` Stanley Chang[昌育德] [this message]
2023-08-03  0:04     ` Thinh Nguyen
2023-08-03  6:55       ` Stanley Chang[昌育德]
2023-08-03 23:11         ` Thinh Nguyen
2023-08-07  9:07           ` Stanley Chang[昌育德]
2023-08-07 23:56             ` Thinh Nguyen
2023-08-08  2:58               ` Stanley Chang[昌育德]
2023-08-08 23:37                 ` Thinh Nguyen

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=ff9ca6f15936450696bff502c0047708@realtek.com \
    --to=stanley_chang@realtek.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /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