Control USB Vbus

cancel
Showing results for 
Search instead for 
Did you mean: 

Control USB Vbus

106 Views
mohamed-ali_fod
Contributor I

Hello,

I am working on i.MX6 Quad. I want to set vbus on/off through libusb, but it seems that chipidea driver doesn't allow this because it check for CI_HDRC_TURN_VBUS_EARLY_ON in host_start function so  the priv->reg_vbus is always NULL

priv->reg_vbus = NULL;

if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci)) {
    if (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON) {
        ret = regulator_enable(ci->platdata->reg_vbus);
        if (ret) { 
            dev_err(ci->dev,
            "Failed to enable vbus regulator, ret=%d\n",ret);
            goto put_hcd;
        }
    } else {
         priv->reg_vbus = ci->platdata->reg_vbus;
       }
}

because priv->reg_vbus = NULL the following condition is not satisfied in ehci_ci_portpower function:

if (priv->reg_vbus && enable != priv->enabled)

So the regulator_enable(priv->reg_vbus)/regulator_disable(priv->reg_vbus) are not called.

The question is: it is safe to do always priv->reg_vbus =ci->platdata->reg_vbus in host_start ?

if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci)) {
    if (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON) {

        priv->reg_vbus = ci->platdata->reg_vbus;
        ret = regulator_enable(ci->platdata->reg_vbus);
        if (ret) { 
            dev_err(ci->dev,
            "Failed to enable vbus regulator, ret=%d\n",ret);
            goto put_hcd;
        }
    } 
}

So the condition if (priv->reg_vbus && enable != priv->enabled) in ehci_ci_portpower is true and regulator_disable/regulator_enable can be called.

Best Regards

0 Kudos
2 Replies

82 Views
mohamed-ali_fod
Contributor I

Hello,

The purpose is to disable Vbus in case of over-current from user space or is it already managed in the driver?

Thanks,

Mohamed Ali

0 Kudos

64 Views
b45499
NXP TechSupport
NXP TechSupport
0 Kudos