Re: [PATCH v2 1/5] drivers: usb: chipidea: Add qoriq platform driver

2016-07-08 Thread kbuild test robot
Hi,

[auto build test WARNING on phy/next]
[also build test WARNING on v4.7-rc6 next-20160708]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Rajesh-Bhagat/drivers-usb-chipidea-Add-qoriq-platform-driver/20160709-130557
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git 
next
config: mn10300-allyesconfig (attached as .config)
compiler: am33_2.0-linux-gcc (GCC) 4.9.0
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mn10300 

All warnings (new ones prefixed by >>):

   In file included from include/linux/printk.h:289:0,
from include/linux/kernel.h:13,
from include/linux/list.h:8,
from include/linux/module.h:9,
from drivers/usb/chipidea/ci_hdrc_qoriq.c:12:
   drivers/usb/chipidea/ci_hdrc_qoriq.c: In function 'ci_hdrc_qoriq_usb_setup':
>> include/linux/dynamic_debug.h:64:16: warning: format '%llx' expects argument 
>> of type 'long long unsigned int', but argument 4 has type 'resource_size_t' 
>> [-Wformat=]
 static struct _ddebug  __aligned(8)   \
   ^
   include/linux/dynamic_debug.h:84:2: note: in expansion of macro 
'DEFINE_DYNAMIC_DEBUG_METADATA'
 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);  \
 ^
   include/linux/device.h:1197:2: note: in expansion of macro 'dynamic_dev_dbg'
 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
 ^
   drivers/usb/chipidea/ci_hdrc_qoriq.c:85:2: note: in expansion of macro 
'dev_dbg'
 dev_dbg(dev, "res->start %llx, resource_size(res) %llx\n", res->start,
 ^
   include/linux/dynamic_debug.h:64:16: warning: format '%llx' expects argument 
of type 'long long unsigned int', but argument 5 has type 'resource_size_t' 
[-Wformat=]
 static struct _ddebug  __aligned(8)   \
   ^
   include/linux/dynamic_debug.h:84:2: note: in expansion of macro 
'DEFINE_DYNAMIC_DEBUG_METADATA'
 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);  \
 ^
   include/linux/device.h:1197:2: note: in expansion of macro 'dynamic_dev_dbg'
 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
 ^
   drivers/usb/chipidea/ci_hdrc_qoriq.c:85:2: note: in expansion of macro 
'dev_dbg'
 dev_dbg(dev, "res->start %llx, resource_size(res) %llx\n", res->start,
 ^

vim +64 include/linux/dynamic_debug.h

b48420c1 Jim Cromie  2012-04-27  48 const 
char *modname);
b48420c1 Jim Cromie  2012-04-27  49  
cbc46635 Joe Perches 2011-08-11  50  struct device;
cbc46635 Joe Perches 2011-08-11  51  
b9075fa9 Joe Perches 2011-10-31  52  extern __printf(3, 4)
906d2015 Joe Perches 2014-09-24  53  void __dynamic_dev_dbg(struct _ddebug 
*descriptor, const struct device *dev,
b9075fa9 Joe Perches 2011-10-31  54const char *fmt, ...);
cbc46635 Joe Perches 2011-08-11  55  
ffa10cb4 Jason Baron 2011-08-11  56  struct net_device;
ffa10cb4 Jason Baron 2011-08-11  57  
b9075fa9 Joe Perches 2011-10-31  58  extern __printf(3, 4)
906d2015 Joe Perches 2014-09-24  59  void __dynamic_netdev_dbg(struct _ddebug 
*descriptor,
ffa10cb4 Jason Baron 2011-08-11  60   const struct 
net_device *dev,
b9075fa9 Joe Perches 2011-10-31  61   const char *fmt, ...);
ffa10cb4 Jason Baron 2011-08-11  62  
07613b0b Jason Baron 2011-10-04  63  #define 
DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt)   \
c0d2af63 Joe Perches 2012-10-18 @64 static struct _ddebug  __aligned(8) 
\
07613b0b Jason Baron 2011-10-04  65 __attribute__((section("__verbose"))) 
name = {  \
07613b0b Jason Baron 2011-10-04  66 .modname = KBUILD_MODNAME,  
\
07613b0b Jason Baron 2011-10-04  67 .function = __func__,   
\
07613b0b Jason Baron 2011-10-04  68 .filename = __FILE__,   
\
07613b0b Jason Baron 2011-10-04  69 .format = (fmt),
\
07613b0b Jason Baron 2011-10-04  70 .lineno = __LINE__, 
\
07613b0b Jason Baron 2011-10-04  71 .flags =  
_DPRINTK_FLAGS_DEFAULT,   \
07613b0b Jason Baron 2011-10-04  72 }

:: The code at line 64 was first introduced by commit
:: c0d2af637863940b1a4fb208224ca7acb905c39f dynamic_debug: Remove 
unnecessary __used

:: TO: Joe Perches 
:: CC: Greg Kroah-Hartman 

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH v2 1/5] drivers: usb: chipidea: Add qoriq platform driver

2016-07-08 Thread kbuild test robot
Hi,

[auto build test WARNING on phy/next]
[also build test WARNING on v4.7-rc6 next-20160708]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Rajesh-Bhagat/drivers-usb-chipidea-Add-qoriq-platform-driver/20160709-130557
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git 
next
config: blackfin-allmodconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 4.6.3
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=blackfin 

All warnings (new ones prefixed by >>):

   drivers/usb/chipidea/ci_hdrc_qoriq.c: In function 'ci_hdrc_qoriq_usb_setup':
>> drivers/usb/chipidea/ci_hdrc_qoriq.c:85:2: warning: format '%llx' expects 
>> argument of type 'long long unsigned int', but argument 4 has type 
>> 'resource_size_t' [-Wformat]
   drivers/usb/chipidea/ci_hdrc_qoriq.c:85:2: warning: format '%llx' expects 
argument of type 'long long unsigned int', but argument 5 has type 
'resource_size_t' [-Wformat]

vim +85 drivers/usb/chipidea/ci_hdrc_qoriq.c

69  clk_disable_unprepare(data->clk);
70  }
71  
72  static int ci_hdrc_qoriq_usb_setup(struct platform_device *pdev)
73  {
74  u32 reg;
75  struct resource *res;
76  struct device *dev = &pdev->dev;
77  struct ci_hdrc_qoriq_data *data = platform_get_drvdata(pdev);
78  
79  res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
80  if (!res) {
81  dev_err(dev, "failed to get I/O memory\n");
82  return -ENOENT;
83  }
84  
  > 85  dev_dbg(dev, "res->start %llx, resource_size(res) %llx\n", 
res->start,
86  resource_size(res));
87  data->qoriq_regs = devm_ioremap(dev, res->start, 
resource_size(res));
88  if (IS_ERR(data->qoriq_regs)) {
89  dev_err(dev, "failed to remap I/O memory\n");
90  return -ENOMEM;
91  }
92  
93  data->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node);

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH v2 1/5] drivers: usb: chipidea: Add qoriq platform driver

2016-07-08 Thread kbuild test robot
Hi,

[auto build test WARNING on phy/next]
[also build test WARNING on v4.7-rc6 next-20160708]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Rajesh-Bhagat/drivers-usb-chipidea-Add-qoriq-platform-driver/20160709-130557
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy.git 
next
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/linux/printk.h:289:0,
from include/linux/kernel.h:13,
from include/linux/list.h:8,
from include/linux/module.h:9,
from drivers/usb/chipidea/ci_hdrc_qoriq.c:12:
   drivers/usb/chipidea/ci_hdrc_qoriq.c: In function 'ci_hdrc_qoriq_usb_setup':
