usb: implement power control by 'buspower' attribute
authorlyz <lyz@rock-chips.com>
Wed, 29 Oct 2014 09:24:29 +0000 (17:24 +0800)
committerlyz <lyz@rock-chips.com>
Fri, 14 Nov 2014 03:02:14 +0000 (11:02 +0800)
This node is used for usb controller test application to enum usb
devices plugin and disconnect.

drivers/usb/dwc_otg_310/dwc_otg_attr.c
drivers/usb/dwc_otg_310/usbdev_rk32.c

index 989b655d150cfee3359fc19a9e83b26b0a1cf139..f071bf401473ed0d021f6ab88d710bb13cfae4fc 100755 (executable)
@@ -580,10 +580,15 @@ static ssize_t buspower_store(struct device *_dev,
                              struct device_attribute *attr,
                              const char *buf, size_t count)
 {
-
        dwc_otg_device_t *otg_dev = _dev->platform_data;
+       struct dwc_otg_platform_data *pldata = otg_dev->pldata;
        uint32_t on = simple_strtoul(buf, NULL, 16);
+
+       if (on != 0 && on != 1)
+               return -EINVAL;
+
        dwc_otg_set_prtpower(otg_dev->core_if, on);
+       pldata->power_enable(on);
        return count;
 }
 
index e0394614614afe430df67f98140c8f5af1a135dd..84894be0ed0aa1b37c511b74e683f9e776bb4281 100755 (executable)
@@ -337,7 +337,8 @@ static void usb20host_power_enable(int enable)
 {
        if (0 == enable) {
                /* disable host_drv power */
-               /* do not disable power in default */
+               if (gpio_is_valid(control_usb->host_gpios->gpio))
+                       gpio_set_value(control_usb->host_gpios->gpio, 0);
        } else if (1 == enable) {
                /* enable host_drv power */
                if (gpio_is_valid(control_usb->host_gpios->gpio))