[PATCH] usb:dwc3:fix access poisoned list_head in dwc3_gadget_giveback

2017-12-23 Thread Yu Chen
From: Yu Chen <cheny...@huawei.com>

Unable to handle kernel paging request at virtual address dead0108
pgd = fff7a3179000
[dead0108] *pgd=230e0003, *pud=230e0003,
*pmd=
Internal error: Oops: 9644 [#1] PREEMPT SMP
Modules linked in:
CPU: 2 PID: 1 Comm: init Tainted: GW   4.4.23+ #1
TGID: 1 Comm: init
Hardware name: kirin970 (DT)
task: fff99f19 ti: fff99f1740e0 task.ti: fff99f1740e0
PC is at dwc3_gadget_giveback+0xa8/0x228
LR is at dwc3_remove_requests+0x44/0x88

The crash occurred when usb work as rndis device and
__dwc3_gadget_kick_transfer return error in __dwc3_gadget_ep_queue.
The request submited in __dwc3_gadget_ep_queue is moved to started_list
but not kicked. It is stil on started_list although
__dwc3_gadget_kick_transfer failed. When dwc3_gadget_ep_queue return
error to u_ether driver, the request will be resubmit to dwc3 driver.
At last, the same request is both on started_list and pending_list,
it will be list_del twice in dwc3_remove_requests and cause crash.

Signed-off-by: Yu Chen <cheny...@huawei.com>
---
 drivers/usb/dwc3/gadget.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 639dd1b163a0..a913e64ca4e0 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1278,9 +1278,28 @@ static void dwc3_gadget_start_isoc(struct dwc3 *dwc,
__dwc3_gadget_start_isoc(dwc, dep, cur_uf);
 }
 
+static int dwc3_gadget_is_req_pengding_or_started(struct dwc3_ep *dep,
+   struct dwc3_request *req)
+{
+   struct dwc3_request *iterate_req;
+
+   list_for_each_entry(iterate_req, >pending_list, list) {
+   if (iterate_req == req)
+   return 1;
+   }
+
+   list_for_each_entry(iterate_req, >started_list, list) {
+   if (iterate_req == req)
+   return 1;
+   }
+
+   return 0;
+}
+
 static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request 
*req)
 {
struct dwc3 *dwc = dep->dwc;
+   int ret;
 
if (!dep->endpoint.desc) {
dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
@@ -1334,7 +1353,14 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, 
struct dwc3_request *req)
}
 
 out:
-   return __dwc3_gadget_kick_transfer(dep);
+   ret = __dwc3_gadget_kick_transfer(dep);
+   if (ret && dwc3_gadget_is_req_pengding_or_started(dep, req)) {
+   dev_dbg(dwc->dev, "%s: req still on list, return 0\n",
+   dep->name);
+   ret = 0;
+   }
+
+   return ret;
 }
 
 static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
-- 
2.15.0-rc2

--
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] Subject: [PATCH] usb:dwc3:fix access poisoned list_head in dwc3_gadget_giveback

2017-12-23 Thread Yu Chen
From: Yu Chen <cheny...@huawei.com>

