[PATCHv2] USB: ohci: da8xx: Resume the entire host controller

2016-11-24 Thread Axel Haslam
The da8xx ohci controller is not working after suspend and resume.

This is because only the root hub is being resumed.

Balance the ohci_suspend of the suspend path with an ohci_resume
in the resume path so that we resume the entire controller, and not
just the root hub.

Also, while we are here, remove setting device power_state,
as this is no longer needed and scheduled for removal

Acked-by: Alan Stern <st...@rowland.harvard.edu>
Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
Changes v1->v2
* reword commit message (Alan Stern)

 drivers/usb/host/ohci-da8xx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 9e336f4..05da2cb 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -528,8 +528,7 @@ static int ohci_da8xx_resume(struct platform_device *dev)
if (ret)
return ret;
 
-   dev->dev.power.power_state = PMSG_ON;
-   usb_hcd_resume_root_hub(hcd);
+   ohci_resume(hcd, false);
 
return 0;
 }
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] USB: ohci: da8xx: Balance ochi_disable with ohci_enable in resume.

2016-11-23 Thread Axel Haslam
On resume from suspend a failure with -ESHUTDOWN is returned
from ohci_bus_resume, and the usb is inoperable.

This happens because ohci_suspend disables the master interrupt
and sets an hcd flag to say that the hw is no longer accessible.

Calling ohci_resume reverts the steps taken on ohci_suspend
and flags the HW as "accessible" again, resume completes
successfully and usb is working after a suspend/resume sequence.

While we are here, remove setting device power_state,
as this is no longer needed and scheduled for removal.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index b3de8bc..a598bd8 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -340,8 +340,7 @@ static int ohci_da8xx_resume(struct platform_device *dev)
if (ret)
return ret;
 
-   dev->dev.power.power_state = PMSG_ON;
-   usb_hcd_resume_root_hub(hcd);
+   ohci_resume(hcd, false);
 
return 0;
 }
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv7 1/5] USB: ohci: da8xx: use ohci priv data instead of globals

2016-11-23 Thread Axel Haslam
Instead of global variables, use the extra_priv_size of
the ohci driver.

We cannot yet move the ocic mask because this is used on
the interrupt handler which is registered through platform
data and does not have an hcd pointer. This will be moved
on a later patch.

Tested-by: David Lechner <da...@lechnology.com>
Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 73 +--
 1 file changed, 43 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index bd6cf3c..cd75677 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -35,43 +35,50 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
u16 wValue, u16 wIndex, char *buf, u16 wLength);
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
-static struct clk *usb11_clk;
-static struct phy *usb11_phy;
+struct da8xx_ohci_hcd {
+   struct clk *usb11_clk;
+   struct phy *usb11_phy;
+};
+
+#define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
 /* Over-current indicator change bitmask */
 static volatile u16 ocic_mask;
 
-static int ohci_da8xx_enable(void)
+static int ohci_da8xx_enable(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
int ret;
 
-   ret = clk_prepare_enable(usb11_clk);
+   ret = clk_prepare_enable(da8xx_ohci->usb11_clk);
if (ret)
return ret;
 
-   ret = phy_init(usb11_phy);
+   ret = phy_init(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_init;
 
-   ret = phy_power_on(usb11_phy);
+   ret = phy_power_on(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_power_on;
 
return 0;
 
 err_phy_power_on:
-   phy_exit(usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
 err_phy_init:
-   clk_disable_unprepare(usb11_clk);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 
return ret;
 }
 
-static void ohci_da8xx_disable(void)
+static void ohci_da8xx_disable(struct usb_hcd *hcd)
 {
-   phy_power_off(usb11_phy);
-   phy_exit(usb11_phy);
-   clk_disable_unprepare(usb11_clk);
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
+
+   phy_power_off(da8xx_ohci->usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
 /*
@@ -97,7 +104,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
dev_dbg(dev, "starting USB controller\n");
 
-   result = ohci_da8xx_enable();
+   result = ohci_da8xx_enable(hcd);
if (result < 0)
return result;
 
@@ -109,7 +116,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
result = ohci_setup(hcd);
if (result < 0) {
-   ohci_da8xx_disable();
+   ohci_da8xx_disable(hcd);
return result;
}
 
@@ -231,6 +238,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 static int ohci_da8xx_probe(struct platform_device *pdev)
 {
struct da8xx_ohci_root_hub *hub = dev_get_platdata(>dev);
+   struct da8xx_ohci_hcd *da8xx_ohci;
struct usb_hcd  *hcd;
struct resource *mem;
int error, irq;
@@ -238,25 +246,29 @@ static int ohci_da8xx_probe(struct platform_device *pdev)
if (hub == NULL)
return -ENODEV;
 
-   usb11_clk = devm_clk_get(>dev, "usb11");
-   if (IS_ERR(usb11_clk)) {
-   if (PTR_ERR(usb11_clk) != -EPROBE_DEFER)
+   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
+   dev_name(>dev));
+   if (!hcd)
+   return -ENOMEM;
+
+   da8xx_ohci = to_da8xx_ohci(hcd);
+
+   da8xx_ohci->usb11_clk = devm_clk_get(>dev, "usb11");
+   if (IS_ERR(da8xx_ohci->usb11_clk)) {
+   error = PTR_ERR(da8xx_ohci->usb11_clk);
+   if (error != -EPROBE_DEFER)
dev_err(>dev, "Failed to get clock.\n");
-   return PTR_ERR(usb11_clk);
+   goto err;
}
 
-   usb11_phy = devm_phy_get(>dev, "usb-phy");
-   if (IS_ERR(usb11_phy)) {
-   if (PTR_ERR(usb11_phy) != -EPROBE_DEFER)
+   da8xx_ohci->usb11_phy = devm_phy_get(>dev, "usb-phy");
+   if (IS_ERR(da8xx_ohci->usb11_phy)) {
+   error = PTR_ERR(da8xx_ohci->usb11_phy);
+   if (error != -EPROBE_DEFER)
dev_err(>dev, "Failed to get phy.\n");
-   return PTR_ERR(usb11_phy);
+   goto err;
}
 
-   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
-   dev_name(>dev));
-   if (!hcd)
-   

[PATCHv7 0/5] SB: ohci-da8xx: Add device tree support

2016-11-23 Thread Axel Haslam
When booting using device tree, we can not make use of
platform callbacks to handle vbus and over current gpios.

This series allows the ohci-da8xx driver to use a regulator
instead of the platform callbacks to control vbus and adds
the device tree bindings to be able to probe using DT.

Once all users of the platform callbacks will be converted to
use a regulator, we will be able to remove platform data completely.

**DEPENDENCY**:
These patches depend on a regulator patch that is
merged into linux-next, but not yet on usb-next:

regulator: core: Add new API to poll for error conditions
https://lkml.org/lkml/2016/11/3/191


Changes from v6->v7
* remove print on over current event as the usb core already does it (David)
* fix ocic mask for regulator event (David)
* spelling fix and tested-by on first patch.
* skip error message on probe defer from regulator (David)

Changes from v5->v6
* Fix regulator over current flag check (David)
* Spelling fixes and code cleanups (David)
* add Ack for device tree binding

Changes from v4->v5
* Append the Device tree patches to v4.
* Submit only the first part of the series (no dependencies).
this can be applied and merged through the usb tree.

Changes from v3->v4
* separate the series into smaller series for driver and arch/arm code,
  to ease review and merging to different trees.

Changes form v2->v3
* drop patches that have been integrated to arch/arm
* drop regulator patches which will be integrated through regulator tree
* use of the accepted regulator API to get over current status
* better patch separation with the use of wrappers

Changes from v1->v2
* Rebased and added patch to make ohci a separate driver
* Use a regulator instead of handling Gpios (David Lechner)
* Add an over current mode to regulator framework
* Fixed regulator is able to register for and over current irq
* Added patch by Alexandre to remove build warnings
* Moved global variables into private hcd structure.
Axel Haslam (5):
  USB: ohci: da8xx: use ohci priv data instead of globals
  USB: ohci: da8xx: Add wrappers for platform callbacks
  USB: ohci: da8xx: Allow a regulator to handle VBUS
  USB: ohci: da8xx: Add devicetree bindings
  USB: ohci: da8xx: Allow probing from DT

 .../devicetree/bindings/usb/ohci-da8xx.txt |  23 ++
 drivers/usb/host/ohci-da8xx.c  | 290 +
 2 files changed, 263 insertions(+), 50 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv7 2/5] USB: ohci: da8xx: Add wrappers for platform callbacks

2016-11-23 Thread Axel Haslam
To migrate to a DT based boot, we will remove the use of platform
callbacks, in favor of using the regulator framework to handle
vbus and over current.

In preparation to use a regulator instead of callbacks, move the platform
data callbacks into separate functions. This provides well defined place
to for the regulator API to coexist with the platform callbacks before
all users are converted.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 125 ++
 1 file changed, 102 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index cd75677..aab4e3a 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -81,6 +81,72 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
+static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return hub->set_power(1, on);
+
+   return 0;
+}
+
+static int ohci_da8xx_get_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_power)
+   return hub->get_power(1);
+
+   return 1;
+}
+
+static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return hub->get_oci(1);
+
+   return 0;
+}
+
+static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_potpgt(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->potpgt)
+   return 1;
+
+   return 0;
+}
+
 /*
  * Handle the port over-current indicator change.
  */
@@ -94,6 +160,26 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_register_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   return hub->ocic_notify(ohci_da8xx_ocic_handler);
+
+   return 0;
+}
+
+static void ohci_da8xx_unregister_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   hub->ocic_notify(NULL);
+}
+
 static int ohci_da8xx_reset(struct usb_hcd *hcd)
 {
struct device *dev  = hcd->self.controller;
@@ -127,16 +213,18 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 * the correct hub descriptor...
 */
rh_a = ohci_readl(ohci, >regs->roothub.a);
-   if (hub->set_power) {
+   if (ohci_da8xx_has_set_power(hcd)) {
rh_a &= ~RH_A_NPS;
rh_a |=  RH_A_PSM;
}
-   if (hub->get_oci) {
+   if (ohci_da8xx_has_oci(hcd)) {
rh_a &= ~RH_A_NOCP;
rh_a |=  RH_A_OCPM;
}
-   rh_a &= ~RH_A_POTPGT;
-   rh_a |= hub->potpgt << 24;
+   if (ohci_da8xx_has_potpgt(hcd)) {
+   rh_a &= ~RH_A_POTPGT;
+   rh_a |= hub->potpgt << 24;
+   }
ohci_writel(ohci, rh_a, >regs->roothub.a);
 
return result;
@@ -169,7 +257,6 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
  u16 wIndex, char *buf, u16 wLength)
 {
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
int temp;
 
switch (typeReq) {
@@ -183,11 +270,11 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, 
u16 typeReq, u16 wValue,
temp = roothub_portstatus(hcd_to_ohci(hcd), wIndex - 1);
 
  

[PATCHv7 3/5] USB: ohci: da8xx: Allow a regulator to handle VBUS

2016-11-23 Thread Axel Haslam
Using a regulator to handle VBUS will eliminate the need for
platform data and callbacks, and make the driver more generic
allowing different types of regulators to handle VBUS.

The regulator equivalents to the platform callbacks are:
set_power   ->  regulator_enable/regulator_disable
get_power   ->  regulator_is_enabled
get_oci ->  regulator_get_error_flags
ocic_notify ->  regulator event notification

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 96 +--
 1 file changed, 93 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index aab4e3a..07366ae 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,8 +37,12 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
 struct da8xx_ohci_hcd {
+   struct usb_hcd *hcd;
struct clk *usb11_clk;
struct phy *usb11_phy;
+   struct regulator *vbus_reg;
+   struct notifier_block nb;
+   unsigned int reg_enabled;
 };
 
 #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
@@ -83,56 +88,103 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
 
 static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   int ret;
 
if (hub && hub->set_power)
return hub->set_power(1, on);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   if (on && !da8xx_ohci->reg_enabled) {
+   ret = regulator_enable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Failed to enable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->reg_enabled = 1;
+
+   } else if (!on && da8xx_ohci->reg_enabled) {
+   ret = regulator_disable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Failed  to disable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->reg_enabled = 0;
+   }
+
return 0;
 }
 
 static int ohci_da8xx_get_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_power)
return hub->get_power(1);
 
+   if (da8xx_ohci->vbus_reg)
+   return regulator_is_enabled(da8xx_ohci->vbus_reg);
+
return 1;
 }
 
 static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   unsigned int flags;
+   int ret;
 
if (hub && hub->get_oci)
return hub->get_oci(1);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   ret = regulator_get_error_flags(da8xx_ohci->vbus_reg, );
+   if (ret)
+   return ret;
+
+   if (flags & REGULATOR_ERROR_OVER_CURRENT)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->set_power)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_oci)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
@@ -160,15 +212,39 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_regulator_event(struct notifier_block *nb,
+   unsigned long event, void *data)
+{
+   struct da8xx_ohci_hcd *da8xx_ohci =
+   container_of(nb, struct da8xx_ohci_hcd

[PATCHv7 5/5] USB: ohci: da8xx: Allow probing from DT

2016-11-23 Thread Axel Haslam
This adds the compatible string to the ohci driver
to be able to probe from DT

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 07366ae..1818206 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -394,6 +394,13 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 }
 
 /*-*/
+#ifdef CONFIG_OF
+static const struct of_device_id da8xx_ohci_ids[] = {
+   { .compatible = "ti,da830-ohci" },
+   { }
+};
+MODULE_DEVICE_TABLE(of, da8xx_ohci_ids);
+#endif
 
 static int ohci_da8xx_probe(struct platform_device *pdev)
 {
@@ -546,6 +553,7 @@ static struct platform_driver ohci_hcd_da8xx_driver = {
 #endif
.driver = {
.name   = DRV_NAME,
+   .of_match_table = of_match_ptr(da8xx_ohci_ids),
},
 };
 
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv7 4/5] USB: ohci: da8xx: Add devicetree bindings

2016-11-23 Thread Axel Haslam
This patch documents the device tree bindings required for
the ohci controller found in TI da8xx family of SoC's

Cc: robh...@kernel.org
Cc: mark.rutl...@arm.com
Cc: devicet...@vger.kernel.org
Acked-by: Rob Herring <r...@kernel.org>
Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 .../devicetree/bindings/usb/ohci-da8xx.txt | 23 ++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

diff --git a/Documentation/devicetree/bindings/usb/ohci-da8xx.txt 
b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
new file mode 100644
index 000..2dc8f67
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
@@ -0,0 +1,23 @@
+DA8XX USB OHCI controller
+
+Required properties:
+
+ - compatible: Should be "ti,da830-ohci"
+ - reg:Should contain one register range i.e. start and length
+ - interrupts: Description of the interrupt line
+ - phys:   Phandle for the PHY device
+ - phy-names:  Should be "usb-phy"
+
+Optional properties:
+ - vbus-supply: phandle of regulator that controls vbus power / over-current
+
+Example:
+
+ohci: usb@0225000 {
+compatible = "ti,da830-ohci";
+reg = <0x225000 0x1000>;
+interrupts = <59>;
+phys = <_phy 1>;
+phy-names = "usb-phy";
+vbus-supply = <_usb_ohci>;
+};
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 3/5] USB: ohci: da8xx: Allow a regulator to handle VBUS

2016-11-22 Thread Axel Haslam
On Tue, Nov 22, 2016 at 9:37 PM, David Lechner <da...@lechnology.com> wrote:
> On 11/21/2016 10:30 AM, Axel Haslam wrote:
>>
>> Using a regulator to handle VBUS will eliminate the need for
>> platform data and callbacks, and make the driver more generic
>> allowing different types of regulators to handle VBUS.
>>
>> The regulator equivalents to the platform callbacks are:
>> set_power   ->  regulator_enable/regulator_disable
>> get_power   ->  regulator_is_enabled
>> get_oci ->  regulator_get_error_flags
>> ocic_notify ->  regulator event notification
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>>  drivers/usb/host/ohci-da8xx.c | 97
>> +--
>>  1 file changed, 94 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
>> index 90763ad..d0eb754 100644
>> --- a/drivers/usb/host/ohci-da8xx.c
>> +++ b/drivers/usb/host/ohci-da8xx.c
>> @@ -20,6 +20,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -36,8 +37,12 @@ static int (*orig_ohci_hub_control)(struct usb_hcd
>> *hcd, u16 typeReq,
>>  static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
>>
>>  struct da8xx_ohci_hcd {
>> +   struct usb_hcd *hcd;
>> struct clk *usb11_clk;
>> struct phy *usb11_phy;
>> +   struct regulator *vbus_reg;
>> +   struct notifier_block nb;
>> +   unsigned int reg_enabled;
>>  };
>>
>>  #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd
>> *)(hcd_to_ohci(hcd)->priv)
>> @@ -83,56 +88,103 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
>>
>>  static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
>>  {
>> +   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
>> struct device *dev  = hcd->self.controller;
>> struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
>> +   int ret;
>>
>> if (hub && hub->set_power)
>> return hub->set_power(1, on);
>>
>> +   if (!da8xx_ohci->vbus_reg)
>> +   return 0;
>> +
>> +   if (on && !da8xx_ohci->reg_enabled) {
>> +   ret = regulator_enable(da8xx_ohci->vbus_reg);
>> +   if (ret) {
>> +   dev_err(dev, "Failed to enable regulator: %d\n",
>> ret);
>> +   return ret;
>> +   }
>> +   da8xx_ohci->reg_enabled = 1;
>> +
>> +   } else if (!on && da8xx_ohci->reg_enabled) {
>> +   ret = regulator_disable(da8xx_ohci->vbus_reg);
>> +   if (ret) {
>> +   dev_err(dev, "Failed  to disable regulator: %d\n",
>> ret);
>> +   return ret;
>> +   }
>> +   da8xx_ohci->reg_enabled = 0;
>> +   }
>> +
>> return 0;
>>  }
>>
>>  static int ohci_da8xx_get_power(struct usb_hcd *hcd)
>>  {
>> +   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
>> struct device *dev  = hcd->self.controller;
>> struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
>>
>> if (hub && hub->get_power)
>> return hub->get_power(1);
>>
>> +   if (da8xx_ohci->vbus_reg)
>> +   return regulator_is_enabled(da8xx_ohci->vbus_reg);
>> +
>> return 1;
>>  }
>>
>>  static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
>>  {
>> +   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
>> struct device *dev  = hcd->self.controller;
>> struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
>> +   unsigned int flags;
>> +   int ret;
>>
>> if (hub && hub->get_oci)
>> return hub->get_oci(1);
>>
>> +   if (!da8xx_ohci->vbus_reg)
>> +   return 0;
>> +
>> +   ret = regulator_get_error_flags(da8xx_ohci->vbus_reg, );
>> +   if (ret)
>> +   return ret;
>> +
>> +   if (flags & REGULATOR_ERROR_OVER_CURRENT)
>> +   return 1;
>> +
>> return 0;
>>  }
>>
>>  static int ohci_da8xx_has_set_

Re: [v5,3/5] USB: ohci: da8xx: Allow a regulator to handle VBUS

2016-11-22 Thread Axel Haslam
On Mon, Nov 21, 2016 at 5:29 PM, David Lechner <da...@lechnology.com> wrote:
> On 11/21/2016 04:22 AM, Axel Haslam wrote:
>>
>> Hi David,
>>
>> Thanks for the review,
>>
>
> You're welcome.
>
>>>>
>>>> @@ -160,15 +212,41 @@ static void ohci_da8xx_ocic_handler(struct
>>>> da8xx_ohci_root_hub *hub,
>>>> hub->set_power(port, 0);
>>>>  }
>>>>
>>>> +static int ohci_da8xx_regulator_event(struct notifier_block *nb,
>>>> +   unsigned long event, void *data)
>>>> +{
>>>> +   struct da8xx_ohci_hcd *da8xx_ohci =
>>>> +   container_of(nb, struct da8xx_ohci_hcd,
>>>> nb);
>>>> +   struct device *dev = da8xx_ohci->hcd->self.controller;
>>>> +
>>>> +   if (event & REGULATOR_EVENT_OVER_CURRENT) {
>>>> +   dev_warn(dev, "over current event\n");
>>>
>>>
>>>
>>> Won't this result in duplicate overcurrent warnings in the kernel log? It
>>> seems like in previous version of this patch series, we would get an
>>> overcurrent error from the core usb driver.
>>
>>
>> you mean in the regulator driver? i did not make changes to core usb.
>> but, no,  i did not add a print in the fixed regulator driver itself.
>> Since
>> the regulator is  a separate driver, and could be implemented with or
>> without
>> a trace, i think its better to leave this print. It shows that the usb
>> driver
>> has well received the notification.
>>
>
> No, I mean in drivers/usb/core/hub.c. There is
>
> if (status & USB_PORT_STAT_OVERCURRENT)
> dev_err(_dev->dev, "over-current condition\n");
>
> and
>
> if (status & HUB_STATUS_OVERCURRENT)
> dev_err(hub_dev, "over-current condition\n");
>
> In ohci_da8xx_hub_control(), we are setting RH_PS_POCI and RH_PS_OCIC, so
> these messages will be printed via the core hub driver. We don't need to
> print another message from the same event.
>
>

Hi David

I did a couple of tests, and i don't get those prints do you get them?.
What i understand is that they happen when we get a hub event that is
reporting the over current. Which is what the root hub of the davinci system
does not have, and why we use gpios instead).

Regards,
Axel.

>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/3] usb: ohci-da8xx: rename driver to ohci-da8xx

2016-11-21 Thread Axel Haslam
Hi Greg,

On Thu, Nov 3, 2016 at 5:03 PM, Axel Haslam <ahas...@baylibre.com> wrote:
> The davinci ohci driver name (currently "ohci") is too generic.
> To be consistent with other usb dirvers, append the "-da8xx" postfix
> to the name.
>

if there are no objections, would it be possible to pick up this patch?
the corresponding phy patch was merged and the platform changes
are ack'ed, and will we taken by the davinci maintainer once this patch
gets in.

i can resend stand-alone if its preferred.

Regards
Axel

> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
> ---
>  drivers/usb/host/ohci-da8xx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
> index 30c4878..429d58b 100644
> --- a/drivers/usb/host/ohci-da8xx.c
> +++ b/drivers/usb/host/ohci-da8xx.c
> @@ -27,7 +27,7 @@
>  #include "ohci.h"
>
>  #define DRIVER_DESC "DA8XX"
> -#define DRV_NAME "ohci"
> +#define DRV_NAME "ohci-da8xx"
>
>  static struct hc_driver __read_mostly ohci_da8xx_hc_driver;
>
> --
> 2.10.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 1/5] USB: ohci: da8xx: use ohci priv data instead of globals

2016-11-21 Thread Axel Haslam
Instead of global variables, use the extra_priv_size of
the ohci driver.

We cannot yet move the ocic mask because this is used on
the interrupt handler which is registerded through platform
data and does not have an hcd pointer. This will be moved
on a later patch.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 73 +--
 1 file changed, 43 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index b3de8bc..aa6f904f 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -35,43 +35,50 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
u16 wValue, u16 wIndex, char *buf, u16 wLength);
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
-static struct clk *usb11_clk;
-static struct phy *usb11_phy;
+struct da8xx_ohci_hcd {
+   struct clk *usb11_clk;
+   struct phy *usb11_phy;
+};
+
+#define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
 /* Over-current indicator change bitmask */
 static volatile u16 ocic_mask;
 
