Re: [PATCH v7 05/20] usb: phy: msm: Migrate to Managed Device Resource allocation

2014-04-28 Thread Ivan T. Ivanov
On Fri, 2014-04-25 at 15:53 -0500, Felipe Balbi wrote:
> On Thu, Apr 24, 2014 at 01:49:38PM -0300, Fabio Estevam wrote:
> > On Thu, Apr 24, 2014 at 12:48 PM, Ivan T. Ivanov  wrote:
> > 
> > > +   motg->vddcx = devm_regulator_get(motg->phy.dev, "HSUSB_VDDCX");
> > > +   if (IS_ERR(motg->vddcx)) {
> > > +   dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
> > > +   return PTR_ERR(motg->vddcx);
> > > +   }
> > > +
> > > +   motg->v3p3 = devm_regulator_get(motg->phy.dev, "HSUSB_3p3");
> > > +   if (IS_ERR(motg->v3p3)) {
> > > +   dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
> > > +   return PTR_ERR(motg->v3p3);
> > > +   }
> > > +
> > > +   motg->v1p8 = devm_regulator_get(motg->phy.dev, "HSUSB_1p8");
> > > +   if (IS_ERR(motg->v1p8)) {
> > > +   dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
> > > +   return PTR_ERR(motg->v1p8);
> > > +   }
> > 
> > It seems that calling devm_regulator_bulk_get() here would simplify
> > the code here.

Sure. 

> 
> any comments here ?? Should I expect a new version ?


Will fix rest of the comments and send updated patch set.

Regards,
Ivan
> 


--
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 v7 20/20] usb: phy: msm: Use usb_add_phy_dev() to register device

2014-04-28 Thread Ivan T. Ivanov
On Fri, 2014-04-25 at 15:53 -0500, Felipe Balbi wrote:
> On Thu, Apr 24, 2014 at 09:06:24PM +0400, Sergei Shtylyov wrote:
> > Hello.
> > 
> > On 04/24/2014 07:48 PM, Ivan T. Ivanov wrote:
> > 
> > >From: "Ivan T. Ivanov" 
> > 
> > >They could be more than one USB2.0 PHY's on the platform.
> > 
> >s/They/There/
> > 
> > >This will allow all of them to be registred successfuly.
> > 
> >s/registred successfuly/registered successfully/

Ouch. will fix it.

Regards,
Ivan


--
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/1] usb: core: remove the Kconfig entry for USB_DEBUG

2014-04-28 Thread Peter Chen
Since we have already removed the usage of CONFIG_USB_DEBUG, it is
meaningless that there is still a configuration entry for CONFIG_USB_DEBUG.

Signed-off-by: Peter Chen 
---
 drivers/usb/core/Kconfig |7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index cb8e991..9519878 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -1,13 +1,6 @@
 #
 # USB Core configuration
 #
-config USB_DEBUG
-   bool "USB verbose debug messages"
-   help
- Say Y here if you want the USB core & hub drivers to produce a bunch
- of debug messages to the system log. Select this if you are having a
- problem with USB support and want to see more of what is going on.
-
 config USB_ANNOUNCE_NEW_DEVICES
bool "USB announce new devices"
help
-- 
1.7.8

--
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 v9 4/4] usb: ehci-exynos: Change to use phy provided by the generic phy framework

2014-04-28 Thread Vivek Gautam
From: Kamil Debski 

Add the phy provider, supplied by new Exynos-usb2phy using
Generic phy framework.
Keeping the support for older USB phy intact right now, in order
to prevent any functionality break in absence of relevant
device tree side change for ehci-exynos.
Once we move to new phy in the device nodes for ehci, we can
remove the support for older phys.

Signed-off-by: Kamil Debski 
[gautam.vi...@samsung.com: Addressed review comments from mailing list]
[gautam.vi...@samsung.com: Kept the code for old usb-phy, and just
added support for new exynos5-usb2phy in generic phy framework]
[gautam.vi...@samsung.com: Edited the commit message]
Signed-off-by: Vivek Gautam 
Cc: Jingoo Han 
Cc: Alan Stern 
---
 .../devicetree/bindings/usb/exynos-usb.txt |   18 +++
 drivers/usb/host/ehci-exynos.c |  143 +---
 2 files changed, 141 insertions(+), 20 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt 
b/Documentation/devicetree/bindings/usb/exynos-usb.txt
index 03b7e43..4f368b0 100644
--- a/Documentation/devicetree/bindings/usb/exynos-usb.txt
+++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt
@@ -12,6 +12,15 @@ Required properties:
  - interrupts: interrupt number to the cpu.
  - clocks: from common clock binding: handle to usb clock.
  - clock-names: from common clock binding: Shall be "usbhost".
+ - port: if in the SoC there are EHCI phys, they should be listed here.
+   One phy per port. Each port should have its 'reg' entry.
+   - reg: port number on EHCI controller, e.g
+  On Exynos5250, port 0 is USB2.0 otg phy
+ port 1 is HSIC phy0
+ port 2 is HSIC phy1
+   - phys: from the *Generic PHY* bindings; specifying phy used by port.
+   - phy-names: from the *Generic PHY* bindings; specifying name of phy
+used by the port.
 
 Optional properties:
  - samsung,vbus-gpio:  if present, specifies the GPIO that
@@ -27,6 +36,15 @@ Example:
 
clocks = <&clock 285>;
clock-names = "usbhost";
+
+   #address-cells = <1>;
+   #size-cells = <0>;
+   port@0 {
+   reg = <0>;
+   phys = <&usb2phy 1>;
+   phy-names = "host";
+   status = "disabled";
+   };
};
 
 OHCI
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index 4d763dc..caeadb4 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -42,14 +43,119 @@
 static const char hcd_name[] = "ehci-exynos";
 static struct hc_driver __read_mostly exynos_ehci_hc_driver;
 
+#define PHY_NUMBER 3
 struct exynos_ehci_hcd {
struct clk *clk;
struct usb_phy *phy;
struct usb_otg *otg;
+   struct phy *phy_g[PHY_NUMBER];
 };
 
 #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv)
 