Unable to handle kernel paging request at virtual address dead0108
pgd = fff7a3179000
[dead0108] *pgd=230e0003, *pud=230e0003,
*pmd=
Internal error: Oops: 9644 [#1] PREEMPT SMP
Modules linked in:
CPU: 2 PID: 1 Comm: init Tainted: GW   4.4.23+ #1
TGID: 1 Comm: init
Hardware name: kirin970 (DT)
task: fff99f19 ti: fff99f1740e0 task.ti: fff99f1740e0
PC is at dwc3_gadget_giveback+0xa8/0x228
LR is at dwc3_remove_requests+0x44/0x88

The crash occurred when usb work as rndis device and
__dwc3_gadget_kick_transfer return error in __dwc3_gadget_ep_queue.
The request submited in __dwc3_gadget_ep_queue is moved to started_list
but not kicked. It is stil on started_list although
__dwc3_gadget_kick_transfer failed. When dwc3_gadget_ep_queue return
error to u_ether driver, the request will be resubmit to dwc3 driver.
At last, the same request is both on started_list and pending_list,
it will be list_del twice in dwc3_remove_requests and cause crash.

Signed-off-by: Yu Chen <cheny...@huawei.com>
---
 drivers/usb/dwc3/gadget.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 639dd1b163a0..a913e64ca4e0 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1278,9 +1278,28 @@ static void dwc3_gadget_start_isoc(struct dwc3 *dwc,
__dwc3_gadget_start_isoc(dwc, dep, cur_uf);
 }
 
+static int dwc3_gadget_is_req_pengding_or_started(struct dwc3_ep *dep,
+   struct dwc3_request *req)
+{
+   struct dwc3_request *iterate_req;
+
+   list_for_each_entry(iterate_req, >pending_list, list) {
+   if (iterate_req == req)
+   return 1;
+   }
+
+   list_for_each_entry(iterate_req, >started_list, list) {
+   if (iterate_req == req)
+   return 1;
+   }
+
+   return 0;
+}
+
 static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request 
*req)
 {
struct dwc3 *dwc = dep->dwc;
+   int ret;
 
if (!dep->endpoint.desc) {
dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
@@ -1334,7 +1353,14 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, 
struct dwc3_request *req)
}
 
 out:
-   return __dwc3_gadget_kick_transfer(dep);
+   ret = __dwc3_gadget_kick_transfer(dep);
+   if (ret && dwc3_gadget_is_req_pengding_or_started(dep, req)) {
+   dev_dbg(dwc->dev, "%s: req still on list, return 0\n",
+   dep->name);
+   ret = 0;
+   }
+
+   return ret;
 }
 
 static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
-- 
2.15.0-rc2

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


[PATCH v3] usb:xhci fix panic in xhci_free_virt_devices_depth_first

2017-11-06 Thread Yu Chen
From: Yu Chen <cheny...@huawei.com>

Check vdev->real_port 0 to avoid panic
[9.261347] [] 
xhci_free_virt_devices_depth_first+0x58/0x108
[9.261352] [] xhci_mem_cleanup+0x1bc/0x570
[9.261355] [] xhci_stop+0x140/0x1c8
[9.261365] [] usb_remove_hcd+0xfc/0x1d0
[9.261369] [] xhci_plat_remove+0x6c/0xa8
[9.261377] [] platform_drv_remove+0x2c/0x70
[9.261384] [] __device_release_driver+0x80/0x108
[9.261387] [] device_release_driver+0x2c/0x40
[9.261392] [] bus_remove_device+0xe0/0x120
[9.261396] [] device_del+0x114/0x210
[9.261399] [] platform_device_del+0x30/0xa0
[9.261403] [] dwc3_otg_work+0x204/0x488
[9.261407] [] event_work+0x304/0x5b8
[9.261414] [] process_one_work+0x148/0x490
[9.261417] [] worker_thread+0x50/0x4a0
[9.261421] [] kthread+0xe8/0x100
[9.261427] [] ret_from_fork+0x10/0x50

The problem can occur if xhci_plat_remove() is called shortly after
xhci_plat_probe(). While xhci_free_virt_devices_depth_first been
called before the device has been setup and get real_port initialized.
The problem occurred on Hikey960 and was reproduced by Guenter Roeck
on Kevin with chromeos-4.4.

Cc: Guenter Roeck <gro...@google.com>
Signed-off-by: Fan Ning <fanni...@hisilicon.com>
Signed-off-by: Li Rui <liru...@hisilicon.com>
Signed-off-by: yangdi <yangd...@hisilicon.com>
Signed-off-by: Yu Chen <cheny...@huawei.com>

---
 drivers/usb/host/xhci-mem.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 2a82c927ded2..97f30eb7dac0 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -947,6 +947,12 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd 
*xhci, int slot_id)
if (!vdev)
return;
 
