Skip to content

Commit

Permalink
usb: renesas_usbhs: add extcon notifier to set mode for non-otg channel
Browse files Browse the repository at this point in the history
This patch adds extcon notifier callback to set the mode of
host/peripheral by using extcon state (e.g phy-rcar-gen3-usb2) for
non-otg channel (e.g. R-Car D3).

[Fengguang Wu: fixed sparse warning]

Signed-off-by: Fengguang Wu <[email protected]>
Signed-off-by: Yoshihiro Shimoda <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>

usb: renesas_usbhs: usbhs_rcar3_notifier() can be static

Fixes: 3a7cce26122e ("usb: renesas_usbhs: add extcon notifier to set mode for non-otg channel")
Signed-off-by: Fengguang Wu <[email protected]>
Signed-off-by: Felipe Balbi <[email protected]>
  • Loading branch information
shimoday authored and Felipe Balbi committed Dec 14, 2017
1 parent cd14247 commit 8ada211
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/usb/renesas_usbhs/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,15 @@ static int usbhs_probe(struct platform_device *pdev)
break;
case USBHS_TYPE_RCAR_GEN3_WITH_PLL:
priv->pfunc = usbhs_rcar3_with_pll_ops;
if (!IS_ERR_OR_NULL(priv->edev)) {
priv->nb.notifier_call = priv->pfunc.notifier;
ret = devm_extcon_register_notifier(&pdev->dev,
priv->edev,
EXTCON_USB_HOST,
&priv->nb);
if (ret < 0)
dev_err(&pdev->dev, "no notifier registered\n");
}
break;
default:
if (!info->platform_callback.get_id) {
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/renesas_usbhs/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ struct usbhs_priv {
struct platform_device *pdev;

struct extcon_dev *edev;
struct notifier_block nb;

spinlock_t lock;

Expand Down
11 changes: 11 additions & 0 deletions drivers/usb/renesas_usbhs/rcar3.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ static int usbhs_rcar3_get_id(struct platform_device *pdev)
return USBHS_GADGET;
}

static int usbhs_rcar3_notifier(struct notifier_block *nb, unsigned long event,
void *data)
{
struct usbhs_priv *priv = container_of(nb, struct usbhs_priv, nb);

usbhs_rcar3_set_usbsel(priv, !!event);

return NOTIFY_DONE;
}

const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = {
.power_ctrl = usbhs_rcar3_power_ctrl,
.get_id = usbhs_rcar3_get_id,
Expand All @@ -120,4 +130,5 @@ const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = {
const struct renesas_usbhs_platform_callback usbhs_rcar3_with_pll_ops = {
.power_ctrl = usbhs_rcar3_power_and_pll_ctrl,
.get_id = usbhs_rcar3_get_id,
.notifier = usbhs_rcar3_notifier,
};

0 comments on commit 8ada211

Please sign in to comment.