+static int exynos_ehci_get_phy(struct device *dev,
+   struct exynos_ehci_hcd *exynos_ehci)
+{
+   struct device_node *child;
+   struct phy *phy;
+   int phy_number;
+   int ret = 0;
+
+   exynos_ehci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR(exynos_ehci->phy)) {
+   ret = PTR_ERR(exynos_ehci->phy);
+   /* This is the case when PHY config is disabled */
+   if (ret == -ENXIO || ret == -ENODEV) {
+   dev_dbg(dev, "Failed to get usb2 phy\n");
+   exynos_ehci->phy = NULL;
+   ret = 0;
+   } else if (ret == -EPROBE_DEFER) {
+   goto fail_phy;
+   } else {
+   dev_err(dev, "no usb2 phy configured\n");
+   goto fail_phy;
+   }
+   } else {
+   exynos_ehci->otg = exynos_ehci->phy->otg;
+   }
+
+   for_each_available_child_of_node(dev->of_node, child) {
+   ret = of_property_read_u32(child, "reg", &phy_number);
+   if (ret) {
+   dev_err(dev, "Failed to parse device tree\n");
+   of_node_put(child);
+   goto fail_phy;
+   }
+   if (phy_number >= PHY_NUMBER) {
+   dev_err(dev, "Invalid number of PHYs\n");
+   of_node_put(child);
+   ret = -EINVAL;
+   goto fail_phy;
+   }
+   phy = devm_of_phy_get(dev, child, 0);
+   of_node_put(child);
+   if (IS_ERR(phy)) {
+   ret = PTR_ERR(phy);
+   /* This is the case when PHY config is disabled */
+   if (ret == -ENOSYS || ret == -ENODEV) {
+   dev_dbg(dev

[PATCH 2/4] usb: ehci-exynos: Use struct device instead of platform_device

2014-04-28 Thread Vivek Gautam
Change to use struct device instead of struct platform_device
for some static functions.

Signed-off-by: Vivek Gautam 
Cc: Jingoo Han 
Cc: Alan Stern 
---
 drivers/usb/host/ehci-exynos.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index 7f425ac..4d763dc 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -50,9 +50,8 @@ struct exynos_ehci_hcd {
 
 #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv)
 
-static void exynos_setup_vbus_gpio(struct platform_device *pdev)
+static void exynos_setup_vbus_gpio(struct device *dev)
 {
-   struct device *dev = &pdev->dev;
int err;
int gpio;
 
@@ -88,7 +87,7 @@ static int exynos_ehci_probe(struct platform_device *pdev)
if (err)
return err;
 
-   exynos_setup_vbus_gpio(pdev);
+   exynos_setup_vbus_gpio(&pdev->dev);
 
hcd = usb_create_hcd(&exynos_ehci_hc_driver,
 &pdev->dev, dev_name(&pdev->dev));
-- 
1.7.10.4

--
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 3/4] usb: ohci-exynos: Add facility to use phy provided by the generic phy framework

2014-04-28 Thread Vivek Gautam
Add support to consume phy provided by Generic phy framework.
Keeping the support for older usb-phy intact right now, in order
to prevent any functionality break in absence of relevant
device tree side change for ohci-exynos.
Once we move to new phy in the device nodes for ohci, we can
remove the support for older phys.

Signed-off-by: Vivek Gautam 
Cc: Jingoo Han 
Cc: Alan Stern 
---
 .../devicetree/bindings/usb/exynos-usb.txt |   19 +++
 drivers/usb/host/ohci-exynos.c |  129 +---
 2 files changed, 132 insertions(+), 16 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/exynos-usb.txt 
b/Documentation/devicetree/bindings/usb/exynos-usb.txt
index d967ba1..03b7e43 100644
--- a/Documentation/devicetree/bindings/usb/exynos-usb.txt
+++ b/Documentation/devicetree/bindings/usb/exynos-usb.txt
@@ -38,6 +38,15 @@ Required properties:
  - interrupts: interrupt number to the cpu.
  - clocks: from common clock binding: handle to usb clock.
  - clock-names: from common clock binding: Shall be "usbhost".
+ - port: if in the SoC there are OHCI phys, they should be listed here.
+   One phy per port. Each port should have its 'reg' entry.
+   - reg: port number on OHCI controller, e.g
+  On Exynos5250, port 0 is USB2.0 otg phy
+ port 1 is HSIC phy0
+ port 2 is HSIC phy1
+   - phys: from the *Generic PHY* bindings specifying phy used by port.
+   - phy-names: from the *Generic PHY* bindings specifying name of phy
+used by the port.
 
 Example:
usb@1212 {
@@ -47,6 +56,16 @@ Example:
 
clocks = <&clock 285>;
clock-names = "usbhost";
+
+   #address-cells = <1>;
+   #size-cells = <0>;
+   port@0 {
+   reg = <0>;
+   phys = <&usb2phy 1>;
+   phy-names = "host";
+   status = "disabled";
+   };
+
};
 
 DWC3
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 05f00e3..011ccde 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -33,28 +34,122 @@ static struct hc_driver __read_mostly 
exynos_ohci_hc_driver;
 
 #define to_exynos_ohci(hcd) (struct exynos_ohci_hcd *)(hcd_to_ohci(hcd)->priv)
 
+#define PHY_NUMBER 3
 struct exynos_ohci_hcd {
struct clk *clk;
struct usb_phy *phy;
struct usb_otg *otg;
+   struct phy *phy_g[PHY_NUMBER];
 };
 
-static void exynos_ohci_phy_enable(struct device *dev)
+static int exynos_ohci_get_phy(struct device *dev,
+   struct exynos_ohci_hcd *exynos_ohci)
+{
+   struct device_node *child;
+   struct phy *phy;
+   int phy_number;
+   int ret = 0;
+
+   exynos_ohci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR(exynos_ohci->phy)) {
+   ret = PTR_ERR(exynos_ohci->phy);
+   /* This is the case when PHY config is disabled */
+   if (ret == -ENXIO || ret == -ENODEV) {
+   dev_dbg(dev, "Failed to get usb2 phy\n");
+   exynos_ohci->phy = NULL;
+   ret = 0;
+   } else if (ret == -EPROBE_DEFER) {
+   goto fail_phy;
+   } else {
+   dev_err(dev, "no usb2 phy configured\n");
+   goto fail_phy;
+   }
+   } else {
+   exynos_ohci->otg = exynos_ohci->phy->otg;
+   }
+
+   /* Getting generic phy:
+* We are keeping both types of phys as a part of transiting OHCI
+* to generic phy framework, so that in absence of supporting dts
+* changes the functionality doesn't break.
+* Once we move the ohci dt nodes to use new generic phys,
+* we can remove support for older PHY in this driver.
+*/
+   for_each_available_child_of_node(dev->of_node, child) {
+   ret = of_property_read_u32(child, "reg", &phy_number);
+   if (ret) {
+   dev_err(dev, "Failed to parse device tree\n");
+   of_node_put(child);
+   goto fail_phy;
+   }
+   if (phy_number >= PHY_NUMBER) {
+   dev_err(dev, "Invalid number of PHYs\n");
+   of_node_put(child);
+   ret = -EINVAL;
+   goto fail_phy;
+   }
+   phy = devm_of_phy_get(dev, child, 0);
+   of_node_put(child);
+   if (IS_ERR(phy)) {
+   ret = PTR_ERR(phy);
+   /* This is the case when PHY config is disabled */
+   if (ret == -ENOSYS || ret == -ENODEV) {
+   dev_

[PATCH 1/4] usb: ohci-exynos: Use struct device instead of platform_device

2014-04-28 Thread Vivek Gautam
Change to use struct device instead of struct platform_device
for some static functions.

Signed-off-by: Vivek Gautam 
Cc: Jingoo Han 
Cc: Alan Stern 
---
 drivers/usb/host/ohci-exynos.c |   20 +---
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index 9cf80cb..05f00e3 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -39,18 +39,18 @@ struct exynos_ohci_hcd {
struct usb_otg *otg;
 };
 
-static void exynos_ohci_phy_enable(struct platform_device *pdev)
+static void exynos_ohci_phy_enable(struct device *dev)
 {
-   struct usb_hcd *hcd = platform_get_drvdata(pdev);
+   struct usb_hcd *hcd = dev_get_drvdata(dev);
struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
 
if (exynos_ohci->phy)
usb_phy_init(exynos_ohci->phy);
 }
 
-static void exynos_ohci_phy_disable(struct platform_device *pdev)
+static void exynos_ohci_phy_disable(struct device *dev)
 {
-   struct usb_hcd *hcd = platform_get_drvdata(pdev);
+   struct usb_hcd *hcd = dev_get_drvdata(dev);
struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
 
if (exynos_ohci->phy)
@@ -139,7 +139,7 @@ skip_phy:
 
platform_set_drvdata(pdev, hcd);
 
-   exynos_ohci_phy_enable(pdev);
+   exynos_ohci_phy_enable(&pdev->dev);
 
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err) {
@@ -150,7 +150,7 @@ skip_phy:
return 0;
 
 fail_add_hcd:
-   exynos_ohci_phy_disable(pdev);
+   exynos_ohci_phy_disable(&pdev->dev);
 fail_io:
clk_disable_unprepare(exynos_ohci->clk);
 fail_clk:
@@ -168,7 +168,7 @@ static int exynos_ohci_remove(struct platform_device *pdev)
if (exynos_ohci->otg)
exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self);
 
-   exynos_ohci_phy_disable(pdev);
+   exynos_ohci_phy_disable(&pdev->dev);
 
clk_disable_unprepare(exynos_ohci->clk);
 
@@ -190,7 +190,6 @@ static int exynos_ohci_suspend(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
-   struct platform_device *pdev = to_platform_device(dev);
bool do_wakeup = device_may_wakeup(dev);
int rc = ohci_suspend(hcd, do_wakeup);
 
@@ -200,7 +199,7 @@ static int exynos_ohci_suspend(struct device *dev)
if (exynos_ohci->otg)
exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self);
 
-   exynos_ohci_phy_disable(pdev);
+   exynos_ohci_phy_disable(dev);
 
clk_disable_unprepare(exynos_ohci->clk);
 
@@ -211,14 +210,13 @@ static int exynos_ohci_resume(struct device *dev)
 {
struct usb_hcd *hcd = dev_get_drvdata(dev);
struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
-   struct platform_device *pdev= to_platform_device(dev);
 
clk_prepare_enable(exynos_ohci->clk);
 
if (exynos_ohci->otg)
exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self);
 
-   exynos_ohci_phy_enable(pdev);
+   exynos_ohci_phy_enable(dev);
 
ohci_resume(hcd, false);
 
-- 
1.7.10.4

--
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 0/4] usb: ehci/ohci-exynos: Move to generic phy framework

2014-04-28 Thread Vivek Gautam
Based and tested on 'usb-next' branch of Greg's usb tree, with relevant
device tree patches[1]

Changes from v2:
 - Added two patches in the series for some cleanup.
   usb: ohci-exynos: Use struct device instead of platform_device
   usb: ehci-exynos: Use struct device instead of platform_device
 - Addressed review comments.
   -- Moved exynos_ohci_phyg_on()/off routines inside
  exynos_ohci_phy_enable()/disable.
   -- Added functions exynos_ehci_phy_enable() and exynos_ehci_phy_disable()
  and moved exynos_ehci_phyg_on()/off routines respectively in them.
   -- Added necessary checks.

Kamil Debski (1):
  usb: ehci-exynos: Change to use phy provided by the generic phy
framework

Vivek Gautam (3):
  usb: ohci-exynos: Use struct device instead of platform_device
  usb: ehci-exynos: Use struct device instead of platform_device
  usb: ohci-exynos: Add facility to use phy provided by the generic phy
framework

 .../devicetree/bindings/usb/exynos-usb.txt |   37 +
 drivers/usb/host/ehci-exynos.c |  148 +---
 drivers/usb/host/ohci-exynos.c |  141 ---
 3 files changed, 280 insertions(+), 46 deletions(-)

-- 
1.7.10.4

--
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 0/4] usb: ehci/ohci-exynos: Move to generic phy framework

2014-04-28 Thread Vivek Gautam
Based and tested on 'usb-next' branch of Greg's usb tree, with relevant
device tree patches[1]

Changes from v2:
 - Added two patches in the series for some cleanup.
   usb: ohci-exynos: Use struct device instead of platform_device
   usb: ehci-exynos: Use struct device instead of platform_device
 - Addressed review comments.
   -- Moved exynos_ohci_phyg_on()/off routines inside
  exynos_ohci_phy_enable()/disable.
   -- Added functions exynos_ehci_phy_enable() and exynos_ehci_phy_disable()
  and moved exynos_ehci_phyg_on()/off routines respectively in them.
   -- Added necessary checks.

Kamil Debski (1):
  usb: ehci-exynos: Change to use phy provided by the generic phy
framework

Vivek Gautam (3):
  usb: ohci-exynos: Use struct device instead of platform_device
  usb: ehci-exynos: Use struct device instead of platform_device
  usb: ohci-exynos: Add facility to use phy provided by the generic phy
framework

 .../devicetree/bindings/usb/exynos-usb.txt |   37 +
 drivers/usb/host/ehci-exynos.c |  148 +---
 drivers/usb/host/ohci-exynos.c |  141 ---
 3 files changed, 280 insertions(+), 46 deletions(-)

-- 
1.7.10.4

--
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 2/3] usb: dwc3: gadget: pretty print link states

2014-04-28 Thread David Laight
From: Felipe Balbi
...
> +static const char *dwc3_gadget_link_string(enum dwc3_link_state link_state)
> +{
> + switch (link_state) {
> + case DWC3_LINK_STATE_U0:
> + return "U0";
> + case DWC3_LINK_STATE_U1:
> + return "U1";
> + case DWC3_LINK_STATE_U2:
> + return "U2";
> + case DWC3_LINK_STATE_U3:
> + return "U3";
> + case DWC3_LINK_STATE_SS_DIS:
> + return "SS.Disabled";
> + case DWC3_LINK_STATE_RX_DET:
> + return "RX.Detect";
> + case DWC3_LINK_STATE_SS_INACT:
> + return "SS.Inactive";
> + case DWC3_LINK_STATE_POLL:
> + return "Polling";
> + case DWC3_LINK_STATE_RECOV:
> + return "Recovery";
> + case DWC3_LINK_STATE_HRESET:
> + return "Hot Reset";
> + case DWC3_LINK_STATE_CMPLY:
> + return "Compliance";
> + case DWC3_LINK_STATE_LPBK:
> + return "Loopback";
> + case DWC3_LINK_STATE_RESET:
> + return "Reset";
> + case DWC3_LINK_STATE_RESUME:
> + return "Resume";
> + default:
> + return "UNKNOWN link state\n";
> + }
> +}

If the values are dense the compiler will generate much smaller code
if you index an array - possibly even: char msg[][12];

David



--
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 0/4] usb: ehci/ohci-exynos: Move to generic phy framework

2014-04-28 Thread Vivek Gautam
On Mon, Apr 28, 2014 at 2:55 PM, Vivek Gautam  wrote:
> Based and tested on 'usb-next' branch of Greg's usb tree, with relevant
> device tree patches[1]

[1] [PATCH v7 0/2] dts: Add usb2phy to Exynos 5250
 http://www.spinics.net/lists/linux-usb/msg106427.html


>
> Changes from v2:
>  - Added two patches in the series for some cleanup.
>usb: ohci-exynos: Use struct device instead of platform_device
>usb: ehci-exynos: Use struct device instead of platform_device
>  - Addressed review comments.
>-- Moved exynos_ohci_phyg_on()/off routines inside
>   exynos_ohci_phy_enable()/disable.
>-- Added functions exynos_ehci_phy_enable() and exynos_ehci_phy_disable()
>   and moved exynos_ehci_phyg_on()/off routines respectively in them.
>-- Added necessary checks.
>
> Kamil Debski (1):
>   usb: ehci-exynos: Change to use phy provided by the generic phy
> framework
>
> Vivek Gautam (3):
>   usb: ohci-exynos: Use struct device instead of platform_device
>   usb: ehci-exynos: Use struct device instead of platform_device
>   usb: ohci-exynos: Add facility to use phy provided by the generic phy
> framework
>
>  .../devicetree/bindings/usb/exynos-usb.txt |   37 +
>  drivers/usb/host/ehci-exynos.c |  148 
> +---
>  drivers/usb/host/ohci-exynos.c |  141 ---
>  3 files changed, 280 insertions(+), 46 deletions(-)
>
> --
> 1.7.10.4
>



-- 
Best Regards
Vivek Gautam
Samsung R&D Institute, Bangalore
India
--
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 00/13] extcon: major rework

2014-04-28 Thread Robert Baldyga
On 04/24/2014 09:52 PM, Greg KH wrote:
> On Mon, Apr 14, 2014 at 01:46:11PM +0200, Robert Baldyga wrote:
>> This patchset adds many improvements to extcon class driver and extcon
>> provider drivers. It changes extcon API to faster and safer by replaceing
>> function taking extcon and cable names with functions working with
>> structures representing this objects.
> 
> What is "faster" exactly?  How did you measure this?  What benchmarks
> can be run to test this claim?
> 

Most of new API functions are O(1), because they take as argument
pointer to struct extcon_cable, and operates on it. In contrast,
previous API functions needed to compare given cable name with name of
each cable specified in extcon controller. This solution was also prone
to errors - when you make typo in extcon name or cable name it will not
be detected at compilation time. The new API uses names only at
initialization, and after that each function takes pointer to struct
extcon_cable.

The old API is also fragile because defined list of cables could be
different in each extcon provider (the same cable could have different
name in each extcon provider), so using different extcon providers with
different drivers would need doing modifications in drivers.

Best regards
Robert Baldyga
Samsung R&D Institute Poland
--
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: common: rename phy-fsm-usb.c to usb-otg-fsm.c

2014-04-28 Thread Peter Chen
Since usb otg fsm implementation is not related to usb phy.
We move it from usb/phy/ to usb/common/, and rename it to
reflect its real meaning.

Signed-off-by: Peter Chen 
---
 drivers/usb/common/Makefile|1 +
 .../{phy/phy-fsm-usb.c => common/usb-otg-fsm.c}|0
 drivers/usb/core/Kconfig   |9 +
 drivers/usb/phy/Kconfig|9 -
 drivers/usb/phy/Makefile   |1 -
 5 files changed, 10 insertions(+), 10 deletions(-)
 rename drivers/usb/{phy/phy-fsm-usb.c => common/usb-otg-fsm.c} (100%)

diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
index 9b320d1..7526461 100644
--- a/drivers/usb/common/Makefile
+++ b/drivers/usb/common/Makefile
@@ -3,3 +3,4 @@
 #
 
 obj-$(CONFIG_USB_COMMON) += usb-common.o
+obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/common/usb-otg-fsm.c
similarity index 100%
rename from drivers/usb/phy/phy-fsm-usb.c
rename to drivers/usb/common/usb-otg-fsm.c
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index 9519878..8d18eba 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -81,3 +81,12 @@ config USB_OTG_BLACKLIST_HUB
  and software costs by not supporting external hubs.  So
  are "Embedded Hosts" that don't offer OTG support.
 
+config USB_OTG_FSM
+   tristate "USB 2.0 OTG FSM implementation"
+   depends on USB
+   select USB_OTG
+   select USB_PHY
+   help
+ Implements OTG Final State Machine as specified in On-The-Go
+ and Embedded Host Supplement to the USB Revision 2.0 Specification.
+
diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 33dd6a6..d027a19 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -6,15 +6,6 @@ menu "USB Physical Layer drivers"
 config USB_PHY
def_bool n
 
-config USB_OTG_FSM
-   tristate "USB 2.0 OTG FSM implementation"
-   depends on USB
-   select USB_OTG
-   select USB_PHY
-   help
- Implements OTG Final State Machine as specified in On-The-Go
- and Embedded Host Supplement to the USB Revision 2.0 Specification.
-
 #
 # USB Transceiver Drivers
 #
diff --git a/drivers/usb/phy/Makefile b/drivers/usb/phy/Makefile
index a2d0569..24a9133 100644
--- a/drivers/usb/phy/Makefile
+++ b/drivers/usb/phy/Makefile
@@ -3,7 +3,6 @@
 #
 obj-$(CONFIG_USB_PHY)  += phy.o
 obj-$(CONFIG_OF)   += of.o
-obj-$(CONFIG_USB_OTG_FSM)  += phy-fsm-usb.o
 
 # transceiver drivers, keep the list sorted
 
-- 
1.7.8

--
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/2] Re-organize usb common

2014-04-28 Thread Peter Chen
Hi Greg,

This patch set creates usb/common for usb common things, and moves
otg fsm implementation from usb/phy/ to usb/common/. I have a
discussion with Felipe about it at below link:
http://www.spinics.net/lists/linux-usb/msg106357.html

Thanks.

Peter Chen (2):
  usb: move usb/usb-common.c to usb/common/usb-common.c
  usb: common: rename phy-fsm-usb.c to usb-otg-fsm.c

 drivers/usb/Makefile   |2 +-
 drivers/usb/common/Makefile|6 ++
 drivers/usb/{ => common}/usb-common.c  |0
 .../{phy/phy-fsm-usb.c => common/usb-otg-fsm.c}|0
 drivers/usb/core/Kconfig   |9 +
 drivers/usb/phy/Kconfig|9 -
 drivers/usb/phy/Makefile   |1 -
 7 files changed, 16 insertions(+), 11 deletions(-)
 create mode 100644 drivers/usb/common/Makefile
 rename drivers/usb/{ => common}/usb-common.c (100%)
 rename drivers/usb/{phy/phy-fsm-usb.c => common/usb-otg-fsm.c} (100%)

-- 
1.7.8

--
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: move usb/usb-common.c to usb/common/usb-common.c

2014-04-28 Thread Peter Chen
Since we will have more usb-common things, and it will let
usb-common.c be larger and larger, we create a folder named usb/common
for all usb common things.

Signed-off-by: Peter Chen 
---
 drivers/usb/Makefile  |2 +-
 drivers/usb/common/Makefile   |5 +
 drivers/usb/{ => common}/usb-common.c |0
 3 files changed, 6 insertions(+), 1 deletions(-)
 create mode 100644 drivers/usb/common/Makefile
 rename drivers/usb/{ => common}/usb-common.c (100%)

diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 1ae2bf3..f0d3332 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -58,4 +58,4 @@ obj-$(CONFIG_USB_CHIPIDEA)+= chipidea/
 obj-$(CONFIG_USB_RENESAS_USBHS)+= renesas_usbhs/
 obj-$(CONFIG_USB_GADGET)   += gadget/
 
-obj-$(CONFIG_USB_COMMON)   += usb-common.o
+obj-$(CONFIG_USB_COMMON)   += common/
diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
new file mode 100644
index 000..9b320d1
--- /dev/null
+++ b/drivers/usb/common/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for the usb common parts.
+#
+
+obj-$(CONFIG_USB_COMMON) += usb-common.o
diff --git a/drivers/usb/usb-common.c b/drivers/usb/common/usb-common.c
similarity index 100%
rename from drivers/usb/usb-common.c
rename to drivers/usb/common/usb-common.c
-- 
1.7.8

--
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 1/4] usb: ohci-exynos: Use struct device instead of platform_device

2014-04-28 Thread Jingoo Han
On Monday, April 28, 2014 6:25 PM, Vivek Gautam wrote:
> 
> Change to use struct device instead of struct platform_device
> for some static functions.
> 
> Signed-off-by: Vivek Gautam 
> Cc: Jingoo Han 

Acked-by: Jingoo Han 

Best regards,
Jingoo Han

> Cc: Alan Stern 
> ---
>  drivers/usb/host/ohci-exynos.c |   20 +---
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
> index 9cf80cb..05f00e3 100644
> --- a/drivers/usb/host/ohci-exynos.c
> +++ b/drivers/usb/host/ohci-exynos.c
> @@ -39,18 +39,18 @@ struct exynos_ohci_hcd {
>   struct usb_otg *otg;
>  };
> 
> -static void exynos_ohci_phy_enable(struct platform_device *pdev)
> +static void exynos_ohci_phy_enable(struct device *dev)
>  {
> - struct usb_hcd *hcd = platform_get_drvdata(pdev);
> + struct usb_hcd *hcd = dev_get_drvdata(dev);
>   struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
> 
>   if (exynos_ohci->phy)
>   usb_phy_init(exynos_ohci->phy);
>  }
> 
> -static void exynos_ohci_phy_disable(struct platform_device *pdev)
> +static void exynos_ohci_phy_disable(struct device *dev)
>  {
> - struct usb_hcd *hcd = platform_get_drvdata(pdev);
> + struct usb_hcd *hcd = dev_get_drvdata(dev);
>   struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
> 
>   if (exynos_ohci->phy)
> @@ -139,7 +139,7 @@ skip_phy:
> 
>   platform_set_drvdata(pdev, hcd);
> 
> - exynos_ohci_phy_enable(pdev);
> + exynos_ohci_phy_enable(&pdev->dev);
> 
>   err = usb_add_hcd(hcd, irq, IRQF_SHARED);
>   if (err) {
> @@ -150,7 +150,7 @@ skip_phy:
>   return 0;
> 
>  fail_add_hcd:
> - exynos_ohci_phy_disable(pdev);
> + exynos_ohci_phy_disable(&pdev->dev);
>  fail_io:
>   clk_disable_unprepare(exynos_ohci->clk);
>  fail_clk:
> @@ -168,7 +168,7 @@ static int exynos_ohci_remove(struct platform_device 
> *pdev)
>   if (exynos_ohci->otg)
>   exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self);
> 
> - exynos_ohci_phy_disable(pdev);
> + exynos_ohci_phy_disable(&pdev->dev);
> 
>   clk_disable_unprepare(exynos_ohci->clk);
> 
> @@ -190,7 +190,6 @@ static int exynos_ohci_suspend(struct device *dev)
>  {
>   struct usb_hcd *hcd = dev_get_drvdata(dev);
>   struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
> - struct platform_device *pdev = to_platform_device(dev);
>   bool do_wakeup = device_may_wakeup(dev);
>   int rc = ohci_suspend(hcd, do_wakeup);
> 
> @@ -200,7 +199,7 @@ static int exynos_ohci_suspend(struct device *dev)
>   if (exynos_ohci->otg)
>   exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self);
> 
> - exynos_ohci_phy_disable(pdev);
> + exynos_ohci_phy_disable(dev);
> 
>   clk_disable_unprepare(exynos_ohci->clk);
> 
> @@ -211,14 +210,13 @@ static int exynos_ohci_resume(struct device *dev)
>  {
>   struct usb_hcd *hcd = dev_get_drvdata(dev);
>   struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
> - struct platform_device *pdev= to_platform_device(dev);
> 
>   clk_prepare_enable(exynos_ohci->clk);
> 
>   if (exynos_ohci->otg)
>   exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self);
> 
> - exynos_ohci_phy_enable(pdev);
> + exynos_ohci_phy_enable(dev);
> 
>   ohci_resume(hcd, false);
> 
> --
> 1.7.10.4

--
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 2/4] usb: ehci-exynos: Use struct device instead of platform_device

2014-04-28 Thread Jingoo Han
On Monday, April 28, 2014 6:26 PM, Vivek Gautam wrote:
> 
> Change to use struct device instead of struct platform_device
> for some static functions.
> 
> Signed-off-by: Vivek Gautam 
> Cc: Jingoo Han 

Acked-by: Jingoo Han 

Best regards,
Jingoo Han

> Cc: Alan Stern 
> ---
>  drivers/usb/host/ehci-exynos.c |5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> index 7f425ac..4d763dc 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -50,9 +50,8 @@ struct exynos_ehci_hcd {
> 
>  #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd 
> *)(hcd_to_ehci(hcd)->priv)
> 
> -static void exynos_setup_vbus_gpio(struct platform_device *pdev)
> +static void exynos_setup_vbus_gpio(struct device *dev)
>  {
> - struct device *dev = &pdev->dev;
>   int err;
>   int gpio;
> 
> @@ -88,7 +87,7 @@ static int exynos_ehci_probe(struct platform_device *pdev)
>   if (err)
>   return err;
> 
> - exynos_setup_vbus_gpio(pdev);
> + exynos_setup_vbus_gpio(&pdev->dev);
> 
>   hcd = usb_create_hcd(&exynos_ehci_hc_driver,
>&pdev->dev, dev_name(&pdev->dev));
> --
> 1.7.10.4

--
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: remove redundant D0 power state set

2014-04-28 Thread Yijing Wang
Pci_enable_device() will set device power state to D0,
so it's no need to do it again after call pci_enable_device().

Signed-off-by: Yijing Wang 
---
 drivers/usb/core/hcd-pci.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 1f02e65..82044b5 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -192,7 +192,6 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct 
pci_device_id *id)
 
if (pci_enable_device(dev) < 0)
return -ENODEV;
-   dev->current_state = PCI_D0;
 
/*
 * The xHCI driver has its own irq management
-- 
1.7.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: /sys/bus/usb/devices

2014-04-28 Thread Mathias Nyman



On 04/27/2014 11:11 AM, John Freed wrote:

I hope you don't mind me writing you directly, and if someone else can
handle this better please let me know.

I'm trying to do some backend work on libusb and I notice that the
kernel keeps all the information on the Device Descriptors except for
the value of the Serial Number string.

(Well, almost all. Oddly, the "manufacturer" string is not included for
hubs from Intel! I presume that's because they're really PCI devices and
there is some black magic going on in the background to fill in the USB
device descriptor.)

I'm wondering if it would be difficult for you to establish a
"serialnumber" value in the directory that holds the other values (like
maxchild, etc.) from the Device Descriptor. I'm not a kernel programmer,
which is why I'm turning to you.



Hi John

I'll add this to the linux-usb mailing list. It has people with more 
knowledge about generic usb core area.


The serial number string descriptor in a device descriptor is optional, 
so it might just not be there.  I checked that usb core has code for 
supporting string descriptors in sysfs if they exists.


-Mathias
--
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 v5] tools: usb: aio example applications

2014-04-28 Thread Robert Baldyga
Hi Felipe,

Are you going to merge this examples, or should they be merged through
another tree?

Best regards
Robert Baldyga
Samsung R&D Institute Poland

On 02/11/2014 11:43 AM, Robert Baldyga wrote:
> This patch adds two example applications showing usage of Asynchronous I/O API
> of FunctionFS. First one (aio_simple) is simple example of bidirectional data
> transfer. Second one (aio_multibuff) shows multi-buffer data transfer, which
> may to be used in high performance applications.
> 
> Both examples contains userspace applications for device and for host.
> It needs libaio library on the device, and libusb library on host.
> 
> Signed-off-by: Robert Baldyga 
> ---
> 
> Hello,
> 
> This is fifth version of patch adding examples of use AIO API of FunctionFS.
> 
> In this version I have fixed eventfd handling adding read() when any events
> available. I also added reading many events at once, and made some changes
> increasing readability of code.
> 
> Best regards
> Robert Baldyga
> Samsung R&D Institute Poland
> 
> Changelog:
> 
> v5:
> - move examples to diretory tools/usb/ffs-aio-example
> - fix eventfd handling
> - add receiveing many events and once
> - improve error handling
> 
> v4: http://www.spinics.net/lists/linux-usb/msg102195.html
> - fix error handling in host applications
> - replace busy waiting with select function
> - cleanup code, remove duplicated code, move structure definitions
>   and #defines to top on file
> 
> v3: http://www.spinics.net/lists/linux-usb/msg101723.html
> - get rid of global variables
> - add missing error handling
> - fix some style problems
> 
> v2: http://www.spinics.net/lists/linux-usb/msg101650.html
> - cleanup code
> - a lot of small fixes
> 
> v1: http://www.spinics.net/lists/linux-usb/msg101614.html
> 
>  .../multibuff/device_app/aio_multibuff.c   |  349 
> 
>  .../ffs-aio-example/multibuff/host_app/Makefile|   13 +
>  .../usb/ffs-aio-example/multibuff/host_app/test.c  |  146 
>  .../ffs-aio-example/simple/device_app/aio_simple.c |  335 +++
>  tools/usb/ffs-aio-example/simple/host_app/Makefile |   13 +
>  tools/usb/ffs-aio-example/simple/host_app/test.c   |  148 +
>  6 files changed, 1004 insertions(+)
>  create mode 100644 
> tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
>  create mode 100644 tools/usb/ffs-aio-example/multibuff/host_app/Makefile
>  create mode 100644 tools/usb/ffs-aio-example/multibuff/host_app/test.c
>  create mode 100644 tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
>  create mode 100644 tools/usb/ffs-aio-example/simple/host_app/Makefile
>  create mode 100644 tools/usb/ffs-aio-example/simple/host_app/test.c
> 
> diff --git a/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c 
> b/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
> new file mode 100644
> index 000..87216a0
> --- /dev/null
> +++ b/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
> @@ -0,0 +1,349 @@
> +#define _BSD_SOURCE /* for endian.h */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "libaio.h"
> +#define IOCB_FLAG_RESFD (1 << 0)
> +
> +#include 
> +
> +#define BUF_LEN  8192
> +#define BUFS_MAX 128
> +#define AIO_MAX  (BUFS_MAX*2)
> +
> +/ Descriptors and Strings 
> ***/
> +
> +static const struct {
> + struct usb_functionfs_descs_head header;
> + struct {
> + struct usb_interface_descriptor intf;
> + struct usb_endpoint_descriptor_no_audio bulk_sink;
> + struct usb_endpoint_descriptor_no_audio bulk_source;
> + } __attribute__ ((__packed__)) fs_descs, hs_descs;
> +} __attribute__ ((__packed__)) descriptors = {
> + .header = {
> + .magic = htole32(FUNCTIONFS_DESCRIPTORS_MAGIC),
> + .length = htole32(sizeof(descriptors)),
> + .fs_count = 3,
> + .hs_count = 3,
> + },
> + .fs_descs = {
> + .intf = {
> + .bLength = sizeof(descriptors.fs_descs.intf),
> + .bDescriptorType = USB_DT_INTERFACE,
> + .bNumEndpoints = 2,
> + .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
> + .iInterface = 1,
> + },
> + .bulk_sink = {
> + .bLength = sizeof(descriptors.fs_descs.bulk_sink),
> + .bDescriptorType = USB_DT_ENDPOINT,
> + .bEndpointAddress = 1 | USB_DIR_IN,
> + .bmAttributes = USB_ENDPOINT_XFER_BULK,
> + },
> + .bulk_source = {
> + .bLength = sizeof(descriptors.fs_descs.bulk_source),
> + .bDescriptorType = USB_DT_ENDPOINT,
> + 

Re: [PATCH 1/1] usb: core: remove the Kconfig entry for USB_DEBUG

2014-04-28 Thread Greg KH
On Mon, Apr 28, 2014 at 02:12:38PM +0800, Peter Chen wrote:
> Since we have already removed the usage of CONFIG_USB_DEBUG, it is
> meaningless that there is still a configuration entry for CONFIG_USB_DEBUG.

We finally did it?  Nice, I didn't realize that last bits were now gone,
thanks for reminding me with this patch.

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


Re: [PATCH 3/4] dwc3: host: Set xhci lpm support quirk

2014-04-28 Thread Pratyush Anand
On Sat, Apr 26, 2014 at 02:10:21AM +0800, Felipe Balbi wrote:
> On Fri, Apr 25, 2014 at 02:27:11PM +0530, Pratyush Anand wrote:
> > On Tue, Apr 22, 2014 at 10:41:06PM +0800, Felipe Balbi wrote:
> > > On Tue, Apr 22, 2014 at 10:46:13AM +0530, Pratyush Anand wrote:
> > > > On Tue, Apr 22, 2014 at 12:43:55PM +0800, Felipe Balbi wrote:
> > > > > On Tue, Apr 22, 2014 at 09:57:29AM +0530, Pratyush Anand wrote:
> > > > > > All dwc3 based xhci host controller supports USB3.0 LPM 
> > > > > > functionality.
> > > > > > Therefore enable quirk flag to support it for dwc3 xhci host driver.
> > > > > > 
> > > > > > Signed-off-by: Pratyush Anand 
> > > > > > Tested-by: Aymen Bouattay 
> > > > > > ---
> > > > > >  drivers/usb/dwc3/host.c | 1 +
> > > > > >  1 file changed, 1 insertion(+)
> > > > > > 
> > > > > > diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
> > > > > > index a362ed9..b0e4669 100644
> > > > > > --- a/drivers/usb/dwc3/host.c
> > > > > > +++ b/drivers/usb/dwc3/host.c
> > > > > > @@ -86,6 +86,7 @@ int dwc3_host_init(struct dwc3 *dwc)
> > > > > > hcd = platform_get_drvdata(xhci);
> > > > > > xhci_dev = hcd_to_xhci(hcd);
> > > > > > xhci_dev->shared_hcd->phy = dwc->usb3_phy;
> > > > > > +   xhci_dev->quirks |= XHCI_LPM_SUPPORT;
> > > > > 
> > > > > weird... what sort of changes do you have which you didn't send yet ?
> > > > > dwc3/host.c does not create the xHCI device. dwc3_host_init() is
> > > > > basically a wrapper to platform_add_device()
> > > > 
> > > > There is nothing, and it works.
> > > > 
> > > > Adding platform xhci driver in defconfig and selecting dwc3 in DT is 
> > > > sufficient.
> > > > Did I get, what you were asking?
> > > 
> > > this little hunk below will never apply to dwc3/host.c:
> > > 
> > > diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
> > > index a362ed9..b0e4669 100644
> > > --- a/drivers/usb/dwc3/host.c
> > > +++ b/drivers/usb/dwc3/host.c
> > > @@ -86,6 +86,7 @@ int dwc3_host_init(struct dwc3 *dwc)
> > >   hcd = platform_get_drvdata(xhci);
> > >   xhci_dev = hcd_to_xhci(hcd);
> > >   xhci_dev->shared_hcd->phy = dwc->usb3_phy;
> > > + xhci_dev->quirks |= XHCI_LPM_SUPPORT;
> > > 
> > > 
> > > here are dwc3/host.c contents as of v3.15-rc2 (removed comments)
> > > 
> > > #include 
> > > 
> > > #include "core.h"
> > > 
> > > int dwc3_host_init(struct dwc3 *dwc)
> > > {
> > >   struct platform_device  *xhci;
> > >   int ret;
> > > 
> > >   xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
> > >   if (!xhci) {
> > >   dev_err(dwc->dev, "couldn't allocate xHCI device\n");
> > >   ret = -ENOMEM;
> > >   goto err0;
> > >   }
> > > 
> > >   dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask);
> > > 
> > >   xhci->dev.parent= dwc->dev;
> > >   xhci->dev.dma_mask  = dwc->dev->dma_mask;
> > >   xhci->dev.dma_parms = dwc->dev->dma_parms;
> > > 
> > >   dwc->xhci = xhci;
> > > 
> > >   ret = platform_device_add_resources(xhci, dwc->xhci_resources,
> > >   DWC3_XHCI_RESOURCES_NUM);
> > >   if (ret) {
> > >   dev_err(dwc->dev, "couldn't add resources to xHCI device\n");
> > >   goto err1;
> > >   }
> > > 
> > >   ret = platform_device_add(xhci);
> > >   if (ret) {
> > >   dev_err(dwc->dev, "failed to register xHCI device\n");
> > >   goto err1;
> > >   }
> > > 
> > >   return 0;
> > > 
> > > err1:
> > >   platform_device_put(xhci);
> > > 
> > > err0:
> > >   return ret;
> > > }
> > > 
> > > void dwc3_host_exit(struct dwc3 *dwc)
> > > {
> > >   platform_device_unregister(dwc->xhci);
> > > }
> > > 
> > > as you can see, there is no such thing as xhci_dev variable.
> > 
> > OKI see..
> > I will rebase it with latest code.
> 
> please do and show me test results. considering that hunk was *never*
> part of dwc3-host I'm assuming you're taking patches from internal
> vendor kernel and not even testing anything in mainline. I need to see
> some test results before I can take your patches. Sorry

Yaa, Sure.. I have patches ready but I am on leave these days. So not
sending. Will send only after proper testing next week. I will insure
that rebased patches without any dependency to internal kernel have been
tested on hardware.

Pratyush

> 
> cheers
> 
> -- 
> balbi


--
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 0/4] xhci: fixes for 3.15-rc usb-linus

2014-04-28 Thread Mathias Nyman

On 04/25/2014 07:35 PM, Greg KH wrote:

On Fri, Apr 25, 2014 at 07:20:12PM +0300, Mathias Nyman wrote:

Hi Greg

Second try at this xhci fixes series for 3.15-rc usb-linus.
Most of them are very small fixes that didn't make
it to 3.14, sitting and waiting for 3.15-rc1 to come out.

Only the "Prefer endpoint context.." patch  by Julius has a bit more content.

These patches are picked together with Sarah, they are tested on top of
3.15-rc1, and apply on your current usb-linus branch


Much better, all now applied.

What's with all that trailing whitespace in your email text?



Thanks for applying, and sorry about the whitespace errors.
Did some copy-pasting between editors without proper whitespace 
detection set on all file types.


I'll be more careful with these in the future

-Mathias
--
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 v8 03/20] usb: phy: msm: Move global regulators variables to driver state

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Eliminating global variables allows driver to handle multiple
device instances.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 82 ---
 include/linux/usb/msm_hsusb.h |  3 ++
 2 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 6ae4d2f..6bae936 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -58,47 +58,43 @@
 #define USB_PHY_VDD_DIG_VOL_MIN100 /* uV */
 #define USB_PHY_VDD_DIG_VOL_MAX132 /* uV */

-static struct regulator *hsusb_3p3;
-static struct regulator *hsusb_1p8;
-static struct regulator *hsusb_vddcx;
-
 static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
 {
int ret = 0;

if (init) {
-   hsusb_vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
-   if (IS_ERR(hsusb_vddcx)) {
+   motg->vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
+   if (IS_ERR(motg->vddcx)) {
dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
-   return PTR_ERR(hsusb_vddcx);
+   return PTR_ERR(motg->vddcx);
}

-   ret = regulator_set_voltage(hsusb_vddcx,
+   ret = regulator_set_voltage(motg->vddcx,
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
-   regulator_put(hsusb_vddcx);
+   regulator_put(motg->vddcx);
return ret;
}

-   ret = regulator_enable(hsusb_vddcx);
+   ret = regulator_enable(motg->vddcx);
if (ret) {
dev_err(motg->phy.dev, "unable to enable hsusb 
vddcx\n");
-   regulator_put(hsusb_vddcx);
+   regulator_put(motg->vddcx);
}
} else {
-   ret = regulator_set_voltage(hsusb_vddcx, 0,
+   ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret)
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
-   ret = regulator_disable(hsusb_vddcx);
+   ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb 
vddcx\n");

-   regulator_put(hsusb_vddcx);
+   regulator_put(motg->vddcx);
}

return ret;
@@ -109,38 +105,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int 
init)
int rc = 0;

if (init) {
-   hsusb_3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
-   if (IS_ERR(hsusb_3p3)) {
+   motg->v3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
+   if (IS_ERR(motg->v3p3)) {
dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
-   return PTR_ERR(hsusb_3p3);
+   return PTR_ERR(motg->v3p3);
}

-   rc = regulator_set_voltage(hsusb_3p3, USB_PHY_3P3_VOL_MIN,
+   rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 3p3\n");
goto put_3p3;
}
-   rc = regulator_enable(hsusb_3p3);
+   rc = regulator_enable(motg->v3p3);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 
3p3\n");
goto put_3p3;
}
-   hsusb_1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
-   if (IS_ERR(hsusb_1p8)) {
+   motg->v1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
+   if (IS_ERR(motg->v1p8)) {
dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
-   rc = PTR_ERR(hsusb_1p8);
+   rc = PTR_ERR(motg->v1p8);
goto disable_3p3;
}
-   rc = regulator_set_voltage(hsusb_1p8, USB_PHY_1P8_VOL_MIN,
+   rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 1p8\n");
goto put_1p8;
}

[PATCH v8 19/20] usb: phy: msm: Vote for corner of VDD CX instead of voltage of VDD CX

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

New platform uses RBCPR hardware feature, with that voting for
absolute voltage of VDD CX is not required. Hence vote for corner of
VDD CX which uses nominal corner voltage on VDD CX.

Signed-off-by: Ivan T. Ivanov 
Cc: Mayank Rana 
---
 .../devicetree/bindings/usb/msm-hsusb.txt  |  5 
 drivers/usb/phy/phy-msm-usb.c  | 35 +-
 include/linux/usb/msm_hsusb.h  |  1 +
 3 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index 0669667..2826f2a 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -65,6 +65,10 @@ Optional properties:
 Some platforms may have configuration to allow USB
 controller work with any of the two HSPHYs present.

+- qcom,vdd-levels: This property must be a list of three integer values
+(no, min, max) where each value represents either a voltage
+in microvolts or a value corresponding to voltage corner.
+
 Example HSUSB OTG controller device node:

 usb@f9a55000 {
@@ -87,4 +91,5 @@ Example HSUSB OTG controller device node:

 qcom,otg-control = <1>;
 qcom,phy-init-sequence = < -1 0x63 >;
+qcom,vdd-levels = <1 5 7>;
};
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 366527e..8e7956e 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -62,6 +62,13 @@

 #define USB_PHY_VDD_DIG_VOL_MIN100 /* uV */
 #define USB_PHY_VDD_DIG_VOL_MAX132 /* uV */
+#define USB_PHY_SUSP_DIG_VOL   50  /* uV */
+
+enum vdd_levels {
+   VDD_LEVEL_NONE = 0,
+   VDD_LEVEL_MIN,
+   VDD_LEVEL_MAX,
+};

 static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
 {
@@ -69,8 +76,8 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)

if (init) {
ret = regulator_set_voltage(motg->vddcx,
-   USB_PHY_VDD_DIG_VOL_MIN,
-   USB_PHY_VDD_DIG_VOL_MAX);
+   motg->vdd_levels[VDD_LEVEL_MIN],
+   motg->vdd_levels[VDD_LEVEL_MAX]);
if (ret) {
dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
return ret;
@@ -81,7 +88,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
dev_err(motg->phy.dev, "unable to enable hsusb 
vddcx\n");
} else {
ret = regulator_set_voltage(motg->vddcx, 0,
-   USB_PHY_VDD_DIG_VOL_MAX);
+   motg->vdd_levels[VDD_LEVEL_MAX]);
if (ret)
dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
ret = regulator_disable(motg->vddcx);
@@ -435,17 +442,16 @@ static int msm_phy_init(struct usb_phy *phy)

 #ifdef CONFIG_PM

-#define USB_PHY_SUSP_DIG_VOL  50
 static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high)
 {
-   int max_vol = USB_PHY_VDD_DIG_VOL_MAX;
+   int max_vol = motg->vdd_levels[VDD_LEVEL_MAX];
int min_vol;
int ret;

if (high)
-   min_vol = USB_PHY_VDD_DIG_VOL_MIN;
+   min_vol = motg->vdd_levels[VDD_LEVEL_MIN];
else
-   min_vol = USB_PHY_SUSP_DIG_VOL;
+   min_vol = motg->vdd_levels[VDD_LEVEL_NONE];

ret = regulator_set_voltage(motg->vddcx, min_vol, max_vol);
if (ret) {
@@ -1441,7 +1447,7 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
struct device_node *node = pdev->dev.of_node;
struct property *prop;
int len, ret, words;
-   u32 val;
+   u32 val, tmp[3];

pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
@@ -1472,6 +1478,19 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
if (!of_property_read_u32(node, "qcom,phy-num", &val) && val < 2)
motg->phy_number = val;

+   motg->vdd_levels[VDD_LEVEL_NONE] = USB_PHY_SUSP_DIG_VOL;
+   motg->vdd_levels[VDD_LEVEL_MIN] = USB_PHY_VDD_DIG_VOL_MIN;
+   motg->vdd_levels[VDD_LEVEL_MAX] = USB_PHY_VDD_DIG_VOL_MAX;
+
+   if (of_get_property(node, "qcom,vdd-levels", &len) &&
+   len == sizeof(tmp)) {
+   of_property_read_u32_array(node, "qcom,vdd-levels",
+  tmp, len / sizeof(*tmp));
+   motg->vdd_levels[VDD_LEVEL_NONE] = tmp[VDD_LEVEL_NONE];
+   motg->vdd_levels[VDD_LEVEL_MIN] = tmp[VDD_LEVEL_MIN];
+   motg->vdd_levels[VDD_LEVEL_MAX] = tmp[VDD_LEVEL_MAX];
+   }
+
prop = of_find_property(node, "qcom,phy-init-sequence", &len);

[PATCH v8 17/20] usb: phy: msm: Select secondary PHY via TCSR

2014-04-28 Thread Ivan T. Ivanov
From: Tim Bird 

Select the secondary PHY using the TCSR register, if phy-num=1
in the DTS (or phy_number is set in the platform data).  The
SOC has 2 PHYs which can be used with the OTG port, and this
code allows configuring the correct one.

Note: This resolves the problem I was seeing where I couldn't
get the USB driver working at all on a dragonboard, from cold
boot.  This patch depends on patch 5/14 from Ivan's msm USB
patch set.  It does not use DT for the register address, as
there's no evidence that this address changes between SoC
versions.

Signed-off-by: Tim Bird 
---
 drivers/usb/phy/phy-msm-usb.c| 14 ++
 include/linux/usb/msm_hsusb_hw.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index db8d963..9437bcf 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1489,6 +1489,7 @@ static int msm_otg_probe(struct platform_device *pdev)
struct resource *res;
struct msm_otg *motg;
struct usb_phy *phy;
+   void __iomem *phy_select;

motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL);
if (!motg) {
@@ -1553,6 +1554,19 @@ static int msm_otg_probe(struct platform_device *pdev)
if (IS_ERR(motg->regs))
return PTR_ERR(motg->regs);

+   /*
+* NOTE: The PHYs can be multiplexed between the chipidea controller
+* and the dwc3 controller, using a single bit. It is important that
+* the dwc3 driver does not set this bit in an incompatible way.
+*/
+   if (motg->phy_number) {
+   phy_select = devm_ioremap_nocache(&pdev->dev, USB2_PHY_SEL, 4);
+   if (IS_ERR(phy_select))
+   return PTR_ERR(phy_select);
+   /* Enable second PHY with the OTG port */
+   writel_relaxed(0x1, phy_select);
+   }
+
dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);

motg->irq = platform_get_irq(pdev, 0);
diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
index 98d3dd8..a29f603 100644
--- a/include/linux/usb/msm_hsusb_hw.h
+++ b/include/linux/usb/msm_hsusb_hw.h
@@ -16,6 +16,9 @@
 #ifndef __LINUX_USB_GADGET_MSM72K_UDC_H__
 #define __LINUX_USB_GADGET_MSM72K_UDC_H__

+/* USB phy selector - in TCSR address range */
+#define USB2_PHY_SEL 0xfd4ab000
+
 #define USB_AHBBURST (MSM_USB_BASE + 0x0090)
 #define USB_AHBMODE  (MSM_USB_BASE + 0x0098)
 #define USB_CAPLENGTH(MSM_USB_BASE + 0x0100) /* 8 bit */
--
1.8.3.2

--
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 v8 14/20] usb: phy: msm: Add support for secondary PHY control

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Allow support to use 2nd HSPHY with USB2 Core.
Some platforms may have configuration to allow USB controller
work with any of the two HSPHYs present. By default driver
configures USB core to use primary HSPHY. Add support to allow
user select 2nd HSPHY using DT parameter.

Signed-off-by: Ivan T. Ivanov 
Cc: Manu Gautam 
---
 .../devicetree/bindings/usb/msm-hsusb.txt  |  6 ++
 drivers/usb/phy/phy-msm-usb.c  | 24 --
 include/linux/usb/msm_hsusb.h  |  1 +
 include/linux/usb/msm_hsusb_hw.h   |  1 +
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index ee4123d..0669667 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -59,6 +59,12 @@ Optional properties:
 For example: qcom,phy-init-sequence = < -1 0x63 >;
 Will update only value at address ULPI_EXT_VENDOR_SPECIFIC + 1.

+- qcom,phy-num: Select number of pyco-phy to use, can be one of
+0 - PHY one, default
+1 - Second PHY
+Some platforms may have configuration to allow USB
+controller work with any of the two HSPHYs present.
+
 Example HSUSB OTG controller device node:

 usb@f9a55000 {
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index a6abb1b..8d57045 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -314,6 +314,9 @@ static int msm_otg_phy_reset(struct msm_otg *motg)
if (!retries)
return -ETIMEDOUT;

+   if (motg->phy_number)
+   writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
+
dev_info(motg->phy.dev, "phy_reset: success\n");
return 0;
 }
@@ -368,6 +371,9 @@ static int msm_otg_reset(struct usb_phy *phy)
ulpi_write(phy, ulpi_val, ULPI_USB_INT_EN_FALL);
}

+   if (motg->phy_number)
+   writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
+
return 0;
 }

@@ -404,6 +410,7 @@ static int msm_otg_suspend(struct msm_otg *motg)
struct usb_phy *phy = &motg->phy;
struct usb_bus *bus = phy->otg->host;
struct msm_otg_platform_data *pdata = motg->pdata;
+   void __iomem *addr;
int cnt = 0;

if (atomic_read(&motg->in_lpm))
@@ -463,9 +470,13 @@ static int msm_otg_suspend(struct msm_otg *motg)
 */
writel(readl(USB_USBCMD) | ASYNC_INTR_CTRL | ULPI_STP_CTRL, USB_USBCMD);

+   addr = USB_PHY_CTRL;
+   if (motg->phy_number)
+   addr = USB_PHY_CTRL2;
+
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL)
-   writel(readl(USB_PHY_CTRL) | PHY_RETEN, USB_PHY_CTRL);
+   writel(readl(addr) | PHY_RETEN, addr);

clk_disable_unprepare(motg->pclk);
clk_disable_unprepare(motg->clk);
@@ -495,6 +506,7 @@ static int msm_otg_resume(struct msm_otg *motg)
 {
struct usb_phy *phy = &motg->phy;
struct usb_bus *bus = phy->otg->host;
+   void __iomem *addr;
int cnt = 0;
unsigned temp;

@@ -508,9 +520,14 @@ static int msm_otg_resume(struct msm_otg *motg)

if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL) {
+
+   addr = USB_PHY_CTRL;
+   if (motg->phy_number)
+   addr = USB_PHY_CTRL2;
+
msm_hsusb_ldo_set_mode(motg, 1);
msm_hsusb_config_vddcx(motg, 1);
-   writel(readl(USB_PHY_CTRL) & ~PHY_RETEN, USB_PHY_CTRL);
+   writel(readl(addr) & ~PHY_RETEN, addr);
}

temp = readl(USB_USBCMD);
@@ -1399,6 +1416,9 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
if (val == OTG_PMIC_CONTROL)
pdata->otg_control = val;

+   if (!of_property_read_u32(node, "qcom,phy-num", &val) && val < 2)
+   motg->phy_number = val;
+
prop = of_find_property(node, "qcom,phy-init-sequence", &len);
if (!prop || !len)
return 0;
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 4e5d916..4628f1a 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -158,6 +158,7 @@ struct msm_otg {
atomic_t in_lpm;
int async_int;
unsigned cur_power;
+   int phy_number;
struct delayed_work chg_work;
enum usb_chg_state chg_state;
enum usb_chg_type chg_type;
diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
index 6e97a2d..e6d7035 100644
--- a/include/linux/usb/msm_hsusb_hw.h
+++ b/include/linux/u

[PATCH v8 02/20] usb: phy: msm: Remove __init macro from driver probe method

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

This fixes following:

WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in reference 
from the variable msm_otg_driver to the function .init.text:msm_otg_probe()
The variable msm_otg_driver references
the function __init msm_otg_probe()

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 5b37b81..6ae4d2f 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1406,7 +1406,7 @@ static void msm_otg_debugfs_cleanup(void)
debugfs_remove(msm_otg_dbg_root);
 }

-static int __init msm_otg_probe(struct platform_device *pdev)
+static int msm_otg_probe(struct platform_device *pdev)
 {
int ret = 0;
struct resource *res;
--
1.8.3.2

--
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 v8 20/20] usb: phy: msm: Use usb_add_phy_dev() to register device

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

There could be more than one USB2.0 PHY's on the platform.
This will allow all of them to be registered successfully.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8e7956e..9dc7918 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1663,6 +1663,7 @@ static int msm_otg_probe(struct platform_device *pdev)
phy->init = msm_phy_init;
phy->set_power = msm_otg_set_power;
phy->notify_disconnect = msm_phy_notify_disconnect;
+   phy->type = USB_PHY_TYPE_USB2;

phy->io_ops = &msm_otg_io_ops;

@@ -1672,7 +1673,7 @@ static int msm_otg_probe(struct platform_device *pdev)

msm_usb_reset(phy);

-   ret = usb_add_phy(&motg->phy, USB_PHY_TYPE_USB2);
+   ret = usb_add_phy_dev(&motg->phy);
if (ret) {
dev_err(&pdev->dev, "usb_add_phy failed\n");
goto disable_ldo;
--
1.8.3.2

--
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 v8 18/20] usb: phy: msm: Handle disconnect events

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Put the transceiver in non-driving mode. Otherwise host
may not detect soft-disconnection.

Signed-off-by: Ivan T. Ivanov 
Cc: Pavankumar Kondeti 
---
 drivers/usb/phy/phy-msm-usb.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 9437bcf..366527e 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -235,6 +235,23 @@ static void ulpi_init(struct msm_otg *motg)
}
 }

+static int msm_phy_notify_disconnect(struct usb_phy *phy,
+  enum usb_device_speed speed)
+{
+   int val;
+
+   /*
+* Put the transceiver in non-driving mode. Otherwise host
+* may not detect soft-disconnection.
+*/
+   val = ulpi_read(phy, ULPI_FUNC_CTRL);
+   val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
+   val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
+   ulpi_write(phy, val, ULPI_FUNC_CTRL);
+
+   return 0;
+}
+
 static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
 {
int ret;
@@ -1626,6 +1643,7 @@ static int msm_otg_probe(struct platform_device *pdev)

phy->init = msm_phy_init;
phy->set_power = msm_otg_set_power;
+   phy->notify_disconnect = msm_phy_notify_disconnect;

phy->io_ops = &msm_otg_io_ops;

--
1.8.3.2

--
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 v8 16/20] usb: phy: msm: Fix PTS definitions for MSM USB controller

2014-04-28 Thread Ivan T. Ivanov
From: Tim Bird 

Fix the value used for Parallel Transceiver Select (PTS) for the MSM USB
controller.  This is a standard chipidea PORTSC definition, where
a PHY_TYPE of 10b (<<30) is ULPI and 11b (<<30) is SERIAL.
Fix the definitions and use them correctly in the driver code.

Signed-off-by: Tim Bird 
---
 drivers/usb/phy/phy-msm-usb.c| 8 +---
 include/linux/usb/msm_hsusb_hw.h | 5 +++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index bb33996..db8d963 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -287,8 +287,9 @@ static int msm_link_reset(struct msm_otg *motg)
if (motg->phy_number)
writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);

