Commit 6703052f authored by Roger Quadros's avatar Roger Quadros Committed by Peter Chen

usb: cdns3: Fix hardware based role switch

Hardware based role switch is broken as the driver always skips it.
Fix this by registering for  SW role switch only if 'usb-role-switch'
property is present in the device tree.

Fixes: 50642709 ("usb: cdns3: core: quit if it uses role switch class")
Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
parent f3bc432a
...@@ -427,7 +427,6 @@ static irqreturn_t cdns3_wakeup_irq(int irq, void *data) ...@@ -427,7 +427,6 @@ static irqreturn_t cdns3_wakeup_irq(int irq, void *data)
*/ */
static int cdns3_probe(struct platform_device *pdev) static int cdns3_probe(struct platform_device *pdev)
{ {
struct usb_role_switch_desc sw_desc = { };
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct resource *res; struct resource *res;
struct cdns3 *cdns; struct cdns3 *cdns;
...@@ -529,11 +528,13 @@ static int cdns3_probe(struct platform_device *pdev) ...@@ -529,11 +528,13 @@ static int cdns3_probe(struct platform_device *pdev)
if (ret) if (ret)
goto err2; goto err2;
if (device_property_read_bool(dev, "usb-role-switch")) {
struct usb_role_switch_desc sw_desc = { };
sw_desc.set = cdns3_role_set; sw_desc.set = cdns3_role_set;
sw_desc.get = cdns3_role_get; sw_desc.get = cdns3_role_get;
sw_desc.allow_userspace_control = true; sw_desc.allow_userspace_control = true;
sw_desc.driver_data = cdns; sw_desc.driver_data = cdns;
if (device_property_read_bool(dev, "usb-role-switch"))
sw_desc.fwnode = dev->fwnode; sw_desc.fwnode = dev->fwnode;
cdns->role_sw = usb_role_switch_register(dev, &sw_desc); cdns->role_sw = usb_role_switch_register(dev, &sw_desc);
...@@ -542,6 +543,7 @@ static int cdns3_probe(struct platform_device *pdev) ...@@ -542,6 +543,7 @@ static int cdns3_probe(struct platform_device *pdev)
dev_warn(dev, "Unable to register Role Switch\n"); dev_warn(dev, "Unable to register Role Switch\n");
goto err3; goto err3;
} }
}
if (cdns->wakeup_irq) { if (cdns->wakeup_irq) {
ret = devm_request_irq(cdns->dev, cdns->wakeup_irq, ret = devm_request_irq(cdns->dev, cdns->wakeup_irq,
...@@ -582,6 +584,7 @@ static int cdns3_probe(struct platform_device *pdev) ...@@ -582,6 +584,7 @@ static int cdns3_probe(struct platform_device *pdev)
return 0; return 0;
err4: err4:
cdns3_drd_exit(cdns); cdns3_drd_exit(cdns);
if (cdns->role_sw)
usb_role_switch_unregister(cdns->role_sw); usb_role_switch_unregister(cdns->role_sw);
err3: err3:
set_phy_power_off(cdns); set_phy_power_off(cdns);
......
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