-static int ohci_da8xx_enable(void)
+static int ohci_da8xx_enable(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
int ret;
 
-   ret = clk_prepare_enable(usb11_clk);
+   ret = clk_prepare_enable(da8xx_ohci->usb11_clk);
if (ret)
return ret;
 
-   ret = phy_init(usb11_phy);
+   ret = phy_init(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_init;
 
-   ret = phy_power_on(usb11_phy);
+   ret = phy_power_on(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_power_on;
 
return 0;
 
 err_phy_power_on:
-   phy_exit(usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
 err_phy_init:
-   clk_disable_unprepare(usb11_clk);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 
return ret;
 }
 
-static void ohci_da8xx_disable(void)
+static void ohci_da8xx_disable(struct usb_hcd *hcd)
 {
-   phy_power_off(usb11_phy);
-   phy_exit(usb11_phy);
-   clk_disable_unprepare(usb11_clk);
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
+
+   phy_power_off(da8xx_ohci->usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
 /*
@@ -97,7 +104,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
dev_dbg(dev, "starting USB controller\n");
 
-   result = ohci_da8xx_enable();
+   result = ohci_da8xx_enable(hcd);
if (result < 0)
return result;
 
@@ -109,7 +116,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
result = ohci_setup(hcd);
if (result < 0) {
-   ohci_da8xx_disable();
+   ohci_da8xx_disable(hcd);
return result;
}
 
@@ -231,6 +238,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 static int ohci_da8xx_probe(struct platform_device *pdev)
 {
struct da8xx_ohci_root_hub *hub = dev_get_platdata(>dev);
+   struct da8xx_ohci_hcd *da8xx_ohci;
struct usb_hcd  *hcd;
struct resource *mem;
int error, irq;
@@ -238,25 +246,29 @@ static int ohci_da8xx_probe(struct platform_device *pdev)
if (hub == NULL)
return -ENODEV;
 
-   usb11_clk = devm_clk_get(>dev, "usb11");
-   if (IS_ERR(usb11_clk)) {
-   if (PTR_ERR(usb11_clk) != -EPROBE_DEFER)
+   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
+   dev_name(>dev));
+   if (!hcd)
+   return -ENOMEM;
+
+   da8xx_ohci = to_da8xx_ohci(hcd);
+
+   da8xx_ohci->usb11_clk = devm_clk_get(>dev, "usb11");
+   if (IS_ERR(da8xx_ohci->usb11_clk)) {
+   error = PTR_ERR(da8xx_ohci->usb11_clk);
+   if (error != -EPROBE_DEFER)
dev_err(>dev, "Failed to get clock.\n");
-   return PTR_ERR(usb11_clk);
+   goto err;
}
 
-   usb11_phy = devm_phy_get(>dev, "usb-phy");
-   if (IS_ERR(usb11_phy)) {
-   if (PTR_ERR(usb11_phy) != -EPROBE_DEFER)
+   da8xx_ohci->usb11_phy = devm_phy_get(>dev, "usb-phy");
+   if (IS_ERR(da8xx_ohci->usb11_phy)) {
+   error = PTR_ERR(da8xx_ohci->usb11_phy);
+   if (error != -EPROBE_DEFER)
dev_err(>dev, "Failed to get phy.\n");
-   return PTR_ERR(usb11_phy);
+   goto err;
}
 
-   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
-   dev_name(>dev));
-   if (!hcd)
-   return -ENOMEM;
-
mem = platform_get_resource(pd

[PATCH v6 3/5] USB: ohci: da8xx: Allow a regulator to handle VBUS

2016-11-21 Thread Axel Haslam
Using a regulator to handle VBUS will eliminate the need for
platform data and callbacks, and make the driver more generic
allowing different types of regulators to handle VBUS.

The regulator equivalents to the platform callbacks are:
set_power   ->  regulator_enable/regulator_disable
get_power   ->  regulator_is_enabled
get_oci ->  regulator_get_error_flags
ocic_notify ->  regulator event notification

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 97 +--
 1 file changed, 94 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 90763ad..d0eb754 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,8 +37,12 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
 struct da8xx_ohci_hcd {
+   struct usb_hcd *hcd;
struct clk *usb11_clk;
struct phy *usb11_phy;
+   struct regulator *vbus_reg;
+   struct notifier_block nb;
+   unsigned int reg_enabled;
 };
 
 #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
@@ -83,56 +88,103 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
 
 static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   int ret;
 
if (hub && hub->set_power)
return hub->set_power(1, on);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   if (on && !da8xx_ohci->reg_enabled) {
+   ret = regulator_enable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Failed to enable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->reg_enabled = 1;
+
+   } else if (!on && da8xx_ohci->reg_enabled) {
+   ret = regulator_disable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Failed  to disable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->reg_enabled = 0;
+   }
+
return 0;
 }
 
 static int ohci_da8xx_get_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_power)
return hub->get_power(1);
 
+   if (da8xx_ohci->vbus_reg)
+   return regulator_is_enabled(da8xx_ohci->vbus_reg);
+
return 1;
 }
 
 static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   unsigned int flags;
+   int ret;
 
if (hub && hub->get_oci)
return hub->get_oci(1);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   ret = regulator_get_error_flags(da8xx_ohci->vbus_reg, );
+   if (ret)
+   return ret;
+
+   if (flags & REGULATOR_ERROR_OVER_CURRENT)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->set_power)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_oci)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
@@ -160,15 +212,41 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_regulator_event(struct notifier_block *nb,
+   unsigned long event, void *data)
+{
+   struct da8xx_ohci_hcd *da8xx_ohci =
+   container_of(nb, struct da8xx_o

[PATCH v6 5/5] USB: ohci: da8xx: Allow probing from DT

2016-11-21 Thread Axel Haslam
This adds the compatible string to the ohci driver
to be able to probe from DT

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index d0eb754..8b7479b 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -396,6 +396,13 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 }
 
 /*-*/
+#ifdef CONFIG_OF
+static const struct of_device_id da8xx_ohci_ids[] = {
+   { .compatible = "ti,da830-ohci" },
+   { }
+};
+MODULE_DEVICE_TABLE(of, da8xx_ohci_ids);
+#endif
 
 static int ohci_da8xx_probe(struct platform_device *pdev)
 {
@@ -547,6 +554,7 @@ static struct platform_driver ohci_hcd_da8xx_driver = {
 #endif
.driver = {
.name   = DRV_NAME,
+   .of_match_table = of_match_ptr(da8xx_ohci_ids),
},
 };
 
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 0/5] USB: ohci-da8xx: Add device tree support

2016-11-21 Thread Axel Haslam
When booting using device tree, we can not make use of
platform callbacks to handle vbus and over current gpios.

This series allows the ohci-da8xx driver to use a regulator
instead of the platform callbacks to control vbus and adds
the device tree bindings to be able to probe using DT.

Once all users of the platform callbacks will be converted to
use a regulator, we will be able to remove platform data completely.

Changes from v5->v6
* Fix regulator over current flag check (David)
* Spelling fixes and code cleanups (David)
* add Ack for device tree binding

Changes from v4->v5
* Append the Device tree patches to v4.
* Submit only the first part of the series (no dependencies).
this can be applied and merged through the usb tree.

Changes from v3->v4
* separate the series into smaller series for driver and arch/arm code,
  to ease review and merging to different trees.

Changes form v2->v3
* drop patches that have been integrated to arch/arm
* drop regulator patches which will be integrated through regulator tree
* use of the accepted regulator API to get over current status
* better patch separation with the use of wrappers

Changes from v1->v2
* Rebased and added patch to make ohci a separate driver
* Use a regulator instead of handling Gpios (David Lechner)
* Add an over current mode to regulator framework
* Fixed regulator is able to register for and over current irq
* Added patch by Alexandre to remove build warnings
* Moved global variables into private hcd structure.
Axel Haslam (5):
  USB: ohci: da8xx: use ohci priv data instead of globals
  USB: ohci: da8xx: Add wrappers for platform callbacks
  USB: ohci: da8xx: Allow a regulator to handle VBUS
  USB: ohci: da8xx: Add devicetree bindings
  USB: ohci: da8xx: Allow probing from DT

 .../devicetree/bindings/usb/ohci-da8xx.txt |  23 ++
 drivers/usb/host/ohci-da8xx.c  | 291 +
 2 files changed, 264 insertions(+), 50 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 2/5] USB: ohci: da8xx: Add wrappers for platform callbacks

2016-11-21 Thread Axel Haslam
To migrate to a DT based boot, we will remove the use of platform
callbacks, in favor of using the regulator framework to handle
vbus and over current.

In preparation to use a regulator instead of callbacks, move the platform
data callbacks into separate functions. This provides well defined place
to for the regulator API to coexist with the platform callbacks before
all users are converted.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 125 ++
 1 file changed, 102 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index aa6f904f..90763ad 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -81,6 +81,72 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
+static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return hub->set_power(1, on);
+
+   return 0;
+}
+
+static int ohci_da8xx_get_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_power)
+   return hub->get_power(1);
+
+   return 1;
+}
+
+static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return hub->get_oci(1);
+
+   return 0;
+}
+
+static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_potpgt(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->potpgt)
+   return 1;
+
+   return 0;
+}
+
 /*
  * Handle the port over-current indicator change.
  */
@@ -94,6 +160,26 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_register_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   return hub->ocic_notify(ohci_da8xx_ocic_handler);
+
+   return 0;
+}
+
+static void ohci_da8xx_unregister_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   hub->ocic_notify(NULL);
+}
+
 static int ohci_da8xx_reset(struct usb_hcd *hcd)
 {
struct device *dev  = hcd->self.controller;
@@ -127,16 +213,18 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 * the correct hub descriptor...
 */
rh_a = ohci_readl(ohci, >regs->roothub.a);
-   if (hub->set_power) {
+   if (ohci_da8xx_has_set_power(hcd)) {
rh_a &= ~RH_A_NPS;
rh_a |=  RH_A_PSM;
}
-   if (hub->get_oci) {
+   if (ohci_da8xx_has_oci(hcd)) {
rh_a &= ~RH_A_NOCP;
rh_a |=  RH_A_OCPM;
}
-   rh_a &= ~RH_A_POTPGT;
-   rh_a |= hub->potpgt << 24;
+   if (ohci_da8xx_has_potpgt(hcd)) {
+   rh_a &= ~RH_A_POTPGT;
+   rh_a |= hub->potpgt << 24;
+   }
ohci_writel(ohci, rh_a, >regs->roothub.a);
 
return result;
@@ -169,7 +257,6 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
  u16 wIndex, char *buf, u16 wLength)
 {
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
int temp;
 
switch (typeReq) {
@@ -183,11 +270,11 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, 
u16 typeReq, u16 wValue,
temp = roothub_portstatus(hcd_to_ohci(hcd), wIndex - 1);
 
  

[PATCH v6 4/5] USB: ohci: da8xx: Add devicetree bindings

2016-11-21 Thread Axel Haslam
This patch documents the device tree bindings required for
the ohci controller found in TI da8xx family of SoC's

Cc: robh...@kernel.org
Cc: mark.rutl...@arm.com
Cc: devicet...@vger.kernel.org
Acked-by: Rob Herring <r...@kernel.org>
Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 .../devicetree/bindings/usb/ohci-da8xx.txt | 23 ++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

diff --git a/Documentation/devicetree/bindings/usb/ohci-da8xx.txt 
b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
new file mode 100644
index 000..2dc8f67
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
@@ -0,0 +1,23 @@
+DA8XX USB OHCI controller
+
+Required properties:
+
+ - compatible: Should be "ti,da830-ohci"
+ - reg:Should contain one register range i.e. start and length
+ - interrupts: Description of the interrupt line
+ - phys:   Phandle for the PHY device
+ - phy-names:  Should be "usb-phy"
+
+Optional properties:
+ - vbus-supply: phandle of regulator that controls vbus power / over-current
+
+Example:
+
+ohci: usb@0225000 {
+compatible = "ti,da830-ohci";
+reg = <0x225000 0x1000>;
+interrupts = <59>;
+phys = <_phy 1>;
+phy-names = "usb-phy";
+vbus-supply = <_usb_ohci>;
+};
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 10/10] ARM: dts: da850: add usb device node

2016-11-21 Thread Axel Haslam
On Mon, Nov 21, 2016 at 11:49 AM, Sekhar Nori  wrote:
> On Monday 21 November 2016 04:16 PM, Sekhar Nori wrote:
 In commit 2957e36e76c836b167e5e0c1edb578d8a9bd7af6 in the linux-davinci
 >> tree, the alias for the musb device is usb0. So, I think we should use 
 >> usb1
 >> here instead of ohci - or change the usb0 alias to musb.
 >>
 >> https://git.kernel.org/cgit/linux/kernel/git/nsekhar/linux-davinci.git/commit/?h=v4.10/dt=2957e36e76c836b167e5e0c1edb578d8a9bd7af6
>>> >
>>> > ok, i will change to usb1, since i will be resubmiting this.
>
>> I have already applied a version of this patch. Please re-base against
>> linux-davinci/master and send a delta patch.
>
> Hmm, no. scratch that. I mixed this up with the musb patch I applied.
> usb1 sounds good. Please also separate out the soc and board specific
> dts additions for your next version.

Ok will do.


>
> Thanks,
> Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 10/10] ARM: dts: da850: add usb device node

2016-11-21 Thread Axel Haslam
On Mon, Nov 21, 2016 at 3:42 AM, David Lechner <da...@lechnology.com> wrote:
> On 11/07/2016 02:39 PM, Axel Haslam wrote:
>>
>> This adds the ohci device node for the da850 soc.
>> It also enables it for the omapl138 hawk board.
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>>  arch/arm/boot/dts/da850-lcdk.dts | 8 
>>  arch/arm/boot/dts/da850.dtsi | 8 
>>  2 files changed, 16 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/da850-lcdk.dts
>> b/arch/arm/boot/dts/da850-lcdk.dts
>> index 7b8ab21..aaf533e 100644
>> --- a/arch/arm/boot/dts/da850-lcdk.dts
>> +++ b/arch/arm/boot/dts/da850-lcdk.dts
>> @@ -86,6 +86,14 @@
>> };
>>  };
>>
>> +_phy {
>> +   status = "okay";
>> +};
>> +
>> + {
>> +   status = "okay";
>> +};
>> +
>>   {
>> pinctrl-names = "default";
>> pinctrl-0 = <_rxtx_pins>;
>> diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
>> index 2534aab..50e86da 100644
>> --- a/arch/arm/boot/dts/da850.dtsi
>> +++ b/arch/arm/boot/dts/da850.dtsi
>> @@ -405,6 +405,14 @@
>> >;
>> status = "disabled";
>> };
>> +   ohci: usb@0225000 {
>
>
> In commit 2957e36e76c836b167e5e0c1edb578d8a9bd7af6 in the linux-davinci
> tree, the alias for the musb device is usb0. So, I think we should use usb1
> here instead of ohci - or change the usb0 alias to musb.
>
> https://git.kernel.org/cgit/linux/kernel/git/nsekhar/linux-davinci.git/commit/?h=v4.10/dt=2957e36e76c836b167e5e0c1edb578d8a9bd7af6

ok, i will change to usb1, since i will be resubmiting this.

>
>> +   compatible = "ti,da830-ohci";
>> +   reg = <0x225000 0x1000>;
>> +   interrupts = <59>;
>> +   phys = <_phy 1>;
>> +   phy-names = "usb-phy";
>> +   status = "disabled";
>> +   };
>> gpio: gpio@226000 {
>> compatible = "ti,dm6441-gpio";
>> gpio-controller;
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [v5,3/5] USB: ohci: da8xx: Allow a regulator to handle VBUS

2016-11-21 Thread Axel Haslam
Hi David,

Thanks for the review,


On Sun, Nov 20, 2016 at 4:31 AM, David Lechner <da...@lechnology.com> wrote:
> On 11/14/2016 08:41 AM, ahas...@baylibre.com wrote:
>>
>> Using a regulator to handle VBUS will eliminate the need for
>> platform data and callbacks, and make the driver more generic
>> allowing different types of regulators to handle VBUS.
>>
>> The regulator equivalents to the platform callbacks are:
>> set_power   ->  regulator_enable/regulator_disable
>> get_power   ->  regulator_is_enabled
>> get_oci ->  regulator_get_error_flags
>> ocic_notify ->  regulator event notification
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>>  drivers/usb/host/ohci-da8xx.c | 95
>> ++-
>>  1 file changed, 93 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
>> index 83e3c98..42eaeb9 100644
>> --- a/drivers/usb/host/ohci-da8xx.c
>> +++ b/drivers/usb/host/ohci-da8xx.c
>> @@ -20,6 +20,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -36,8 +37,12 @@ static int (*orig_ohci_hub_control)(struct usb_hcd
>> *hcd, u16 typeReq,
>>  static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
>>
>>  struct da8xx_ohci_hcd {
>> +   struct usb_hcd *hcd;
>> struct clk *usb11_clk;
>> struct phy *usb11_phy;
>> +   struct regulator *vbus_reg;
>> +   struct notifier_block nb;
>> +   unsigned int is_powered;
>
>
> Since is_powered is only used to indicate if we have called
> regulator_enable(), I think it would make more sense to name it reg_enabled
> instead.

ok.

>
>>  };
>>
>>  #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd
>> *)(hcd_to_ohci(hcd)->priv)
>> @@ -83,56 +88,103 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
>>
>>  static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
>>  {
>> +   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
>> struct device *dev  = hcd->self.controller;
>> struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
>> +   int ret;
>>
>> if (hub && hub->set_power)
>> return hub->set_power(1, on);
>>
>> +   if (!da8xx_ohci->vbus_reg)
>> +   return 0;
>> +
>> +   if (on && !da8xx_ohci->is_powered) {
>> +   ret = regulator_enable(da8xx_ohci->vbus_reg);
>> +   if (ret) {
>> +   dev_err(dev, "Fail to enable regulator: %d\n",
>> ret);
>
>
> s/Fail/Failed/

will fix in both places.

>
>> +   return ret;
>> +   }
>> +   da8xx_ohci->is_powered = 1;
>> +
>> +   } else if (!on && da8xx_ohci->is_powered) {
>> +   ret = regulator_disable(da8xx_ohci->vbus_reg);
>> +   if (ret) {
>> +   dev_err(dev, "Fail to disable regulator: %d\n",
>> ret);
>
>
> s/Fail/Failed/
>
>> +   return ret;
>> +   }
>> +   da8xx_ohci->is_powered = 0;
>> +   }
>> +
>> return 0;
>>  }
>>
>>  static int ohci_da8xx_get_power(struct usb_hcd *hcd)
>>  {
>> +   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
>> struct device *dev  = hcd->self.controller;
>> struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
>>
>> if (hub && hub->get_power)
>> return hub->get_power(1);
>>
>> +   if (da8xx_ohci->vbus_reg)
>> +   return regulator_is_enabled(da8xx_ohci->vbus_reg);
>> +
>> return 1;
>>  }
>>
>>  static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
>>  {
>> +   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
>> struct device *dev  = hcd->self.controller;
>> struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
>> +   unsigned int flags;
>> +   int ret;
>>
>> if (hub && hub->get_oci)
>> return hub->get_oci(1);
>>
>> +   if (!da8xx_ohci->vbus_reg)
>> +   return 0;
>> +
>> +   ret = reg

Re: [v5,1/5] USB: ohci: da8xx: use ohci priv data instead of globals

2016-11-21 Thread Axel Haslam
On Sun, Nov 20, 2016 at 3:58 AM, David Lechner <da...@lechnology.com> wrote:
> On 11/14/2016 08:40 AM, ahas...@baylibre.com wrote:
>>
>> Instead of global variables, use the extra_priv_size of
>> the ohci driver.
>>
>> We cannot yet move the ocic mask because this is used on
>> the interrupt handler which is registerded through platform
>> data and does not have an hcd pointer. This will be moved
>> on a later patch.
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>>  drivers/usb/host/ohci-da8xx.c | 73
>> +--
>>  1 file changed, 43 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
>> index b3de8bc..438970b 100644
>> --- a/drivers/usb/host/ohci-da8xx.c
>> +++ b/drivers/usb/host/ohci-da8xx.c
>
> ...
>>
>> @@ -238,25 +246,29 @@ static int ohci_da8xx_probe(struct platform_device
>> *pdev)
>> if (hub == NULL)
>> return -ENODEV;
>>
>> -   usb11_clk = devm_clk_get(>dev, "usb11");
>> -   if (IS_ERR(usb11_clk)) {
>> -   if (PTR_ERR(usb11_clk) != -EPROBE_DEFER)
>> +   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
>> +   dev_name(>dev));
>> +   if (!hcd)
>> +   return -ENOMEM;
>> +
>> +   da8xx_ohci = to_da8xx_ohci(hcd);
>> +
>> +   da8xx_ohci->usb11_clk = devm_clk_get(>dev, "usb11");
>> +   if (IS_ERR(da8xx_ohci->usb11_clk)) {
>> +   if (PTR_ERR(da8xx_ohci->usb11_clk) != -EPROBE_DEFER)
>> dev_err(>dev, "Failed to get clock.\n");
>> -   return PTR_ERR(usb11_clk);
>> +   error = PTR_ERR(da8xx_ohci->usb11_clk);
>> +   goto err;
>> }
>
>
> Small thing, but this could be written slightly cleaner as:
>
> da8xx_ohci->usb11_clk = devm_clk_get(>dev, "usb11");
> if (IS_ERR(da8xx_ohci->usb11_clk)) {
> error = PTR_ERR(da8xx_ohci->usb11_clk);
> if (error != -EPROBE_DEFER)
> dev_err(>dev, "Failed to get clock.\n");
> goto err;
> }
>

Yes, right, i will change it,
Thanks.

>>
>> -   usb11_phy = devm_phy_get(>dev, "usb-phy");
>> -   if (IS_ERR(usb11_phy)) {
>> -   if (PTR_ERR(usb11_phy) != -EPROBE_DEFER)
>> +   da8xx_ohci->usb11_phy = devm_phy_get(>dev, "usb-phy");
>> +   if (IS_ERR(da8xx_ohci->usb11_phy)) {
>> +   if (PTR_ERR(da8xx_ohci->usb11_phy) != -EPROBE_DEFER)
>> dev_err(>dev, "Failed to get phy.\n");
>> -   return PTR_ERR(usb11_phy);
>> +   error = PTR_ERR(da8xx_ohci->usb11_phy);
>> +   goto err;
>> }
>
>
> same here
>
> ...
>
>
> Tested-by: David Lechner <da...@lechnology.com>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 4/5] USB: ohci: da8xx: Add devicetree bindings

2016-11-14 Thread Axel Haslam
This patch documents the device tree bindings required for
the ohci controller found in TI da8xx family of SoC's

Cc: robh...@kernel.org
Cc: mark.rutl...@arm.com
Cc: devicet...@vger.kernel.org
Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 .../devicetree/bindings/usb/ohci-da8xx.txt | 23 ++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

diff --git a/Documentation/devicetree/bindings/usb/ohci-da8xx.txt 
b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
new file mode 100644
index 000..2dc8f67
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
@@ -0,0 +1,23 @@
+DA8XX USB OHCI controller
+
+Required properties:
+
+ - compatible: Should be "ti,da830-ohci"
+ - reg:Should contain one register range i.e. start and length
+ - interrupts: Description of the interrupt line
+ - phys:   Phandle for the PHY device
+ - phy-names:  Should be "usb-phy"
+
+Optional properties:
+ - vbus-supply: phandle of regulator that controls vbus power / over-current
+
+Example:
+
+ohci: usb@0225000 {
+compatible = "ti,da830-ohci";
+reg = <0x225000 0x1000>;
+interrupts = <59>;
+phys = <_phy 1>;
+phy-names = "usb-phy";
+vbus-supply = <_usb_ohci>;
+};
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 1/5] USB: ohci: da8xx: use ohci priv data instead of globals

2016-11-14 Thread Axel Haslam
Instead of global variables, use the extra_priv_size of
the ohci driver.

We cannot yet move the ocic mask because this is used on
the interrupt handler which is registerded through platform
data and does not have an hcd pointer. This will be moved
on a later patch.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 73 +--
 1 file changed, 43 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index b3de8bc..438970b 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -35,43 +35,50 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
u16 wValue, u16 wIndex, char *buf, u16 wLength);
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
-static struct clk *usb11_clk;
-static struct phy *usb11_phy;
+struct da8xx_ohci_hcd {
+   struct clk *usb11_clk;
+   struct phy *usb11_phy;
+};
+
+#define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
 /* Over-current indicator change bitmask */
 static volatile u16 ocic_mask;
 