+   /* put transceiver in serial mode as part of reset */
val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
-   writel(val | PORTSC_PTS_ULPI, USB_PORTSC);
+   writel(val | PORTSC_PTS_SERIAL, USB_PORTSC);

return 0;
 }
@@ -308,8 +309,9 @@ static int msm_otg_reset(struct usb_phy *phy)
if (cnt >= LINK_RESET_TIMEOUT_USEC)
return -ETIMEDOUT;

-   /* select ULPI phy */
-   writel(0x8000, USB_PORTSC);
+   /* select ULPI phy and clear other status/control bits in PORTSC */
+   writel(PORTSC_PTS_ULPI, USB_PORTSC);
+
writel(0x0, USB_AHBBURST);
writel(0x08, USB_AHBMODE);

diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
index 575c743..98d3dd8 100644
--- a/include/linux/usb/msm_hsusb_hw.h
+++ b/include/linux/usb/msm_hsusb_hw.h
@@ -31,8 +31,9 @@
 #define USB_USBINTR  (MSM_USB_BASE + 0x0148)

 #define PORTSC_PHCD(1 << 23) /* phy suspend mode */
-#define PORTSC_PTS_MASK (3 << 30)
-#define PORTSC_PTS_ULPI (3 << 30)
+#define PORTSC_PTS_MASK(3 << 30)
+#define PORTSC_PTS_ULPI(2 << 30)
+#define PORTSC_PTS_SERIAL  (3 << 30)

 #define USB_ULPI_VIEWPORT(MSM_USB_BASE + 0x0170)
 #define ULPI_RUN  (1 << 30)
--
1.8.3.2

--
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 v8 09/20] usb: phy: msm: Remove unused pclk_src_name

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

There are no references to 'pclk_src_name' in plaform code,
so it is unused.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 26 +-
 include/linux/usb/msm_hsusb.h |  5 -
 2 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 7eb2abf..c2361bf 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -464,9 +464,6 @@ static int msm_otg_suspend(struct msm_otg *motg)
if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);

-   if (!IS_ERR(motg->pclk_src))
-   clk_disable_unprepare(motg->pclk_src);
-
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL) {
msm_hsusb_ldo_set_mode(motg, 0);
@@ -496,9 +493,6 @@ static int msm_otg_resume(struct msm_otg *motg)
if (!atomic_read(&motg->in_lpm))
return 0;

-   if (!IS_ERR(motg->pclk_src))
-   clk_prepare_enable(motg->pclk_src);
-
clk_prepare_enable(motg->pclk);
clk_prepare_enable(motg->clk);
if (!IS_ERR(motg->core_clk))
@@ -1396,17 +1390,8 @@ static int msm_otg_probe(struct platform_device *pdev)
 * If USB Core is running its protocol engine based on CORE CLK,
 * CORE CLK  must be running at >55Mhz for correct HSUSB
 * operation and USB core cannot tolerate frequency changes on
-* CORE CLK. For such USB cores, vote for maximum clk frequency
-* on pclk source
+* CORE CLK.
 */
-motg->pclk_src = ERR_PTR(-ENOENT);
-if (motg->pdata->pclk_src_name) {
-   motg->pclk_src = devm_clk_get(&pdev->dev,
-   motg->pdata->pclk_src_name);
-   if (IS_ERR(motg->pclk_src))
-   return PTR_ERR(motg->pclk_src);
-   }
-
motg->pclk = devm_clk_get(&pdev->dev, "usb_hs_pclk");
if (IS_ERR(motg->pclk)) {
dev_err(&pdev->dev, "failed to get usb_hs_pclk\n");
@@ -1446,10 +1431,6 @@ static int msm_otg_probe(struct platform_device *pdev)
motg->v1p8  = regs[2].consumer;

clk_set_rate(motg->clk, 6000);
-   if (!IS_ERR(motg->pclk_src)) {
-   clk_set_rate(motg->pclk_src, INT_MAX);
-   clk_prepare_enable(motg->pclk_src);
-   }

clk_prepare_enable(motg->clk);
clk_prepare_enable(motg->pclk);
@@ -1525,8 +1506,6 @@ disable_clks:
clk_disable_unprepare(motg->clk);
if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);
-   if (!IS_ERR(motg->pclk_src))
-   clk_disable_unprepare(motg->pclk_src);
return ret;
 }

@@ -1571,9 +1550,6 @@ static int msm_otg_remove(struct platform_device *pdev)
clk_disable_unprepare(motg->clk);
if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);
-   if (!IS_ERR(motg->pclk_src))
-   clk_disable_unprepare(motg->pclk_src);
-
msm_hsusb_ldo_init(motg, 0);

pm_runtime_set_suspended(&pdev->dev);
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 72c5830..262ed80 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -106,8 +106,6 @@ enum usb_chg_type {
  * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
  * @mode: Supported mode (OTG/peripheral/host).
  * @otg_control: OTG switch controlled by user/Id pin
- * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k
- *  dfab_usb_hs_clk in case of 8660 and 8960.
  */
 struct msm_otg_platform_data {
int *phy_init_seq;
@@ -117,7 +115,6 @@ struct msm_otg_platform_data {
enum otg_control_type otg_control;
enum msm_usb_phy_type phy_type;
void (*setup_gpio)(enum usb_otg_state state);
-   char *pclk_src_name;
int (*link_clk_reset)(struct clk *link_clk, bool assert);
int (*phy_clk_reset)(struct clk *phy_clk);
 };
@@ -129,7 +126,6 @@ struct msm_otg_platform_data {
  * @irq: IRQ number assigned for HSUSB controller.
  * @clk: clock struct of usb_hs_clk.
  * @pclk: clock struct of usb_hs_pclk.
- * @pclk_src: pclk source for voting.
  * @phy_reset_clk: clock struct of usb_phy_clk.
  * @core_clk: clock struct of usb_hs_core_clk.
  * @regs: ioremapped register base address.
@@ -150,7 +146,6 @@ struct msm_otg {
int irq;
struct clk *clk;
struct clk *pclk;
-   struct clk *pclk_src;
struct clk *phy_reset_clk;
struct clk *core_clk;
void __iomem *regs;
--
1.8.3.2

--
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 v8 07/20] usb: phy: msm: Fix checkpatch.pl warnings

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

This fixes following:

WARNING: quoted string split across lines
WARNING: Prefer seq_puts to seq_printf

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 39 ++-
 1 file changed, 14 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index d7b8360..874c51a 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -67,8 +67,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
-   dev_err(motg->phy.dev, "unable to set the voltage "
-   "for hsusb vddcx\n");
+   dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
return ret;
}

@@ -79,8 +78,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret)
-   dev_err(motg->phy.dev, "unable to set the voltage "
-   "for hsusb vddcx\n");
+   dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb 
vddcx\n");
@@ -97,8 +95,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
-   dev_err(motg->phy.dev, "unable to set voltage level "
-   "for hsusb 3p3\n");
+   dev_err(motg->phy.dev, "Cannot set v3p3 voltage\n");
goto exit;
}
rc = regulator_enable(motg->v3p3);
@@ -109,8 +106,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int 
init)
rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
-   dev_err(motg->phy.dev, "unable to set voltage level "
-   "for hsusb 1p8\n");
+   dev_err(motg->phy.dev, "Cannot set v1p8 voltage\n");
goto disable_3p3;
}
rc = regulator_enable(motg->v1p8);
@@ -137,15 +133,13 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, 
int on)
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_HPM_LOAD);
if (ret < 0) {
-   pr_err("%s: Unable to set HPM of the regulator "
-   "HSUSB_1p8\n", __func__);
+   pr_err("Could not set HPM for v1p8\n");
return ret;
}
ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_HPM_LOAD);
if (ret < 0) {
-   pr_err("%s: Unable to set HPM of the regulator "
-   "HSUSB_3p3\n", __func__);
+   pr_err("Could not set HPM for v3p3\n");
regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
return ret;
@@ -154,13 +148,11 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, 
int on)
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
if (ret < 0)
-   pr_err("%s: Unable to set LPM of the regulator "
-   "HSUSB_1p8\n", __func__);
+   pr_err("Could not set LPM for v1p8\n");
ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_LPM_LOAD);
if (ret < 0)
-   pr_err("%s: Unable to set LPM of the regulator "
-   "HSUSB_3p3\n", __func__);
+   pr_err("Could not set LPM for v3p3\n");
}

pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
@@ -390,8 +382,7 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, int 
high)

ret = regulator_set_voltage(motg->vddcx, min_vol, max_vol);
if (ret) {
-   pr_err("%s: unable to set the voltage for regulator "
-   "HSUSB_VDDCX\n", __func__);
+   pr_err("Cannot set vddcx voltage\n");
return ret;
}

@@ -546,8 +537,7 @@ static int msm_otg_resume(struct msm_otg *motg)
 * PHY. USB state can not be rest

[PATCH v8 15/20] usb: phy: msm: Correct USB PHY Reset sequence for newer platform

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

On few legacy platforms, USB PHY is having dedicated reset clk.
It is used to reset USB PHY after putting USB PHY into low power
mode and for calibration of USB PHY. Putting USB PHY into low
power mode is causing ulpi read/write timeout as expected. USB PHY
reset clk is not available on newer platform.

For 28nm PHY, reset USB PHY after resetting USB LINK.
Also reset USB PHY using USB_PHY_PON bit with USB_OTG_HS_PHY_CTRL
register after programming USB PHY Override registers as suggested
with hardware programming guidelines.

Signed-off-by: Ivan T. Ivanov 
Signed-off-by: Tim Bird 
Cc: Mayank Rana 
---
 drivers/usb/phy/phy-msm-usb.c| 140 ---
 include/linux/usb/msm_hsusb_hw.h |   5 ++
 2 files changed, 93 insertions(+), 52 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8d57045..bb33996 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -48,6 +48,7 @@
 #define DRIVER_NAME"msm_otg"

 #define ULPI_IO_TIMEOUT_USEC   (10 * 1000)
+#define LINK_RESET_TIMEOUT_USEC(250 * 1000)

 #define USB_PHY_3P3_VOL_MIN305 /* uV */
 #define USB_PHY_3P3_VOL_MAX330 /* uV */
@@ -267,77 +268,35 @@ static int msm_otg_phy_clk_reset(struct msm_otg *motg)
return ret;
 }

-static int msm_otg_phy_reset(struct msm_otg *motg)
+static int msm_link_reset(struct msm_otg *motg)
 {
u32 val;
int ret;
-   int retries;

ret = msm_otg_link_clk_reset(motg, 1);
if (ret)
return ret;
-   ret = msm_otg_phy_clk_reset(motg);
-   if (ret)
-   return ret;
-   ret = msm_otg_link_clk_reset(motg, 0);
-   if (ret)
-   return ret;

-   val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
-   writel(val | PORTSC_PTS_ULPI, USB_PORTSC);
-
-   for (retries = 3; retries > 0; retries--) {
-   ret = ulpi_write(&motg->phy, ULPI_FUNC_CTRL_SUSPENDM,
-   ULPI_CLR(ULPI_FUNC_CTRL));
-   if (!ret)
-   break;
-   ret = msm_otg_phy_clk_reset(motg);
-   if (ret)
-   return ret;
-   }
-   if (!retries)
-   return -ETIMEDOUT;
+   /* wait for 1ms delay as suggested in HPG. */
+   usleep_range(1000, 1200);

-   /* This reset calibrates the phy, if the above write succeeded */
-   ret = msm_otg_phy_clk_reset(motg);
+   ret = msm_otg_link_clk_reset(motg, 0);
if (ret)
return ret;

-   for (retries = 3; retries > 0; retries--) {
-   ret = ulpi_read(&motg->phy, ULPI_DEBUG);
-   if (ret != -ETIMEDOUT)
-   break;
-   ret = msm_otg_phy_clk_reset(motg);
-   if (ret)
-   return ret;
-   }
-   if (!retries)
-   return -ETIMEDOUT;
-
if (motg->phy_number)
writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);

-   dev_info(motg->phy.dev, "phy_reset: success\n");
+   val = readl(USB_PORTSC) & ~PORTSC_PTS_MASK;
+   writel(val | PORTSC_PTS_ULPI, USB_PORTSC);
+
return 0;
 }

-#define LINK_RESET_TIMEOUT_USEC(250 * 1000)
 static int msm_otg_reset(struct usb_phy *phy)
 {
struct msm_otg *motg = container_of(phy, struct msm_otg, phy);
-   struct msm_otg_platform_data *pdata = motg->pdata;
int cnt = 0;
-   int ret;
-   u32 val = 0;
-   u32 ulpi_val = 0;
-
-   ret = msm_otg_phy_reset(motg);
-   if (ret) {
-   dev_err(phy->dev, "phy_reset failed\n");
-   return ret;
-   }
-
-   ulpi_init(motg);

writel(USBCMD_RESET, USB_USBCMD);
while (cnt < LINK_RESET_TIMEOUT_USEC) {
@@ -351,11 +310,86 @@ static int msm_otg_reset(struct usb_phy *phy)

/* select ULPI phy */
writel(0x8000, USB_PORTSC);
+   writel(0x0, USB_AHBBURST);
+   writel(0x08, USB_AHBMODE);
+
+   if (motg->phy_number)
+   writel(readl(USB_PHY_CTRL2) | BIT(16), USB_PHY_CTRL2);
+   return 0;
+}
+
+static void msm_phy_reset(struct msm_otg *motg)
+{
+   void __iomem *addr;
+
+   if (motg->pdata->phy_type != SNPS_28NM_INTEGRATED_PHY) {
+   msm_otg_phy_clk_reset(motg);
+   return;
+   }
+
+   addr = USB_PHY_CTRL;
+   if (motg->phy_number)
+   addr = USB_PHY_CTRL2;
+
+   /* Assert USB PHY_POR */
+   writel(readl(addr) | PHY_POR_ASSERT, addr);
+
+   /*
+* wait for minimum 10 microseconds as suggested in HPG.
+* Use a slightly larger value since the exact value didn't
+* work 100% of the time.
+*/
+   udelay(12);
+
+   /* Deassert USB PHY_POR */
+   writel(readl(addr) & ~PHY_POR_ASSERT, addr);
+}
+
+static int msm_usb_reset(struct usb_phy *phy)
+{
+   struct msm_otg *motg = container_of(phy, struct msm_

[PATCH v8 11/20] usb: phy: msm: Properly check result from platform_get_irq()

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Function return negative code on error.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index bd9e286..7e968aa 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1413,7 +1413,7 @@ static int msm_otg_probe(struct platform_device *pdev)
dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);

motg->irq = platform_get_irq(pdev, 0);
-   if (!motg->irq) {
+   if (motg->irq < 0) {
dev_err(&pdev->dev, "platform_get_irq failed\n");
return motg->irq;
}
--
1.8.3.2

--
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: /sys/bus/usb/devices

2014-04-28 Thread Greg KH
On Mon, Apr 28, 2014 at 02:59:16PM +0300, Mathias Nyman wrote:
> 
> 
> On 04/27/2014 11:11 AM, John Freed wrote:
> > I hope you don't mind me writing you directly, and if someone else can
> > handle this better please let me know.
> >
> > I'm trying to do some backend work on libusb and I notice that the
> > kernel keeps all the information on the Device Descriptors except for
> > the value of the Serial Number string.
> >
> > (Well, almost all. Oddly, the "manufacturer" string is not included for
> > hubs from Intel! I presume that's because they're really PCI devices and
> > there is some black magic going on in the background to fill in the USB
> > device descriptor.)
> >
> > I'm wondering if it would be difficult for you to establish a
> > "serialnumber" value in the directory that holds the other values (like
> > maxchild, etc.) from the Device Descriptor. I'm not a kernel programmer,
> > which is why I'm turning to you.
> >
> 
> Hi John
> 
> I'll add this to the linux-usb mailing list. It has people with more 
> knowledge about generic usb core area.
> 
> The serial number string descriptor in a device descriptor is optional, 
> so it might just not be there.  I checked that usb core has code for 
> supporting string descriptors in sysfs if they exists.

If the serial number is present in the device, it will show up in sysfs
in a file called "serial".  Most USB devices these days don't seem to
have them, especially ones that are "built into" a laptop.

Hope this helps,

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 v8 05/20] usb: phy: msm: Migrate to Managed Device Resource allocation

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Move memory, regulators, clocks and irq allocation to
devm_* variants. Properly check for valid clk handles.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 187 +++---
 1 file changed, 68 insertions(+), 119 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index b7d73f2..67705fc 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -63,27 +63,18 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
int ret = 0;

if (init) {
-   motg->vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
-   if (IS_ERR(motg->vddcx)) {
-   dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
-   return PTR_ERR(motg->vddcx);
-   }
-
ret = regulator_set_voltage(motg->vddcx,
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
-   regulator_put(motg->vddcx);
return ret;
}

ret = regulator_enable(motg->vddcx);
-   if (ret) {
+   if (ret)
dev_err(motg->phy.dev, "unable to enable hsusb 
vddcx\n");
-   regulator_put(motg->vddcx);
-   }
} else {
ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
@@ -93,8 +84,6 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int 
init)
ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb 
vddcx\n");
-
-   regulator_put(motg->vddcx);
}

return ret;
@@ -105,53 +94,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int 
init)
int rc = 0;

if (init) {
-   motg->v3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
-   if (IS_ERR(motg->v3p3)) {
-   dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
-   return PTR_ERR(motg->v3p3);
-   }
-
rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 3p3\n");
-   goto put_3p3;
+   goto exit;
}
rc = regulator_enable(motg->v3p3);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 
3p3\n");
-   goto put_3p3;
-   }
-   motg->v1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
-   if (IS_ERR(motg->v1p8)) {
-   dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
-   rc = PTR_ERR(motg->v1p8);
-   goto disable_3p3;
+   goto exit;
}
rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 1p8\n");
-   goto put_1p8;
+   goto disable_3p3;
}
rc = regulator_enable(motg->v1p8);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 
1p8\n");
-   goto put_1p8;
+   goto disable_3p3;
}

return 0;
}

regulator_disable(motg->v1p8);
-put_1p8:
-   regulator_put(motg->v1p8);
 disable_3p3:
regulator_disable(motg->v3p3);
-put_3p3:
-   regulator_put(motg->v3p3);
+exit:
return rc;
 }

@@ -506,7 +480,7 @@ static int msm_otg_suspend(struct msm_otg *motg)

clk_disable_unprepare(motg->pclk);
clk_disable_unprepare(motg->clk);
-   if (motg->core_clk)
+   if (!IS_ERR(motg->core_clk))
clk_disable_unprepare(motg->core_clk);

if (!IS_ERR(motg->pclk_src))
@@ -546,7 +520,7 @@ static int msm_otg_resume(struct msm_otg *motg)

clk_prepare_enable(motg->pclk);
clk_prepare_enable(motg->clk);
-   if (motg->core_clk)
+   if (!IS_ERR(motg->core_clk))
clk_prepare_enable(motg->core_clk);

if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
@@ -1404,6 +1378,7 @@ static void msm_otg_debugfs_cleanup(void)

 static int msm_otg_probe(struct

[PATCH v8 06/20] usb: phy: msm: Remove unnecessarily check for valid regulators.

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Whether regulators are available or not is checked at driver
probe. If they are not available driver will refuse to load,
so no need to check them again.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 67705fc..d7b8360 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -133,16 +133,6 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, 
int on)
 {
int ret = 0;

-   if (!motg->v1p8 || IS_ERR(motg->v1p8)) {
-   pr_err("%s: HSUSB_1p8 is not initialized\n", __func__);
-   return -ENODEV;
-   }
-
-   if (!motg->v3p3 || IS_ERR(motg->v3p3)) {
-   pr_err("%s: HSUSB_3p3 is not initialized\n", __func__);
-   return -ENODEV;
-   }
-
if (on) {
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_HPM_LOAD);
--
1.8.3.2

--
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 v8 04/20] usb: phy: msm: Enable deferred driver probing

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Using platform_driver_probe() prevent driver from requesting
probe deferral. Fix this.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 6bae936..b7d73f2 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1736,6 +1736,7 @@ static const struct dev_pm_ops msm_otg_dev_pm_ops = {
 };

 static struct platform_driver msm_otg_driver = {
+   .probe = msm_otg_probe,
.remove = msm_otg_remove,
.driver = {
.name = DRIVER_NAME,
@@ -1744,7 +1745,7 @@ static struct platform_driver msm_otg_driver = {
},
 };

-module_platform_driver_probe(msm_otg_driver, msm_otg_probe);
+module_platform_driver(msm_otg_driver);

 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("MSM USB transceiver driver");
--
1.8.3.2

--
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 v8 08/20] usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Use enum usb_dr_mode and drop default usb_dr_mode from platform data.

USB DT bindings states: dr_mode: "...In case this attribute isn't
passed via DT, USB DRD controllers should default to OTG...",
so remove redundand field.

Signed-off-by: Ivan T. Ivanov 
Acked-by: David Brown 
---
 arch/arm/mach-msm/board-msm7x30.c |  2 +-
 arch/arm/mach-msm/board-qsd8x50.c |  2 +-
 drivers/usb/phy/phy-msm-usb.c | 41 ---
 include/linux/usb/msm_hsusb.h | 20 +--
 4 files changed, 20 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mach-msm/board-msm7x30.c 
