linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* USB: chipidea: Do not hang when CONFIG_USB_CHIPIDEA_ULPI is not selected
@ 2018-06-25 14:06 Fabio Estevam
  0 siblings, 0 replies; 2+ messages in thread
From: Fabio Estevam @ 2018-06-25 14:06 UTC (permalink / raw)
  To: Peter.Chen
  Cc: linux-usb, andrew.smirnov, l.stach, sebastian.reichel, shawnguo,
	linux-imx, kernel, Fabio Estevam

From: Fabio Estevam <fabio.estevam@nxp.com>

Since commit 03e6275ae381087bd8 ("usb: chipidea: Fix ULPI on imx51") the
kernel hangs on a imx51-babbage board, when using the ULPI interface with
the CONFIG_USB_CHIPIDEA_ULPI option unselected.

Instead of hanging the kernel, let's warn the user that
CONFIG_USB_CHIPIDEA_ULPI needs to be selected, propagate an error
and continue with booting the kernel.

The user can then react to the warning and select
CONFIG_USB_CHIPIDEA_ULPI as needed.

Fixes: 03e6275ae381087bd8 ("usb: chipidea: Fix ULPI on imx51")
Suggested-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
---
 drivers/usb/chipidea/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 85fc6db..5ab9db1 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -608,6 +608,16 @@ static int ci_get_platdata(struct device *dev,
 	if (!platdata->phy_mode)
 		platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
 
+	if (platdata->phy_mode == USBPHY_INTERFACE_MODE_ULPI) {
+		/*
+		 * CONFIG_USB_CHIPIDEA_ULPI needs to be selected
+		 * for proper usage of the ULPI mode
+		 */
+		WARN_ONCE(!IS_ENABLED(CONFIG_USB_CHIPIDEA_ULPI),
+		"Select CONFIG_USB_CHIPIDEA_ULPI in order to use ULPI mode\n");
+		return -EINVAL;
+	}
+
 	if (!platdata->dr_mode)
 		platdata->dr_mode = usb_get_dr_mode(dev);
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* USB: chipidea: Do not hang when CONFIG_USB_CHIPIDEA_ULPI is not selected
@ 2018-06-25 14:10 Fabio Estevam
  0 siblings, 0 replies; 2+ messages in thread
From: Fabio Estevam @ 2018-06-25 14:10 UTC (permalink / raw)
  To: Peter Chen
  Cc: USB list, Andrey Smirnov, Lucas Stach, Sebastian Reichel,
	Shawn Guo, NXP Linux Team, Sascha Hauer, Fabio Estevam

On Mon, Jun 25, 2018 at 11:06 AM, Fabio Estevam <festevam@gmail.com> wrote:
> From: Fabio Estevam <fabio.estevam@nxp.com>
>
> Since commit 03e6275ae381087bd8 ("usb: chipidea: Fix ULPI on imx51") the
> kernel hangs on a imx51-babbage board, when using the ULPI interface with
> the CONFIG_USB_CHIPIDEA_ULPI option unselected.
>
> Instead of hanging the kernel, let's warn the user that
> CONFIG_USB_CHIPIDEA_ULPI needs to be selected, propagate an error
> and continue with booting the kernel.
>
> The user can then react to the warning and select
> CONFIG_USB_CHIPIDEA_ULPI as needed.
>
> Fixes: 03e6275ae381087bd8 ("usb: chipidea: Fix ULPI on imx51")
> Suggested-by: Lucas Stach <l.stach@pengutronix.de>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
>  drivers/usb/chipidea/core.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 85fc6db..5ab9db1 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -608,6 +608,16 @@ static int ci_get_platdata(struct device *dev,
>         if (!platdata->phy_mode)
>                 platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
>
> +       if (platdata->phy_mode == USBPHY_INTERFACE_MODE_ULPI) {
> +               /*
> +                * CONFIG_USB_CHIPIDEA_ULPI needs to be selected
> +                * for proper usage of the ULPI mode
> +                */
> +               WARN_ONCE(!IS_ENABLED(CONFIG_USB_CHIPIDEA_ULPI),
> +               "Select CONFIG_USB_CHIPIDEA_ULPI in order to use ULPI mode\n");
> +               return -EINVAL;

Oops, sorry. Please discard this one.

Logic is wrong here. Will fix and submit a v2.
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-25 14:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-25 14:06 USB: chipidea: Do not hang when CONFIG_USB_CHIPIDEA_ULPI is not selected Fabio Estevam
  -- strict thread matches above, loose matches on Subject: below --
2018-06-25 14:10 Fabio Estevam

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).