+   if (vdev->real_port == 0 ||
+   vdev->real_port > HCS_MAX_PORTS(xhci->hcs_params1)) {
+   xhci_dbg(xhci, "Bad vdev->real_port.\n");
+   goto out;
+   }
+
tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
/* is this a hub device that added a tt_info to the tts list */
@@ -960,6 +966,7 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd 
*xhci, int slot_id)
}
}
}
+out:
/* we are now at a leaf device */
xhci_free_virt_device(xhci, slot_id);
 }
-- 
2.15.0-rc2

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


[PATCH v2] usb:xhci fix panic in xhci_free_virt_devices_depth_first

2017-11-06 Thread Yu Chen
From: Yu Chen <cheny...@huawei.com>

Check vdev->real_port 0 to avoid panic
[9.261347] [] 
xhci_free_virt_devices_depth_first+0x58/0x108
[9.261352] [] xhci_mem_cleanup+0x1bc/0x570
[9.261355] [] xhci_stop+0x140/0x1c8
[9.261365] [] usb_remove_hcd+0xfc/0x1d0
[9.261369] [] xhci_plat_remove+0x6c/0xa8
[9.261377] [] platform_drv_remove+0x2c/0x70
[9.261384] [] __device_release_driver+0x80/0x108
[9.261387] [] device_release_driver+0x2c/0x40
[9.261392] [] bus_remove_device+0xe0/0x120
[9.261396] [] device_del+0x114/0x210
[9.261399] [] platform_device_del+0x30/0xa0
[9.261403] [] dwc3_otg_work+0x204/0x488
[9.261407] [] event_work+0x304/0x5b8
[9.261414] [] process_one_work+0x148/0x490
[9.261417] [] worker_thread+0x50/0x4a0
[9.261421] [] kthread+0xe8/0x100
[9.261427] [] ret_from_fork+0x10/0x50

The problem can occur if xhci_plat_remove() is called shortly after
xhci_plat_probe(). While xhci_free_virt_devices_depth_first been
called before the device has been setup and get real_port initialized.
The problem occurred on Hikey960 and was reproduced by Guenter Roeck
on Kevin with chromeos-4.4.

Cc: Guenter Roeck <gro...@google.com>
Signed-off-by: Fan Ning <fanni...@hisilicon.com>
Signed-off-by: Li Rui <liru...@hisilicon.com>
Signed-off-by: yangdi <yangd...@hisilicon.com>
Signed-off-by: Yu Chen <cheny...@huawei.com>

---
 drivers/usb/host/xhci-mem.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 2a82c927ded2..0361b4a58f59 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -947,6 +947,9 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd 
*xhci, int slot_id)
if (!vdev)
return;
 
+   if (WARN_ON(!vdev->real_port))
+   goto out;
+
tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
/* is this a hub device that added a tt_info to the tts list */
@@ -960,6 +963,7 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd 
*xhci, int slot_id)
}
}
}
+out:
/* we are now at a leaf device */
xhci_free_virt_device(xhci, slot_id);
 }
-- 
2.15.0-rc2

--
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:xhci fix panic in xhci_free_virt_devices_depth_first

2017-11-05 Thread Yu Chen
From: Yu Chen <cheny...@huawei.com>

Check vdev->real_port 0 to avoid panic
[9.261347] [] 
xhci_free_virt_devices_depth_first+0x58/0x108
[9.261352] [] xhci_mem_cleanup+0x1bc/0x570
[9.261355] [] xhci_stop+0x140/0x1c8
[9.261365] [] usb_remove_hcd+0xfc/0x1d0
[9.261369] [] xhci_plat_remove+0x6c/0xa8
[9.261377] [] platform_drv_remove+0x2c/0x70
[9.261384] [] __device_release_driver+0x80/0x108
[9.261387] [] device_release_driver+0x2c/0x40
[9.261392] [] bus_remove_device+0xe0/0x120
[9.261396] [] device_del+0x114/0x210
[9.261399] [] platform_device_del+0x30/0xa0
[9.261403] [] dwc3_otg_work+0x204/0x488
[9.261407] [] event_work+0x304/0x5b8
[9.261414] [] process_one_work+0x148/0x490
[9.261417] [] worker_thread+0x50/0x4a0
[9.261421] [] kthread+0xe8/0x100
[9.261427] [] ret_from_fork+0x10/0x50