b/arch/arm/mach-msm/board-msm7x30.c
index 46de789..0c4c200 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -95,7 +95,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk)

 static struct msm_otg_platform_data msm_otg_pdata = {
.phy_init_seq   = hsusb_phy_init_seq,
-   .mode   = USB_PERIPHERAL,
+   .mode   = USB_DR_MODE_PERIPHERAL,
.otg_control= OTG_PHY_CONTROL,
.link_clk_reset = hsusb_link_clk_reset,
.phy_clk_reset  = hsusb_phy_clk_reset,
diff --git a/arch/arm/mach-msm/board-qsd8x50.c 
b/arch/arm/mach-msm/board-qsd8x50.c
index 9169ec3..4c74861 100644
--- a/arch/arm/mach-msm/board-qsd8x50.c
+++ b/arch/arm/mach-msm/board-qsd8x50.c
@@ -116,7 +116,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk)

 static struct msm_otg_platform_data msm_otg_pdata = {
.phy_init_seq   = hsusb_phy_init_seq,
-   .mode   = USB_PERIPHERAL,
+   .mode   = USB_DR_MODE_PERIPHERAL,
.otg_control= OTG_PHY_CONTROL,
.link_clk_reset = hsusb_link_clk_reset,
.phy_clk_reset  = hsusb_phy_clk_reset,
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 874c51a..7eb2abf 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -348,10 +348,10 @@ static int msm_otg_reset(struct usb_phy *phy)

if (pdata->otg_control == OTG_PHY_CONTROL) {
val = readl(USB_OTGSC);
-   if (pdata->mode == USB_OTG) {
+   if (pdata->mode == USB_DR_MODE_OTG) {
ulpi_val = ULPI_INT_IDGRD | ULPI_INT_SESS_VALID;
val |= OTGSC_IDIE | OTGSC_BSVIE;
-   } else if (pdata->mode == USB_PERIPHERAL) {
+   } else if (pdata->mode == USB_DR_MODE_PERIPHERAL) {
ulpi_val = ULPI_INT_SESS_VALID;
val |= OTGSC_BSVIE;
}
@@ -637,7 +637,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 * Fail host registration if this board can support
 * only peripheral configuration.
 */
-   if (motg->pdata->mode == USB_PERIPHERAL) {
+   if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) {
dev_info(otg->phy->dev, "Host mode is not supported\n");
return -ENODEV;
}
@@ -666,7 +666,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct 
usb_bus *host)
 * Kick the state machine work, if peripheral is not supported
 * or peripheral is already registered with us.
 */
-   if (motg->pdata->mode == USB_HOST || otg->gadget) {
+   if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
pm_runtime_get_sync(otg->phy->dev);
schedule_work(&motg->sm_work);
}
@@ -710,7 +710,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
 * Fail peripheral registration if this board can support
 * only host configuration.
 */
-   if (motg->pdata->mode == USB_HOST) {
+   if (motg->pdata->mode == USB_DR_MODE_HOST) {
dev_info(otg->phy->dev, "Peripheral mode is not supported\n");
return -ENODEV;
}
@@ -735,7 +735,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
 * Kick the state machine work, if host is not supported
 * or host is already registered with us.
 */
-   if (motg->pdata->mode == USB_PERIPHERAL || otg->host) {
+   if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
pm_runtime_get_sync(otg->phy->dev);
schedule_work(&motg->sm_work);
}
@@ -1056,7 +1056,7 @@ static void msm_otg_init_sm(struct msm_otg *motg)
u32 otgsc = readl(USB_OTGSC);

switch (pdata->mode) {
-   case USB_OTG:
+   case USB_DR_MODE_OTG:
if (pdata->otg_control == OTG_PHY_CONTROL) {
if (otgsc & OTGSC_ID)
set_bit(ID, &motg->inputs);
@@ -1068,21 +1068,14 @@ static void msm_otg_init_sm(struct msm_otg *motg)
else
clear_bit(B_SESS_VLD, &motg->inputs);
}

[PATCH v8 01/20] usb: phy: msm: Make driver selectable on ARCH_QCOM

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Controller could be found on APQ and MSM platforms,
make configuration description more generic.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 416e0c8..0c668a3 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -171,11 +171,11 @@ config USB_ISP1301
  module will be called phy-isp1301.

 config USB_MSM_OTG
-   tristate "OTG support for Qualcomm on-chip USB controller"
-   depends on (USB || USB_GADGET) && ARCH_MSM
+   tristate "Qualcomm on-chip USB OTG controller support"
+   depends on (USB || USB_GADGET) && (ARCH_MSM || ARCH_QCOM)
select USB_PHY
help
- Enable this to support the USB OTG transceiver on MSM chips. It
+ Enable this to support the USB OTG transceiver on Qualcomm chips. It
  handles PHY initialization, clock management, and workarounds
  required after resetting the hardware and power management.
  This driver is required even for peripheral only or host only
--
1.8.3.2

--
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 v8 12/20] usb: phy: msm: Add device tree support and binding information

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Allows controller to be specified via device tree.

Signed-off-by: Ivan T. Ivanov 
---
 .../devicetree/bindings/usb/msm-hsusb.txt  |  67 
 drivers/usb/phy/phy-msm-usb.c  | 113 +
 include/linux/usb/msm_hsusb.h  |   6 +-
 3 files changed, 165 insertions(+), 21 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt 
b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index 5ea26c6..ee4123d 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -15,3 +15,70 @@ Example EHCI controller device node:
usb-phy = <&usb_otg>;
};

+USB PHY with optional OTG:
+
+Required properties:
+- compatible:   Should contain:
+  "qcom,usb-otg-ci" for chipsets with ChipIdea 45nm PHY
+  "qcom,usb-otg-snps" for chipsets with Synopsys 28nm PHY
+
+- regs: Offset and length of the register set in the memory map
+- interrupts:   interrupt-specifier for the OTG interrupt.
+
+- clocks:   A list of phandle + clock-specifier pairs for the
+clocks listed in clock-names
+- clock-names:  Should contain the following:
+  "phy" USB PHY reference clock
+  "core"Protocol engine clock
+  "iface"   Interface bus clock
+  "alt_core"Protocol engine clock for targets with asynchronous
+reset methodology. (optional)
+
+- vdccx-supply: phandle to the regulator for the vdd supply for
+digital circuit operation.
+- v1p8-supply:  phandle to the regulator for the 1.8V supply
+- v3p3-supply:  phandle to the regulator for the 3.3V supply
+
+- resets:   A list of phandle + reset-specifier pairs for the
+resets listed in reset-names
+- reset-names:  Should contain the following:
+  "phy" USB PHY controller reset
+  "link"USB LINK controller reset
+
+- qcom,otg-control: OTG control (VBUS and ID notifications) can be one of
+1 - PHY control
+2 - PMIC control
+
+Optional properties:
+- dr_mode:  One of "host", "peripheral" or "otg". Defaults to "otg"
+
+- qcom,phy-init-sequence: PHY configuration sequence values. This is related 
to Device
+Mode Eye Diagram test. Start address at which these values 
will be
+written is ULPI_EXT_VENDOR_SPECIFIC. Value of -1 is reserved as
+"do not overwrite default value at this address".
+For example: qcom,phy-init-sequence = < -1 0x63 >;
+Will update only value at address ULPI_EXT_VENDOR_SPECIFIC + 1.
+
+Example HSUSB OTG controller device node:
+
+usb@f9a55000 {
+compatible = "qcom,usb-otg-snps";
+reg = <0xf9a55000 0x400>;
+interrupts = <0 134 0>;
+dr_mode = "peripheral";
+
+clocks = <&gcc GCC_XO_CLK>, <&gcc GCC_USB_HS_SYSTEM_CLK>,
+<&gcc GCC_USB_HS_AHB_CLK>;
+
+clock-names = "phy", "core", "iface";
+
+vddcx-supply = <&pm8841_s2_corner>;
+v1p8-supply = <&pm8941_l6>;
+v3p3-supply = <&pm8941_l24>;
+
+resets = <&gcc GCC_USB2A_PHY_BCR>, <&gcc GCC_USB_HS_BCR>;
+reset-names = "phy", "link";
+
+qcom,otg-control = <1>;
+qcom,phy-init-sequence = < -1 0x63 >;
+   };
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 7e968aa..1bf2d4e 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -30,9 +30,12 @@
 #include 
 #include 
 #include 
+#include 
+#include 

 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -217,16 +220,16 @@ static struct usb_phy_io_ops msm_otg_io_ops = {
 static void ulpi_init(struct msm_otg *motg)
 {
struct msm_otg_platform_data *pdata = motg->pdata;
-   int *seq = pdata->phy_init_seq;
+   int *seq = pdata->phy_init_seq, idx;
+   u32 addr = ULPI_EXT_VENDOR_SPECIFIC;

-   if (!seq)
-   return;
+   for (idx = 0; idx < pdata->phy_init_sz; idx++) {
+   if (seq[idx] == -1)
+   continue;

-   while (seq[0] >= 0) {
dev_vdbg(motg->phy.dev, "ulpi: write 0x%02x to 0x%02x\n",
-   seq[0], seq[1]);
-   ulpi_write(&motg->phy, seq[0], seq[1]);
-   seq += 2;
+   seq[idx], addr + idx);
+   ulpi_write(&motg->phy, seq[idx], addr + idx);
}
 }

@@ -1343,26 +1346,96 @@ static void msm_otg_debugfs_cleanup(void)
debugfs_remove(msm_otg_dbg_root);
 }

+static struct of_device_id msm_otg_dt_match[] = {
+   {
+   .compatible = "qcom,usb-otg-ci",
+   .data = (void *) CI_45NM_INTEGRATED_PHY
+   },
+   {
+   .compatible = "qcom,usb-otg-snps",
+   .data = (void *) SNPS_28NM_INTEGRATED_PHY
+   },
+   { }
+};
+MODULE_DEVICE_TABLE(of, msm_o

[PATCH v8 13/20] usb: phy: msm: Use reset framework for LINK and PHY resets

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Using reset framework eliminate need of platform specific
callbacks and enable reset lines to be specified in DT files.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 29 +
 include/linux/usb/msm_hsusb.h |  3 +++
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 1bf2d4e..a6abb1b 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 

 #include 
 #include 
@@ -235,12 +236,15 @@ static void ulpi_init(struct msm_otg *motg)

 static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
 {
-   int ret = 0;
+   int ret;

-   if (!motg->pdata->link_clk_reset)
-   return ret;
+   if (motg->pdata->link_clk_reset)
+   ret = motg->pdata->link_clk_reset(motg->clk, assert);
+   else if (assert)
+   ret = reset_control_assert(motg->link_rst);
+   else
+   ret = reset_control_deassert(motg->link_rst);

-   ret = motg->pdata->link_clk_reset(motg->clk, assert);
if (ret)
dev_err(motg->phy.dev, "usb link clk reset %s failed\n",
assert ? "assert" : "deassert");
@@ -250,12 +254,13 @@ static int msm_otg_link_clk_reset(struct msm_otg *motg, 
bool assert)

 static int msm_otg_phy_clk_reset(struct msm_otg *motg)
 {
-   int ret = 0;
+   int ret;

-   if (!motg->pdata->phy_clk_reset)
-   return ret;
+   if (motg->pdata->phy_clk_reset)
+   ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
+   else
+   ret = reset_control_reset(motg->phy_rst);

-   ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
if (ret)
dev_err(motg->phy.dev, "usb phy clk reset failed\n");

@@ -1377,6 +1382,14 @@ static int msm_otg_read_dt(struct platform_device *pdev, 
struct msm_otg *motg)
id = of_match_device(msm_otg_dt_match, &pdev->dev);
pdata->phy_type = (int) id->data;

+   motg->link_rst = devm_reset_control_get(&pdev->dev, "link");
+   if (IS_ERR(motg->link_rst))
+   return PTR_ERR(motg->link_rst);
+
+   motg->phy_rst = devm_reset_control_get(&pdev->dev, "phy");
+   if (IS_ERR(motg->phy_rst))
+   return PTR_ERR(motg->phy_rst);
+
pdata->mode = of_usb_get_dr_mode(node);
if (pdata->mode == USB_DR_MODE_UNKNOWN)
pdata->mode = USB_DR_MODE_OTG;
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index bd68299..4e5d916 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -165,6 +165,9 @@ struct msm_otg {
struct regulator *v3p3;
struct regulator *v1p8;
struct regulator *vddcx;
+
+   struct reset_control *phy_rst;
+   struct reset_control *link_rst;
 };

 #endif
--
1.8.3.2

--
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 v8 00/20] usb: phy: msm: Fixes, cleanups and DT support

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Hi,

This is a new version of patches posted earlier[1].

Changes since v7

 - Use bulk regulator request function in patch #05
 - Fix errors in patch #20 commit message

[1] http://www.spinics.net/lists/linux-arm-msm/msg08997.html

Ivan T. Ivanov (18):
  usb: phy: msm: Make driver selectable on ARCH_QCOM
  usb: phy: msm: Remove __init macro from driver probe method
  usb: phy: msm: Move global regulators variables to driver state
  usb: phy: msm: Enable deferred driver probing
  usb: phy: msm: Migrate to Managed Device Resource allocation
  usb: phy: msm: Remove unnecessarily check for valid regulators.
  usb: phy: msm: Fix checkpatch.pl warnings
  usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode
  usb: phy: msm: Remove unused pclk_src_name
  usb: phy: msm: Remove HSUSB prefix from regulator names
  usb: phy: msm: Properly check result from platform_get_irq()
  usb: phy: msm: Add device tree support and binding information
  usb: phy: msm: Use reset framework for LINK and PHY resets
  usb: phy: msm: Add support for secondary PHY control
  usb: phy: msm: Correct USB PHY Reset sequence for newer platform
  usb: phy: msm: Handle disconnect events
  usb: phy: msm: Vote for corner of VDD CX instead of voltage of VDD CX
  usb: phy: msm: Use usb_add_phy_dev() to register device

Tim Bird (2):
  usb: phy: msm: Fix PTS definitions for MSM USB controller
  usb: phy: msm: Select secondary PHY via TCSR

 .../devicetree/bindings/usb/msm-hsusb.txt  |  78 +++
 arch/arm/mach-msm/board-msm7x30.c  |   2 +-
 arch/arm/mach-msm/board-qsd8x50.c  |   2 +-
 drivers/usb/phy/Kconfig|   6 +-
 drivers/usb/phy/phy-msm-usb.c  | 700 -
 include/linux/usb/msm_hsusb.h  |  39 +-
 include/linux/usb/msm_hsusb_hw.h   |  14 +-
 7 files changed, 504 insertions(+), 337 deletions(-)

--
1.8.3.2

--
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 v8 10/20] usb: phy: msm: Remove HSUSB prefix from regulator names

2014-04-28 Thread Ivan T. Ivanov
From: "Ivan T. Ivanov" 

Prefix did not bring any useful information. Currently none
of the MSM platforms define these regulators, so it is safe
to rename them.

Signed-off-by: Ivan T. Ivanov 
---
 drivers/usb/phy/phy-msm-usb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index c2361bf..bd9e286 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1418,9 +1418,9 @@ static int msm_otg_probe(struct platform_device *pdev)
return motg->irq;
}

-   regs[0].supply = "HSUSB_VDDCX";
-   regs[1].supply = "HSUSB_3p3";
-   regs[2].supply = "HSUSB_1p8";
+   regs[0].supply = "vddcx";
+   regs[1].supply = "v3p3";
+   regs[2].supply = "v1p8";

ret = devm_regulator_bulk_get(motg->phy.dev, ARRAY_SIZE(regs), regs);
if (ret)
--
1.8.3.2

--
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/7] ARM: DRA7: hwmod: Add SYSCONFIG for usb_otg_ss

2014-04-28 Thread Roger Quadros
Add the sysconfig class bits for the Super Speed USB
controllers

Signed-off-by: Roger Quadros 
---
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c 
b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
index 810c205..067d322 100644
--- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c
@@ -1731,8 +1731,20 @@ static struct omap_hwmod dra7xx_uart6_hwmod = {
  *
  */
 
+static struct omap_hwmod_class_sysconfig dra7xx_usb_otg_ss_sysc = {
+   .rev_offs   = 0x,
+   .sysc_offs  = 0x0010,
+   .sysc_flags = (SYSC_HAS_DMADISABLE | SYSC_HAS_MIDLEMODE |
+  SYSC_HAS_SIDLEMODE),
+   .idlemodes  = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
+  SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
+  MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
+   .sysc_fields= &omap_hwmod_sysc_type2,
+};
+
 static struct omap_hwmod_class dra7xx_usb_otg_ss_hwmod_class = {
.name   = "usb_otg_ss",
+   .sysc   = &dra7xx_usb_otg_ss_sysc,
 };
 
 /* usb_otg_ss1 */
-- 
1.8.3.2

--
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/7] ARM: dts: dra7-clock: Add "l3init_960m_gfclk" clock gate

2014-04-28 Thread Roger Quadros
This clock gate description is missing in the older Reference manuals.
It is present on the SoC to provide 960MHz reference clock to the
internal USB PHYs.

Reference: DRA75x_DRA74x_ES1.1_NDA_TRM_vO.pdf, pg. 900,
Table 3-812. CM_COREAON_L3INIT_60M_GFCLK_CLKCTRL

Use l3init_960m_gfclk as parent of usb_otg_ss1_refclk960m and
usb_otg_ss2_refclk960m.

CC: Tero Kristo 
Signed-off-by: Roger Quadros 
---
 arch/arm/boot/dts/dra7xx-clocks.dtsi | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/dra7xx-clocks.dtsi 
b/arch/arm/boot/dts/dra7xx-clocks.dtsi
index cfb8fc7..c767687 100644
--- a/arch/arm/boot/dts/dra7xx-clocks.dtsi
+++ b/arch/arm/boot/dts/dra7xx-clocks.dtsi
@@ -1386,6 +1386,14 @@
ti,dividers = <1>, <8>;
};
 
+   l3init_960m_gfclk: l3init_960m_gfclk {
+   #clock-cells = <0>;
+   compatible = "ti,gate-clock";
+   clocks = <&dpll_usb_clkdcoldo>;
+   ti,bit-shift = <8>;
+   reg = <0x06c0>;
+   };
+
dss_32khz_clk: dss_32khz_clk {
#clock-cells = <0>;
compatible = "ti,gate-clock";
@@ -1533,7 +1541,7 @@
usb_otg_ss1_refclk960m: usb_otg_ss1_refclk960m {
#clock-cells = <0>;
compatible = "ti,gate-clock";
-   clocks = <&dpll_usb_clkdcoldo>;
+   clocks = <&l3init_960m_gfclk>;
ti,bit-shift = <8>;
reg = <0x13f0>;
};
@@ -1541,7 +1549,7 @@
usb_otg_ss2_refclk960m: usb_otg_ss2_refclk960m {
#clock-cells = <0>;
compatible = "ti,gate-clock";
-   clocks = <&dpll_usb_clkdcoldo>;
+   clocks = <&l3init_960m_gfclk>;
ti,bit-shift = <8>;
reg = <0x1340>;
};
-- 
1.8.3.2

--
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 5/7] phy: omap-usb2: Add clock names to Documentation binding

2014-04-28 Thread Roger Quadros
Add "wkupclk" and "refclk" information to DT binding information.

Signed-off-by: Roger Quadros 
---
 Documentation/devicetree/bindings/phy/ti-phy.txt | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt 
b/Documentation/devicetree/bindings/phy/ti-phy.txt
index 788fb0f..9ce458f 100644
--- a/Documentation/devicetree/bindings/phy/ti-phy.txt
+++ b/Documentation/devicetree/bindings/phy/ti-phy.txt
@@ -32,6 +32,11 @@ Required properties:
  - reg : Address and length of the register set for the device.
  - #phy-cells: determine the number of cells that should be given in the
phandle while referencing this phy.
+ - clocks: a list of phandles and clock-specifier pairs, one for each entry in
+   clock-names.
+ - clock-names: should include:
+   * "wkupclk" - wakeup clock.
+   * "refclk" - reference clock (optional).
 
 Optional properties:
  - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -44,6 +49,8 @@ usb2phy@4a0ad080 {
reg = <0x4a0ad080 0x58>;
ctrl-module = <&omap_control_usb>;
#phy-cells = <0>;
+   clocks = <&usb_phy_cm_clk32k>, <&usb_otg_ss_refclk960m>;
+   clock-names = "wkupclk", "refclk";
 };
 
 TI PIPE3 PHY
-- 
1.8.3.2

--
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 7/7] dts: dra7-evm: add USB support

2014-04-28 Thread Roger Quadros
Add USB pinmux information and USB modes
for the USB controllers.

Signed-off-by: Roger Quadros 
---
 arch/arm/boot/dts/dra7-evm.dts | 24 
 1 file changed, 24 insertions(+)

diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
index 5babba0..1d77815 100644
--- a/arch/arm/boot/dts/dra7-evm.dts
+++ b/arch/arm/boot/dts/dra7-evm.dts
@@ -93,6 +93,18 @@
0x24c (PIN_INPUT_SLEW | MUX_MODE0) /* uart3_txd */
>;
};
+
+   usb1_pins: pinmux_usb1_pins {
+pinctrl-single,pins = <
+   0x280   0xc /* usb1_drvvbus, SLOW_SLEW | PULLUPEN | 
MODE0 */
+>;
+};
+
+   usb2_pins: pinmux_usb2_pins {
+pinctrl-single,pins = <
+   0x284   0xc /* usb2_drvvbus, SLOW_SLEW | PULLUPEN | 
MODE0 */
+>;
+};
 };
 
 &i2c1 {
@@ -273,3 +285,15 @@
 &cpu0 {
cpu0-supply = <&smps123_reg>;
 };
+
+&usb1 {
+   dr_mode = "peripheral";
+   pinctrl-names = "default";
+   pinctrl-0 = <&usb1_pins>;
+};
+
+&usb2 {
+   dr_mode = "host";
+   pinctrl-names = "default";
+   pinctrl-0 = <&usb2_pins>;
+};
-- 
1.8.3.2

--
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/7] USB support for DRA7-evm

2014-04-28 Thread Roger Quadros
Hi,

This series enables the 2 USB ports on the DRA7-evm.

NOTE: USB1 port is hard coded to work in peripheral mode and USB2 port
in host mode. This is due to missing ID pin interrupt in pre ver.E boards.

USB1 port doesn't in peripheral mode out of the box due to missing VBUS 
detection
and mailbox write. To test this I had to do a manual write to enable VBUSVALID
in the USB_UTMI_OTG_STATUS register.
omapconf set bit 0x48880084 1

USB2 port works well in host mode.

Patches are based on 3.15-rc3.

cheers,
-roger

Roger Quadros (7):
  ARM: dts: dra7-clock: Add "l3init_960m_gfclk" clock gate
  ARM: DRA7: hwmod: Add SYSCONFIG for usb_otg_ss
  phy: omap-usb2: Use generic clock names "wkupclk" and "refclk"
  ARM: dts: omap4+: Add clocks to USB2 PHY node
  phy: omap-usb2: Add clock names to Documentation binding
  ARM: dts: dra7: Add USB related nodes
  dts: dra7-evm: add USB support

 Documentation/devicetree/bindings/phy/ti-phy.txt |   7 ++
 arch/arm/boot/dts/dra7-evm.dts   |  24 
 arch/arm/boot/dts/dra7.dtsi  | 149 +++
 arch/arm/boot/dts/dra7xx-clocks.dtsi |  12 +-
 arch/arm/boot/dts/omap4.dtsi |   2 +
 arch/arm/boot/dts/omap5.dtsi |   2 +
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c|  22 ++--
 drivers/phy/phy-omap-usb2.c  |   8 +-
 8 files changed, 210 insertions(+), 16 deletions(-)

-- 
1.8.3.2

--
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 6/7] ARM: dts: dra7: Add USB related nodes

2014-04-28 Thread Roger Quadros
Add nodes for the Super Speed USB controllers, omap-control-usb,
USB2 PHY and USB3 PHY devices.

Remove ocp2scp1 address space from hwmod data as it is
now provided via device tree.

Signed-off-by: Roger Quadros 
---
 arch/arm/boot/dts/dra7.dtsi   | 149 ++
 arch/arm/mach-omap2/omap_hwmod_7xx_data.c |  10 --
 2 files changed, 149 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 149b550..4535e54 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -789,6 +789,155 @@
dma-names = "tx0", "rx0";
status = "disabled";
};
+
+   omap_control_usb2phy1: control-phy@4a002300 {
+   compatible = "ti,control-phy-usb2";
+   reg = <0x4a002300 0x4>;
+   reg-names = "power";
+   };
+
+   omap_control_usb3phy1: control-phy@4a002370 {
+   compatible = "ti,control-phy-pipe3";
+   reg = <0x4a002370 0x4>;
+   reg-names = "power";
+   };
+
+   omap_control_usb2phy2: control-phy@0x4a002e74 {
+   compatible = "ti,control-phy-usb2-dra7";
+   reg = <0x4a002e74 0x4>;
+   reg-names = "power";
+   };
+
+   /* OCP2SCP1 */
+   ocp2scp@4a08 {
+   compatible = "ti,omap-ocp2scp";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+   reg = <0x4a08 0x20>;
+   ti,hwmods = "ocp2scp1";
+
+   usb2_phy1: phy@4a084000 {
+   compatible = "ti,omap-usb2";
+   reg = <0x4a084000 0x400>;
+   ctrl-module = <&omap_control_usb2phy1>;
+   clocks = <&usb_phy1_always_on_clk32k>,
+<&usb_otg_ss1_refclk960m>;
+   clock-names =   "wkupclk",
+   "refclk";
+   #phy-cells = <0>;
+   };
+
+   usb2_phy2: phy@4a085000 {
+   compatible = "ti,omap-usb2";
+   reg = <0x4a085000 0x400>;
+   ctrl-module = <&omap_control_usb2phy2>;
+   clocks = <&usb_phy2_always_on_clk32k>,
+<&usb_otg_ss2_refclk960m>;
+   clock-names =   "wkupclk",
+   "refclk";
+   #phy-cells = <0>;
+   };
+
+   usb3_phy1: phy@4a084400 {
+   compatible = "ti,omap-usb3";
+   reg = <0x4a084400 0x80>,
+ <0x4a084800 0x64>,
+ <0x4a084c00 0x40>;
+   reg-names = "phy_rx", "phy_tx", "pll_ctrl";
+   ctrl-module = <&omap_control_usb3phy1>;
+   clocks = <&usb_phy3_always_on_clk32k>,
+<&sys_clkin1>,
+<&usb_otg_ss1_refclk960m>;
+   clock-names =   "wkupclk",
+   "sysclk",
+   "refclk";
+   #phy-cells = <0>;
+   };
+   };
+
+   omap_dwc3_1@4888 {
+   compatible = "ti,dwc3";
+   ti,hwmods = "usb_otg_ss1";
+   reg = <0x4888 0x1>;
+   interrupts = <0 77 4>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   utmi-mode = <2>;
+   ranges;
+   usb1: usb@4889 {
+   compatible = "snps,dwc3";
+   reg = <0x4889 0x17000>;
+   interrupts = <0 76 4>;
+   phys = <&usb2_phy1>, <&usb3_phy1>;
+   phy-names = "usb2-phy", "usb3-phy";
+   tx-fifo-resize;
+   maximum-speed = "super-speed";
+   dr_mode = "otg";
+   };
+   };
+
+   omap_dwc3_2@488c {
+   compatible = "ti,dwc3";
+   ti,hwmods = "usb_otg_ss2";
+   reg = <0x488c 0x1>;
+   interru

[PATCH v2 4/7] ARM: dts: omap4+: Add clocks to USB2 PHY node

2014-04-28 Thread Roger Quadros
The USB2 PHY driver expects named clocks for wakeup clock
and reference clock. Provide this information for USB2 PHY
nodes in OMAP4 and OMAP5 SoC DTS.

Signed-off-by: Roger Quadros 
---
 arch/arm/boot/dts/omap4.dtsi | 2 ++
 arch/arm/boot/dts/omap5.dtsi | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 649b5cd..f866de9 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -642,6 +642,8 @@
compatible = "ti,omap-usb2";
reg = <0x4a0ad080 0x58>;
ctrl-module = <&omap_control_usb2phy>;
+   clocks = <&usb_phy_cm_clk32k>;
+   clock-names = "wkupclk";
#phy-cells = <0>;
};
};
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index f8c9855..47b714c 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -803,6 +803,8 @@
compatible = "ti,omap-usb2";
reg = <0x4a084000 0x7c>;
ctrl-module = <&omap_control_usb2phy>;
+   clocks = <&usb_phy_cm_clk32k>, 
<&usb_otg_ss_refclk960m>;
+   clock-names = "wkupclk", "refclk";
#phy-cells = <0>;
};
 
-- 
1.8.3.2

--
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 3/7] phy: omap-usb2: Use generic clock names "wkupclk" and "refclk"

2014-04-28 Thread Roger Quadros
As clocks might be named differently on multiple platforms, use a generic
name in the driver and allow device tree node to specify the platform
specific clock name.

Signed-off-by: Roger Quadros 
---
 drivers/phy/phy-omap-usb2.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
index a2205a8..fb5e515 100644
--- a/drivers/phy/phy-omap-usb2.c
+++ b/drivers/phy/phy-omap-usb2.c
@@ -275,16 +275,16 @@ static int omap_usb2_probe(struct platform_device *pdev)
if (IS_ERR(phy_provider))
return PTR_ERR(phy_provider);
 
-   phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
+   phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");
if (IS_ERR(phy->wkupclk)) {
-   dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n");
+   dev_err(&pdev->dev, "unable to get wkupclk\n");
return PTR_ERR(phy->wkupclk);
}
clk_prepare(phy->wkupclk);
 
-   phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m");
+   phy->optclk = devm_clk_get(phy->dev, "refclk");
if (IS_ERR(phy->optclk))
-   dev_vdbg(&pdev->dev, "unable to get refclk960m\n");
+   dev_dbg(&pdev->dev, "unable to get refclk\n");
else
clk_prepare(phy->optclk);
 
-- 
1.8.3.2

--
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 v4 0/3] usb: chipidea: msm: Clean and fix glue layer driver

2014-04-28 Thread Ivan T. Ivanov
On Fri, 2014-04-25 at 03:10 +, Peter Chen wrote:
>  
> > 
> > On Thu, 2014-04-24 at 08:38 +0800, Peter Chen wrote:
> > > On Wed, Apr 23, 2014 at 03:28:01PM +0300, Ivan T. Ivanov wrote:
> > > > From: "Ivan T. Ivanov" 
> > > >
> > > > This series intend to fix driver, which was broken for a while.
> > > > It is used to create peripheral role device, which in coordination
> > > > with phy-usb-msm driver could provide USB2.0 gadget support for
> > > > Qualcomm targets.
> > > >
> > > > Changes since version 3.
> > > >
> > > >  - Fix typo in devicetree description file.
> > > >
> > > > Previews version can be found here:
> > >
> > > Since in your phy's patchset, you also access portsc which is in
> > > chipidea register region, it is not a standard way.
> > > In case, you will change something at chipidea driver in future when
> > > you re-work your next revision phy's patchset, I do not send this
> > > patchset to Greg right now.
> > >
> > 
> > Did you see problems with _this_ particular patch set? There is no direct
> > dependency between PHY patches and these changes.
> > 
>  
> I have not seen problems for this patch set, if you make sure the current
> phy operation (eg, "phy_type) at chipidea core does not affect you,
> I am glad to accept this.

You mean phy_mode? Peripheral functionality is tested on top of
current linus/master and it looks fine.

Regards,
Ivan

> 
> Peter
> NrybXǧv^)޺{.n+{zXܨ}Ơz&j:+vzZ++zfh~izw?&)ߢf^jǫym@Aa0hi


--
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: [RESEND PATCHv5] usb: dwc2: Add function to calculate correct FIFO sizes

2014-04-28 Thread Dinh Nguyen

