提交 6ba43c29 编写于 作者: H Hans de Goede 提交者: Kishon Vijay Abraham I

phy-sun4i-usb: Add support for phy_set_mode

Together with some musb sunxi glue changes this allows run-time dr_mode
switching support via the "mode" musb sysfs attribute.
Signed-off-by: NHans de Goede <hdegoede@redhat.com>
Signed-off-by: NKishon Vijay Abraham I <kishon@ti.com>
上级 5f90d31c
......@@ -427,6 +427,35 @@ static int sun4i_usb_phy_power_off(struct phy *_phy)
return 0;
}
static int sun4i_usb_phy_set_mode(struct phy *_phy, enum phy_mode mode)
{
struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy);
if (phy->index != 0)
return -EINVAL;
switch (mode) {
case PHY_MODE_USB_HOST:
data->dr_mode = USB_DR_MODE_HOST;
break;
case PHY_MODE_USB_DEVICE:
data->dr_mode = USB_DR_MODE_PERIPHERAL;
break;
case PHY_MODE_USB_OTG:
data->dr_mode = USB_DR_MODE_OTG;
break;
default:
return -EINVAL;
}
dev_info(&_phy->dev, "Changing dr_mode to %d\n", (int)data->dr_mode);
data->force_session_end = true;
queue_delayed_work(system_wq, &data->detect, 0);
return 0;
}
void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled)
{
struct sun4i_usb_phy *phy = phy_get_drvdata(_phy);
......@@ -440,6 +469,7 @@ static const struct phy_ops sun4i_usb_phy_ops = {
.exit = sun4i_usb_phy_exit,
.power_on = sun4i_usb_phy_power_on,
.power_off = sun4i_usb_phy_power_off,
.set_mode = sun4i_usb_phy_set_mode,
.owner = THIS_MODULE,
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册