The problem can occur if xhci_plat_remove() is called shortly after
xhci_plat_probe(). While xhci_free_virt_devices_depth_first been
called before the device has been setup and get real_port initialized.
The problem occurred on Hikey960 and was reproduced by Guenter Roeck
on Kevin with chromeos-4.4.

Cc: Guenter Roeck <gro...@google.com>
Signed-off-by: Fan Ning <fanni...@hisilicon.com>
Signed-off-by: Li Rui <liru...@hisilicon.com>
Signed-off-by: yangdi <yangd...@hisilicon.com>
Signed-off-by: Yu Chen <cheny...@huawei.com>


---
 drivers/usb/host/xhci-mem.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 2a82c927ded2..295789d993b0 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -947,6 +947,11 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd 
*xhci, int slot_id)
if (!vdev)
return;
 
+   if (WARN_ON(!vdev->real_port)) {
+   xhci_warn(xhci, "Bad vdev->real_port\n");
+   goto out;
+   }
+
tt_list_head = &(xhci->rh_bw[vdev->real_port - 1].tts);
list_for_each_entry_safe(tt_info, next, tt_list_head, tt_list) {
/* is this a hub device that added a tt_info to the tts list */
@@ -960,6 +965,7 @@ void xhci_free_virt_devices_depth_first(struct xhci_hcd 
*xhci, int slot_id)
}
}
}
+out:
/* we are now at a leaf device */
xhci_free_virt_device(xhci, slot_id);
 }
-- 
2.15.0-rc2

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


[RFC 1/3] USB: Add document for usb of Hikey960

2017-10-24 Thread Yu Chen
DT bindings for usb of Hikey960.

Signed-off-by: Yu Chen <cheny...@huawei.com>
Signed-off-by: Ning Fan <fanni...@hisilicon.com>
Signed-off-by: Di Yang <yangd...@hisilicon.com>
Signed-off-by: Rui Li <liru...@hisilicon.com>

---
 .../devicetree/bindings/usb/hisilicon-usb.txt  | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/hisilicon-usb.txt

diff --git a/Documentation/devicetree/bindings/usb/hisilicon-usb.txt 
b/Documentation/devicetree/bindings/usb/hisilicon-usb.txt
new file mode 100644
index ..dc4c460885d6
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/hisilicon-usb.txt
@@ -0,0 +1,38 @@
+* HISILICON USB HUB
+
+Required properties:
+- compatible: One of the specific types :"hisilicon,hi3660-dwc3",
+   "hisilicon,gpio_hubv1","hisilicon,gpio_hubv2"
+
+Optional properties of devices using ISP1301:
+- transceiver: phandle of isp1301 - this helps the ISP1301 driver to find the
+   ISP1301 instance associated with the respective USB driver
+
+Example:
+
+   hisi_usb@ff20 {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   compatible = "hisilicon,hi3660-dwc3";
+   reg = <0x0 0xff20 0x0 0x1000
+0x0 0xff10 0x0 0x10>;
+   ranges;
+   bc_again_flag = <0>;
+
+   clocks = <_ctrl HI3660_CLK_ABB_USB>,
+<_ctrl HI3660_ACLK_GATE_USB3OTG>;
+   clock-names = "clk_usb3phy_ref", "aclk_usb3otg";
+   eye_diagram_param = <0x1c466e3>;
+   eye_diagram_host_param = <0x1c466e3>;
+   usb3_phy_cr_param = <0xb80>;
+   usb3_phy_host_cr_param = <0x980>;
+   usb3_phy_tx_vboost_lvl = <0x5>;
+
+   dwc3@ff10 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0xff10 0x0 0x10>;
+   interrupts = <0 159 4>, <0 161 4>;
+   dr_mode = "otg";
+   maximum-speed = "super-speed";
+   };
+   };
\ No newline at end of file
-- 
2.11.GIT


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