On 4/14/14 4:11 PM, dingu...@altera.com wrote:
> From: Dinh Nguyen 
>
> The dwc2 IP on the SOCFPGA cannot use the default HW configured
> FIFO sizes. The total FIFO depth as read from GHWCFG3 reports 0x1f80 or 8064
> 32-bit words. But the GRXFSIZ, GNPTXFSIZ, and HPTXFSIZ register defaults
> to 0x2000 or 8192 32-bit words. So the driver cannot just use the fifo sizes
> as read from those registers.
>
> For platforms that face the same issue, this commits sets the RX, periodic TX,
> and non-periodic TX fifo size to those that are recommended v2.93a spec for
> the DWC2 IP. Implements Method #2 from the Synopsys v2.93a spec for the DWC2.
>
> Signed-off-by: Dinh Nguyen 
> Acked-by: Paul Zimmerman 
> Reviewed-by: Felipe Balbi 
> ---
> v5:
> - Fix build error around dev_err()
>
> v4:
> - Fix comment style errors
> - Use comment suggestion from Felipe to clearly commmunicate invalid fifo 
> sizes
> - Removed useless comment
>
> v3:
> - Address comments from Felipe
> - Used Method 2 as recommended by Synopsys to high-bandwidth endpoints.
>
> v2:
> - Fix coding style with braces around both if() branches
> ---
>  drivers/usb/dwc2/core.c |   68 
> +++
>  1 file changed, 68 insertions(+)
>
> diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
> index 1d12988..27d2c9b 100644
> --- a/drivers/usb/dwc2/core.c
> +++ b/drivers/usb/dwc2/core.c
> @@ -507,6 +507,72 @@ void dwc2_disable_host_interrupts(struct dwc2_hsotg 
> *hsotg)
>   writel(intmsk, hsotg->regs + GINTMSK);
>  }
>  
> +/*
> + * dwc2_calculate_dynamic_fifo() - Calculates the default fifo size
> + * For system that have a total fifo depth that is smaller than the default
> + * RX + TX fifo size.
> + *
> + * @hsotg: Programming view of DWC_otg controller
> + */
> +static void dwc2_calculate_dynamic_fifo(struct dwc2_hsotg *hsotg)
> +{
> + struct dwc2_core_params *params = hsotg->core_params;
> + struct dwc2_hw_params *hw = &hsotg->hw_params;
> + u32 rxfsiz, nptxfsiz, ptxfsiz, total_fifo_size;
> +
> + total_fifo_size = hw->total_fifo_size;
> + rxfsiz = params->host_rx_fifo_size;
> + nptxfsiz = params->host_nperio_tx_fifo_size;
> + ptxfsiz = params->host_perio_tx_fifo_size;
> +
> + /*
> +  * Will use Method 2 defined in the DWC2 spec: minimum FIFO depth
> +  * allocation with support for high bandwidth endpoints. Synopsys
> +  * defines MPS(Max Packet size) for a periodic EP=1024, and for
> +  * non-periodic as 512.
> +  */
> + if (total_fifo_size < (rxfsiz + nptxfsiz + ptxfsiz)) {
> + /*
> +  * For Buffer DMA mode/Scatter Gather DMA mode
> +  * 2 * ((Largest Packet size / 4) + 1 + 1) + n
> +  * with n = number of host channel.
> +  * 2 * ((1024/4) + 2) = 516
> +  */
> + rxfsiz = 516 + hw->host_channels;
> +
> + /*
> +  * min non-periodic tx fifo depth
> +  * 2 * (largest non-periodic USB packet used / 4)
> +  * 2 * (512/4) = 256
> +  */
> + nptxfsiz = 256;
> +
> + /*
> +  * min periodic tx fifo depth
> +  * (largest packet size*MC)/4
> +  * (1024 * 3)/4 = 768
> +  */
> + ptxfsiz = 768;
> +
> + params->host_rx_fifo_size = rxfsiz;
> + params->host_nperio_tx_fifo_size = nptxfsiz;
> + params->host_perio_tx_fifo_size = ptxfsiz;
> + }
> +
> + /*
> +  * If the summation of RX, NPTX and PTX fifo sizes is still
> +  * bigger than the total_fifo_size, then we have a problem.
> +  *
> +  * We won't be able to allocate as many endpoints. Right now,
> +  * we're just printing an error message, but ideally this FIFO
> +  * allocation algorithm would be improved in the future.
> +  *
> +  * FIXME improve this FIFO allocation algorithm.
> +  */
> + if (unlikely(total_fifo_size < (rxfsiz + nptxfsiz + ptxfsiz)))
> + dev_err(hsotg->dev, "invalid fifo sizes\n");
> +}
> +
>  static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
>  {
>   struct dwc2_core_params *params = hsotg->core_params;
> @@ -515,6 +581,8 @@ static void dwc2_config_fifos(struct dwc2_hsotg *hsotg)
>   if (!params->enable_dynamic_fifo)
>   return;
>  
> + dwc2_calculate_dynamic_fifo(hsotg);
> +
>   /* Rx FIFO */
>   grxfsiz = readl(hsotg->regs + GRXFSIZ);
>   dev_dbg(hsotg->dev, "initial grxfsiz=%08x\n", grxfsiz);
Hi Greg,

If you're ok with this patch, can you please apply this to usb-next?

Thanks,
Dinh
--
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] Nokia 5300 should be treated as unusual dev

2014-04-28 Thread Daniele Forsi
Signed-off-by: Daniele Forsi 
---
This patch depends on the patch sent by Victor A. Santos
 on April 27th with commit
message "Nokia 305 should be treated as unusual dev".

 drivers/usb/storage/unusual_devs.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/storage/unusual_devs.h 
b/drivers/usb/storage/unusual_devs.h
index 6eee0ce..174a447 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -234,6 +234,13 @@ UNUSUAL_DEV(  0x0421, 0x0495, 0x0370, 0x0370,
USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64 ),
 
+/* Reported by Daniele Forsi  */
+UNUSUAL_DEV(  0x0421, 0x04b9, 0x0350, 0x0350,
+   "Nokia",
+   "5300",
+   USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+   US_FL_MAX_SECTORS_64 ),
+
 /* Patch submitted by Victor A. Santos  */
 UNUSUAL_DEV(  0x0421, 0x05af, 0x0742, 0x0742,
"Nokia",
-- 
1.9.2

--
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: what code calls the gadget composite driver's setup method?

2014-04-28 Thread Alan Stern
On Sun, 27 Apr 2014, Larry Martin wrote:

> Alan is right, the code I wanted is in gadget/omap_udc.c.  How/where is 
> that code linked?
> 
> I put in some printks and do not get the output.  My new printk strings 
> are not in g_printer.ko, but other strings from composite.c and 
> printer.c are there.  Grep does not hit "omap-udc" in my kernel, so I 
> don't think it's compiled in.  But my new printk strings are not in any 
> gadget folder .ko.  I looked at other things too but hopefully that 
> makes my case.
> 
> Can someone who knows this code tell me how to get my changes to 
> omap-udc.c into an executable?  A pointer to a document would be great.

This depends on your kernel configuration.  See which drivers are 
enabled in the "USB Peripheral Controller" section of your .config 
file, and whether or not they are configured as modules.

It's possible that some of the modules you want to change get loaded 
from an initramfs image during booting.

Alan Stern

--
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 2/2] usb: common: rename phy-fsm-usb.c to usb-otg-fsm.c

2014-04-28 Thread Alan Stern
On Mon, 28 Apr 2014, Peter Chen wrote:

> Since usb otg fsm implementation is not related to usb phy.
> We move it from usb/phy/ to usb/common/, and rename it to
> reflect its real meaning.
> 
> Signed-off-by: Peter Chen 
> ---
>  drivers/usb/common/Makefile|1 +
>  .../{phy/phy-fsm-usb.c => common/usb-otg-fsm.c}|0
>  drivers/usb/core/Kconfig   |9 +
>  drivers/usb/phy/Kconfig|9 -
>  drivers/usb/phy/Makefile   |1 -
>  5 files changed, 10 insertions(+), 10 deletions(-)
>  rename drivers/usb/{phy/phy-fsm-usb.c => common/usb-otg-fsm.c} (100%)
> 
> diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
> index 9b320d1..7526461 100644
> --- a/drivers/usb/common/Makefile
> +++ b/drivers/usb/common/Makefile
> @@ -3,3 +3,4 @@
>  #
>  
>  obj-$(CONFIG_USB_COMMON) += usb-common.o
> +obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
> diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/common/usb-otg-fsm.c
> similarity index 100%
> rename from drivers/usb/phy/phy-fsm-usb.c
> rename to drivers/usb/common/usb-otg-fsm.c
> diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
> index 9519878..8d18eba 100644
> --- a/drivers/usb/core/Kconfig
> +++ b/drivers/usb/core/Kconfig
> @@ -81,3 +81,12 @@ config USB_OTG_BLACKLIST_HUB
> and software costs by not supporting external hubs.  So
> are "Embedded Hosts" that don't offer OTG support.
>  
> +config USB_OTG_FSM
> + tristate "USB 2.0 OTG FSM implementation"
> + depends on USB
> + select USB_OTG
> + select USB_PHY
> + help
> +   Implements OTG Final State Machine as specified in On-The-Go

Minor error you might want to fix at this time:  s/Final/Finite/

Alan Stern

--
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: remove redundant D0 power state set

2014-04-28 Thread Alan Stern
On Mon, 28 Apr 2014, Yijing Wang wrote:

> Pci_enable_device() will set device power state to D0,
> so it's no need to do it again after call pci_enable_device().
> 
> Signed-off-by: Yijing Wang 
> ---
>  drivers/usb/core/hcd-pci.c |1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
> index 1f02e65..82044b5 100644
> --- a/drivers/usb/core/hcd-pci.c
> +++ b/drivers/usb/core/hcd-pci.c
> @@ -192,7 +192,6 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct 
> pci_device_id *id)
>  
>   if (pci_enable_device(dev) < 0)
>   return -ENODEV;
> - dev->current_state = PCI_D0;
>  
>   /*
>* The xHCI driver has its own irq management

Acked-by: Alan Stern 

--
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: /sys/bus/usb/devices

2014-04-28 Thread Alan Stern
On Mon, 28 Apr 2014, Mathias Nyman wrote:

> 
> 
> On 04/27/2014 11:11 AM, John Freed wrote:
> > I hope you don't mind me writing you directly, and if someone else can
> > handle this better please let me know.
> >
> > I'm trying to do some backend work on libusb and I notice that the
> > kernel keeps all the information on the Device Descriptors except for
> > the value of the Serial Number string.
> >
> > (Well, almost all. Oddly, the "manufacturer" string is not included for
> > hubs from Intel! I presume that's because they're really PCI devices and
> > there is some black magic going on in the background to fill in the USB
> > device descriptor.)

Tha "manufacturer" file is cached in the kernel if the device has one.  
If it doesn't show up for your Intel hubs, it must be because the hubs 
don't have a manufacturer string descriptor.

Alan Stern

--
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 3/4] usb: ohci-exynos: Add facility to use phy provided by the generic phy framework

2014-04-28 Thread Alan Stern
On Mon, 28 Apr 2014, Vivek Gautam wrote:

> Add support to consume phy provided by Generic phy framework.
> Keeping the support for older usb-phy intact right now, in order
> to prevent any functionality break in absence of relevant
> device tree side change for ohci-exynos.
> Once we move to new phy in the device nodes for ohci, we can
> remove the support for older phys.
> 
> Signed-off-by: Vivek Gautam 
> Cc: Jingoo Han 
> Cc: Alan Stern 
> ---

> +static int exynos_ohci_phy_enable(struct device *dev)
>  {
>   struct usb_hcd *hcd = dev_get_drvdata(dev);
>   struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
> + int i;
> + int ret = 0;
>  
> - if (exynos_ohci->phy)
> - usb_phy_init(exynos_ohci->phy);
> + if (exynos_ohci->phy) {
> + ret = usb_phy_init(exynos_ohci->phy);
> + if (ret)
> + return ret;
> + }
> +
> + for (i = 0; ret == 0 && i < PHY_NUMBER; i++)
> + if (exynos_ohci->phy_g[i])
> + ret = phy_power_on(exynos_ohci->phy_g[i]);
> + if (ret)
> + for (i--; i >= 0; i--)
> + if (exynos_ohci->phy_g[i])
> + phy_power_off(exynos_ohci->phy_g[i]);

Do you want to call usb_phy_shutdown() at this point?

> +
> + return ret;
>  }
>  
> -static void exynos_ohci_phy_disable(struct device *dev)
> +static int exynos_ohci_phy_disable(struct device *dev)
>  {
>   struct usb_hcd *hcd = dev_get_drvdata(dev);
>   struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
> + int i;
> + int ret = 0;
>  
>   if (exynos_ohci->phy)
>   usb_phy_shutdown(exynos_ohci->phy);
> +
> + for (i = 0; i < PHY_NUMBER; i++)
> + if (exynos_ohci->phy_g[i])
> + ret = phy_power_off(exynos_ohci->phy_g[i]);
> +
> + return ret;
>  }

This return value is practically meaningless.  It is the status from 
the last PHY only; any errors involving the other PHYs have been lost.

You may as well make this function return void.

> @@ -210,13 +302,18 @@ static int exynos_ohci_resume(struct device *dev)
>  {
>   struct usb_hcd *hcd = dev_get_drvdata(dev);
>   struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd);
> + int ret;
>  
>   clk_prepare_enable(exynos_ohci->clk);
>  
>   if (exynos_ohci->otg)
>   exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self);
>  
> - exynos_ohci_phy_enable(dev);
> + ret = exynos_ohci_phy_enable(dev);
> + if (ret) {
> + dev_err(dev, "Failed to enable USB phy\n");

Do you want to call clk_disable_unprepare() here?

> + return ret;
> + }
>  
>   ohci_resume(hcd, false);

Alan Stern

--
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: problem with resume after s2ram

2014-04-28 Thread Alan Stern
On Sat, 26 Apr 2014, Peter Münster wrote:

> On Tue, Apr 22 2014, Alan Stern wrote:
> 
> > Here's diag5; it's essentially a subset of diag4.  Test it in the same
> > way.
> >
> > (Not being able to wake up the system from the keyboard is expected
> > for diag4.  With diag5, you may or may not be able to use the keyboard
> > for wakeup -- try it and see.  It's even possible that the system will 
> > crash if you use the keyboard but not if you use the power button!)
> 
> Hi Alan,
> 
> I can wakeup with the keyboard and there is no crash. Please find
> attached the log. There are 2 s2ram-wakeup cycles: the first wakeup is
> with the power-button, the second with the keyboard.

That's interesting.  Here's another test you should try with that same
kernel.  Start moving the mouse before you wake up the system, and keep
moving it until the system has fully resumed.  When you do this, does
it work right?  That is, when the screen turns back on, do you see the
mouse cursor moving around?

Below is the next patch in the series, diag6.  This adds back more 
material that was removeed in diag5.  My guess is that this one will 
cause your system to crash during resume.

Alan Stern



Index: peter/drivers/usb/core/hub.c
===
--- peter.orig/drivers/usb/core/hub.c
+++ peter/drivers/usb/core/hub.c
@@ -2981,7 +2981,7 @@ int usb_port_suspend(struct usb_device *
 * Therefore we will turn on the suspend feature if udev or any of its
 * descendants is enabled for remote wakeup.
 */
-   else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0)
+   else if (0)
status = set_port_feature(hub->hdev, port1,
USB_PORT_FEAT_SUSPEND);
else {
@@ -3107,38 +3107,6 @@ static int finish_port_resume(struct usb
if (status) {
dev_dbg(&udev->dev, "gone after usb resume? status %d\n",
status);
-   /*
-* There are a few quirky devices which violate the standard
-* by claiming to have remote wakeup enabled after a reset,
-* which crash if the feature is cleared, hence check for
-* udev->reset_resume
-*/
-   } else if (udev->actconfig && !udev->reset_resume) {
-   if (!hub_is_superspeed(udev->parent)) {
-   le16_to_cpus(&devstatus);
-   if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP))
-   status = usb_control_msg(udev,
-   usb_sndctrlpipe(udev, 0),
-   USB_REQ_CLEAR_FEATURE,
-   USB_RECIP_DEVICE,
-   USB_DEVICE_REMOTE_WAKEUP, 0,
-   NULL, 0,
-   USB_CTRL_SET_TIMEOUT);
-   } else {
-   status = usb_get_status(udev, USB_RECIP_INTERFACE, 0,
-   &devstatus);
-   le16_to_cpus(&devstatus);
-   if (!status && devstatus & (USB_INTRF_STAT_FUNC_RW_CAP
-   | USB_INTRF_STAT_FUNC_RW))
-   status =
-   usb_disable_function_remotewakeup(udev);
-   }
-
-   if (status)
-   dev_dbg(&udev->dev,
-   "disable remote wakeup, status %d\n",
-   status);
-   status = 0;
}
return status;
 }

--
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: dwc3: debugfs: add snapshot to dump requests trbs events

2014-04-28 Thread Felipe Balbi
On Mon, Apr 28, 2014 at 04:49:23PM -0400, Zhuang Jin Can wrote:
> Adds a debugfs file "snapshot" to dump dwc3 requests, trbs and events.

you need to explain what are you trying to provide to our users here.

What "problem" are you trying to solve ?

> As ep0 requests are more complex than others. It's not included in this
> patch.

For ep0, you could at least print the endpoint phase we are currently
in and if we have requests in flight or not.

> Signed-off-by: Zhuang Jin Can 
> ---
>  drivers/usb/dwc3/core.h|4 +
>  drivers/usb/dwc3/debugfs.c |  192 
> 
>  drivers/usb/dwc3/gadget.h  |   41 ++
>  3 files changed, 237 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 57332e3..9d04ddd 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -849,6 +849,10 @@ struct dwc3_event_devt {
>   u32 type:4;
>   u32 reserved15_12:4;
>   u32 event_info:9;
> +
> +#define DEVT_EVTINFO_SUPERSPEED  (1 << 4)
> +#define DEVT_EVTINFO_HIRD(n) (((n) & (0xf << 5)) >> 5)
> +
>   u32 reserved31_25:7;
>  } __packed;
>  
> diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
> index 9ac37fe..078d147 100644
> --- a/drivers/usb/dwc3/debugfs.c
> +++ b/drivers/usb/dwc3/debugfs.c
> @@ -618,6 +618,191 @@ static const struct file_operations 
> dwc3_link_state_fops = {
>   .release= single_release,
>  };
>  
> +static void dwc3_dump_requests(struct seq_file *s, struct list_head *head,
> + const char *list_name)
> +{
> + struct dwc3_request *req;
> +
> + if (list_empty(head)) {
> + seq_printf(s, "list %s is empty\n", list_name);
> + return;
> + }
> +
> + seq_printf(s, "list %s:\n", list_name);
> + list_for_each_entry(req, head, list) {
> + struct usb_request *request = &req->request;
> +
> + seq_printf(s, "usb_request@0x%p: buf@0x%p(dma@0x%pad), 
> len=%d\n",
> + request, request->buf, &request->dma,
> + request->length);
> +
> + if (req->queued)
> + seq_printf(s, "\tstatus=%d: actual=%d; start_slot=%u: 
> trb@0x%p(dma@0x%pad)\n",
> + request->status, request->actual,
> + req->start_slot, req->trb,
> + &req->trb_dma);
> + }
> +}
> +
> +static void dwc3_dump_trbs(struct seq_file *s, struct dwc3_ep *dep)
> +{
> + struct dwc3_trb *trb;
> + int i;
> +
> + seq_printf(s, "busy_slot = %u, free_slot = %u\n",
> + dep->busy_slot & DWC3_TRB_MASK,
> + dep->free_slot & DWC3_TRB_MASK);
> +
> + for (i = 0; i < DWC3_TRB_NUM; i++) {
> + trb = &dep->trb_pool[i];
> + if (i == (dep->busy_slot & DWC3_TRB_MASK)) {

I really dislike these Yoda Conditionals. Fix this up.

> + seq_puts(s, "busy_slot--|\n");
> + seq_puts(s, "   \\\n");
> + }
> + if (i == (dep->free_slot & DWC3_TRB_MASK)) {
> + seq_puts(s, "free_slot--|\n");
> + seq_puts(s, "   \\\n");
> + }
> + seq_printf(s, "trb[%02d](dma@0x%pad): %08x(bpl), %08x(bph), 
> %08x(size), %08x(ctrl)\n",

I'm not sure you need to print out the TRB address. bpl, bph, size and
ctrl are desired though.

> + i, &dep->trb_pool_dma + i * sizeof(*trb),
> + trb->bpl, trb->bph, trb->size, trb->ctrl);

this will be pretty difficult to parse by a human. I would rather see
you creating one directory per TRB (and also one directory per
endpoint) which holds the details for that entity, so that it looks
like:

dwc3
|-- current_state   (or perhaps a better name, but snapshot isn't very good 
either)
|-- ep2
|   |-- direction
|   |-- maxpacket
|   |-- number
|   |-- state
|   |-- stream_capable
|   |-- type
|   |-- trbs
|   |   |-- trb0
|   |   |   |-- bph
|   |   |   |-- bpl
|   |   |   |-- ctrl
|   |   |   |-- size
|   |   |-- trb1
|   |   |   |-- bph
|   |   |   |-- bpl
|   |   |   |-- ctrl
|   |   |   |-- size
|   |   |-- trb2
|   |   |   |-- bph
|   |   |   |-- bpl
|   |   |   |-- ctrl
|   |   |   |-- size
|   |   |-- trb3
|   |   |   |-- bph
|   |   |   |-- bpl
|   |   |   |-- ctrl
|   |   |   |-- size
.   .   .
.   .   .
.   .   .
|   |-- request0
|   |   |-- direction
|   |   |-- mapped
|   |   |-- queued
|   |   |-- trb0(symlink to actual trb directory)
|   |   |-- ep2 (symlink to actual ep2 directory)
|   |   |-- usbrequest
|   |   |-- actual
|   |   |-- length
|   |   |-- no_interrupt
|   |   |-- num_

[PATCH] fsl-usb: do not test for PHY_CLK_VALID bit on controller version 1.6

2014-04-28 Thread Nikita Yushchenko
Per reference manuals of Freescale P1020 and P2020 SoCs, USB controller
present in these SoCs has bit 17 of USBx_CONTROL register marked as
Reserved - there is no PHY_CLK_VALID bit there.

Testing for this bit in ehci_fsl_setup_phy() behaves differently on two
P1020RDB boards available here - on one board test passes and fsl-usb
init succeeds, but on other board test fails, causing fsl-usb init to
fail.

This patch changes ehci_fsl_setup_phy() not to test PHY_CLK_VALID on
controller version 1.6 that (per manual) does not have this bit.

Signed-off-by: Nikita Yushchenko 
---
 drivers/usb/host/ehci-fsl.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 6f2c8d3..cf2734b 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -248,7 +248,8 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
break;
}
 
-   if (pdata->have_sysif_regs && pdata->controller_ver &&
+   if (pdata->have_sysif_regs &&
+   pdata->controller_ver > FSL_USB_VER_1_6 &&
(phy_mode == FSL_USB2_PHY_ULPI)) {
/* check PHY_CLK_VALID to get phy clk valid */
if (!(spin_event_timeout(in_be32(non_ehci + FSL_SOC_USB_CTRL) &
-- 
1.7.10.4

--
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 4/7] ARM: dts: omap4+: Add clocks to USB2 PHY node

2014-04-28 Thread Felipe Balbi
On Mon, Apr 28, 2014 at 05:01:24PM +0300, Roger Quadros wrote:
> The USB2 PHY driver expects named clocks for wakeup clock
> and reference clock. Provide this information for USB2 PHY
> nodes in OMAP4 and OMAP5 SoC DTS.
> 
> Signed-off-by: Roger Quadros 

Reviewed-by: Felipe Balbi 

> ---
>  arch/arm/boot/dts/omap4.dtsi | 2 ++
>  arch/arm/boot/dts/omap5.dtsi | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
> index 649b5cd..f866de9 100644
> --- a/arch/arm/boot/dts/omap4.dtsi
> +++ b/arch/arm/boot/dts/omap4.dtsi
> @@ -642,6 +642,8 @@
>   compatible = "ti,omap-usb2";
>   reg = <0x4a0ad080 0x58>;
>   ctrl-module = <&omap_control_usb2phy>;
> + clocks = <&usb_phy_cm_clk32k>;
> + clock-names = "wkupclk";
>   #phy-cells = <0>;
>   };
>   };
> diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
> index f8c9855..47b714c 100644
> --- a/arch/arm/boot/dts/omap5.dtsi
> +++ b/arch/arm/boot/dts/omap5.dtsi
> @@ -803,6 +803,8 @@
>   compatible = "ti,omap-usb2";
>   reg = <0x4a084000 0x7c>;
>   ctrl-module = <&omap_control_usb2phy>;
> + clocks = <&usb_phy_cm_clk32k>, 
> <&usb_otg_ss_refclk960m>;
> + clock-names = "wkupclk", "refclk";
>   #phy-cells = <0>;
>   };
>  
> -- 
> 1.8.3.2
> 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2 3/7] phy: omap-usb2: Use generic clock names "wkupclk" and "refclk"

2014-04-28 Thread Felipe Balbi
Hi,

On Mon, Apr 28, 2014 at 05:01:23PM +0300, Roger Quadros wrote:
> As clocks might be named differently on multiple platforms, use a generic
> name in the driver and allow device tree node to specify the platform
> specific clock name.
> 
> Signed-off-by: Roger Quadros 
> ---
>  drivers/phy/phy-omap-usb2.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c
> index a2205a8..fb5e515 100644
> --- a/drivers/phy/phy-omap-usb2.c
> +++ b/drivers/phy/phy-omap-usb2.c
> @@ -275,16 +275,16 @@ static int omap_usb2_probe(struct platform_device *pdev)
>   if (IS_ERR(phy_provider))
>   return PTR_ERR(phy_provider);
>  
> - phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
> + phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");

doesn't this patch cause a regression ? I mean, you're changing the
clock name before fixing DTS. Also, that DTS has been in a major version
of the kernel, so we need to maintain compatibility with it. How about:

phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");
if (IS_ERR(phy->wkupclk)) {
dev_err(&pdev->dev, "unable to get wkupclk, trying old name\n");
phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
if (IS_ERR(phy->wkupclk)) {
dev_err(&pdev->dev, "unable to get 
usb_phy_cm_clk32k\n");
return PTR_ERR(phy->wkupclk);
} else {
dev_warn(&pdev->dev, "found usb_phy_cm_clk32k, please 
fix your DTS\n");
}
}

a bit ugly, but at least we don't cause any regressions. Likewise for
other clocks.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2 5/7] phy: omap-usb2: Add clock names to Documentation binding

2014-04-28 Thread Felipe Balbi
On Mon, Apr 28, 2014 at 05:01:25PM +0300, Roger Quadros wrote:
> Add "wkupclk" and "refclk" information to DT binding information.
> 
> Signed-off-by: Roger Quadros 

Reviewed-by: Felipe Balbi 

> ---
>  Documentation/devicetree/bindings/phy/ti-phy.txt | 7 +++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt 
> b/Documentation/devicetree/bindings/phy/ti-phy.txt
> index 788fb0f..9ce458f 100644
> --- a/Documentation/devicetree/bindings/phy/ti-phy.txt
> +++ b/Documentation/devicetree/bindings/phy/ti-phy.txt
> @@ -32,6 +32,11 @@ Required properties:
>   - reg : Address and length of the register set for the device.
>   - #phy-cells: determine the number of cells that should be given in the
> phandle while referencing this phy.
> + - clocks: a list of phandles and clock-specifier pairs, one for each entry 
> in
> +   clock-names.
> + - clock-names: should include:
> +   * "wkupclk" - wakeup clock.
> +   * "refclk" - reference clock (optional).
>  
>  Optional properties:
>   - ctrl-module : phandle of the control module used by PHY driver to power on
> @@ -44,6 +49,8 @@ usb2phy@4a0ad080 {
>   reg = <0x4a0ad080 0x58>;
>   ctrl-module = <&omap_control_usb>;
>   #phy-cells = <0>;
> + clocks = <&usb_phy_cm_clk32k>, <&usb_otg_ss_refclk960m>;
> + clock-names = "wkupclk", "refclk";
>  };
>  
>  TI PIPE3 PHY
> -- 
> 1.8.3.2
> 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2 6/7] ARM: dts: dra7: Add USB related nodes

2014-04-28 Thread Felipe Balbi
On Mon, Apr 28, 2014 at 05:01:26PM +0300, Roger Quadros wrote:
> Add nodes for the Super Speed USB controllers, omap-control-usb,
> USB2 PHY and USB3 PHY devices.
> 
> Remove ocp2scp1 address space from hwmod data as it is
> now provided via device tree.
> 
> Signed-off-by: Roger Quadros 

Reviewed-by: Felipe Balbi 

> ---
>  arch/arm/boot/dts/dra7.dtsi   | 149 
> ++
>  arch/arm/mach-omap2/omap_hwmod_7xx_data.c |  10 --
>  2 files changed, 149 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
> index 149b550..4535e54 100644
> --- a/arch/arm/boot/dts/dra7.dtsi
> +++ b/arch/arm/boot/dts/dra7.dtsi
> @@ -789,6 +789,155 @@
>   dma-names = "tx0", "rx0";
>   status = "disabled";
>   };
> +
> + omap_control_usb2phy1: control-phy@4a002300 {
> + compatible = "ti,control-phy-usb2";
> + reg = <0x4a002300 0x4>;
> + reg-names = "power";
> + };
> +
> + omap_control_usb3phy1: control-phy@4a002370 {
> + compatible = "ti,control-phy-pipe3";
> + reg = <0x4a002370 0x4>;
> + reg-names = "power";
> + };
> +
> + omap_control_usb2phy2: control-phy@0x4a002e74 {
> + compatible = "ti,control-phy-usb2-dra7";
> + reg = <0x4a002e74 0x4>;
> + reg-names = "power";
> + };
> +
> + /* OCP2SCP1 */
> + ocp2scp@4a08 {
> + compatible = "ti,omap-ocp2scp";
> + #address-cells = <1>;
> + #size-cells = <1>;
> + ranges;
> + reg = <0x4a08 0x20>;
> + ti,hwmods = "ocp2scp1";
> +
> + usb2_phy1: phy@4a084000 {
> + compatible = "ti,omap-usb2";
> + reg = <0x4a084000 0x400>;
> + ctrl-module = <&omap_control_usb2phy1>;
> + clocks = <&usb_phy1_always_on_clk32k>,
> +  <&usb_otg_ss1_refclk960m>;
> + clock-names =   "wkupclk",
> + "refclk";
> + #phy-cells = <0>;
> + };
> +
> + usb2_phy2: phy@4a085000 {
> + compatible = "ti,omap-usb2";
> + reg = <0x4a085000 0x400>;
> + ctrl-module = <&omap_control_usb2phy2>;
> + clocks = <&usb_phy2_always_on_clk32k>,
> +  <&usb_otg_ss2_refclk960m>;
> + clock-names =   "wkupclk",
> + "refclk";
> + #phy-cells = <0>;
> + };
> +
> + usb3_phy1: phy@4a084400 {
> + compatible = "ti,omap-usb3";
> + reg = <0x4a084400 0x80>,
> +   <0x4a084800 0x64>,
> +   <0x4a084c00 0x40>;
> + reg-names = "phy_rx", "phy_tx", "pll_ctrl";
> + ctrl-module = <&omap_control_usb3phy1>;
> + clocks = <&usb_phy3_always_on_clk32k>,
> +  <&sys_clkin1>,
> +  <&usb_otg_ss1_refclk960m>;
> + clock-names =   "wkupclk",
> + "sysclk",
> + "refclk";
> + #phy-cells = <0>;
> + };
> + };
> +
> + omap_dwc3_1@4888 {
> + compatible = "ti,dwc3";
> + ti,hwmods = "usb_otg_ss1";
> + reg = <0x4888 0x1>;
> + interrupts = <0 77 4>;
> + #address-cells = <1>;
> + #size-cells = <1>;
> + utmi-mode = <2>;
> + ranges;
> + usb1: usb@4889 {
> + compatible = "snps,dwc3";
> + reg = <0x4889 0x17000>;
> + interrupts = <0 76 4>;
> + phys = <&usb2_phy1>, <&usb3_phy1>;
> + phy-names = "usb2-phy", "usb3-phy";
> + tx-fifo-resize;
> + maximum-speed = "super-speed";
> + dr_mode = "otg";
> + };
> + };
> +
> + omap_dwc3_2@488c {
> + compatible 

Re: [PATCH 2/2] usb: common: rename phy-fsm-usb.c to usb-otg-fsm.c

2014-04-28 Thread Felipe Balbi
On Mon, Apr 28, 2014 at 04:29:24PM +0800, Peter Chen wrote:
> Since usb otg fsm implementation is not related to usb phy.
> We move it from usb/phy/ to usb/common/, and rename it to
> reflect its real meaning.
> 
> Signed-off-by: Peter Chen 
> ---
>  drivers/usb/common/Makefile|1 +
>  .../{phy/phy-fsm-usb.c => common/usb-otg-fsm.c}|0
>  drivers/usb/core/Kconfig   |9 +
>  drivers/usb/phy/Kconfig|9 -
>  drivers/usb/phy/Makefile   |1 -
>  5 files changed, 10 insertions(+), 10 deletions(-)
>  rename drivers/usb/{phy/phy-fsm-usb.c => common/usb-otg-fsm.c} (100%)
> 
> diff --git a/drivers/usb/common/Makefile b/drivers/usb/common/Makefile
> index 9b320d1..7526461 100644
> --- a/drivers/usb/common/Makefile
> +++ b/drivers/usb/common/Makefile
> @@ -3,3 +3,4 @@
>  #
>  
>  obj-$(CONFIG_USB_COMMON) += usb-common.o
> +obj-$(CONFIG_USB_OTG_FSM) += usb-otg-fsm.o
> diff --git a/drivers/usb/phy/phy-fsm-usb.c b/drivers/usb/common/usb-otg-fsm.c
> similarity index 100%
> rename from drivers/usb/phy/phy-fsm-usb.c
> rename to drivers/usb/common/usb-otg-fsm.c

as I said before, you probably want to drop the dependency on the PHY
layer, perhaps that can be done as follow up patches...

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2 7/7] dts: dra7-evm: add USB support

