From be4ee634b2cb1e55799b9fc72a4b2ff0e8e164ef Mon Sep 17 00:00:00 2001 From: ckkim Date: Tue, 23 Feb 2021 18:13:22 +0900 Subject: [PATCH] ODROID-C: Add to enalbe OTG vbus on/off. Change-Id: I45f016be13ce261cb939aba609d25ef1dc4457c2 --- .../amlogic/usb/dwc_otg/310/dwc_otg_attr.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) mode change 100644 => 100755 drivers/amlogic/usb/dwc_otg/310/dwc_otg_attr.c diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_attr.c b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_attr.c old mode 100644 new mode 100755 index e054b7c7912b..a4f1d6addbe2 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_attr.c +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_attr.c @@ -893,6 +893,34 @@ static ssize_t buspower_store(struct device *_dev, DEVICE_ATTR(buspower, 0644, buspower_show, buspower_store); +/** + * Set the VBus Power + */ +static ssize_t vbus_store(struct device *_dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ +#ifdef LM_INTERFACE + struct lm_device *lm_dev = container_of(_dev, struct lm_device, dev); + dwc_otg_device_t *otg_dev = lm_get_drvdata(lm_dev); +#elif defined(PCI_INTERFACE) + dwc_otg_device_t *otg_dev = dev_get_drvdata(_dev); +#endif + uint32_t on = simple_strtoul(buf, NULL, 16); + + if (dwc_otg_is_host_mode(otg_dev->core_if)) { + dwc_otg_set_vbus_power(otg_dev->core_if, on); + DWC_PRINTF("Set VBus Power : %d \n", on); + } + else { + DWC_PRINTF("Not in host mode. Nothing to do."); + } + + return count; +} + +DEVICE_ATTR(vbus, S_IWUSR, 0, vbus_store); + /** * @todo Need to do more for suspend? */ @@ -1540,6 +1568,7 @@ void dwc_otg_attr_create( error = device_create_file(&dev->dev, &dev_attr_hnp); error = device_create_file(&dev->dev, &dev_attr_srp); error = device_create_file(&dev->dev, &dev_attr_buspower); + error = device_create_file(&dev->dev, &dev_attr_vbus); error = device_create_file(&dev->dev, &dev_attr_bussuspend); error = device_create_file(&dev->dev, &dev_attr_mode_ch_tim_en); error = device_create_file(&dev->dev, &dev_attr_fr_interval); @@ -1600,6 +1629,7 @@ void dwc_otg_attr_remove( device_remove_file(&dev->dev, &dev_attr_hnp); device_remove_file(&dev->dev, &dev_attr_srp); device_remove_file(&dev->dev, &dev_attr_buspower); + device_remove_file(&dev->dev, &dev_attr_vbus); device_remove_file(&dev->dev, &dev_attr_bussuspend); device_remove_file(&dev->dev, &dev_attr_mode_ch_tim_en); device_remove_file(&dev->dev, &dev_attr_fr_interval);