-static int ohci_da8xx_enable(void)
+static int ohci_da8xx_enable(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
int ret;
 
-   ret = clk_prepare_enable(usb11_clk);
+   ret = clk_prepare_enable(da8xx_ohci->usb11_clk);
if (ret)
return ret;
 
-   ret = phy_init(usb11_phy);
+   ret = phy_init(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_init;
 
-   ret = phy_power_on(usb11_phy);
+   ret = phy_power_on(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_power_on;
 
return 0;
 
 err_phy_power_on:
-   phy_exit(usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
 err_phy_init:
-   clk_disable_unprepare(usb11_clk);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 
return ret;
 }
 
-static void ohci_da8xx_disable(void)
+static void ohci_da8xx_disable(struct usb_hcd *hcd)
 {
-   phy_power_off(usb11_phy);
-   phy_exit(usb11_phy);
-   clk_disable_unprepare(usb11_clk);
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
+
+   phy_power_off(da8xx_ohci->usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
 /*
@@ -97,7 +104,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
dev_dbg(dev, "starting USB controller\n");
 
-   result = ohci_da8xx_enable();
+   result = ohci_da8xx_enable(hcd);
if (result < 0)
return result;
 
@@ -109,7 +116,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
result = ohci_setup(hcd);
if (result < 0) {
-   ohci_da8xx_disable();
+   ohci_da8xx_disable(hcd);
return result;
}
 
@@ -231,6 +238,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 static int ohci_da8xx_probe(struct platform_device *pdev)
 {
struct da8xx_ohci_root_hub *hub = dev_get_platdata(>dev);
+   struct da8xx_ohci_hcd *da8xx_ohci;
struct usb_hcd  *hcd;
struct resource *mem;
int error, irq;
@@ -238,25 +246,29 @@ static int ohci_da8xx_probe(struct platform_device *pdev)
if (hub == NULL)
return -ENODEV;
 
-   usb11_clk = devm_clk_get(>dev, "usb11");
-   if (IS_ERR(usb11_clk)) {
-   if (PTR_ERR(usb11_clk) != -EPROBE_DEFER)
+   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
+   dev_name(>dev));
+   if (!hcd)
+   return -ENOMEM;
+
+   da8xx_ohci = to_da8xx_ohci(hcd);
+
+   da8xx_ohci->usb11_clk = devm_clk_get(>dev, "usb11");
+   if (IS_ERR(da8xx_ohci->usb11_clk)) {
+   if (PTR_ERR(da8xx_ohci->usb11_clk) != -EPROBE_DEFER)
dev_err(>dev, "Failed to get clock.\n");
-   return PTR_ERR(usb11_clk);
+   error = PTR_ERR(da8xx_ohci->usb11_clk);
+   goto err;
}
 
-   usb11_phy = devm_phy_get(>dev, "usb-phy");
-   if (IS_ERR(usb11_phy)) {
-   if (PTR_ERR(usb11_phy) != -EPROBE_DEFER)
+   da8xx_ohci->usb11_phy = devm_phy_get(>dev, "usb-phy");
+   if (IS_ERR(da8xx_ohci->usb11_phy)) {
+   if (PTR_ERR(da8xx_ohci->usb11_phy) != -EPROBE_DEFER)
dev_err(>dev, "Failed to get phy.\n");
-   return PTR_ERR(usb11_phy);
+   error = PTR_ERR(da8xx_ohci->usb11_phy);
+   goto err;
}
 
-   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
-   dev_name(>dev));
-   if (!hcd)
-   

[PATCH v5 2/5] USB: ohci: da8xx: Add wrappers for platform callbacks

2016-11-14 Thread Axel Haslam
In preparation to use a regulator instead of platform callbacks,
move the platform callbacks into separate functions.

This provides a well defined place to for the regulator API to coexist
with the callbacks until all users are converted, and the callbacks
can be removed.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 125 ++
 1 file changed, 102 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 438970b..83e3c98 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -81,6 +81,72 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
+static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return hub->set_power(1, on);
+
+   return 0;
+}
+
+static int ohci_da8xx_get_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_power)
+   return hub->get_power(1);
+
+   return 1;
+}
+
+static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return hub->get_oci(1);
+
+   return 0;
+}
+
+static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_potpgt(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->potpgt)
+   return 1;
+
+   return 0;
+}
+
 /*
  * Handle the port over-current indicator change.
  */
@@ -94,6 +160,26 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_register_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   return hub->ocic_notify(ohci_da8xx_ocic_handler);
+
+   return 0;
+}
+
+static void ohci_da8xx_unregister_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   hub->ocic_notify(NULL);
+}
+
 static int ohci_da8xx_reset(struct usb_hcd *hcd)
 {
struct device *dev  = hcd->self.controller;
@@ -127,16 +213,18 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 * the correct hub descriptor...
 */
rh_a = ohci_readl(ohci, >regs->roothub.a);
-   if (hub->set_power) {
+   if (ohci_da8xx_has_set_power(hcd)) {
rh_a &= ~RH_A_NPS;
rh_a |=  RH_A_PSM;
}
-   if (hub->get_oci) {
+   if (ohci_da8xx_has_oci(hcd)) {
rh_a &= ~RH_A_NOCP;
rh_a |=  RH_A_OCPM;
}
-   rh_a &= ~RH_A_POTPGT;
-   rh_a |= hub->potpgt << 24;
+   if (ohci_da8xx_has_potpgt(hcd)) {
+   rh_a &= ~RH_A_POTPGT;
+   rh_a |= hub->potpgt << 24;
+   }
ohci_writel(ohci, rh_a, >regs->roothub.a);
 
return result;
@@ -169,7 +257,6 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
  u16 wIndex, char *buf, u16 wLength)
 {
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
int temp;
 
switch (typeReq) {
@@ -183,11 +270,11 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, 
u16 typeReq, u16 wValue,
temp = roothub_portstatus(hcd_to_ohci(hcd), wIndex - 1);
 
/* The port power status (PPS) bit defaults to 1 */
-   if (hub->get_power && hub->get_power(wIndex

[PATCH v5 3/5] USB: ohci: da8xx: Allow a regulator to handle VBUS

2016-11-14 Thread Axel Haslam
Using a regulator to handle VBUS will eliminate the need for
platform data and callbacks, and make the driver more generic
allowing different types of regulators to handle VBUS.

The regulator equivalents to the platform callbacks are:
set_power   ->  regulator_enable/regulator_disable
get_power   ->  regulator_is_enabled
get_oci ->  regulator_get_error_flags
ocic_notify ->  regulator event notification

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 95 ++-
 1 file changed, 93 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 83e3c98..42eaeb9 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,8 +37,12 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
 struct da8xx_ohci_hcd {
+   struct usb_hcd *hcd;
struct clk *usb11_clk;
struct phy *usb11_phy;
+   struct regulator *vbus_reg;
+   struct notifier_block nb;
+   unsigned int is_powered;
 };
 
 #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
@@ -83,56 +88,103 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
 
 static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   int ret;
 
if (hub && hub->set_power)
return hub->set_power(1, on);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   if (on && !da8xx_ohci->is_powered) {
+   ret = regulator_enable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Fail to enable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->is_powered = 1;
+
+   } else if (!on && da8xx_ohci->is_powered) {
+   ret = regulator_disable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Fail to disable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->is_powered = 0;
+   }
+
return 0;
 }
 
 static int ohci_da8xx_get_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_power)
return hub->get_power(1);
 
+   if (da8xx_ohci->vbus_reg)
+   return regulator_is_enabled(da8xx_ohci->vbus_reg);
+
return 1;
 }
 
 static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   unsigned int flags;
+   int ret;
 
if (hub && hub->get_oci)
return hub->get_oci(1);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   ret = regulator_get_error_flags(da8xx_ohci->vbus_reg, );
+   if (ret)
+   return ret;
+
+   if (flags && REGULATOR_ERROR_OVER_CURRENT)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->set_power)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_oci)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
@@ -160,15 +212,41 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_regulator_event(struct notifier_block *nb,
+   unsigned long event, void *data)
+{
+   struct da8xx_ohci_hcd *da8xx_ohci =
+   container_of(nb, struct da8

[PATCH v5 5/5] USB: ohci: da8xx: Allow probing from DT

2016-11-14 Thread Axel Haslam
This adds the compatible string to the ohci driver
to be able to probe from DT

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 42eaeb9..b761b2b 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -396,6 +396,13 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 }
 
 /*-*/
+#ifdef CONFIG_OF
+static const struct of_device_id da8xx_ohci_ids[] = {
+   { .compatible = "ti,da830-ohci" },
+   { }
+};
+MODULE_DEVICE_TABLE(of, da8xx_ohci_ids);
+#endif
 
 static int ohci_da8xx_probe(struct platform_device *pdev)
 {
@@ -547,6 +554,7 @@ static struct platform_driver ohci_hcd_da8xx_driver = {
 #endif
.driver = {
.name   = DRV_NAME,
+   .of_match_table = of_match_ptr(da8xx_ohci_ids),
},
 };
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 0/5] USB: ohci-da8xx: Add device tree support

2016-11-14 Thread Axel Haslam
When booting using device tree, we can not make use of
platform callbacks to handle vbus and over current gpios.

This series allows the ohci-da8xx driver to use a regulator
instead of the platform callbacks to control vbus and adds
the device tree bindings to be able to probe using DT.

Once all users of the platform callbacks will be converted to
use a regulator, we will be able to remove platform data completely.

Changes from v4->v5
* Append the Device tree patches to v4.
* Submit only the first part of the series (no dependencies).
this can be applied and merged through the usb tree.

Changes from v3->v4
* separate the series into smaller series for driver and arch/arm code,
  to ease review and merging to different trees.

Changes form v2->v3
* drop patches that have been integrated to arch/arm
* drop regulator patches which will be integrated through regulator tree
* use of the accepted regulator API to get over current status
* better patch separation with the use of wrappers

Changes from v1->v2
* Rebased and added patch to make ohci a separate driver
* Use a regulator instead of handling Gpios (David Lechner)
* Add an over current mode to regulator framework
* Fixed regulator is able to register for and over current irq
* Added patch by Alexandre to remove build warnings
* Moved global variables into private hcd structure.
Axel Haslam (5):
  USB: ohci: da8xx: use ohci priv data instead of globals
  USB: ohci: da8xx: Add wrappers for platform callbacks
  USB: ohci: da8xx: Allow a regulator to handle VBUS
  USB: ohci: da8xx: Add devicetree bindings
  USB: ohci: da8xx: Allow probing from DT

 .../devicetree/bindings/usb/ohci-da8xx.txt |  23 ++
 drivers/usb/host/ohci-da8xx.c  | 291 +
 2 files changed, 264 insertions(+), 50 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 00/10] Add DT support for ohci-da8xx

2016-11-10 Thread Axel Haslam
On Thu, Nov 10, 2016 at 1:02 PM, Greg KH <gre...@linuxfoundation.org> wrote:
> On Tue, Nov 08, 2016 at 05:37:41PM +0100, Axel Haslam wrote:
>> Hi,
>>
>> On Mon, Nov 7, 2016 at 9:39 PM, Axel Haslam <ahas...@baylibre.com> wrote:
>> > The purpose of this patch series is to add DT support for the davinci
>> > ohci driver.
>> >
>>
>> To make it easier to review. I will split the arch/arm and driver
>> patches into separate series.
>
> I don't think it's easier, as now I have no idea what order, or what
> tree it should go through :(

Hi Greg,

i will resend the series one by one and wait for each to be merged
before sending the next, so that there is no confusion on the ordering
or on what tree they should apply.

Regards
Axel.

>
> I'm guessing not mine, so all are now deleted from my patch queue...
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] ARM: dts: da850: add usb device node

2016-11-08 Thread Axel Haslam
This adds the ohci device node for the da850 soc.
It also enables it for the omapl138 hawk board.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/boot/dts/da850-lcdk.dts | 8 
 arch/arm/boot/dts/da850.dtsi | 8 
 2 files changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/da850-lcdk.dts b/arch/arm/boot/dts/da850-lcdk.dts
index 7b8ab21..aaf533e 100644
--- a/arch/arm/boot/dts/da850-lcdk.dts
+++ b/arch/arm/boot/dts/da850-lcdk.dts
@@ -86,6 +86,14 @@
};
 };
 
+_phy {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_rxtx_pins>;
diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 2534aab..c74f1a6 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -405,6 +405,14 @@
>;
status = "disabled";
};
+   ohci: usb@225000 {
+   compatible = "ti,da830-ohci";
+   reg = <0x225000 0x1000>;
+   interrupts = <59>;
+   phys = <_phy 1>;
+   phy-names = "usb-phy";
+   status = "disabled";
+   };
gpio: gpio@226000 {
compatible = "ti,dm6441-gpio";
gpio-controller;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] USB: ohci: da8xx: Remove ohci platform callbacks

2016-11-08 Thread Axel Haslam
Now that all ohci users are are using a regulator, we can
remove the platform callbacks and data.

potpgt is no longer necessary as a power on delay time can
be specified for the regulator itself.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 84 ++-
 include/linux/platform_data/usb-davinci.h | 20 
 2 files changed, 5 insertions(+), 99 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 0a4b885..3dcbf1f 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -89,12 +89,8 @@ static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
int ret;
 
-   if (hub && hub->set_power)
-   return hub->set_power(1, on);
-
if (!da8xx_ohci->vbus_reg)
return 0;
 
@@ -121,11 +117,6 @@ static int ohci_da8xx_set_power(struct usb_hcd *hcd, int 
on)
 static int ohci_da8xx_get_power(struct usb_hcd *hcd)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
-   struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
-
-   if (hub && hub->get_power)
-   return hub->get_power(1);
 
if (da8xx_ohci->vbus_reg)
return regulator_is_enabled(da8xx_ohci->vbus_reg);
@@ -137,13 +128,9 @@ static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
unsigned int flags;
int ret;
 
-   if (hub && hub->get_oci)
-   return hub->get_oci(1);
-
if (!da8xx_ohci->vbus_reg)
return 0;
 
@@ -159,29 +146,9 @@ static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
return 0;
 }
 
-static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
+static int ohci_da8xx_has_regulator(struct usb_hcd *hcd)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
-   struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
-
-   if (hub && hub->set_power)
-   return 1;
-
-   if (da8xx_ohci->vbus_reg)
-   return 1;
-
-   return 0;
-}
-
-static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
-{
-   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
-   struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
-
-   if (hub && hub->get_oci)
-   return 1;
 
if (da8xx_ohci->vbus_reg)
return 1;
@@ -189,30 +156,9 @@ static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
return 0;
 }
 
-static int ohci_da8xx_has_potpgt(struct usb_hcd *hcd)
-{
-   struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
-
-   if (hub && hub->potpgt)
-   return 1;
-
-   return 0;
-}
-
 /*
  * Handle the port over-current indicator change.
  */
-static void ohci_da8xx_ocic_handler(struct da8xx_ohci_root_hub *hub,
-   unsigned port)
-{
-   ocic_mask |= 1 << port;
-
-   /* Once over-current is detected, the port needs to be powered down */
-   if (hub->get_oci(port) > 0)
-   hub->set_power(port, 0);
-}
-
 static int ohci_da8xx_regulator_event(struct notifier_block *nb,
unsigned long event, void *data)
 {
@@ -233,12 +179,9 @@ static int ohci_da8xx_register_notify(struct usb_hcd *hcd)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
int ret = 0;
 
-   if (hub && hub->ocic_notify)
-   ret = hub->ocic_notify(ohci_da8xx_ocic_handler);
-   else if (da8xx_ohci->vbus_reg) {
+   if (da8xx_ohci->vbus_reg) {
da8xx_ohci->nb.notifier_call = ohci_da8xx_regulator_event;
ret = devm_regulator_register_notifier(da8xx_ohci->vbus_reg,
_ohci->nb);
@@ -250,19 +193,9 @@ static int ohci_da8xx_register_notify(struct usb_hcd *hcd)
return ret;
 }
 
-static void ohci_da8xx_unregister_notify(struct usb_hcd *hcd)
-{
-   struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(de

[PATCH 0/2] [PART 3/4] USB: ohci-da8xx: Remove platform callbacks

2016-11-08 Thread Axel Haslam
There are no more users of the platform callbacks as
all of them have been converted to use a regulator.

We can now remove the plafrom callbacks from the driver and the platform
data structure.

DEPENDENCIES:
1. [PATCH 0/3] fix ohci phy name
https://lkml.org/lkml/2016/11/2/208
2. [PATCH/RFC v2 0/3] regulator: handling of error conditions for usb drivers
https://lkml.org/lkml/2016/11/3/188
3. [PATCH v4 0/3] [PART 1/4] USB: ohci-da8xx: Allow a regulator for VBUS and 
over current
4. [PATCH 0/3] [PART 2/4] ARM: davinci: OHCI: Use a regulator instead of 
callbacks

A branch with all the dependencies can be found here:
https://github.com/axelhaslamx/linux-axel/commits/ohci-da8xx-dt-v4

Axel Haslam (2):
  USB: ohci: da8xx: Remove ohci platform callbacks
  USB: ohci: da8xx: use a flag instead of mask for ocic

 drivers/usb/host/ohci-da8xx.c | 101 --
 include/linux/platform_data/usb-davinci.h |  20 --
 2 files changed, 12 insertions(+), 109 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] USB: ohci: da8xx: use a flag instead of mask for ocic

2016-11-08 Thread Axel Haslam
Now that the platform callback is removed, we can move the over
current indictor changed flag to the private data structure.

Since the driver only handles a single port, there is no need
for ocic to be a mask, we can use a simple flag instead.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 3dcbf1f..83b182e 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -43,12 +43,10 @@ struct da8xx_ohci_hcd {
struct regulator *vbus_reg;
struct notifier_block nb;
unsigned int is_powered;
+   unsigned int oc_changed;
 };
 #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
-/* Over-current indicator change bitmask */
-static volatile u16 ocic_mask;
-
 static int ohci_da8xx_enable(struct usb_hcd *hcd)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
@@ -168,7 +166,7 @@ static int ohci_da8xx_regulator_event(struct notifier_block 
*nb,
 
if (event & REGULATOR_EVENT_OVER_CURRENT) {
dev_warn(dev, "over current event\n");
-   ocic_mask |= 1;
+   da8xx_ohci->oc_changed = 1;
ohci_da8xx_set_power(da8xx_ohci->hcd, 0);
}
 
@@ -241,10 +239,11 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
  */
 static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
int length  = orig_ohci_hub_status_data(hcd, buf);
 
/* See if we have OCIC bit set on port 1 */
-   if (ocic_mask & (1 << 1)) {
+   if (da8xx_ohci->oc_changed) {
dev_dbg(hcd->self.controller, "over-current indicator change "
"on port 1\n");
 
@@ -262,6 +261,7 @@ static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, 
char *buf)
 static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
  u16 wIndex, char *buf, u16 wLength)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
int temp;
 
@@ -284,7 +284,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
temp |=  RH_PS_POCI;
 
/* The over-current indicator change (OCIC) bit is 0 too */
-   if (ocic_mask & (1 << wIndex))
+   if (da8xx_ohci->oc_changed)
temp |=  RH_PS_OCIC;
 
put_unaligned(cpu_to_le32(temp), (__le32 *)buf);
@@ -311,10 +311,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
temp ? "Set" : "Clear", wIndex,
"C_OVER_CURRENT");
 
-   if (temp)
-   ocic_mask |= 1 << wIndex;
-   else
-   ocic_mask &= ~(1 << wIndex);
+   da8xx_ohci->oc_changed = temp;
return 0;
}
}
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 2/3] USB: ohci: da8xx: Prepare to remove platform callbacks

2016-11-08 Thread Axel Haslam
Wrap the platform data callbacks into separate functions.
This will help migrate to using a regulator by providing a well defined
place to implement the regulator functions while the platform calls
are still in place and users have not been converted.

The platform callbacks will be removed on a following patch.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 125 ++
 1 file changed, 102 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 0442c64..9ed43c7 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -80,6 +80,72 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
+static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return hub->set_power(1, on);
+
+   return 0;
+}
+
+static int ohci_da8xx_get_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_power)
+   return hub->get_power(1);
+
+   return 1;
+}
+
+static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return hub->get_oci(1);
+
+   return 0;
+}
+
+static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_potpgt(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->potpgt)
+   return 1;
+
+   return 0;
+}
+
 /*
  * Handle the port over-current indicator change.
  */
