Re: [PATCH v9 5/5] usb: dwc3: add rockchip specific glue layer

2016-08-15 Thread kbuild test robot
Hi William,

[auto build test ERROR on balbi-usb/next]
[also build test ERROR on v4.8-rc2 next-20160815]
[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/William-Wu/support-rockchip-dwc3-driver/20160815-151035
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/usb/dwc3/dwc3-rockchip.c:18:0:
>> drivers/usb/dwc3/dwc3-rockchip.c:424:25: error: 'of_dwc3_rockchip_match' 
>> undeclared here (not in a function)
MODULE_DEVICE_TABLE(of, of_dwc3_rockchip_match);
^
   include/linux/module.h:223:21: note: in definition of macro 
'MODULE_DEVICE_TABLE'
extern const typeof(name) __mod_##type##__##name##_device_table  \
^~~~
>> include/linux/module.h:223:27: error: 
>> '__mod_of__of_dwc3_rockchip_match_device_table' aliased to undefined symbol 
>> 'of_dwc3_rockchip_match'
extern const typeof(name) __mod_##type##__##name##_device_table  \
  ^
>> drivers/usb/dwc3/dwc3-rockchip.c:424:1: note: in expansion of macro 
>> 'MODULE_DEVICE_TABLE'
MODULE_DEVICE_TABLE(of, of_dwc3_rockchip_match);
^~~

vim +/of_dwc3_rockchip_match +424 drivers/usb/dwc3/dwc3-rockchip.c

   418  
   419  static const struct of_device_id rockchip_dwc3_match[] = {
   420  { .compatible = "rockchip,rk3399-dwc3" },
   421  { /* Sentinel */ }
   422  };
   423  
 > 424  MODULE_DEVICE_TABLE(of, of_dwc3_rockchip_match);
   425  
   426  static struct platform_driver dwc3_rockchip_driver = {
   427  .probe  = dwc3_rockchip_probe,

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


.config.gz
Description: Binary data


Re: [PATCH v9 5/5] usb: dwc3: add rockchip specific glue layer

2016-08-15 Thread kbuild test robot
Hi William,

[auto build test ERROR on balbi-usb/next]
[also build test ERROR on v4.8-rc2 next-20160815]
[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/William-Wu/support-rockchip-dwc3-driver/20160815-151035
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   In file included from drivers/usb/dwc3/dwc3-rockchip.c:18:0:
>> drivers/usb/dwc3/dwc3-rockchip.c:424:25: error: 'of_dwc3_rockchip_match' 
>> undeclared here (not in a function)
MODULE_DEVICE_TABLE(of, of_dwc3_rockchip_match);
^
   include/linux/module.h:223:21: note: in definition of macro 
'MODULE_DEVICE_TABLE'
extern const typeof(name) __mod_##type##__##name##_device_table  \
^~~~
>> include/linux/module.h:223:27: error: 
>> '__mod_of__of_dwc3_rockchip_match_device_table' aliased to undefined symbol 
>> 'of_dwc3_rockchip_match'
extern const typeof(name) __mod_##type##__##name##_device_table  \
  ^
>> drivers/usb/dwc3/dwc3-rockchip.c:424:1: note: in expansion of macro 
>> 'MODULE_DEVICE_TABLE'
MODULE_DEVICE_TABLE(of, of_dwc3_rockchip_match);
^~~

vim +/of_dwc3_rockchip_match +424 drivers/usb/dwc3/dwc3-rockchip.c

   418  
   419  static const struct of_device_id rockchip_dwc3_match[] = {
   420  { .compatible = "rockchip,rk3399-dwc3" },
   421  { /* Sentinel */ }
   422  };
   423  
 > 424  MODULE_DEVICE_TABLE(of, of_dwc3_rockchip_match);
   425  
   426  static struct platform_driver dwc3_rockchip_driver = {
   427  .probe  = dwc3_rockchip_probe,

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


.config.gz
Description: Binary data


[PATCH v9 5/5] usb: dwc3: add rockchip specific glue layer

2016-08-15 Thread William Wu
Add rockchip specific glue layer to support USB3 Peripheral mode
and Host mode on rockchip platforms (e.g. rk3399).

The DesignWare USB3 integrated in rockchip SoCs is a configurable
IP Core which can be instantiated as Dual-Role Device (DRD), Host
Only (XHCI) and Peripheral Only configurations.

We use extcon notifier to manage usb cable detection and mode switch.
Enable DWC3 PM runtime auto suspend to allow core enter runtime_suspend
if USB cable is dettached. For host mode, it requires to keep whole
DWC3 controller in reset state to hold pipe power state in P2 before
initializing PHY. And it need to reconfigure USB PHY interface of DWC3
core after deassert DWC3 controller reset.

The current driver supports Host only and Peripheral Only well, for
now, we will add support for OTG after we have it all stabilized.

Signed-off-by: William Wu 
---
 drivers/usb/dwc3/Kconfig |   9 +
 drivers/usb/dwc3/Makefile|   1 +
 drivers/usb/dwc3/core.c  |   2 +-
 drivers/usb/dwc3/core.h  |   1 +
 drivers/usb/dwc3/dwc3-rockchip.c | 441 +++
 5 files changed, 453 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/dwc3/dwc3-rockchip.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index a64ce1c..3d5ec30 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -96,6 +96,15 @@ config USB_DWC3_OF_SIMPLE
 Currently supports Xilinx and Qualcomm DWC USB3 IP.
 Say 'Y' or 'M' if you have one such device.
 
+config USB_DWC3_ROCKCHIP
+   tristate "Rockchip Platforms"
+   depends on EXTCON && (ARCH_ROCKCHIP || COMPILE_TEST)
+   depends on OF
+   default USB_DWC3
+   help
+ Support of USB2/3 functionality in Rockchip platforms.
+ say 'Y' or 'M' if you have one such device.
+
 config USB_DWC3_ST
tristate "STMicroelectronics Platforms"
depends on ARCH_STI && OF
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 22420e1..86fc4fd 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -38,4 +38,5 @@ obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o
 obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o
 obj-$(CONFIG_USB_DWC3_KEYSTONE)+= dwc3-keystone.o
 obj-$(CONFIG_USB_DWC3_OF_SIMPLE)   += dwc3-of-simple.o
+obj-$(CONFIG_USB_DWC3_ROCKCHIP)+= dwc3-rockchip.o
 obj-$(CONFIG_USB_DWC3_ST)  += dwc3-st.o
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index e887b38..3da6215 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -405,7 +405,7 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
  * initialized. The PHY interfaces and the PHYs get initialized together with
  * the core in dwc3_core_init.
  */
-static int dwc3_phy_setup(struct dwc3 *dwc)
+int dwc3_phy_setup(struct dwc3 *dwc)
 {
u32 reg;
int ret;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 3d94acd..79403ff 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1123,6 +1123,7 @@ struct dwc3_gadget_ep_cmd_params {
 /* prototypes */
 void dwc3_set_mode(struct dwc3 *dwc, u32 mode);
 u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type);
+int dwc3_phy_setup(struct dwc3 *dwc);
 
 /* check whether we are on the DWC_usb31 core */
 static inline bool dwc3_is_usb31(struct dwc3 *dwc)
diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c
new file mode 100644
index 000..632bbb9
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-rockchip.c
@@ -0,0 +1,441 @@
+/**
+ * dwc3-rockchip.c - Rockchip Specific Glue layer
+ *
+ * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
+ *
+ * Authors: William Wu 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "io.h"
+
+#define DWC3_ROCKCHIP_AUTOSUSPEND_DELAY  500 /* ms */
+
+struct dwc3_rockchip {
+   int num_clocks;
+   struct device   *dev;
+   struct clk  **clks;
+   struct dwc3 *dwc;
+   struct reset_control*otg_rst;
+   struct extcon_dev   *edev;
+   struct notifier_block   device_nb;
+   struct notifier_block   host_nb;
+   struct work_struct  otg_work;
+};
+
+static int dwc3_rockchip_device_notifier(struct notifier_block *nb,
+ 

[PATCH v9 5/5] usb: dwc3: add rockchip specific glue layer

2016-08-15 Thread William Wu
Add rockchip specific glue layer to support USB3 Peripheral mode
and Host mode on rockchip platforms (e.g. rk3399).

The DesignWare USB3 integrated in rockchip SoCs is a configurable
IP Core which can be instantiated as Dual-Role Device (DRD), Host
Only (XHCI) and Peripheral Only configurations.

We use extcon notifier to manage usb cable detection and mode switch.
Enable DWC3 PM runtime auto suspend to allow core enter runtime_suspend
if USB cable is dettached. For host mode, it requires to keep whole
DWC3 controller in reset state to hold pipe power state in P2 before
initializing PHY. And it need to reconfigure USB PHY interface of DWC3
core after deassert DWC3 controller reset.

The current driver supports Host only and Peripheral Only well, for
now, we will add support for OTG after we have it all stabilized.

Signed-off-by: William Wu 
---
 drivers/usb/dwc3/Kconfig |   9 +
 drivers/usb/dwc3/Makefile|   1 +
 drivers/usb/dwc3/core.c  |   2 +-
 drivers/usb/dwc3/core.h  |   1 +
 drivers/usb/dwc3/dwc3-rockchip.c | 441 +++
 5 files changed, 453 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/dwc3/dwc3-rockchip.c

diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index a64ce1c..3d5ec30 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -96,6 +96,15 @@ config USB_DWC3_OF_SIMPLE
 Currently supports Xilinx and Qualcomm DWC USB3 IP.
 Say 'Y' or 'M' if you have one such device.
 
+config USB_DWC3_ROCKCHIP
+   tristate "Rockchip Platforms"
+   depends on EXTCON && (ARCH_ROCKCHIP || COMPILE_TEST)
+   depends on OF
+   default USB_DWC3
+   help
+ Support of USB2/3 functionality in Rockchip platforms.
+ say 'Y' or 'M' if you have one such device.
+
 config USB_DWC3_ST
tristate "STMicroelectronics Platforms"
depends on ARCH_STI && OF
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 22420e1..86fc4fd 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -38,4 +38,5 @@ obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o
 obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o
 obj-$(CONFIG_USB_DWC3_KEYSTONE)+= dwc3-keystone.o
 obj-$(CONFIG_USB_DWC3_OF_SIMPLE)   += dwc3-of-simple.o
+obj-$(CONFIG_USB_DWC3_ROCKCHIP)+= dwc3-rockchip.o
 obj-$(CONFIG_USB_DWC3_ST)  += dwc3-st.o
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index e887b38..3da6215 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -405,7 +405,7 @@ static void dwc3_cache_hwparams(struct dwc3 *dwc)
  * initialized. The PHY interfaces and the PHYs get initialized together with
  * the core in dwc3_core_init.
  */
-static int dwc3_phy_setup(struct dwc3 *dwc)
+int dwc3_phy_setup(struct dwc3 *dwc)
 {
u32 reg;
int ret;
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 3d94acd..79403ff 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -1123,6 +1123,7 @@ struct dwc3_gadget_ep_cmd_params {
 /* prototypes */
 void dwc3_set_mode(struct dwc3 *dwc, u32 mode);
 u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type);
+int dwc3_phy_setup(struct dwc3 *dwc);
 
 /* check whether we are on the DWC_usb31 core */
 static inline bool dwc3_is_usb31(struct dwc3 *dwc)
diff --git a/drivers/usb/dwc3/dwc3-rockchip.c b/drivers/usb/dwc3/dwc3-rockchip.c
new file mode 100644
index 000..632bbb9
--- /dev/null
+++ b/drivers/usb/dwc3/dwc3-rockchip.c
@@ -0,0 +1,441 @@
+/**
+ * dwc3-rockchip.c - Rockchip Specific Glue layer
+ *
+ * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
+ *
+ * Authors: William Wu 
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "core.h"
+#include "io.h"
+
+#define DWC3_ROCKCHIP_AUTOSUSPEND_DELAY  500 /* ms */
+
+struct dwc3_rockchip {
+   int num_clocks;
+   struct device   *dev;
+   struct clk  **clks;
+   struct dwc3 *dwc;
+   struct reset_control*otg_rst;
+   struct extcon_dev   *edev;
+   struct notifier_block   device_nb;
+   struct notifier_block   host_nb;
+   struct work_struct  otg_work;
+};
+
+static int dwc3_rockchip_device_notifier(struct notifier_block *nb,
+unsigned long event,