>> drivers/usb/chipidea/ci_hdrc_qoriq.c:85:15: warning: format '%llx' expects 
>> argument of type 'long long unsigned int', but argument 4 has type 
>> 'resource_size_t {aka unsigned int}' [-Wformat=]
 dev_dbg(dev, "res->start %llx, resource_size(res) %llx\n", res->start,
  ^
   include/linux/dynamic_debug.h:86:39: note: in definition of macro 
'dynamic_dev_dbg'
  __dynamic_dev_dbg(&descriptor, dev, fmt, \
  ^~~
>> drivers/usb/chipidea/ci_hdrc_qoriq.c:85:2: note: in expansion of macro 
>> 'dev_dbg'
 dev_dbg(dev, "res->start %llx, resource_size(res) %llx\n", res->start,
 ^~~
   drivers/usb/chipidea/ci_hdrc_qoriq.c:85:15: warning: format '%llx' expects 
argument of type 'long long unsigned int', but argument 5 has type 
'resource_size_t {aka unsigned int}' [-Wformat=]
 dev_dbg(dev, "res->start %llx, resource_size(res) %llx\n", res->start,
  ^
   include/linux/dynamic_debug.h:86:39: note: in definition of macro 
'dynamic_dev_dbg'
  __dynamic_dev_dbg(&descriptor, dev, fmt, \
  ^~~
>> drivers/usb/chipidea/ci_hdrc_qoriq.c:85:2: note: in expansion of macro 
>> 'dev_dbg'
 dev_dbg(dev, "res->start %llx, resource_size(res) %llx\n", res->start,
 ^~~

vim +85 drivers/usb/chipidea/ci_hdrc_qoriq.c

 6   *
 7   * This program is free software; you can redistribute it and/or modify
 8   * it under the terms of the GNU General Public License version 2 as
 9   * published by the Free Software Foundation.
10   *
11   */
  > 12  #include 
13  #include 
14  #include 
15  #include 
16  #include 
17  #include 
18  #include 
19  #include 
20  #include 
21  
22  #include "ci.h"
23  #include "ci_hdrc_qoriq.h"
24  
25  struct ci_hdrc_qoriq_data {
26  struct phy *phy;
27  struct clk *clk;
28  void __iomem *qoriq_regs;
29  struct platform_device *ci_pdev;
30  enum usb_phy_interface phy_mode;
31  };
32  
33  /*
34   * clock helper functions
35   */
36  static int ci_hdrc_qoriq_get_clks(struct platform_device *pdev)
37  {
38  int ret;
39  struct device *dev = &pdev->dev;
40  struct ci_hdrc_qoriq_data *data = platform_get_drvdata(pdev);
41  
42  data->clk = devm_clk_get(dev, "usb2-clock");
43  if (IS_ERR(data->clk)) {
44  dev_err(dev, "failed to get clk, err=%ld\n",
45  PTR_ERR(data->clk));
46  return ret;
47  }
48  return 0;
49  }
50  
51  static int ci_hdrc_qoriq_prepare_enable_clks(struct platform_device 
*pdev)
52  {
53  int ret;
54  struct device *dev = &pdev->dev;
55  struct ci_hdrc_qoriq_data *data = platform_get_drvdata(pdev);
56  
57  ret = clk_prepare_enable(data->clk);
58  if (ret) {
59  dev_err(dev, "failed to prepare/enable clk, err=%d\n", 
ret);
60  return ret;
61  }
62  return 0;
63  }
64  
65  static void ci_hdrc_qoriq_disable_unprepare_clks(struct platform_device 
*pdev)
66  {
67  struct ci_hdrc_qoriq_data *data = platform_get_drvdata(pdev);
68  
69  clk_disable_unprepare(data->clk);
70  }
71  
72  static int ci_hdrc_qoriq_usb_setup(struct platform_device *pdev)
73  {
74  u32 reg;
75  struct resource *res;
76  struct devic

[PATCH v2 0/5] drivers: usb: chipidea: Add qoriq platform

2016-07-08 Thread Rajesh Bhagat
Adds qoriq platform driver for chipidea controller as well as
qoriq usb 2.0 phy driver. Also, enables chipidea driver and QorIQ
USB 2.0 PHY driver on LS1021A platform.

Rajesh Bhagat (5):
  drivers: usb: chipidea: Add qoriq platform driver
  usb: DT binding documentation for qoriq usb 2.0 controller
  drivers: usb: phy: Add qoriq usb 2.0 phy driver support
  phy: DT binding documentation for qoriq usb 2.0 phy
  arm: dts: ls1021a: enable chipidea driver and USB 2.0 PHY driver

 .../devicetree/bindings/phy/qoriq-usb2-phy.txt |  22 ++
 .../devicetree/bindings/usb/ci-hdrc-qoriq.txt  |  34 +++
 arch/arm/boot/dts/ls1021a.dtsi |  15 +-
 drivers/phy/Kconfig|   8 +
 drivers/phy/Makefile   |   1 +
 drivers/phy/phy-qoriq-usb2.c   | 228 
 drivers/phy/phy-qoriq-usb2.h   |  50 +
 drivers/usb/chipidea/Makefile  |   2 +
 drivers/usb/chipidea/ci_hdrc_qoriq.c   | 237 +
 drivers/usb/chipidea/ci_hdrc_qoriq.h   |  65 ++
 10 files changed, 661 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/phy/qoriq-usb2-phy.txt
 create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qoriq.txt
 create mode 100644 drivers/phy/phy-qoriq-usb2.c
 create mode 100644 drivers/phy/phy-qoriq-usb2.h
 create mode 100644 drivers/usb/chipidea/ci_hdrc_qoriq.c
 create mode 100644 drivers/usb/chipidea/ci_hdrc_qoriq.h

-- 
2.6.2.198.g614a2ac

--
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/5] arm: dts: ls1021a: enable chipidea driver and USB 2.0 PHY driver

2016-07-08 Thread Rajesh Bhagat
This patch adds entries in dts to enable chipidea platform driver
and USB 2.0 PHY driver.

Signed-off-by: Rajesh Bhagat 
---
Changes in v2:
 - Reworked for latest changes

 arch/arm/boot/dts/ls1021a.dtsi | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi
index 5ae8e92..bbba1ba 100644
--- a/arch/arm/boot/dts/ls1021a.dtsi
+++ b/arch/arm/boot/dts/ls1021a.dtsi
@@ -612,10 +612,23 @@
};
};
 
+   usbphy0: usbphy@860 {
+   compatible = "fsl,qoriq-usb2-phy",
+"fsl,qoriq-usb2-phy-v1.0";
+   reg = <0x0 0x860 0x0 0x1000>;
+   #phy-cells = <0>;
+   phy_type = "ulpi";
+   };
+
usb@860 {
-   compatible = "fsl-usb2-dr-v2.5", "fsl-usb2-dr";
+   compatible =  "fsl,ci-qoriq-usb2",
+ "fsl,ci-qoriq-usb2-v2.5";
reg = <0x0 0x860 0x0 0x1000>;
interrupts = ;
+   phy-names = "usb2-phy";
+   phys = <&usbphy0>;
+   clock-names = "usb2-clock";
+   clocks = <&platform_clk 1>;
dr_mode = "host";
phy_type = "ulpi";
};
-- 
2.6.2.198.g614a2ac

--
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/5] usb: DT binding documentation for qoriq usb 2.0 controller

2016-07-08 Thread Rajesh Bhagat
Describes the qoriq usb 2.0 controller driver binding, currently used
for LS1021A and LS1012A platform.

Signed-off-by: Rajesh Bhagat 
---
Changes in v2: 
 - Adds DT binding documentation for qoriq usb 2.0 controller
 - Changed the compatible string to fsl,ci-qoriq-usb2

 .../devicetree/bindings/usb/ci-hdrc-qoriq.txt  | 34 ++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/ci-hdrc-qoriq.txt

diff --git a/Documentation/devicetree/bindings/usb/ci-hdrc-qoriq.txt 
b/Documentation/devicetree/bindings/usb/ci-hdrc-qoriq.txt
new file mode 100644
index 000..8ad7306
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/ci-hdrc-qoriq.txt
@@ -0,0 +1,34 @@
+* Freescale QorIQ SoC USB 2.0 Controllers
+
+Required properties:
+- compatible: Should be "fsl,ci-qoriq-usb2"
+  Wherever applicable, the IP version of the USB controller should
+  also be mentioned (for eg. fsl,ci-qoriq-usb2-vX.Y).
+  where, X.Y is IP version of USB controller.
+- reg: Should contain registers location and length
+- interrupts: Should contain controller interrupt
+- phy-names: from the *Generic PHY* bindings
+- phys: from the *Generic PHY* bindings
+- clocks: clock provider specifier
+- clock-names: shall be "usb2-clock"
+Refer to clk/clock-bindings.txt for generic clock consumer properties
+
+Recommended properties:
+- dr_mode: One of "host" or "peripheral".
+- phy_type: the type of the phy connected to the core. Should be one
+  of "utmi", "utmi_wide", "ulpi", "serial" or "hsic". Without this
+  property the PORTSC register won't be touched
+
+Examples:
+usb@860 {
+   compatible =  "fsl,ci-qoriq-usb2",
+ "fsl,ci-qoriq-usb2-v2.5";
+   reg = <0x0 0x860 0x0 0x1000>;
+   interrupts = <0 139 0x4>;
+   phy-names = "usb2-phy";
+   phys = <&usbphy0>;
+   clock-names = "usb2-clock";
+   clocks = <&clockgen 4 3>;
+   dr_mode = "host";
+   phy_type = "ulpi";
+};
-- 
2.6.2.198.g614a2ac

--
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/5] drivers: usb: phy: Add qoriq usb 2.0 phy driver support

2016-07-08 Thread Rajesh Bhagat
Adds qoriq usb 2.0 phy driver support for LS1021A and LS1012A
platform.

Signed-off-by: Rajesh Bhagat 
---
Changes in v2:
 - Replaced Freescale with QorIQ in comments section
 - Changed the compatible string to fsl,qoriq-usb2-phy and added version
 - Added dependency on ARCH_MXC/ARCH_LAYERSCAPE and OF in Kconfig
 - Dropped CONFIG_ULPI #ifdefs to make code generic
 - Removed calls to devm free/release calls

 drivers/phy/Kconfig  |   8 ++
 drivers/phy/Makefile |   1 +
 drivers/phy/phy-qoriq-usb2.c | 228 +++
 drivers/phy/phy-qoriq-usb2.h |  50 ++
 4 files changed, 287 insertions(+)
 create mode 100644 drivers/phy/phy-qoriq-usb2.c
 create mode 100644 drivers/phy/phy-qoriq-usb2.h

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index b869b98..cc69299 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -434,4 +434,12 @@ config PHY_CYGNUS_PCIE
 
 source "drivers/phy/tegra/Kconfig"
 
+config PHY_QORIQ_USB2
+   tristate "QorIQ USB 2.0 PHY driver"
+   depends on ARCH_MXC || ARCH_LAYERSCAPE
+   depends on OF
+   select GENERIC_PHY
+   help
+ Enable this to support the USB2.0 PHY on the QorIQ SoC.
+
 endmenu
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 9c3e73c..044105a 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -53,5 +53,6 @@ obj-$(CONFIG_PHY_TUSB1210)+= phy-tusb1210.o
 obj-$(CONFIG_PHY_BRCM_SATA)+= phy-brcm-sata.o
 obj-$(CONFIG_PHY_PISTACHIO_USB)+= phy-pistachio-usb.o
 obj-$(CONFIG_PHY_CYGNUS_PCIE)  += phy-bcm-cygnus-pcie.o
+obj-$(CONFIG_PHY_QORIQ_USB2)+= phy-qoriq-usb2.o
 
 obj-$(CONFIG_ARCH_TEGRA) += tegra/
diff --git a/drivers/phy/phy-qoriq-usb2.c b/drivers/phy/phy-qoriq-usb2.c
new file mode 100644
index 000..f74d255
--- /dev/null
+++ b/drivers/phy/phy-qoriq-usb2.c
@@ -0,0 +1,228 @@
+/*
+ * QorIQ SoC USB 2.0 PHY driver
+ *
+ * Copyright 2016 Freescale Semiconductor, Inc.
+ * Author: Rajesh Bhagat 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "phy-qoriq-usb2.h"
+
+static int qoriq_usb2_phy_init(struct phy *_phy)
+{
+   struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
+   struct device *dev = ctx->dev;
+
+   if (ctx->ulpi_phy) {
+   if (usb_phy_init(ctx->ulpi_phy)) {
+   dev_err(dev, "unable to init transceiver, probably 
missing\n");
+   return -ENODEV;
+   }
+   }
+
+   return 0;
+}
+
+static int qoriq_usb2_phy_power_on(struct phy *_phy)
+{
+   struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
+   u32 flags;
+
+   if (ctx->ulpi_phy) {
+   flags = usb_phy_io_read(ctx->ulpi_phy, ULPI_OTG_CTRL);
+   usb_phy_io_write(ctx->ulpi_phy, flags |
+(ULPI_OTG_CTRL_DRVVBUS_EXT |
+ULPI_OTG_CTRL_EXTVBUSIND), ULPI_OTG_CTRL);
+   flags = usb_phy_io_read(ctx->ulpi_phy, ULPI_IFC_CTRL);
+   usb_phy_io_write(ctx->ulpi_phy, flags |
+(ULPI_IFC_CTRL_EXTERNAL_VBUS |
+ULPI_IFC_CTRL_PASSTHRU), ULPI_IFC_CTRL);
+   }
+
+   return 0;
+}
+
+static int qoriq_usb2_phy_power_off(struct phy *_phy)
+{
+   /* TODO: Add logic to power off phy */
+
+   return 0;
+}
+
+static int qoriq_usb2_phy_exit(struct phy *_phy)
+{
+   struct qoriq_usb2_phy_ctx *ctx = phy_get_drvdata(_phy);
+
+   if (ctx->ulpi_phy)
+   usb_phy_shutdown(ctx->ulpi_phy);
+
+   return 0;
+}
+
+static const struct phy_ops ops = {
+   .init   = qoriq_usb2_phy_init,
+   .power_on   = qoriq_usb2_phy_power_on,
+   .power_off  = qoriq_usb2_phy_power_off,
+   .exit   = qoriq_usb2_phy_exit,
+   .owner  = THIS_MODULE,
+};
+
+
+static enum qoriq_usb2_phy_ver of_usb_get_phy_version(struct device_node *np)
+{
+   enum qoriq_usb2_phy_ver phy_version = QORIQ_PHY_UNKNOWN;
+
+   if (of_device_is_compatible(np, "fsl,qoriq-usb2-phy")) {
+   if (of_device_is_compatible(np, "fsl,qoriq-usb2-phy-v1.0"))
+   phy_version = QORIQ_PHY_LEGACY;
+   else if (of_device_is_compatible(np, "fsl,qoriq-usb2-phy-v2.0"))
+   phy_version = QORIQ_PHY_NXP_ISP1508;
+   }
+   return phy_version;
+}
+
+static int qoriq_usb2_phy_probe(struct platform_device *pdev)
+{
+   int ret;
+   struct resource *res;
+   struct qoriq_usb2_phy_ctx *ctx;
+   struct device *dev = &pdev->dev;
+   const struct of_device_id *of_id;
+   struct phy_pr

[PATCH v2 1/5] drivers: usb: chipidea: Add qoriq platform driver

2016-07-08 Thread Rajesh Bhagat
Adds qoriq platform driver for chipidea controller,
verfied on LS1021A and LS1012A platforms.

Signed-off-by: Rajesh Bhagat 
---
Changes in v2:
 - Replaced Freescale with QorIQ in comments section
 - Added macros to remove hardcoding while programming registers
 - Changed the compatible string to fsl,ci-qoriq-usb2 and added version
 - Removed calls to devm free/release calls 

 drivers/usb/chipidea/Makefile|   2 +
 drivers/usb/chipidea/ci_hdrc_qoriq.c | 237 +++
 drivers/usb/chipidea/ci_hdrc_qoriq.h |  65 ++
 3 files changed, 304 insertions(+)
 create mode 100644 drivers/usb/chipidea/ci_hdrc_qoriq.c
 create mode 100644 drivers/usb/chipidea/ci_hdrc_qoriq.h

diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
index 518e445..3122b86b 100644
--- a/drivers/usb/chipidea/Makefile
+++ b/drivers/usb/chipidea/Makefile
@@ -14,3 +14,5 @@ obj-$(CONFIG_USB_CHIPIDEA)+= ci_hdrc_zevio.o
 obj-$(CONFIG_USB_CHIPIDEA_PCI) += ci_hdrc_pci.o
 
 obj-$(CONFIG_USB_CHIPIDEA_OF)  += usbmisc_imx.o ci_hdrc_imx.o
+
+obj-$(CONFIG_USB_CHIPIDEA)  += ci_hdrc_qoriq.o
diff --git a/drivers/usb/chipidea/ci_hdrc_qoriq.c 
b/drivers/usb/chipidea/ci_hdrc_qoriq.c
new file mode 100644
index 000..3f478c6
--- /dev/null
+++ b/drivers/usb/chipidea/ci_hdrc_qoriq.c
@@ -0,0 +1,237 @@
+/*
+ * QorIQ SoC USB 2.0 Controller driver
+ *
+ * Copyright 2016 Freescale Semiconductor, Inc.
+ * Author: Rajesh Bhagat 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "ci.h"
+#include "ci_hdrc_qoriq.h"
+
+struct ci_hdrc_qoriq_data {
+   struct phy *phy;
+   struct clk *clk;
+   void __iomem *qoriq_regs;
+   struct platform_device *ci_pdev;
+   enum usb_phy_interface phy_mode;
+};
+
+/*
+ * clock helper functions
+ */
+static int ci_hdrc_qoriq_get_clks(struct platform_device *pdev)
+{
+   int ret;
+   struct device *dev = &pdev->dev;
+   struct ci_hdrc_qoriq_data *data = platform_get_drvdata(pdev);
+
+   data->clk = devm_clk_get(dev, "usb2-clock");
+   if (IS_ERR(data->clk)) {
+   dev_err(dev, "failed to get clk, err=%ld\n",
+   PTR_ERR(data->clk));
+   return ret;
+   }
+   return 0;
+}
+
+static int ci_hdrc_qoriq_prepare_enable_clks(struct platform_device *pdev)
+{
+   int ret;
+   struct device *dev = &pdev->dev;
+   struct ci_hdrc_qoriq_data *data = platform_get_drvdata(pdev);
+
+   ret = clk_prepare_enable(data->clk);
+   if (ret) {
+   dev_err(dev, "failed to prepare/enable clk, err=%d\n", ret);
+   return ret;
+   }
+   return 0;
+}
+
+static void ci_hdrc_qoriq_disable_unprepare_clks(struct platform_device *pdev)
+{
+   struct ci_hdrc_qoriq_data *data = platform_get_drvdata(pdev);
+
+   clk_disable_unprepare(data->clk);
+}
+
+static int ci_hdrc_qoriq_usb_setup(struct platform_device *pdev)
+{
+   u32 reg;
+   struct resource *res;
+   struct device *dev = &pdev->dev;
+   struct ci_hdrc_qoriq_data *data = platform_get_drvdata(pdev);
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!res) {
+   dev_err(dev, "failed to get I/O memory\n");
+   return -ENOENT;
+   }
+
+   dev_dbg(dev, "res->start %llx, resource_size(res) %llx\n", res->start,
+   resource_size(res));
+   data->qoriq_regs = devm_ioremap(dev, res->start, resource_size(res));
+   if (IS_ERR(data->qoriq_regs)) {
+   dev_err(dev, "failed to remap I/O memory\n");
+   return -ENOMEM;
+   }
+
+   data->phy_mode = of_usb_get_phy_mode(pdev->dev.of_node);
+   dev_dbg(dev, "phy_mode %d\n", data->phy_mode);
+
+   reg = ioread32be(data->qoriq_regs + QORIQ_SOC_USB_CTRL);
+   switch (data->phy_mode) {
+   case USBPHY_INTERFACE_MODE_ULPI:
+   iowrite32be(reg | ~UTMI_PHY_EN,
+   data->qoriq_regs + QORIQ_SOC_USB_CTRL);
+   reg = ioread32be(data->qoriq_regs + QORIQ_SOC_USB_CTRL);
+   iowrite32be(reg | USB_CTRL_USB_EN,
+   data->qoriq_regs + QORIQ_SOC_USB_CTRL);
+   break;
+   default:
+   dev_err(dev, "unsupported phy_mode %d\n", data->phy_mode);
+   return -EINVAL;
+   }
+
+   /* Setup Snooping for all the 4GB space */
+   /* SNOOP1 starts from 0x0, size 2G */
+   iowrite32be(SNOOP_SIZE_2GB, data->qoriq_regs + QORIQ_SOC_USB_SNOOP1);
+   /* SNOOP2 starts from 0x8000, size 2G */
+   iowrite32be(SNOOP_SIZE_2GB | 0x8000,
+   data->qoriq_regs + QORIQ_SOC_USB_SNOOP2);
+
+   iowrite32be(PRICTRL_PRI_LVL, data->q

[PATCH v2 4/5] phy: DT binding documentation for qoriq usb 2.0 phy

2016-07-08 Thread Rajesh Bhagat
Describes the qoriq usb 2.0 phy driver binding, currently used
for LS1021A and LS1012A platform.

Signed-off-by: Rajesh Bhagat 
---
Changes in v2:
 - Adds DT binding documentation for qoriq usb 2.0 phy
 - Changed the compatible string to fsl,qoriq-usb2-phy

 .../devicetree/bindings/phy/qoriq-usb2-phy.txt | 22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/qoriq-usb2-phy.txt

diff --git a/Documentation/devicetree/bindings/phy/qoriq-usb2-phy.txt 
b/Documentation/devicetree/bindings/phy/qoriq-usb2-phy.txt
new file mode 100644
index 000..f043855
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/qoriq-usb2-phy.txt
@@ -0,0 +1,22 @@
+QorIQ SoC USB 2.0 PHY
+
+Required properties:
+ - compatible: should be "fsl,qoriq-usb2-phy",
+   Wherever applicable, the version of the USB PHY should
+   also be mentioned (for eg. fsl,qoriq-usb2-phy-vX.Y).
+   where, X = Phy vendor(Legacy = 1, NXP = 2) and Y = PHY version
+ - reg : Address and length of the usb phy control register set.
+ - phy_type : For multi port host USB controllers, should be one of
+   "ulpi", or "serial". For dual role USB controllers, should be
+   one of "ulpi", "utmi", "utmi_wide", or "serial".
+
+The main purpose of this PHY driver is to enable the USB PHY reference clock
+gate on the QorIQ SOC for USB2 PHY OR implement errata workaround in
+future. Otherwise it is just an NOP PHY driver.
+
+usbphy0: usbphy@860 {
+compatible = "fsl,qoriq-usb2-phy" "fsl,qoriq-usb2-phy-vX.Y";
+reg = <0x0 0x860 0x0 0x1000>;
+#phy-cells = <0>;
+phy_type = "ulpi";
+};
-- 
2.6.2.198.g614a2ac

--
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 net] r8152: remove the setting of LAN_WAKE_EN

2016-07-08 Thread David Miller
From: Hayes Wang 
Date: Wed, 6 Jul 2016 17:03:29 +0800

> The LAN_WAKE_EN is not used to determine if the device could support
> WOL. It is used to sigal a GPIO pin when a WOL event occurs. The WOL
> still works even though it is disabled.
> 
> Signed-off-by: Hayes Wang 

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


Re: [PATCH v6 3/5] usb: dwc3: add phyif_utmi_quirk

2016-07-08 Thread William.wu

Dear Heiko & Balbi,


On 2016/7/8 21:29, Felipe Balbi wrote:

Hi,

Heiko Stuebner  writes:

Am Donnerstag, 7. Juli 2016, 10:54:24 schrieb William Wu:

Add a quirk to configure the core to support the
UTMI+ PHY with an 8- or 16-bit interface. UTMI+ PHY
interface is hardware property, and it's platform
dependent. Normall, the PHYIf can be configured
during coreconsultant. But for some specific usb
cores(e.g. rk3399 soc dwc3), the default PHYIf
configuration value is fault, so we need to
reconfigure it by software.

And refer to the dwc3 databook, the GUSB2PHYCFG.USBTRDTIM
must be set to the corresponding value according to
the UTMI+ PHY interface.

Signed-off-by: William Wu 
---

[...]

diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt
b/Documentation/devicetree/bindings/usb/dwc3.txt index 020b0e9..8d7317d
100644
--- a/Documentation/devicetree/bindings/usb/dwc3.txt
+++ b/Documentation/devicetree/bindings/usb/dwc3.txt
@@ -42,6 +42,10 @@ Optional properties:
   - snps,dis-u2-freeclk-exists-quirk: when set, clear the
u2_freeclk_exists in GUSB2PHYCFG, specify that USB2 PHY doesn't provide
a free-running PHY clock.
+ - snps,phyif-utmi-quirk: when set core will set phyif UTMI+ interface.
+ - snps,phyif-utmi: the value to configure the core to support a UTMI+
PHY +   with an 8- or 16-bit interface. Value 0 select 8-bit
+   interface, value 1 select 16-bit interface.

maybe
snps,phyif-utmi-width = <8> or <16>;

devicetree is about describing the hardware, not the things that get written
to registers :-) . The conversion from the described width to the register
value can easily be done in the driver.

Thanks for your suggestion:-)
Yes, “snps,phyif-utmi-width = <8> or <16>” is much clearer and easier to 
understand.
And I have considered the same dts property for phyif-utmi, but I have 
no good idea about
the conversion from described width to the registers value for the time 
being.