@@ -93,6 +159,26 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_register_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   return hub->ocic_notify(ohci_da8xx_ocic_handler);
+
+   return 0;
+}
+
+static void ohci_da8xx_unregister_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   hub->ocic_notify(NULL);
+}
+
 static int ohci_da8xx_reset(struct usb_hcd *hcd)
 {
struct device *dev  = hcd->self.controller;
@@ -126,16 +212,18 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 * the correct hub descriptor...
 */
rh_a = ohci_readl(ohci, >regs->roothub.a);
-   if (hub->set_power) {
+   if (ohci_da8xx_has_set_power(hcd)) {
rh_a &= ~RH_A_NPS;
rh_a |=  RH_A_PSM;
}
-   if (hub->get_oci) {
+   if (ohci_da8xx_has_oci(hcd)) {
rh_a &= ~RH_A_NOCP;
rh_a |=  RH_A_OCPM;
}
-   rh_a &= ~RH_A_POTPGT;
-   rh_a |= hub->potpgt << 24;
+   if (ohci_da8xx_has_potpgt(hcd)) {
+   rh_a &= ~RH_A_POTPGT;
+   rh_a |= hub->potpgt << 24;
+   }
ohci_writel(ohci, rh_a, >regs->roothub.a);
 
return result;
@@ -168,7 +256,6 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
  u16 wIndex, char *buf, u16 wLength)
 {
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
int temp;
 
switch (typeReq) {
@@ -182,11 +269,11 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, 
u16 typeReq, u16 wValue,
temp = roothub_portstatus(hcd_to_ohci(hcd), wIndex - 1);
 
/* The port power status (PPS) bit defaults to 1 */
-   if (hub-&

[PATCH v4 1/3] USB: ohci: da8xx: use ohci priv data instead of globals

2016-11-08 Thread Axel Haslam
Instead of global variables, use the extra_priv_size of
the ohci driver.

We cannot yet move the ocic mask because this is used on
the interrupt handler which is registerded through platform
data and does not have an hcd pointer. This will be moved
on a later patch.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 72 +--
 1 file changed, 42 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 429d58b..0442c64 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -35,43 +35,49 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
u16 wValue, u16 wIndex, char *buf, u16 wLength);
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
-static struct clk *usb11_clk;
-static struct phy *usb11_phy;
+struct da8xx_ohci_hcd {
+   struct clk *usb11_clk;
+   struct phy *usb11_phy;
+};
+#define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
 /* Over-current indicator change bitmask */
 static volatile u16 ocic_mask;
 
-static int ohci_da8xx_enable(void)
+static int ohci_da8xx_enable(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
int ret;
 
-   ret = clk_prepare_enable(usb11_clk);
+   ret = clk_prepare_enable(da8xx_ohci->usb11_clk);
if (ret)
return ret;
 
-   ret = phy_init(usb11_phy);
+   ret = phy_init(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_init;
 
-   ret = phy_power_on(usb11_phy);
+   ret = phy_power_on(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_power_on;
 
return 0;
 
 err_phy_power_on:
-   phy_exit(usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
 err_phy_init:
-   clk_disable_unprepare(usb11_clk);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 
return ret;
 }
 
-static void ohci_da8xx_disable(void)
+static void ohci_da8xx_disable(struct usb_hcd *hcd)
 {
-   phy_power_off(usb11_phy);
-   phy_exit(usb11_phy);
-   clk_disable_unprepare(usb11_clk);
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
+
+   phy_power_off(da8xx_ohci->usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
 /*
@@ -97,7 +103,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
dev_dbg(dev, "starting USB controller\n");
 
-   result = ohci_da8xx_enable();
+   result = ohci_da8xx_enable(hcd);
if (result < 0)
return result;
 
@@ -109,7 +115,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
result = ohci_setup(hcd);
if (result < 0) {
-   ohci_da8xx_disable();
+   ohci_da8xx_disable(hcd);
return result;
}
 
@@ -231,6 +237,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 static int ohci_da8xx_probe(struct platform_device *pdev)
 {
struct da8xx_ohci_root_hub *hub = dev_get_platdata(>dev);
+   struct da8xx_ohci_hcd *da8xx_ohci;
struct usb_hcd  *hcd;
struct resource *mem;
int error, irq;
@@ -238,25 +245,29 @@ static int ohci_da8xx_probe(struct platform_device *pdev)
if (hub == NULL)
return -ENODEV;
 
-   usb11_clk = devm_clk_get(>dev, "usb11");
-   if (IS_ERR(usb11_clk)) {
-   if (PTR_ERR(usb11_clk) != -EPROBE_DEFER)
+   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
+   dev_name(>dev));
+   if (!hcd)
+   return -ENOMEM;
+
+   da8xx_ohci = to_da8xx_ohci(hcd);
+
+   da8xx_ohci->usb11_clk = devm_clk_get(>dev, "usb11");
+   if (IS_ERR(da8xx_ohci->usb11_clk)) {
+   if (PTR_ERR(da8xx_ohci->usb11_clk) != -EPROBE_DEFER)
dev_err(>dev, "Failed to get clock.\n");
-   return PTR_ERR(usb11_clk);
+   error = PTR_ERR(da8xx_ohci->usb11_clk);
+   goto err;
}
 
-   usb11_phy = devm_phy_get(>dev, "usb-phy");
-   if (IS_ERR(usb11_phy)) {
-   if (PTR_ERR(usb11_phy) != -EPROBE_DEFER)
+   da8xx_ohci->usb11_phy = devm_phy_get(>dev, "usb-phy");
+   if (IS_ERR(da8xx_ohci->usb11_phy)) {
+   if (PTR_ERR(da8xx_ohci->usb11_phy) != -EPROBE_DEFER)
dev_err(>dev, "Failed to get phy.\n");
-   return PTR_ERR(usb11_phy);
+   error = PTR_ERR(da8xx_ohci->usb11_phy);
+   goto err;
}
 
-   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
-   dev_name(>dev));
-   if (!hcd)
-   

[PATCH v4 3/3] USB: ohci: da8xx: Allow a regulator to handle VBUS

2016-11-08 Thread Axel Haslam
We need to remove the platform callbacks to be able to probe
the driver using device tree. Using a regulator to handle VBUS will
eliminate the need for these callbacks once all users are converted
to use a regulator.

The regulator equivalents to the platform callbacks are:
set_power   ->  regulator_enable/regulator_disable
get_power   ->  regulator_is_enabled
get_oci ->  regulator_get_error_flags
ocic_notify ->  regulator event notification

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 97 ++-
 1 file changed, 95 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 9ed43c7..0a4b885 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,8 +37,12 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
 struct da8xx_ohci_hcd {
+   struct usb_hcd *hcd;
struct clk *usb11_clk;
struct phy *usb11_phy;
+   struct regulator *vbus_reg;
+   struct notifier_block nb;
+   unsigned int is_powered;
 };
 #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
@@ -82,56 +87,105 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
 
 static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   int ret;
 
if (hub && hub->set_power)
return hub->set_power(1, on);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   if (on && !da8xx_ohci->is_powered) {
+   ret = regulator_enable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Fail to enable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->is_powered = 1;
+
+   } else if (!on && da8xx_ohci->is_powered) {
+   ret = regulator_disable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Fail to disable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->is_powered = 0;
+   }
+
return 0;
 }
 
 static int ohci_da8xx_get_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_power)
return hub->get_power(1);
 
+   if (da8xx_ohci->vbus_reg)
+   return regulator_is_enabled(da8xx_ohci->vbus_reg);
+
return 1;
 }
 
 static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   unsigned int flags;
+   int ret;
 
if (hub && hub->get_oci)
return hub->get_oci(1);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   ret = regulator_get_error_flags(da8xx_ohci->vbus_reg, );
+   if (ret) {
+   dev_err(dev, "could not get regulator error flags: %d\n", ret);
+   return ret;
+   }
+
+   if (flags && REGULATOR_ERROR_OVER_CURRENT)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->set_power)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_oci)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
@@ -159,15 +213,41 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_regulator_event(struct notifier_block *nb,
+   unsig

[PATCH 2/3] ARM: davinci: hawk: Remove vbus and over current gpios

2016-11-08 Thread Axel Haslam
The hawk board VBUS is fixed to a 5v source, and the over
current pin is actually not connected to the SoC.

Do not reseve these gpios for OHCI as they are not related
to usb.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/mach-davinci/board-omapl138-hawk.c | 99 ++---
 1 file changed, 4 insertions(+), 95 deletions(-)

diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c 
b/arch/arm/mach-davinci/board-omapl138-hawk.c
index a4e8726..a252404 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -28,9 +28,6 @@
 #define DA850_HAWK_MMCSD_CD_PINGPIO_TO_PIN(3, 12)
 #define DA850_HAWK_MMCSD_WP_PINGPIO_TO_PIN(3, 13)
 
-#define DA850_USB1_VBUS_PINGPIO_TO_PIN(2, 4)
-#define DA850_USB1_OC_PIN  GPIO_TO_PIN(6, 13)
-
 static short omapl138_hawk_mii_pins[] __initdata = {
DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
@@ -181,76 +178,10 @@ static __init void omapl138_hawk_mmc_init(void)
gpio_free(DA850_HAWK_MMCSD_CD_PIN);
 }
 
-static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id);
-static da8xx_ocic_handler_t hawk_usb_ocic_handler;
-
-static const short da850_hawk_usb11_pins[] = {
-   DA850_GPIO2_4, DA850_GPIO6_13,
-   -1
-};
-
-static int hawk_usb_set_power(unsigned port, int on)
-{
-   gpio_set_value(DA850_USB1_VBUS_PIN, on);
-   return 0;
-}
-
-static int hawk_usb_get_power(unsigned port)
-{
-   return gpio_get_value(DA850_USB1_VBUS_PIN);
-}
-
-static int hawk_usb_get_oci(unsigned port)
-{
-   return !gpio_get_value(DA850_USB1_OC_PIN);
-}
-
-static int hawk_usb_ocic_notify(da8xx_ocic_handler_t handler)
-{
-   int irq = gpio_to_irq(DA850_USB1_OC_PIN);
-   int error   = 0;
-
-   if (handler != NULL) {
-   hawk_usb_ocic_handler = handler;
-
-   error = request_irq(irq, omapl138_hawk_usb_ocic_irq,
-   IRQF_TRIGGER_RISING |
-   IRQF_TRIGGER_FALLING,
-   "OHCI over-current indicator", NULL);
-   if (error)
-   pr_err("%s: could not request IRQ to watch "
-   "over-current indicator changes\n", __func__);
-   } else {
-   free_irq(irq, NULL);
-   }
-   return error;
-}
-
-static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = {
-   .set_power  = hawk_usb_set_power,
-   .get_power  = hawk_usb_get_power,
-   .get_oci= hawk_usb_get_oci,
-   .ocic_notify= hawk_usb_ocic_notify,
-   /* TPS2087 switch @ 5V */
-   .potpgt = (3 + 1) / 2,  /* 3 ms max */
-};
-
-static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id)
-{
-   hawk_usb_ocic_handler(_hawk_usb11_pdata, 1);
-   return IRQ_HANDLED;
-}
-
 static __init void omapl138_hawk_usb_init(void)
 {
int ret;
 
-   ret = davinci_cfg_reg_list(da850_hawk_usb11_pins);
-   if (ret) {
-   pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
-   return;
-   }
-
ret = da8xx_register_usb20_phy_clk(false);
if (ret)
pr_warn("%s: USB 2.0 PHY CLK registration failed: %d\n",
@@ -266,34 +197,12 @@ static __init void omapl138_hawk_usb_init(void)
pr_warn("%s: USB PHY registration failed: %d\n",
__func__, ret);
 
-   ret = gpio_request_one(DA850_USB1_VBUS_PIN,
-   GPIOF_DIR_OUT, "USB1 VBUS");
-   if (ret < 0) {
-   pr_err("%s: failed to request GPIO for USB 1.1 port "
-   "power control: %d\n", __func__, ret);
-   return;
-   }
-
-   ret = gpio_request_one(DA850_USB1_OC_PIN,
-   GPIOF_DIR_IN, "USB1 OC");
-   if (ret < 0) {
-   pr_err("%s: failed to request GPIO for USB 1.1 port "
-   "over-current indicator: %d\n", __func__, ret);
-   goto usb11_setup_oc_fail;
-   }
-
-   ret = da8xx_register_usb11(_hawk_usb11_pdata);
-   if (ret) {
-   pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
-   goto usb11_setup_fail;
-   }
+   ret = da8xx_register_usb11(NULL);
+   if (ret)
+   pr_warn("%s: USB 1.1 registration failed: %d\n",
+   __func__, ret);
 
return;
-
-usb11_setup_fail:
-   gpio_free(DA850_USB1_OC_PIN);
-usb11_setup_oc_fail:
-   gpio_free(DA850_USB1_VBUS_PIN);
 }
 
 static __init void omapl138_hawk_init(void)
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] ARM: davinci: remove ohci platform usage

2016-11-08 Thread Axel Haslam
As all users of ohci platform data have been converted
to use a regulator, we dont need to pass platform
data to register the ohci device anymore.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/mach-davinci/board-da830-evm.c | 2 +-
 arch/arm/mach-davinci/board-omapl138-hawk.c | 2 +-
 arch/arm/mach-davinci/include/mach/da8xx.h  | 2 +-
 arch/arm/mach-davinci/usb-da8xx.c   | 3 +--
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index 16a401a..cb67885 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -129,7 +129,7 @@ static __init void da830_evm_usb_init(void)
if (ret)
pr_warn("fail to add ohci regulator\n");
 
-   ret = da8xx_register_usb11(NULL);
+   ret = da8xx_register_usb11();
if (ret)
pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
 }
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c 
b/arch/arm/mach-davinci/board-omapl138-hawk.c
index a252404..cbe7324 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -197,7 +197,7 @@ static __init void omapl138_hawk_usb_init(void)
pr_warn("%s: USB PHY registration failed: %d\n",
__func__, ret);
 
-   ret = da8xx_register_usb11(NULL);
+   ret = da8xx_register_usb11();
if (ret)
pr_warn("%s: USB 1.1 registration failed: %d\n",
__func__, ret);
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h 
b/arch/arm/mach-davinci/include/mach/da8xx.h
index 43322be..6096402 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -91,7 +91,7 @@ int da8xx_register_spi_bus(int instance, unsigned 
num_chipselect);
 int da8xx_register_watchdog(void);
 int da8xx_register_usb_phy(void);
 int da8xx_register_usb20(unsigned mA, unsigned potpgt);
-int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata);
+int da8xx_register_usb11(void);
 int da8xx_register_usb_refclkin(int rate);
 int da8xx_register_usb20_phy_clk(bool use_usb_refclkin);
 int da8xx_register_usb11_phy_clk(bool use_usb_refclkin);
diff --git a/arch/arm/mach-davinci/usb-da8xx.c 
b/arch/arm/mach-davinci/usb-da8xx.c
index c6feecf..4ea91bb 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -119,9 +119,8 @@ static struct platform_device da8xx_usb11_device = {
.resource   = da8xx_usb11_resources,
 };
 
-int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
+int __init da8xx_register_usb11(void)
 {
-   da8xx_usb11_device.dev.platform_data = pdata;
return platform_device_register(_usb11_device);
 }
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] [PART 4/4] USB: ohci-da8xx: Add DT support

2016-11-08 Thread Axel Haslam
This series defines the bindings and adds device tree support
for the davinci OHCI driver.

DEPENDENCIES:
1. [PATCH 0/3] fix ohci phy name
https://lkml.org/lkml/2016/11/2/208
2. [PATCH/RFC v2 0/3] regulator: handling of error conditions for usb drivers
https://lkml.org/lkml/2016/11/3/188
3. [PATCH v4 0/3] [PART 1/4] USB: ohci-da8xx: Allow a regulator for VBUS and 
over current
4. [PATCH 0/3] [PART 2/4] ARM: davinci: OHCI: Use a regulator instead of 
callbacks
5. [PATCH 0/2] [PART 3/4] USB: ohci-da8xx: Remove platform callbacks

A branch with all the dependencies can be found here:
https://github.com/axelhaslamx/linux-axel/commits/ohci-da8xx-dt-v4


Axel Haslam (3):
  USB: ohci: da8xx: Add devicetree bindings
  USB: ohci: da8xx: Allow probing from DT
  ARM: dts: da850: add usb device node

 .../devicetree/bindings/usb/ohci-da8xx.txt | 39 ++
 arch/arm/boot/dts/da850-lcdk.dts   |  8 +
 arch/arm/boot/dts/da850.dtsi   |  8 +
 drivers/usb/host/ohci-da8xx.c  |  8 +
 4 files changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] USB: ohci: da8xx: Allow probing from DT

2016-11-08 Thread Axel Haslam
This adds the compatible string to the ohci driver
to be able to probe from DT

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 83b182e..bbfe342 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -321,6 +321,13 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 }
 
 /*-*/
+#ifdef CONFIG_OF
+static const struct of_device_id da8xx_ohci_ids[] = {
+   { .compatible = "ti,da830-ohci" },
+   { }
+};
+MODULE_DEVICE_TABLE(of, da8xx_ohci_ids);
+#endif
 
 static int ohci_da8xx_probe(struct platform_device *pdev)
 {
@@ -472,6 +479,7 @@ static struct platform_driver ohci_hcd_da8xx_driver = {
 #endif
.driver = {
.name   = DRV_NAME,
+   .of_match_table = of_match_ptr(da8xx_ohci_ids),
},
 };
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] [PART 2/4] ARM: davinci: OHCI: Use a regulator instead of callbacks

2016-11-08 Thread Axel Haslam
With the ultimate goal to able to probe the ohci driver form DT,
convert users of OHCI pdata to use a regulator instead of
passing platform function pointers. This will help to remove the
platform callbacks in a future series.

DEPENDENCIES:
1. [PATCH 0/3] fix ohci phy name
https://lkml.org/lkml/2016/11/2/208
2. [PATCH/RFC v2 0/3] regulator: handling of error conditions for usb drivers
https://lkml.org/lkml/2016/11/3/188
3. [PATCH v4 0/3] [PART 1/4] USB: ohci-da8xx: Allow a regulator for VBUS and 
over current

A branch with all the dependencies can be found here:
https://github.com/axelhaslamx/linux-axel/commits/ohci-da8xx-dt-v4

Axel Haslam (3):
  ARM: davinci: da830: Handle vbus with a regulator
  ARM: davinci: hawk: Remove vbus and over current gpios
  ARM: davinci: remove ohci platform usage

 arch/arm/mach-davinci/board-da830-evm.c | 108 ++--
 arch/arm/mach-davinci/board-omapl138-hawk.c |  99 ++---
 arch/arm/mach-davinci/include/mach/da8xx.h  |   2 +-
 arch/arm/mach-davinci/usb-da8xx.c   |   3 +-
 4 files changed, 44 insertions(+), 168 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 0/3] [PART 1/4] USB: ohci-da8xx: Allow a regulator for VBUS and over current

2016-11-08 Thread Axel Haslam
This is the first of 4 series of patches to convert the
da8xx-ohci driver to use a regulator and probe form device tree 

To be able to use device tree to probe the driver, we need to remove
the platform callbacks that are handling vbus and over current.

These patches prepare the stage by allowing to use a regulator
instead of the platform callbacks.

DEPENDENCIES:
1. [PATCH 0/3] fix ohci phy name
https://lkml.org/lkml/2016/11/2/208
2. [PATCH/RFC v2 0/3] regulator: handling of error conditions for usb drivers
https://lkml.org/lkml/2016/11/3/188

A branch with all the dependencies can be found here:
https://github.com/axelhaslamx/linux-axel/commits/ohci-da8xx-dt-v4

Changes from v3->v4
* separate the series into smaller series for driver and arch/arm code,
  to ease review and merging to different trees.

Changes form v2->v3
* drop patches that have been integrated to arch/arm
* drop regulator patches which will be integrated through regulator tree
* use of the accepted regulator API to get over current status
* better patch separation with the use of wrappers

Changes from v1->v2
* Rebased and added patch to make ohci a separate driver
* Use a regulator instead of handling Gpios (David Lechner)
* Add an over current mode to regulator framework
* Fixed regulator is able to register for and over current irq
* Added patch by Alexandre to remove build warnings
* Moved global variables into private hcd structure.

Axel Haslam (3):
  USB: ohci: da8xx: use ohci priv data instead of globals
  USB: ohci: da8xx: Prepare to remove platform callbacks
  USB: ohci: da8xx: Allow a regulator to handle VBUS

 drivers/usb/host/ohci-da8xx.c | 284 ++
 1 file changed, 234 insertions(+), 50 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] USB: ohci: da8xx: Add devicetree bindings

2016-11-08 Thread Axel Haslam
This patch documents the device tree bindings required for
the ohci controller found in TI da8xx family of SoC's

Cc: devicet...@vger.kernel.org
Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 .../devicetree/bindings/usb/ohci-da8xx.txt | 39 ++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

diff --git a/Documentation/devicetree/bindings/usb/ohci-da8xx.txt 
b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
new file mode 100644
index 000..66672e6
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
@@ -0,0 +1,39 @@
+DA8XX USB OHCI controller
+
+Required properties:
+
+ - compatible: Should be "ti,da830-ohci"
+ - reg:Should contain one register range i.e. start and length
+ - interrupts: Description of the interrupt line
+ - phys:   Phandle for the PHY device
+ - phy-names:  Should be "usb-phy"
+
+Optional properties:
+ - vbus-supply: Regulator that controls vbus power
+
+Example:
+
+reg_usb_ohci: regulator@0 {
+compatible = "regulator-fixed";
+gpio = < 109 0>;
+over-current-gpios = < 36 0>;
+regulator-boot-on;
+enable-active-high;
+regulator-name = "usb_ohci_vbus";
+regulator-min-microvolt = <500>;
+regulator-max-microvolt = <500>;
+};
+
+usb_phy: usb-phy {
+compatible = "ti,da830-usb-phy";
+#phy-cells = <1>;
+};
+
+ohci: usb@0225000 {
+compatible = "ti,da830-ohci";
+reg = <0x225000 0x1000>;
+interrupts = <59>;
+phys = <_phy 1>;
+phy-names = "usb-phy";
+vbus-supply = <_usb_ohci>;
+};
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] ARM: davinci: da830: Handle vbus with a regulator

2016-11-08 Thread Axel Haslam
The usb driver can now take a regulator instead of the platform
callbacks for vbus handling. Lets use a regulator so we can remove
the callbacks in a later patch.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/mach-davinci/board-da830-evm.c | 108 +++-
 1 file changed, 38 insertions(+), 70 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index 5db0901..16a401a 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -38,72 +40,48 @@
 #include 
 
 #define DA830_EVM_PHY_ID   ""
-/*
- * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
- */
-#define ON_BD_USB_DRV  GPIO_TO_PIN(1, 15)
-#define ON_BD_USB_OVC  GPIO_TO_PIN(2, 4)
 
 static const short da830_evm_usb11_pins[] = {
DA830_GPIO1_15, DA830_GPIO2_4,
-1
 };
 
-static da8xx_ocic_handler_t da830_evm_usb_ocic_handler;
-
-static int da830_evm_usb_set_power(unsigned port, int on)
-{
-   gpio_set_value(ON_BD_USB_DRV, on);
-   return 0;
-}
+static struct regulator_consumer_supply usb_ohci_consumer_supply =
+   REGULATOR_SUPPLY("vbus", "ohci-da8xx");
 
-static int da830_evm_usb_get_power(unsigned port)
-{
-   return gpio_get_value(ON_BD_USB_DRV);
-}
-
-static int da830_evm_usb_get_oci(unsigned port)
-{
-   return !gpio_get_value(ON_BD_USB_OVC);
-}
-
-static irqreturn_t da830_evm_usb_ocic_irq(int, void *);
-
-static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
-{
-   int irq = gpio_to_irq(ON_BD_USB_OVC);
-   int error   = 0;
-
-   if (handler != NULL) {
-   da830_evm_usb_ocic_handler = handler;
-
-   error = request_irq(irq, da830_evm_usb_ocic_irq,
-   IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
-   "OHCI over-current indicator", NULL);
-   if (error)
-   pr_err("%s: could not request IRQ to watch over-current 
indicator changes\n",
-  __func__);
-   } else
-   free_irq(irq, NULL);
-
-   return error;
-}
+static struct regulator_init_data usb_ohci_initdata = {
+   .consumer_supplies = _ohci_consumer_supply,
+   .num_consumer_supplies = 1,
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+};
 
-static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = {
-   .set_power  = da830_evm_usb_set_power,
-   .get_power  = da830_evm_usb_get_power,
-   .get_oci= da830_evm_usb_get_oci,
-   .ocic_notify= da830_evm_usb_ocic_notify,
+static struct fixed_voltage_config usb_ohci_config = {
+   .supply_name= "vbus",
+   .microvolts = 500,
+   .gpio   = GPIO_TO_PIN(1, 15),
+   .enable_high= 1,
+   .enabled_at_boot= 0,
+   .init_data  = _ohci_initdata,
+};
 
-   /* TPS2065 switch @ 5V */
-   .potpgt = (3 + 1) / 2,  /* 3 ms max */
+static struct platform_device da8xx_usb11_regulator = {
+   .name   = "reg-fixed-voltage",
+   .id = 0,
+   .dev= {
+   .platform_data = _ohci_config,
+   },
 };
 
-static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id)
-{
-   da830_evm_usb_ocic_handler(_evm_usb11_pdata, 1);
-   return IRQ_HANDLED;
-}
+static struct gpiod_lookup_table usb11_gpios_table = {
+   .dev_id = "reg-fixed-voltage.0",
+   .table = {
+   /* gpio chip 1 contains gpio range 32-63 */
+   GPIO_LOOKUP("davinci_gpio.1", 4, "over-current",
+   GPIO_ACTIVE_LOW),
+   },
+};
 
 static __init void da830_evm_usb_init(void)
 {
@@ -145,23 +123,13 @@ static __init void da830_evm_usb_init(void)
return;
}
 
-   ret = gpio_request(ON_BD_USB_DRV, "ON_BD_USB_DRV");
-   if (ret) {
-   pr_err("%s: failed to request GPIO for USB 1.1 port power 
control: %d\n",
-  __func__, ret);
-   return;
-   }
-   gpio_direction_output(ON_BD_USB_DRV, 0);
+   gpiod_add_lookup_table(_gpios_table);
 
-   ret = gpio_request(ON_BD_USB_OVC, "ON_BD_USB_OVC");
-   if (ret) {
-   pr_err("%s: failed to request GPIO for USB 1.1 port 
over-current indicator: %d\n",
-  __func__, ret);
-   return;
-   }
-   gpio_direction_input(ON_BD_USB_OVC);
+   ret = platform_device_register(_usb11_regulator);
+   if (ret)
+ 

Re: [PATCH v3 00/10] Add DT support for ohci-da8xx

2016-11-08 Thread Axel Haslam
Hi,

On Mon, Nov 7, 2016 at 9:39 PM, Axel Haslam <ahas...@baylibre.com> wrote:
> The purpose of this patch series is to add DT support for the davinci
> ohci driver.
>

To make it easier to review. I will split the arch/arm and driver
patches into separate series.

Regards
Axel


