Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1515312 > unrolled thread

[PATCH v4 0/4] usb: musb: da8xx: Fix few issues

Started byAlexandre Bailon <abailon@baylibre.com>
First post2016-11-04 17:50 +0100
Last post2016-11-04 21:30 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v4 0/4] usb: musb: da8xx: Fix few issues Alexandre Bailon <abailon@baylibre.com> - 2016-11-04 17:50 +0100
    [PATCH v4 3/4] usb: musb: Add a quirk flag to skip the phy set mode Alexandre Bailon <abailon@baylibre.com> - 2016-11-04 17:50 +0100
      Re: [PATCH v4 3/4] usb: musb: Add a quirk flag to skip the phy set  mode David Lechner <david@lechnology.com> - 2016-11-04 20:00 +0100
      Re: [PATCH v4 3/4] usb: musb: Add a quirk flag to skip the phy set  mode Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-11-04 21:30 +0100

#1515312 — [PATCH v4 0/4] usb: musb: da8xx: Fix few issues

FromAlexandre Bailon <abailon@baylibre.com>
Date2016-11-04 17:50 +0100
Subject[PATCH v4 0/4] usb: musb: da8xx: Fix few issues
Message-ID<szPQJ-4hU-9@gated-at.bofh.it>
Currently, the USB OTG of the da8xx doesn't work.
This series intend to fix them.

Change in v2:
* Fix the error path da8xx_musb_init()

Changes in v3:
* Remove the host workaround that was not working on every platform
* Add a property to the devicetree node of phy to force the phy in a specific
  mode (host or device).
* Only use dr_mode to configure the controller mode and let the phy in OTG mode.
  The main goal of this change is to prevent the phy to be set in host or
  device mode because these modes have some issues.

Changes in v4:
* Enable VBUS sense and session end comparator during probe of phy.
* Add a quirk flag to skip the phy set mode made during the init of musb.
  In that way, we can still can configure the phy mode by using mode file in
  sysfs and configure the controller mode by using dr_mode or platform_data.
* Init the phy in otg mode in da8xx glue driver.

Alexandre Bailon (4):
  usb: musb: da8xx: Call earlier clk_prepare_enable()
  phy: da8xx-usb: Configure CFGCHIP2 to support OTG workaround
  usb: musb: Add a quirk flag to skip the phy set mode
  usb: musb: da8xx: Set phy in OTG mode by default

 drivers/phy/phy-da8xx-usb.c  | 20 +++++++++++++++-----
 drivers/usb/musb/da8xx.c     | 27 +++++++++++++++++----------
 drivers/usb/musb/musb_core.c | 15 ++++++++++-----
 drivers/usb/musb/musb_core.h |  1 +
 4 files changed, 43 insertions(+), 20 deletions(-)

-- 
2.7.3

[toc] | [next] | [standalone]


#1515313 — [PATCH v4 3/4] usb: musb: Add a quirk flag to skip the phy set mode