About phyif utmi width configuration, we need to set two places in 
GUSB2PHYCFG register,
according to DWC3 USB3.0 controller databook version3.00a,6.3.46 
GUSB2PHYCFG


--
Bits   |  Name | Description
--
  13:10  |   USBTRDTIM   | Sets the turnaround time in PHY clocks.
|| 4'h5: When the MAC 
interface is 16-bit UTMI+
|| 4'h9: When the MAC 
interface is 8-bit UTMI+/ULPI.

--
  3|   PHYIF|If UTMI+ is selected, the 
application uses this bit to configure
||core to support a UTMI+ 
PHY with an 8- or 16-bit interface.

||1'b0: 8 bits
||1'b1: 16 bits
--

And I think maybe I can try to do this:
change it in dts:
snps,phyif-utmi-width = <8> or <16>;

Then convert to register value like this:
   device_property_read_u8(dev, "snps,phyif-utmi-width",
 &phyif_utmi_width);

   dwc->phyif_utmi = phyif_utmi_width >> 4;

 Ater the conversion, dwc->phyif_utmi value 0 means 8 bits, value 1 
means 16 bits,

 and it's easier for us to config GUSB2PHYCFG.

Is it OK?




Also I don't think you need two properties for this. If the snps,phyif-utmi
property is specified it indicates that you want to manually set the width
and if it is absent you want to use the IC default. All functions reading
property-values indicate if the property is missing.

Ah, it seems very good to me. One dts property "snps,phyif-utmi" can help to
reconfig phyif utmi width. And it seems that Felipe likes it very much 
too. :-D

But it looks like there is already a precendence in
snps,tx_de_emphasis(_quirk), so maybe Felipe has a different opinion here?




   - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
utmi_l1_suspend_n, false when asserts utmi_sleep_n
   - snps,hird-threshold: HIRD threshold
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 0b7bfd2..94036b1 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -408,6 +408,7 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
  static int dwc3_phy_setup(struct dwc3 *dwc)
  {
u32 reg;
+   u32 usbtrdtim;
int ret;

reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
@@ -503,6 +504,15 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
if (dwc->dis_u2_freeclk_exists_quirk)
reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;

+   if (dwc->phyif_ut

Re: [PATCH v2] input: tablet: pegasus_notetaker: USB PM fixes

2016-07-08 Thread Dmitry Torokhov
On Tue, Jun 28, 2016 at 06:17:13PM +0200, Martin Kepplinger wrote:
> Am 2016-06-23 um 19:18 schrieb Dmitry Torokhov:
> > Hi Martin,
> > 
> > On Tue, Jun 14, 2016 at 01:20:15PM +0200, Martin Kepplinger wrote:
> >>  static int pegasus_reset_resume(struct usb_interface *intf)
> >>  {
> >> +  struct pegasus *pegasus = usb_get_intfdata(intf);
> >> +
> >> +  if (pegasus->dev->users)
> >> +  pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE);
> >> +
> >>return pegasus_resume(intf);
> > 
> > Hmm, we need to take input mutex when using pegasus->dev->users, how
> > about the version below instead?
> > 
> > Thanks.
> > 
> 
> Sorry for the delay, give me a few more days to test and confirm this or
> come up with a final patch.

Martin, did you have time to try out this version of the patch?

Thanks!

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


[PATCH 3/3] usb: phy: generic: remove the vbus dependency

2016-07-08 Thread Robert Jarzmik
As the last known user, ie. pxa27x_udc relying on calls to
usb_gadget_xxx() was amended to use the phy notifier, remove a bit the
USB stack adherence.

Actually the driver still uses the gadget API for structures definition,
but the implementation of USB gadget specific function usb_gadget_*() is
not necessary anymore.

Signed-off-by: Robert Jarzmik 
---
 drivers/usb/phy/phy-generic.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 41b8aff9b925..c14e767a3fbf 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -118,8 +118,6 @@ static irqreturn_t nop_gpio_vbus_thread(int irq, void *data)
status = USB_EVENT_VBUS;
otg->state = OTG_STATE_B_PERIPHERAL;
nop->phy.last_event = status;
-   if (otg->gadget)
-   usb_gadget_vbus_connect(otg->gadget);
 
/* drawing a "unit load" is *always* OK, except for OTG */
nop_set_vbus_draw(nop, 100);
@@ -129,8 +127,6 @@ static irqreturn_t nop_gpio_vbus_thread(int irq, void *data)
} else {
nop_set_vbus_draw(nop, 0);
 
-   if (otg->gadget)
-   usb_gadget_vbus_disconnect(otg->gadget);
status = USB_EVENT_NONE;
otg->state = OTG_STATE_B_IDLE;
nop->phy.last_event = status;
@@ -187,7 +183,8 @@ static int nop_set_peripheral(struct usb_otg *otg, struct 
usb_gadget *gadget)
 
otg->gadget = gadget;
if (otg->state == OTG_STATE_B_PERIPHERAL)
-   usb_gadget_vbus_connect(gadget);
+   atomic_notifier_call_chain(&otg->usb_phy->notifier,
+  USB_EVENT_VBUS, otg->gadget);
else
otg->state = OTG_STATE_B_IDLE;
return 0;
-- 
2.1.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 2/3] usb: phy: generic: cope with initial state

2016-07-08 Thread Robert Jarzmik
In the gpio based case, the status of the phy is known at start by
reading the VBus gpio.

Actually, this is a fix, as this initial state, when not set up,
prevents a gadget to answer to the enumeration phase, as there is no
notification in this case (the VBus is already high when kernel boots)
so no interrupt is triggered, and the flow is :
 - gadget initializes
 - gadget gets its phy-generic with a xxx_get_phy_xxx() call type
 - gadget does a "set_peripheral()" call type
   => here if the otg->state is correctly filled, the proper vbus
   handling will be called, and the gadget will be aware it should
   answer enumeration and go forth

Without this fix, the USB cable must be removed and replugged for any
gadget relying on phy-generic and its gpio vbus handling to work.

The problem was seen on a pxa27x architecture based board on a
devicetree build.

Signed-off-by: Robert Jarzmik 
---
 drivers/usb/phy/phy-generic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index 980c9dee09eb..41b8aff9b925 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -322,6 +322,8 @@ static int usb_phy_generic_probe(struct platform_device 
*pdev)
gpiod_to_irq(nop->gpiod_vbus), err);
return err;
}
+   nop->phy.otg->state = gpiod_get_value(nop->gpiod_vbus) ?
+   OTG_STATE_B_PERIPHERAL : OTG_STATE_B_IDLE;
}
 
nop->phy.init   = usb_gen_phy_init;
-- 
2.1.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 1/3] usb: gadget: pxa27x: add phy notifier event handler

2016-07-08 Thread Robert Jarzmik
In the legacy behavior, and USB phy, upon detection a VBus signal, was
calling usb_gadget_vbus_(dis)connect().

This model doesn't work if the phy is generic and doesn't have an
adherence to the gadget API.

Instead of relying on the phy to call the gadget API, hook up the phy
notifier to report the VBus event, and upon it call the usb gadget API
ourselves.

This brings a new ordering problem, as before even if the usb_get_phy()
was failing because the UDC was probed before the phy, the phy would
call the gadget anyway, making the VBus connection event forwarded to
the gadget. Now we rely on the notifier, we have to ensure the
xxx_get_phy() does indeed work.

In order to cope with this, it is assumed that :
 - for legacy platform_data machine, as the ordering cannot be ensured,
   the phy must call usb_gadget_vbus_(dis)connect, such as
   phy-gpio-vbus-usb.c
 - for new devicetree platforms, we'll rely on the probe deferral, and
   the phy can be gadget API agnostic.

Signed-off-by: Robert Jarzmik 
---
 drivers/usb/gadget/udc/pxa27x_udc.c | 51 +++--
 1 file changed, 49 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/pxa27x_udc.c 
b/drivers/usb/gadget/udc/pxa27x_udc.c
index 001a3b74a993..79643e25a5bb 100644
--- a/drivers/usb/gadget/udc/pxa27x_udc.c
+++ b/drivers/usb/gadget/udc/pxa27x_udc.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "pxa27x_udc.h"
 
@@ -1655,6 +1656,37 @@ static int pxa_udc_vbus_draw(struct usb_gadget *_gadget, 
unsigned mA)
return -EOPNOTSUPP;
 }
 
+/**
+ * pxa_udc_phy_event - Called by phy upon VBus event
+ * @nb: notifier block
+ * @action: phy action, is vbus connect or disconnect
+ * @data: the usb_gadget structure in pxa_udc
+ *
+ * Called by the USB Phy when a cable connect or disconnect is sensed.
+ *
+ * Returns 0
+ */
+static int pxa_udc_phy_event(struct notifier_block *nb, unsigned long action,
+void *data)
+{
+   struct usb_gadget *gadget = data;
+
+   switch (action) {
+   case USB_EVENT_VBUS:
+   usb_gadget_vbus_connect(gadget);
+   return NOTIFY_OK;
+   case USB_EVENT_NONE:
+   usb_gadget_vbus_disconnect(gadget);
+   return NOTIFY_OK;
+   default:
+   return NOTIFY_DONE;
+   }
+}
+
+static struct notifier_block pxa27x_udc_phy = {
+   .notifier_call = pxa_udc_phy_event,
+};
+
 static int pxa27x_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver);
 static int pxa27x_udc_stop(struct usb_gadget *g);
@@ -2435,7 +2467,14 @@ static int pxa_udc_probe(struct platform_device *pdev)
return udc->irq;
 
udc->dev = &pdev->dev;
-   udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+   if (of_have_populated_dt()) {
+   udc->transceiver =
+   devm_usb_get_phy_by_phandle(udc->dev, "phys", 0);
+   if (IS_ERR(udc->transceiver))
+   return PTR_ERR(udc->transceiver);
+   } else {
+   udc->transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
+   }
 