[RFC 0/3] USB: Modify dwc3 code for support Hikey960

2017-10-24 Thread Yu Chen
The HiKey960 development platform is based around the HiSilicon Kirin960.
The patch sets add support for usb of HiKey960.

Fan Ning (3):
  Add document for usb of Hikey960
  Modify dwc3 code for support usb of Hikey960
  Modify device tree for support Hikey960

 .../devicetree/bindings/usb/hisilicon-usb.txt  |   38 +
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi  |   39 +
 arch/arm64/configs/defconfig   |5 +
 drivers/usb/dwc3/Kconfig   |   26 +
 drivers/usb/dwc3/Makefile  |5 +
 drivers/usb/dwc3/core.c|   78 +-
 drivers/usb/dwc3/core.h|   19 +-
 drivers/usb/dwc3/dwc3-hi3660.c |  310 +++
 drivers/usb/dwc3/dwc3-hisi.c   | 1972 
 drivers/usb/dwc3/dwc3-hisi.h   |  293 +++
 drivers/usb/dwc3/dwc3-otg.c|  360 
 drivers/usb/dwc3/dwc3-otg.h|  133 ++
 drivers/usb/dwc3/ep0.c |   55 +-
 drivers/usb/dwc3/gadget.c  |   20 +-
 drivers/usb/dwc3/hisi_hikey_gpio.c |  300 +++
 drivers/usb/dwc3/host.c|   13 +
 drivers/usb/dwc3/io.h  |   14 +
 include/linux/hisi/log/hisi_log.h  |  143 ++
 include/linux/hisi/usb/hisi_hikey_gpio.h   |   24 +
 include/linux/hisi/usb/hisi_usb.h  |   57 +
 20 files changed, 3896 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/hisilicon-usb.txt
 mode change 100644 => 100755 arch/arm64/boot/dts/hisilicon/hi3660.dtsi
 create mode 100644 drivers/usb/dwc3/dwc3-hi3660.c
 create mode 100644 drivers/usb/dwc3/dwc3-hisi.c
 create mode 100644 drivers/usb/dwc3/dwc3-hisi.h
 create mode 100644 drivers/usb/dwc3/dwc3-otg.c
 create mode 100644 drivers/usb/dwc3/dwc3-otg.h
 create mode 100644 drivers/usb/dwc3/hisi_hikey_gpio.c
 create mode 100644 include/linux/hisi/log/hisi_log.h
 create mode 100644 include/linux/hisi/usb/hisi_hikey_gpio.h
 create mode 100644 include/linux/hisi/usb/hisi_usb.h

-- 
2.11.GIT


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


[RFC 2/3] USB: dwc3: Modify dwc3 code for support usb of Hikey960

2017-10-24 Thread Yu Chen
The usb controller of Kirin960 is DesignWare Cores SuperSpeed USB 3.0 
Controller.
The patch modifies dwc3 for support Kirin960 and adds codes for a USB Hub on 
board Hikey960.

Signed-off-by: Yu Chen <cheny...@huawei.com>
Signed-off-by: Ning Fan <fanni...@hisilicon.com>
Signed-off-by: Di Yang <yangd...@hisilicon.com>
Signed-off-by: Rui Li <liru...@hisilicon.com>