> To be able to use device tree to probe the driver, we need to remove
> the platform callbacks that are handling vbus and over current.
>
> The first four patches prepare the stage by allowing to use a regulator
> instead of the callbacks.
>
> The next three patches convert the callback users to use a regulator
> instead and then remove the callbacks from the driver and platform code.
>
> Finally, we add device tree bindings and support in the driver.
>
> DEPENDENCIES:
> This series has depends on some patches currently under review
> but mostly accepted:
> 1. [PATCH 0/3] fix ohci phy name [1] (accepted)
> 2. [PATCH/RFC v2 0/3] regulator: handling of error conditions for usb drivers 
> [2] (accepted)
> 3. [PATCH] gpio: davinci: Use unique labels for each gpio chip [3] (review 
> pending)
>
> Also the current davinci baranches soon to be pulled to linux-next:
> davinci-for-v4.10/soc
> davinci-for-v4.10/dt
> davinci-for-v4.10/defconfig
> davinci-for-v4.10/cleanup
>
> A branch with all the dependencies can be found here [4].
>
> Changes form v2->v3
> * drop patches that have been integrated to arch/arm
> * drop regulator patches which will be integrated through regulator tree
> * use of the accepted regulator API to get over current status
> * better patch separation with the use of wrappers
>
> Changes from v1->v2
> * Rebased and added patch to make ohci a separate driver
> * Use a regulator instead of handling Gpios (David Lechner)
> * Add an over current mode to regulator framework
> * Fixed regulator is able to register for and over current irq
> * Added patch by Alexandre to remove build warnings
> * Moved global variables into private hcd structure.
>
> [1] https://lkml.org/lkml/2016/11/2/208
> [2] https://lkml.org/lkml/2016/11/3/188
> [3] http://www.spinics.net/lists/linux-gpio/msg17710.html
> [4] https://github.com/axelhaslamx/linux-axel/commits/ohci-da8xx-dt-v3
>
> Axel Haslam (10):
>   USB: ohci: da8xx: use ohci priv data instead of globals
>   USB: ohci: da8xx: Prepare to remove platform callbacks
>   USB: ohci: da8xx: Allow a regulator to handle VBUS
>   ARM: davinci: da830: Handle vbus with a regulator
>   ARM: davinci: hawk: Remove vbus and over current gpios
>   USB: ohci: da8xx: Remove ohci platform callbacks
>   USB: ohci: da8xx: use a flag instead of mask for ocic
>   USB: ohci: da8xx: Add devicetree bindings
>   USB: ohci: da8xx: Allow probing from DT
>   ARM: dts: da850: add usb device node
>
>  .../devicetree/bindings/usb/ohci-da8xx.txt |  39 
>  arch/arm/boot/dts/da850-lcdk.dts   |   8 +
>  arch/arm/boot/dts/da850.dtsi   |   8 +
>  arch/arm/mach-davinci/board-da830-evm.c| 108 -
>  arch/arm/mach-davinci/board-omapl138-hawk.c|  99 +---
>  arch/arm/mach-davinci/include/mach/da8xx.h |   2 +-
>  arch/arm/mach-davinci/usb-da8xx.c  |   3 +-
>  drivers/usb/host/ohci-da8xx.c  | 253 
> +++--
>  include/linux/platform_data/usb-davinci.h  |  20 --
>  9 files changed, 283 insertions(+), 257 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt
>
> --
> 2.10.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 00/10] Add DT support for ohci-da8xx

2016-11-07 Thread Axel Haslam
The purpose of this patch series is to add DT support for the davinci
ohci driver.

To be able to use device tree to probe the driver, we need to remove
the platform callbacks that are handling vbus and over current.

The first four patches prepare the stage by allowing to use a regulator
instead of the callbacks.

The next three patches convert the callback users to use a regulator
instead and then remove the callbacks from the driver and platform code.

Finally, we add device tree bindings and support in the driver.

DEPENDENCIES:
This series has depends on some patches currently under review
but mostly accepted:
1. [PATCH 0/3] fix ohci phy name [1] (accepted)
2. [PATCH/RFC v2 0/3] regulator: handling of error conditions for usb drivers 
[2] (accepted)
3. [PATCH] gpio: davinci: Use unique labels for each gpio chip [3] (review 
pending)

Also the current davinci baranches soon to be pulled to linux-next:
davinci-for-v4.10/soc
davinci-for-v4.10/dt
davinci-for-v4.10/defconfig
davinci-for-v4.10/cleanup

A branch with all the dependencies can be found here [4].

Changes form v2->v3
* drop patches that have been integrated to arch/arm
* drop regulator patches which will be integrated through regulator tree
* use of the accepted regulator API to get over current status
* better patch separation with the use of wrappers

Changes from v1->v2
* Rebased and added patch to make ohci a separate driver
* Use a regulator instead of handling Gpios (David Lechner)
* Add an over current mode to regulator framework
* Fixed regulator is able to register for and over current irq
* Added patch by Alexandre to remove build warnings
* Moved global variables into private hcd structure.

[1] https://lkml.org/lkml/2016/11/2/208
[2] https://lkml.org/lkml/2016/11/3/188
[3] http://www.spinics.net/lists/linux-gpio/msg17710.html
[4] https://github.com/axelhaslamx/linux-axel/commits/ohci-da8xx-dt-v3

Axel Haslam (10):
  USB: ohci: da8xx: use ohci priv data instead of globals
  USB: ohci: da8xx: Prepare to remove platform callbacks
  USB: ohci: da8xx: Allow a regulator to handle VBUS
  ARM: davinci: da830: Handle vbus with a regulator
  ARM: davinci: hawk: Remove vbus and over current gpios
  USB: ohci: da8xx: Remove ohci platform callbacks
  USB: ohci: da8xx: use a flag instead of mask for ocic
  USB: ohci: da8xx: Add devicetree bindings
  USB: ohci: da8xx: Allow probing from DT
  ARM: dts: da850: add usb device node

 .../devicetree/bindings/usb/ohci-da8xx.txt |  39 
 arch/arm/boot/dts/da850-lcdk.dts   |   8 +
 arch/arm/boot/dts/da850.dtsi   |   8 +
 arch/arm/mach-davinci/board-da830-evm.c| 108 -
 arch/arm/mach-davinci/board-omapl138-hawk.c|  99 +---
 arch/arm/mach-davinci/include/mach/da8xx.h |   2 +-
 arch/arm/mach-davinci/usb-da8xx.c  |   3 +-
 drivers/usb/host/ohci-da8xx.c  | 253 +++--
 include/linux/platform_data/usb-davinci.h  |  20 --
 9 files changed, 283 insertions(+), 257 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 02/10] USB: ohci: da8xx: Prepare to remove platform callbacks

2016-11-07 Thread Axel Haslam
Wrap the platform data callbacks into separate functions.
This will help migrate to using a regulator by providing a well defined
place to implement the regulator functions while the platform calls
are still in place and users have not been converted.

The platform callbacks will be removed on a following patch.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 125 ++
 1 file changed, 102 insertions(+), 23 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 0442c64..9ed43c7 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -80,6 +80,72 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
+static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return hub->set_power(1, on);
+
+   return 0;
+}
+
+static int ohci_da8xx_get_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_power)
+   return hub->get_power(1);
+
+   return 1;
+}
+
+static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return hub->get_oci(1);
+
+   return 0;
+}
+
+static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->set_power)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->get_oci)
+   return 1;
+
+   return 0;
+}
+
+static int ohci_da8xx_has_potpgt(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->potpgt)
+   return 1;
+
+   return 0;
+}
+
 /*
  * Handle the port over-current indicator change.
  */
@@ -93,6 +159,26 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_register_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   return hub->ocic_notify(ohci_da8xx_ocic_handler);
+
+   return 0;
+}
+
+static void ohci_da8xx_unregister_notify(struct usb_hcd *hcd)
+{
+   struct device *dev  = hcd->self.controller;
+   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+
+   if (hub && hub->ocic_notify)
+   hub->ocic_notify(NULL);
+}
+
 static int ohci_da8xx_reset(struct usb_hcd *hcd)
 {
struct device *dev  = hcd->self.controller;
@@ -126,16 +212,18 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 * the correct hub descriptor...
 */
rh_a = ohci_readl(ohci, >regs->roothub.a);
-   if (hub->set_power) {
+   if (ohci_da8xx_has_set_power(hcd)) {
rh_a &= ~RH_A_NPS;
rh_a |=  RH_A_PSM;
}
-   if (hub->get_oci) {
+   if (ohci_da8xx_has_oci(hcd)) {
rh_a &= ~RH_A_NOCP;
rh_a |=  RH_A_OCPM;
}
-   rh_a &= ~RH_A_POTPGT;
-   rh_a |= hub->potpgt << 24;
+   if (ohci_da8xx_has_potpgt(hcd)) {
+   rh_a &= ~RH_A_POTPGT;
+   rh_a |= hub->potpgt << 24;
+   }
ohci_writel(ohci, rh_a, >regs->roothub.a);
 
return result;
@@ -168,7 +256,6 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
  u16 wIndex, char *buf, u16 wLength)
 {
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
int temp;
 
switch (typeReq) {
@@ -182,11 +269,11 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, 
u16 typeReq, u16 wValue,
temp = roothub_portstatus(hcd_to_ohci(hcd), wIndex - 1);
 
/* The port power status (PPS) bit defaults to 1 */
-   if (hub-&

[PATCH v3 01/10] USB: ohci: da8xx: use ohci priv data instead of globals

2016-11-07 Thread Axel Haslam
Instead of global variables, use the extra_priv_size of
the ohci driver.

We cannot yet move the ocic mask because this is used on
the interrupt handler which is registerded through platform
data and does not have an hcd pointer. This will be moved
on a later patch.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 72 +--
 1 file changed, 42 insertions(+), 30 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 429d58b..0442c64 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -35,43 +35,49 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
u16 wValue, u16 wIndex, char *buf, u16 wLength);
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
-static struct clk *usb11_clk;
-static struct phy *usb11_phy;
+struct da8xx_ohci_hcd {
+   struct clk *usb11_clk;
+   struct phy *usb11_phy;
+};
+#define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
 /* Over-current indicator change bitmask */
 static volatile u16 ocic_mask;
 
-static int ohci_da8xx_enable(void)
+static int ohci_da8xx_enable(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
int ret;
 
-   ret = clk_prepare_enable(usb11_clk);
+   ret = clk_prepare_enable(da8xx_ohci->usb11_clk);
if (ret)
return ret;
 
-   ret = phy_init(usb11_phy);
+   ret = phy_init(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_init;
 
-   ret = phy_power_on(usb11_phy);
+   ret = phy_power_on(da8xx_ohci->usb11_phy);
if (ret)
goto err_phy_power_on;
 
return 0;
 
 err_phy_power_on:
-   phy_exit(usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
 err_phy_init:
-   clk_disable_unprepare(usb11_clk);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 
return ret;
 }
 
-static void ohci_da8xx_disable(void)
+static void ohci_da8xx_disable(struct usb_hcd *hcd)
 {
-   phy_power_off(usb11_phy);
-   phy_exit(usb11_phy);
-   clk_disable_unprepare(usb11_clk);
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
+
+   phy_power_off(da8xx_ohci->usb11_phy);
+   phy_exit(da8xx_ohci->usb11_phy);
+   clk_disable_unprepare(da8xx_ohci->usb11_clk);
 }
 
 /*
@@ -97,7 +103,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
dev_dbg(dev, "starting USB controller\n");
 
-   result = ohci_da8xx_enable();
+   result = ohci_da8xx_enable(hcd);
if (result < 0)
return result;
 
@@ -109,7 +115,7 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
 
result = ohci_setup(hcd);
if (result < 0) {
-   ohci_da8xx_disable();
+   ohci_da8xx_disable(hcd);
return result;
}
 
@@ -231,6 +237,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
 static int ohci_da8xx_probe(struct platform_device *pdev)
 {
struct da8xx_ohci_root_hub *hub = dev_get_platdata(>dev);
+   struct da8xx_ohci_hcd *da8xx_ohci;
struct usb_hcd  *hcd;
struct resource *mem;
int error, irq;
@@ -238,25 +245,29 @@ static int ohci_da8xx_probe(struct platform_device *pdev)
if (hub == NULL)
return -ENODEV;
 
-   usb11_clk = devm_clk_get(>dev, "usb11");
-   if (IS_ERR(usb11_clk)) {
-   if (PTR_ERR(usb11_clk) != -EPROBE_DEFER)
+   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
+   dev_name(>dev));
+   if (!hcd)
+   return -ENOMEM;
+
+   da8xx_ohci = to_da8xx_ohci(hcd);
+
+   da8xx_ohci->usb11_clk = devm_clk_get(>dev, "usb11");
+   if (IS_ERR(da8xx_ohci->usb11_clk)) {
+   if (PTR_ERR(da8xx_ohci->usb11_clk) != -EPROBE_DEFER)
dev_err(>dev, "Failed to get clock.\n");
-   return PTR_ERR(usb11_clk);
+   error = PTR_ERR(da8xx_ohci->usb11_clk);
+   goto err;
}
 
-   usb11_phy = devm_phy_get(>dev, "usb-phy");
-   if (IS_ERR(usb11_phy)) {
-   if (PTR_ERR(usb11_phy) != -EPROBE_DEFER)
+   da8xx_ohci->usb11_phy = devm_phy_get(>dev, "usb-phy");
+   if (IS_ERR(da8xx_ohci->usb11_phy)) {
+   if (PTR_ERR(da8xx_ohci->usb11_phy) != -EPROBE_DEFER)
dev_err(>dev, "Failed to get phy.\n");
-   return PTR_ERR(usb11_phy);
+   error = PTR_ERR(da8xx_ohci->usb11_phy);
+   goto err;
}
 
-   hcd = usb_create_hcd(_da8xx_hc_driver, >dev,
-   dev_name(>dev));
-   if (!hcd)
-   

[PATCH v3 10/10] ARM: dts: da850: add usb device node

2016-11-07 Thread Axel Haslam
This adds the ohci device node for the da850 soc.
It also enables it for the omapl138 hawk board.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/boot/dts/da850-lcdk.dts | 8 
 arch/arm/boot/dts/da850.dtsi | 8 
 2 files changed, 16 insertions(+)

diff --git a/arch/arm/boot/dts/da850-lcdk.dts b/arch/arm/boot/dts/da850-lcdk.dts
index 7b8ab21..aaf533e 100644
--- a/arch/arm/boot/dts/da850-lcdk.dts
+++ b/arch/arm/boot/dts/da850-lcdk.dts
@@ -86,6 +86,14 @@
};
 };
 
+_phy {
+   status = "okay";
+};
+
+ {
+   status = "okay";
+};
+
  {
pinctrl-names = "default";
pinctrl-0 = <_rxtx_pins>;
diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
index 2534aab..50e86da 100644
--- a/arch/arm/boot/dts/da850.dtsi
+++ b/arch/arm/boot/dts/da850.dtsi
@@ -405,6 +405,14 @@
>;
status = "disabled";
};
+   ohci: usb@0225000 {
+   compatible = "ti,da830-ohci";
+   reg = <0x225000 0x1000>;
+   interrupts = <59>;
+   phys = <_phy 1>;
+   phy-names = "usb-phy";
+   status = "disabled";
+   };
gpio: gpio@226000 {
compatible = "ti,dm6441-gpio";
gpio-controller;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 06/10] USB: ohci: da8xx: Remove ohci platform callbacks

2016-11-07 Thread Axel Haslam
Now that all ohci users are are using a regulator, we can
remove the platform callbacks and data.

potpgt is no longer necessary as a power on delay time can
be specified for the regulator itself.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/mach-davinci/board-da830-evm.c |  2 +-
 arch/arm/mach-davinci/board-omapl138-hawk.c |  2 +-
 arch/arm/mach-davinci/include/mach/da8xx.h  |  2 +-
 arch/arm/mach-davinci/usb-da8xx.c   |  3 +-
 drivers/usb/host/ohci-da8xx.c   | 84 ++---
 include/linux/platform_data/usb-davinci.h   | 20 ---
 6 files changed, 9 insertions(+), 104 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index 16a401a..cb67885 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -129,7 +129,7 @@ static __init void da830_evm_usb_init(void)
if (ret)
pr_warn("fail to add ohci regulator\n");
 
-   ret = da8xx_register_usb11(NULL);
+   ret = da8xx_register_usb11();
if (ret)
pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
 }
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c 
b/arch/arm/mach-davinci/board-omapl138-hawk.c
index a252404..cbe7324 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -197,7 +197,7 @@ static __init void omapl138_hawk_usb_init(void)
pr_warn("%s: USB PHY registration failed: %d\n",
__func__, ret);
 
-   ret = da8xx_register_usb11(NULL);
+   ret = da8xx_register_usb11();
if (ret)
pr_warn("%s: USB 1.1 registration failed: %d\n",
__func__, ret);
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h 
b/arch/arm/mach-davinci/include/mach/da8xx.h
index 43322be..6096402 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -91,7 +91,7 @@ int da8xx_register_spi_bus(int instance, unsigned 
num_chipselect);
 int da8xx_register_watchdog(void);
 int da8xx_register_usb_phy(void);
 int da8xx_register_usb20(unsigned mA, unsigned potpgt);
-int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata);
+int da8xx_register_usb11(void);
 int da8xx_register_usb_refclkin(int rate);
 int da8xx_register_usb20_phy_clk(bool use_usb_refclkin);
 int da8xx_register_usb11_phy_clk(bool use_usb_refclkin);
diff --git a/arch/arm/mach-davinci/usb-da8xx.c 
b/arch/arm/mach-davinci/usb-da8xx.c
index c6feecf..4ea91bb 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -119,9 +119,8 @@ static struct platform_device da8xx_usb11_device = {
.resource   = da8xx_usb11_resources,
 };
 
-int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
+int __init da8xx_register_usb11(void)
 {
-   da8xx_usb11_device.dev.platform_data = pdata;
return platform_device_register(_usb11_device);
 }
 
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 0a4b885..3dcbf1f 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -89,12 +89,8 @@ static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
int ret;
 
-   if (hub && hub->set_power)
-   return hub->set_power(1, on);
-
if (!da8xx_ohci->vbus_reg)
return 0;
 
@@ -121,11 +117,6 @@ static int ohci_da8xx_set_power(struct usb_hcd *hcd, int 
on)
 static int ohci_da8xx_get_power(struct usb_hcd *hcd)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
-   struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
-
-   if (hub && hub->get_power)
-   return hub->get_power(1);
 
if (da8xx_ohci->vbus_reg)
return regulator_is_enabled(da8xx_ohci->vbus_reg);
@@ -137,13 +128,9 @@ static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
-   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
unsigned int flags;
int ret;
 
-   if (hub && hub->get_oci)
-   return hub->get_oci(1);
-
if (!da8xx_ohci->vbus_reg)
return 0;
 
@@ -159,29 +146,9 @@ static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
return 0;
 }
 
-static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
+static int ohci_da8xx_has_regulator(struct usb_hcd *hcd)
 {
struct da8xx_ohci_hcd *da

[PATCH v3 04/10] ARM: davinci: da830: Handle vbus with a regulator

2016-11-07 Thread Axel Haslam
The usb driver can now take a regulator instead of the platform
callbacks for vbus handling. Lets use a regulator so we can remove
the callbacks in a later patch.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/mach-davinci/board-da830-evm.c | 108 +++-
 1 file changed, 38 insertions(+), 70 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c 
b/arch/arm/mach-davinci/board-da830-evm.c
index 5db0901..16a401a 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -28,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -38,72 +40,48 @@
 #include 
 
 #define DA830_EVM_PHY_ID   ""
-/*
- * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
- */
-#define ON_BD_USB_DRV  GPIO_TO_PIN(1, 15)
-#define ON_BD_USB_OVC  GPIO_TO_PIN(2, 4)
 
 static const short da830_evm_usb11_pins[] = {
DA830_GPIO1_15, DA830_GPIO2_4,
-1
 };
 
-static da8xx_ocic_handler_t da830_evm_usb_ocic_handler;
-
-static int da830_evm_usb_set_power(unsigned port, int on)
-{
-   gpio_set_value(ON_BD_USB_DRV, on);
-   return 0;
-}
+static struct regulator_consumer_supply usb_ohci_consumer_supply =
+   REGULATOR_SUPPLY("vbus", "ohci-da8xx");
 
-static int da830_evm_usb_get_power(unsigned port)
-{
-   return gpio_get_value(ON_BD_USB_DRV);
-}
-
-static int da830_evm_usb_get_oci(unsigned port)
-{
-   return !gpio_get_value(ON_BD_USB_OVC);
-}
-
-static irqreturn_t da830_evm_usb_ocic_irq(int, void *);
-
-static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
-{
-   int irq = gpio_to_irq(ON_BD_USB_OVC);
-   int error   = 0;
-
-   if (handler != NULL) {
-   da830_evm_usb_ocic_handler = handler;
-
-   error = request_irq(irq, da830_evm_usb_ocic_irq,
-   IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
-   "OHCI over-current indicator", NULL);
-   if (error)
-   pr_err("%s: could not request IRQ to watch over-current 
indicator changes\n",
-  __func__);
-   } else
-   free_irq(irq, NULL);
-
-   return error;
-}
+static struct regulator_init_data usb_ohci_initdata = {
+   .consumer_supplies = _ohci_consumer_supply,
+   .num_consumer_supplies = 1,
+   .constraints = {
+   .valid_ops_mask = REGULATOR_CHANGE_STATUS,
+   },
+};
 
-static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = {
-   .set_power  = da830_evm_usb_set_power,
-   .get_power  = da830_evm_usb_get_power,
-   .get_oci= da830_evm_usb_get_oci,
-   .ocic_notify= da830_evm_usb_ocic_notify,
+static struct fixed_voltage_config usb_ohci_config = {
+   .supply_name= "vbus",
+   .microvolts = 500,
+   .gpio   = GPIO_TO_PIN(1, 15),
+   .enable_high= 1,
+   .enabled_at_boot= 0,
+   .init_data  = _ohci_initdata,
+};
 
-   /* TPS2065 switch @ 5V */
-   .potpgt = (3 + 1) / 2,  /* 3 ms max */
+static struct platform_device da8xx_usb11_regulator = {
+   .name   = "reg-fixed-voltage",
+   .id = 0,
+   .dev= {
+   .platform_data = _ohci_config,
+   },
 };
 
-static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id)
-{
-   da830_evm_usb_ocic_handler(_evm_usb11_pdata, 1);
-   return IRQ_HANDLED;
-}
+static struct gpiod_lookup_table usb11_gpios_table = {
+   .dev_id = "reg-fixed-voltage.0",
+   .table = {
+   /* gpio chip 1 contains gpio range 32-63 */
+   GPIO_LOOKUP("davinci_gpio.1", 4, "over-current",
+   GPIO_ACTIVE_LOW),
+   },
+};
 
 static __init void da830_evm_usb_init(void)
 {
@@ -145,23 +123,13 @@ static __init void da830_evm_usb_init(void)
return;
}
 
-   ret = gpio_request(ON_BD_USB_DRV, "ON_BD_USB_DRV");
-   if (ret) {
-   pr_err("%s: failed to request GPIO for USB 1.1 port power 
control: %d\n",
-  __func__, ret);
-   return;
-   }
-   gpio_direction_output(ON_BD_USB_DRV, 0);
+   gpiod_add_lookup_table(_gpios_table);
 
-   ret = gpio_request(ON_BD_USB_OVC, "ON_BD_USB_OVC");
-   if (ret) {
-   pr_err("%s: failed to request GPIO for USB 1.1 port 
over-current indicator: %d\n",
-  __func__, ret);
-   return;
-   }
-   gpio_direction_input(ON_BD_USB_OVC);
+   ret = platform_device_register(_usb11_regulator);
+   if (ret)
+ 

[PATCH v3 05/10] ARM: davinci: hawk: Remove vbus and over current gpios

2016-11-07 Thread Axel Haslam
The hawk board VBUS is fixed to a 5v source, and the over
current pin is actually not connected to the SoC.

Do not reseve these gpios for OHCI as they are not related
to usb.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/mach-davinci/board-omapl138-hawk.c | 99 ++---
 1 file changed, 4 insertions(+), 95 deletions(-)

diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c 
b/arch/arm/mach-davinci/board-omapl138-hawk.c
index a4e8726..a252404 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -28,9 +28,6 @@
 #define DA850_HAWK_MMCSD_CD_PINGPIO_TO_PIN(3, 12)
 #define DA850_HAWK_MMCSD_WP_PINGPIO_TO_PIN(3, 13)
 
-#define DA850_USB1_VBUS_PINGPIO_TO_PIN(2, 4)
-#define DA850_USB1_OC_PIN  GPIO_TO_PIN(6, 13)
-
 static short omapl138_hawk_mii_pins[] __initdata = {
DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
@@ -181,76 +178,10 @@ static __init void omapl138_hawk_mmc_init(void)
gpio_free(DA850_HAWK_MMCSD_CD_PIN);
 }
 
-static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id);
-static da8xx_ocic_handler_t hawk_usb_ocic_handler;
-
-static const short da850_hawk_usb11_pins[] = {
-   DA850_GPIO2_4, DA850_GPIO6_13,
-   -1
-};
-
-static int hawk_usb_set_power(unsigned port, int on)
-{
-   gpio_set_value(DA850_USB1_VBUS_PIN, on);
-   return 0;
-}
-
-static int hawk_usb_get_power(unsigned port)
-{
-   return gpio_get_value(DA850_USB1_VBUS_PIN);
-}
-
-static int hawk_usb_get_oci(unsigned port)
-{
-   return !gpio_get_value(DA850_USB1_OC_PIN);
-}
-
-static int hawk_usb_ocic_notify(da8xx_ocic_handler_t handler)
-{
-   int irq = gpio_to_irq(DA850_USB1_OC_PIN);
-   int error   = 0;
-
-   if (handler != NULL) {
-   hawk_usb_ocic_handler = handler;
-
-   error = request_irq(irq, omapl138_hawk_usb_ocic_irq,
-   IRQF_TRIGGER_RISING |
-   IRQF_TRIGGER_FALLING,
-   "OHCI over-current indicator", NULL);
-   if (error)
-   pr_err("%s: could not request IRQ to watch "
-   "over-current indicator changes\n", __func__);
-   } else {
-   free_irq(irq, NULL);
-   }
-   return error;
-}
-
-static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = {
-   .set_power  = hawk_usb_set_power,
-   .get_power  = hawk_usb_get_power,
-   .get_oci= hawk_usb_get_oci,
-   .ocic_notify= hawk_usb_ocic_notify,
-   /* TPS2087 switch @ 5V */
-   .potpgt = (3 + 1) / 2,  /* 3 ms max */
-};
-
-static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id)
-{
-   hawk_usb_ocic_handler(_hawk_usb11_pdata, 1);
-   return IRQ_HANDLED;
-}
-
 static __init void omapl138_hawk_usb_init(void)
 {
int ret;
 
-   ret = davinci_cfg_reg_list(da850_hawk_usb11_pins);
-   if (ret) {
-   pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
-   return;
-   }
-
ret = da8xx_register_usb20_phy_clk(false);
if (ret)
pr_warn("%s: USB 2.0 PHY CLK registration failed: %d\n",
@@ -266,34 +197,12 @@ static __init void omapl138_hawk_usb_init(void)
pr_warn("%s: USB PHY registration failed: %d\n",
__func__, ret);
 
-   ret = gpio_request_one(DA850_USB1_VBUS_PIN,
-   GPIOF_DIR_OUT, "USB1 VBUS");
-   if (ret < 0) {
-   pr_err("%s: failed to request GPIO for USB 1.1 port "
-   "power control: %d\n", __func__, ret);
-   return;
-   }
-
-   ret = gpio_request_one(DA850_USB1_OC_PIN,
-   GPIOF_DIR_IN, "USB1 OC");
-   if (ret < 0) {
-   pr_err("%s: failed to request GPIO for USB 1.1 port "
-   "over-current indicator: %d\n", __func__, ret);
-   goto usb11_setup_oc_fail;
-   }
-
-   ret = da8xx_register_usb11(_hawk_usb11_pdata);
-   if (ret) {
-   pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
-   goto usb11_setup_fail;
-   }
+   ret = da8xx_register_usb11(NULL);
+   if (ret)
+   pr_warn("%s: USB 1.1 registration failed: %d\n",
+   __func__, ret);
 
return;
-
-usb11_setup_fail:
-   gpio_free(DA850_USB1_OC_PIN);
-usb11_setup_oc_fail:
-   gpio_free(DA850_USB1_VBUS_PIN);
 }
 
 static __init void omapl138_hawk_init(void)
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 08/10] USB: ohci: da8xx: Add devicetree bindings

2016-11-07 Thread Axel Haslam
This patch documents the device tree bindings required for
the ohci controller found in TI da8xx family of SoC's

Cc: devicet...@vger.kernel.org
Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 .../devicetree/bindings/usb/ohci-da8xx.txt | 39 ++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt

diff --git a/Documentation/devicetree/bindings/usb/ohci-da8xx.txt 
b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
new file mode 100644
index 000..f18e82c
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
@@ -0,0 +1,39 @@
+DA8XX USB OHCI controller
+
+Required properties:
+
+ - compatible: Should be "ti,da830-ohci"
+ - reg:Should contain one register range i.e. start and length
+ - interrupts: Description of the interrupt line
+ - phys:   Phandle for the PHY device
+ - phy-names:  Should be "usb-phy"
+
+Optional properties:
+ - vbus-supply: Regulator that controls vbus power
+
+Example:
+
+reg_usb_ohci: regulator@0 {
+compatible = "regulator-fixed";
+gpio = < 109 0>;
+over-current-gpios = < 36 0>;
+regulator-boot-on;
+enable-active-high;
+regulator-name = "usb_ohci_vbus";
+regulator-min-microvolt = <500>;
+regulator-max-microvolt = <500>;
+};
+
+usb_phy: usb-phy {
+compatible = "ti,da830-usb-phy";
+#phy-cells = <1>;
+};
+
+ohci: usb@0225000 {
+compatible = "ti,da830-ohci";
+reg = <0x225000 0x1000>;
+interrupts = <59>;
+phys = <_phy 1>;
+phy-names = "usb-phy";
+vbus-supply = <_usb_ohci>;
+};
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 07/10] USB: ohci: da8xx: use a flag instead of mask for ocic

2016-11-07 Thread Axel Haslam
Now that the platform callback is removed, we can move the over
current indictor changed flag to the private data structure.

Since the driver only handles a single port, there is no need
for ocic to be a mask, we can use a simple flag instead.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 3dcbf1f..83b182e 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -43,12 +43,10 @@ struct da8xx_ohci_hcd {
struct regulator *vbus_reg;
struct notifier_block nb;
unsigned int is_powered;
+   unsigned int oc_changed;
 };
 #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
-/* Over-current indicator change bitmask */
-static volatile u16 ocic_mask;
-
 static int ohci_da8xx_enable(struct usb_hcd *hcd)
 {
struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
@@ -168,7 +166,7 @@ static int ohci_da8xx_regulator_event(struct notifier_block 
*nb,
 
if (event & REGULATOR_EVENT_OVER_CURRENT) {
dev_warn(dev, "over current event\n");
-   ocic_mask |= 1;
+   da8xx_ohci->oc_changed = 1;
ohci_da8xx_set_power(da8xx_ohci->hcd, 0);
}
 
@@ -241,10 +239,11 @@ static int ohci_da8xx_reset(struct usb_hcd *hcd)
  */
 static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
int length  = orig_ohci_hub_status_data(hcd, buf);
 
/* See if we have OCIC bit set on port 1 */
-   if (ocic_mask & (1 << 1)) {
+   if (da8xx_ohci->oc_changed) {
dev_dbg(hcd->self.controller, "over-current indicator change "
"on port 1\n");
 
@@ -262,6 +261,7 @@ static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, 
char *buf)
 static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
  u16 wIndex, char *buf, u16 wLength)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
int temp;
 
@@ -284,7 +284,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
temp |=  RH_PS_POCI;
 
/* The over-current indicator change (OCIC) bit is 0 too */
-   if (ocic_mask & (1 << wIndex))
+   if (da8xx_ohci->oc_changed)
temp |=  RH_PS_OCIC;
 
put_unaligned(cpu_to_le32(temp), (__le32 *)buf);
@@ -311,10 +311,7 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, u16 
typeReq, u16 wValue,
temp ? "Set" : "Clear", wIndex,
"C_OVER_CURRENT");
 
-   if (temp)
-   ocic_mask |= 1 << wIndex;
-   else
-   ocic_mask &= ~(1 << wIndex);
+   da8xx_ohci->oc_changed = temp;
return 0;
}
}
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 03/10] USB: ohci: da8xx: Allow a regulator to handle VBUS

2016-11-07 Thread Axel Haslam
We need to remove the platform callbacks to be able to probe
the driver using device tree. Using a regulator to handle VBUS will
eliminate the need for these callbacks once all users are converted
to use a regulator.

The regulator equivalents to the platform callbacks are:
set_power   ->  regulator_enable/regulator_disable
get_power   ->  regulator_is_enabled
get_oci ->  regulator_get_error_flags
ocic_notify ->  regulator event notification

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 97 ++-
 1 file changed, 95 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 9ed43c7..0a4b885 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -36,8 +37,12 @@ static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, 
u16 typeReq,
 static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
 struct da8xx_ohci_hcd {
+   struct usb_hcd *hcd;
struct clk *usb11_clk;
struct phy *usb11_phy;
+   struct regulator *vbus_reg;
+   struct notifier_block nb;
+   unsigned int is_powered;
 };
 #define to_da8xx_ohci(hcd) (struct da8xx_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
@@ -82,56 +87,105 @@ static void ohci_da8xx_disable(struct usb_hcd *hcd)
 
 static int ohci_da8xx_set_power(struct usb_hcd *hcd, int on)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   int ret;
 
if (hub && hub->set_power)
return hub->set_power(1, on);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   if (on && !da8xx_ohci->is_powered) {
+   ret = regulator_enable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Fail to enable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->is_powered = 1;
+
+   } else if (!on && da8xx_ohci->is_powered) {
+   ret = regulator_disable(da8xx_ohci->vbus_reg);
+   if (ret) {
+   dev_err(dev, "Fail to disable regulator: %d\n", ret);
+   return ret;
+   }
+   da8xx_ohci->is_powered = 0;
+   }
+
return 0;
 }
 
 static int ohci_da8xx_get_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_power)
