From: lyz Date: Wed, 29 Oct 2014 09:24:29 +0000 (+0800) Subject: usb: implement power control by 'buspower' attribute X-Git-Tag: firefly_0821_release~4473 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=18b8b4564e0b84e50e7809879e1a029fa149a51f;p=firefly-linux-kernel-4.4.55.git usb: implement power control by 'buspower' attribute This node is used for usb controller test application to enum usb devices plugin and disconnect. --- diff --git a/drivers/usb/dwc_otg_310/dwc_otg_attr.c b/drivers/usb/dwc_otg_310/dwc_otg_attr.c index 989b655d150c..f071bf401473 100755 --- a/drivers/usb/dwc_otg_310/dwc_otg_attr.c +++ b/drivers/usb/dwc_otg_310/dwc_otg_attr.c @@ -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; } diff --git a/drivers/usb/dwc_otg_310/usbdev_rk32.c b/drivers/usb/dwc_otg_310/usbdev_rk32.c index e0394614614a..84894be0ed0a 100755 --- a/drivers/usb/dwc_otg_310/usbdev_rk32.c +++ b/drivers/usb/dwc_otg_310/usbdev_rk32.c @@ -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))