linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bin Liu <b-liu@ti.com>
To: Alexandre Bailon <abailon@baylibre.com>
Cc: <david@lechnology.com>, <balbi@kernel.org>, <kishon@ti.com>,
	<khilman@baylibre.com>, <linux-kernel@vger.kernel.org>,
	<linux-usb@vger.kernel.org>, <nsekhar@ti.com>
Subject: Re: [PATCH v5 3/4] usb: musb: Add a new argument to musb_platform_set_mode()
Date: Mon, 14 Nov 2016 11:36:17 -0600	[thread overview]
Message-ID: <20161114173617.GA4512@uda0271908> (raw)
In-Reply-To: <1478523908-4383-4-git-send-email-abailon@baylibre.com>

Hi,

On Mon, Nov 07, 2016 at 02:05:07PM +0100, Alexandre Bailon wrote:
> During the init, the driver will use musb_platform_set_mode()
> to configure the controller mode and the PHY mode.
> The PHY of DA8xx has some issues when the PHY is forced in host or device,
> so we want to keep it in OTG mode unless the user request a specific mode
> by using the sysfs.
> Add the init argument to musb_platform_set_mode() in order to let the
> callback change its behavior if it is called during the init.

Tony's patch set which fixes musb pm regression (but has not been merged
yet) introduces musb->is_initialized. You might want to use this new
variable in da8xx_musb_set_mode(), instead of adding this init flag.

Regards,
-Bin.