return hub->get_power(1);
 
+   if (da8xx_ohci->vbus_reg)
+   return regulator_is_enabled(da8xx_ohci->vbus_reg);
+
return 1;
 }
 
 static int ohci_da8xx_get_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
+   unsigned int flags;
+   int ret;
 
if (hub && hub->get_oci)
return hub->get_oci(1);
 
+   if (!da8xx_ohci->vbus_reg)
+   return 0;
+
+   ret = regulator_get_error_flags(da8xx_ohci->vbus_reg, );
+   if (ret) {
+   dev_err(dev, "could not get regulator error flags: %d\n", ret);
+   return ret;
+   }
+
+   if (flags && REGULATOR_ERROR_OVER_CURRENT)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_set_power(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->set_power)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
 static int ohci_da8xx_has_oci(struct usb_hcd *hcd)
 {
+   struct da8xx_ohci_hcd *da8xx_ohci = to_da8xx_ohci(hcd);
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
 
if (hub && hub->get_oci)
return 1;
 
+   if (da8xx_ohci->vbus_reg)
+   return 1;
+
return 0;
 }
 
@@ -159,15 +213,41 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
+static int ohci_da8xx_regulator_event(struct notifier_block *nb,
+   unsig

[PATCH v2 3/3] usb: ohci-da8xx: rename driver to ohci-da8xx

2016-11-03 Thread Axel Haslam
The davinci ohci driver name (currently "ohci") is too generic.
To be consistent with other usb dirvers, append the "-da8xx" postfix
to the name.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 30c4878..429d58b 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -27,7 +27,7 @@
 #include "ohci.h"
 
 #define DRIVER_DESC "DA8XX"
-#define DRV_NAME "ohci"
+#define DRV_NAME "ohci-da8xx"
 
 static struct hc_driver __read_mostly ohci_da8xx_hc_driver;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/3] phy: da8xx-usb: rename the ohci device to ohci-da8xx