FromAlexandre Bailon <abailon@baylibre.com>
Date2016-11-04 17:50 +0100
Subject[PATCH v4 3/4] usb: musb: Add a quirk flag to skip the phy set mode
Message-ID<szPQK-4hU-31@gated-at.bofh.it>
In reply to#1515312
During the init, the driver will use the 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.
Add way to skip the set mode and let the da8xx glue manage the phy mode.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
---
 drivers/usb/musb/musb_core.c | 15 ++++++++++-----
 drivers/usb/musb/musb_core.h |  1 +
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 27dadc0..6f5f039 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -2046,6 +2046,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
 {
 	int			status;
 	struct musb		*musb;
+	enum musb_mode		mode = MUSB_UNDEFINED;
 	struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
 
 	/* The driver might handle more features than the board; OK.
@@ -2261,13 +2262,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);
+		mode = MUSB_HOST;
 		break;
 	case MUSB_PORT_MODE_GADGET:
 		status = musb_gadget_setup(musb);
 		if (status < 0)
 			goto fail3;
-		status = musb_platform_set_mode(musb, MUSB_PERIPHERAL);
+		mode = MUSB_PERIPHERAL;
 		break;
 	case MUSB_PORT_MODE_DUAL_ROLE:
 		status = musb_host_setup(musb, plat->power);
@@ -2278,15 +2279,19 @@ 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);
+		mode = MUSB_OTG;
 		break;
 	default:
 		dev_err(dev, "unsupported port mode %d\n", musb->port_mode);
 		break;
 	}
 
-	if (status < 0)
-		goto fail3;
+	if (mode != MUSB_UNDEFINED &&
+		!(musb->io.quirks & MUSB_SKIP_SET_MODE)) {
+		status = musb_platform_set_mode(musb, mode);
+		if (status < 0)
+			goto fail3;
+	}
 
 	status = musb_init_debugfs(musb);
 	if (status < 0)
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
index 2cb88a49..9bd8b6b 100644
--- a/drivers/usb/musb/musb_core.h
+++ b/drivers/usb/musb/musb_core.h
@@ -172,6 +172,7 @@ struct musb_io;
  */
 struct musb_platform_ops {
 
+#define MUSB_SKIP_SET_MODE	BIT(7)
 #define MUSB_DMA_UX500		BIT(6)
 #define MUSB_DMA_CPPI41		BIT(5)
 #define MUSB_DMA_CPPI		BIT(4)
-- 
2.7.3

[toc] | [prev] | [next] | [standalone]


#1515371 — Re: [PATCH v4 3/4] usb: musb: Add a quirk flag to skip the phy set mode

FromDavid Lechner <david@lechnology.com>
Date2016-11-04 20:00 +0100
SubjectRe: [PATCH v4 3/4] usb: musb: Add a quirk flag to skip the phy set mode
Message-ID<szRSy-5w8-7@gated-at.bofh.it>
In reply to#1515313
On 11/04/2016 11:43 AM, Alexandre Bailon wrote:
> During the init, the driver will use the 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.
> Add way to skip the set mode and let the da8xx glue manage the phy mode.
>

I think you are on the right track here. But I think a cleaner way to do 
this would be to add a bool parameter to musb_platform_set_mode() that 
is passed musb->ops->set_mode() callback. You could call this parameter 
init or first_call or something like that. This way, the set_mode() 
callback can have a different behavior depending on when it is called.

In musb_init_controller(), for example, you would have...

	status = musb_platform_set_mode(musb, MUSB_HOST, true);

and in musb_mode_store(), you would have...

	status = musb_platform_set_mode(musb, MUSB_HOST, false);



> Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
> ---
>  drivers/usb/musb/musb_core.c | 15 ++++++++++-----
>  drivers/usb/musb/musb_core.h |  1 +
>  2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 27dadc0..6f5f039 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
> @@ -2046,6 +2046,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
>  {
>  	int			status;
>  	struct musb		*musb;
> +	enum musb_mode		mode = MUSB_UNDEFINED;
>  	struct musb_hdrc_platform_data *plat = dev_get_platdata(dev);
>
>  	/* The driver might handle more features than the board; OK.
> @@ -2261,13 +2262,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);
> +		mode = MUSB_HOST;
>  		break;
>  	case MUSB_PORT_MODE_GADGET:
>  		status = musb_gadget_setup(musb);
>  		if (status < 0)
>  			goto fail3;
> -		status = musb_platform_set_mode(musb, MUSB_PERIPHERAL);
> +		mode = MUSB_PERIPHERAL;
>  		break;
>  	case MUSB_PORT_MODE_DUAL_ROLE:
>  		status = musb_host_setup(musb, plat->power);
> @@ -2278,15 +2279,19 @@ 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);
> +		mode = MUSB_OTG;
>  		break;
>  	default:
>  		dev_err(dev, "unsupported port mode %d\n", musb->port_mode);
>  		break;
>  	}
>
> -	if (status < 0)
> -		goto fail3;
> +	if (mode != MUSB_UNDEFINED &&
> +		!(musb->io.quirks & MUSB_SKIP_SET_MODE)) {
> +		status = musb_platform_set_mode(musb, mode);
> +		if (status < 0)
> +			goto fail3;
> +	}
>
>  	status = musb_init_debugfs(musb);
>  	if (status < 0)
> diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h
> index 2cb88a49..9bd8b6b 100644
> --- a/drivers/usb/musb/musb_core.h
> +++ b/drivers/usb/musb/musb_core.h
> @@ -172,6 +172,7 @@ struct musb_io;
>   */
>  struct musb_platform_ops {
>
> +#define MUSB_SKIP_SET_MODE	BIT(7)

This would be better described as MUSB_SKIP_SET_MODE_IN_INIT

>  #define MUSB_DMA_UX500		BIT(6)
>  #define MUSB_DMA_CPPI41		BIT(5)
>  #define MUSB_DMA_CPPI		BIT(4)
>

[toc] | [prev] | [next] | [standalone]


#1515382 — Re: [PATCH v4 3/4] usb: musb: Add a quirk flag to skip the phy set mode

FromSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date2016-11-04 21:30 +0100
SubjectRe: [PATCH v4 3/4] usb: musb: Add a quirk flag to skip the phy set mode
Message-ID<szThD-6we-21@gated-at.bofh.it>
In reply to#1515313
Hello.

On 11/04/2016 07:43 PM, Alexandre Bailon wrote:

> During the init, the driver will use the mode to configure
> the controller mode and the phy mode.

    PHY -- be consistent please...

> The PHY of DA8xx has some issues when the phy is forced in host or device.

    Again.

> Add way to skip the set mode and let the da8xx glue manage the phy mode.
>
> Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
> ---
>  drivers/usb/musb/musb_core.c | 15 ++++++++++-----
>  drivers/usb/musb/musb_core.h |  1 +
>  2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
> index 27dadc0..6f5f039 100644
> --- a/drivers/usb/musb/musb_core.c
> +++ b/drivers/usb/musb/musb_core.c
[...]
> @@ -2278,15 +2279,19 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
[...]
> -	if (status < 0)
> -		goto fail3;
> +	if (mode != MUSB_UNDEFINED &&
> +		!(musb->io.quirks & MUSB_SKIP_SET_MODE)) {

    Please either add one more tab here or align to 'mode', so it's easier on 
the eyes.

> +		status = musb_platform_set_mode(musb, mode);
> +		if (status < 0)
> +			goto fail3;
> +	}
>
>  	status = musb_init_debugfs(musb);
>  	if (status < 0)
[...]

MBR, Sergei

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web