2014-04-28 Thread Felipe Balbi
On Mon, Apr 28, 2014 at 05:01:27PM +0300, Roger Quadros wrote:
> Add USB pinmux information and USB modes
> for the USB controllers.
> 
> Signed-off-by: Roger Quadros 

Reviewed-by: Felipe Balbi 

> ---
>  arch/arm/boot/dts/dra7-evm.dts | 24 
>  1 file changed, 24 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
> index 5babba0..1d77815 100644
> --- a/arch/arm/boot/dts/dra7-evm.dts
> +++ b/arch/arm/boot/dts/dra7-evm.dts
> @@ -93,6 +93,18 @@
>   0x24c (PIN_INPUT_SLEW | MUX_MODE0) /* uart3_txd */
>   >;
>   };
> +
> + usb1_pins: pinmux_usb1_pins {
> +pinctrl-single,pins = <
> + 0x280   0xc /* usb1_drvvbus, SLOW_SLEW | PULLUPEN | 
> MODE0 */
> +>;
> +};
> +
> + usb2_pins: pinmux_usb2_pins {
> +pinctrl-single,pins = <
> + 0x284   0xc /* usb2_drvvbus, SLOW_SLEW | PULLUPEN | 
> MODE0 */
> +>;
> +};
>  };
>  
>  &i2c1 {
> @@ -273,3 +285,15 @@
>  &cpu0 {
>   cpu0-supply = <&smps123_reg>;
>  };
> +
> +&usb1 {
> + dr_mode = "peripheral";
> + pinctrl-names = "default";
> + pinctrl-0 = <&usb1_pins>;
> +};
> +
> +&usb2 {
> + dr_mode = "host";
> + pinctrl-names = "default";
> + pinctrl-0 = <&usb2_pins>;
> +};
> -- 
> 1.8.3.2
> 

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] staging: octeon-usb: prevent memory corruption

2014-04-28 Thread Sergey Popov
24.03.2014 01:18, Aaro Koskinen пишет:
> Hi,
> 
> On Sat, Mar 22, 2014 at 01:13:52PM +0400, Sergey Popov wrote:
>> scsi 0:0:0:0: Direct-Access SanDisk  Cruzer Facet 1.26 PQ: 0 ANSI: 5
>> sd 0:0:0:0: [sda] 15633408 512-byte logical blocks: (8.00 GB/7.45 GiB)
>> usb 1-1: reset high-speed USB device number 2 using OcteonUSB
>> usb 1-1: reset high-speed USB device number 2 using OcteonUSB
>> usb 1-1: device descriptor read/64, error -145
> 
> Can you boot with PRINTK_TIME and USB_STORAGE_DEBUG enabled and send
> the logs?
> 
> A.
> 

Hi again. I am very sorry, your email someway lost, probably due to
misconfiguration of my MUA.

I have attached new boot log, kernel(now - 3.15_rc2) is configured with
PRINTK_TIME and USB_STORAGE_DEBUG as you requested.


-- 
Best regards, Sergey Popov
Gentoo developer
Gentoo Desktop-effects project lead
Gentoo Qt project lead
Gentoo Proxy maintainers project lead
U-Boot 1.1.1 (UBNT Build ID: 4493936-g009d77b) (Build time: Sep 20 2012 - 
15:48:51)

BIST check passed.
UBNT_E100 r1:2, r2:12, serial #: DC9FDB29E401
Core clock: 500 MHz, DDR clock: 266 MHz (532 Mhz data rate)
DRAM:  512 MB
Clearing DRAM... done
Flash:  4 MB
Net:   octeth0, octeth1, octeth2

USB:   (port 0) scanning bus for devices... 1 USB Devices found
   scanning bus for storage devices...
  Device 0: Vendor: SanDisk  Prod.: Cruzer Facet Rev: 1.26
Type: Removable Hard Disk
Capacity: 7633.5 MB = 7.4 GB (15633408 x 512)
 0 
reading vmlinux.64

...
.

..

10988919 bytes read
argv[2]: coremask=0x3
argv[3]: root=/dev/sda2
argv[4]: rootdelay=15
argv[5]: rw
argv[6]: mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@3072k(eeprom)
argv[7]: net.ifnames=0
argv[8]: console=ttyS0,115200
argv[9]: panic=5
ELF file is 64 bit
Allocating memory for ELF segment: addr: 0x8110 (adjusted to: 
0x110), size 0x8382c0
Allocated memory for ELF segment: addr: 0x8110, size 0x8382c0
Processing PHDR 0
  Loading 7fdf00 bytes at 8110
  Clearing 3a3c0 bytes at 818fdf00
## Loading Linux kernel with entry point: 0x816d7b10 ...
Bootloader: Done loading app on coremask: 0x3
[0.00] Initializing cgroup subsys cpuset
[0.00] Initializing cgroup subsys cpu
[0.00] Initializing cgroup subsys cpuacct
[0.00] Linux version 3.15.0-rc2 (neko@phantom) (gcc version 4.8.2 
(Gentoo 4.8.2 p1.3r1, pie-0.5.8r1) ) #1 SMP Mon Apr 28 20:04:08 MSK 2014
[0.00] CVMSEG size: 2 cache lines (256 bytes)
[0.00] bootconsole [early0] enabled
[0.00] CPU0 revision is: 000d0601 (Cavium Octeon+)
[0.00] Checking for the multiply/shift bug... no.
[0.00] Checking for the daddiu bug... no.
[0.00] Determined physical RAM map:
[0.00]  memory: 0640 @ 01a0 (usable)
[0.00]  memory: 07c0 @ 0820 (usable)
[0.00]  memory: 0fc0 @ 00041000 (usable)
[0.00]  memory: 008382c0 @ 0110 (usable)
[0.00] Wasting 243712 bytes for tracking 4352 unused pages
[0.00] Initrd not found or empty - disabling initrd
[0.00] Using internal Device Tree.
[0.00] software IO TLB [mem 0x0218f000-0x0618f000] (64MB) mapped at 
[8218f000-8618efff]
[0.00] Zone ranges:
[0.00]   DMA32[mem 0x0110-0xefff]
[0.00]   Normal   [mem 0xf000-0x41fbf]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x0110-0x01937fff]
[0.00]   node   0: [mem 0x01a0-0x07df]
[0.00]   node   0: [mem 0x0820-0x0fdf]
[0.00]   node   0: [mem 0x41000-0x41fbf]
[0.00] Primary instruction cache 32kB, virtually tagged, 4 way, 64 
sets, linesize 128 bytes.
[0.00] Primary data cache 16kB, 64-way, 2 sets, linesize 128 bytes.
[0.00] PERCPU: Embedded 10 pages/cpu @8622a000 s12032 r8192 
d20736 u40960
[0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total 
pages: 122265
[0.00] Kernel command line:  bootoctlinux $loadaddr coremask=0x3 
root=/dev/sda2 rootdelay=15 rw 
mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@3072k(eeprom5
[0.00] PID hash table entries: 2048 (order: 2, 16384 bytes)
[0.00] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes)
[0.00] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes)
[0.00] Memory: 413184K/495840K available (6029K kernel code, 530K 
rwdata, 1332K rodata, 272K init, 224K bss, 82656K reserved)
[0.00] Hierarchical RCU implementation.
[0.00]  RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[0.00] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[0.00] NR_IRQS:512
[7.553957] allocated 2097152 bytes of page_cgroup
[

Re: [PATCH v8 02/20] usb: phy: msm: Remove __init macro from driver probe method

2014-04-28 Thread Ivan T. Ivanov
On Mon, 2014-04-28 at 12:03 -0500, Felipe Balbi wrote:
> On Mon, Apr 28, 2014 at 09:00:43PM +0400, Sergei Shtylyov wrote:
> > Hello.
> > 
> > On 04/28/2014 05:34 PM, Ivan T. Ivanov wrote:
> > 
> > >From: "Ivan T. Ivanov" 
> > 
> > >This fixes following:
> > 
> > >WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in 
> > >reference from the variable msm_otg_driver to the function 
> > >.init.text:msm_otg_probe()
> > >The variable msm_otg_driver references
> > >the function __init msm_otg_probe()
> > 
> >Hm, this warning shouldn't occur before patch #4, no?
> 
> good catch, this could probably be merged there.

True. Should I resend it?

Regards,
Ivan


--
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


LOAN

2014-04-28 Thread Bakker, K.
Dear valued customer,

Do you need an urgent loan to pay of your bills, invest more on your business, 
if yes PREMIUM CAPITAL LOAN offer loan at 3% interest rate. We are fast and 
reliable when it comes to loan lending contact email: 
premiumcapitall...@hotmail.co.uk for more information.

Contact email: premiumcapitall...@hotmail.co.uk

--
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: [RESEND PATCH v2] documentation: docbook: document process of writing an musb glue layer

2014-04-28 Thread Felipe Balbi
On Mon, Apr 28, 2014 at 07:30:26PM +0200, Apelete Seketeli wrote:
> Hi Felipe,
> 
> On Mon, Apr-14-2014 at 10:12:56 PM +0200, Apelete Seketeli wrote:
> > Document the process of writing an musb glue layer by taking the
> > Ingenic JZ4740 glue layer as an example, as it seems more simple than
> > most glue layers due to the basic feature set of the JZ4740 USB device
> > controller.
> > 
> > Signed-off-by: Apelete Seketeli 
> 
> This one wasn't part of the pull request for 3.15-rc3, so I was
> wondering if you are planning to pull it in the next round of fixes
> (if it qualifies as such) or just waiting for the 3.16 merge window ?

yeah, probably. I'll get to this by the end of the week.

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v8 02/20] usb: phy: msm: Remove __init macro from driver probe method

2014-04-28 Thread Felipe Balbi
On Mon, Apr 28, 2014 at 08:52:48PM +0300, Ivan T. Ivanov wrote:
> On Mon, 2014-04-28 at 12:03 -0500, Felipe Balbi wrote:
> > On Mon, Apr 28, 2014 at 09:00:43PM +0400, Sergei Shtylyov wrote:
> > > Hello.
> > > 
> > > On 04/28/2014 05:34 PM, Ivan T. Ivanov wrote:
> > > 
> > > >From: "Ivan T. Ivanov" 
> > > 
> > > >This fixes following:
> > > 
> > > >WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in 
> > > >reference from the variable msm_otg_driver to the function 
> > > >.init.text:msm_otg_probe()
> > > >The variable msm_otg_driver references
> > > >the function __init msm_otg_probe()
> > > 
> > >Hm, this warning shouldn't occur before patch #4, no?
> > 
> > good catch, this could probably be merged there.
> 
> True. Should I resend it?

hold on, that's simple enough to sort out while applying. Unless there
are any other big comments with your series, no need to resend.

cheers

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH v2 5/7] phy: omap-usb2: Add clock names to Documentation binding

2014-04-28 Thread Sergei Shtylyov

Hello.

On 04/28/2014 06:01 PM, Roger Quadros wrote:


Add "wkupclk" and "refclk" information to DT binding information.



Signed-off-by: Roger Quadros 
---
  Documentation/devicetree/bindings/phy/ti-phy.txt | 7 +++
  1 file changed, 7 insertions(+)



diff --git a/Documentation/devicetree/bindings/phy/ti-phy.txt 
b/Documentation/devicetree/bindings/phy/ti-phy.txt
index 788fb0f..9ce458f 100644
--- a/Documentation/devicetree/bindings/phy/ti-phy.txt
+++ b/Documentation/devicetree/bindings/phy/ti-phy.txt
@@ -32,6 +32,11 @@ Required properties:
   - reg : Address and length of the register set for the device.
   - #phy-cells: determine the number of cells that should be given in the
 phandle while referencing this phy.
+ - clocks: a list of phandles and clock-specifier pairs, one for each entry in
+   clock-names.


   I thought clock specifier includes phandle. Anyway, this description 
doesn't seem to match your example...



+ - clock-names: should include:
+   * "wkupclk" - wakeup clock.
+   * "refclk" - reference clock (optional).

  Optional properties:
   - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -44,6 +49,8 @@ usb2phy@4a0ad080 {
reg = <0x4a0ad080 0x58>;
ctrl-module = <&omap_control_usb>;
#phy-cells = <0>;
+   clocks = <&usb_phy_cm_clk32k>, <&usb_otg_ss_refclk960m>;
+   clock-names = "wkupclk", "refclk";
  };


WBR, Sergei

--
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 v7 12/16] usb: synchronize port poweroff and khubd

2014-04-28 Thread Dan Williams
On Mon, Apr 28, 2014 at 11:25 AM, Alan Stern  wrote:
> On Fri, 25 Apr 2014, Dan Williams wrote:
>
>> >> @@ -4892,11 +4897,17 @@ static void hub_events(void)
>> >>
>> >>   /* deal with port status changes */
>> >>   for (i = 1; i <= hdev->maxchild; i++) {
>> >> + struct usb_port *port_dev = hub->ports[i - 1];
>> >> +
>> >>   if (!test_bit(i, hub->busy_bits)
>> >>   && (test_and_clear_bit(i, 
>> >> hub->event_bits)
>> >>   || test_bit(i, 
>> >> hub->change_bits)
>> >> - || test_bit(i, 
>> >> hub->wakeup_bits)))
>> >> + || test_bit(i, 
>> >> hub->wakeup_bits))) {
>> >
>> > Please add a comment here, explaining that this is to prevent any
>> > runtime suspends from powering-off the port while we're handling the
>> > events.
>> >
>>
>> Added:
>> /*
>>  * The get_noresume and barrier ensures that 
>> if
>
> s/ensures/ensure/
>
>>  * the port was in the process of resuming we
>
> s/resuming/resuming,/
>
>>  * flush that work and keep the port active 
>> for
>>  * the duration of the port_event().  
>> However,
>>  * if the port is runtime pm suspended
>>  * (powered-off), we leave it in that state, 
>> run
>>  * an abbreviated port_event(), and move on.
>>  */
>
> Otherwise fine.
>

Noted, thanks.
--
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 v7 11/16] usb: refactor port handling in hub_events()

2014-04-28 Thread Alan Stern
On Fri, 25 Apr 2014, Dan Williams wrote:

> > Here's a second question.  I don't know if there's any definitive
> > answer.  What do you think of passing values like hdev, hcd, and
> > port_dev as arguments, as opposed to re-deriving them from the other
> > values?
> >
> > In theory, it could result in slightly smaller object code,
> > particularly in cases (like here) where the whole routine can be
> > inlined.  Also, it might reduce slightly the chances for copy/pasting
> > errors.
> >
> > This isn't a big deal either way.  But people seem to prefer passing
> > fewer arguments, and I have often wondered why.
> 
> 80 columns?

Maybe.

> We could do something like:
> 
> struct usb_port_context {
>   struct usb_port port_dev;
>   struct usb_hub *hub;
>   struct usb_device *hdev;
>   int port1;
>   u16 portstatus, portchange;
> }
> 
> ...and pass that around.  But I think that is a cleanup for another
> patch series.

That doesn't seem like a big improvement.  Why go to all the trouble of
creating a data structure to hold your local variables when you can
just pass them on the stack?  In the case where you're calling an
inline routine, the compiler often wouldn't even need to allocate new
stack locations to hold these values; it could reuse the local
variables in the calling function.

> >> + if (hub_handle_remote_wakeup(hub, port1, portstatus, portchange))
> >> + connect_change = 1;
> >
> > Moving this little portion is a candidate for the cleanup patch.
> 
> Moving it where?  Sorry I've cache flushed the context for this bit.

I've completely forgotten.  Maybe I was thinking ahead to a later patch 
in the series.

> Attached for review, but will be resubmitted with a refresh the whole
> patch set

The file you attached was a copy of patch 12/16, not an updated version
of this patch.  I'll wait for the whole patch set to reappear.  (And 
that reminds me, I still need to review patches 14-16 of the original 
series...)

Alan Stern

--
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 v7 12/16] usb: synchronize port poweroff and khubd

2014-04-28 Thread Alan Stern
On Fri, 25 Apr 2014, Dan Williams wrote:

> >> @@ -4892,11 +4897,17 @@ static void hub_events(void)
> >>
> >>   /* deal with port status changes */
> >>   for (i = 1; i <= hdev->maxchild; i++) {
> >> + struct usb_port *port_dev = hub->ports[i - 1];
> >> +
> >>   if (!test_bit(i, hub->busy_bits)
> >>   && (test_and_clear_bit(i, 
> >> hub->event_bits)
> >>   || test_bit(i, 
> >> hub->change_bits)
> >> - || test_bit(i, 
> >> hub->wakeup_bits)))
> >> + || test_bit(i, 
> >> hub->wakeup_bits))) {
> >
> > Please add a comment here, explaining that this is to prevent any
> > runtime suspends from powering-off the port while we're handling the
> > events.
> >
> 
> Added:
> /*
>  * The get_noresume and barrier ensures that 
> if

s/ensures/ensure/

>  * the port was in the process of resuming we

s/resuming/resuming,/

>  * flush that work and keep the port active 
> for
>  * the duration of the port_event().  However,
>  * if the port is runtime pm suspended
>  * (powered-off), we leave it in that state, 
> run
>  * an abbreviated port_event(), and move on.
>  */

Otherwise fine.

Alan Stern

--
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 v8 02/20] usb: phy: msm: Remove __init macro from driver probe method

2014-04-28 Thread Ivan T. Ivanov
On Mon, 2014-04-28 at 12:54 -0500, Felipe Balbi wrote:
> On Mon, Apr 28, 2014 at 08:52:48PM +0300, Ivan T. Ivanov wrote:
> > On Mon, 2014-04-28 at 12:03 -0500, Felipe Balbi wrote:
> > > On Mon, Apr 28, 2014 at 09:00:43PM +0400, Sergei Shtylyov wrote:
> > > > Hello.
> > > > 
> > > > On 04/28/2014 05:34 PM, Ivan T. Ivanov wrote:
> > > > 
> > > > >From: "Ivan T. Ivanov" 
> > > > 
> > > > >This fixes following:
> > > > 
> > > > >WARNING: drivers/usb/phy/built-in.o(.data+0x68): Section mismatch in 
> > > > >reference from the variable msm_otg_driver to the function 
> > > > >.init.text:msm_otg_probe()
> > > > >The variable msm_otg_driver references
> > > > >the function __init msm_otg_probe()
> > > > 
> > > >Hm, this warning shouldn't occur before patch #4, no?
> > > 
> > > good catch, this could probably be merged there.
> > 
> > True. Should I resend it?
> 
> hold on, that's simple enough to sort out while applying. Unless there
> are any other big comments with your series, no need to resend.

Sure, I will wait for more comments.

Thanks,
Ivan

> 
> cheers
> 


--
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] uwb: formatting and compile warning fixes

2014-04-28 Thread Thomas Pugliese
This set contains a few fixes for formatting issues and compile warnings 
in UWB.  Some of the changes for lines over 80 chars required pulling 
deeply nested code into separate functions which makes that patch look 
more significant than it really is.

Thomas Pugliese (3):
  uwb: whitespace and line length cleanups
  uwb: comment typo fix
  uwb: fix variable set but not used warnings

 drivers/uwb/beacon.c |   3 -
 drivers/uwb/drp.c| 294 +--
 drivers/uwb/est.c|   2 -
 drivers/uwb/ie-rcv.c |   2 -
 drivers/uwb/radio.c  |   2 +-
 5 files changed, 167 insertions(+), 136 deletions(-)

-- 
1.8.3.2

--
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] uwb: fix variable set but not used warnings

2014-04-28 Thread Thomas Pugliese
Fix variable set but not used warnings in UWB.

Signed-off-by: Thomas Pugliese 
---
 drivers/uwb/beacon.c | 3 ---
 drivers/uwb/est.c| 2 --
 drivers/uwb/ie-rcv.c | 2 --
 3 files changed, 7 deletions(-)

diff --git a/drivers/uwb/beacon.c b/drivers/uwb/beacon.c
index b476187..f40745f 100644
--- a/drivers/uwb/beacon.c
+++ b/drivers/uwb/beacon.c
@@ -397,7 +397,6 @@ int uwbd_evt_handle_rc_beacon(struct uwb_event *evt)
struct uwb_rc_evt_beacon *be;
struct uwb_beacon_frame *bf;
struct uwb_beca_e *bce;
-   unsigned long last_ts;
 
rc = evt->rc;
be = container_of(evt->notif.rceb, struct uwb_rc_evt_beacon, rceb);
@@ -441,8 +440,6 @@ int uwbd_evt_handle_rc_beacon(struct uwb_event *evt)
/* purge old beacon data */
kfree(bce->be);
 