2016-11-03 Thread Axel Haslam
The ohci device name has changed in the board configuraion files,
hence, change the phy lookup table to match the new name.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/phy/phy-da8xx-usb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-da8xx-usb.c b/drivers/phy/phy-da8xx-usb.c
index 32ae78c..c85fb0b 100644
--- a/drivers/phy/phy-da8xx-usb.c
+++ b/drivers/phy/phy-da8xx-usb.c
@@ -198,7 +198,8 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
} else {
int ret;
 
-   ret = phy_create_lookup(d_phy->usb11_phy, "usb-phy", "ohci.0");
+   ret = phy_create_lookup(d_phy->usb11_phy, "usb-phy",
+   "ohci-da8xx");
if (ret)
dev_warn(dev, "Failed to create usb11 phy lookup\n");
ret = phy_create_lookup(d_phy->usb20_phy, "usb-phy",
@@ -216,7 +217,7 @@ static int da8xx_usb_phy_remove(struct platform_device 
*pdev)
 
if (!pdev->dev.of_node) {
phy_remove_lookup(d_phy->usb20_phy, "usb-phy", "musb-da8xx");
-   phy_remove_lookup(d_phy->usb11_phy, "usb-phy", "ohci.0");
+   phy_remove_lookup(d_phy->usb11_phy, "usb-phy", "ohci-da8xx");
}
 
return 0;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/3] ARM: davinci: da8xx: Fix ohci device name

2016-11-03 Thread Axel Haslam
While the clk lookup table is making reference to "ohci"
other subsystems (such as phy) are trying to match "ohci.0"

Since there is a single ohci instance, instead of changing
the clk name, change the dev id to -1, and add the "-da8xx"
postfix to match the driver name that will also be changed
in a subsequent patch.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/mach-davinci/da830.c | 2 +-
 arch/arm/mach-davinci/da850.c | 2 +-
 arch/arm/mach-davinci/da8xx-dt.c  | 2 +-
 arch/arm/mach-davinci/usb-da8xx.c | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 41459bd..073c458 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -420,7 +420,7 @@ static struct clk_lookup da830_clks[] = {
CLK("davinci_mdio.0",   "fck",  _clk),
CLK(NULL,   "gpio", _clk),
CLK("i2c_davinci.2",NULL,   _clk),
-   CLK("ohci", "usb11",_clk),
+   CLK("ohci-da8xx",   "usb11",_clk),
CLK(NULL,   "emif3",_clk),
CLK(NULL,   "arm",  _clk),
CLK(NULL,   "rmii", _clk),
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 196e262..3961556 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -503,7 +503,7 @@ static struct clk_lookup da850_clks[] = {
CLK("da830-mmc.1",  NULL,   _clk),
CLK("ti-aemif", NULL,   _clk),
CLK(NULL,   "aemif",_clk),
-   CLK("ohci", "usb11",_clk),
+   CLK("ohci-da8xx",   "usb11",_clk),
CLK("musb-da8xx",   "usb20",_clk),
CLK("spi_davinci.0",NULL,   _clk),
CLK("spi_davinci.1",NULL,   _clk),
diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c
index 92ae093..2afb067 100644
--- a/arch/arm/mach-davinci/da8xx-dt.c
+++ b/arch/arm/mach-davinci/da8xx-dt.c
@@ -39,7 +39,7 @@ static struct of_dev_auxdata da850_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("ti,da830-mcasp-audio", 0x01d0, "davinci-mcasp.0", 
NULL),
OF_DEV_AUXDATA("ti,da850-aemif", 0x6800, "ti-aemif", NULL),
OF_DEV_AUXDATA("ti,da850-tilcdc", 0x01e13000, "da8xx_lcdc.0", NULL),
-   OF_DEV_AUXDATA("ti,da830-ohci", 0x01e25000, "ohci", NULL),
+   OF_DEV_AUXDATA("ti,da830-ohci", 0x01e25000, "ohci-da8xx", NULL),
OF_DEV_AUXDATA("ti,da830-musb", 0x01e0, "musb-da8xx", NULL),
OF_DEV_AUXDATA("ti,da830-usb-phy", 0x01c1417c, "da8xx-usb-phy", NULL),
{}
diff --git a/arch/arm/mach-davinci/usb-da8xx.c 
b/arch/arm/mach-davinci/usb-da8xx.c
index b010e5f..c6feecf 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -109,8 +109,8 @@ static struct resource da8xx_usb11_resources[] = {
 static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
 
 static struct platform_device da8xx_usb11_device = {
-   .name   = "ohci",
-   .id = 0,
+   .name   = "ohci-da8xx",
+   .id = -1,
.dev = {
.dma_mask   = _usb11_dma_mask,
.coherent_dma_mask  = DMA_BIT_MASK(32),
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/3] davinci: ohci: fix usb ohci device name

2016-11-03 Thread Axel Haslam
The usb ohci clock match is not working because the usb clock
is registered as "ohci" instead of "ohci.0"

But since there is only a single ohci instance, lets pass -1 to
the platform data id parameter and avoid the extra ".0" matching.

while we are fixing this, rename the driver from "ohci" to
"ohci-da8xx" which  is less generic and consistent with other
usb drivers.

changes form v1 -> v2
*Reword commit messages (David Lechner)

Because of the recently accepted patches on the ARM-davinci side,
This patch series is based on:
branch: /v4.10/soc of the linux-davinci tree.

It Depends on two accepted usb patches missing on that branch:
6c21caa USB: OHCI: make ohci-da8xx a separate driver (in next-usb)
6110c42 usb: ohci-da8xx: Remove code that references mach (in linux-next)

A branch with both patches applied + this series can be found here:
https://github.com/axelhaslamx/linux-axel/commits/ti-davinci-ohci-rename


Axel Haslam (3):
  ARM: davinci: da8xx: Fix ohci device name
  phy: da8xx-usb: rename the ohci device to ohci-da8xx
  usb: ohci-da8xx: rename driver to ohci-da8xx

 arch/arm/mach-davinci/da830.c | 2 +-
 arch/arm/mach-davinci/da850.c | 2 +-
 arch/arm/mach-davinci/da8xx-dt.c  | 2 +-
 arch/arm/mach-davinci/usb-da8xx.c | 4 ++--
 drivers/phy/phy-da8xx-usb.c   | 5 +++--
 drivers/usb/host/ohci-da8xx.c | 2 +-
 6 files changed, 9 insertions(+), 8 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] fix ohci phy name

2016-11-03 Thread Axel Haslam
On Thu, Nov 3, 2016 at 1:00 PM, Sekhar Nori <nsek...@ti.com> wrote:
> On Thursday 03 November 2016 01:54 PM, Axel Haslam wrote:
>> Hi Sekhar, David,
>>
>> It might make sense to have this patch series,
>> squashed into a single patch, would you agree,
>> or do you prefer it as is: one-per-subsystem?
>
> Patches in the current form are okay. Some coordination is required in
> getting them merged though. I am happy to take the driver patches
> through ARM-SoC with ack from respective maintainers.
>
> I will need to carry the platform patch through my tree because it
> conflicts with other changes I have already queued.
>
> That said, I am unable to review 3/3 since I am unable to find its baseline.
>

ok, ill send v2 fixing Davids comments on the commit messages
and referencing the missing patch that is queued on usb-next.

-Axel
> Thanks,
> Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] usb: ohci-da8xx: rename driver to ohci-da8xx

2016-11-03 Thread Axel Haslam
Hi Sekhar,

The baseline used was the branch usb-next, in Greg's tree:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git

Linux next is missing this patch[1] which was applied last week,
but not yet pulled into linux-next. it will be there soon.

Sorry, i did not mention it, i thought it would be already
on linux-next.

[1]
6c21caa USB: OHCI: make ohci-da8xx a separate driver
https://lkml.org/lkml/2016/10/27/120

Regards
Axel



On Thu, Nov 3, 2016 at 12:56 PM, Sekhar Nori <nsek...@ti.com> wrote:
> On Wednesday 02 November 2016 06:14 PM, Axel Haslam wrote:
>> To be consistent on the usb driver for the davinci
>> platform follow the example of musb, and add the
>> "-da8xx" postfix to the driver name.
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>>  drivers/usb/host/ohci-da8xx.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
>> index bd6cf3c..b3de8bc 100644
>> --- a/drivers/usb/host/ohci-da8xx.c
>> +++ b/drivers/usb/host/ohci-da8xx.c
>> @@ -27,7 +27,7 @@
>>  #include "ohci.h"
>>
>>  #define DRIVER_DESC "DA8XX"
>> -#define DRV_NAME "ohci"
>> +#define DRV_NAME "ohci-da8xx"
>
> To which baseline does this patch apply? I don't see this code in
> linux-next.
>
> Thanks,
> Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/3] fix ohci phy name

2016-11-03 Thread Axel Haslam
Hi Sekhar, David,

It might make sense to have this patch series,
squashed into a single patch, would you agree,
or do you prefer it as is: one-per-subsystem?

Regards
Axel.

On Wed, Nov 2, 2016 at 1:44 PM, Axel Haslam <ahas...@baylibre.com> wrote:
> The usb ohci clock match is not working because the usb clock
> is registered as "ohci" instead of "ohci.0"
>
> But since there is only a single ohci instance, lets pass -1 to
> the platform data id parameter and avoid the extra ".0" matching.
>
> while we are fixing this, rename the driver to "ohci-da8xx" to be
> consistent with davinci musb and other usb drivers.
>
> Axel Haslam (3):
>   ARM: davinci: da8xx: Fix ohci driver name
>   phy: da8xx-usb: rename the ohci device to ohci-da8xx
>   usb: ohci-da8xx: rename driver to ohci-da8xx
>
>  arch/arm/mach-davinci/da830.c | 2 +-
>  arch/arm/mach-davinci/da850.c | 2 +-
>  arch/arm/mach-davinci/da8xx-dt.c  | 2 +-
>  arch/arm/mach-davinci/usb-da8xx.c | 4 ++--
>  drivers/phy/phy-da8xx-usb.c   | 5 +++--
>  drivers/usb/host/ohci-da8xx.c | 2 +-
>  6 files changed, 9 insertions(+), 8 deletions(-)
>
> --
> 2.10.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] ARM: davinci: da8xx: Fix ohci driver name

2016-11-02 Thread Axel Haslam
There is a single instance of the ohci driver,
while the clk lookup table is making reference to "ohci"
other subsystems (such as phy) are looking for "ohci.0"

Since there is a single ohci instance, change the dev id
to -1, and add the "-da8xx" for consitancy with the musb
driver name.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 arch/arm/mach-davinci/da830.c | 2 +-
 arch/arm/mach-davinci/da850.c | 2 +-
 arch/arm/mach-davinci/da8xx-dt.c  | 2 +-
 arch/arm/mach-davinci/usb-da8xx.c | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c
index 41459bd..073c458 100644
--- a/arch/arm/mach-davinci/da830.c
+++ b/arch/arm/mach-davinci/da830.c
@@ -420,7 +420,7 @@ static struct clk_lookup da830_clks[] = {
CLK("davinci_mdio.0",   "fck",  _clk),
CLK(NULL,   "gpio", _clk),
CLK("i2c_davinci.2",NULL,   _clk),
-   CLK("ohci", "usb11",_clk),
+   CLK("ohci-da8xx",   "usb11",_clk),
CLK(NULL,   "emif3",_clk),
CLK(NULL,   "arm",  _clk),
CLK(NULL,   "rmii", _clk),
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 196e262..3961556 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -503,7 +503,7 @@ static struct clk_lookup da850_clks[] = {
CLK("da830-mmc.1",  NULL,   _clk),
CLK("ti-aemif", NULL,   _clk),
CLK(NULL,   "aemif",_clk),
-   CLK("ohci", "usb11",_clk),
+   CLK("ohci-da8xx",   "usb11",_clk),
CLK("musb-da8xx",   "usb20",_clk),
CLK("spi_davinci.0",NULL,   _clk),
CLK("spi_davinci.1",NULL,   _clk),
diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c
index 92ae093..2afb067 100644
--- a/arch/arm/mach-davinci/da8xx-dt.c
+++ b/arch/arm/mach-davinci/da8xx-dt.c
@@ -39,7 +39,7 @@ static struct of_dev_auxdata da850_auxdata_lookup[] 
__initdata = {
OF_DEV_AUXDATA("ti,da830-mcasp-audio", 0x01d0, "davinci-mcasp.0", 
NULL),
OF_DEV_AUXDATA("ti,da850-aemif", 0x6800, "ti-aemif", NULL),
OF_DEV_AUXDATA("ti,da850-tilcdc", 0x01e13000, "da8xx_lcdc.0", NULL),
-   OF_DEV_AUXDATA("ti,da830-ohci", 0x01e25000, "ohci", NULL),
+   OF_DEV_AUXDATA("ti,da830-ohci", 0x01e25000, "ohci-da8xx", NULL),
OF_DEV_AUXDATA("ti,da830-musb", 0x01e0, "musb-da8xx", NULL),
OF_DEV_AUXDATA("ti,da830-usb-phy", 0x01c1417c, "da8xx-usb-phy", NULL),
{}
diff --git a/arch/arm/mach-davinci/usb-da8xx.c 
b/arch/arm/mach-davinci/usb-da8xx.c
index b010e5f..c6feecf 100644
--- a/arch/arm/mach-davinci/usb-da8xx.c
+++ b/arch/arm/mach-davinci/usb-da8xx.c
@@ -109,8 +109,8 @@ static struct resource da8xx_usb11_resources[] = {
 static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
 
 static struct platform_device da8xx_usb11_device = {
-   .name   = "ohci",
-   .id = 0,
+   .name   = "ohci-da8xx",
+   .id = -1,
.dev = {
.dma_mask   = _usb11_dma_mask,
.coherent_dma_mask  = DMA_BIT_MASK(32),
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] phy: da8xx-usb: rename the ohci device to ohci-da8xx

2016-11-02 Thread Axel Haslam
There is only one ohci on the da8xx series of chips,
so remove the ".0" when creating the phy. Also add
the "-da8xx" postfix to be consistent across davinci
usb drivers.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/phy/phy-da8xx-usb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-da8xx-usb.c b/drivers/phy/phy-da8xx-usb.c
index 32ae78c..c85fb0b 100644
--- a/drivers/phy/phy-da8xx-usb.c
+++ b/drivers/phy/phy-da8xx-usb.c
@@ -198,7 +198,8 @@ static int da8xx_usb_phy_probe(struct platform_device *pdev)
} else {
int ret;
 
-   ret = phy_create_lookup(d_phy->usb11_phy, "usb-phy", "ohci.0");
+   ret = phy_create_lookup(d_phy->usb11_phy, "usb-phy",
+   "ohci-da8xx");
if (ret)
dev_warn(dev, "Failed to create usb11 phy lookup\n");
ret = phy_create_lookup(d_phy->usb20_phy, "usb-phy",
@@ -216,7 +217,7 @@ static int da8xx_usb_phy_remove(struct platform_device 
*pdev)
 
if (!pdev->dev.of_node) {
phy_remove_lookup(d_phy->usb20_phy, "usb-phy", "musb-da8xx");
-   phy_remove_lookup(d_phy->usb11_phy, "usb-phy", "ohci.0");
+   phy_remove_lookup(d_phy->usb11_phy, "usb-phy", "ohci-da8xx");
}
 
return 0;
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/3] fix ohci phy name

2016-11-02 Thread Axel Haslam
The usb ohci clock match is not working because the usb clock
is registered as "ohci" instead of "ohci.0"

But since there is only a single ohci instance, lets pass -1 to
the platform data id parameter and avoid the extra ".0" matching.

while we are fixing this, rename the driver to "ohci-da8xx" to be
consistent with davinci musb and other usb drivers.

Axel Haslam (3):
  ARM: davinci: da8xx: Fix ohci driver name
  phy: da8xx-usb: rename the ohci device to ohci-da8xx
  usb: ohci-da8xx: rename driver to ohci-da8xx

 arch/arm/mach-davinci/da830.c | 2 +-
 arch/arm/mach-davinci/da850.c | 2 +-
 arch/arm/mach-davinci/da8xx-dt.c  | 2 +-
 arch/arm/mach-davinci/usb-da8xx.c | 4 ++--
 drivers/phy/phy-da8xx-usb.c   | 5 +++--
 drivers/usb/host/ohci-da8xx.c | 2 +-
 6 files changed, 9 insertions(+), 8 deletions(-)

-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] usb: ohci-da8xx: rename driver to ohci-da8xx

2016-11-02 Thread Axel Haslam
To be consistent on the usb driver for the davinci
platform follow the example of musb, and add the
"-da8xx" postfix to the driver name.

Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---
 drivers/usb/host/ohci-da8xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index bd6cf3c..b3de8bc 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -27,7 +27,7 @@
 #include "ohci.h"
 
 #define DRIVER_DESC "DA8XX"
-#define DRV_NAME "ohci"
+#define DRV_NAME "ohci-da8xx"
 
 static struct hc_driver __read_mostly ohci_da8xx_hc_driver;
 
-- 
2.10.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] USB: OHCI: make ohci-da8xx a separate driver

2016-10-27 Thread Axel Haslam
On Thu, Oct 27, 2016 at 2:58 AM, David Lechner  wrote:
> On 10/26/2016 04:08 PM, ahas...@baylibre.com wrote:
>
>> +module_exit(ohci_da8xx_exit);
>> +MODULE_DESCRIPTION(DRIVER_DESC);
>> +MODULE_LICENSE("GPL");
>>  MODULE_ALIAS("platform:ohci");
>
>
> The "ohci" in MODULE_ALIAS() should also be replaced with hcd_name.

i dont see any other module int the whole kernel that is
using a const char here, ill just change back to #define
the name and use that instead.


>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] USB: OHCI: make ohci-da8xx a separate driver

2016-10-27 Thread Axel Haslam
From: Manjunath Goudar <manjunath.gou...@linaro.org>

Separate the Davinci OHCI host controller driver from ohci-hcd
host code so that it can be built as a separate driver module.
This work is part of enabling multi-platform kernels on ARM

Tested-by: David Lechner <da...@lechnology.com>
Signed-off-by: Manjunath Goudar <manjunath.gou...@linaro.org>
[Axel: adapted and rebased, fixed minor comments]
Signed-off-by: Axel Haslam <ahas...@baylibre.com>
---

This was a previews patch submited by Manjunath [1]
that was never taken in because of an undefined symbol
when loading as a module. That symbol is not present anymore
so we can safly build the driver as a module.

I rebased, fixing the minor remaining comments.

V1->V2
* changed hdc_name to a #define and use it in MODE_ALIAS (David)
* Added tested-by tag from David

http://patches.linaro.org/patch/18234/
 drivers/usb/host/Kconfig  |   4 +-
 drivers/usb/host/Makefile |   1 +
 drivers/usb/host/ohci-da8xx.c | 182 --
 drivers/usb/host/ohci-hcd.c   |  18 -
 4 files changed, 74 insertions(+), 131 deletions(-)

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 83b6cec..6361fc7 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -479,9 +479,9 @@ config USB_OHCI_HCD_OMAP3
  OMAP3 and later chips.
 
 config USB_OHCI_HCD_DAVINCI
-   bool "OHCI support for TI DaVinci DA8xx"
+   tristate "OHCI support for TI DaVinci DA8xx"
depends on ARCH_DAVINCI_DA8XX
-   depends on USB_OHCI_HCD=y
+   depends on USB_OHCI_HCD
select PHY_DA8XX_USB
default y
help
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 6ef785b..2644537 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_USB_OHCI_HCD_AT91)   += ohci-at91.o
 obj-$(CONFIG_USB_OHCI_HCD_S3C2410) += ohci-s3c2410.o
 obj-$(CONFIG_USB_OHCI_HCD_LPC32XX) += ohci-nxp.o
 obj-$(CONFIG_USB_OHCI_HCD_PXA27X)  += ohci-pxa27x.o
+obj-$(CONFIG_USB_OHCI_HCD_DAVINCI) += ohci-da8xx.o
 
 obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
 obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index 3656d7c..30c4878 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -11,16 +11,29 @@
  * kind, whether express or implied.
  */
 
+#include 
+#include 
 #include 
 #include 
+#include 
+#include 
 #include 
-#include 
 #include 
 #include 
+#include 
+#include 
+#include 
 
-#ifndef CONFIG_ARCH_DAVINCI_DA8XX
-#error "This file is DA8xx bus glue.  Define CONFIG_ARCH_DAVINCI_DA8XX."
-#endif
+#include "ohci.h"
+
+#define DRIVER_DESC "DA8XX"
+#define DRV_NAME "ohci"
+
+static struct hc_driver __read_mostly ohci_da8xx_hc_driver;
+
+static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, u16 typeReq,
+   u16 wValue, u16 wIndex, char *buf, u16 wLength);
+static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
 
 static struct clk *usb11_clk;
 static struct phy *usb11_phy;
@@ -74,7 +87,7 @@ static void ohci_da8xx_ocic_handler(struct 
da8xx_ohci_root_hub *hub,
hub->set_power(port, 0);
 }
 
-static int ohci_da8xx_init(struct usb_hcd *hcd)
+static int ohci_da8xx_reset(struct usb_hcd *hcd)
 {
struct device *dev  = hcd->self.controller;
struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
@@ -94,7 +107,7 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
 */
ohci->num_ports = 1;
 
-   result = ohci_init(ohci);
+   result = ohci_setup(hcd);
if (result < 0) {
ohci_da8xx_disable();
return result;
@@ -122,30 +135,12 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
return result;
 }
 
-static void ohci_da8xx_stop(struct usb_hcd *hcd)
-{
-   ohci_stop(hcd);
-   ohci_da8xx_disable();
-}
-
-static int ohci_da8xx_start(struct usb_hcd *hcd)
-{
-   struct ohci_hcd *ohci   = hcd_to_ohci(hcd);
-   int result;
-
-   result = ohci_run(ohci);
-   if (result < 0)
-   ohci_da8xx_stop(hcd);
-
-   return result;
-}
-
 /*
  * Update the status data from the hub with the over-current indicator change.
  */
 static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
-   int length  = ohci_hub_status_data(hcd, buf);
+   int length  = orig_ohci_hub_status_data(hcd, buf);
 
/* See if we have OCIC bit set on port 1 */
if (ocic_mask & (1 << 1)) {
@@ -227,66 +222,13 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd, 
u16 typeReq, u16 wValue,
}
}
 
-   return ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);
+   return orig_ohci_hub_control(hcd, typeReq,

Re: [PATCH/RFT v2 12/17] USB: ochi-da8xx: Use a regulator for vbus/overcurrent

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 6:53 PM, David Lechner <da...@lechnology.com> wrote:
> On 10/25/2016 03:24 AM, Axel Haslam wrote:
>>
>> On Tue, Oct 25, 2016 at 3:39 AM, David Lechner <da...@lechnology.com>
>> wrote:
>>>
>>> On 10/24/2016 11:46 AM, ahas...@baylibre.com wrote:
>>>>
>>>>
>>>> From: Axel Haslam <ahas...@baylibre.com>
>>>>
>>>> Currently, the da8xx ohci driver uses a set of gpios and callbacks in
>>>> board files to handle vbus and overcurrent irqs form the power supply.
>>>> However, this does not play nice when moving to a DT based boot were
>>>> we wont have board files.
>>>>
>>>> Instead of requesting and handling the gpio, use the regulator framework
>>>> to take care of enabling and disabling vbus power.
>>>> This has the benefit
>>>> that we dont need to pass any more platform data to the driver:
>>>>
>>>> These will be handled by the regulator framework:
>>>> set_power   ->  regulator_enable/regulator_disable
>>>> get_power   ->  regulator_is_enabled
>>>> get_oci ->  regulator_get_mode
>>>> ocic_notify ->  regulator notification
>>>>
>>>> We can keep the default potpgt and use the regulator start delay
>>>> instead:
>>>> potpgt  -> regulator startup delay time
>>>>
>>>> The hawk board does not have a GPIO/OVERCURRENT gpio to control vbus,
>>>> (they should not have been decleared/reserved) so, just remove those
>>>> definitions from the hwk board file.
>>>>
>>>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>>>> ---
>>>
>>>
>>>
>>>
>>> How do you recover after an overcurrent event?
>>>
>>> I have configured a fixed-regulator using device-tree, but similar to the
>>> configuration in the board files here. However, when I shorted out the
>>> VBUS
>>> and caused an overcurrent event, I see nothing in the kernel log saying
>>> that
>>> there was an overcurrent event and after I remove the short, the
>>> regulator
>>> is never turned back on.
>>>
>>>
>>
>> You should have the patch to fix gpiolib, and you should declare the
>> over current gpio on the regulator as such:
>> (if the pin is enabled high you should add oc-active-high);
>>
>>vbus_fixed: fixed-regulator-vbus {
>>compatible = "regulator-fixed";
>>gpio = < 109 0>;
>>oc-gpio = < 36 0>;
>>regulator-boot-on;
>>enable-active-high;
>>regulator-name = "vbus";
>>regulator-min-microvolt = <500>;
>>regulator-max-microvolt = <500>;
>>};
>>
>>
>> Question: Do you see that the over current gpio was requested
>> in debugfs/gpio? and, do you see the interrupt in /proc/interrupts?
>>
>> If you unplug and plug in back the usb device it should work again.
>> also you can unbind and bind it should also start to work:
>> something like:
>>
>> echo usb1 >/sys/bus/usb/drivers/usb/unbind
>> echo usb1 >/sys/bus/usb/drivers/usb/bind
>>
>>
>
> I have added oc-active-high and I get different results, but it is still not
> quite right. When I short the VBUS, I can see that my overcurrent gpio
> changes state. However, the driver does not turn of the VBUS. When I remove
> the short, I get an overcurrent error in the kernel log. I would expect this
> when I create the short, not when I remove it. I also tried adding
> GPIO_ACTIVE_LOW to the oc-gpio, but this did not change the behavior. In
> either case, the oc_gpio shows as high under normal conditions, so perhaps
> there is a problem with the gpio-davinci driver not picking up
> GPIO_ACTIVE_LOW from the device tree.
>
>
> My regulator is basically the same. My device just uses different gpios.
>
> vbus_reg: vbus-reg {
> compatible = "regulator-fixed";
> pinctrl-names = "default";
> pinctrl-0 = <_pins>;
> gpio = < 101 GPIO_ACTIVE_LOW>;
> oc-gpio = < 99 0>;
> enable-active-high;
> oc-active-high;
> regulator-name = "vbus";
> regulator-min-microvolt = <500>;
> regulator-max

Re: [PATCH/RFT v2 11/17] USB: OHCI: make ohci-da8xx a separate driver

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 6:12 PM, David Lechner <da...@lechnology.com> wrote:
> On 10/25/2016 02:39 AM, Axel Haslam wrote:
>>
>> On Tue, Oct 25, 2016 at 2:38 AM, David Lechner <da...@lechnology.com>
>> wrote:
>>>
>>> On 10/24/2016 11:46 AM, ahas...@baylibre.com wrote:
>>>>
>>>>
>>>> -#ifndef CONFIG_ARCH_DAVINCI_DA8XX
>>>> -#error "This file is DA8xx bus glue.  Define
>>>> CONFIG_ARCH_DAVINCI_DA8XX."
>>>> -#endif
>>>> +#include "ohci.h"
>>>> +
>>>> +#define DRIVER_DESC "OHCI DA8XX driver"
>>>> +
>>>> +static const char hcd_name[] = "ohci-da8xx";
>>>
>>>
>>>
>>> why static const char instead of #define? This is only used one time in a
>>> pr_info, so it seems kind of pointless anyway.
>>
>>
>> Other drivers are using static const for the same variable.
>> i think static const is preferred over #define because #define doet give a
>> type.
>> If you dont mind ill keep it static const.
>>
>
> If this string was used in this file more than one place, I would agree with
> you, but currently it is only used as the argument of a pr_info(). The
> string "ohci-da8xx" could just be included in the fmt string instead of
> using "%s".

I think the purpose was to use it in the .name of the platform_driver
structure, too. only that not everybody is doing that, i looked at some bad
 examples :(

would you agree to keep it if we use it in .name too?

-Axel

>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 09/17] regulator: fixed: Add over current event

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 4:57 PM, Axel Haslam <ahas...@baylibre.com> wrote:
> On Tue, Oct 25, 2016 at 4:33 PM, Mark Brown <broo...@kernel.org> wrote:
>> On Tue, Oct 25, 2016 at 02:55:48PM +0200, Axel Haslam wrote:
>>
>>> To be able to use regulator to handle the overcurrent pin, i need to be able
>>> to somehow retrieve the over current pin state from the regulator driver.
>>
>> What makes you say that, none of the existing users need this?
>>
>>> As i was trying your suggestion, i remembered why i thought i should use
>>> mode instead of status: Status seems to be for internal regulator driver 
>>> use,
>>> there is no regulator_get_status, function and REGULATOR_STATUS_* are 
>>> defined
>>> in driver.h and not in consumer.h as  REGULATOR_MODE_*
>>
>>> Would you be ok if i allow consumers to get the status via a new
>>> "regulator_get_status" call?
>>
>> What would they do with this information that they can't do with the
>> existing error notification?
>
> the usb core relies in two flags that need too be set properly, one is the
> over-current indicator RH_PS_POCI , and the other is the over current
> indicator "change" (RH_PS_OCIC).
>
> The idea was to use the notification to set the over current indicator
> "change" flag,
> which will happen for both rising and falling edges. And to use
> get_status or get_mode
> to set the over-current indicator flag which should reflect the actual
> pin status.
>

BTW, for the notification, i should have used a new event flag
something like: OVER_CURRENT_CHANGED and not just OVER_CURRENT


Regards
Axel

>
> -Axel.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 09/17] regulator: fixed: Add over current event

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 4:33 PM, Mark Brown <broo...@kernel.org> wrote:
> On Tue, Oct 25, 2016 at 02:55:48PM +0200, Axel Haslam wrote:
>
>> To be able to use regulator to handle the overcurrent pin, i need to be able
>> to somehow retrieve the over current pin state from the regulator driver.
>
> What makes you say that, none of the existing users need this?
>
>> As i was trying your suggestion, i remembered why i thought i should use
>> mode instead of status: Status seems to be for internal regulator driver use,
>> there is no regulator_get_status, function and REGULATOR_STATUS_* are defined
>> in driver.h and not in consumer.h as  REGULATOR_MODE_*
>
>> Would you be ok if i allow consumers to get the status via a new
>> "regulator_get_status" call?
>
> What would they do with this information that they can't do with the
> existing error notification?

the usb core relies in two flags that need too be set properly, one is the
over-current indicator RH_PS_POCI , and the other is the over current
indicator "change" (RH_PS_OCIC).

The idea was to use the notification to set the over current indicator
"change" flag,
which will happen for both rising and falling edges. And to use
get_status or get_mode
to set the over-current indicator flag which should reflect the actual
pin status.


-Axel.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 09/17] regulator: fixed: Add over current event

2016-10-25 Thread Axel Haslam
Hi Mark,

On Mon, Oct 24, 2016 at 8:19 PM, Mark Brown <broo...@kernel.org> wrote:
> On Mon, Oct 24, 2016 at 08:11:40PM +0200, Axel Haslam wrote:
>> On Mon, Oct 24, 2016 at 7:53 PM, Mark Brown <broo...@kernel.org> wrote:
>
>> > does it make sense to report this as a mode, we don't report other error
>> > conditions as modes but instead use REGULATOR_STATUS_ with the
>> > get_status() operation?
>
>> I used mode, because when the regulator toggles the overcurrent
>> line, it means that it has entered a current limited mode, at least the
>> regulator im looking at. ill change to STATUS
>
> That's not what regulator modes are - please look at the documentation
> for the defines here.  They're about the quality of regulation.

To be able to use regulator to handle the overcurrent pin, i need to be able
to somehow retrieve the over current pin state from the regulator driver.

As i was trying your suggestion, i remembered why i thought i should use
mode instead of status: Status seems to be for internal regulator driver use,
there is no regulator_get_status, function and REGULATOR_STATUS_* are defined
in driver.h and not in consumer.h as  REGULATOR_MODE_*

it seems that status is only used to print sysfs info.

Would you be ok if i allow consumers to get the status via a new
"regulator_get_status" call?

Regards
Axel.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 12/17] USB: ochi-da8xx: Use a regulator for vbus/overcurrent

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 12:43 PM, Sekhar Nori <nsek...@ti.com> wrote:
> On Monday 24 October 2016 10:16 PM, ahas...@baylibre.com wrote:
>> From: Axel Haslam <ahas...@baylibre.com>
>>
>> Currently, the da8xx ohci driver uses a set of gpios and callbacks in
>> board files to handle vbus and overcurrent irqs form the power supply.
>> However, this does not play nice when moving to a DT based boot were
>> we wont have board files.
>>
>> Instead of requesting and handling the gpio, use the regulator framework
>> to take care of enabling and disabling vbus power. This has the benefit
>> that we dont need to pass any more platform data to the driver:
>>
>> These will be handled by the regulator framework:
>> set_power   ->  regulator_enable/regulator_disable
>> get_power   ->  regulator_is_enabled
>> get_oci ->  regulator_get_mode
>> ocic_notify ->  regulator notification
>>
>> We can keep the default potpgt and use the regulator start delay instead:
>> potpgt  -> regulator startup delay time
>>
>> The hawk board does not have a GPIO/OVERCURRENT gpio to control vbus,
>> (they should not have been decleared/reserved) so, just remove those
>> definitions from the hwk board file.
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>>  arch/arm/mach-davinci/board-da830-evm.c |  97 
>>  arch/arm/mach-davinci/board-omapl138-hawk.c |  96 +---
>>  arch/arm/mach-davinci/include/mach/da8xx.h  |   2 +-
>>  arch/arm/mach-davinci/usb-da8xx.c   |   3 +-
>>  drivers/usb/host/ohci-da8xx.c   | 111 
>> ++--
>>  include/linux/platform_data/usb-davinci.h   |  19 -
>>  6 files changed, 105 insertions(+), 223 deletions(-)
>
> Can you separate out the driver enhancement from the platform
> (mach-davinci) changes? They need to go through different trees.
>

Ok, i will do that,  (it might require intermediate code to have
the driver working on each patch)

> Thanks,
> Sekhar
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 08/17] ARM: davinci: hawk: add full constraints for ohci plat boot

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 12:28 PM, Sekhar Nori <nsek...@ti.com> wrote:
> On Monday 24 October 2016 10:16 PM, ahas...@baylibre.com wrote:
>> From: Axel Haslam <ahas...@baylibre.com>
>>
>> The phy framework requests an optional "phy" regulator. If it does
>> not find one, it returns -EPROBE_DEFER. In the case of non-DT based boot
>> for the omap138-lcdk board, this would prevent the usb11 phy to probe
>> correctly and ohci would not enumerate.
>>
>> By calling "regulator_has_full_constraints", An error would be returned
>
> nit: prefer regulator_has_full_constraints()
>
>> instead of DEFER for the "optional" regulator, and the probe of
>> the phy driver can continue normally without a regulator.
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>
> Looks good to me. Just drop the "hawk: from subject line since you also
> touch da830 evm. I am not sure what "ohci plat boot" means. How about
> the following:
>
> "ARM: davinci: da8xx: fix OHCI PHY probe for non-DT boot"
>

Will do.

Thanks
Axel.

> Thanks,
> Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 07/17] ARM: davinci: da8xx: Enable the usb20 "per" clk on phy_clk_enable

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 4:53 AM, David Lechner <da...@lechnology.com> wrote:
> On 10/24/2016 11:46 AM, ahas...@baylibre.com wrote:
>>
>> From: Axel Haslam <ahas...@baylibre.com>
>>
>> While probing ochi phy with usb20 phy as a parent clock for usb11_phy,
>> the usb20_phy clock enable would time out. This is because the usb20
>> module clock needs to enabled while trying to lock the usb20_phy PLL.
>>
>> Call clk enable and get for the usb20 peripheral before trying to
>> enable the phy PLL.
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>
>
>
> This patch can be combined with "ARM: davinci: da8xx: add usb phy clocks"
> since that patch has not been merged yet.

yes, agree, these should be merged.

>
> If you like, I can resubmit my patches from this series along with the
> changes from this patch.

Ok, if you can resubmit those patches with this change  included
i can reference them and start making the series shorter.
i will also submit in separate patches the regulator changes, as requested
by Mark.



Regards
Axel.

