usb: gadget: tegra-xudc: Add vbus_draw support
Register vbus_draw to gadget ops and update corresponding vbus draw current to usb_phy. Signed-off-by: Nagarjuna Kristam <nkristam@nvidia.com> Signed-off-by: Felipe Balbi <balbi@kernel.org>
This commit is contained in:
parent
f7ac582eff
commit
ac82b56bda
@ -492,6 +492,7 @@ struct tegra_xudc {
|
|||||||
bool powergated;
|
bool powergated;
|
||||||
|
|
||||||
struct usb_phy **usbphy;
|
struct usb_phy **usbphy;
|
||||||
|
struct usb_phy *curr_usbphy;
|
||||||
struct notifier_block vbus_nb;
|
struct notifier_block vbus_nb;
|
||||||
|
|
||||||
struct completion disconnect_complete;
|
struct completion disconnect_complete;
|
||||||
@ -719,6 +720,7 @@ static int tegra_xudc_vbus_notify(struct notifier_block *nb,
|
|||||||
if (!xudc->suspended && phy_index != -1) {
|
if (!xudc->suspended && phy_index != -1) {
|
||||||
xudc->curr_utmi_phy = xudc->utmi_phy[phy_index];
|
xudc->curr_utmi_phy = xudc->utmi_phy[phy_index];
|
||||||
xudc->curr_usb3_phy = xudc->usb3_phy[phy_index];
|
xudc->curr_usb3_phy = xudc->usb3_phy[phy_index];
|
||||||
|
xudc->curr_usbphy = usbphy;
|
||||||
schedule_work(&xudc->usb_role_sw_work);
|
schedule_work(&xudc->usb_role_sw_work);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2042,6 +2044,20 @@ static int tegra_xudc_gadget_stop(struct usb_gadget *gadget)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tegra_xudc_gadget_vbus_draw(struct usb_gadget *gadget,
|
||||||
|
unsigned int m_a)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
struct tegra_xudc *xudc = to_xudc(gadget);
|
||||||
|
|
||||||
|
dev_dbg(xudc->dev, "%s: %u mA\n", __func__, m_a);
|
||||||
|
|
||||||
|
if (xudc->curr_usbphy->chg_type == SDP_TYPE)
|
||||||
|
ret = usb_phy_set_power(xudc->curr_usbphy, m_a);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int tegra_xudc_set_selfpowered(struct usb_gadget *gadget, int is_on)
|
static int tegra_xudc_set_selfpowered(struct usb_gadget *gadget, int is_on)
|
||||||
{
|
{
|
||||||
struct tegra_xudc *xudc = to_xudc(gadget);
|
struct tegra_xudc *xudc = to_xudc(gadget);
|
||||||
@ -2058,6 +2074,7 @@ static struct usb_gadget_ops tegra_xudc_gadget_ops = {
|
|||||||
.pullup = tegra_xudc_gadget_pullup,
|
.pullup = tegra_xudc_gadget_pullup,
|
||||||
.udc_start = tegra_xudc_gadget_start,
|
.udc_start = tegra_xudc_gadget_start,
|
||||||
.udc_stop = tegra_xudc_gadget_stop,
|
.udc_stop = tegra_xudc_gadget_stop,
|
||||||
|
.vbus_draw = tegra_xudc_gadget_vbus_draw,
|
||||||
.set_selfpowered = tegra_xudc_set_selfpowered,
|
.set_selfpowered = tegra_xudc_set_selfpowered,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user