---
 arch/arm64/configs/defconfig |5 +
 drivers/usb/dwc3/Kconfig |   26 +
 drivers/usb/dwc3/Makefile|5 +
 drivers/usb/dwc3/core.c  |   78 +-
 drivers/usb/dwc3/core.h  |   19 +-
 drivers/usb/dwc3/dwc3-hi3660.c   |  310 +
 drivers/usb/dwc3/dwc3-hisi.c | 1972 ++
 drivers/usb/dwc3/dwc3-hisi.h |  293 +
 drivers/usb/dwc3/dwc3-otg.c  |  360 ++
 drivers/usb/dwc3/dwc3-otg.h  |  133 ++
 drivers/usb/dwc3/ep0.c   |   55 +-
 drivers/usb/dwc3/gadget.c|   20 +-
 drivers/usb/dwc3/hisi_hikey_gpio.c   |  300 +
 drivers/usb/dwc3/host.c  |   13 +
 drivers/usb/dwc3/io.h|   14 +
 include/linux/hisi/log/hisi_log.h|  143 +++
 include/linux/hisi/usb/hisi_hikey_gpio.h |   24 +
 include/linux/hisi/usb/hisi_usb.h|   57 +
 18 files changed, 3819 insertions(+), 8 deletions(-)
 create mode 100644 drivers/usb/dwc3/dwc3-hi3660.c
 create mode 100644 drivers/usb/dwc3/dwc3-hisi.c
 create mode 100644 drivers/usb/dwc3/dwc3-hisi.h
 create mode 100644 drivers/usb/dwc3/dwc3-otg.c
 create mode 100644 drivers/usb/dwc3/dwc3-otg.h
 create mode 100644 drivers/usb/dwc3/hisi_hikey_gpio.c
 create mode 100644 include/linux/hisi/log/hisi_log.h
 create mode 100644 include/linux/hisi/usb/hisi_hikey_gpio.h
 create mode 100644 include/linux/hisi/usb/hisi_usb.h

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 34480e9af2e7..8e61b7d96bba 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -405,6 +405,7 @@ CONFIG_SND_SOC_SAMSUNG=y
 CONFIG_SND_SOC_RCAR=m
 CONFIG_SND_SOC_AK4613=m
 CONFIG_SND_SIMPLE_CARD=y
+CONFIG_HISI_HIKEY_GPIO=y
 CONFIG_USB=y
 CONFIG_USB_OTG=y
 CONFIG_USB_XHCI_HCD=y
@@ -419,6 +420,9 @@ CONFIG_USB_OHCI_HCD_PLATFORM=y
 CONFIG_USB_RENESAS_USBHS=m
 CONFIG_USB_STORAGE=y
 CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_DUAL_ROLE=y
+CONFIG_USB_DWC3_HISI=y
+CONFIG_USB_DWC3_OTG=y
 CONFIG_USB_DWC2=y
 CONFIG_USB_CHIPIDEA=y
 CONFIG_USB_CHIPIDEA_UDC=y
@@ -428,6 +432,7 @@ CONFIG_USB_HSIC_USB3503=y
 CONFIG_NOP_USB_XCEIV=y
 CONFIG_USB_MSM_OTG=y
 CONFIG_USB_QCOM_8X16_PHY=y
+CONFIG_EXTCON=y
 CONFIG_USB_ULPI=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_RENESAS_USBHS_UDC=m
diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
index ab8c0e0d3b60..5f7d9f19f503 100644
--- a/drivers/usb/dwc3/Kconfig
+++ b/drivers/usb/dwc3/Kconfig
@@ -106,4 +106,30 @@ config USB_DWC3_ST
  inside (i.e. STiH407).
  Say 'Y' or 'M' if you have one such device.
 
+config USB_DWC3_HISI
+   tristate "Hisilicon Platforms"
+   select USB_DWC3_OTG
+   depends on USB_DWC3
+   default n
+   help
+ Support of USB2/3 functionality in hisilicon platforms,
+ Say 'Y' or 'M' here if you have one such device.
+ Use for hisilicon device and it will select USB_DWC3_OTG
+ if Say 'Y' or 'M' here.
+
+config USB_DWC3_OTG
+   bool "Enable DWC3 OTG"
+   default n
+   help
+ Support of USB2/3 functionality in hisilicon platforms,
+ Say 'Y' or 'M' here if you have one such device.
+ Use for hisilicon device
+ if Say 'Y' or 'M' here.
+
+config HISI_HIKEY_GPIO
+tristate "HISI_HIKEY_GPIO"
+depends on GPIOLIB
+default n
+help
+   If you say yes here you get support for hisi hikey gpio.
 endif
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index f15fabbd1e59..c2c32a5effc7 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -1,6 +1,7 @@
 # define_trace.h needs to know how to find our header
 CFLAGS_trace.o := -I$(src)
 