-   last_ts = bce->ts_jiffies;
-
/* Update commonly used fields */
bce->ts_jiffies = evt->ts_jiffies;
bce->be = be;
diff --git a/drivers/uwb/est.c b/drivers/uwb/est.c
index 457f31d..f3e2325 100644
--- a/drivers/uwb/est.c
+++ b/drivers/uwb/est.c
@@ -258,7 +258,6 @@ int uwb_est_register(u8 type, u8 event_high, u16 vendor, 
u16 product,
 {
unsigned long flags;
unsigned itr;
-   u16 type_event_high;
int result = 0;
 
write_lock_irqsave(&uwb_est_lock, flags);
@@ -268,7 +267,6 @@ int uwb_est_register(u8 type, u8 event_high, u16 vendor, 
u16 product,
goto out;
}
/* Find the right spot to insert it in */
-   type_event_high = type << 8 | event_high;
for (itr = 0; itr < uwb_est_used; itr++)
if (uwb_est[itr].type_event_high < type
&& uwb_est[itr].vendor < vendor
diff --git a/drivers/uwb/ie-rcv.c b/drivers/uwb/ie-rcv.c
index 917e6d7..5fac574 100644
--- a/drivers/uwb/ie-rcv.c
+++ b/drivers/uwb/ie-rcv.c
@@ -31,7 +31,6 @@ int uwbd_evt_handle_rc_ie_rcv(struct uwb_event *evt)
int result = -EINVAL;
struct device *dev = &evt->rc->uwb_dev.dev;
struct uwb_rc_evt_ie_rcv *iercv;
-   size_t iesize;
 
/* Is there enough data to decode it? */
if (evt->notif.size < sizeof(*iercv)) {
@@ -41,7 +40,6 @@ int uwbd_evt_handle_rc_ie_rcv(struct uwb_event *evt)
goto error;
}
iercv = container_of(evt->notif.rceb, struct uwb_rc_evt_ie_rcv, rceb);
-   iesize = le16_to_cpu(iercv->wIELength);
 
dev_dbg(dev, "IE received, element ID=%d\n", iercv->IEData[0]);
 
-- 
1.8.3.2

--
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] uwb: comment typo fix

2014-04-28 Thread Thomas Pugliese
Comment typo fix.

Signed-off-by: Thomas Pugliese 
---
 drivers/uwb/radio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/uwb/radio.c b/drivers/uwb/radio.c
index fd23d98..2427e94 100644
--- a/drivers/uwb/radio.c
+++ b/drivers/uwb/radio.c
@@ -115,7 +115,7 @@ int uwb_radio_start(struct uwb_pal *pal)
 EXPORT_SYMBOL_GPL(uwb_radio_start);
 
 /**
- * uwb_radio_stop - request tha the radio be stopped.
+ * uwb_radio_stop - request that the radio be stopped.
  * @pal: the PAL making the request.
  *
  * Stops the radio if no other PAL is making use of it.
-- 
1.8.3.2

--
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] uwb: whitespace and line length cleanups

2014-04-28 Thread Thomas Pugliese
Fix whitespace and line length issues reported by checkpatch.

Signed-off-by: Thomas Pugliese 
---
 drivers/uwb/drp.c | 294 ++
 1 file changed, 166 insertions(+), 128 deletions(-)

diff --git a/drivers/uwb/drp.c b/drivers/uwb/drp.c
index 468c89f..05b7bd7 100644
--- a/drivers/uwb/drp.c
+++ b/drivers/uwb/drp.c
@@ -29,19 +29,19 @@
 enum uwb_drp_conflict_action {
/* Reservation is maintained, no action needed */
UWB_DRP_CONFLICT_MANTAIN = 0,
-   
+
/* the device shall not transmit frames in conflicting MASs in
 * the following superframe. If the device is the reservation
 * target, it shall also set the Reason Code in its DRP IE to
 * Conflict in its beacon in the following superframe.
 */
UWB_DRP_CONFLICT_ACT1,
-   
+
/* the device shall not set the Reservation Status bit to ONE
 * and shall not transmit frames in conflicting MASs. If the
 * device is the reservation target, it shall also set the
 * Reason Code in its DRP IE to Conflict.
-*/ 
+*/
UWB_DRP_CONFLICT_ACT2,
 
/* the device shall not transmit frames in conflicting MASs in
@@ -115,7 +115,8 @@ int uwb_rc_send_all_drp_ie(struct uwb_rc *rc)
if (uwb_rsv_has_two_drp_ies(rsv) &&
(rsv->mv.companion_drp_ie != NULL)) {
mv = &rsv->mv;
-   num_bytes += mv->companion_drp_ie->hdr.length + 
2;  
+   num_bytes +=
+   mv->companion_drp_ie->hdr.length + 2;
}
}
}
@@ -139,21 +140,23 @@ int uwb_rc_send_all_drp_ie(struct uwb_rc *rc)
memcpy(IEDataptr, rsv->drp_ie,
   rsv->drp_ie->hdr.length + 2);
IEDataptr += rsv->drp_ie->hdr.length + 2;
-   
+
if (uwb_rsv_has_two_drp_ies(rsv) &&
(rsv->mv.companion_drp_ie != NULL)) {
mv = &rsv->mv;
memcpy(IEDataptr, mv->companion_drp_ie,
   mv->companion_drp_ie->hdr.length + 2);
-   IEDataptr += mv->companion_drp_ie->hdr.length + 
2;  
+   IEDataptr +=
+   mv->companion_drp_ie->hdr.length + 2;
}
}
}
 
-   result = uwb_rc_cmd_async(rc, "SET-DRP-IE", &cmd->rccb, sizeof(*cmd) + 
num_bytes,
- UWB_RC_CET_GENERAL, UWB_RC_CMD_SET_DRP_IE,
- uwb_rc_set_drp_cmd_done, NULL);
-   
+   result = uwb_rc_cmd_async(rc, "SET-DRP-IE",
+   &cmd->rccb, sizeof(*cmd) + num_bytes,
+   UWB_RC_CET_GENERAL, UWB_RC_CMD_SET_DRP_IE,
+   uwb_rc_set_drp_cmd_done, NULL);
+
rc->set_drp_ie_pending = 1;
 
kfree(cmd);
@@ -176,8 +179,8 @@ static int evaluate_conflict_action(struct uwb_ie_drp 
*ext_drp_ie, int ext_beaco
int ext_tie_breaker = uwb_ie_drp_tiebreaker(ext_drp_ie);
int ext_status  = uwb_ie_drp_status(ext_drp_ie);
int ext_type= uwb_ie_drp_type(ext_drp_ie);
-   
-   
+
+
/* [ECMA-368 2nd Edition] 17.4.6 */
if (ext_type == UWB_DRP_TYPE_PCA && our_type == UWB_DRP_TYPE_PCA) {
return UWB_DRP_CONFLICT_MANTAIN;
@@ -187,7 +190,7 @@ static int evaluate_conflict_action(struct uwb_ie_drp 
*ext_drp_ie, int ext_beaco
if (our_type == UWB_DRP_TYPE_ALIEN_BP) {
return UWB_DRP_CONFLICT_MANTAIN;
}
-   
+
/* [ECMA-368 2nd Edition] 17.4.6-2 */
if (ext_type == UWB_DRP_TYPE_ALIEN_BP) {
/* here we know our_type != UWB_DRP_TYPE_ALIEN_BP */
@@ -215,7 +218,7 @@ static int evaluate_conflict_action(struct uwb_ie_drp 
*ext_drp_ie, int ext_beaco
our_beacon_slot >  ext_beacon_slot) {
return UWB_DRP_CONFLICT_MANTAIN;
}
-   
+
if (our_status == 0) {
if (our_tie_breaker == ext_tie_breaker) {
/* [ECMA-368 2nd Edition] 17.4.6-6a */
@@ -244,9 +247,9 @@ static int evaluate_conflict_action(struct uwb_ie_drp 
*ext_drp_ie, int ext_beaco
return UWB_DRP_CONFLICT_MANTAIN;
 }
 
-static void handle_conflict_normal(struct uwb_ie_drp *drp_ie, 
-  int ext_beacon_slot, 
-  struct uwb_rsv *rsv, 
+static void handle_conflict_normal(struct uwb_ie_drp *drp_ie,
+  int ext_beacon_slot,
+  struct uwb_rsv *rsv,
   struct uwb_mas_bm *conflicting_mas)
 {
  

Re: [RESEND PATCH v2] documentation: docbook: document process of writing an musb glue layer

2014-04-28 Thread Apelete Seketeli
Hi Felipe,

On Mon, Apr-14-2014 at 10:12:56 PM +0200, Apelete Seketeli wrote:
> Document the process of writing an musb glue layer by taking the
> Ingenic JZ4740 glue layer as an example, as it seems more simple than
> most glue layers due to the basic feature set of the JZ4740 USB device
> controller.
> 
> Signed-off-by: Apelete Seketeli 

This one wasn't part of the pull request for 3.15-rc3, so I was
wondering if you are planning to pull it in the next round of fixes
(if it qualifies as such) or just waiting for the 3.16 merge window ?

Cheers.

> ---
>  Documentation/DocBook/Makefile |3 +-
>  Documentation/DocBook/writing_musb_glue_layer.tmpl |  873 
> 
>  2 files changed, 875 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/DocBook/writing_musb_glue_layer.tmpl
> 
> diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
> index b444f2e..bec0665 100644
> --- a/Documentation/DocBook/Makefile
> +++ b/Documentation/DocBook/Makefile
> @@ -14,7 +14,8 @@ DOCBOOKS := z8530book.xml device-drivers.xml \
>   genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \
>   80211.xml debugobjects.xml sh.xml regulator.xml \
>   alsa-driver-api.xml writing-an-alsa-driver.xml \
> - tracepoint.xml drm.xml media_api.xml w1.xml
> + tracepoint.xml drm.xml media_api.xml w1.xml \
> + writing_musb_glue_layer.xml
>  
>  include Documentation/DocBook/media/Makefile
>  
> diff --git a/Documentation/DocBook/writing_musb_glue_layer.tmpl 
> b/Documentation/DocBook/writing_musb_glue_layer.tmpl
> new file mode 100644
> index 000..837eca7
> --- /dev/null
> +++ b/Documentation/DocBook/writing_musb_glue_layer.tmpl
> @@ -0,0 +1,873 @@
> +
> + + "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; []>
> +
> +
> + 
> +  Writing an MUSB Glue Layer
> +
> +  
> +   
> +Apelete
> +Seketeli
> +
> + 
> +  apelete at seketeli.net
> + 
> +
> +   
> +  
> +
> +  
> +   2014
> +   Apelete Seketeli
> +  
> +
> +  
> +   
> + This documentation is free software; you can redistribute it
> + and/or modify it under the terms of the GNU General Public
> + License as published by the Free Software Foundation; either
> + version 2 of the License, or (at your option) any later version.
> +   
> +
> +   
> + This documentation is distributed in the hope that it will be
> + useful, but WITHOUT ANY WARRANTY; without even the implied
> + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> + See the GNU General Public License for more details.
> +   
> +
> +   
> + You should have received a copy of the GNU General Public License
> + along with this documentation; if not, write to the Free Software
> + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> + 02111-1307 USA
> +   
> +
> +   
> + For more details see the file COPYING in the Linux kernel source
> + tree.
> +   
> +  
> + 
> +
> +
> +
> +  
> +Introduction
> +
> +  The Linux MUSB subsystem is part of the larger Linux USB
> +  subsystem. It provides support for embedded USB Device Controllers
> +  (UDC) that do not use Universal Host Controller Interface (UHCI)
> +  or Open Host Controller Interface (OHCI).
> +
> +
> +  Instead, these embedded UDC rely on the USB On-the-Go (OTG)
> +  specification which they implement at least partially. The silicon
> +  reference design used in most cases is the Multipoint USB
> +  Highspeed Dual-Role Controller (MUSB HDRC) found in the Mentor
> +  Graphics Inventraâ„¢ design.
> +
> +
> +  As a self-taught exercise I have written an MUSB glue layer for
> +  the Ingenic JZ4740 SoC, modelled after the many MUSB glue layers
> +  in the kernel source tree. This layer can be found at
> +  drivers/usb/musb/jz4740.c. In this documentation I will walk
> +  through the basics of the jz4740.c glue layer, explaining the
> +  different pieces and what needs to be done in order to write your
> +  own device glue layer.
> +
> +  
> +
> +  
> +Linux MUSB Basics
> +
> +  To get started on the topic, please read USB On-the-Go Basics (see
> +  Resources) which provides an introduction of USB OTG operation at
> +  the hardware level. A couple of wiki pages by Texas Instruments
> +  and Analog Devices also provide an overview of the Linux kernel
> +  MUSB configuration, albeit focused on some specific devices
> +  provided by these companies. Finally, getting acquainted with the
> +  USB specification at USB home page may come in handy, with
> +  practical instance provided through the Writing USB Device Drivers
> +  documentation (again, see Resources).
> +
> +
> +  Linux USB stack is a layered architecture in which the MUSB
> +  controller hardware sits at the lowest. The MUSB controller driver
> 

RE: [PATCH] usb: dwc3: debugfs: add snapshot to dump requests trbs events

2014-04-28 Thread Paul Zimmerman
> From: linux-usb-ow...@vger.kernel.org 
> [mailto:linux-usb-ow...@vger.kernel.org] On Behalf Of Felipe Balbi
> Sent: Monday, April 28, 2014 8:56 AM
> 
> On Mon, Apr 28, 2014 at 04:49:23PM -0400, Zhuang Jin Can wrote:
> > Adds a debugfs file "snapshot" to dump dwc3 requests, trbs and events.

< snip > 

> > +   for (i = 0; i < evt->length; i += 4) {
> > +   event.raw = *(u32 *) (evt->buf + i);
> > +   if (i == evt->lpos) {
> > +   seq_puts(s, "lpos---|\n");
> > +   seq_puts(s, "   \\\n");
> > +   }
> > +   seq_printf(s, "event[%d]: %08x ", i, event.raw);
> > +
> > +   if (event.type.is_devspec)
> > +   dwc3_dump_dev_event(s, &event.devt);
> > +   else
> > +   dwc3_dump_ep_event(s, &event.depevt);
> > +   seq_puts(s, "\n");
> > +   }
> 
> how well have you tested this ? I'm not entirely sure you should be
> reading the event buffer at any time you want, though I might be wrong.

Just FYI, it is fine to read from the event buffer memory at any time.
But of course, if you happen to read from a location at the same time
the core is writing to it, you may read either the old value or the new,
depending on the timing. So the results might not be 100% reliable.

-- 
Paul

--
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: what code calls the gadget composite driver's setup method?

2014-04-28 Thread Larry Martin


Alan and Rajaram, thanks for your help.  I have not looked at Linux 
kernel builds in this detail before.  I have been trying to recompile 
modules for the Linaro 3.5 kernel that we adopted last year.  I can see 
now there is no choice but to start building kernels and modules 
together.  I have also ordered a copy of Rajaram's book.


For the record, here is the answer to my original question:

The config file for the running kernel on my Gumstix is 
/boot/config-3.5.0+.  That file includes:

CONFIG_USB_GADGET_MUSB_HDRC=y
CONFIG_USB_MUSB_HDRC=y
CONFIG_USB_MUSB_OMAP2PLUS=y
# CONFIG_USB_OMAP is not set
Dereferencing those macros through the Makefile in drivers/usb/musb, I 
see omap2430.o along with musb-hdrc.o, which seems to have several 
source files.  In /sys/devices/platform of the running Gumstix, I see 
the omap2430 and musb-hdrc under that.  My chip's reference manual says 
it includes the Mentor Graphics MUSB HDRC OTG IP block, so all those 
acronyms make sense.  Finally, the call to composite_setup() is in 
musb_gadget_ep0.c, function forward_to_driver(), where a gadget driver's 
"setup" callback is called.


I will have to compile a kernel to debug further, and the latest code 
may fix my problem once I take that step.  Thanks again for your help.


Larry


On 4/28/2014 11:22 AM, Alan Stern wrote:

On Sun, 27 Apr 2014, Larry Martin wrote:


Alan is right, the code I wanted is in gadget/omap_udc.c.  How/where is
that code linked?

I put in some printks and do not get the output.  My new printk strings
are not in g_printer.ko, but other strings from composite.c and
printer.c are there.  Grep does not hit "omap-udc" in my kernel, so I
don't think it's compiled in.  But my new printk strings are not in any
gadget folder .ko.  I looked at other things too but hopefully that
makes my case.

Can someone who knows this code tell me how to get my changes to
omap-udc.c into an executable?  A pointer to a document would be great.

This depends on your kernel configuration.  See which drivers are
enabled in the "USB Peripheral Controller" section of your .config
file, and whether or not they are configured as modules.

It's possible that some of the modules you want to change get loaded
from an initramfs image during booting.

Alan Stern



--
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 v7 14/16] usb: resume (wakeup) child device when port is powered on

2014-04-28 Thread Alan Stern
On Wed, 19 Mar 2014, Dan Williams wrote:

> Unconditionally wake up the child device when the power session is
> recovered.
> 
> This address the following scenarios:
> 
> 1/ The device may need a reset on power-session loss, without this
>change port power-on recovery exposes khubd to scenarios that
>usb_port_resume() is set to handle.  Prior to port power control the
>only time a power session would be lost is during dpm_suspend of the
>hub.  In that scenario usb_port_resume() is guaranteed to be called
>prior to khubd running for that port.  With this change we wakeup the
>child device as soon as possible (prior to khubd running again for this
>port).
> 
>Although khubd has facilities to wake a child device it will only do
>so if the portstatus / portchange indicates a suspend state.  In the
>case of port power control we are not coming from a hub-port-suspend
>state.  This implemenation extends usb_wake_notification() for the
>port rpm_resume case.
> 
> 2/ This mechanism rate limits port power toggling.  The minimum port
>power on/off period is now gated by the child device suspend/resume
>latency.  Empirically this mitigates devices downgrading their connection
>on perceived instability of the host connection.  This ratelimiting is
>really only relevant to port power control testing, but it is a nice
>side effect of closing the above race.  Namely, the race of khubd for
>the given port running while a usb_port_resume() event is pending.
> 
> 3/ Going forward we are finding that power-session recovery requires
>warm-resets (http://marc.info/?t=13865923293&r=1&w=2).  This
>mechanism allows for warm-resets to be requested at the same point in
>the resume path for hub dpm_suspend power session losses, or port
>rpm_suspend power session losses.
> 
> 4/ If the device *was* disconnected the only time we'll know for sure is
>after a failed resume, so it's necessary for usb_port_runtime_resume()
>to expedite a usb_port_resume() to clean up the removed device.  The
>reasoning for this is "least surprise" for the user. Turning on a port
>means that hotplug detection is again enabled for the port, it is
>surprising that devices that were removed while the port was off are not
>disconnected until they are attempted to be used.  As a user "why would
>I try to use a device I removed from the system?"
> 
> 1, 2, and 4 are not a problem in the system dpm_resume case because,
> although the power-session is lost, khubd is frozen until after device
> resume.  For the port rpm_resume use runtime-pm-synchronization to
> guarantee the same sequence of events.  When a usb_wakeup_notification()
> is invoked the port device is in the RPM_RESUMING state.  khubd in turn
> performs a pm_runtime_barrier() on the port device to flush the port
> recovery, holds the port active while it resumes the child, and
> completes child device resume before acting on the current portstatus.

Can you include a brief description of situations in which this would 
be needed, i.e., when something would runtime-resume the port without 
also resuming the child device?  Testing, sure, but not much else comes 
to mind.

> Signed-off-by: Dan Williams 
> ---
>  drivers/usb/core/hub.c  |   40 +---
>  drivers/usb/core/port.c |2 ++
>  2 files changed, 31 insertions(+), 11 deletions(-)

> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
> @@ -104,6 +104,8 @@ static int usb_port_runtime_resume(struct device *dev)
>   if (retval < 0)
>   dev_dbg(&port_dev->dev, "can't get reconnection after 
> setting port  power on, status %d\n",
>   retval);
> +
> + usb_wakeup_notification(hdev, port1);
>   retval = 0;
>   }

I think this can be simplified a lot.  At first glance, almost no
changes to hub.c will be necessary if instead you insert:

if (port_dev->did_runtime_put) {
port_dev->did_runtime_put = false;
pm_runtime_get_noresume(&port_dev->dev);
pm_request_resume(&port_dev->child->dev);
}

Then in usb_port_resume(), simply interchange these two lines:

status = pm_runtime_get_sync(&port_dev->dev);
port_dev->did_runtime_put = false;

Unfortunately, these new references to port_dev->did_runtime_put will
race with the existing references in hub.c.  The simplest solution
seems to be to convert the did_runtime_put values to a set of atomic
bitflags stored in the hub structure (like hub->change_bits).

But this got me thinking...  It looks like the reference to
port_dev->child in usb_port_runtime_resume() already races with the
line

*pdev = NULL;

in usb_disconnect().  We need to make sure that a port runtime-resume
is mutually exclusive with child device removal

Re: [PATCH v7 14/16] usb: resume (wakeup) child device when port is powered on

2014-04-28 Thread Dan Williams
On Mon, Apr 28, 2014 at 1:29 PM, Alan Stern  wrote:
> On Wed, 19 Mar 2014, Dan Williams wrote:
>
>> Unconditionally wake up the child device when the power session is
>> recovered.
>>
>> This address the following scenarios:
>>
>> 1/ The device may need a reset on power-session loss, without this
>>change port power-on recovery exposes khubd to scenarios that
>>usb_port_resume() is set to handle.  Prior to port power control the
>>only time a power session would be lost is during dpm_suspend of the
>>hub.  In that scenario usb_port_resume() is guaranteed to be called
>>prior to khubd running for that port.  With this change we wakeup the
>>child device as soon as possible (prior to khubd running again for this
>>port).
>>
>>Although khubd has facilities to wake a child device it will only do
>>so if the portstatus / portchange indicates a suspend state.  In the
>>case of port power control we are not coming from a hub-port-suspend
>>state.  This implemenation extends usb_wake_notification() for the
>>port rpm_resume case.
>>
>> 2/ This mechanism rate limits port power toggling.  The minimum port
>>power on/off period is now gated by the child device suspend/resume
>>latency.  Empirically this mitigates devices downgrading their connection
>>on perceived instability of the host connection.  This ratelimiting is
>>really only relevant to port power control testing, but it is a nice
>>side effect of closing the above race.  Namely, the race of khubd for
>>the given port running while a usb_port_resume() event is pending.
>>
>> 3/ Going forward we are finding that power-session recovery requires
>>warm-resets (http://marc.info/?t=13865923293&r=1&w=2).  This
>>mechanism allows for warm-resets to be requested at the same point in
>>the resume path for hub dpm_suspend power session losses, or port
>>rpm_suspend power session losses.
>>
>> 4/ If the device *was* disconnected the only time we'll know for sure is
>>after a failed resume, so it's necessary for usb_port_runtime_resume()
>>to expedite a usb_port_resume() to clean up the removed device.  The
>>reasoning for this is "least surprise" for the user. Turning on a port
>>means that hotplug detection is again enabled for the port, it is
>>surprising that devices that were removed while the port was off are not
>>disconnected until they are attempted to be used.  As a user "why would
>>I try to use a device I removed from the system?"
>>
>> 1, 2, and 4 are not a problem in the system dpm_resume case because,
>> although the power-session is lost, khubd is frozen until after device
>> resume.  For the port rpm_resume use runtime-pm-synchronization to
>> guarantee the same sequence of events.  When a usb_wakeup_notification()
>> is invoked the port device is in the RPM_RESUMING state.  khubd in turn
>> performs a pm_runtime_barrier() on the port device to flush the port
>> recovery, holds the port active while it resumes the child, and
>> completes child device resume before acting on the current portstatus.
>
> Can you include a brief description of situations in which this would
> be needed, i.e., when something would runtime-resume the port without
> also resuming the child device?  Testing, sure, but not much else comes
> to mind.

I guess it could be considered testing, but changing the poweroff
policy of the port is one case where it matters to immediately resume
the child.  A user could (even though it is warned against in
Documentation/usb/power-management.txt) unplug a device while the port
is powered off.  Without the forced resume of the child we won't
notice the unplug event until much later.  So, it's a "the world may
have changed, revalidate" operation.  I'll include text along these
lines in the update.

>> Signed-off-by: Dan Williams 
>> ---
>>  drivers/usb/core/hub.c  |   40 +---
>>  drivers/usb/core/port.c |2 ++
>>  2 files changed, 31 insertions(+), 11 deletions(-)
>
>> --- a/drivers/usb/core/port.c
>> +++ b/drivers/usb/core/port.c
>> @@ -104,6 +104,8 @@ static int usb_port_runtime_resume(struct device *dev)
>>   if (retval < 0)
>>   dev_dbg(&port_dev->dev, "can't get reconnection after 
>> setting port  power on, status %d\n",
>>   retval);
>> +
>> + usb_wakeup_notification(hdev, port1);
>>   retval = 0;
>>   }
>
> I think this can be simplified a lot.  At first glance, almost no
> changes to hub.c will be necessary if instead you insert:
>
> if (port_dev->did_runtime_put) {
> port_dev->did_runtime_put = false;
> pm_runtime_get_noresume(&port_dev->dev);
> pm_request_resume(&port_dev->child->dev);
> }

Doesn't this subvert usb_auto{resume|suspend} by changing the power
state of the device re

Re: [PATCH v7 14/16] usb: resume (wakeup) child device when port is powered on

2014-04-28 Thread Dan Williams
On Mon, Apr 28, 2014 at 2:00 PM, Dan Williams  wrote:
> On Mon, Apr 28, 2014 at 1:29 PM, Alan Stern  wrote:
>> On Wed, 19 Mar 2014, Dan Williams wrote:
[..]
>> But this got me thinking...  It looks like the reference to
>> port_dev->child in usb_port_runtime_resume() already races with the
>> line
>>
>> *pdev = NULL;
>>
>> in usb_disconnect().  We need to make sure that a port runtime-resume
>> is mutually exclusive with child device removal.  (Consider, for
>> example, what happens if a thread does a runtime resume on a port and
>> at the same time, the hub is unplugged.)  Any ideas?
>
> Yes, I think we simply need to add
> pm_runtime_{get|put}(&port_dev->dev) to guarantee that port_dev->child
> is always safe to de-reference in usb_port_runtime{suspend|resume}.

...and as I go to add this I notice that prior to the "use
pm_request_resume" suggestion we don't de-reference port_dev->child in
usb_port_runtime_resume().  This realization plus the usage count
tracking that usb_remote_wakeup() affords is leaning me towards
leaving the "force wakeup" mechanism as is for the upcoming re-post.
--
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 v8 03/18] usb: cleanup setting udev->removable from port_dev->connect_type

2014-04-28 Thread Dan Williams
Once usb-acpi has set the port's connect type the usb_device's
->removable attribute can be set in the standard location
set_usb_port_removable().

This also changes behavior in the case where the firmware says that the
port connect type is unknown.  In that case just use the default setting
determined from the hub descriptor.

Note, we no longer pass udev->portnum to acpi_find_child_device() in the
root hub case since:
1/ the usb-core sets this to zero
2/ acpi always expects zero
...just pass zero.

Suggested-by: Alan Stern 
Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |   22 +-
 drivers/usb/core/usb-acpi.c |   34 ++
 2 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index f5de1a787177..9aa7d5102062 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2293,6 +2293,22 @@ static void set_usb_port_removable(struct usb_device 
*udev)
udev->removable = USB_DEVICE_REMOVABLE;
else
udev->removable = USB_DEVICE_FIXED;
+
+   /*
+* Platform firmware may have populated an alternative value for
+* removable.  If the parent port has a known connect_type use
+* that instead.
+*/
+   switch (hub->ports[udev->portnum - 1]->connect_type) {
+   case USB_PORT_CONNECT_TYPE_HOT_PLUG:
+   udev->removable = USB_DEVICE_REMOVABLE;
+   break;
+   case USB_PORT_CONNECT_TYPE_HARD_WIRED:
+   udev->removable = USB_DEVICE_FIXED;
+   break;
+   default: /* use what was set above */
+   break;
+   }
 }
 
 /**
@@ -2362,11 +2378,7 @@ int usb_new_device(struct usb_device *udev)
 
device_enable_async_suspend(&udev->dev);
 
-   /*
-* check whether the hub marks this port as non-removable. Do it
-* now so that platform-specific data can override it in
-* device_add()
-*/
+   /* check whether the hub or firmware marks this port as non-removable */
if (udev->parent)
set_usb_port_removable(udev);
 
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index f91ef0220066..d3e7e1b4125e 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -136,8 +136,8 @@ out:
 
 static struct acpi_device *usb_acpi_find_companion(struct device *dev)
 {
-   int port1;
struct usb_device *udev;
+   struct acpi_device *adev;
acpi_handle *parent_handle;
 
/*
@@ -155,40 +155,18 @@ static struct acpi_device *usb_acpi_find_companion(struct 
device *dev)
 */
if (is_usb_device(dev)) {
udev = to_usb_device(dev);
-   port1 = udev->portnum;
-   if (udev->parent) {
-   struct usb_hub *hub;
-
-   hub = usb_hub_to_struct_hub(udev->parent);
-   /*
-* According usb port's connect type to set usb device's
-* removability.
-*/
-   switch (hub->ports[port1 - 1]->connect_type) {
-   case USB_PORT_CONNECT_TYPE_HOT_PLUG:
-   udev->removable = USB_DEVICE_REMOVABLE;
-   break;
-   case USB_PORT_CONNECT_TYPE_HARD_WIRED:
-   udev->removable = USB_DEVICE_FIXED;
-   break;
-   default:
-   udev->removable = USB_DEVICE_REMOVABLE_UNKNOWN;
-   break;
-   }
-
+   if (udev->parent)
return NULL;
-   }
 
-   /* root hub's parent is the usb hcd. */
-   return acpi_find_child_device(ACPI_COMPANION(dev->parent),
-   port1, false);
+   /* root hub is only child (_ADR=0) under its parent, the HC */
+   adev = ACPI_COMPANION(dev->parent);
+   return acpi_find_child_device(adev, 0, false);
} else if (is_usb_port(dev)) {
struct usb_port *port_dev = to_usb_port(dev);
-   struct acpi_device *adev = NULL;
+   int port1 = port_dev->portnum;
 
/* Get the struct usb_device point of port's hub */
udev = to_usb_device(dev->parent->parent);
-   port1 = port_dev->portnum;
 
/*
 * The root hub ports' parent is the root hub. The non-root-hub

--
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 v8 01/18] usb: disable port power control if not supported in wHubCharacteristics

2014-04-28 Thread Dan Williams
A hub indicates whether it supports per-port power control via the
wHubCharacteristics field in its descriptor.  If it is not supported
a hub will still emulate ClearPortPower(PORT_POWER) requests by
stopping the link state machine.  However, since this does not save
power do not bother suspending.

This also consolidates support checks into a
hub_is_port_power_switchable() helper.

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |8 ++--
 drivers/usb/core/hub.h  |   10 ++
 drivers/usb/core/port.c |   13 -
 3 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 090469ebfcff..22334678e878 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -818,8 +818,6 @@ static unsigned hub_power_on(struct usb_hub *hub, bool 
do_delay)
int port1;
unsigned pgood_delay = hub->descriptor->bPwrOn2PwrGood * 2;
unsigned delay;
-   u16 wHubCharacteristics =
-   le16_to_cpu(hub->descriptor->wHubCharacteristics);
 
/* Enable power on each port.  Some hubs have reserved values
 * of LPSM (> 2) in their descriptors, even though they are
@@ -827,7 +825,7 @@ static unsigned hub_power_on(struct usb_hub *hub, bool 
do_delay)
 * but only emulate it.  In all cases, the ports won't work
 * unless we send these messages to the hub.
 */
-   if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2)
+   if (hub_is_port_power_switchable(hub))
dev_dbg(hub->intfdev, "enabling power on all ports\n");
else
dev_dbg(hub->intfdev, "trying to enable port power on "
@@ -4407,8 +4405,6 @@ static void hub_port_connect_change(struct usb_hub *hub, 
int port1,
struct usb_device *hdev = hub->hdev;
struct device *hub_dev = hub->intfdev;
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
-   unsigned wHubCharacteristics =
-   le16_to_cpu(hub->descriptor->wHubCharacteristics);
struct usb_device *udev;
int status, i;
unsigned unit_load;
@@ -4493,7 +4489,7 @@ static void hub_port_connect_change(struct usb_hub *hub, 
int port1,
test_bit(port1, hub->removed_bits)) {
 
/* maybe switch power back on (e.g. root hub was reset) */
-   if ((wHubCharacteristics & HUB_CHAR_LPSM) < 2
+   if (hub_is_port_power_switchable(hub)
&& !port_is_power_on(hub, portstatus))
set_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
 
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 33bcb2c6f90a..2583e5e80007 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -111,6 +111,16 @@ extern int hub_port_debounce(struct usb_hub *hub, int 
port1,
 extern int usb_clear_port_feature(struct usb_device *hdev,
int port1, int feature);
 
+static inline bool hub_is_port_power_switchable(struct usb_hub *hub)
+{
+   __le16 hcs;
+
+   if (!hub)
+   return false;
+   hcs = hub->descriptor->wHubCharacteristics;
+   return (le16_to_cpu(hcs) & HUB_CHAR_LPSM) < HUB_CHAR_NO_LPSM;
+}
+
 static inline int hub_port_debounce_be_connected(struct usb_hub *hub,
int port1)
 {
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 51542f852393..3a7dd99706aa 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -171,12 +171,15 @@ int usb_hub_create_port_device(struct usb_hub *hub, int 
port1)
 
pm_runtime_set_active(&port_dev->dev);
 
-   /* It would be dangerous if user space couldn't
-* prevent usb device from being powered off. So don't
-* enable port runtime pm if failed to expose port's pm qos.
+   /*
+* Do not enable port runtime pm if the hub does not support
+* power switching.  Also, userspace must have final say of
+* whether a port is permitted to power-off.  Do not enable
+* runtime pm if we fail to expose pm_qos_no_power_off.
 */
-   if (!dev_pm_qos_expose_flags(&port_dev->dev,
-   PM_QOS_FLAG_NO_POWER_OFF))
+   if (hub_is_port_power_switchable(hub)
+   && dev_pm_qos_expose_flags(&port_dev->dev,
+   PM_QOS_FLAG_NO_POWER_OFF) == 0)
pm_runtime_enable(&port_dev->dev);
 
device_enable_async_suspend(&port_dev->dev);

--
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 v8 00/18] port power control reworks

2014-04-28 Thread Dan Williams
Changes since v7 [1]:
* Added patch 8 "usb: make usb_port flags atomic"

* Added patch 15 "usb: hub_handle_remote_wakeup() depends on
  CONFIG_PM_RUNTIME=y"

* Fixed patch 16 "usb: resume (wakeup) child device when port is powered
  on"
  - added USB_PORTDEV_WAKE flag to force usb_remote_wakeup() in
hub_handle_remote_wakeup()

* Added a port_event() comment in patch 13 "usb: synchronize port
  poweroff and khubd"

* Reworked patch 12 "usb: refactor port handling in hub_events()" to
  avoid indentation churn and a cleanup to consolidate calls to
  usb_reset_device()

See a summary of the review state of the series below.

=

This series addresses the following disconnect scenarios when attempting
to use port power-off.

1/ Superspeed devices downgrade to their hispeed connection when
   rx-detection fails on the superspeed pins.  Address this by
   preventing superspeed port poweroff/suspension until the peer port is
   suspended, and powering on the superspeed port before the hispeed
   port is resumed.  This depends on the ability to identify peer ports
   (patches 4-7, and patch 9 implements the policy).

2/ khubd prematurely disconnects ports that are in the process of being
   resumed or reset.  After this series khubd will ignore ports in the
   pm-runtime-suspended or suspending state, or force active ports in the
   resuming state (patch 13).  While it is running it holds a new port
   status lock to synchronize the port status changes of
   usb_port_{suspend|resume} and usb_reset_and_verify_device() (patch 14).

3/ Superspeed devices fail to reconnect after a 2 second timeout  This
   event has two causes:

   3.1/ Repeated {Set|Clear}PortFeature(PORT_POWER) toggles results in
the the device switching to its hispeed connection (due to
perceived instability of the superspeed connection).  Address
this by arranging for the child device to be woken up
and complete a resume cycle when the parent port resumes (patch 16).

   3.2/ Devices may require a warm reset when recovering the power
session.  When the child device is woken up per above and the
port timed out on reconnect, force a warm-reset during the
child's reset-resume (patch 17).

[1]: v7: http://marc.info/?l=linux-usb&m=139526512014030&w=2

---

ACK => Acked-by: Alan Stern 
ack => Acked-by another reviewer

ACK [01/18] usb: disable port power control if not supported in 
wHubCharacteristics
ACK [02/18] usb: rename usb_port device objects
ACK [03/18] usb: cleanup setting udev->removable from port_dev->connect_type
ACK [04/18] usb: assign default peer ports for root hubs
ACK [05/18] usb: assign usb3 external hub port peers
ACK [06/18] usb: find internal hub tier mismatch via acpi
ACK [07/18] usb: sysfs link peer ports
[08/18] usb: make usb_port flags atomic
ACK [09/18] usb: block suspension of superspeed port while hispeed peer is 
active
ACK [10/18] usb: don't clear FEAT_C_ENABLE on usb_port_runtime_resume failure
ACK [11/18] usb: usb3 ports do not support FEAT_C_ENABLE
[12/18] usb: refactor port handling in hub_events()
[13/18] usb: synchronize port poweroff and khubd
[14/18] usb: introduce port status lock
[15/18] usb: hub_handle_remote_wakeup() depends on CONFIG_PM_RUNTIME=y
[16/18] usb: resume (wakeup) child device when port is powered on
ack [17/18] usb: force warm reset to break link re-connect livelock
[18/18] usb: documentation for usb port power off mechanisms

 Documentation/usb/power-management.txt |  242 +-
 drivers/usb/core/hcd.c |   45 ++-
 drivers/usb/core/hub.c |  877 +---
 drivers/usb/core/hub.h |   48 ++-
 drivers/usb/core/port.c|  297 ++-
 drivers/usb/core/usb-acpi.c|  107 ++---
 drivers/usb/core/usb.h |   16 +-
 7 files changed, 1110 insertions(+), 522 deletions(-)
--
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 v8 02/18] usb: rename usb_port device objects

2014-04-28 Thread Dan Williams
The current port name "portX" is ambiguous.  Before adding more port
messages rename ports to "-portX"

This is an ABI change, but the suspicion is that it will go unnoticed as
the port power control implementation has been broken since its
introduction.  If however, someone was relying on the old name we can
add sysfs links from the old name to the new name.

Additionally, it unifies/simplifies port dev_printk messages and modifies
instances of:
dev_XXX(hub->intfdev, ..."port %d"...
dev_XXX(&hdev->dev, ..."port%d"...
into:
dev_XXX(&port_dev->dev, ...

Now that the names are unique usb_port devices it would be nice if they
could be included in /sys/bus/usb.  However, it turns out that this
breaks 'lsusb -t'.  For now, create a dummy port driver so that print
messages are prefixed "usb 1-1-port3" rather than the
subsystem-ambiguous " 1-1-port3".

Finally, it corrects an odd usage of sscanf("port%d") in usb-acpi.c.

Suggested-by: Alan Stern 
Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |  273 ++-
 drivers/usb/core/port.c |   10 +-
 drivers/usb/core/usb-acpi.c |   60 +
 drivers/usb/core/usb.h  |4 -
 4 files changed, 158 insertions(+), 189 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 22334678e878..f5de1a787177 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -412,30 +412,35 @@ static int set_port_feature(struct usb_device *hdev, int 
port1, int feature)
NULL, 0, 1000);
 }
 
+static char *to_led_name(int selector)
+{
+   switch (selector) {
+   case HUB_LED_AMBER:
+   return "amber";
+   case HUB_LED_GREEN:
+   return "green";
+   case HUB_LED_OFF:
+   return "off";
+   case HUB_LED_AUTO:
+   return "auto";
+   default:
+   return "??";
+   }
+}
+
 /*
  * USB 2.0 spec Section 11.24.2.7.1.10 and table 11-7
  * for info about using port indicators
  */
-static void set_port_led(
-   struct usb_hub *hub,
-   int port1,
-   int selector
-)
+static void set_port_led(struct usb_hub *hub, int port1, int selector)
 {
-   int status = set_port_feature(hub->hdev, (selector << 8) | port1,
+   struct usb_port *port_dev = hub->ports[port1 - 1];
+   int status;
+
+   status = set_port_feature(hub->hdev, (selector << 8) | port1,
USB_PORT_FEAT_INDICATOR);
-   if (status < 0)
-   dev_dbg (hub->intfdev,
-   "port %d indicator %s status %d\n",
-   port1,
-   ({ char *s; switch (selector) {
-   case HUB_LED_AMBER: s = "amber"; break;
-   case HUB_LED_GREEN: s = "green"; break;
-   case HUB_LED_OFF: s = "off"; break;
-   case HUB_LED_AUTO: s = "auto"; break;
-   default: s = "??"; break;
-   } s; }),
-   status);
+   dev_dbg(&port_dev->dev, "indicator %s status %d\n",
+   to_led_name(selector), status);
 }
 
 #defineLED_CYCLE_PERIOD((2*HZ)/3)
@@ -909,20 +914,20 @@ static int hub_usb3_port_disable(struct usb_hub *hub, int 
port1)
msleep(HUB_DEBOUNCE_STEP);
}
if (total_time >= HUB_DEBOUNCE_TIMEOUT)
-   dev_warn(hub->intfdev, "Could not disable port %d after %d 
ms\n",
-   port1, total_time);
+   dev_warn(&hub->ports[port1 - 1]->dev,
+   "Could not disable after %d ms\n", total_time);
 
return hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_RX_DETECT);
 }
 
 static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
 {
+   struct usb_port *port_dev = hub->ports[port1 - 1];
struct usb_device *hdev = hub->hdev;
int ret = 0;
 
-   if (hub->ports[port1 - 1]->child && set_state)
-   usb_set_device_state(hub->ports[port1 - 1]->child,
-   USB_STATE_NOTATTACHED);
+   if (port_dev->child && set_state)
+   usb_set_device_state(port_dev->child, USB_STATE_NOTATTACHED);
if (!hub->error) {
if (hub_is_superspeed(hub->hdev))
ret = hub_usb3_port_disable(hub, port1);
@@ -931,8 +936,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, 
int set_state)
USB_PORT_FEAT_ENABLE);
}
if (ret && ret != -ENODEV)
-   dev_err(hub->intfdev, "cannot disable port %d (err = %d)\n",
-   port1, ret);
+   dev_err(&port_dev->dev, "cannot disable (err = %d)\n", ret);
return ret;
 }
 
@@ -943,7 +947,7 @@ static int hub_port_disable(struct usb_hub *hub, int port1, 
int set_state)
  */
 static void hub_port_logical_disc

[PATCH v8 05/18] usb: assign usb3 external hub port peers

2014-04-28 Thread Dan Williams
Given that root hub port peers are already established, external hub peer
ports can be determined by traversing the device topology:

1/ ascend to the parent hub and find the upstream port_dev

2/ walk ->peer to find the peer port

3/ descend to the peer hub via ->child

4/ find the port with the matching port id

Note that this assumes the port labeling scheme required by the
specification [1].

[1]: usb3 3.1 section 10.3.3

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/port.c |   32 
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 0d36610af156..fd53257de6a9 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -181,15 +181,18 @@ static void unlink_peers(struct usb_port *left, struct 
usb_port *right)
left->peer = NULL;
 }
 
-/* set the default peer port for root hubs */
+/*
+ * Set the default peer port for root hubs, or via the upstream peer
+ * relationship for all other hubs
+ */
 static void find_and_link_peer(struct usb_hub *hub, int port1)
 {
struct usb_port *port_dev = hub->ports[port1 - 1], *peer;
struct usb_device *hdev = hub->hdev;
+   struct usb_device *peer_hdev;
+   struct usb_hub *peer_hub;
 
if (!hdev->parent) {
-   struct usb_hub *peer_hub;
-   struct usb_device *peer_hdev;
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
struct usb_hcd *peer_hcd = hcd->shared_hcd;
 
@@ -197,15 +200,28 @@ static void find_and_link_peer(struct usb_hub *hub, int 
port1)
return;
 
peer_hdev = peer_hcd->self.root_hub;
-   peer_hub = usb_hub_to_struct_hub(peer_hdev);
-   if (!peer_hub || port1 > peer_hdev->maxchild)
+   } else {
+   struct usb_port *upstream;
+   struct usb_device *parent = hdev->parent;
+   struct usb_hub *parent_hub = usb_hub_to_struct_hub(parent);
+
+   if (!parent_hub)
return;
 
-   peer = peer_hub->ports[port1 - 1];
+   upstream = parent_hub->ports[hdev->portnum - 1];
+   if (!upstream || !upstream->peer)
+   return;
 
-   if (peer)
-   link_peers(port_dev, peer);
+   peer_hdev = upstream->peer->child;
}
+
+   peer_hub = usb_hub_to_struct_hub(peer_hdev);
+   if (!peer_hub || port1 > peer_hdev->maxchild)
+   return;
+
+   peer = peer_hub->ports[port1 - 1];
+   if (peer)
+   link_peers(port_dev, peer);
 }
 
 int usb_hub_create_port_device(struct usb_hub *hub, int port1)

--
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 v8 06/18] usb: find internal hub tier mismatch via acpi

2014-04-28 Thread Dan Williams
ACPI identifies peer ports by setting their 'group_token' and
'group_position' _PLD data to the same value.  If a platform has tier
mismatch [1] , ACPI can override the default (USB3 defined) peer port
association for internal hubs.  External hubs follow the default peer
association scheme.

Location data is cached as an opaque cookie in usb_port_location data.

Note that we only consider the group_token and group_position attributes
from the _PLD data as ACPI specifies that group_token is a unique
identifier.

When we find port location data for a port then we assume that the
firmware will also describe its peer port.  This allows the
implementation to only ever set the peer once.  This leads to a question
about what happens when a pm runtime event occurs while the peer
associations are still resolving.  Since we only ever set the peer
information once, a USB3 port needs to be prevented from suspending
while its ->peer pointer is NULL (implemented in a subsequent patch).

There is always the possibility that firmware mis-identifies the ports,
but there is not much the kernel can do in that case.

[1]: xhci 1.1 appendix D figure 131
[2]: acpi 5 section 6.1.8

[alan]: don't do default peering when acpi data present
Suggested-by: Alan Stern 
Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.h  |2 ++
 drivers/usb/core/port.c |   56 ---
 drivers/usb/core/usb-acpi.c |   41 ++-
 drivers/usb/core/usb.h  |6 +
 4 files changed, 83 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 1e965abbbd3c..0d8c5b0cdf09 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -83,6 +83,7 @@ struct usb_hub {
  * @port_owner: port's owner
  * @peer: related usb2 and usb3 ports (share the same connector)
  * @connect_type: port's connect type
+ * @location: opaque representation of platform connector location
  * @portnum: port index num based one
  * @power_is_on: port's power state
  * @did_runtime_put: port has done pm_runtime_put().
@@ -93,6 +94,7 @@ struct usb_port {
struct usb_dev_state *port_owner;
struct usb_port *peer;
enum usb_port_connect_type connect_type;
+   usb_port_location_t location;
u8 portnum;
unsigned power_is_on:1;
unsigned did_runtime_put:1;
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index fd53257de6a9..d29e9dc8ea9f 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -182,8 +182,42 @@ static void unlink_peers(struct usb_port *left, struct 
usb_port *right)
 }
 
 /*
- * Set the default peer port for root hubs, or via the upstream peer
- * relationship for all other hubs
+ * For each usb hub device in the system check to see if it is in the
+ * peer domain of the given port_dev, and if it is check to see if it
+ * has a port that matches the given port by location
+ */
+static int match_location(struct usb_device *peer_hdev, void *p)
+{
+   int port1;
+   struct usb_hcd *hcd, *peer_hcd;
+   struct usb_port *port_dev = p, *peer;
+   struct usb_hub *peer_hub = usb_hub_to_struct_hub(peer_hdev);
+   struct usb_device *hdev = to_usb_device(port_dev->dev.parent->parent);
+
+   if (!peer_hub)
+   return 0;
+
+   hcd = bus_to_hcd(hdev->bus);
+   peer_hcd = bus_to_hcd(peer_hdev->bus);
+   /* peer_hcd is provisional until we verify it against the known peer */
+   if (peer_hcd != hcd->shared_hcd)
+   return 0;
+
+   for (port1 = 1; port1 <= peer_hdev->maxchild; port1++) {
+   peer = peer_hub->ports[port1 - 1];
+   if (peer && peer->location == port_dev->location) {
+   link_peers(port_dev, peer);
+   return 1; /* done */
+   }
+   }
+
+   return 0;
+}
+
+/*
+ * Find the peer port either via explicit platform firmware "location"
+ * data, the peer hcd for root hubs, or the upstream peer relationship
+ * for all other hubs.
  */
 static void find_and_link_peer(struct usb_hub *hub, int port1)
 {
@@ -192,7 +226,17 @@ static void find_and_link_peer(struct usb_hub *hub, int 
port1)
struct usb_device *peer_hdev;
struct usb_hub *peer_hub;
 
-   if (!hdev->parent) {
+   /*
+* If location data is available then we can only peer this port
+* by a location match, not the default peer (lest we create a
+* situation where we need to go back and undo a default peering
+* when the port is later peered by location data)
+*/
+   if (port_dev->location) {
+   /* we link the peer in match_location() if found */
+   usb_for_each_dev(port_dev, match_location);
+   return;
+   } else if (!hdev->parent) {
struct usb_hcd *hcd = bus_to_hcd(hdev->bus);
struct usb_hcd *peer_hcd = hcd->shared_hcd;
 

[PATCH v8 07/18] usb: sysfs link peer ports

2014-04-28 Thread Dan Williams
The usb topology after this change will have symlinks between usb3 ports
and their usb2 peers, for example:

usb2/2-1/2-1:1.0/2-1-port1/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port1
usb2/2-1/2-1:1.0/2-1-port2/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port2
usb2/2-1/2-1:1.0/2-1-port3/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port3
usb2/2-1/2-1:1.0/2-1-port4/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port4
usb2/2-0:1.0/usb2-port1/peer=> ../../../usb3/3-0:1.0/usb3-port1
usb2/2-0:1.0/usb2-port2/peer=> ../../../usb3/3-0:1.0/usb3-port2
usb2/2-0:1.0/usb2-port3/peer=> ../../../usb3/3-0:1.0/usb3-port3
usb2/2-0:1.0/usb2-port4/peer=> ../../../usb3/3-0:1.0/usb3-port4

usb3/3-1/3-1:1.0/usb3-1-port1/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port1
usb3/3-1/3-1:1.0/usb3-1-port2/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port2
usb3/3-1/3-1:1.0/usb3-1-port3/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port3
usb3/3-1/3-1:1.0/usb3-1-port4/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port4
usb3/3-0:1.0/usb3-port1/peer   => ../../../usb2/2-0:1.0/usb2-port1
usb3/3-0:1.0/usb3-port2/peer   => ../../../usb2/2-0:1.0/usb2-port2
usb3/3-0:1.0/usb3-port3/peer   => ../../../usb2/2-0:1.0/usb2-port3
usb3/3-0:1.0/usb3-port4/peer   => ../../../usb2/2-0:1.0/usb2-port4

Introduce link_peers_report() to notify on all link_peers() failure
cases.

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/port.c |   39 ++-
 1 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index d29e9dc8ea9f..b7f5225cee2b 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -151,10 +151,12 @@ static struct device_driver usb_port_driver = {
.owner = THIS_MODULE,
 };
 
-static void link_peers(struct usb_port *left, struct usb_port *right)
+static int link_peers(struct usb_port *left, struct usb_port *right)
 {
+   int rc;
+
if (left->peer == right && right->peer == left)
-   return;
+   return 0;
 
if (left->peer || right->peer) {
struct usb_port *lpeer = left->peer;
@@ -164,11 +166,36 @@ static void link_peers(struct usb_port *left, struct 
usb_port *right)
dev_name(&left->dev), dev_name(&right->dev),
dev_name(&left->dev), lpeer,
dev_name(&right->dev), rpeer);
-   return;
+   return -EBUSY;
+   }
+
+   rc = sysfs_create_link(&left->dev.kobj, &right->dev.kobj, "peer");
+   if (rc)
+   return rc;
+   rc = sysfs_create_link(&right->dev.kobj, &left->dev.kobj, "peer");
+   if (rc) {
+   sysfs_remove_link(&left->dev.kobj, "peer");
+   return rc;
}
 
left->peer = right;
right->peer = left;
+
+   return 0;
+}
+
+static void link_peers_report(struct usb_port *left, struct usb_port *right)
+{
+   int rc;
+
+   rc = link_peers(left, right);
+   if (rc == 0) {
+   dev_dbg(&left->dev, "peered to %s\n", dev_name(&right->dev));
+   } else {
+   dev_warn(&left->dev, "failed to peer to %s (%d)\n",
+   dev_name(&right->dev), rc);
+   pr_warn_once("usb: port power management may be unreliable\n");
+   }
 }
 
 static void unlink_peers(struct usb_port *left, struct usb_port *right)
@@ -177,7 +204,9 @@ static void unlink_peers(struct usb_port *left, struct 
usb_port *right)
"%s and %s are not peers?\n",
dev_name(&left->dev), dev_name(&right->dev));
 
+   sysfs_remove_link(&left->dev.kobj, "peer");
right->peer = NULL;
+   sysfs_remove_link(&right->dev.kobj, "peer");
left->peer = NULL;
 }
 
@@ -206,7 +235,7 @@ static int match_location(struct usb_device *peer_hdev, 
void *p)
for (port1 = 1; port1 <= peer_hdev->maxchild; port1++) {
peer = peer_hub->ports[port1 - 1];
if (peer && peer->location == port_dev->location) {
-   link_peers(port_dev, peer);
+   link_peers_report(port_dev, peer);
return 1; /* done */
}
}
@@ -269,7 +298,7 @@ static void find_and_link_peer(struct usb_hub *hub, int 
port1)
 */
peer = peer_hub->ports[port1 - 1];
if (peer && peer->location == 0)
-   link_peers(port_dev, peer);
+   link_peers_report(port_dev, peer);
 }
 
 int usb_hub_create_port_device(struct usb_hub *hub, int port1)

--
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 v8 16/18] usb: resume (wakeup) child device when port is powered on

2014-04-28 Thread Dan Williams
Unconditionally wake up the child device when the power session is
recovered.

This address the following scenarios:

1/ The device may need a reset on power-session loss, without this
   change port power-on recovery exposes khubd to scenarios that
   usb_port_resume() is set to handle.  Prior to port power control the
   only time a power session would be lost is during dpm_suspend of the
   hub.  In that scenario usb_port_resume() is guaranteed to be called
   prior to khubd running for that port.  With this change we wakeup the
   child device as soon as possible (prior to khubd running again for this
   port).

   Although khubd has facilities to wake a child device it will only do
   so if the portstatus / portchange indicates a suspend state.  In the
   case of port power control we are not coming from a hub-port-suspend
   state.  This implemenation extends usb_wake_notification() for the
   port rpm_resume case.

2/ This mechanism rate limits port power toggling.  The minimum port
   power on/off period is now gated by the child device suspend/resume
   latency.  Empirically this mitigates devices downgrading their connection
   on perceived instability of the host connection.  This ratelimiting is
   really only relevant to port power control testing, but it is a nice
   side effect of closing the above race.  Namely, the race of khubd for
   the given port running while a usb_port_resume() event is pending.

3/ Going forward we are finding that power-session recovery requires
   warm-resets (http://marc.info/?t=13865923293&r=1&w=2).  This
   mechanism allows for warm-resets to be requested at the same point in
   the resume path for hub dpm_suspend power session losses, or port
   rpm_suspend power session losses.

4/ If the device *was* disconnected the only time we'll know for sure is
   after a failed resume, so it's necessary for usb_port_runtime_resume()
   to expedite a usb_port_resume() to clean up the removed device.  The
   reasoning for this is "least surprise" for the user. Turning on a port
   means that hotplug detection is again enabled for the port, it is
   surprising that devices that were removed while the port was off are not
   disconnected until they are attempted to be used.  As a user "why would
   I try to use a device I removed from the system?"

1, 2, and 4 are not a problem in the system dpm_resume case because,
although the power-session is lost, khubd is frozen until after device
resume.  For the port rpm_resume use runtime-pm-synchronization to
guarantee the same sequence of events.  When a usb_wakeup_notification()
is invoked the port device is in the RPM_RESUMING state.  khubd in turn
performs a pm_runtime_barrier() on the port device to flush the port
recovery, holds the port active while it resumes the child, and
completes child device resume before acting on the current portstatus.

Besides testing the primary scenario where this mechanism is expected to
be triggered is when the user changes the port power policy
(pm_qos_no_poweroff).   When that is set to 1 we want to revalidate the
child device, where the revalidation is handled by usb_port_resume().

Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |   32 +---
 drivers/usb/core/hub.h  |1 +
 drivers/usb/core/port.c |3 +++
 3 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index cfb6ac835c39..adbdec971e89 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -606,9 +606,11 @@ void usb_kick_khubd(struct usb_device *hdev)
  * USB 3.0 hubs do not report the port link state change from U3 to U0 when the
  * device initiates resume, so the USB core will not receive notice of the
  * resume through the normal hub interrupt URB.
+ *
+ * This is also called by usb_port_runtime_resume() to arrange for the child
+ * device to be woken up as part of the power session recovery for the port.
  */
-void usb_wakeup_notification(struct usb_device *hdev,
-   unsigned int portnum)
+void usb_wakeup_notification(struct usb_device *hdev, unsigned int port1)
 {
struct usb_hub *hub;
 
@@ -617,7 +619,11 @@ void usb_wakeup_notification(struct usb_device *hdev,
 
hub = usb_hub_to_struct_hub(hdev);
if (hub) {
-   set_bit(portnum, hub->wakeup_bits);
+   struct usb_port *port_dev = hub->ports[port1 - 1];
+
+   dev_dbg(&port_dev->dev, "%s\n", __func__);
+   if (!test_and_set_bit(port1, hub->wakeup_bits))
+   pm_runtime_get(&port_dev->dev);
kick_khubd(hub);
}
 }
@@ -4697,15 +4703,20 @@ static int hub_handle_remote_wakeup(struct usb_hub 
*hub, unsigned int port,
__must_hold(&port_dev->status_lock)
 {
struct usb_port *port_dev = hub->ports[port - 1];
+   int connect_change = 0, port_wake = 0;
struct usb_device *hdev;
struct usb_device *udev;
-   i

[PATCH v8 10/18] usb: don't clear FEAT_C_ENABLE on usb_port_runtime_resume failure

2014-04-28 Thread Dan Williams
Three reasons:
1/ It's an invalid operation on usb3 ports
2/ There's no guarantee of when / if a usb2 port has entered an error
   state relative to PORT_POWER request
3/ The port is active / powered at this point, so khubd will clear it as
   a matter of course

Acked-by: Alan Stern 
Signed-off-by: Dan Williams 
---
 drivers/usb/core/port.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index 539555d627f1..32e61913c085 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -106,7 +106,6 @@ static int usb_port_runtime_resume(struct device *dev)
if (retval < 0)
dev_dbg(&port_dev->dev, "can't get reconnection after 
setting port  power on, status %d\n",
retval);
-   usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_C_ENABLE);
retval = 0;
}
 

--
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 v8 08/18] usb: make usb_port flags atomic

2014-04-28 Thread Dan Williams
Before we add another 2 bitfields to the port state, convert it to an
unsigned long and use bitops helpers to manipulate it.  This later
enables setting bits to request action without worrying about colliding
updates.  In particular, a flag to request that the child device be
woken up when the port restores power is added in a later patch.

Signed-off-by: Dan Williams 
---
 drivers/usb/core/hub.c  |   26 +++---
 drivers/usb/core/hub.h  |8 
 drivers/usb/core/port.c |2 +-
 3 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 783acfca6c51..5ab8ce870f5b 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -758,9 +758,14 @@ int usb_hub_set_port_power(struct usb_device *hdev, struct 
usb_hub *hub,
else
ret = usb_clear_port_feature(hdev, port1, USB_PORT_FEAT_POWER);
 
-   if (!ret)
-   port_dev->power_is_on = set;
-   return ret;
+   if (ret)
+   return ret;
+
+   if (set)
+   set_bit(USB_PORTDEV_POWER, &port_dev->flags);
+   else
+   clear_bit(USB_PORTDEV_POWER, &port_dev->flags);
+   return 0;
 }
 
 /**
@@ -839,7 +844,7 @@ static unsigned hub_power_on(struct usb_hub *hub, bool 
do_delay)
dev_dbg(hub->intfdev, "trying to enable port power on "
"non-switchable hub\n");
for (port1 = 1; port1 <= hub->hdev->maxchild; port1++)
-   if (hub->ports[port1 - 1]->power_is_on)
+   if (test_bit(USB_PORTDEV_POWER, &hub->ports[port1 - 1]->flags))
set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
else
usb_clear_port_feature(hub->hdev, port1,
@@ -1188,7 +1193,7 @@ static void hub_activate(struct usb_hub *hub, enum 
hub_activation_type type)
/* Don't set the change_bits when the device
 * was powered off.
 */
-   if (port_dev->power_is_on)
+   if (test_bit(USB_PORTDEV_POWER, &port_dev->flags))
set_bit(port1, hub->change_bits);
 
} else {
@@ -2090,10 +2095,10 @@ void usb_disconnect(struct usb_device **pdev)
sysfs_remove_link(&udev->dev.kobj, "port");
sysfs_remove_link(&port_dev->dev.kobj, "device");
 
-   if (!port_dev->did_runtime_put)
+   /* if we didn't do it at "runtime" we need to do it now */
+   if (!test_and_clear_bit(USB_PORTDEV_DID_RUNTIME_PUT,
+   &port_dev->flags))
pm_runtime_put(&port_dev->dev);
-   else
-   port_dev->did_runtime_put = false;
}
 
usb_remove_ep_devs(&udev->ep0);
@@ -3090,7 +3095,7 @@ int usb_port_suspend(struct usb_device *udev, 
pm_message_t msg)
 
if (status == 0 && !udev->do_remote_wakeup && udev->persist_enabled) {
pm_runtime_put_sync(&port_dev->dev);
-   port_dev->did_runtime_put = true;
+   set_bit(USB_PORTDEV_DID_RUNTIME_PUT, &port_dev->flags);
}
 
usb_mark_last_busy(hub->hdev);
@@ -3233,9 +3238,8 @@ int usb_port_resume(struct usb_device *udev, pm_message_t 
msg)
int status;
u16 portchange, portstatus;
 
-   if (port_dev->did_runtime_put) {
+   if (test_and_clear_bit(USB_PORTDEV_DID_RUNTIME_PUT, &port_dev->flags)) {
status = pm_runtime_get_sync(&port_dev->dev);
-   port_dev->did_runtime_put = false;
if (status < 0) {
dev_dbg(&udev->dev, "can't resume usb port, status 
%d\n",
status);
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 0d8c5b0cdf09..fabf05ea3de6 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -85,8 +85,7 @@ struct usb_hub {
  * @connect_type: port's connect type
  * @location: opaque representation of platform connector location
  * @portnum: port index num based one
- * @power_is_on: port's power state
- * @did_runtime_put: port has done pm_runtime_put().
+ * @flags: operational state, and requests
  */
 struct usb_port {
struct usb_device *child;
@@ -96,8 +95,9 @@ struct usb_port {
enum usb_port_connect_type connect_type;
usb_port_location_t location;
u8 portnum;
-   unsigned power_is_on:1;
-   unsigned did_runtime_put:1;
+   #define USB_PORTDEV_POWER 0
+   #define USB_PORTDEV_DID_RUNTIME_PUT 1
+   unsigned long flags;
 };
 
 #define to_usb_port(_dev) \
diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
index b7f5225cee2b..99de5acb1240 100644
--- a/drivers/usb/core/port.c
+++ b/drivers/usb/core/port.c
@@ -314,7 +314,7 @@ int usb_hub_create_port_device(struct usb_hub *hub, int 
p

  1   2   >