if (IS_ERR(udc->gpiod)) {
dev_err(&pdev->dev, "Couldn't find or request D+ gpio : %ld\n",
@@ -2468,14 +2507,20 @@ static int pxa_udc_probe(struct platform_device *pdev)
goto err;
}
 
+   if (!IS_ERR_OR_NULL(udc->transceiver))
+   usb_register_notifier(udc->transceiver, &pxa27x_udc_phy);
retval = usb_add_gadget_udc(&pdev->dev, &udc->gadget);
if (retval)
-   goto err;
+   goto err_add_gadget;
 
pxa_init_debugfs(udc);
if (should_enable_udc(udc))
udc_enable(udc);
return 0;
+
+err_add_gadget:
+   if (!IS_ERR_OR_NULL(udc->transceiver))
+   usb_unregister_notifier(udc->transceiver, &pxa27x_udc_phy);
 err:
clk_unprepare(udc->clk);
return retval;
@@ -2492,6 +2537,8 @@ static int pxa_udc_remove(struct platform_device *_dev)
usb_del_gadget_udc(&udc->gadget);
pxa_cleanup_debugfs(udc);
 
+   if (!IS_ERR_OR_NULL(udc->transceiver))
+   usb_unregister_notifier(udc->transceiver, &pxa27x_udc_phy);
usb_put_phy(udc->transceiver);
 
udc->transceiver = NULL;
-- 
2.1.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] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-08 Thread Michal Nazarewicz
On Fri, Jul 08 2016, Felipe Balbi wrote:
> My take on this is that it's calling max_t() to try and align to
> wMaxPacketSize. We can see from original commit what was the intent:
>
> commit 03d27ade4941076b34c823d63d91dc895731a595
> Author: Felipe F. Tonello 
> Date:   Wed Mar 9 19:39:30 2016 +
>
> usb: gadget: f_midi: Fixed a bug when buflen was smaller than 
> wMaxPacketSize
> 
> buflen by default (256) is smaller than wMaxPacketSize (512) in high-speed
> devices.
> 
> That caused the OUT endpoint to freeze if the host send any data packet of
> length greater than 256 bytes.
> 
> This is an example dump of what happended on that enpoint:
> HOST:   [DATA][Length=260][...]
> DEVICE: [NAK]
> HOST:   [PING]
> DEVICE: [NAK]
> HOST:   [PING]
> DEVICE: [NAK]
> ...
> HOST:   [PING]
> DEVICE: [NAK]
> 
> This patch fixes this problem by setting the minimum usb_request's buffer 
> size
> for the OUT endpoint as its wMaxPacketSize.
> 
> Acked-by: Michal Nazarewicz 
> Signed-off-by: Felipe F. Tonello 
> Signed-off-by: Felipe Balbi 
>
> diff --git a/drivers/usb/gadget/function/f_midi.c 
> b/drivers/usb/gadget/function/f_midi.c
> index 56e2dde99b03..9ad51dcab982 100644
> --- a/drivers/usb/gadget/function/f_midi.c
> +++ b/drivers/usb/gadget/function/f_midi.c
> @@ -360,7 +360,9 @@ static int f_midi_set_alt(struct usb_function *f, 
> unsigned intf, unsigned alt)
>   /* allocate a bunch of read buffers and queue them all at once. */
>   for (i = 0; i < midi->qlen && err == 0; i++) {
>   struct usb_request *req =
> - midi_alloc_ep_req(midi->out_ep, midi->buflen);
> + midi_alloc_ep_req(midi->out_ep,
> + max_t(unsigned, midi->buflen,
> + bulk_out_desc.wMaxPacketSize));
>   if (req == NULL)
>   return -ENOMEM;
>
> Seems to me usb_ep_align_maybe() would cover this case just as well. But
> then, Felipe's UDC driver seems to need quirk_ep_out_aligned_size. Felipe?

In that case, I agree that max is likely unnecessary.

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
--
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: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-08 Thread Michal Nazarewicz
> Baolin Wang  writes:
>> @@ -359,10 +361,12 @@ static int f_midi_set_alt(struct usb_function *f, 
>> unsigned intf, unsigned alt)
>>  
>>  /* allocate a bunch of read buffers and queue them all at once. */
>>  for (i = 0; i < midi->qlen && err == 0; i++) {
>> -struct usb_request *req =
>> -midi_alloc_ep_req(midi->out_ep,
>> -max_t(unsigned, midi->buflen,
>> -bulk_out_desc.wMaxPacketSize));
>> +struct usb_request *req;
>> +
>> +length = usb_ep_align_maybe(midi->gadget, midi->out_ep,
>> +midi->buflen);

On Fri, Jul 08 2016, Felipe Balbi wrote:
> after calling usb_ep_align_maybe()...
>
>> +req = midi_alloc_ep_req(midi->out_ep,
>> +max_t(unsigned, length, bulk_out_desc.wMaxPacketSize));
>
> ... max_t() is pointless. length will *always* >= wMaxPacketSize.

That is only true for gadgets with the quirk.  usb_ep_align_maybe is
a noöp for gadgets without the quirk.

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
--
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 1/2] usb: gadget: legacy: Add udc module param to all legacy gadgets

2016-07-08 Thread Krzysztof Opasiak


On 07/08/2016 08:56 AM, Peter Chen wrote:
> On Thu, Jul 07, 2016 at 02:17:57PM +0200, Krzysztof Opasiak wrote:
>> Add new module parameter called "udc" to all legacy gadgets.
>> By using this parameter user can choose a controller towhich
>> this gadget should be bound.
>>
>> This may be useful esp. when having multiple controllers
>> or multiple gadget builtin.
>>
>> When value for this param is not provided then old behaviour
>> (binding to first free UDC) remains unchanged.
>>
>> Signed-off-by: Krzysztof Opasiak 
>> ---

(...)

> 
> Tested-by: Peter Chen 
> 
> One suggestion, you can move this udc name module parameter to 
> USB_GADGET_COMPOSITE_OPTIONS().   
> 

It was exactly my first though when I suggested this change.

Unfortunately it turned out to be a little to messy when I implemented this.

Currently USB_GADGET_COMPOSITE_OPTIONS() declares inside an additional
variable (coverwrite) which is used inside gadget's bind() function.
Unfortunately gadget's bind() is called *after* binding to some UDC so
it's too late to read udc_name param. C also doesn't allows us to do sth
like this:

char *udc_name;

(...)

struct whatever w = {
.udc_name = udc_name;
};

So just like in the new macro we would have to add a parameter and move
all macro calls below gadget member or declare a gadget before calling
this macro. This will make this change bigger and in my humble opinion
it hurts readability as part of macro is filling a variable declared
inside macro and other part is filling structure passed as a param.
That's why I decided to keep this separated in two macros called
independently (one before gadget structure and second one after).

Best regards,
-- 
Krzysztof Opasiak
Samsung R&D Institute Poland
Samsung Electronics
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 3/5] usb: dwc3: add phyif_utmi_quirk

2016-07-08 Thread Felipe Balbi

Hi,

Heiko Stuebner  writes:
> Am Donnerstag, 7. Juli 2016, 10:54:24 schrieb William Wu:
>> Add a quirk to configure the core to support the
>> UTMI+ PHY with an 8- or 16-bit interface. UTMI+ PHY
>> interface is hardware property, and it's platform
>> dependent. Normall, the PHYIf can be configured
>> during coreconsultant. But for some specific usb
>> cores(e.g. rk3399 soc dwc3), the default PHYIf
>> configuration value is fault, so we need to
>> reconfigure it by software.
>> 
>> And refer to the dwc3 databook, the GUSB2PHYCFG.USBTRDTIM
>> must be set to the corresponding value according to
>> the UTMI+ PHY interface.
>> 
>> Signed-off-by: William Wu 
>> ---
> [...]
>> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt
>> b/Documentation/devicetree/bindings/usb/dwc3.txt index 020b0e9..8d7317d
>> 100644
>> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
>> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
>> @@ -42,6 +42,10 @@ Optional properties:
>>   - snps,dis-u2-freeclk-exists-quirk: when set, clear the
>> u2_freeclk_exists in GUSB2PHYCFG, specify that USB2 PHY doesn't provide
>>  a free-running PHY clock.
>> + - snps,phyif-utmi-quirk: when set core will set phyif UTMI+ interface.
>> + - snps,phyif-utmi: the value to configure the core to support a UTMI+
>> PHY +with an 8- or 16-bit interface. Value 0 select 
>> 8-bit
>> +interface, value 1 select 16-bit interface.
>
> maybe
>   snps,phyif-utmi-width = <8> or <16>;
>
> devicetree is about describing the hardware, not the things that get written 
> to registers :-) . The conversion from the described width to the register 
> value can easily be done in the driver.
>
>
> Also I don't think you need two properties for this. If the snps,phyif-utmi 
> property is specified it indicates that you want to manually set the width 
> and if it is absent you want to use the IC default. All functions reading 
> property-values indicate if the property is missing.
>
> But it looks like there is already a precendence in 
> snps,tx_de_emphasis(_quirk), so maybe Felipe has a different opinion here?
>
>
>
>>   - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
>>  utmi_l1_suspend_n, false when asserts utmi_sleep_n
>>   - snps,hird-threshold: HIRD threshold
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index 0b7bfd2..94036b1 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -408,6 +408,7 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
>>  static int dwc3_phy_setup(struct dwc3 *dwc)
>>  {
>>  u32 reg;
>> +u32 usbtrdtim;
>>  int ret;
>> 
>>  reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
>> @@ -503,6 +504,15 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
>>  if (dwc->dis_u2_freeclk_exists_quirk)
>>  reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
>> 
>> +if (dwc->phyif_utmi_quirk) {
>> +reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK |
>> +   DWC3_GUSB2PHYCFG_USBTRDTIM_MASK);
>> +usbtrdtim = dwc->phyif_utmi ? USBTRDTIM_UTMI_16_BIT :
>> +USBTRDTIM_UTMI_8_BIT;
>> +reg |= DWC3_GUSB2PHYCFG_PHYIF(dwc->phyif_utmi) |
>> +   DWC3_GUSB2PHYCFG_USBTRDTIM(usbtrdtim);
>> +}
>> +
>>  dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
>> 
>>  return 0;
>> @@ -834,6 +844,7 @@ static int dwc3_probe(struct platform_device *pdev)
>>  struct resource *res;
>>  struct dwc3 *dwc;
>>  u8  lpm_nyet_threshold;
>> +u8  phyif_utmi;
>>  u8  tx_de_emphasis;
>>  u8  hird_threshold;
>> 
>> @@ -880,6 +891,9 @@ static int dwc3_probe(struct platform_device *pdev)
>>  /* default to highest possible threshold */
>>  lpm_nyet_threshold = 0xff;
>> 
>> +/* default to UTMI+ 8-bit interface */
>> +phyif_utmi = 0;
>> +
>>  /* default to -3.5dB de-emphasis */
>>  tx_de_emphasis = 1;
>> 
>> @@ -929,6 +943,10 @@ static int dwc3_probe(struct platform_device *pdev)
>>  "snps,dis_rxdet_inp3_quirk");
>>  dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev,
>>  "snps,dis-u2-freeclk-exists-quirk");
>> +dwc->phyif_utmi_quirk = device_property_read_bool(dev,
>> +"snps,phyif-utmi-quirk");
>> + device_property_read_u8(dev, "snps,phyif-utmi",
>> + &phyif_utmi);
>
>
> As described above device_property_read_u8 will return an error if the 
> property is not present, so you could fill your dwc->phyif_utmi_quirk from 
> that:
>
>   ret = device_property_read_u8(dev, "snps,phyif-utmi",
>&phyif_utmi);
>   dwc->phyif_utmi_quirk = (ret == 0) ? true : false;

I like this much better :-) Unfortunately can't fix tx_deemp

Re: [PATCH] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-08 Thread Felipe Balbi

Hi again,

Felipe Balbi  writes:
> Michal Nazarewicz  writes:
>> On Fri, Jul 08 2016, Baolin Wang wrote:
>>> On 7 July 2016 at 20:51, Michal Nazarewicz  wrote:
 On Thu, Jul 07 2016, Baolin Wang wrote:
> Some gadget device (such as dwc3 gadget) requires 
> quirk_ep_out_aligned_size
> attribute, which means it need to align the request buffer's size to an 
> ep's
> maxpacketsize.
>
> Thus we add usb_ep_align_maybe() function to check if it is need to align
> the request buffer's size to an ep's maxpacketsize.
>
> Signed-off-by: Baolin Wang 

 Acked-by: Michal Nazarewicz 