+ccflags-$(CONFIG_USB_DWC3_OTG) += -DDWC3_OTG_FORCE_MODE
 obj-$(CONFIG_USB_DWC3) += dwc3.o
 
 dwc3-y := core.o
@@ -29,6 +30,8 @@ ifneq ($(CONFIG_DEBUG_FS),)
dwc3-y  += debugfs.o
 endif
 
+dwc3-$(CONFIG_USB_DWC3_OTG)+= dwc3-otg.o
+
 ##
 # Platform-specific glue layers go here
 #
@@ -47,3 +50,5 @@ 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_ST)  += dwc3-st.o
+obj-$(CONFIG_USB_DWC3_HISI)+= dwc3-hisi.o  dwc3-hi3660.o
+obj-$(CONFIG_HISI_HIKEY_GPIO)  += hisi_hikey_gpio.o
diff --git a/drivers/usb/dw

[RFC 3/3] arm64: dts: Modify device tree for support Hikey960

2017-10-24 Thread Yu Chen
Add dts for usb module of Hikey960.

Signed-off-by: Yu Chen <cheny...@huawei.com>
Signed-off-by: Ning Fan <fanni...@hisilicon.com>
Signed-off-by: Di Yang <yangd...@hisilicon.com>
Signed-off-by: Rui Li <liru...@hisilicon.com>

---
 arch/arm64/boot/dts/hisilicon/hi3660.dtsi | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi 
b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
index b7a90d632959..dff3e68c5e38 100644
--- a/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
+++ b/arch/arm64/boot/dts/hisilicon/hi3660.dtsi
@@ -324,6 +324,18 @@
status = "disabled";
};
 
+   hubv2: gpio_hubv2 {
+   compatible = "hisilicon,gpio_hubv2";
+   typc_vbus_int_gpio,typec-gpios = < 2 0>;
+   typc_vbus_enable_val = <1>;
+   otg_gpio = < 6 0>;
+   hub_vdd12_en_gpio = < 1 0>;
+   hub_vdd33_en_gpio = < 6 0>;
+   hub_reset_en_gpio = < 4 0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_pmx_func>;
+   };
+
i2c3: i2c@fdf0c000 {
compatible = "snps,designware-i2c";
reg = <0x0 0xfdf0c000 0x0 0x1000>;
@@ -978,5 +990,32 @@
clocks = <_ctrl HI3660_OSC32K>;
clock-names = "apb_pclk";
};
+
+   hisi_usb@ff20 {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   compatible = "hisilicon,hi3660-dwc3";
+   reg = <0x0 0xff20 0x0 0x1000
+0x0 0xff10 0x0 0x10>;
+   ranges;
+   bc_again_flag = <0>;
+
+   clocks = <_ctrl HI3660_CLK_ABB_USB>,
+<_ctrl HI3660_ACLK_GATE_USB3OTG>;
+   clock-names = "clk_usb3phy_ref", "aclk_usb3otg";
+   eye_diagram_param = <0x1c466e3>;
+   eye_diagram_host_param = <0x1c466e3>;
+   usb3_phy_cr_param = <0xb80>;
+   usb3_phy_host_cr_param = <0x980>;
+   usb3_phy_tx_vboost_lvl = <0x5>;
+
+   dwc3@ff10 {
+   compatible = "snps,dwc3";
+   reg = <0x0 0xff10 0x0 0x10>;
+   interrupts = <0 159 4>, <0 161 4>;
+   dr_mode = "otg";
+   maximum-speed = "super-speed";
+   };
+   };
};
 };
-- 
2.11.GIT


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