>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 13/17] USB: da8xx: use ohci priv data instead of globals

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 3:12 AM, David Lechner <da...@lechnology.com> wrote:
> On 10/24/2016 11:46 AM, ahas...@baylibre.com wrote:
>>
>> From: Axel Haslam <ahas...@baylibre.com>
>> >  static const struct ohci_driver_overrides da8xx_overrides __initconst =
>> > {
>> -   .reset  = ohci_da8xx_reset
>> +   .reset  = ohci_da8xx_reset,
>> +   .extra_priv_size = sizeof(struct da8xx_ohci_hcd),
>
>
> nit: since you are changing both lines anyway, you might as well make the
> ='s line up.

ok, will do.

>
>>  };
>>
>>  /*
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 15/17] usb: host: ohci-da8xx: Add devicetree bindings documentation

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 3:02 AM, David Lechner <da...@lechnology.com> wrote:
> On 10/24/2016 11:46 AM, ahas...@baylibre.com wrote:
>>
>> From: Axel Haslam <ahas...@baylibre.com>
>>
>> This patch documents the device tree bindings required for
>> the ohci controller found in TI da8xx family of SoC's
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>>  .../devicetree/bindings/usb/ohci-da8xx.txt | 39
>> ++
>>  1 file changed, 39 insertions(+)
>>  create mode 100644 Documentation/devicetree/bindings/usb/ohci-da8xx.txt
>>
>> diff --git a/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
>> b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
>> new file mode 100644
>> index 000..4251c84
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/usb/ohci-da8xx.txt
>> @@ -0,0 +1,39 @@
>> +DA8XX USB OHCI controller
>> +
>> +Required properties:
>> +
>> + - compatible: Should be "ti,da830-ohci"
>> + - reg:Should contain one register range i.e. start and length
>> + - interrupts: Description of the interrupt line
>> + - phys:   Phandle for the PHY device
>> + - phy-names:  Should be "usb-phy"
>> +
>> +Optional properties:
>> + - vbus-supply: Regulator that controls vbus power
>
>
>
> Isn't vbus-supply property required?
>
> If it is really supposed to be optional, the ohci driver needs to use
> devm_regulator_get_optional() and handle the case when there is no
> regulator.
>
> I don't see a problem with making it required though since one can just use
> a dummy supply if there is not a real one.

The regulator framework will use a dummy regulator if none is provided.

>
>> +
>> +Example for omap138-lck:
>> +
>> +vbus_fixed: fixed-regulator-vbus {
>> +compatible = "regulator-fixed";
>> +gpio = < 109 0>;
>> +oc-gpio = < 36 0>;
>> +regulator-boot-on;
>> +enable-active-high;
>> +regulator-name = "vbus";
>> +regulator-min-microvolt = <500>;
>> +regulator-max-microvolt = <500>;
>> +};
>> +
>> +usb_phy: usb-phy {
>> +compatible = "ti,da830-usb-phy";
>> +#phy-cells = <1>;
>> +status = "disabled";
>
>
> why disabled?
>

yes, i copied from the device tree im using, but
i should enable these for the example,
i will fix.

>> +};
>> +usb: usb@0225000 {
>> +compatible = "ti,da830-ohci";
>> +reg = <0x225000 0x1000>;
>> +interrupts = <59>;
>> +phys = <_phy 1>;
>> +phy-names = "usb-phy";
>
>
> missing vbus-supply property
>
>> +status = "disabled";
>
>
> why disabled?
>
>> +};
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 03/17] ARM: davinci: da8xx: Add USB PHY platform declaration

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 11:18 AM, Sekhar Nori  wrote:
> On Monday 24 October 2016 10:16 PM, ahas...@baylibre.com wrote:
>> +static struct platform_device da8xx_usb_phy = {
>> + .name   = "da8xx-usb-phy",
>> + .id = 0,
>
> There is a single phy control in the system for both 1.1 and 2.0 PHYs.
> so this can be a singular device (id -1).
>

Ok.

> Thanks,
> Sekhar
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 02/17] ARM: davinci: da8xx: Add CFGCHIP syscon platform declaration.

2016-10-25 Thread Axel Haslam
Hi Sekar,

On Tue, Oct 25, 2016 at 10:10 AM, Sekhar Nori <nsek...@ti.com> wrote:
> On Monday 24 October 2016 10:16 PM, ahas...@baylibre.com wrote:
>> From: David Lechner <da...@lechnology.com>
>>
>> The CFGCHIP registers are used by a number of devices, so using a syscon
>> device to share them. The first consumer of this will by the phy-da8xx-usb
>> driver.
>>
>> Signed-off-by: David Lechner <da...@lechnology.com>
>> [Axel: minor fix: change id to -1]
>
> Can you please clarify this change? There could be other syscon devices
> on the chip for other common registers. Why use the singular device-id?
>

in the case of non DT boot, the phy driver is looking for "syscon" :

d_phy->regmap = syscon_regmap_lookup_by_pdevname("syscon");

if we register the syscon driver with id = 0, the actual name of the syscon
device will be "syscon.0" and the phy driver will fail to probe, because
the strncmp match in the syscon driver (syscon_match_pdevname)
will fail.

should i change the phy driver instead?


Regards,
Axel.



>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>
> Thanks,
> Sekhar
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 12/17] USB: ochi-da8xx: Use a regulator for vbus/overcurrent

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 3:39 AM, David Lechner <da...@lechnology.com> wrote:
> On 10/24/2016 11:46 AM, ahas...@baylibre.com wrote:
>>
>> From: Axel Haslam <ahas...@baylibre.com>
>>
>> Currently, the da8xx ohci driver uses a set of gpios and callbacks in
>> board files to handle vbus and overcurrent irqs form the power supply.
>> However, this does not play nice when moving to a DT based boot were
>> we wont have board files.
>>
>> Instead of requesting and handling the gpio, use the regulator framework
>> to take care of enabling and disabling vbus power.
>> This has the benefit
>> that we dont need to pass any more platform data to the driver:
>>
>> These will be handled by the regulator framework:
>> set_power   ->  regulator_enable/regulator_disable
>> get_power   ->  regulator_is_enabled
>> get_oci ->  regulator_get_mode
>> ocic_notify ->  regulator notification
>>
>> We can keep the default potpgt and use the regulator start delay instead:
>> potpgt  -> regulator startup delay time
>>
>> The hawk board does not have a GPIO/OVERCURRENT gpio to control vbus,
>> (they should not have been decleared/reserved) so, just remove those
>> definitions from the hwk board file.
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>
>
>
> How do you recover after an overcurrent event?
>
> I have configured a fixed-regulator using device-tree, but similar to the
> configuration in the board files here. However, when I shorted out the VBUS
> and caused an overcurrent event, I see nothing in the kernel log saying that
> there was an overcurrent event and after I remove the short, the regulator
> is never turned back on.
>
>

You should have the patch to fix gpiolib, and you should declare the
over current gpio on the regulator as such:
(if the pin is enabled high you should add oc-active-high);

   vbus_fixed: fixed-regulator-vbus {
   compatible = "regulator-fixed";
   gpio = < 109 0>;
   oc-gpio = < 36 0>;
   regulator-boot-on;
   enable-active-high;
   regulator-name = "vbus";
   regulator-min-microvolt = <500>;
   regulator-max-microvolt = <500>;
   };


Question: Do you see that the over current gpio was requested
in debugfs/gpio? and, do you see the interrupt in /proc/interrupts?

If you unplug and plug in back the usb device it should work again.
also you can unbind and bind it should also start to work:
something like:

echo usb1 >/sys/bus/usb/drivers/usb/unbind
echo usb1 >/sys/bus/usb/drivers/usb/bind


>
>> @@ -163,7 +198,6 @@ static int ohci_da8xx_hub_control(struct usb_hcd *hcd,
>> u16 typeReq, u16 wValue,
>>   u16 wIndex, char *buf, u16 wLength)
>>  {
>> struct device *dev  = hcd->self.controller;
>> -   struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
>
>
> nit: unnecessary whitespace change
>
>> int temp;
>>
>> switch (typeReq) {
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 16/17] USB: ohci-da8xx: Allow probing from DT

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 2:53 AM, David Lechner <da...@lechnology.com> wrote:
> On 10/24/2016 11:46 AM, ahas...@baylibre.com wrote:
>>
>> From: Axel Haslam <ahas...@baylibre.com>
>>
>> This adds the compatible string to the ohci driver
>> to be able to probe from DT
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>>  drivers/usb/host/ohci-da8xx.c | 8 
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
>> index bebc3f0..1a8db25 100644
>> --- a/drivers/usb/host/ohci-da8xx.c
>> +++ b/drivers/usb/host/ohci-da8xx.c
>> @@ -273,6 +273,13 @@ static int ohci_da8xx_hub_control(struct usb_hcd
>> *hcd, u16 typeReq, u16 wValue,
>>  }
>>
>>
>> /*-*/
>> +#ifdef CONFIG_OF
>
>
> #ifdef CONFIG_OF is probably not needed here...
>
>> +static const struct of_device_id da8xx_ohci_ids[] = {
>> +   { .compatible = "ti,da830-ohci" },
>> +   { }
>> +};
>> +MODULE_DEVICE_TABLE(of, da8xx_ohci_ids);
>> +#endif
>>
>>  static int ohci_da8xx_probe(struct platform_device *pdev)
>>  {
>> @@ -421,6 +428,7 @@ static int ohci_da8xx_resume(struct platform_device
>> *dev)
>>  #endif
>> .driver = {
>> .name   = "ohci",
>> +   .of_match_table = da8xx_ohci_ids,
>
>
> ...otherwise, da8xx_ohci_ids will not be defined here

this should be  .of_match_table = of_match_ptr(da8xx_ohci_ids),
will fix.

>
>> },
>>  };
>>
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 17/17] ARM: dts: da850: add usb device node

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 2:48 AM, David Lechner <da...@lechnology.com> wrote:
> On 10/24/2016 11:46 AM, ahas...@baylibre.com wrote:
>>
>> From: Axel Haslam <ahas...@baylibre.com>
>>
>> This adds the usb (ohci) device node for the da850 soc.
>> Also it enables it for the lcdk board
>>
>> Signed-off-by: Axel Haslam <ahas...@baylibre.com>
>> ---
>>  arch/arm/boot/dts/da850-lcdk.dts | 8 
>>  arch/arm/boot/dts/da850.dtsi | 8 
>>  2 files changed, 16 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/da850-lcdk.dts
>> b/arch/arm/boot/dts/da850-lcdk.dts
>> index 7b8ab21..fa91339 100644
>> --- a/arch/arm/boot/dts/da850-lcdk.dts
>> +++ b/arch/arm/boot/dts/da850-lcdk.dts
>> @@ -86,6 +86,14 @@
>> };
>>  };
>>
>> +_phy {
>> +   status = "okay";
>> +};
>> +
>> + {
>> +   status = "okay";
>
>
> Don't you need to specify a regulator here using the vbus-supply property?

its is not mandatory, the regulator framework is giving a dummy supply
on regulator_get if it does not find a regulator on device tree. That is
what i could understand from: _regulator_get in regulator/core.c

Also, in the case of platform based boot, if the board init calls
regulator_has_full_constraints which is anyways needed for the phy to probe
correctly it will also return a dummy regulator.


>
>> +};
>> +
>>   {
>> pinctrl-names = "default";
>> pinctrl-0 = <_rxtx_pins>;
>> diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi
>> index 33fcdce..ec2cec3 100644
>> --- a/arch/arm/boot/dts/da850.dtsi
>> +++ b/arch/arm/boot/dts/da850.dtsi
>> @@ -381,6 +381,14 @@
>> #phy-cells = <1>;
>> status = "disabled";
>> };
>> +   usb: usb@0225000 {
>
>
> Don't need the leading 0 on usb@225000
>
> The alias (usb:) might need to be more specific since there is a second usb
> device that will be added later for musb. (The comments in the previous
> review only referred to the "usb" in "usb@", not the alias.)

ok.

>
>> +   compatible = "ti,da830-ohci";
>> +   reg = <0x225000 0x1000>;
>> +   interrupts = <59>;
>> +   phys = <_phy 1>;
>> +   phy-names = "usb-phy";
>> +   status = "disabled";
>> +   };
>> gpio: gpio@226000 {
>> compatible = "ti,dm6441-gpio";
>> gpio-controller;
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 11/17] USB: OHCI: make ohci-da8xx a separate driver

2016-10-25 Thread Axel Haslam
On Tue, Oct 25, 2016 at 2:38 AM, David Lechner  wrote:
> On 10/24/2016 11:46 AM, ahas...@baylibre.com wrote:
>>
>> From: Manjunath Goudar 
>>
>> Separate the Davinci OHCI host controller driver from ohci-hcd
>> host code so that it can be built as a separate driver module.
>> This work is part of enabling multi-platform kernels on ARM;
>> it would be nice to have in 3.11.
>
>
> No need for comment about kernel 3.11.

yes, ok.

>
>>
>> Signed-off-by: Manjunath Goudar 
>> ---
>>  drivers/usb/host/Kconfig  |   2 +-
>>  drivers/usb/host/Makefile |   1 +
>>  drivers/usb/host/ohci-da8xx.c | 185
>> +-
>>  drivers/usb/host/ohci-hcd.c   |  18 
>>  4 files changed, 76 insertions(+), 130 deletions(-)
>>
>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>> index 83b6cec..642c6fe8 100644
>> --- a/drivers/usb/host/Kconfig
>> +++ b/drivers/usb/host/Kconfig
>> @@ -479,7 +479,7 @@ config USB_OHCI_HCD_OMAP3
>>   OMAP3 and later chips.
>>
>>  config USB_OHCI_HCD_DAVINCI
>> -   bool "OHCI support for TI DaVinci DA8xx"
>> +   tristate "OHCI support for TI DaVinci DA8xx"
>> depends on ARCH_DAVINCI_DA8XX
>> depends on USB_OHCI_HCD=y
>
>
> Need to drop the "=y" here, otherwise you still can't compile this as a
> module.

Im able to complile it as a module, but ok ill remove it.

>
>> select PHY_DA8XX_USB
>> diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
>> index 6ef785b..2644537 100644
>> --- a/drivers/usb/host/Makefile
>> +++ b/drivers/usb/host/Makefile
>> @@ -61,6 +61,7 @@ obj-$(CONFIG_USB_OHCI_HCD_AT91)   += ohci-at91.o
>>  obj-$(CONFIG_USB_OHCI_HCD_S3C2410) += ohci-s3c2410.o
>>  obj-$(CONFIG_USB_OHCI_HCD_LPC32XX) += ohci-nxp.o
>>  obj-$(CONFIG_USB_OHCI_HCD_PXA27X)  += ohci-pxa27x.o
>> +obj-$(CONFIG_USB_OHCI_HCD_DAVINCI) += ohci-da8xx.o
>>
>>  obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
>>  obj-$(CONFIG_USB_FHCI_HCD) += fhci.o
>> diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
>> index e98066d..5585d9e 100644
>> --- a/drivers/usb/host/ohci-da8xx.c
>> +++ b/drivers/usb/host/ohci-da8xx.c
>> @@ -11,16 +11,31 @@
>>   * kind, whether express or implied.
>>   */
>>
>> +#include 
>> +#include 
>>  #include 
>>  #include 
>> +#include 
>> +#include 
>>  #include 
>> -#include 
>>  #include 
>>  #include 
>> +#include 
>
>
> linux/platform_device.h is listed twice
>
>> +#include 
>> +#include 
>> +#include 
>>
>> -#ifndef CONFIG_ARCH_DAVINCI_DA8XX
>> -#error "This file is DA8xx bus glue.  Define CONFIG_ARCH_DAVINCI_DA8XX."
>> -#endif
>> +#include "ohci.h"
>> +
>> +#define DRIVER_DESC "OHCI DA8XX driver"
>> +
>> +static const char hcd_name[] = "ohci-da8xx";
>
>
> why static const char instead of #define? This is only used one time in a
> pr_info, so it seems kind of pointless anyway.

Other drivers are using static const for the same variable.
i think static const is preferred over #define because #define doet give a type.
If you dont mind ill keep it static const.


>
>> +
>> +static struct hc_driver __read_mostly ohci_da8xx_hc_driver;
>> +
>> +static int (*orig_ohci_hub_control)(struct usb_hcd  *hcd, u16 typeReq,
>> +   u16 wValue, u16 wIndex, char *buf, u16 wLength);
>> +static int (*orig_ohci_hub_status_data)(struct usb_hcd *hcd, char *buf);
>>
>>  static struct clk *usb11_clk;
>>  static struct phy *usb11_phy;
>> @@ -73,7 +88,7 @@ static void ohci_da8xx_ocic_handler(struct
>> da8xx_ohci_root_hub *hub)
>> hub->set_power(0);
>>  }
>>
>> -static int ohci_da8xx_init(struct usb_hcd *hcd)
>> +static int ohci_da8xx_reset(struct usb_hcd *hcd)
>>  {
>> struct device *dev  = hcd->self.controller;
>> struct da8xx_ohci_root_hub *hub = dev_get_platdata(dev);
>> @@ -93,7 +108,7 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
>>  */
>> ohci->num_ports = 1;
>>
>> -   result = ohci_init(ohci);
>> +   result = ohci_setup(hcd);
>> if (result < 0) {
>> ohci_da8xx_disable();
>> return result;
>> @@ -121,30 +136,12 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
>> return result;
>>  }
>>
>> -static void ohci_da8xx_stop(struct usb_hcd *hcd)
>> -{
>> -   ohci_stop(hcd);
>> -   ohci_da8xx_disable();
>> -}
>> -
>> -static int ohci_da8xx_start(struct usb_hcd *hcd)
>> -{
>> -   struct ohci_hcd *ohci   = hcd_to_ohci(hcd);
>> -   int result;
>> -
>> -   result = ohci_run(ohci);
>> -   if (result < 0)
>> -   ohci_da8xx_stop(hcd);
>> -
>> -   return result;
>> -}
>> -
>>  /*
>>   * Update the status data from the hub with the over-current indicator
>> change.
>>   */
>>  static int ohci_da8xx_hub_status_data(struct usb_hcd *hcd, char *buf)
>>  {
>> -   int length  = ohci_hub_status_data(hcd, buf);
>> + 

Re: [PATCH/RFT v2 09/17] regulator: fixed: Add over current event

2016-10-24 Thread Axel Haslam
On Mon, Oct 24, 2016 at 7:53 PM, Mark Brown  wrote:
> On Mon, Oct 24, 2016 at 06:46:26PM +0200, ahas...@baylibre.com wrote:
>
>> + if (ret) {
>> + pr_err("Failed to request irq: %d\n", ret);
>
> dev_err()
>
>> +++ b/include/linux/regulator/consumer.h
>> @@ -74,6 +74,10 @@
>>   * the most noisy and may not be able to handle fast load
>>   * switching.
>>   *
>> + * OVERCURRENT Regulator has detected an overcurrent condition, and
>> + * may be limiting the supply output.
>> + *
>> + *
>>   * NOTE: Most regulators will only support a subset of these modes. Some
>>   * will only just support NORMAL.
>>   *
>> @@ -84,6 +88,7 @@
>>  #define REGULATOR_MODE_NORMAL0x2
>>  #define REGULATOR_MODE_IDLE  0x4
>>  #define REGULATOR_MODE_STANDBY   0x8
>> +#define REGULATOR_MODE_OVERCURRENT   0x10
>
> This is adding a new core feature with a new mode and should have been
> split out of the driver specific change with a spearate changelog.  Why

Ok, will do.

> does it make sense to report this as a mode, we don't report other error
> conditions as modes but instead use REGULATOR_STATUS_ with the
> get_status() operation?

I used mode, because when the regulator toggles the overcurrent
line, it means that it has entered a current limited mode, at least the
regulator im looking at. ill change to STATUS

Regards
Axel
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT v2 09/17] regulator: fixed: Add over current event

2016-10-24 Thread Axel Haslam
Hi Mark,

On Mon, Oct 24, 2016 at 7:43 PM, Mark Brown <broo...@kernel.org> wrote:
> On Mon, Oct 24, 2016 at 06:46:26PM +0200, ahas...@baylibre.com wrote:
>> From: Axel Haslam <ahas...@baylibre.com>
>>
>> Some regulator supplies have an over-current pin that is
>> activated when the hw detects an over current condition.
>> When this happens, the hardware enters a current limited
>> mode.
>
> Please don't mix random enhancements like this into bigger system
> specific RFC serieses, send them separately so they're easier to spot
> and there's no confusion with dependencies and then reference them from
> the system specific series when you post that.

Ok, sorry i had mixed feelings on how to post all of it.
 there are several dependencies on the series and i  kept
all together to give the context. Do you  want me to repost the regulator
changes seperatly? I can do that, but if you  don't agree with regulator
handling overcurrent, i will have to move the over current
gpio into the driver, and there is no point on re-posting that seperatly.

Regards
Axel
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH/RFT 07/12] USB: ohci-da8xx: Request gpios and handle interrupt in the driver

2016-10-12 Thread Axel Haslam
Hi David

On Tue, Oct 11, 2016 at 1:18 AM, David Lechner <da...@lechnology.com> wrote:
> On 10/07/2016 11:42 AM, ahas...@baylibre.com wrote:
>>
>> From: Axel Haslam <ahas...@baylibre.com>
>>
>> Currently requesting the vbus and overcurrent gpio is handled on
>> the board specific file. But this does not play well moving to
>> device tree.
>>
>> In preparation to migrate to a device tree boot, handle requesting
>> gpios and overcurrent interrupt on the usb driver itself, thus avoiding
>> callbacks to arch/mach*
>>
>
> Instead of using gpios, it seems like it would be better to use a regulator
> here. I don't know of any real-life cases, but who is to say someone
> not design a board that uses a regulator controlled by I2C instead of gpios
> or something like that.
>
> Then, boards that don't have gpios can just use a fixed regulator (or you
> can make the regulator optional). Using a regulator would also allow users
> to decide how to respond to overcurrent events (by supplying their own
> regulator driver) instead of the behavior being dictated by the ohci driver.


I  agree that we should use a regulator for the vbus power.
i will make that change.  However, im not so sure about using the
regulator for the overcurrent handling. There seems to be no other
driver doing this, and as you mention, we would need to change the regulator
framework, which might not be justifiable. I think there is not another way
to handle the over current notification other than powering the port off.

>
> In my particular area of interest (LEGO MINDSTORMS EV3), the 5V (hardware)
> regulator for VBUS does use gpios, but the 5V is also shared with the LEGO
> input and output ports. So what I would ultimately like to be able to do is
> have userspace notified of an overcurrent event and let userspace decided
> when to turn the vbus back on. For example, someone might plug something
> into one of the LEGO input or output ports that causes a short circuit. I
> would like to display a notification to the user and wait for them to
> correct the problem and then press a button to turn the power back on.
>

how about using regulator for vbus, but keeping gpio for overcurrent
notifications?

For the usersapce handling you describe above, maybe we should be able to
listen for an usb overcurrent uevent in userspace? it seems this
question was asked
a couple of years back[1], but im not sure what the conclusion was. In any case,
we could have DT and non-DT based ohci-da8xx working,
And could work on a uevent notification for the scenario you describe
above which
i think is not specific to the ohci-da8xx.

[1]http://linux-usb.vger.kernel.narkive.com/SjcUB5hk/how-best-to-get-over-current-notification-to-user-application


Regards
Axel

> This will require some modifications to the regulator subsystem though. I
> actually started work on this a while back, but haven't had the time to
> pursue it any farther.
>
> Here are my WIP patches in case there is any interest:
> *
> https://github.com/dlech/ev3dev-kernel/commit/541a42b3b8ed639e95bbc835df3292f80190c789
> *
> https://github.com/dlech/ev3dev-kernel/commit/2ba99b1ad6a06c944dd33a073f54044e71b75ae6
> *
> https://github.com/dlech/ev3dev-kernel/commit/cdb03caa50e64931d4f2836c648739aa4385ed3b
> *
> https://github.com/dlech/ev3dev-kernel/commit/9d6b50cde34b51309c74d97c26b1430c7ff6aa0f
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html