> ---
>  drivers/usb/gadget/function/f_midi.c |   18 +++---
>  1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_midi.c 
> b/drivers/usb/gadget/function/f_midi.c
> index 58fc199..2e3f11e 100644
> --- a/drivers/usb/gadget/function/f_midi.c
> +++ b/drivers/usb/gadget/function/f_midi.c
> @@ -328,7 +328,7 @@ static int f_midi_start_ep(struct f_midi *midi,
>  static int f_midi_set_alt(struct usb_function *f, unsigned intf, 
> unsigned alt)
>  {
>   struct f_midi *midi = func_to_midi(f);
> - unsigned i;
> + unsigned i, length;
>   int err;
>
>   /* we only set alt for MIDIStreaming interface */
> @@ -345,9 +345,11 @@ static int f_midi_set_alt(struct usb_function *f, 
> unsigned intf, unsigned alt)
>
>   /* pre-allocate write usb requests to use on f_midi_transmit. */
>   while (kfifo_avail(&midi->in_req_fifo)) {
> - struct usb_request *req =
> - midi_alloc_ep_req(midi->in_ep, midi->buflen);
> + struct usb_request *req;
>
> + length = usb_ep_align_maybe(midi->gadget, midi->in_ep,
> + midi->buflen);
> + req = midi_alloc_ep_req(midi->in_ep, length);
>   if (req == NULL)
>   return -ENOMEM;
>
> @@ -359,10 +361,12 @@ static int f_midi_set_alt(struct usb_function *f, 
> unsigned intf, unsigned alt)
>
>   /* allocate a bunch of read buffers and queue them all at once. */
>   for (i = 0; i < midi->qlen && err == 0; i++) {
> - struct usb_request *req =
> - midi_alloc_ep_req(midi->out_ep,
> - max_t(unsigned, midi->buflen,
> - bulk_out_desc.wMaxPacketSize));
> + struct usb_request *req;
> +
> + length = usb_ep_align_maybe(midi->gadget, midi->out_ep,
> + midi->buflen);
> + req = midi_alloc_ep_req(midi->out_ep,
> + max_t(unsigned, length, 
> bulk_out_desc.wMaxPacketSize));

 Perhaps:

 +   length = midi->buflen < bulk_out_desc.wMaxPacketSize
 +   ? bulk_out_desc.wMaxPacketSize
 +   : usb_ep_align_maybe(midi->gadget, midi->out_ep,
 +midi->buflen);
 +   req = midi_alloc_ep_req(midi->out_ep, length);

 I find it somewhat cleaner.  Up to you.
>>>
>>> But if the gadget does not requires 'quirk_ep_out_aligned_size', then
>>> we also can keep midi->buflen length although midi->buflen <
>>> bulk_out_desc.wMaxPacketSize, right? Thanks for your comment.
>>
>> I don’t know.  That’s not what the original code was doing.  The
>> original code was using:
>>
>> max_t(unsigned, midi->buflen, bulk_out_desc.wMaxPacketSize));
>>
>> for some reason.>
>
> My take on this is that it's calling max_t() to try and align to
> wMaxPacketSize. We can see from original commit what was the intent:
>
> commit 03d27ade4941076b34c823d63d91dc895731a595
> Author: Felipe F. Tonello 
> Date:   Wed Mar 9 19:39:30 2016 +
>
> usb: gadget: f_midi: Fixed a bug when buflen was smaller than 
> wMaxPacketSize
> 
> buflen by default (256) is smaller than wMaxPacketSize (512) in high-speed
> devices.
> 
> That caused the OUT endpoint to freeze if the host send any data packet of
> length greater than 256 bytes.
> 
> This is an example dump of what happended on that enpoint:
> HOST:   [DATA][Length=260][...]
> DEVICE: [NAK]
> HOST:   [PING]
> DEVICE: [NAK]
> HOST:   [PING]
> DEVICE: [NAK]
> ...
> HOST:   [PING]
> DEVICE: [NAK]
> 
> This patch fixes this problem by setting the minimum usb_request's buffer 
> size
> for the OUT endpoint as its wMaxPacketSize.
> 
> Acked-by: Michal Nazarewicz 
> Signed-off-by: Felipe F. Tonello 
> Signed-off-by: Felipe Balbi 
>
> diff --git a/drivers/usb/gadget/function/f_midi.c 
> b/drivers/usb/gadget/function/f_midi.c
> index 56e2dde99b03..9ad51dcab982 

Re: [PATCH] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-08 Thread Felipe Balbi

Hi,

Michal Nazarewicz  writes:
> On Fri, Jul 08 2016, Baolin Wang wrote:
>> On 7 July 2016 at 20:51, Michal Nazarewicz  wrote:
>>> On Thu, Jul 07 2016, Baolin Wang wrote:
 Some gadget device (such as dwc3 gadget) requires quirk_ep_out_aligned_size
 attribute, which means it need to align the request buffer's size to an 
 ep's
 maxpacketsize.

 Thus we add usb_ep_align_maybe() function to check if it is need to align
 the request buffer's size to an ep's maxpacketsize.

 Signed-off-by: Baolin Wang 
>>>
>>> Acked-by: Michal Nazarewicz 
>>>
 ---
  drivers/usb/gadget/function/f_midi.c |   18 +++---
  1 file changed, 11 insertions(+), 7 deletions(-)

 diff --git a/drivers/usb/gadget/function/f_midi.c 
 b/drivers/usb/gadget/function/f_midi.c
 index 58fc199..2e3f11e 100644
 --- a/drivers/usb/gadget/function/f_midi.c
 +++ b/drivers/usb/gadget/function/f_midi.c
 @@ -328,7 +328,7 @@ static int f_midi_start_ep(struct f_midi *midi,
  static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned 
 alt)
  {
   struct f_midi *midi = func_to_midi(f);
 - unsigned i;
 + unsigned i, length;
   int err;

   /* we only set alt for MIDIStreaming interface */
 @@ -345,9 +345,11 @@ static int f_midi_set_alt(struct usb_function *f, 
 unsigned intf, unsigned alt)

   /* pre-allocate write usb requests to use on f_midi_transmit. */
   while (kfifo_avail(&midi->in_req_fifo)) {
 - struct usb_request *req =
 - midi_alloc_ep_req(midi->in_ep, midi->buflen);
 + struct usb_request *req;

 + length = usb_ep_align_maybe(midi->gadget, midi->in_ep,
 + midi->buflen);
 + req = midi_alloc_ep_req(midi->in_ep, length);
   if (req == NULL)
   return -ENOMEM;

 @@ -359,10 +361,12 @@ static int f_midi_set_alt(struct usb_function *f, 
 unsigned intf, unsigned alt)

   /* allocate a bunch of read buffers and queue them all at once. */
   for (i = 0; i < midi->qlen && err == 0; i++) {
 - struct usb_request *req =
 - midi_alloc_ep_req(midi->out_ep,
 - max_t(unsigned, midi->buflen,
 - bulk_out_desc.wMaxPacketSize));
 + struct usb_request *req;
 +
 + length = usb_ep_align_maybe(midi->gadget, midi->out_ep,
 + midi->buflen);
 + req = midi_alloc_ep_req(midi->out_ep,
 + max_t(unsigned, length, 
 bulk_out_desc.wMaxPacketSize));
>>>
>>> Perhaps:
>>>
>>> +   length = midi->buflen < bulk_out_desc.wMaxPacketSize
>>> +   ? bulk_out_desc.wMaxPacketSize
>>> +   : usb_ep_align_maybe(midi->gadget, midi->out_ep,
>>> +midi->buflen);
>>> +   req = midi_alloc_ep_req(midi->out_ep, length);
>>>
>>> I find it somewhat cleaner.  Up to you.
>>
>> But if the gadget does not requires 'quirk_ep_out_aligned_size', then
>> we also can keep midi->buflen length although midi->buflen <
>> bulk_out_desc.wMaxPacketSize, right? Thanks for your comment.
>
> I don’t know.  That’s not what the original code was doing.  The
> original code was using:
>
> max_t(unsigned, midi->buflen, bulk_out_desc.wMaxPacketSize));
>
> for some reason.>

My take on this is that it's calling max_t() to try and align to
wMaxPacketSize. We can see from original commit what was the intent:

commit 03d27ade4941076b34c823d63d91dc895731a595
Author: Felipe F. Tonello 
Date:   Wed Mar 9 19:39:30 2016 +

usb: gadget: f_midi: Fixed a bug when buflen was smaller than wMaxPacketSize

buflen by default (256) is smaller than wMaxPacketSize (512) in high-speed
devices.

That caused the OUT endpoint to freeze if the host send any data packet of
length greater than 256 bytes.

This is an example dump of what happended on that enpoint:
HOST:   [DATA][Length=260][...]
DEVICE: [NAK]
HOST:   [PING]
DEVICE: [NAK]
HOST:   [PING]
DEVICE: [NAK]
...
HOST:   [PING]
DEVICE: [NAK]

This patch fixes this problem by setting the minimum usb_request's buffer 
size
for the OUT endpoint as its wMaxPacketSize.

Acked-by: Michal Nazarewicz 
Signed-off-by: Felipe F. Tonello 
Signed-off-by: Felipe Balbi 

diff --git a/drivers/usb/gadget/function/f_midi.c 
b/drivers/usb/gadget/function/f_midi.c
index 56e2dde99b03..9ad51dcab982 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -360,7 +360,9 @@ static int f_midi_set_alt(struct usb_function *f, unsigned 
intf, unsigned alt)
 

Re: [PATCH] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-08 Thread Felipe Balbi

Hi,

Baolin Wang  writes:
> Some gadget device (such as dwc3 gadget) requires quirk_ep_out_aligned_size
> attribute, which means it need to align the request buffer's size to an ep's
> maxpacketsize.
>
> Thus we add usb_ep_align_maybe() function to check if it is need to align
> the request buffer's size to an ep's maxpacketsize.
>
> Signed-off-by: Baolin Wang 
> ---
>  drivers/usb/gadget/function/f_midi.c |   18 +++---
>  1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_midi.c 
> b/drivers/usb/gadget/function/f_midi.c
> index 58fc199..2e3f11e 100644
> --- a/drivers/usb/gadget/function/f_midi.c
> +++ b/drivers/usb/gadget/function/f_midi.c
> @@ -328,7 +328,7 @@ static int f_midi_start_ep(struct f_midi *midi,
>  static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned 
> alt)
>  {
>   struct f_midi *midi = func_to_midi(f);
> - unsigned i;
> + unsigned i, length;
>   int err;
>  
>   /* we only set alt for MIDIStreaming interface */
> @@ -345,9 +345,11 @@ static int f_midi_set_alt(struct usb_function *f, 
> unsigned intf, unsigned alt)
>  
>   /* pre-allocate write usb requests to use on f_midi_transmit. */
>   while (kfifo_avail(&midi->in_req_fifo)) {
> - struct usb_request *req =
> - midi_alloc_ep_req(midi->in_ep, midi->buflen);
> + struct usb_request *req;
>  
> + length = usb_ep_align_maybe(midi->gadget, midi->in_ep,
> + midi->buflen);

this is not needed for in_ep, only out_ep, right?

> + req = midi_alloc_ep_req(midi->in_ep, length);
>   if (req == NULL)
>   return -ENOMEM;
>  
> @@ -359,10 +361,12 @@ static int f_midi_set_alt(struct usb_function *f, 
> unsigned intf, unsigned alt)
>  
>   /* allocate a bunch of read buffers and queue them all at once. */
>   for (i = 0; i < midi->qlen && err == 0; i++) {
> - struct usb_request *req =
> - midi_alloc_ep_req(midi->out_ep,
> - max_t(unsigned, midi->buflen,
> - bulk_out_desc.wMaxPacketSize));
> + struct usb_request *req;
> +
> + length = usb_ep_align_maybe(midi->gadget, midi->out_ep,
> + midi->buflen);

after calling usb_ep_align_maybe()...

> + req = midi_alloc_ep_req(midi->out_ep,
> + max_t(unsigned, length, bulk_out_desc.wMaxPacketSize));

... max_t() is pointless. length will *always* >= wMaxPacketSize.

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb: gadget: f_midi: Add checking if it need align buffer's size to an ep's maxpacketsize

2016-07-08 Thread Michal Nazarewicz
On Fri, Jul 08 2016, Baolin Wang wrote:
> On 7 July 2016 at 20:51, Michal Nazarewicz  wrote:
>> On Thu, Jul 07 2016, Baolin Wang wrote:
>>> Some gadget device (such as dwc3 gadget) requires quirk_ep_out_aligned_size
>>> attribute, which means it need to align the request buffer's size to an ep's
>>> maxpacketsize.
>>>
>>> Thus we add usb_ep_align_maybe() function to check if it is need to align
>>> the request buffer's size to an ep's maxpacketsize.
>>>
>>> Signed-off-by: Baolin Wang 
>>
>> Acked-by: Michal Nazarewicz 
>>
>>> ---
>>>  drivers/usb/gadget/function/f_midi.c |   18 +++---
>>>  1 file changed, 11 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/usb/gadget/function/f_midi.c 
>>> b/drivers/usb/gadget/function/f_midi.c
>>> index 58fc199..2e3f11e 100644
>>> --- a/drivers/usb/gadget/function/f_midi.c
>>> +++ b/drivers/usb/gadget/function/f_midi.c
>>> @@ -328,7 +328,7 @@ static int f_midi_start_ep(struct f_midi *midi,
>>>  static int f_midi_set_alt(struct usb_function *f, unsigned intf, unsigned 
>>> alt)
>>>  {
>>>   struct f_midi *midi = func_to_midi(f);
>>> - unsigned i;
>>> + unsigned i, length;
>>>   int err;
>>>
>>>   /* we only set alt for MIDIStreaming interface */
>>> @@ -345,9 +345,11 @@ static int f_midi_set_alt(struct usb_function *f, 
>>> unsigned intf, unsigned alt)
>>>
>>>   /* pre-allocate write usb requests to use on f_midi_transmit. */
>>>   while (kfifo_avail(&midi->in_req_fifo)) {
>>> - struct usb_request *req =
>>> - midi_alloc_ep_req(midi->in_ep, midi->buflen);
>>> + struct usb_request *req;
>>>
>>> + length = usb_ep_align_maybe(midi->gadget, midi->in_ep,
>>> + midi->buflen);
>>> + req = midi_alloc_ep_req(midi->in_ep, length);
>>>   if (req == NULL)
>>>   return -ENOMEM;
>>>
>>> @@ -359,10 +361,12 @@ static int f_midi_set_alt(struct usb_function *f, 
>>> unsigned intf, unsigned alt)
>>>
>>>   /* allocate a bunch of read buffers and queue them all at once. */
>>>   for (i = 0; i < midi->qlen && err == 0; i++) {
>>> - struct usb_request *req =
>>> - midi_alloc_ep_req(midi->out_ep,
>>> - max_t(unsigned, midi->buflen,
>>> - bulk_out_desc.wMaxPacketSize));
>>> + struct usb_request *req;
>>> +
>>> + length = usb_ep_align_maybe(midi->gadget, midi->out_ep,
>>> + midi->buflen);
>>> + req = midi_alloc_ep_req(midi->out_ep,
>>> + max_t(unsigned, length, 
>>> bulk_out_desc.wMaxPacketSize));
>>
>> Perhaps:
>>
>> +   length = midi->buflen < bulk_out_desc.wMaxPacketSize
>> +   ? bulk_out_desc.wMaxPacketSize
>> +   : usb_ep_align_maybe(midi->gadget, midi->out_ep,
>> +midi->buflen);
>> +   req = midi_alloc_ep_req(midi->out_ep, length);
>>
>> I find it somewhat cleaner.  Up to you.
>
> But if the gadget does not requires 'quirk_ep_out_aligned_size', then
> we also can keep midi->buflen length although midi->buflen <
> bulk_out_desc.wMaxPacketSize, right? Thanks for your comment.

I don’t know.  That’s not what the original code was doing.  The
original code was using:

max_t(unsigned, midi->buflen, bulk_out_desc.wMaxPacketSize));

for some reason.>

>>>   if (req == NULL)
>>>   return -ENOMEM;
>>>
>>
>> --
>> Best regards
>> ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
>> «If at first you don’t succeed, give up skydiving»
>
>
>
> -- 
> Baolin.wang
> Best Regards

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 3/5] usb: dwc3: add phyif_utmi_quirk

2016-07-08 Thread Heiko Stuebner
Hi William,

Am Donnerstag, 7. Juli 2016, 10:54:24 schrieb William Wu:
> Add a quirk to configure the core to support the
> UTMI+ PHY with an 8- or 16-bit interface. UTMI+ PHY
> interface is hardware property, and it's platform
> dependent. Normall, the PHYIf can be configured
> during coreconsultant. But for some specific usb
> cores(e.g. rk3399 soc dwc3), the default PHYIf
> configuration value is fault, so we need to
> reconfigure it by software.
> 
> And refer to the dwc3 databook, the GUSB2PHYCFG.USBTRDTIM
> must be set to the corresponding value according to
> the UTMI+ PHY interface.
> 
> Signed-off-by: William Wu 
> ---
[...]
> diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt
> b/Documentation/devicetree/bindings/usb/dwc3.txt index 020b0e9..8d7317d
> 100644
> --- a/Documentation/devicetree/bindings/usb/dwc3.txt
> +++ b/Documentation/devicetree/bindings/usb/dwc3.txt
> @@ -42,6 +42,10 @@ Optional properties:
>   - snps,dis-u2-freeclk-exists-quirk: when set, clear the
> u2_freeclk_exists in GUSB2PHYCFG, specify that USB2 PHY doesn't provide
>   a free-running PHY clock.
> + - snps,phyif-utmi-quirk: when set core will set phyif UTMI+ interface.
> + - snps,phyif-utmi: the value to configure the core to support a UTMI+
> PHY + with an 8- or 16-bit interface. Value 0 select 8-bit
> + interface, value 1 select 16-bit interface.

maybe
snps,phyif-utmi-width = <8> or <16>;

devicetree is about describing the hardware, not the things that get written 
to registers :-) . The conversion from the described width to the register 
value can easily be done in the driver.


Also I don't think you need two properties for this. If the snps,phyif-utmi 
property is specified it indicates that you want to manually set the width 
and if it is absent you want to use the IC default. All functions reading 
property-values indicate if the property is missing.

But it looks like there is already a precendence in 
snps,tx_de_emphasis(_quirk), so maybe Felipe has a different opinion here?



>   - snps,is-utmi-l1-suspend: true when DWC3 asserts output signal
>   utmi_l1_suspend_n, false when asserts utmi_sleep_n
>   - snps,hird-threshold: HIRD threshold
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 0b7bfd2..94036b1 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -408,6 +408,7 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
>  static int dwc3_phy_setup(struct dwc3 *dwc)
>  {
>   u32 reg;
> + u32 usbtrdtim;
>   int ret;
> 
>   reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
> @@ -503,6 +504,15 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
>   if (dwc->dis_u2_freeclk_exists_quirk)
>   reg &= ~DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS;
> 
> + if (dwc->phyif_utmi_quirk) {
> + reg &= ~(DWC3_GUSB2PHYCFG_PHYIF_MASK |
> +DWC3_GUSB2PHYCFG_USBTRDTIM_MASK);
> + usbtrdtim = dwc->phyif_utmi ? USBTRDTIM_UTMI_16_BIT :
> + USBTRDTIM_UTMI_8_BIT;
> + reg |= DWC3_GUSB2PHYCFG_PHYIF(dwc->phyif_utmi) |
> +DWC3_GUSB2PHYCFG_USBTRDTIM(usbtrdtim);
> + }
> +
>   dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
> 
>   return 0;
> @@ -834,6 +844,7 @@ static int dwc3_probe(struct platform_device *pdev)
>   struct resource *res;
>   struct dwc3 *dwc;
>   u8  lpm_nyet_threshold;
> + u8  phyif_utmi;
>   u8  tx_de_emphasis;
>   u8  hird_threshold;
> 
> @@ -880,6 +891,9 @@ static int dwc3_probe(struct platform_device *pdev)
>   /* default to highest possible threshold */
>   lpm_nyet_threshold = 0xff;
> 
> + /* default to UTMI+ 8-bit interface */
> + phyif_utmi = 0;
> +
>   /* default to -3.5dB de-emphasis */
>   tx_de_emphasis = 1;
> 
> @@ -929,6 +943,10 @@ static int dwc3_probe(struct platform_device *pdev)
>   "snps,dis_rxdet_inp3_quirk");
>   dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev,
>   "snps,dis-u2-freeclk-exists-quirk");
> + dwc->phyif_utmi_quirk = device_property_read_bool(dev,
> + "snps,phyif-utmi-quirk");
> +  device_property_read_u8(dev, "snps,phyif-utmi",
> +  &phyif_utmi);


As described above device_property_read_u8 will return an error if the 
property is not present, so you could fill your dwc->phyif_utmi_quirk from 
that:

ret = device_property_read_u8(dev, "snps,phyif-utmi",
 &phyif_utmi);
dwc->phyif_utmi_quirk = (ret == 0) ? true : false;


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

[PATCH] USB: bcma: initialize Northstar USB 3.0 controller

2016-07-08 Thread Rafał Miłecki
It's a rather simple controller, we just need to make sure USB is
powered (using GPIO pin) and reset bus core. Once this is done it's
safe to register XHCI controller and let it init PHY and do its magic.

Signed-off-by: Rafał Miłecki 
---
 drivers/usb/host/bcma-hcd.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
index 172ef17..422fdc2 100644
--- a/drivers/usb/host/bcma-hcd.c
+++ b/drivers/usb/host/bcma-hcd.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -338,6 +339,18 @@ err_unregister_ohci_dev:
return err;
 }
 
+static int bcma_hcd_usb30_init(struct bcma_hcd_device *bcma_hcd)
+{
+   struct bcma_device *core = bcma_hcd->core;
+   struct device *dev = &core->dev;
+
+   bcma_core_enable(core, 0);
+
+   of_platform_default_populate(dev->of_node, NULL, dev);
+
+   return 0;
+}
+
 static int bcma_hcd_probe(struct bcma_device *core)
 {
int err;
@@ -362,6 +375,11 @@ static int bcma_hcd_probe(struct bcma_device *core)
if (err)
return err;
break;
+   case BCMA_CORE_NS_USB30:
+   err = bcma_hcd_usb30_init(usb_dev);
+   if (err)
+   return err;
+   break;
default:
return -ENODEV;
}
@@ -416,6 +434,7 @@ static int bcma_hcd_resume(struct bcma_device *dev)
 static const struct bcma_device_id bcma_hcd_table[] = {
BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, 
BCMA_ANY_CLASS),
BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_USB20, BCMA_ANY_REV, 
BCMA_ANY_CLASS),
+   BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_USB30, BCMA_ANY_REV, 
BCMA_ANY_CLASS),
{},
 };
 MODULE_DEVICE_TABLE(bcma, bcma_hcd_table);
-- 
1.8.4.5

--
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/gadget: fix gadgetfs aio support

2016-07-08 Thread Mathieu Laurendeau
I'll resend the patch. Sorry for the noise.

Le 08/07/2016 13:01, Sergei Shtylyov a écrit :
> Hello.
> 
> On 7/8/2016 9:15 AM, Mathieu Laurendeau wrote:
> 
>> Hi,
> 
>Greetings should not be a part of the patch description.
> 
>> Since commit 7fe3976e0f3ab26f8ffd9430d3d2a19a70f2c8d2 ("gadget: switch
>> ep_io_operations to ->read_iter/->write_iter") io submissions fail with
>> ENODEV.
>>
>> Fixes: 7fe3976e0f3a ("gadget: switch ep_io_operations to
>> ->read_iter/->write_iter")
>> Signed-off-by: Mathieu Laurendeau 
>> ---
>>  drivers/usb/gadget/legacy/inode.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/gadget/legacy/inode.c 
>> b/drivers/usb/gadget/legacy/inode.c
>> index aa3707b..120a03a 100644
>> --- a/drivers/usb/gadget/legacy/inode.c
>> +++ b/drivers/usb/gadget/legacy/inode.c
>> @@ -542,7 +542,7 @@ static ssize_t ep_aio(struct kiocb *iocb,
>>   */
>>  spin_lock_irq(&epdata->dev->lock);
>>  value = -ENODEV;
>> -if (unlikely(epdata->ep))
>> +if (unlikely(epdata->ep) == NULL)
> 
>This placement of the inner parens doesn't make sense, you should enclose 
> the whole comparison.
> 
> [...]
> 
> MBR, 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] usb/gadget: fix gadgetfs aio support

2016-07-08 Thread Sergei Shtylyov

Hello.

On 7/8/2016 9:15 AM, Mathieu Laurendeau wrote:


Hi,


   Greetings should not be a part of the patch description.


Since commit 7fe3976e0f3ab26f8ffd9430d3d2a19a70f2c8d2 ("gadget: switch
ep_io_operations to ->read_iter/->write_iter") io submissions fail with
ENODEV.

Fixes: 7fe3976e0f3a ("gadget: switch ep_io_operations to
->read_iter/->write_iter")
Signed-off-by: Mathieu Laurendeau 
---
 drivers/usb/gadget/legacy/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/inode.c 
b/drivers/usb/gadget/legacy/inode.c
index aa3707b..120a03a 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -542,7 +542,7 @@ static ssize_t ep_aio(struct kiocb *iocb,
 */
spin_lock_irq(&epdata->dev->lock);
value = -ENODEV;
-   if (unlikely(epdata->ep))
+   if (unlikely(epdata->ep) == NULL)


   This placement of the inner parens doesn't make sense, you should enclose 
the whole comparison.


[...]

MBR, 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 1/1] usb: udc: core: fix error handling

2016-07-08 Thread Felipe Balbi

Hi,

Peter Chen  writes:
> The udc device needs to be deleted if error occurs
>
> Fixes: 855ed04a (usb: gadget: udc-core: independent registration of gadgets 
> and gadget drivers)

it's preferred that the abbreviation is done with 12 characters and
commit subject be wrapped also with "". IOW:

Fixes: 855ed04a3758 ("usb: gadget: udc-core: independent registration of
gadgets and gadget drivers")"

> Signed-off-by: Peter Chen 
> ---
>  drivers/usb/gadget/udc/core.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> index ff8685e..934f838 100644
> --- a/drivers/usb/gadget/udc/core.c
> +++ b/drivers/usb/gadget/udc/core.c
> @@ -1145,7 +1145,7 @@ int usb_add_gadget_udc_release(struct device *parent, 
> struct usb_gadget *gadget,
>   if (ret != -EPROBE_DEFER)
>   list_del(&driver->pending);
>   if (ret)
> - goto err4;
> + goto err5;
>   break;
>   }
>   }
> @@ -1154,6 +1154,9 @@ int usb_add_gadget_udc_release(struct device *parent, 
> struct usb_gadget *gadget,
>  
>   return 0;
>  
> +err5:
> + device_del(&udc->dev);
> +
>  err4:
>   list_del(&udc->list);
>   mutex_unlock(&udc_lock);
> -- 
> 1.9.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

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH] usb/gadget: fix gadgetfs aio support

2016-07-08 Thread kbuild test robot
Hi,

[auto build test WARNING on balbi-usb/next]
[also build test WARNING on v4.7-rc6 next-20160707]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Mathieu-Laurendeau/usb-gadget-fix-gadgetfs-aio-support/20160708-164431
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   include/linux/compiler.h:232:8: sparse: attribute 'no_sanitize_address': 
unknown attribute
>> drivers/usb/gadget/legacy/inode.c:545:34: sparse: incompatible types for 
>> operation (==)
   drivers/usb/gadget/legacy/inode.c:545:34:left side has type int
   drivers/usb/gadget/legacy/inode.c:545:34:right side has type void *
   drivers/usb/gadget/legacy/inode.c: In function 'ep_aio':
   drivers/usb/gadget/legacy/inode.c:545:27: warning: comparison between 
pointer and integer
 if (unlikely(epdata->ep) == NULL)
  ^~

vim +545 drivers/usb/gadget/legacy/inode.c

   529  ssize_t value;
   530  
   531  iocb->private = priv;
   532  priv->iocb = iocb;
   533  
   534  kiocb_set_cancel_fn(iocb, ep_aio_cancel);
   535  get_ep(epdata);
   536  priv->epdata = epdata;
   537  priv->actual = 0;
   538  priv->mm = current->mm; /* mm teardown waits for iocbs in 
exit_aio() */
   539  
   540  /* each kiocb is coupled to one usb_request, but we can't
   541   * allocate or submit those if the host disconnected.
   542   */
   543  spin_lock_irq(&epdata->dev->lock);
   544  value = -ENODEV;
 > 545  if (unlikely(epdata->ep) == NULL)
   546  goto fail;
   547  
   548  req = usb_ep_alloc_request(epdata->ep, GFP_ATOMIC);
   549  value = -ENOMEM;
   550  if (unlikely(!req))
   551  goto fail;
   552  
   553  priv->req = req;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
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 08/22] usb: chipidea: Remove locking in ci_udc_start()

2016-07-08 Thread Peter Chen
On Thu, Jul 07, 2016 at 03:20:59PM -0700, Stephen Boyd wrote:
> We don't call hw_device_reset() with the ci->lock held, so it
> doesn't seem like this lock here is protecting anything. Let's
> just remove it. This allows us to call sleeping functions like
> phy_init() from within the CI_HDRC_CONTROLLER_RESET_EVENT hook.
> 
> Cc: Peter Chen 
> Cc: Greg Kroah-Hartman 
> Signed-off-by: Stephen Boyd 
> ---
>  drivers/usb/chipidea/udc.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> index 065f5d97aa67..f16be4710cdb 100644
> --- a/drivers/usb/chipidea/udc.c
> +++ b/drivers/usb/chipidea/udc.c
> @@ -1719,7 +1719,6 @@ static int ci_udc_start(struct usb_gadget *gadget,
>struct usb_gadget_driver *driver)
>  {
>   struct ci_hdrc *ci = container_of(gadget, struct ci_hdrc, gadget);
> - unsigned long flags;
>   int retval = -ENOMEM;
>  
>   if (driver->disconnect == NULL)
> @@ -1746,7 +1745,6 @@ static int ci_udc_start(struct usb_gadget *gadget,
>  
>   pm_runtime_get_sync(&ci->gadget.dev);
>   if (ci->vbus_active) {
> - spin_lock_irqsave(&ci->lock, flags);
>   hw_device_reset(ci);
>   } else {
>   usb_udc_vbus_handler(&ci->gadget, false);
> @@ -1755,7 +1753,6 @@ static int ci_udc_start(struct usb_gadget *gadget,
>   }
>  
>   retval = hw_device_state(ci, ci->ep0out->qh.dma);
> - spin_unlock_irqrestore(&ci->lock, flags);
>   if (retval)
>   pm_runtime_put_sync(&ci->gadget.dev);
>  

The main purpose for this is disabling interrupt when reset controller,
in case the unexpected interrupts occur.

You can move this between hw_device_state.

-- 

Best Regards,
Peter Chen
--
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 07/22] usb: chipidea: Notify events when switching host mode

2016-07-08 Thread Peter Chen
On Thu, Jul 07, 2016 at 03:20:58PM -0700, Stephen Boyd wrote:
> The chipidea/udc.c file sends a CI_HDRC_CONTROLLER_RESET_EVENT to
> the wrapper drivers when it calls hw_device_reset(), but that
> function is not called from chipidea/host.c. And the udc.c file
> sends the CI_HDRC_CONTROLLER_STOPPED_EVENT but the host.c file
> doesn't do anything.
> 
> The intent of the reset event is to allow the wrapper driver to
> do any wrapper specific things after the reset bit has been set
> in the usb command register. Therefore, add this event hook in
> the host role after we toggle that bit.
> 
> Similarly, the intent of the stopped event is to allow the
> wrapper driver to do any wrapper specific things after the device
> is stopped. So when we stop the host role, send the stopped
> event.
> 
> Cc: Peter Chen 
> Cc: Greg Kroah-Hartman 
> Signed-off-by: Stephen Boyd 
> ---
>  drivers/usb/chipidea/host.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
> index 053bac9d983c..a1d8551ca79d 100644
> --- a/drivers/usb/chipidea/host.c
> +++ b/drivers/usb/chipidea/host.c
> @@ -87,6 +87,9 @@ static int ehci_ci_reset(struct usb_hcd *hcd)
>   if (ret)
>   return ret;
>  
> + if (ci->platdata->notify_event)
> + ci->platdata->notify_event(ci, CI_HDRC_CONTROLLER_RESET_EVENT);
> +
>   ci_platform_configure(ci);
>  
>   return ret;
> @@ -184,6 +187,9 @@ static void host_stop(struct ci_hdrc *ci)
>   struct usb_hcd *hcd = ci->hcd;
>  
>   if (hcd) {
> + if (ci->platdata->notify_event)
> + ci->platdata->notify_event(ci,
> + CI_HDRC_CONTROLLER_STOPPED_EVENT);
>   usb_remove_hcd(hcd);
>   usb_put_hcd(hcd);
>   if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) &&

Acked-by: Peter Chen 

-- 

Best Regards,
Peter Chen
--
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/gadget: fix gadgetfs aio support

2016-07-08 Thread kbuild test robot
Hi,

[auto build test WARNING on balbi-usb/next]
[also build test WARNING on v4.7-rc6 next-20160707]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Mathieu-Laurendeau/usb-gadget-fix-gadgetfs-aio-support/20160708-164431
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
config: x86_64-randconfig-s5-07081546 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/init.h:4:0,
from drivers/usb/gadget/legacy/inode.c:16:
   drivers/usb/gadget/legacy/inode.c: In function 'ep_aio':
   drivers/usb/gadget/legacy/inode.c:545:27: warning: comparison between 
pointer and integer
 if (unlikely(epdata->ep) == NULL)
  ^
   include/linux/compiler.h:151:30: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> drivers/usb/gadget/legacy/inode.c:545:2: note: in expansion of macro 'if'
 if (unlikely(epdata->ep) == NULL)
 ^~
   drivers/usb/gadget/legacy/inode.c:545:27: warning: comparison between 
pointer and integer
 if (unlikely(epdata->ep) == NULL)
  ^
   include/linux/compiler.h:151:42: note: in definition of macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> drivers/usb/gadget/legacy/inode.c:545:2: note: in expansion of macro 'if'
 if (unlikely(epdata->ep) == NULL)
 ^~
   drivers/usb/gadget/legacy/inode.c:545:27: warning: comparison between 
pointer and integer
 if (unlikely(epdata->ep) == NULL)
  ^
   include/linux/compiler.h:162:16: note: in definition of macro '__trace_if'
  __r = !!(cond); \
   ^~~~
>> drivers/usb/gadget/legacy/inode.c:545:2: note: in expansion of macro 'if'
 if (unlikely(epdata->ep) == NULL)
 ^~
--
   In file included from /kbuild/src/stress/include/linux/init.h:4:0,
from 
/kbuild/src/stress/drivers/usb/gadget/legacy/inode.c:16:
   /kbuild/src/stress/drivers/usb/gadget/legacy/inode.c: In function 'ep_aio':
   /kbuild/src/stress/drivers/usb/gadget/legacy/inode.c:545:27: warning: 
comparison between pointer and integer
 if (unlikely(epdata->ep) == NULL)
  ^
   /kbuild/src/stress/include/linux/compiler.h:151:30: note: in definition of 
macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> /kbuild/src/stress/drivers/usb/gadget/legacy/inode.c:545:2: note: in 
>> expansion of macro 'if'
 if (unlikely(epdata->ep) == NULL)
 ^~
   /kbuild/src/stress/drivers/usb/gadget/legacy/inode.c:545:27: warning: 
comparison between pointer and integer
 if (unlikely(epdata->ep) == NULL)
  ^
   /kbuild/src/stress/include/linux/compiler.h:151:42: note: in definition of 
macro '__trace_if'
 if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
 ^~~~
>> /kbuild/src/stress/drivers/usb/gadget/legacy/inode.c:545:2: note: in 
>> expansion of macro 'if'
 if (unlikely(epdata->ep) == NULL)
 ^~
   /kbuild/src/stress/drivers/usb/gadget/legacy/inode.c:545:27: warning: 
comparison between pointer and integer
 if (unlikely(epdata->ep) == NULL)
  ^
   /kbuild/src/stress/include/linux/compiler.h:162:16: note: in definition of 
macro '__trace_if'
  __r = !!(cond); \
   ^~~~
>> /kbuild/src/stress/drivers/usb/gadget/legacy/inode.c:545:2: note: in 
>> expansion of macro 'if'
 if (unlikely(epdata->ep) == NULL)
 ^~

vim +/if +545 drivers/usb/gadget/legacy/inode.c

   529  ssize_t value;
   530  
   531  iocb->private = priv;
   532  priv->iocb = iocb;
   533  
   534  kiocb_set_cancel_fn(iocb, ep_aio_cancel);
   535  get_ep(epdata);
   536  priv->epdata = epdata;
   537  priv->actual = 0;
   538  priv->mm = current->mm; /* mm teardown waits for iocbs in 
exit_aio() */
   539  
   540  /* each kiocb is coupled to one usb_request, but we can't
   541   * allocate or submit those if the host disconnected.
   542   */
   543  spin_lock_irq(&epdata->dev->lock);
   544  value = -ENODEV;
 > 545  if (unlikely(epdata->ep) == NULL)
   546  

Re: [PATCH v2 06/22] usb: chipidea: Add platform flag for wrapper phy management

2016-07-08 Thread Peter Chen
On Thu, Jul 07, 2016 at 03:20:57PM -0700, Stephen Boyd wrote:
> The ULPI phy on qcom platforms needs to be initialized and
> powered on after a USB reset and before we toggle the run/stop
> bit. Otherwise, the phy locks up and doesn't work properly.
> Therefore, add a flag to skip any phy power management in the
> core layer, leaving it up to the glue driver to manage.
> 
> Cc: Peter Chen 
> Cc: Greg Kroah-Hartman 
> Signed-off-by: Stephen Boyd 
> ---
>  drivers/usb/chipidea/core.c  | 6 ++
>  include/linux/usb/chipidea.h | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 01390e02ee53..532085a096d9 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -361,6 +361,9 @@ static int _ci_usb_phy_init(struct ci_hdrc *ci)
>   */
>  static void ci_usb_phy_exit(struct ci_hdrc *ci)
>  {
> + if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL)
> + return;
> +
>   if (ci->phy) {
>   phy_power_off(ci->phy);
>   phy_exit(ci->phy);
> @@ -379,6 +382,9 @@ static int ci_usb_phy_init(struct ci_hdrc *ci)
>  {
>   int ret;
>  
> + if (ci->platdata->flags & CI_HDRC_OVERRIDE_PHY_CONTROL)
> + return 0;
> +

How you handle the code for PHY getting at probe?

-- 

Best Regards,
Peter Chen
--
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/gadget: fix gadgetfs aio support

2016-07-08 Thread kbuild test robot
Hi,

[auto build test WARNING on balbi-usb/next]
[also build test WARNING on v4.7-rc6 next-20160707]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Mathieu-Laurendeau/usb-gadget-fix-gadgetfs-aio-support/20160708-164431
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
config: i386-randconfig-r0-07081252 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/usb/gadget/legacy/inode.c: In function 'ep_aio':
>> drivers/usb/gadget/legacy/inode.c:545:27: warning: comparison between 
>> pointer and integer
 if (unlikely(epdata->ep) == NULL)
  ^~

vim +545 drivers/usb/gadget/legacy/inode.c

   529  ssize_t value;
   530  
   531  iocb->private = priv;
   532  priv->iocb = iocb;
   533  
   534  kiocb_set_cancel_fn(iocb, ep_aio_cancel);
   535  get_ep(epdata);
   536  priv->epdata = epdata;
   537  priv->actual = 0;
   538  priv->mm = current->mm; /* mm teardown waits for iocbs in 
exit_aio() */
   539  
   540  /* each kiocb is coupled to one usb_request, but we can't
   541   * allocate or submit those if the host disconnected.
   542   */
   543  spin_lock_irq(&epdata->dev->lock);
   544  value = -ENODEV;
 > 545  if (unlikely(epdata->ep) == NULL)
   546  goto fail;
   547  
   548  req = usb_ep_alloc_request(epdata->ep, GFP_ATOMIC);
   549  value = -ENOMEM;
   550  if (unlikely(!req))
   551  goto fail;
   552  
   553  priv->req = req;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[peter.chen-usb:pwrseq-lib 4/7] ERROR: "pwrseq_get" [drivers/usb/core/usbcore.ko] undefined!

2016-07-08 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.git 
pwrseq-lib
head:   72289855b3d236efef879059b315940de9e80df2
commit: bda499ece3edc6187490ad32238bcc65075d80d5 [4/7] usb: core: add power 
sequence handling for USB devices
config: i386-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-1) 6.1.1 20160430
reproduce:
git checkout bda499ece3edc6187490ad32238bcc65075d80d5
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

>> ERROR: "pwrseq_get" [drivers/usb/core/usbcore.ko] undefined!
>> ERROR: "pwrseq_free" [drivers/usb/core/usbcore.ko] undefined!
>> ERROR: "is_pwrseq_supported" [drivers/usb/core/usbcore.ko] undefined!
>> ERROR: "pwrseq_put" [drivers/usb/core/usbcore.ko] undefined!
>> ERROR: "pwrseq_off" [drivers/usb/core/usbcore.ko] undefined!
>> ERROR: "pwrseq_on" [drivers/usb/core/usbcore.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


Re: [PATCH v2 04/22] usb: chipidea: Only read/write OTGSC from one place

2016-07-08 Thread Peter Chen
On Thu, Jul 07, 2016 at 03:20:55PM -0700, Stephen Boyd wrote:
> With the id and vbus detection done via extcon we need to make
> sure we poll the status of OTGSC properly by considering what the
> extcon is saying, and not just what the register is saying. Let's
> move this hw_wait_reg() function to the only place it's used and
> simplify it for polling the OTGSC register. Then we can make
> certain we only use the hw_read_otgsc() API to read OTGSC, which
> will make sure we properly handle extcon events.
> 
> Cc: Peter Chen 
> Cc: Greg Kroah-Hartman 
> Cc: "Ivan T. Ivanov" 
> Fixes: 3ecb3e09b042 ("usb: chipidea: Use extcon framework for VBUS and ID 
> detect")
> Signed-off-by: Stephen Boyd 
> ---
>  drivers/usb/chipidea/ci.h   |  3 ---
>  drivers/usb/chipidea/core.c | 32 
>  drivers/usb/chipidea/otg.c  | 34 ++
>  3 files changed, 30 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
> index cd414559040f..05bc4d631cb9 100644
> --- a/drivers/usb/chipidea/ci.h
> +++ b/drivers/usb/chipidea/ci.h
> @@ -428,9 +428,6 @@ int hw_port_test_set(struct ci_hdrc *ci, u8 mode);
>  
>  u8 hw_port_test_get(struct ci_hdrc *ci);
>  
> -int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask,
> - u32 value, unsigned int timeout_ms);
> -
>  void ci_platform_configure(struct ci_hdrc *ci);
>  
>  int dbg_create_files(struct ci_hdrc *ci);
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 69426e644d17..01390e02ee53 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -516,38 +516,6 @@ int hw_device_reset(struct ci_hdrc *ci)
>   return 0;
>  }
>  
> -/**
> - * hw_wait_reg: wait the register value
> - *
> - * Sometimes, it needs to wait register value before going on.
> - * Eg, when switch to device mode, the vbus value should be lower
> - * than OTGSC_BSV before connects to host.
> - *
> - * @ci: the controller
> - * @reg: register index
> - * @mask: mast bit
> - * @value: the bit value to wait
> - * @timeout_ms: timeout in millisecond
> - *
> - * This function returns an error code if timeout
> - */
> -int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask,
> - u32 value, unsigned int timeout_ms)
> -{
> - unsigned long elapse = jiffies + msecs_to_jiffies(timeout_ms);
> -
> - while (hw_read(ci, reg, mask) != value) {
> - if (time_after(jiffies, elapse)) {
> - dev_err(ci->dev, "timeout waiting for %08x in %d\n",
> - mask, reg);
> - return -ETIMEDOUT;
> - }
> - msleep(20);
> - }
> -
> - return 0;
> -}
> -
>  static irqreturn_t ci_irq(int irq, void *data)
>  {
>   struct ci_hdrc *ci = data;
> diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
> index 03b6743461d1..a6fc60934297 100644
> --- a/drivers/usb/chipidea/otg.c
> +++ b/drivers/usb/chipidea/otg.c
> @@ -104,7 +104,31 @@ void ci_handle_vbus_change(struct ci_hdrc *ci)
>   usb_gadget_vbus_disconnect(&ci->gadget);
>  }
>  
> -#define CI_VBUS_STABLE_TIMEOUT_MS 5000
> +/**
> + * When we switch to device mode, the vbus value should be lower
> + * than OTGSC_BSV before connecting to host.
> + *
> + * @ci: the controller
> + *
> + * This function returns an error code if timeout
> + */
> +static int hw_wait_otgsc_bsv(struct ci_hdrc *ci)

I think the function name should reflect "we wait for vbus lower than bsv"
Care to change one?

-- 

Best Regards,
Peter Chen
--
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 03/22] usb: ulpi: Support device discovery via device properties

2016-07-08 Thread Peter Chen
On Thu, Jul 07, 2016 at 03:20:54PM -0700, Stephen Boyd wrote:
> @@ -39,6 +42,10 @@ static int ulpi_match(struct device *dev, struct 
> device_driver *driver)
>   struct ulpi *ulpi = to_ulpi_dev(dev);
>   const struct ulpi_device_id *id;
>  
> + /* Some ULPI devices don't have a product id so rely on OF match */
> + if (ulpi->id.product == 0)
> + return of_driver_match_device(dev, driver);
> +

How about using vendor id? It can't be 0, but pid may be 0.
See: http://www.linux-usb.org/usb.ids

> +static int ulpi_of_register(struct ulpi *ulpi)
> +{
> + struct device_node *np = NULL, *child;
> +
> + /* Find a ulpi bus underneath the parent or the parent of the parent */
> + if (ulpi->dev.parent->of_node)
> + np = of_find_node_by_name(ulpi->dev.parent->of_node, "ulpi");
> + else if (ulpi->dev.parent->parent && ulpi->dev.parent->parent->of_node)
> + np = of_find_node_by_name(ulpi->dev.parent->parent->of_node,
> +   "ulpi");
> + if (!np)
> + return 0;
> +
> + child = of_get_next_available_child(np, NULL);
> + if (!child)
> + return -EINVAL;

You may need to call of_node_put on parent (np), not on child node
below.

> +
> + ulpi->dev.of_node = child;
> +
> + return 0;
> +}
> +
> +static int ulpi_read_id(struct ulpi *ulpi)
>  {
>   int ret;
>  
> @@ -174,14 +218,39 @@ static int ulpi_register(struct device *dev, struct 
> ulpi *ulpi)
>   ulpi->id.product = ulpi_read(ulpi, ULPI_PRODUCT_ID_LOW);
>   ulpi->id.product |= ulpi_read(ulpi, ULPI_PRODUCT_ID_HIGH) << 8;
>  
> + return 0;
> +}
> +

What does this API for? Why it still needs to be called after
vid/pid gets from firmware?

> +static int ulpi_register(struct device *dev, struct ulpi *ulpi)
> +{
> + int ret;
> +
>   ulpi->dev.parent = dev;
>   ulpi->dev.bus = &ulpi_bus;
>   ulpi->dev.type = &ulpi_dev_type;
>   dev_set_name(&ulpi->dev, "%s.ulpi", dev_name(dev));
>  
> + if (IS_ENABLED(CONFIG_OF)) {
> + ret = ulpi_of_register(ulpi);
> + if (ret)
> + return ret;
> + }
> +
>   ACPI_COMPANION_SET(&ulpi->dev, ACPI_COMPANION(dev));
>  
> - request_module("ulpi:v%04xp%04x", ulpi->id.vendor, ulpi->id.product);
> + ret = device_property_read_u16(&ulpi->dev, "ulpi-vendor",
> +&ulpi->id.vendor);
> + ret |= device_property_read_u16(&ulpi->dev, "ulpi-product",
> + &ulpi->id.product);
> + if (ret) {
> + ret = ulpi_read_id(ulpi);
> + if (ret)
> + return ret;
> + }
> +
[...]

>  void ulpi_unregister_interface(struct ulpi *ulpi)
>  {
> + of_node_put(ulpi->dev.of_node);

[...]

-- 

Best Regards,
Peter Chen
--
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/gadget: fix gadgetfs aio support

2016-07-08 Thread Mathieu Laurendeau
Hi,

Since commit 7fe3976e0f3ab26f8ffd9430d3d2a19a70f2c8d2 ("gadget: switch
ep_io_operations to ->read_iter/->write_iter") io submissions fail with
ENODEV.

Fixes: 7fe3976e0f3a ("gadget: switch ep_io_operations to
->read_iter/->write_iter")
Signed-off-by: Mathieu Laurendeau 
---
 drivers/usb/gadget/legacy/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/legacy/inode.c 
b/drivers/usb/gadget/legacy/inode.c
index aa3707b..120a03a 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -542,7 +542,7 @@ static ssize_t ep_aio(struct kiocb *iocb,
 */
spin_lock_irq(&epdata->dev->lock);
value = -ENODEV;
-   if (unlikely(epdata->ep))
+   if (unlikely(epdata->ep) == NULL)
goto fail;

req = usb_ep_alloc_request(epdata->ep, GFP_ATOMIC);
-- 
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] usb: Kconfig: move ulpi bus to common

2016-07-08 Thread Peter Chen
The ULPI bus is not only for host, but for device mode too, so move
it out from host's Kconfig.

Cc: Heikki Krogerus 
Signed-off-by: Peter Chen 
---
 drivers/usb/common/Kconfig | 21 +
 drivers/usb/core/Kconfig   | 21 -
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/common/Kconfig b/drivers/usb/common/Kconfig
index 951b1d0..e251aec 100644
--- a/drivers/usb/common/Kconfig
+++ b/drivers/usb/common/Kconfig
@@ -7,3 +7,24 @@ config USB_LED_TRIG
  Say Y here if you are working on a system with led-class supported
  LEDs and you want to use them as activity indicators for USB host or
  gadget.
+
+config USB_ULPI_BUS
+   tristate "USB ULPI PHY interface support"
+   depends on USB_SUPPORT
+   help
+ UTMI+ Low Pin Interface (ULPI) is specification for a commonly used
+ USB 2.0 PHY interface. The ULPI specification defines a standard set
+ of registers that can be used to detect the vendor and product which
+ allows ULPI to be handled as a bus. This module is the driver for that
+ bus.
+
+ The ULPI interfaces (the buses) are registered by the drivers for USB
+ controllers which support ULPI register access and have ULPI PHY
+ attached to them. The ULPI PHY drivers themselves are normal PHY
+ drivers.
+
+ ULPI PHYs provide often functions such as ADP sensing/probing (OTG
+ protocol) and USB charger detection.
+
+ To compile this driver as a module, choose M here: the module will
+ be called ulpi.
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig
index dd28010..d6e43ce 100644
--- a/drivers/usb/core/Kconfig
+++ b/drivers/usb/core/Kconfig
@@ -82,24 +82,3 @@ config USB_OTG_FSM
help
  Implements OTG Finite State Machine as specified in On-The-Go
  and Embedded Host Supplement to the USB Revision 2.0 Specification.
-
-config USB_ULPI_BUS
-   tristate "USB ULPI PHY interface support"
-   depends on USB_SUPPORT
-   help
- UTMI+ Low Pin Interface (ULPI) is specification for a commonly used
- USB 2.0 PHY interface. The ULPI specification defines a standard set
- of registers that can be used to detect the vendor and product which
- allows ULPI to be handled as a bus. This module is the driver for that
- bus.
-
- The ULPI interfaces (the buses) are registered by the drivers for USB
- controllers which support ULPI register access and have ULPI PHY
- attached to them. The ULPI PHY drivers themselves are normal PHY
- drivers.
-
- ULPI PHYs provide often functions such as ADP sensing/probing (OTG
- protocol) and USB charger detection.
-
- To compile this driver as a module, choose M here: the module will
- be called ulpi.
-- 
1.9.1

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


[PATCH 1/2] usb: Kconfig: move common things under usb/common

2016-07-08 Thread Peter Chen
It can simplify root Kconfig

Signed-off-by: Peter Chen 
---
 drivers/usb/Kconfig| 10 +-
 drivers/usb/common/Kconfig |  9 +
 2 files changed, 10 insertions(+), 9 deletions(-)
 create mode 100644 drivers/usb/common/Kconfig

diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 8689dcb..1a28a9f 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -150,14 +150,6 @@ source "drivers/usb/phy/Kconfig"
 
 source "drivers/usb/gadget/Kconfig"
 
-config USB_LED_TRIG
-   bool "USB LED Triggers"
-   depends on LEDS_CLASS && USB_COMMON && LEDS_TRIGGERS
-   help
- This option adds LED triggers for USB host and/or gadget activity.
-
- Say Y here if you are working on a system with led-class supported
- LEDs and you want to use them as activity indicators for USB host or
- gadget.
+source "drivers/usb/common/Kconfig"
 
 endif # USB_SUPPORT
diff --git a/drivers/usb/common/Kconfig b/drivers/usb/common/Kconfig
new file mode 100644
index 000..951b1d0
--- /dev/null
+++ b/drivers/usb/common/Kconfig
@@ -0,0 +1,9 @@
+config USB_LED_TRIG
+   bool "USB LED Triggers"
+   depends on LEDS_CLASS && USB_COMMON && LEDS_TRIGGERS
+   help
+ This option adds LED triggers for USB host and/or gadget activity.
+
+ Say Y here if you are working on a system with led-class supported
+ LEDs and you want to use them as activity indicators for USB host or
+ gadget.
-- 
1.9.1

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


[PATCH 1/1] usb: udc: core: fix error handling

2016-07-08 Thread Peter Chen
The udc device needs to be deleted if error occurs

Fixes: 855ed04a (usb: gadget: udc-core: independent registration of gadgets and 
gadget drivers)
Signed-off-by: Peter Chen 
---
 drivers/usb/gadget/udc/core.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
index ff8685e..934f838 100644
--- a/drivers/usb/gadget/udc/core.c
+++ b/drivers/usb/gadget/udc/core.c
@@ -1145,7 +1145,7 @@ int usb_add_gadget_udc_release(struct device *parent, 
struct usb_gadget *gadget,
if (ret != -EPROBE_DEFER)
list_del(&driver->pending);
if (ret)
-   goto err4;
+   goto err5;
break;
}
}
@@ -1154,6 +1154,9 @@ int usb_add_gadget_udc_release(struct device *parent, 
struct usb_gadget *gadget,
 
return 0;
 
+err5:
+   device_del(&udc->dev);
+
 err4:
list_del(&udc->list);
mutex_unlock(&udc_lock);
-- 
1.9.1

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


Re: [PATCH v2 1/2] usb: gadget: legacy: Add udc module param to all legacy gadgets

2016-07-08 Thread Peter Chen
On Thu, Jul 07, 2016 at 02:17:57PM +0200, Krzysztof Opasiak wrote:
> Add new module parameter called "udc" to all legacy gadgets.
> By using this parameter user can choose a controller towhich
> this gadget should be bound.
> 
> This may be useful esp. when having multiple controllers
> or multiple gadget builtin.
> 
> When value for this param is not provided then old behaviour
> (binding to first free UDC) remains unchanged.
> 
> Signed-off-by: Krzysztof Opasiak 
> ---
> Changes since v1:
> - add documentation for udc_name field
> 
> ---
>  drivers/usb/gadget/composite.c |1 +
>  drivers/usb/gadget/legacy/acm_ms.c |2 ++
>  drivers/usb/gadget/legacy/audio.c  |2 ++
>  drivers/usb/gadget/legacy/cdc2.c   |2 ++
>  drivers/usb/gadget/legacy/dbgp.c   |3 +++
>  drivers/usb/gadget/legacy/ether.c  |2 ++
>  drivers/usb/gadget/legacy/g_ffs.c  |2 ++
>  drivers/usb/gadget/legacy/gmidi.c  |2 ++
>  drivers/usb/gadget/legacy/hid.c|2 ++
>  drivers/usb/gadget/legacy/mass_storage.c   |2 ++
>  drivers/usb/gadget/legacy/multi.c  |2 ++
>  drivers/usb/gadget/legacy/ncm.c|2 ++
>  drivers/usb/gadget/legacy/nokia.c  |2 ++
>  drivers/usb/gadget/legacy/printer.c|2 ++
>  drivers/usb/gadget/legacy/serial.c |2 ++
>  drivers/usb/gadget/legacy/tcm_usb_gadget.c |2 ++
>  drivers/usb/gadget/legacy/webcam.c |2 ++
>  drivers/usb/gadget/legacy/zero.c   |2 ++
>  include/linux/usb/composite.h  |7 +++
>  19 files changed, 43 insertions(+)
> 
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index eb64848..1262c03 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -2313,6 +2313,7 @@ int usb_composite_probe(struct usb_composite_driver 
> *driver)
>   driver->name = "composite";
>  
>   driver->gadget_driver = composite_driver_template;
> + driver->gadget_driver.udc_name = driver->udc_name;
>   gadget_driver = &driver->gadget_driver;
>  
>   gadget_driver->function =  (char *) driver->name;
> diff --git a/drivers/usb/gadget/legacy/acm_ms.c 
> b/drivers/usb/gadget/legacy/acm_ms.c
> index c39de65..9ca07e8 100644
> --- a/drivers/usb/gadget/legacy/acm_ms.c
> +++ b/drivers/usb/gadget/legacy/acm_ms.c
> @@ -260,6 +260,8 @@ static struct usb_composite_driver acm_ms_driver = {
>   .unbind = acm_ms_unbind,
>  };
>  
> +USB_GADGET_COMPOSITE_UDC_NAME(acm_ms_driver);
> +
>  module_usb_composite_driver(acm_ms_driver);
>  
>  MODULE_DESCRIPTION(DRIVER_DESC);
> diff --git a/drivers/usb/gadget/legacy/audio.c 
> b/drivers/usb/gadget/legacy/audio.c
> index 5d7b3c6..a07e36c 100644
> --- a/drivers/usb/gadget/legacy/audio.c
> +++ b/drivers/usb/gadget/legacy/audio.c
> @@ -304,6 +304,8 @@ static struct usb_composite_driver audio_driver = {
>   .unbind = audio_unbind,
>  };
>  
> +USB_GADGET_COMPOSITE_UDC_NAME(audio_driver);
> +
>  module_usb_composite_driver(audio_driver);
>  
>  MODULE_DESCRIPTION(DRIVER_DESC);
> diff --git a/drivers/usb/gadget/legacy/cdc2.c 
> b/drivers/usb/gadget/legacy/cdc2.c
> index 51c0868..fd5f142 100644
> --- a/drivers/usb/gadget/legacy/cdc2.c
> +++ b/drivers/usb/gadget/legacy/cdc2.c
> @@ -234,6 +234,8 @@ static struct usb_composite_driver cdc_driver = {
>   .unbind = cdc_unbind,
>  };
>  
> +USB_GADGET_COMPOSITE_UDC_NAME(cdc_driver);
> +
>  module_usb_composite_driver(cdc_driver);
>  
>  MODULE_DESCRIPTION(DRIVER_DESC);
> diff --git a/drivers/usb/gadget/legacy/dbgp.c 
> b/drivers/usb/gadget/legacy/dbgp.c
> index 99ca3da..5d434bd 100644
> --- a/drivers/usb/gadget/legacy/dbgp.c
> +++ b/drivers/usb/gadget/legacy/dbgp.c
> @@ -406,6 +406,9 @@ static struct usb_gadget_driver dbgp_driver = {
>   },
>  };
>  
> +module_param_named(udc, dbgp_driver.udc_name, charp, S_IRUGO);
> +MODULE_PARM_DESC(udc, "USB Device Controller Name");
> +
>  static int __init dbgp_init(void)
>  {
>   return usb_gadget_probe_driver(&dbgp_driver);
> diff --git a/drivers/usb/gadget/legacy/ether.c 
> b/drivers/usb/gadget/legacy/ether.c
> index 25a2c2e..172c4b5 100644
> --- a/drivers/usb/gadget/legacy/ether.c
> +++ b/drivers/usb/gadget/legacy/ether.c
> @@ -479,6 +479,8 @@ static struct usb_composite_driver eth_driver = {
>   .unbind = eth_unbind,
>  };
>  
> +USB_GADGET_COMPOSITE_UDC_NAME(eth_driver);
> +
>  module_usb_composite_driver(eth_driver);
>  
>  MODULE_DESCRIPTION(PREFIX DRIVER_DESC);
> diff --git a/drivers/usb/gadget/legacy/g_ffs.c 
> b/drivers/usb/gadget/legacy/g_ffs.c
> index f85639e..ffa9cc3 100644
> --- a/drivers/usb/gadget/legacy/g_ffs.c
> +++ b/drivers/usb/gadget/legacy/g_ffs.c
> @@ -158,6 +158,8 @@ static struct usb_composite_driver gfs_driver = {
>   .unbind = gfs_unbind,
>  };
>  
> +USB_GADGET_COMPOSITE_UDC_NAME(gfs_driver);
> +
>  static unsigned int missing_funcs;
>  sta