Linux-USB Archive on lore.kernel.org
 help / color / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: Philippe Schenker <philippe.schenker@toradex.com>
Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Stefan Agner <stefan.agner@toradex.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: chipidea: fix ci_irq for role-switching use-case
Date: Tue, 30 Jun 2020 00:43:00 +0000
Message-ID: <20200630004323.GA12443@b29397-desktop> (raw)
In-Reply-To: <88f0a5bf564eded8b210457204facdf2c7a9c5dc.camel@toradex.com>

On 20-06-29 10:04:13, Philippe Schenker wrote:
> On Mon, 2020-06-29 at 07:26 +0000, Peter Chen wrote:
> > On 20-06-26 13:03:11, Philippe Schenker wrote:
> > > If the hardware is in low-power-mode and one plugs in device or host
> > > it did not switch the mode due to the early exit out of the
> > > interrupt.
> > 
> > Do you mean there is no coming call for role-switch? Could you please
> > share
> > your dts changes? Try below patch:
> 
> Here are my DTS changes:
> 
> diff --git a/arch/arm/boot/dts/imx7-colibri-eval-v3.dtsi
> b/arch/arm/boot/dts/imx7-colibri-eval-v3.dtsi
> index 97601375f2640..c424f707a1afa 100644
> --- a/arch/arm/boot/dts/imx7-colibri-eval-v3.dtsi
> +++ b/arch/arm/boot/dts/imx7-colibri-eval-v3.dtsi
> @@ -13,6 +13,13 @@
>                 stdout-path = "serial0:115200n8";
>         };
>  
> +       extcon_usbc_det: usbc_det {
> +               compatible = "linux,extcon-usb-gpio";
> +               id-gpio = <&gpio7 14 GPIO_ACTIVE_HIGH>;
> +               pinctrl-names = "default";
> +               pinctrl-0 = <&pinctrl_usbc_det>;
> +       };
> +
>         /* fixed crystal dedicated to mpc258x */
>         clk16m: clk16m {
>                 compatible = "fixed-clock";
> @@ -174,6 +181,7 @@
>  };
>  
>  &usbotg1 {
> +       extcon = <&extcon_usbc_det>, <&extcon_usbc_det>;

If you have only ID extcon, but no VBUS extcon, you only need to
add only phandle, see dt-binding for detail please.

>         status = "okay";
>  };
>  
> diff --git a/arch/arm/boot/dts/imx7-colibri.dtsi
> b/arch/arm/boot/dts/imx7-colibri.dtsi
> index e18e89dec8792..caea90d2421fd 100644
> --- a/arch/arm/boot/dts/imx7-colibri.dtsi
> +++ b/arch/arm/boot/dts/imx7-colibri.dtsi
> @@ -457,7 +457,7 @@
>  };
>  
>  &usbotg1 {
> -       dr_mode = "host";
> +       dr_mode = "otg";
>  };
>  
>  &usdhc1 {
> @@ -486,7 +486,7 @@
>  &iomuxc {
>         pinctrl-names = "default";
>         pinctrl-0 = <&pinctrl_gpio1 &pinctrl_gpio2 &pinctrl_gpio3
> &pinctrl_gpio4
> -                    &pinctrl_gpio7 &pinctrl_usbc_det>;
> +                    &pinctrl_gpio7>;
>  
>         pinctrl_gpio1: gpio1-grp {
>                 fsl,pins = <
> 
> > 
> > 
> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > index e8ce300ad490..9e10dcfeb98f 100644
> > --- a/drivers/usb/chipidea/core.c
> > +++ b/drivers/usb/chipidea/core.c
> > @@ -1313,6 +1313,29 @@ static void ci_controller_suspend(struct
> > ci_hdrc *ci)
> >  	enable_irq(ci->irq);
> >  }
> >  
> > +/*
> > + * Handle the wakeup interrupt triggered by extcon connector
> > + * We need to call ci_irq again for extcon since the first
> > + * interrupt (wakeup int) only let the controller be out of
> > + * low power mode, but not handle any interrupts.
> > + */
> > +static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
> > +{
> > +	struct ci_hdrc_cable *cable_id, *cable_vbus;
> > +	u32 otgsc = hw_read_otgsc(ci, ~0);
> > +
> > +	cable_id = &ci->platdata->id_extcon;
> > +	cable_vbus = &ci->platdata->vbus_extcon;
> > +
> > +	if (!IS_ERR(cable_id->edev) && ci->is_otg &&
> > +		(otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS))
> > +		ci_irq(ci->irq, ci);
> > +
> > +	if (!IS_ERR(cable_vbus->edev) && ci->is_otg &&
> > +		(otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS))
> > +		ci_irq(ci->irq, ci);
> > +}
> > +
> >  static int ci_controller_resume(struct device *dev)
> >  {
> >  	struct ci_hdrc *ci = dev_get_drvdata(dev);
> > @@ -1343,6 +1366,7 @@ static int ci_controller_resume(struct device
> > *dev)
> >  		enable_irq(ci->irq);
> >  		if (ci_otg_is_fsm_mode(ci))
> >  			ci_otg_fsm_wakeup_by_srp(ci);
> > +		ci_extcon_wakeup_int(ci);
> >  	}
> >  
> >  	return 0;
> 
> Thanks for creating this patch! I wanted also something like that, but
> couldn't find out where to put it. 
> 
> I tried this patch and with the above devicetree changes this works
> perfectly! Thanks Peter!
> 
> Should I send the patch with you as the "Suggested-by" or do you want to
> send the patch so you are the Author? I would have it ready in my git
> repo.

This patch was a part of one patch at downstream, I will submit one and
add your tags.

> > > 
> > > Hi Peter
> > > 
> > > During my investigation I found a bug in ci_irq. I would appreciate
> > > if you could review this. From what I see this patch should be save
> > > to apply.
> > > 
> > > This patch does not solve all of our issues. When I have RUNTIME_PM
> > > enabled on imx6ull or imx7. RNDIS still does not come up. So there
> > > has to be another bug hiding somewhere in the Runtime PM code to
> > > prevent
> > > RNDIS from working properly. I quickly looked through your patches
> > > that added this stuff back in 2015 but couldn't spot anything
> > > related to
> > > usb gadget-mode.
> > > 
> > > If you right away know where the problem could be hiding itself,
> > > I would appreciate a hint.
> > > 
> > 
> > I need information for call trace for further suggestion.

With this patch, does your RNDIS issue be fixed or still not?

Peter
> > 
> > Peter
> > 
> > > ---
> > > 
> > >  drivers/usb/chipidea/core.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/usb/chipidea/core.c
> > > b/drivers/usb/chipidea/core.c
> > > index 9a7c53d09ab4..5159420a23a4 100644
> > > --- a/drivers/usb/chipidea/core.c
> > > +++ b/drivers/usb/chipidea/core.c
> > > @@ -518,7 +518,7 @@ static irqreturn_t ci_irq(int irq, void *data)
> > >  		disable_irq_nosync(irq);
> > >  		ci->wakeup_int = true;
> > >  		pm_runtime_get(ci->dev);
> > > -		return IRQ_HANDLED;
> > > +		ret = IRQ_HANDLED;
> > >  	}
> > >  
> > >  	if (ci->is_otg) {
> > > -- 
> > > 2.27.0
> > > 

-- 

Thanks,
Peter Chen

  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-26 11:03 Philippe Schenker
2020-06-29  7:26 ` Peter Chen
2020-06-29 10:04   ` Philippe Schenker
2020-06-30  0:43     ` Peter Chen [this message]
2020-06-30 11:59       ` Philippe Schenker
2020-07-01  2:52         ` Peter Chen
2020-07-01  8:32           ` Philippe Schenker
2020-07-01  9:02             ` Peter Chen
2020-07-01 10:52               ` Philippe Schenker

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=20200630004323.GA12443@b29397-desktop \
    --to=peter.chen@nxp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=marcel.ziswiler@toradex.com \
    --cc=philippe.schenker@toradex.com \
    --cc=stefan.agner@toradex.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

Linux-USB Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \
		linux-usb@vger.kernel.org
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git