> 
> Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
> ---
>  drivers/usb/musb/am35x.c     |  2 +-
>  drivers/usb/musb/blackfin.c  |  2 +-
>  drivers/usb/musb/da8xx.c     |  2 +-
>  drivers/usb/musb/davinci.c   |  2 +-
>  drivers/usb/musb/musb_core.c | 12 ++++++------
>  drivers/usb/musb/musb_core.h |  6 +++---
>  drivers/usb/musb/musb_dsps.c |  2 +-
>  drivers/usb/musb/sunxi.c     |  2 +-
>  drivers/usb/musb/tusb6010.c  |  2 +-
>  9 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
> index 50ca805..7136888 100644
> --- a/drivers/usb/musb/am35x.c
> +++ b/drivers/usb/musb/am35x.c
> @@ -332,7 +332,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
>  	return ret;
>  }
>  
> -static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode)
> +static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode, bool init)
>  {
>  	struct device *dev = musb->controller;
>  	struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
> diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c
> index 310238c..544e98f 100644
> --- a/drivers/usb/musb/blackfin.c
> +++ b/drivers/usb/musb/blackfin.c
> @@ -356,7 +356,7 @@ static int bfin_musb_vbus_status(struct musb *musb)
>  	return 0;
>  }
>  
> -static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode)
> +static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode, bool init)
>  {
>  	return -EIO;
>  }
> diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
> index 6749aa1..ac0c2f7 100644
> --- a/drivers/usb/musb/da8xx.c
> +++ b/drivers/usb/musb/da8xx.c
> @@ -335,7 +335,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
>  	return ret;
>  }
>  
> -static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode)
> +static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode, bool init)
>  {
>  	struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
>  	enum phy_mode phy_mode;
> diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c
> index cee61a5..d12b902 100644
> --- a/drivers/usb/musb/davinci.c
> +++ b/drivers/usb/musb/davinci.c
> @@ -369,7 +369,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci)
>  	return retval;
>  }
>  
> -static int davinci_musb_set_mode(struct musb *musb, u8 mode)
> +static int davinci_musb_set_mode(struct musb *musb, u8 mode, bool init)
>  {
>  	/* EVM can't do this (right?) */
>  	return -EIO;
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 27dadc0..4a8d394 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -1730,11 +1730,11 @@ musb_mode_store(struct device *dev, struct device_attribute *attr,
>  
>  	spin_lock_irqsave(&musb->lock, flags);
>  	if (sysfs_streq(buf, "host"))
> -		status = musb_platform_set_mode(musb, MUSB_HOST);
> +		status = musb_platform_set_mode(musb, MUSB_HOST, false);
>  	else if (sysfs_streq(buf, "peripheral"))
> -		status = musb_platform_set_mode(musb, MUSB_PERIPHERAL);
> +		status = musb_platform_set_mode(musb, MUSB_PERIPHERAL, false);
>  	else if (sysfs_streq(buf, "otg"))
> -		status = musb_platform_set_mode(musb, MUSB_OTG);
> +		status = musb_platform_set_mode(musb, MUSB_OTG, false);
>  	else
>  		status = -EINVAL;
>  	spin_unlock_irqrestore(&musb->lock, flags);
> @@ -2261,13 +2261,13 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
>  		status = musb_host_setup(musb, plat->power);
>  		if (status < 0)
>  			goto fail3;
> -		status = musb_platform_set_mode(musb, MUSB_HOST);
> +		status = musb_platform_set_mode(musb, MUSB_HOST, true);
>  		break;
>  	case MUSB_PORT_MODE_GADGET:
>  		status = musb_gadget_setup(musb);
>  		if (status < 0)
>  			goto fail3;
> -		status = musb_platform_set_mode(musb, MUSB_PERIPHERAL);
> +		status = musb_platform_set_mode(musb, MUSB_PERIPHERAL, true);
>  		break;
>  	case MUSB_PORT_MODE_DUAL_ROLE:
>  		status = musb_host_setup(musb, plat->power);
> @@ -2278,7 +2278,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
>  			musb_host_cleanup(musb);
>  			goto fail3;
>  		}
> -		status = musb_platform_set_mode(musb, MUSB_OTG);
> +		status = musb_platform_set_mode(musb, MUSB_OTG, true);
>  		break;
>  	default:
>  		dev_err(dev, "unsupported port mode %d\n", musb->port_mode);
> diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
> index 2cb88a49..1bfc8fa 100644
> --- a/drivers/usb/musb/musb_core.h
> +++ b/drivers/usb/musb/musb_core.h
> @@ -203,7 +203,7 @@ struct musb_platform_ops {
>  	struct dma_controller *
>  		(*dma_init) (struct musb *musb, void __iomem *base);
>  	void	(*dma_exit)(struct dma_controller *c);
> -	int	(*set_mode)(struct musb *musb, u8 mode);
> +	int	(*set_mode)(struct musb *musb, u8 mode, bool init);
>  	void	(*try_idle)(struct musb *musb, unsigned long timeout);
>  	int	(*recover)(struct musb *musb);
>  
> @@ -558,12 +558,12 @@ static inline void musb_platform_disable(struct musb *musb)
>  		musb->ops->disable(musb);
>  }
>  
> -static inline int musb_platform_set_mode(struct musb *musb, u8 mode)
> +static inline int musb_platform_set_mode(struct musb *musb, u8 mode, bool init)
>  {
>  	if (!musb->ops->set_mode)
>  		return 0;
>  
> -	return musb->ops->set_mode(musb, mode);
> +	return musb->ops->set_mode(musb, mode, init);
>  }
>  
>  static inline void musb_platform_try_idle(struct musb *musb,
> diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
> index 0f17d21..a889679 100644
> --- a/drivers/usb/musb/musb_dsps.c
> +++ b/drivers/usb/musb/musb_dsps.c
> @@ -462,7 +462,7 @@ static int dsps_musb_exit(struct musb *musb)
>  	return 0;
>  }
>  
> -static int dsps_musb_set_mode(struct musb *musb, u8 mode)
> +static int dsps_musb_set_mode(struct musb *musb, u8 mode, bool init)
>  {
>  	struct device *dev = musb->controller;
>  	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
> diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c
> index 1408245..04bf763 100644
> --- a/drivers/usb/musb/sunxi.c
> +++ b/drivers/usb/musb/sunxi.c
> @@ -346,7 +346,7 @@ static void sunxi_musb_dma_controller_destroy(struct dma_controller *c)
>  {
>  }
>  
> -static int sunxi_musb_set_mode(struct musb *musb, u8 mode)
> +static int sunxi_musb_set_mode(struct musb *musb, u8 mode, bool init)
>  {
>  	struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent);
>  	enum phy_mode new_mode;
> diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
> index df7c9f4..8a74587 100644
> --- a/drivers/usb/musb/tusb6010.c
> +++ b/drivers/usb/musb/tusb6010.c
> @@ -628,7 +628,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on)
>   * Note that if a mini-A cable is plugged in the ID line will stay down as
>   * the weak ID pull-up is not able to pull the ID up.
>   */
> -static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode)
> +static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode, bool init)
>  {
>  	void __iomem	*tbase = musb->ctrl_base;
>  	u32		otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf;
> -- 
> 2.7.3
> 

  reply	other threads:[~2016-11-14 17:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-07 13:05 [PATCH v5 0/4] usb: musb: da8xx: Fix few issues Alexandre Bailon
2016-11-07 13:05 ` [PATCH v5 1/4] usb: musb: da8xx: Call earlier clk_prepare_enable() Alexandre Bailon
2016-11-07 13:05 ` [PATCH v5 2/4] phy: da8xx-usb: Configure CFGCHIP2 to support OTG workaround Alexandre Bailon
2016-11-15 13:12   ` Kishon Vijay Abraham I
2016-11-07 13:05 ` [PATCH v5 3/4] usb: musb: Add a new argument to musb_platform_set_mode() Alexandre Bailon
2016-11-14 17:36   ` Bin Liu [this message]
2016-11-14 17:37     ` Alexandre Bailon
2016-11-07 13:05 ` [PATCH v5 4/4] usb: musb: da8xx: Set phy in OTG mode by default Alexandre Bailon

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=20161114173617.GA4512@uda0271908 \
    --to=b-liu@ti.com \
    --cc=abailon@baylibre.com \
    --cc=balbi@kernel.org \
    --cc=david@lechnology.com \
    --cc=khilman@baylibre.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=nsekhar@ti.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;
as well as URLs for NNTP newsgroup(s).