Commit 4acb0200 authored by Tony Lindgren's avatar Tony Lindgren Committed by Kishon Vijay Abraham I

phy: cpcap-usb: Fix error path when no host driver is loaded

If musb_mailbox() returns an error, we must still continue to finish
configuring the phy.

Otherwise the phy state may end up only half initialized, and this can
cause the debug serial console to stop working. And this will happen if the
usb driver musb controller is not loaded.

Let's fix the issue by adding helper for cpcap_usb_try_musb_mailbox().

Fixes: 6d6ce40f ("phy: cpcap-usb: Add CPCAP PMIC USB support")
Cc: Merlijn Wajer <merlijn@wizzup.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Sebastian Reichel <sre@kernel.org>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent e42617b8
...@@ -207,6 +207,19 @@ static int cpcap_phy_get_ints_state(struct cpcap_phy_ddata *ddata, ...@@ -207,6 +207,19 @@ static int cpcap_phy_get_ints_state(struct cpcap_phy_ddata *ddata,
static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata); static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata);
static int cpcap_usb_set_usb_mode(struct cpcap_phy_ddata *ddata); static int cpcap_usb_set_usb_mode(struct cpcap_phy_ddata *ddata);
static void cpcap_usb_try_musb_mailbox(struct cpcap_phy_ddata *ddata,
enum musb_vbus_id_status status)
{
int error;
error = musb_mailbox(status);
if (!error)
return;
dev_dbg(ddata->dev, "%s: musb_mailbox failed: %i\n",
__func__, error);
}
static void cpcap_usb_detect(struct work_struct *work) static void cpcap_usb_detect(struct work_struct *work)
{ {
struct cpcap_phy_ddata *ddata; struct cpcap_phy_ddata *ddata;
...@@ -226,9 +239,7 @@ static void cpcap_usb_detect(struct work_struct *work) ...@@ -226,9 +239,7 @@ static void cpcap_usb_detect(struct work_struct *work)
if (error) if (error)
goto out_err; goto out_err;
error = musb_mailbox(MUSB_ID_GROUND); cpcap_usb_try_musb_mailbox(ddata, MUSB_ID_GROUND);
if (error)
goto out_err;
error = regmap_update_bits(ddata->reg, CPCAP_REG_USBC3, error = regmap_update_bits(ddata->reg, CPCAP_REG_USBC3,
CPCAP_BIT_VBUSSTBY_EN | CPCAP_BIT_VBUSSTBY_EN |
...@@ -257,9 +268,7 @@ static void cpcap_usb_detect(struct work_struct *work) ...@@ -257,9 +268,7 @@ static void cpcap_usb_detect(struct work_struct *work)
error = cpcap_usb_set_usb_mode(ddata); error = cpcap_usb_set_usb_mode(ddata);
if (error) if (error)
goto out_err; goto out_err;
error = musb_mailbox(MUSB_ID_GROUND); cpcap_usb_try_musb_mailbox(ddata, MUSB_ID_GROUND);
if (error)
goto out_err;
return; return;
} }
...@@ -269,9 +278,7 @@ static void cpcap_usb_detect(struct work_struct *work) ...@@ -269,9 +278,7 @@ static void cpcap_usb_detect(struct work_struct *work)
error = cpcap_usb_set_usb_mode(ddata); error = cpcap_usb_set_usb_mode(ddata);
if (error) if (error)
goto out_err; goto out_err;
error = musb_mailbox(MUSB_VBUS_VALID); cpcap_usb_try_musb_mailbox(ddata, MUSB_VBUS_VALID);
if (error)
goto out_err;
return; return;
} }
...@@ -281,9 +288,7 @@ static void cpcap_usb_detect(struct work_struct *work) ...@@ -281,9 +288,7 @@ static void cpcap_usb_detect(struct work_struct *work)
if (error) if (error)
goto out_err; goto out_err;
error = musb_mailbox(MUSB_VBUS_OFF); cpcap_usb_try_musb_mailbox(ddata, MUSB_VBUS_OFF);
if (error)
goto out_err;
dev_dbg(ddata->dev, "set UART mode\n"); dev_dbg(ddata->dev, "set UART mode\n");
...@@ -649,9 +654,7 @@ static int cpcap_usb_phy_remove(struct platform_device *pdev) ...@@ -649,9 +654,7 @@ static int cpcap_usb_phy_remove(struct platform_device *pdev)
if (error) if (error)
dev_err(ddata->dev, "could not set UART mode\n"); dev_err(ddata->dev, "could not set UART mode\n");
error = musb_mailbox(MUSB_VBUS_OFF); cpcap_usb_try_musb_mailbox(ddata, MUSB_VBUS_OFF);
if (error)
dev_err(ddata->dev, "could not set mailbox\n");
usb_remove_phy(&ddata->phy); usb_remove_phy(&ddata->phy);
cancel_delayed_work_sync(&ddata->detect_work); cancel_delayed_work_sync(&ddata->detect_work);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment