Re: [PATCH v5 0/5] Add support for Fujitsu USB host controller
2015-03-11 5:30 GMT+08:00 Felipe Balbi ba...@ti.com: On Sun, Feb 22, 2015 at 12:25:35PM +0800, Sneeker Yeh wrote: These patches add support for XHCI compliant Host controller found on Fujitsu Socs, and are based on http://lwn.net/Articles/629162/ The first patch is to add Fujitsu glue layer of Synopsis DesignWare USB3 driver and last four patch is about quirk implementation of errata in Synopsis DesignWare USB3 IP. Patch 1 introduces a quirk with device disconnection management necessary Synopsys Designware USB3 IP with versions 3.00a and hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. It solves a problem where without the quirk, that host controller will die after a usb device is disconnected from port of root hub. Patch 2 is to set Synopsis quirk in xhci platform driver based on xhci platform data. Patch 3 is to add a revison number 2.90a and 3.00a of Synopsis DesignWare USB3 IP core driver. Patch 4 introduces using a quirk based on a errata of Synopsis DesignWare USB3 IP which is versions 3.00a and has hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, which cannot be read from software. As a result this quirk has to be enabled via platform data or device tree. Patch 5 introduces Fujitsu Specific Glue layer in Synopsis DesignWare USB3 IP driver. Successfully tested on Fujitsu mb86s7x board. Changes since v4 (RFC): [https://lkml.org/lkml/2015/2/17/13] - based on Felipe's comment, rename dwc3-mb86s70.c to dwc3-fujitsu.c which is more generic. - based on Mathias's comment, remove unhelpful comment, and change the function name of xhci_try_to_clear_csc() to xhci_late_csc_clear_quirk() which is more appropriate. Changes since v3 (RFC): [https://lkml.org/lkml/2015/1/25/8] - based on Mathias's comment, fix bug and using xhci_port_state_to_neutral() helper function to mask out some RW1C bits, prevent writing back all the bits read from the PORTSC register. Changes since v2 (RFC): [https://lkml.org/lkml/2015/1/19/55] - based on Felipe's comment, re-order patches to avoid breaking bisectability, - based on Felipe's comment, add comment to structure's member, and sort it alphabetically, - based on Felipe's comment, add another v2.90 revision number in dwc3 IP. Changes since v1 (RFC): [https://lkml.org/lkml/2014/12/15/929] - based on Arnd's comment, remove entire unnecessary Fujitsu EHCI/OHCI glue, - based on Felipe's comment, fix mis-using of runtime-pm API and setting dma mask, remove unnecessary comment, and refactor suspend/resume handler in Fujitsu Specific Glue layer in dwc3, - based on Felipe's comment, add more commit log and comments in Synopsis quirk implementation, and separate it into four patches. Sneeker Yeh (5): xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core xhci: Platform: Set Synopsis device disconnection quirk based on platform data usb: dwc3: add revision number DWC3_REVISION_290A and DWC3_REVISION_300A usb: dwc3: Add quirk for Synopsis device disconnection errata usb: dwc3: add Fujitsu Specific Glue layer Mathias, if you want me to take this series I need your Acked-by, otherwise I can give you mine, just let me know. Hi Mathias, I hope I'm not imposing here, but would you let me know if there's any further comment for the patchset. Much appreciate, Sneeker -- balbi -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 3/5] usb: dwc3: add revision number DWC3_REVISION_290A and DWC3_REVISION_300A
Add the contstant for v2.90a and v3.00a dwc3 IP detection Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/dwc3/core.h |2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index d201910..0b3bb0f 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -772,6 +772,8 @@ struct dwc3 { #define DWC3_REVISION_260A 0x5533260a #define DWC3_REVISION_270A 0x5533270a #define DWC3_REVISION_280A 0x5533280a +#define DWC3_REVISION_290A 0x5533290a +#define DWC3_REVISION_300A 0x5533300a enum dwc3_ep0_next ep0_next_event; enum dwc3_ep0_state ep0state; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 2/5] xhci: Platform: Set Synopsis device disconnection quirk based on platform data
If an xhci platform has Synopsis device disconnection errata then enable XHCI_DISCONNECT_QUIRK quirk flag. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-plat.c |3 +++ include/linux/usb/xhci_pdriver.h |4 2 files changed, 7 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 08d402b..40beb95 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -147,6 +147,9 @@ static int xhci_plat_probe(struct platform_device *pdev) if ((node of_property_read_bool(node, usb3-lpm-capable)) || (pdata pdata-usb3_lpm_capable)) xhci-quirks |= XHCI_LPM_SUPPORT; + + if (pdata pdata-delay_portcsc_clear) + xhci-quirks |= XHCI_DISCONNECT_QUIRK; /* * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset) * is called by usb_add_hcd(). diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h index 376654b..a37a3a5 100644 --- a/include/linux/usb/xhci_pdriver.h +++ b/include/linux/usb/xhci_pdriver.h @@ -18,10 +18,14 @@ * * @usb3_lpm_capable: determines if this xhci platform supports USB3 * LPM capability + * @delay_portcsc_clear: determines if Synopsis USB3 core has errata in + * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 hardware + * configuration. * */ struct usb_xhci_pdata { unsignedusb3_lpm_capable:1; + unsigneddelay_portcsc_clear:1; }; #endif /* __USB_CORE_XHCI_PDRIVER_H */ -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 4/5] usb: dwc3: Add quirk for Synopsis device disconnection errata
Synopsis Designware USB3 IP earlier than v3.00a which is configured in silicon with DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, would need a specific quirk to prevent xhci host controller from dying when device is disconnected. Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP configuration whose state cannot be checked from software in runtime, it has to be enabled via platform data or device tree. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- Documentation/devicetree/bindings/usb/dwc3.txt | 17 + drivers/usb/dwc3/core.c|6 ++ drivers/usb/dwc3/core.h|4 drivers/usb/dwc3/host.c|4 drivers/usb/dwc3/platform_data.h |8 5 files changed, 39 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index cd7f045..1b78b29 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -37,6 +37,23 @@ Optional properties: - 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 + - snps,has_suspend_on_disconnect: true when IP is configured in silicon with + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, it can inject a + specific quirk to prevent xhci host controller from + dying when usb device is disconnected from root hub. + Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP + configuration whose state cannot be checked from + software in runtime, it has to be enabled via platform + data or device tree. + + xhci host dying symptom here is caused by that + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 + configuration makes IP auto-suspended after PORTCSC is + cleared when usb device detached, then an asynchronous + disconnection procedure might fail using endpoint + command that suspened IP won't have any response to. + + this issue is fixed when IP version = 3.00a. This is usually a subnode to DWC3 glue to which it is connected. diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 9f0e209..705980c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -838,6 +838,9 @@ static int dwc3_probe(struct platform_device *pdev) snps,tx_de_emphasis_quirk); of_property_read_u8(node, snps,tx_de_emphasis, tx_de_emphasis); + + dwc-suspend_on_disconnect_quirk = of_property_read_bool(node, + snps,has_suspend_on_disconnect); } else if (pdata) { dwc-maximum_speed = pdata-maximum_speed; dwc-has_lpm_erratum = pdata-has_lpm_erratum; @@ -864,6 +867,9 @@ static int dwc3_probe(struct platform_device *pdev) dwc-tx_de_emphasis_quirk = pdata-tx_de_emphasis_quirk; if (pdata-tx_de_emphasis) tx_de_emphasis = pdata-tx_de_emphasis; + + dwc-suspend_on_disconnect_quirk = + pdata-has_suspend_on_disconnect; } /* default to superspeed if no maximum_speed passed */ diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 0b3bb0f..dfc7d63 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -688,6 +688,9 @@ struct dwc3_scratchpad_array { * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes. * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround * @start_config_issued: true when StartConfig command has been issued + * @suspend_on_disconnect_quirk: set if core was configured with + * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. Note that there's + * now way for software to detect this in runtime. * @three_stage_setup: set if we perform a three phase setup * @disable_scramble_quirk: set if we enable the disable scramble quirk * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk @@ -813,6 +816,7 @@ struct dwc3 { unsignedresize_fifos:1; unsignedsetup_packet_pending:1; unsignedstart_config_issued:1; + unsignedsuspend_on_disconnect_quirk:1; unsignedthree_stage_setup:1; unsigneddisable_scramble_quirk:1; diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 12bfd3c..9c42074 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -53,6 +53,10 @@ int dwc3_host_init(struct dwc3 *dwc
[PATCH v5 5/5] usb: dwc3: add Fujitsu Specific Glue layer
This patch adds support for Synopsis DesignWare USB3 IP Core found on Fujitsu Socs. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- .../devicetree/bindings/usb/fujitsu-dwc3.txt | 33 drivers/usb/dwc3/Kconfig | 10 + drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/dwc3-fujitsu.c| 206 4 files changed, 250 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-fujitsu.c diff --git a/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt new file mode 100644 index 000..fd16fe9 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt @@ -0,0 +1,33 @@ +FUJITSU GLUE COMPONENTS + +MB86S7x DWC3 GLUE +- compatible: Should be fujitsu,mb86s7x-dwc3 +- clocks: from common clock binding, handle to usb clock. +- clock-names: Should contain the following: + core Master/Core clock needs to run at a minimum of 125 MHz to + support a 4 Gbps IN or 4 Gbps OUT + transfer at a given time. + +Sub-nodes: +The dwc3 core should be added as subnode to MB86S7x dwc3 glue. +- dwc3 : + The binding details of dwc3 can be found in: + Documentation/devicetree/bindings/usb/dwc3.txt + +Example device nodes: + + usb3host: mb86s7x_usb3host { + compatible = fujitsu,mb86s7x-dwc3; + clocks = clk_alw_1_1; + clock-names = core; + #address-cells = 2; + #size-cells = 1; + ranges; + + dwc3@3220 { + compatible = synopsys,dwc3; + reg = 0 0x3230 0x10; + interrupts = 0 412 0x4, + 0 414 0x4; + }; + }; diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index edbf9c8..2e145ca 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -97,6 +97,16 @@ config USB_DWC3_QCOM Recent Qualcomm SoCs ship with one DesignWare Core USB3 IP inside, say 'Y' or 'M' if you have one such device. +config USB_DWC3_FUJITSU + tristate Fujitsu MB86S7x Designware USB3 Platform code + default USB_DWC3 + help + MB86S7X SOC ship with DesignWare Core USB3 IP inside, + this implementation also integrated Fujitsu USB PHY inside + this Core USB3 IP. + + say 'Y' or 'M' if you have one such device. + comment Debugging features config USB_DWC3_DEBUG diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index 46172f4..a92c747 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -37,3 +37,4 @@ obj-$(CONFIG_USB_DWC3_PCI)+= dwc3-pci.o obj-$(CONFIG_USB_DWC3_KEYSTONE)+= dwc3-keystone.o obj-$(CONFIG_USB_DWC3_QCOM)+= dwc3-qcom.o obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o +obj-$(CONFIG_USB_DWC3_FUJITSU) += dwc3-fujitsu.o diff --git a/drivers/usb/dwc3/dwc3-fujitsu.c b/drivers/usb/dwc3/dwc3-fujitsu.c new file mode 100644 index 000..307a44c --- /dev/null +++ b/drivers/usb/dwc3/dwc3-fujitsu.c @@ -0,0 +1,206 @@ +/** + * dwc3-fujitsu.c - Fujitsu mb86s7x DWC3 Specific Glue layer + * + * Copyright (c) 2013 - 2015 FUJITSU SEMICONDUCTOR LIMITED + * http://jp.fujitsu.com/group/fsl + * + * Authors: Alice Chan alice.c...@tw.fujitsu.com + * Sneeker Yeh sneeker@tw.fujitsu.com + * based on dwc3-exynos.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include linux/module.h +#include linux/kernel.h +#include linux/slab.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/interrupt.h +#include linux/of.h +#include linux/of_platform.h +#include linux/pm_runtime.h +#include linux/clk.h + +struct dwc3_mb86s7x { + struct device *dev; + struct clk *clks[5]; + u8 clk_cnt; +}; + +static int dwc3_mb86s7x_clk_control(struct device *dev, bool on) +{ + struct dwc3_mb86s7x *priv = dev_get_drvdata(dev); + int ret, i = priv-clk_cnt; + + if (!on) + goto clock_off; + + for (i = 0; i priv-clk_cnt; i++) { + ret = clk_prepare_enable(priv-clks[i]); + if (ret) { + dev_err(dev, failed to enable clock[%d]\n, i); + on = ret; + goto clock_off; + } + } + + return 0; + +clock_off: + for (; i 0;) + clk_disable_unprepare(priv-clks[--i]); + + return on; +} + +static int dwc3_mb86s7x_remove_child(struct device
[PATCH v5 0/5] Add support for Fujitsu USB host controller
These patches add support for XHCI compliant Host controller found on Fujitsu Socs, and are based on http://lwn.net/Articles/629162/ The first patch is to add Fujitsu glue layer of Synopsis DesignWare USB3 driver and last four patch is about quirk implementation of errata in Synopsis DesignWare USB3 IP. Patch 1 introduces a quirk with device disconnection management necessary Synopsys Designware USB3 IP with versions 3.00a and hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. It solves a problem where without the quirk, that host controller will die after a usb device is disconnected from port of root hub. Patch 2 is to set Synopsis quirk in xhci platform driver based on xhci platform data. Patch 3 is to add a revison number 2.90a and 3.00a of Synopsis DesignWare USB3 IP core driver. Patch 4 introduces using a quirk based on a errata of Synopsis DesignWare USB3 IP which is versions 3.00a and has hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, which cannot be read from software. As a result this quirk has to be enabled via platform data or device tree. Patch 5 introduces Fujitsu Specific Glue layer in Synopsis DesignWare USB3 IP driver. Successfully tested on Fujitsu mb86s7x board. Changes since v4 (RFC): [https://lkml.org/lkml/2015/2/17/13] - based on Felipe's comment, rename dwc3-mb86s70.c to dwc3-fujitsu.c which is more generic. - based on Mathias's comment, remove unhelpful comment, and change the function name of xhci_try_to_clear_csc() to xhci_late_csc_clear_quirk() which is more appropriate. Changes since v3 (RFC): [https://lkml.org/lkml/2015/1/25/8] - based on Mathias's comment, fix bug and using xhci_port_state_to_neutral() helper function to mask out some RW1C bits, prevent writing back all the bits read from the PORTSC register. Changes since v2 (RFC): [https://lkml.org/lkml/2015/1/19/55] - based on Felipe's comment, re-order patches to avoid breaking bisectability, - based on Felipe's comment, add comment to structure's member, and sort it alphabetically, - based on Felipe's comment, add another v2.90 revision number in dwc3 IP. Changes since v1 (RFC): [https://lkml.org/lkml/2014/12/15/929] - based on Arnd's comment, remove entire unnecessary Fujitsu EHCI/OHCI glue, - based on Felipe's comment, fix mis-using of runtime-pm API and setting dma mask, remove unnecessary comment, and refactor suspend/resume handler in Fujitsu Specific Glue layer in dwc3, - based on Felipe's comment, add more commit log and comments in Synopsis quirk implementation, and separate it into four patches. Sneeker Yeh (5): xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core xhci: Platform: Set Synopsis device disconnection quirk based on platform data usb: dwc3: add revision number DWC3_REVISION_290A and DWC3_REVISION_300A usb: dwc3: Add quirk for Synopsis device disconnection errata usb: dwc3: add Fujitsu Specific Glue layer Documentation/devicetree/bindings/usb/dwc3.txt | 17 ++ .../devicetree/bindings/usb/fujitsu-dwc3.txt | 33 drivers/usb/dwc3/Kconfig | 10 + drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/core.c|6 + drivers/usb/dwc3/core.h|6 + drivers/usb/dwc3/dwc3-fujitsu.c| 206 drivers/usb/dwc3/host.c|4 + drivers/usb/dwc3/platform_data.h |8 + drivers/usb/host/xhci-hub.c|4 + drivers/usb/host/xhci-plat.c |3 + drivers/usb/host/xhci.c| 33 drivers/usb/host/xhci.h| 24 +++ include/linux/usb/xhci_pdriver.h |4 + 14 files changed, 359 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-fujitsu.c -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 5/5] usb: dwc3: add Fujitsu Specific Glue layer
hi Felipe: thanks for the suggestion, 2015-02-18 3:26 GMT+08:00 Felipe Balbi ba...@ti.com: On Tue, Feb 17, 2015 at 01:41:37PM +0800, Sneeker Yeh wrote: This patch adds support for Synopsis DesignWare USB3 IP Core found on Fujitsu Socs. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- .../devicetree/bindings/usb/fujitsu-dwc3.txt | 33 drivers/usb/dwc3/Kconfig | 11 ++ drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/dwc3-mb86s70.c| 206 4 files changed, 251 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-mb86s70.c what's the possibility that fujitsu will make another SoC with dwc3 in it ? I wonder if we should use a slightly more generic name here: dwc3-fujitsu.c ? We did have several SoC that has dwc3 in it, dwc3-fujitsu.c looks fine, and I would like to take this to next patchset. Much appreciate, Sneeker -- balbi -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/5] xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core
hi Mathias, thanks for reviewing these, 2015-02-18 16:47 GMT+08:00 Mathias Nyman mathias.ny...@intel.com: Hi This looks correct, but if you are still going to make a new series fixing Felipe's comments then the following tiny nitpicks could be fixed as well. Otherwise Acked-by: Mathias Nyman mathias.ny...@linux.intel.com Felipe, Do you want to take this series through your tree? On 17.02.2015 07:41, Sneeker Yeh wrote: +static void xhci_try_to_clear_csc(struct usb_hcd *hcd, int dev_port_num) Either add a function description explaining something like Late clearing of connect status. Some quirky hardware will suspend the controller when CSC bit is cleared and leave URBs unhandled Or change the function name to something like xhci_late_csc_clear_quirk() or xhci_deferred_csc_clear_quirk() Maybe the name should be changed anyways. The try to makes it look like some non-blocking version of a csc clear function. hm...thanks...it totally make sense, i'd like to use xhci_deferred_csc_clear_quirk(), and will take it to my next patches. +{ + int max_ports; + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + __le32 __iomem **port_array; + u32 status; + + /* print debug info */ Remove this comment okay, i see. + if (hcd-speed == HCD_USB3) { + max_ports = xhci-num_usb3_ports; + port_array = xhci-usb3_ports; + } else { + max_ports = xhci-num_usb2_ports; + port_array = xhci-usb2_ports; + } + + if (dev_port_num max_ports) { + xhci_err(xhci, %s() port number invalid, __func__); + return; + } + status = readl(port_array[dev_port_num - 1]); + + /* write 1 to clear */ Not really a helpful comment either, either remove or change to something like clearing the connect status bit will now immediately suspend these quirky controllers okay, i got it , thanks. Much appreciate, Sneeker -Mathias -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 2/5] xhci: Platform: Set Synopsis device disconnection quirk based on platform data
If an xhci platform has Synopsis device disconnection errata then enable XHCI_DISCONNECT_QUIRK quirk flag. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-plat.c |3 +++ include/linux/usb/xhci_pdriver.h |4 2 files changed, 7 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 08d402b..40beb95 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -147,6 +147,9 @@ static int xhci_plat_probe(struct platform_device *pdev) if ((node of_property_read_bool(node, usb3-lpm-capable)) || (pdata pdata-usb3_lpm_capable)) xhci-quirks |= XHCI_LPM_SUPPORT; + + if (pdata pdata-delay_portcsc_clear) + xhci-quirks |= XHCI_DISCONNECT_QUIRK; /* * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset) * is called by usb_add_hcd(). diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h index 376654b..a37a3a5 100644 --- a/include/linux/usb/xhci_pdriver.h +++ b/include/linux/usb/xhci_pdriver.h @@ -18,10 +18,14 @@ * * @usb3_lpm_capable: determines if this xhci platform supports USB3 * LPM capability + * @delay_portcsc_clear: determines if Synopsis USB3 core has errata in + * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 hardware + * configuration. * */ struct usb_xhci_pdata { unsignedusb3_lpm_capable:1; + unsigneddelay_portcsc_clear:1; }; #endif /* __USB_CORE_XHCI_PDRIVER_H */ -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 5/5] usb: dwc3: add Fujitsu Specific Glue layer
This patch adds support for Synopsis DesignWare USB3 IP Core found on Fujitsu Socs. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- .../devicetree/bindings/usb/fujitsu-dwc3.txt | 33 drivers/usb/dwc3/Kconfig | 11 ++ drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/dwc3-mb86s70.c| 206 4 files changed, 251 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-mb86s70.c diff --git a/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt new file mode 100644 index 000..be091eb --- /dev/null +++ b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt @@ -0,0 +1,33 @@ +FUJITSU GLUE COMPONENTS + +MB86S7x DWC3 GLUE +- compatible: Should be fujitsu,mb86s70-dwc3 +- clocks: from common clock binding, handle to usb clock. +- clock-names: Should contain the following: + core Master/Core clock needs to run at a minimum of 125 MHz to + support a 4 Gbps IN or 4 Gbps OUT + transfer at a given time. + +Sub-nodes: +The dwc3 core should be added as subnode to MB86S7x dwc3 glue. +- dwc3 : + The binding details of dwc3 can be found in: + Documentation/devicetree/bindings/usb/dwc3.txt + +Example device nodes: + + usb3host: mb86s70_usb3host { + compatible = fujitsu,mb86s70-dwc3; + clocks = clk_alw_1_1; + clock-names = core; + #address-cells = 2; + #size-cells = 1; + ranges; + + dwc3@3220 { + compatible = synopsys,dwc3; + reg = 0 0x3230 0x10; + interrupts = 0 412 0x4, + 0 414 0x4; + }; + }; diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index edbf9c8..8ab0f2c 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -61,6 +61,17 @@ config USB_DWC3_EXYNOS Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside, say 'Y' or 'M' if you have one such device. +config USB_DWC3_MB86S70 + tristate MB86S70 Designware USB3 Platform code + default USB_DWC3 + help + MB86S7X SOC ship with DesignWare Core USB3 IP inside, + this implementation also integrated Fujitsu USB PHY inside + this Core USB3 IP. + + say 'Y' or 'M' if you have one such device. + + config USB_DWC3_PCI tristate PCIe-based Platforms depends on PCI diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index 46172f4..76634b7 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -37,3 +37,4 @@ obj-$(CONFIG_USB_DWC3_PCI)+= dwc3-pci.o obj-$(CONFIG_USB_DWC3_KEYSTONE)+= dwc3-keystone.o obj-$(CONFIG_USB_DWC3_QCOM)+= dwc3-qcom.o obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o +obj-$(CONFIG_USB_DWC3_MB86S70) += dwc3-mb86s70.o diff --git a/drivers/usb/dwc3/dwc3-mb86s70.c b/drivers/usb/dwc3/dwc3-mb86s70.c new file mode 100644 index 000..301be76 --- /dev/null +++ b/drivers/usb/dwc3/dwc3-mb86s70.c @@ -0,0 +1,206 @@ +/** + * dwc3-mb86s70.c - Fujitsu mb86s70 DWC3 Specific Glue layer + * + * Copyright (c) 2013 - 2014 FUJITSU SEMICONDUCTOR LIMITED + * http://jp.fujitsu.com/group/fsl + * + * Authors: Alice Chan alice.c...@tw.fujitsu.com + * Sneeker Yeh sneeker@tw.fujitsu.com + * based on dwc3-exynos.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include linux/module.h +#include linux/kernel.h +#include linux/slab.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/interrupt.h +#include linux/of.h +#include linux/of_platform.h +#include linux/pm_runtime.h +#include linux/clk.h + +struct dwc3_mb86s70 { + struct device *dev; + struct clk *clks[5]; + u8 clk_cnt; +}; + +static int dwc3_mb86s70_clk_control(struct device *dev, bool on) +{ + struct dwc3_mb86s70 *priv = dev_get_drvdata(dev); + int ret, i = priv-clk_cnt; + + if (!on) + goto clock_off; + + for (i = 0; i priv-clk_cnt; i++) { + ret = clk_prepare_enable(priv-clks[i]); + if (ret) { + dev_err(dev, failed to enable clock[%d]\n, i); + on = ret; + goto clock_off; + } + } + + return 0; + +clock_off: + for (; i 0;) + clk_disable_unprepare(priv-clks[--i]); + + return on; +} + +static int
[PATCH v4 1/5] xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core
This issue is defined by a three-way race at disconnect, between 1) Class driver interrupt endpoint resheduling attempts if the ISR gave an ep error event due to device detach (it would try 3 times) 2) Disconnect interrupt on PORTSC_CSC, which is cleared by hub thread asynchronously 3) The hardware IP was configured in silicon with - DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 - Synopsys IP version is 3.00a The IP will auto-suspend itself on device detach with some phy-specific interval after CSC is cleared by 2) If 2) and 3) complete before 1), the interrupts it expects will not be generated by the autosuspended IP, leading to a deadlock. Even later disconnection procedure would detect that corresponding urb is still in-progress and issue a ep stop command, auto-suspended IP still won't respond to that command. this defect would result in this when device detached: --- [ 99.603544] usb 4-1: USB disconnect, device number 2 [ 104.615254] xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop endpoint command. [ 104.623362] xhci-hcd xhci-hcd.0.auto: Assuming host is dying, halting host. [ 104.653261] xhci-hcd xhci-hcd.0.auto: Host not halted after 16000 microseconds. [ 104.660584] xhci-hcd xhci-hcd.0.auto: Non-responsive xHCI host is not halting. [ 104.667817] xhci-hcd xhci-hcd.0.auto: Completing active URBs anyway. [ 104.674198] xhci-hcd xhci-hcd.0.auto: HC died; cleaning up -- As a result, when device detached, we desired to postpone PORTCSC clear behind disable slot. it's found that all executed ep command related to disconnetion, are executed before disable slot. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-hub.c |4 drivers/usb/host/xhci.c | 31 +++ drivers/usb/host/xhci.h | 24 3 files changed, 59 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index a7865c4..3b8f7fc 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -368,6 +368,10 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, port_change_bit = warm(BH) reset; break; case USB_PORT_FEAT_C_CONNECTION: + if ((xhci-quirks XHCI_DISCONNECT_QUIRK) + !(readl(addr) PORT_CONNECT)) + return; + status = PORT_CSC; port_change_bit = connect; break; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index ec8ac16..1fb8c1c 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3580,6 +3580,35 @@ command_cleanup: return ret; } +static void xhci_try_to_clear_csc(struct usb_hcd *hcd, int dev_port_num) +{ + int max_ports; + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + __le32 __iomem **port_array; + u32 status; + + /* print debug info */ + if (hcd-speed == HCD_USB3) { + max_ports = xhci-num_usb3_ports; + port_array = xhci-usb3_ports; + } else { + max_ports = xhci-num_usb2_ports; + port_array = xhci-usb2_ports; + } + + if (dev_port_num max_ports) { + xhci_err(xhci, %s() port number invalid, __func__); + return; + } + status = readl(port_array[dev_port_num - 1]); + + /* write 1 to clear */ + if (!(status PORT_CONNECT) (status PORT_CSC)) { + status = xhci_port_state_to_neutral(status); + writel(status | PORT_CSC, port_array[dev_port_num - 1]); + } +} + /* * At this point, the struct usb_device is about to go away, the device has * disconnected, and all traffic has been stopped and the endpoints have been @@ -3645,6 +3674,8 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev) xhci_ring_cmd_db(xhci); spin_unlock_irqrestore(xhci-lock, flags); + if (xhci-quirks XHCI_DISCONNECT_QUIRK) + xhci_try_to_clear_csc(hcd, udev-portnum); /* * Event command completion handler will free any data structures * associated with the slot. XXX Can free sleep? diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 9745147..cb74706 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1560,6 +1560,30 @@ struct xhci_hcd { #define XHCI_SPURIOUS_WAKEUP (1 18) /* For controllers with a broken beyond repair streams implementation */ #define XHCI_BROKEN_STREAMS(1 19) +/* + * This issue is defined by a three-way race at disconnect in Synopsis USB3 IP, + * between + * 1) Class driver interrupt endpoint resheduling attempts if the ISR gave an ep + *error event due to device detach (it would try 3 times) + * 2) Disconnect interrupt on PORTSC_CSC, which is cleared by hub
[PATCH v4 0/5] Add support for Fujitsu USB host controller
These patches add support for XHCI compliant Host controller found on Fujitsu Socs, and are based on http://lwn.net/Articles/629162/ The first patch is to add Fujitsu glue layer of Synopsis DesignWare USB3 driver and last four patch is about quirk implementation of errata in Synopsis DesignWare USB3 IP. Patch 1 introduces a quirk with device disconnection management necessary Synopsys Designware USB3 IP with versions 3.00a and hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. It solves a problem where without the quirk, that host controller will die after a usb device is disconnected from port of root hub. Patch 2 is to set Synopsis quirk in xhci platform driver based on xhci platform data. Patch 3 is to add a revison number 2.90a and 3.00a of Synopsis DesignWare USB3 IP core driver. Patch 4 introduces using a quirk based on a errata of Synopsis DesignWare USB3 IP which is versions 3.00a and has hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, which cannot be read from software. As a result this quirk has to be enabled via platform data or device tree. Patch 5 introduces Fujitsu Specific Glue layer in Synopsis DesignWare USB3 IP driver. Successfully tested on Fujitsu mb86s7x board. Changes since v3 (RFC): [https://lkml.org/lkml/2014/12/15/929] - based on Mathias's comment, fix bug and using xhci_port_state_to_neutral() helper function to mask out some RW1C bits, prevent writing back all the bits read from the PORTSC register. Changes since v2 (RFC): [https://lkml.org/lkml/2014/12/15/929] - based on Felipe's comment, re-order patches to avoid breaking bisectability, - based on Felipe's comment, add comment to structure's member, and sort it alphabetically, - based on Felipe's comment, add another v2.90 revision number in dwc3 IP. Changes since v1 (RFC): [https://lkml.org/lkml/2014/12/15/929] - based on Arnd's comment, remove entire unnecessary Fujitsu EHCI/OHCI glue, - based on Felipe's comment, fix mis-using of runtime-pm API and setting dma mask, remove unnecessary comment, and refactor suspend/resume handler in Fujitsu Specific Glue layer in dwc3, - based on Felipe's comment, add more commit log and comments in Synopsis quirk implementation, and separate it into four patches. Sneeker Yeh (5): xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core xhci: Platform: Set Synopsis device disconnection quirk based on platform data usb: dwc3: add revision number DWC3_REVISION_290A and DWC3_REVISION_300A usb: dwc3: Add quirk for Synopsis device disconnection errata usb: dwc3: add Fujitsu Specific Glue layer Documentation/devicetree/bindings/usb/dwc3.txt | 17 ++ .../devicetree/bindings/usb/fujitsu-dwc3.txt | 33 drivers/usb/dwc3/Kconfig | 11 ++ drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/core.c|6 + drivers/usb/dwc3/core.h|6 + drivers/usb/dwc3/dwc3-mb86s70.c| 206 drivers/usb/dwc3/host.c|4 + drivers/usb/dwc3/platform_data.h |8 + drivers/usb/host/xhci-hub.c|4 + drivers/usb/host/xhci-plat.c |3 + drivers/usb/host/xhci.c| 31 +++ drivers/usb/host/xhci.h| 24 +++ include/linux/usb/xhci_pdriver.h |4 + 14 files changed, 358 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-mb86s70.c -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 4/5] usb: dwc3: Add quirk for Synopsis device disconnection errata
Synopsis Designware USB3 IP earlier than v3.00a which is configured in silicon with DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, would need a specific quirk to prevent xhci host controller from dying when device is disconnected. Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP configuration whose state cannot be checked from software in runtime, it has to be enabled via platform data or device tree. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- Documentation/devicetree/bindings/usb/dwc3.txt | 17 + drivers/usb/dwc3/core.c|6 ++ drivers/usb/dwc3/core.h|4 drivers/usb/dwc3/host.c|4 drivers/usb/dwc3/platform_data.h |8 5 files changed, 39 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index cd7f045..1b78b29 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -37,6 +37,23 @@ Optional properties: - 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 + - snps,has_suspend_on_disconnect: true when IP is configured in silicon with + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, it can inject a + specific quirk to prevent xhci host controller from + dying when usb device is disconnected from root hub. + Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP + configuration whose state cannot be checked from + software in runtime, it has to be enabled via platform + data or device tree. + + xhci host dying symptom here is caused by that + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 + configuration makes IP auto-suspended after PORTCSC is + cleared when usb device detached, then an asynchronous + disconnection procedure might fail using endpoint + command that suspened IP won't have any response to. + + this issue is fixed when IP version = 3.00a. This is usually a subnode to DWC3 glue to which it is connected. diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 9f0e209..705980c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -838,6 +838,9 @@ static int dwc3_probe(struct platform_device *pdev) snps,tx_de_emphasis_quirk); of_property_read_u8(node, snps,tx_de_emphasis, tx_de_emphasis); + + dwc-suspend_on_disconnect_quirk = of_property_read_bool(node, + snps,has_suspend_on_disconnect); } else if (pdata) { dwc-maximum_speed = pdata-maximum_speed; dwc-has_lpm_erratum = pdata-has_lpm_erratum; @@ -864,6 +867,9 @@ static int dwc3_probe(struct platform_device *pdev) dwc-tx_de_emphasis_quirk = pdata-tx_de_emphasis_quirk; if (pdata-tx_de_emphasis) tx_de_emphasis = pdata-tx_de_emphasis; + + dwc-suspend_on_disconnect_quirk = + pdata-has_suspend_on_disconnect; } /* default to superspeed if no maximum_speed passed */ diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 0b3bb0f..dfc7d63 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -688,6 +688,9 @@ struct dwc3_scratchpad_array { * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes. * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround * @start_config_issued: true when StartConfig command has been issued + * @suspend_on_disconnect_quirk: set if core was configured with + * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. Note that there's + * now way for software to detect this in runtime. * @three_stage_setup: set if we perform a three phase setup * @disable_scramble_quirk: set if we enable the disable scramble quirk * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk @@ -813,6 +816,7 @@ struct dwc3 { unsignedresize_fifos:1; unsignedsetup_packet_pending:1; unsignedstart_config_issued:1; + unsignedsuspend_on_disconnect_quirk:1; unsignedthree_stage_setup:1; unsigneddisable_scramble_quirk:1; diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 12bfd3c..9c42074 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -53,6 +53,10 @@ int dwc3_host_init(struct dwc3 *dwc
[PATCH v4 3/5] usb: dwc3: add revision number DWC3_REVISION_290A and DWC3_REVISION_300A
Add the contstant for v2.90a and v3.00a dwc3 IP detection Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/dwc3/core.h |2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index d201910..0b3bb0f 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -772,6 +772,8 @@ struct dwc3 { #define DWC3_REVISION_260A 0x5533260a #define DWC3_REVISION_270A 0x5533270a #define DWC3_REVISION_280A 0x5533280a +#define DWC3_REVISION_290A 0x5533290a +#define DWC3_REVISION_300A 0x5533300a enum dwc3_ep0_next ep0_next_event; enum dwc3_ep0_state ep0state; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 1/5] xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core
hi Mathias: thanks for reviewing these patch, and sorry for replying lately~ 2015-02-12 21:50 GMT+08:00 Mathias Nyman mathias.ny...@intel.com: On 25.01.2015 10:13, Sneeker Yeh wrote: This issue is defined by a three-way race at disconnect, between 1) Class driver interrupt endpoint resheduling attempts if the ISR gave an ep error event due to device detach (it would try 3 times) 2) Disconnect interrupt on PORTSC_CSC, which is cleared by hub thread asynchronously 3) The hardware IP was configured in silicon with - DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 - Synopsys IP version is 3.00a The IP will auto-suspend itself on device detach with some phy-specific interval after CSC is cleared by 2) If 2) and 3) complete before 1), the interrupts it expects will not be generated by the autosuspended IP, leading to a deadlock. Even later disconnection procedure would detect that corresponding urb is still in-progress and issue a ep stop command, auto-suspended IP still won't respond to that command. So did I understand correctly that the class driver submits a new urb which is enqueued by xhci_urb_enqueue() before the hub thread notices the device is disconnected. Then hub thread clears CSC bit, controller suspends and the new urb is never given back? yes. Doesn't the CSC bit and PORT_CONNECT bit show the device is disconnected when we enter xhci_enqueue_urb(), even it the hub thread doesn't know this yet? Would it make sense to check those bits in xhci_enqueue_urb, and just return error in the xhci_urb_enqueue() if device is not connected? Then there wouldn't be a need for any quirk at all. ya I tried this before, it would work if i stop enqueue when i found device detached, but sometime it won't work when device might be detached just right after i done enqueue, just like Alan mentioned. If that doesn't work then this patch looks good in general. See comments below this defect would result in this when device detached: --- [ 99.603544] usb 4-1: USB disconnect, device number 2 [ 104.615254] xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop endpoint command. [ 104.623362] xhci-hcd xhci-hcd.0.auto: Assuming host is dying, halting host. [ 104.653261] xhci-hcd xhci-hcd.0.auto: Host not halted after 16000 microseconds. [ 104.660584] xhci-hcd xhci-hcd.0.auto: Non-responsive xHCI host is not halting. [ 104.667817] xhci-hcd xhci-hcd.0.auto: Completing active URBs anyway. [ 104.674198] xhci-hcd xhci-hcd.0.auto: HC died; cleaning up -- As a result, when device detached, we desired to postpone PORTCSC clear behind disable slot. it's found that all executed ep command related to disconnetion, are executed before disable slot. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-hub.c |4 drivers/usb/host/xhci.c | 29 + drivers/usb/host/xhci.h | 24 3 files changed, 57 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index a7865c4..3b8f7fc 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -368,6 +368,10 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, port_change_bit = warm(BH) reset; break; case USB_PORT_FEAT_C_CONNECTION: + if ((xhci-quirks XHCI_DISCONNECT_QUIRK) + !(readl(addr) PORT_CONNECT)) + return; + New port status event are prevented until CSC is cleared, not sure if there's any harm in that? hub thread would be aware of device detach before he try to clear PORTCSC, IIUC, Despite I skip clearing PORTCSC here, whole device detach procedure still behave normally. status = PORT_CSC; port_change_bit = connect; break; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c50d8d2..aa8e02a 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3584,6 +3584,33 @@ command_cleanup: return ret; } +static void xhci_try_to_clear_csc(struct usb_hcd *hcd, int dev_port_num) +{ + int max_ports; + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + __le32 __iomem **port_array; + u32 status; + + /* print debug info */ + if (hcd-speed == HCD_USB3) { + max_ports = xhci-num_usb3_ports; + port_array = xhci-usb3_ports; + } else { + max_ports = xhci-num_usb2_ports; + port_array = xhci-usb2_ports; + } + + if (dev_port_num max_ports) { + xhci_err(xhci, %s() port number invalid, __func__); + return; + } + status = readl(port_array[dev_port_num - 1]); + + /* write 1 to clear */ + if (!(status PORT_CONNECT
Re: [PATCH v3 0/5] Add support for Fujitsu USB host controller
Hi 2015-01-31 0:38 GMT+08:00 Felipe Balbi ba...@ti.com: Hi, On Thu, Jan 29, 2015 at 10:23:12AM -0600, Felipe Balbi wrote: On Tue, Jan 27, 2015 at 09:22:50AM -0600, Felipe Balbi wrote: Hi, On Sun, Jan 25, 2015 at 04:13:23PM +0800, Sneeker Yeh wrote: These patches add support for XHCI compliant Host controller found on Fujitsu Socs, and are based on http://lwn.net/Articles/629162/ The first patch is to add Fujitsu glue layer of Synopsis DesignWare USB3 driver and last four patch is about quirk implementation of errata in Synopsis DesignWare USB3 IP. Patch 1 introduces a quirk with device disconnection management necessary Synopsys Designware USB3 IP with versions 3.00a and hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. It solves a problem where without the quirk, that host controller will die after a usb device is disconnected from port of root hub. Patch 2 is to set Synopsis quirk in xhci platform driver based on xhci platform data. Patch 3 is to add a revison number 2.90a and 3.00a of Synopsis DesignWare USB3 IP core driver. Patch 4 introduces using a quirk based on a errata of Synopsis DesignWare USB3 IP which is versions 3.00a and has hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, which cannot be read from software. As a result this quirk has to be enabled via platform data or device tree. Patch 5 introduces Fujitsu Specific Glue layer in Synopsis DesignWare USB3 IP driver. Mathias, let me know how you want to handle this. Either I take them all, or you take them all. What do you prefer ? Mathias ? Mathias, a reminder on this series. Would any problem is still in my patchset? e.g. I might still not arrange these patch in a appropriate order so that Mathias cannot review and accept these? BR, Sneeker, sincerely -- balbi -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 0/5] Add support for Fujitsu USB host controller
These patches add support for XHCI compliant Host controller found on Fujitsu Socs, and are based on http://lwn.net/Articles/629162/ The first patch is to add Fujitsu glue layer of Synopsis DesignWare USB3 driver and last four patch is about quirk implementation of errata in Synopsis DesignWare USB3 IP. Patch 1 introduces a quirk with device disconnection management necessary Synopsys Designware USB3 IP with versions 3.00a and hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. It solves a problem where without the quirk, that host controller will die after a usb device is disconnected from port of root hub. Patch 2 is to set Synopsis quirk in xhci platform driver based on xhci platform data. Patch 3 is to add a revison number 2.90a and 3.00a of Synopsis DesignWare USB3 IP core driver. Patch 4 introduces using a quirk based on a errata of Synopsis DesignWare USB3 IP which is versions 3.00a and has hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, which cannot be read from software. As a result this quirk has to be enabled via platform data or device tree. Patch 5 introduces Fujitsu Specific Glue layer in Synopsis DesignWare USB3 IP driver. Successfully tested on Fujitsu mb86s7x board. Changes since v2 (RFC): [https://lkml.org/lkml/2014/12/15/929] - based on Felipe's comment, re-order patches to avoid breaking bisectability, - based on Felipe's comment, add comment to structure's member, and sort it alphabetically, - based on Felipe's comment, add another v2.90 revision number in dwc3 IP. Changes since v1 (RFC): [https://lkml.org/lkml/2014/12/15/929] - based on Arnd's comment, remove entire unnecessary Fujitsu EHCI/OHCI glue, - based on Felipe's comment, fix mis-using of runtime-pm API and setting dma mask, remove unnecessary comment, and refactor suspend/resume handler in Fujitsu Specific Glue layer in dwc3, - based on Felipe's comment, add more commit log and comments in Synopsis quirk implementation, and separate it into four patches. Sneeker Yeh (5): xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core xhci: Platform: Set Synopsis device disconnection quirk based on platform data usb: dwc3: add revision number DWC3_REVISION_290A and DWC3_REVISION_300A usb: dwc3: Add quirk for Synopsis device disconnection errata usb: dwc3: add Fujitsu Specific Glue layer Documentation/devicetree/bindings/usb/dwc3.txt | 17 ++ .../devicetree/bindings/usb/fujitsu-dwc3.txt | 33 drivers/usb/dwc3/Kconfig | 11 ++ drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/core.c|6 + drivers/usb/dwc3/core.h|6 + drivers/usb/dwc3/dwc3-mb86s70.c| 206 drivers/usb/dwc3/host.c|4 + drivers/usb/dwc3/platform_data.h |8 + drivers/usb/host/xhci-hub.c|4 + drivers/usb/host/xhci-plat.c |3 + drivers/usb/host/xhci.c| 29 +++ drivers/usb/host/xhci.h| 24 +++ include/linux/usb/xhci_pdriver.h |4 + 14 files changed, 356 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-mb86s70.c -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/5] xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core
This issue is defined by a three-way race at disconnect, between 1) Class driver interrupt endpoint resheduling attempts if the ISR gave an ep error event due to device detach (it would try 3 times) 2) Disconnect interrupt on PORTSC_CSC, which is cleared by hub thread asynchronously 3) The hardware IP was configured in silicon with - DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 - Synopsys IP version is 3.00a The IP will auto-suspend itself on device detach with some phy-specific interval after CSC is cleared by 2) If 2) and 3) complete before 1), the interrupts it expects will not be generated by the autosuspended IP, leading to a deadlock. Even later disconnection procedure would detect that corresponding urb is still in-progress and issue a ep stop command, auto-suspended IP still won't respond to that command. this defect would result in this when device detached: --- [ 99.603544] usb 4-1: USB disconnect, device number 2 [ 104.615254] xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop endpoint command. [ 104.623362] xhci-hcd xhci-hcd.0.auto: Assuming host is dying, halting host. [ 104.653261] xhci-hcd xhci-hcd.0.auto: Host not halted after 16000 microseconds. [ 104.660584] xhci-hcd xhci-hcd.0.auto: Non-responsive xHCI host is not halting. [ 104.667817] xhci-hcd xhci-hcd.0.auto: Completing active URBs anyway. [ 104.674198] xhci-hcd xhci-hcd.0.auto: HC died; cleaning up -- As a result, when device detached, we desired to postpone PORTCSC clear behind disable slot. it's found that all executed ep command related to disconnetion, are executed before disable slot. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-hub.c |4 drivers/usb/host/xhci.c | 29 + drivers/usb/host/xhci.h | 24 3 files changed, 57 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index a7865c4..3b8f7fc 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -368,6 +368,10 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, port_change_bit = warm(BH) reset; break; case USB_PORT_FEAT_C_CONNECTION: + if ((xhci-quirks XHCI_DISCONNECT_QUIRK) + !(readl(addr) PORT_CONNECT)) + return; + status = PORT_CSC; port_change_bit = connect; break; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c50d8d2..aa8e02a 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3584,6 +3584,33 @@ command_cleanup: return ret; } +static void xhci_try_to_clear_csc(struct usb_hcd *hcd, int dev_port_num) +{ + int max_ports; + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + __le32 __iomem **port_array; + u32 status; + + /* print debug info */ + if (hcd-speed == HCD_USB3) { + max_ports = xhci-num_usb3_ports; + port_array = xhci-usb3_ports; + } else { + max_ports = xhci-num_usb2_ports; + port_array = xhci-usb2_ports; + } + + if (dev_port_num max_ports) { + xhci_err(xhci, %s() port number invalid, __func__); + return; + } + status = readl(port_array[dev_port_num - 1]); + + /* write 1 to clear */ + if (!(status PORT_CONNECT) (status PORT_CSC)) + writel(status PORT_CSC, port_array[0]); +} + /* * At this point, the struct usb_device is about to go away, the device has * disconnected, and all traffic has been stopped and the endpoints have been @@ -3649,6 +3676,8 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev) xhci_ring_cmd_db(xhci); spin_unlock_irqrestore(xhci-lock, flags); + if (xhci-quirks XHCI_DISCONNECT_QUIRK) + xhci_try_to_clear_csc(hcd, udev-portnum); /* * Event command completion handler will free any data structures * associated with the slot. XXX Can free sleep? diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index cc7c5bb..65a65cc 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1560,6 +1560,30 @@ struct xhci_hcd { #define XHCI_SPURIOUS_WAKEUP (1 18) /* For controllers with a broken beyond repair streams implementation */ #define XHCI_BROKEN_STREAMS(1 19) +/* + * This issue is defined by a three-way race at disconnect in Synopsis USB3 IP, + * between + * 1) Class driver interrupt endpoint resheduling attempts if the ISR gave an ep + *error event due to device detach (it would try 3 times) + * 2) Disconnect interrupt on PORTSC_CSC, which is cleared by hub thread + *asynchronously + * 3) The hardware IP was configured in silicon
[PATCH v3 2/5] xhci: Platform: Set Synopsis device disconnection quirk based on platform data
If an xhci platform has Synopsis device disconnection errata then enable XHCI_DISCONNECT_QUIRK quirk flag. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-plat.c |3 +++ include/linux/usb/xhci_pdriver.h |4 2 files changed, 7 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 08d402b..40beb95 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -147,6 +147,9 @@ static int xhci_plat_probe(struct platform_device *pdev) if ((node of_property_read_bool(node, usb3-lpm-capable)) || (pdata pdata-usb3_lpm_capable)) xhci-quirks |= XHCI_LPM_SUPPORT; + + if (pdata pdata-delay_portcsc_clear) + xhci-quirks |= XHCI_DISCONNECT_QUIRK; /* * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset) * is called by usb_add_hcd(). diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h index 376654b..a37a3a5 100644 --- a/include/linux/usb/xhci_pdriver.h +++ b/include/linux/usb/xhci_pdriver.h @@ -18,10 +18,14 @@ * * @usb3_lpm_capable: determines if this xhci platform supports USB3 * LPM capability + * @delay_portcsc_clear: determines if Synopsis USB3 core has errata in + * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 hardware + * configuration. * */ struct usb_xhci_pdata { unsignedusb3_lpm_capable:1; + unsigneddelay_portcsc_clear:1; }; #endif /* __USB_CORE_XHCI_PDRIVER_H */ -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 4/5] usb: dwc3: Add quirk for Synopsis device disconnection errata
Synopsis Designware USB3 IP earlier than v3.00a which is configured in silicon with DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, would need a specific quirk to prevent xhci host controller from dying when device is disconnected. Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP configuration whose state cannot be checked from software in runtime, it has to be enabled via platform data or device tree. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- Documentation/devicetree/bindings/usb/dwc3.txt | 17 + drivers/usb/dwc3/core.c|6 ++ drivers/usb/dwc3/core.h|4 drivers/usb/dwc3/host.c|4 drivers/usb/dwc3/platform_data.h |8 5 files changed, 39 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index cd7f045..1b78b29 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -37,6 +37,23 @@ Optional properties: - 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 + - snps,has_suspend_on_disconnect: true when IP is configured in silicon with + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, it can inject a + specific quirk to prevent xhci host controller from + dying when usb device is disconnected from root hub. + Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP + configuration whose state cannot be checked from + software in runtime, it has to be enabled via platform + data or device tree. + + xhci host dying symptom here is caused by that + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 + configuration makes IP auto-suspended after PORTCSC is + cleared when usb device detached, then an asynchronous + disconnection procedure might fail using endpoint + command that suspened IP won't have any response to. + + this issue is fixed when IP version = 3.00a. This is usually a subnode to DWC3 glue to which it is connected. diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 25ddc39..fbceab1 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -838,6 +838,9 @@ static int dwc3_probe(struct platform_device *pdev) snps,tx_de_emphasis_quirk); of_property_read_u8(node, snps,tx_de_emphasis, tx_de_emphasis); + + dwc-suspend_on_disconnect_quirk = of_property_read_bool(node, + snps,has_suspend_on_disconnect); } else if (pdata) { dwc-maximum_speed = pdata-maximum_speed; dwc-has_lpm_erratum = pdata-has_lpm_erratum; @@ -864,6 +867,9 @@ static int dwc3_probe(struct platform_device *pdev) dwc-tx_de_emphasis_quirk = pdata-tx_de_emphasis_quirk; if (pdata-tx_de_emphasis) tx_de_emphasis = pdata-tx_de_emphasis; + + dwc-suspend_on_disconnect_quirk = + pdata-has_suspend_on_disconnect; } /* default to superspeed if no maximum_speed passed */ diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 46f9f9a..c730190 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -692,6 +692,9 @@ struct dwc3_scratchpad_array { * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes. * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround * @start_config_issued: true when StartConfig command has been issued + * @suspend_on_disconnect_quirk: set if core was configured with + * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. Note that there's + * now way for software to detect this in runtime. * @three_stage_setup: set if we perform a three phase setup * @disable_scramble_quirk: set if we enable the disable scramble quirk * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk @@ -818,6 +821,7 @@ struct dwc3 { unsignedresize_fifos:1; unsignedsetup_packet_pending:1; unsignedstart_config_issued:1; + unsignedsuspend_on_disconnect_quirk:1; unsignedthree_stage_setup:1; unsigneddisable_scramble_quirk:1; diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 12bfd3c..9c42074 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -53,6 +53,10 @@ int dwc3_host_init(struct dwc3 *dwc
[PATCH v3 5/5] usb: dwc3: add Fujitsu Specific Glue layer
This patch adds support for Synopsis DesignWare USB3 IP Core found on Fujitsu Socs. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- .../devicetree/bindings/usb/fujitsu-dwc3.txt | 33 drivers/usb/dwc3/Kconfig | 11 ++ drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/dwc3-mb86s70.c| 206 4 files changed, 251 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-mb86s70.c diff --git a/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt new file mode 100644 index 000..be091eb --- /dev/null +++ b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt @@ -0,0 +1,33 @@ +FUJITSU GLUE COMPONENTS + +MB86S7x DWC3 GLUE +- compatible: Should be fujitsu,mb86s70-dwc3 +- clocks: from common clock binding, handle to usb clock. +- clock-names: Should contain the following: + core Master/Core clock needs to run at a minimum of 125 MHz to + support a 4 Gbps IN or 4 Gbps OUT + transfer at a given time. + +Sub-nodes: +The dwc3 core should be added as subnode to MB86S7x dwc3 glue. +- dwc3 : + The binding details of dwc3 can be found in: + Documentation/devicetree/bindings/usb/dwc3.txt + +Example device nodes: + + usb3host: mb86s70_usb3host { + compatible = fujitsu,mb86s70-dwc3; + clocks = clk_alw_1_1; + clock-names = core; + #address-cells = 2; + #size-cells = 1; + ranges; + + dwc3@3220 { + compatible = synopsys,dwc3; + reg = 0 0x3230 0x10; + interrupts = 0 412 0x4, + 0 414 0x4; + }; + }; diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 58b5b2c..3390d42 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -61,6 +61,17 @@ config USB_DWC3_EXYNOS Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside, say 'Y' or 'M' if you have one such device. +config USB_DWC3_MB86S70 + tristate MB86S70 Designware USB3 Platform code + default USB_DWC3 + help + MB86S7X SOC ship with DesignWare Core USB3 IP inside, + this implementation also integrated Fujitsu USB PHY inside + this Core USB3 IP. + + say 'Y' or 'M' if you have one such device. + + config USB_DWC3_PCI tristate PCIe-based Platforms depends on PCI diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index bb34fbc..05d1de2 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -38,3 +38,4 @@ obj-$(CONFIG_USB_DWC3_PCI)+= dwc3-pci.o obj-$(CONFIG_USB_DWC3_KEYSTONE)+= dwc3-keystone.o obj-$(CONFIG_USB_DWC3_QCOM)+= dwc3-qcom.o obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o +obj-$(CONFIG_USB_DWC3_MB86S70) += dwc3-mb86s70.o diff --git a/drivers/usb/dwc3/dwc3-mb86s70.c b/drivers/usb/dwc3/dwc3-mb86s70.c new file mode 100644 index 000..301be76 --- /dev/null +++ b/drivers/usb/dwc3/dwc3-mb86s70.c @@ -0,0 +1,206 @@ +/** + * dwc3-mb86s70.c - Fujitsu mb86s70 DWC3 Specific Glue layer + * + * Copyright (c) 2013 - 2014 FUJITSU SEMICONDUCTOR LIMITED + * http://jp.fujitsu.com/group/fsl + * + * Authors: Alice Chan alice.c...@tw.fujitsu.com + * Sneeker Yeh sneeker@tw.fujitsu.com + * based on dwc3-exynos.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include linux/module.h +#include linux/kernel.h +#include linux/slab.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/interrupt.h +#include linux/of.h +#include linux/of_platform.h +#include linux/pm_runtime.h +#include linux/clk.h + +struct dwc3_mb86s70 { + struct device *dev; + struct clk *clks[5]; + u8 clk_cnt; +}; + +static int dwc3_mb86s70_clk_control(struct device *dev, bool on) +{ + struct dwc3_mb86s70 *priv = dev_get_drvdata(dev); + int ret, i = priv-clk_cnt; + + if (!on) + goto clock_off; + + for (i = 0; i priv-clk_cnt; i++) { + ret = clk_prepare_enable(priv-clks[i]); + if (ret) { + dev_err(dev, failed to enable clock[%d]\n, i); + on = ret; + goto clock_off; + } + } + + return 0; + +clock_off: + for (; i 0;) + clk_disable_unprepare(priv-clks[--i]); + + return on; +} + +static int
[PATCH v3 3/5] usb: dwc3: add revision number DWC3_REVISION_290A and DWC3_REVISION_300A
Add the contstant for v2.90a and v3.00a dwc3 IP detection Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/dwc3/core.h |2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 4bb9aa6..46f9f9a 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -776,6 +776,8 @@ struct dwc3 { #define DWC3_REVISION_260A 0x5533260a #define DWC3_REVISION_270A 0x5533270a #define DWC3_REVISION_280A 0x5533280a +#define DWC3_REVISION_290A 0x5533290a +#define DWC3_REVISION_300A 0x5533300a enum dwc3_ep0_next ep0_next_event; enum dwc3_ep0_state ep0state; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/5] usb: dwc3: Add quirk for Synopsis device disconnection errata
Hi Felipe: Thanks for reviewing these, 2015-01-19 22:50 GMT+08:00 Felipe Balbi ba...@ti.com: Hi, On Mon, Jan 19, 2015 at 03:56:47PM +0800, Sneeker Yeh wrote: Synopsis Designware USB3 IP earlier than v3.00a which is configured in silicon with DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, would need a specific quirk to prevent xhci host controller from dying when device is disconnected. Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP configuration whose state cannot be checked from software in runtime, it has to be enabled via platform data or device tree. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- Documentation/devicetree/bindings/usb/dwc3.txt | 17 + drivers/usb/dwc3/core.c|6 ++ drivers/usb/dwc3/core.h|1 + drivers/usb/dwc3/host.c|4 drivers/usb/dwc3/platform_data.h |1 + 5 files changed, 29 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index cd7f045..1b78b29 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -37,6 +37,23 @@ Optional properties: - 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 + - snps,has_suspend_on_disconnect: true when IP is configured in silicon with + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, it can inject a + specific quirk to prevent xhci host controller from + dying when usb device is disconnected from root hub. + Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP + configuration whose state cannot be checked from + software in runtime, it has to be enabled via platform + data or device tree. + + xhci host dying symptom here is caused by that + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 + configuration makes IP auto-suspended after PORTCSC is + cleared when usb device detached, then an asynchronous + disconnection procedure might fail using endpoint + command that suspened IP won't have any response to. + + this issue is fixed when IP version = 3.00a. This is usually a subnode to DWC3 glue to which it is connected. diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 25ddc39..fbceab1 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -838,6 +838,9 @@ static int dwc3_probe(struct platform_device *pdev) snps,tx_de_emphasis_quirk); of_property_read_u8(node, snps,tx_de_emphasis, tx_de_emphasis); + + dwc-suspend_on_disconnect_quirk = of_property_read_bool(node, + snps,has_suspend_on_disconnect); } else if (pdata) { dwc-maximum_speed = pdata-maximum_speed; dwc-has_lpm_erratum = pdata-has_lpm_erratum; @@ -864,6 +867,9 @@ static int dwc3_probe(struct platform_device *pdev) dwc-tx_de_emphasis_quirk = pdata-tx_de_emphasis_quirk; if (pdata-tx_de_emphasis) tx_de_emphasis = pdata-tx_de_emphasis; + + dwc-suspend_on_disconnect_quirk = + pdata-has_suspend_on_disconnect; } /* default to superspeed if no maximum_speed passed */ diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 8090249..d7458ff 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -832,6 +832,7 @@ struct dwc3 { unsignedtx_de_emphasis_quirk:1; unsignedtx_de_emphasis:2; + unsignedsuspend_on_disconnect_quirk:1; you're missing the comment on the structure and these should be alphabetically sorted. okay, I see, I'll change it like this: --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -692,6 +692,9 @@ struct dwc3_scratchpad_array { * @resize_fifos: tells us it's ok to reconfigure our TxFIFO sizes. * @setup_packet_pending: true when there's a Setup Packet in FIFO. Workaround * @start_config_issued: true when StartConfig command has been issued + * @suspend_on_disconnect_quirk: set if core was configured with + * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. Note that there's + * now way for software to detect this in runtime. * @three_stage_setup: set if we perform a three phase setup * @disable_scramble_quirk: set if we enable the disable scramble quirk * @u2exit_lfps_quirk: set if we enable u2exit lfps quirk @@ -818,6 +821,7 @@ struct dwc3
Re: [PATCH v2 4/5] xhci: Platform: Set Synopsis device disconnection quirk based on platform data
hi, 2015-01-19 22:51 GMT+08:00 Felipe Balbi ba...@ti.com: On Mon, Jan 19, 2015 at 03:56:48PM +0800, Sneeker Yeh wrote: If an xhci platform has Synopsis device disconnection errata then enable XHCI_DISCONNECT_QUIRK quirk flag. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-plat.c |3 +++ include/linux/usb/xhci_pdriver.h |4 2 files changed, 7 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 08d402b..40beb95 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -147,6 +147,9 @@ static int xhci_plat_probe(struct platform_device *pdev) if ((node of_property_read_bool(node, usb3-lpm-capable)) || (pdata pdata-usb3_lpm_capable)) xhci-quirks |= XHCI_LPM_SUPPORT; + + if (pdata pdata-delay_portcsc_clear) + xhci-quirks |= XHCI_DISCONNECT_QUIRK; /* * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset) * is called by usb_add_hcd(). diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h index 376654b..a37a3a5 100644 --- a/include/linux/usb/xhci_pdriver.h +++ b/include/linux/usb/xhci_pdriver.h @@ -18,10 +18,14 @@ * * @usb3_lpm_capable:determines if this xhci platform supports USB3 * LPM capability + * @delay_portcsc_clear: determines if Synopsis USB3 core has errata in + * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 hardware + * configuration. * */ struct usb_xhci_pdata { unsignedusb3_lpm_capable:1; + unsigneddelay_portcsc_clear:1; previous patch won't build before this is applied. That's a problem. Please shuffle things around so that each and every patch builds and works on its own. We cannot break bisectability ;-) Ah...sorry I seem to make a mess here, i'll re-arrange all patches next round. Much appreciate, Sneeker -- balbi -- To unsubscribe from this list: send the line unsubscribe devicetree 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 2/5] usb: dwc3: add revision number DWC3_REVISION_300A
hi, 2015-01-20 4:00 GMT+08:00 Felipe Balbi ba...@ti.com: On Mon, Jan 19, 2015 at 07:45:31PM +, John Youn wrote: -Original Message- From: Felipe Balbi [mailto:ba...@ti.com] Sent: Monday, January 19, 2015 6:47 AM looking at Synopsys Solvnet for this IP, it shows that current version is 2.90a. There's no 3.00a. Paul, John, is there a 3.00a version of the DWC USB3 IP ? Yes there is, but it has not been released yet, thus it's not in Solvnet. alright, in that case, Sneeker, can you update this patch to add 2.90a and 3.00a macros ? Sure, I'll also add 2.90a in next round, Thanks, and much appreciate, Sneeker Thanks -- balbi -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/5] usb: dwc3: add Fujitsu Specific Glue layer
This patch adds support for Synopsis DesignWare USB3 IP Core found on Fujitsu Socs. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- .../devicetree/bindings/usb/fujitsu-dwc3.txt | 33 drivers/usb/dwc3/Kconfig | 11 ++ drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/dwc3-mb86s70.c| 206 4 files changed, 251 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-mb86s70.c diff --git a/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt new file mode 100644 index 000..be091eb --- /dev/null +++ b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt @@ -0,0 +1,33 @@ +FUJITSU GLUE COMPONENTS + +MB86S7x DWC3 GLUE +- compatible: Should be fujitsu,mb86s70-dwc3 +- clocks: from common clock binding, handle to usb clock. +- clock-names: Should contain the following: + core Master/Core clock needs to run at a minimum of 125 MHz to + support a 4 Gbps IN or 4 Gbps OUT + transfer at a given time. + +Sub-nodes: +The dwc3 core should be added as subnode to MB86S7x dwc3 glue. +- dwc3 : + The binding details of dwc3 can be found in: + Documentation/devicetree/bindings/usb/dwc3.txt + +Example device nodes: + + usb3host: mb86s70_usb3host { + compatible = fujitsu,mb86s70-dwc3; + clocks = clk_alw_1_1; + clock-names = core; + #address-cells = 2; + #size-cells = 1; + ranges; + + dwc3@3220 { + compatible = synopsys,dwc3; + reg = 0 0x3230 0x10; + interrupts = 0 412 0x4, + 0 414 0x4; + }; + }; diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 58b5b2c..3390d42 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -61,6 +61,17 @@ config USB_DWC3_EXYNOS Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside, say 'Y' or 'M' if you have one such device. +config USB_DWC3_MB86S70 + tristate MB86S70 Designware USB3 Platform code + default USB_DWC3 + help + MB86S7X SOC ship with DesignWare Core USB3 IP inside, + this implementation also integrated Fujitsu USB PHY inside + this Core USB3 IP. + + say 'Y' or 'M' if you have one such device. + + config USB_DWC3_PCI tristate PCIe-based Platforms depends on PCI diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index bb34fbc..05d1de2 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -38,3 +38,4 @@ obj-$(CONFIG_USB_DWC3_PCI)+= dwc3-pci.o obj-$(CONFIG_USB_DWC3_KEYSTONE)+= dwc3-keystone.o obj-$(CONFIG_USB_DWC3_QCOM)+= dwc3-qcom.o obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o +obj-$(CONFIG_USB_DWC3_MB86S70) += dwc3-mb86s70.o diff --git a/drivers/usb/dwc3/dwc3-mb86s70.c b/drivers/usb/dwc3/dwc3-mb86s70.c new file mode 100644 index 000..301be76 --- /dev/null +++ b/drivers/usb/dwc3/dwc3-mb86s70.c @@ -0,0 +1,206 @@ +/** + * dwc3-mb86s70.c - Fujitsu mb86s70 DWC3 Specific Glue layer + * + * Copyright (c) 2013 - 2014 FUJITSU SEMICONDUCTOR LIMITED + * http://jp.fujitsu.com/group/fsl + * + * Authors: Alice Chan alice.c...@tw.fujitsu.com + * Sneeker Yeh sneeker@tw.fujitsu.com + * based on dwc3-exynos.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include linux/module.h +#include linux/kernel.h +#include linux/slab.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/interrupt.h +#include linux/of.h +#include linux/of_platform.h +#include linux/pm_runtime.h +#include linux/clk.h + +struct dwc3_mb86s70 { + struct device *dev; + struct clk *clks[5]; + u8 clk_cnt; +}; + +static int dwc3_mb86s70_clk_control(struct device *dev, bool on) +{ + struct dwc3_mb86s70 *priv = dev_get_drvdata(dev); + int ret, i = priv-clk_cnt; + + if (!on) + goto clock_off; + + for (i = 0; i priv-clk_cnt; i++) { + ret = clk_prepare_enable(priv-clks[i]); + if (ret) { + dev_err(dev, failed to enable clock[%d]\n, i); + on = ret; + goto clock_off; + } + } + + return 0; + +clock_off: + for (; i 0;) + clk_disable_unprepare(priv-clks[--i]); + + return on; +} + +static int
[PATCH v2 2/5] usb: dwc3: add revision number DWC3_REVISION_300A
Add the contstant for v3.00a dwc3 IP detection Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/dwc3/core.h |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 4bb9aa6..8090249 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -776,6 +776,7 @@ struct dwc3 { #define DWC3_REVISION_260A 0x5533260a #define DWC3_REVISION_270A 0x5533270a #define DWC3_REVISION_280A 0x5533280a +#define DWC3_REVISION_300A 0x5533300a enum dwc3_ep0_next ep0_next_event; enum dwc3_ep0_state ep0state; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree 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] usb: dwc3: Add quirk for Synopsis device disconnection errata
Synopsis Designware USB3 IP earlier than v3.00a which is configured in silicon with DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, would need a specific quirk to prevent xhci host controller from dying when device is disconnected. Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP configuration whose state cannot be checked from software in runtime, it has to be enabled via platform data or device tree. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- Documentation/devicetree/bindings/usb/dwc3.txt | 17 + drivers/usb/dwc3/core.c|6 ++ drivers/usb/dwc3/core.h|1 + drivers/usb/dwc3/host.c|4 drivers/usb/dwc3/platform_data.h |1 + 5 files changed, 29 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc3.txt b/Documentation/devicetree/bindings/usb/dwc3.txt index cd7f045..1b78b29 100644 --- a/Documentation/devicetree/bindings/usb/dwc3.txt +++ b/Documentation/devicetree/bindings/usb/dwc3.txt @@ -37,6 +37,23 @@ Optional properties: - 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 + - snps,has_suspend_on_disconnect: true when IP is configured in silicon with + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, it can inject a + specific quirk to prevent xhci host controller from + dying when usb device is disconnected from root hub. + Since DWC_USB3_SUSPEND_ON_DISCONNECT_EN is an IP + configuration whose state cannot be checked from + software in runtime, it has to be enabled via platform + data or device tree. + + xhci host dying symptom here is caused by that + DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 + configuration makes IP auto-suspended after PORTCSC is + cleared when usb device detached, then an asynchronous + disconnection procedure might fail using endpoint + command that suspened IP won't have any response to. + + this issue is fixed when IP version = 3.00a. This is usually a subnode to DWC3 glue to which it is connected. diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 25ddc39..fbceab1 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -838,6 +838,9 @@ static int dwc3_probe(struct platform_device *pdev) snps,tx_de_emphasis_quirk); of_property_read_u8(node, snps,tx_de_emphasis, tx_de_emphasis); + + dwc-suspend_on_disconnect_quirk = of_property_read_bool(node, + snps,has_suspend_on_disconnect); } else if (pdata) { dwc-maximum_speed = pdata-maximum_speed; dwc-has_lpm_erratum = pdata-has_lpm_erratum; @@ -864,6 +867,9 @@ static int dwc3_probe(struct platform_device *pdev) dwc-tx_de_emphasis_quirk = pdata-tx_de_emphasis_quirk; if (pdata-tx_de_emphasis) tx_de_emphasis = pdata-tx_de_emphasis; + + dwc-suspend_on_disconnect_quirk = + pdata-has_suspend_on_disconnect; } /* default to superspeed if no maximum_speed passed */ diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 8090249..d7458ff 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -832,6 +832,7 @@ struct dwc3 { unsignedtx_de_emphasis_quirk:1; unsignedtx_de_emphasis:2; + unsignedsuspend_on_disconnect_quirk:1; }; /* -- */ diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 12bfd3c..9c42074 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -53,6 +53,10 @@ int dwc3_host_init(struct dwc3 *dwc) pdata.usb3_lpm_capable = 1; #endif + if ((dwc-revision DWC3_REVISION_300A) + dwc-suspend_on_disconnect_quirk) + pdata.delay_portcsc_clear = 1; + ret = platform_device_add_data(xhci, pdata, sizeof(pdata)); if (ret) { dev_err(dwc-dev, couldn't add platform data to xHCI device\n); diff --git a/drivers/usb/dwc3/platform_data.h b/drivers/usb/dwc3/platform_data.h index a3a3b6d..69562f1 100644 --- a/drivers/usb/dwc3/platform_data.h +++ b/drivers/usb/dwc3/platform_data.h @@ -44,4 +44,5 @@ struct dwc3_platform_data { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; + unsigned has_suspend_on_disconnect:1; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe
[PATCH v2 5/5] xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core
This issue is defined by a three-way race at disconnect, between 1) Class driver interrupt endpoint resheduling attempts if the ISR gave an ep error event due to device detach (it would try 3 times) 2) Disconnect interrupt on PORTSC_CSC, which is cleared by hub thread asynchronously 3) The hardware IP was configured in silicon with - DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 - Synopsys IP version is 3.00a The IP will auto-suspend itself on device detach with some phy-specific interval after CSC is cleared by 2) If 2) and 3) complete before 1), the interrupts it expects will not be generated by the autosuspended IP, leading to a deadlock. Even later disconnection procedure would detect that corresponding urb is still in-progress and issue a ep stop command, auto-suspended IP still won't respond to that command. this defect would result in this when device detached: --- [ 99.603544] usb 4-1: USB disconnect, device number 2 [ 104.615254] xhci-hcd xhci-hcd.0.auto: xHCI host not responding to stop endpoint command. [ 104.623362] xhci-hcd xhci-hcd.0.auto: Assuming host is dying, halting host. [ 104.653261] xhci-hcd xhci-hcd.0.auto: Host not halted after 16000 microseconds. [ 104.660584] xhci-hcd xhci-hcd.0.auto: Non-responsive xHCI host is not halting. [ 104.667817] xhci-hcd xhci-hcd.0.auto: Completing active URBs anyway. [ 104.674198] xhci-hcd xhci-hcd.0.auto: HC died; cleaning up -- As a result, when device detached, we desired to postpone PORTCSC clear behind disable slot. it's found that all executed ep command related to disconnetion, are executed before disable slot. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-hub.c |4 drivers/usb/host/xhci.c | 29 + drivers/usb/host/xhci.h | 24 3 files changed, 57 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index a7865c4..3b8f7fc 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -368,6 +368,10 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, port_change_bit = warm(BH) reset; break; case USB_PORT_FEAT_C_CONNECTION: + if ((xhci-quirks XHCI_DISCONNECT_QUIRK) + !(readl(addr) PORT_CONNECT)) + return; + status = PORT_CSC; port_change_bit = connect; break; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index c50d8d2..aa8e02a 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3584,6 +3584,33 @@ command_cleanup: return ret; } +static void xhci_try_to_clear_csc(struct usb_hcd *hcd, int dev_port_num) +{ + int max_ports; + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + __le32 __iomem **port_array; + u32 status; + + /* print debug info */ + if (hcd-speed == HCD_USB3) { + max_ports = xhci-num_usb3_ports; + port_array = xhci-usb3_ports; + } else { + max_ports = xhci-num_usb2_ports; + port_array = xhci-usb2_ports; + } + + if (dev_port_num max_ports) { + xhci_err(xhci, %s() port number invalid, __func__); + return; + } + status = readl(port_array[dev_port_num - 1]); + + /* write 1 to clear */ + if (!(status PORT_CONNECT) (status PORT_CSC)) + writel(status PORT_CSC, port_array[0]); +} + /* * At this point, the struct usb_device is about to go away, the device has * disconnected, and all traffic has been stopped and the endpoints have been @@ -3649,6 +3676,8 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev) xhci_ring_cmd_db(xhci); spin_unlock_irqrestore(xhci-lock, flags); + if (xhci-quirks XHCI_DISCONNECT_QUIRK) + xhci_try_to_clear_csc(hcd, udev-portnum); /* * Event command completion handler will free any data structures * associated with the slot. XXX Can free sleep? diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index cc7c5bb..65a65cc 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1560,6 +1560,30 @@ struct xhci_hcd { #define XHCI_SPURIOUS_WAKEUP (1 18) /* For controllers with a broken beyond repair streams implementation */ #define XHCI_BROKEN_STREAMS(1 19) +/* + * This issue is defined by a three-way race at disconnect in Synopsis USB3 IP, + * between + * 1) Class driver interrupt endpoint resheduling attempts if the ISR gave an ep + *error event due to device detach (it would try 3 times) + * 2) Disconnect interrupt on PORTSC_CSC, which is cleared by hub thread + *asynchronously + * 3) The hardware IP was configured in silicon
[PATCH v2 4/5] xhci: Platform: Set Synopsis device disconnection quirk based on platform data
If an xhci platform has Synopsis device disconnection errata then enable XHCI_DISCONNECT_QUIRK quirk flag. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-plat.c |3 +++ include/linux/usb/xhci_pdriver.h |4 2 files changed, 7 insertions(+) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 08d402b..40beb95 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -147,6 +147,9 @@ static int xhci_plat_probe(struct platform_device *pdev) if ((node of_property_read_bool(node, usb3-lpm-capable)) || (pdata pdata-usb3_lpm_capable)) xhci-quirks |= XHCI_LPM_SUPPORT; + + if (pdata pdata-delay_portcsc_clear) + xhci-quirks |= XHCI_DISCONNECT_QUIRK; /* * Set the xHCI pointer before xhci_plat_setup() (aka hcd_driver.reset) * is called by usb_add_hcd(). diff --git a/include/linux/usb/xhci_pdriver.h b/include/linux/usb/xhci_pdriver.h index 376654b..a37a3a5 100644 --- a/include/linux/usb/xhci_pdriver.h +++ b/include/linux/usb/xhci_pdriver.h @@ -18,10 +18,14 @@ * * @usb3_lpm_capable: determines if this xhci platform supports USB3 * LPM capability + * @delay_portcsc_clear: determines if Synopsis USB3 core has errata in + * DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1 hardware + * configuration. * */ struct usb_xhci_pdata { unsignedusb3_lpm_capable:1; + unsigneddelay_portcsc_clear:1; }; #endif /* __USB_CORE_XHCI_PDRIVER_H */ -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/5] Add support for Fujitsu USB host controller
These patches add support for XHCI compliant Host controller found on Fujitsu Socs, and are based on http://lwn.net/Articles/629162/ The first patch is to add Fujitsu glue layer of Synopsis DesignWare USB3 driver and last four patch is about quirk implementation of errata in Synopsis DesignWare USB3 IP. Patch 1 introduces Fujitsu Specific Glue layer in Synopsis DesignWare USB3 IP driver. Patch 2 is to add a revison number 3.00a of Synopsis DesignWare USB3 IP core driver. Patch 3 introduces using a quirk based on a errata of Synopsis DesignWare USB3 IP which is versions 3.00a and has hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1, which cannot be read from software. As a result this quirk has to be enabled via platform data or device tree. Patch 4 is to set Synopsis quirk in xhci platform driver based on xhci platform data. Patch 5 introduces a quirk with device disconnection management necessary Synopsys Designware USB3 IP with versions 3.00a and hardware configuration DWC_USB3_SUSPEND_ON_DISCONNECT_EN=1. It solves a problem where without the quirk, that host controller will die after a usb device is disconnected from port of root hub. Successfully tested on Fujitsu mb86s7x board. Changes since v1 (RFC): [https://lkml.org/lkml/2014/12/15/929] - based on Arnd's comment, remove entire unnecessary Fujitsu EHCI/OHCI glue, - based on Felipe's comment, fix mis-using of runtime-pm API and setting dma mask, remove unnecessary comment, and refactor suspend/resume handler in Fujitsu Specific Glue layer in dwc3, - based on Felipe's comment, add more commit log and comments in Synopsis quirk implementation, and separate it into four patches. Sneeker Yeh (5): usb: dwc3: add Fujitsu Specific Glue layer usb: dwc3: add revision number DWC3_REVISION_300A usb: dwc3: Add quirk for Synopsis device disconnection errata xhci: Platform: Set Synopsis device disconnection quirk based on platform data xhci: add a quirk for device disconnection errata for Synopsis Designware USB3 core Documentation/devicetree/bindings/usb/dwc3.txt | 17 ++ .../devicetree/bindings/usb/fujitsu-dwc3.txt | 33 drivers/usb/dwc3/Kconfig | 11 ++ drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/core.c|6 + drivers/usb/dwc3/core.h|2 + drivers/usb/dwc3/dwc3-mb86s70.c| 206 drivers/usb/dwc3/host.c|4 + drivers/usb/dwc3/platform_data.h |1 + drivers/usb/host/xhci-hub.c|4 + drivers/usb/host/xhci-plat.c |3 + drivers/usb/host/xhci.c| 29 +++ drivers/usb/host/xhci.h| 24 +++ include/linux/usb/xhci_pdriver.h |4 + 14 files changed, 345 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-mb86s70.c -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/3] Add support for Fujitsu USB host controller
These patches add support for EHCI and XHCI compliant Host controller found on Fujitsu Socs, and are based on http://www.spinics.net/lists/arm-kernel/msg385573.html First patch is EHCI platform glue driver. Patch 2 introduces Fujitsu Specific Glue layer in Synopsis DesignWare USB3 IP driver. Patch 3 introduces a quirk with device disconnection management necessary for IPs using the Synopsys Designware dwc3 core. It solves a problem where without the quirk, that host controller will die after a usb device is disconnected from port of root hub, which happened in Synopsis core with Fujitsu config-free usb phy integrated. Successfully tested on Fujitsu mb86s7x board. Sneeker Yeh (3): usb: host: f_usb20ho: add support for Fujitsu ehci/ohci USB 2.0 host controller usb: dwc3: add Fujitsu Specific Glue layer usb: dwc3: add a quirk for device disconnection issue in Synopsis dwc3 core .../devicetree/bindings/usb/fujitsu-dwc3.txt | 25 ++ .../devicetree/bindings/usb/fujitsu-ehci.txt | 22 ++ drivers/usb/dwc3/Kconfig | 11 + drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/dwc3-mb86s70.c| 194 + drivers/usb/host/Kconfig | 11 + drivers/usb/host/Makefile |1 + drivers/usb/host/f_usb20ho_hcd.c | 306 drivers/usb/host/f_usb20ho_hcd.h | 35 +++ drivers/usb/host/xhci-hub.c|4 + drivers/usb/host/xhci-plat.c |5 + drivers/usb/host/xhci.c| 29 ++ drivers/usb/host/xhci.h|7 + 13 files changed, 651 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-ehci.txt create mode 100644 drivers/usb/dwc3/dwc3-mb86s70.c create mode 100644 drivers/usb/host/f_usb20ho_hcd.c create mode 100644 drivers/usb/host/f_usb20ho_hcd.h -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree 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: dwc3: add a quirk for device disconnection issue in Synopsis dwc3 core
Synopsis DesignWare USB3 IP Core integrated with a config-free phy needs special handling during device disconnection to avoid the host controller dying. This quirk makes sure PORT_CSC is cleared after the disable slot command when usb device is disconnected from internal root hub, otherwise, Synopsis core would fall into a state that cannot use any endpoint command. Consequently, device disconnection procedure might not be finished because sometimes endpoint need to be stop by endpoint stop command issuing. Symptom usually happens when disconnected device is keyboard, mouse, and hub. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- drivers/usb/host/xhci-hub.c |4 drivers/usb/host/xhci-plat.c |5 + drivers/usb/host/xhci.c | 29 + drivers/usb/host/xhci.h |7 +++ 4 files changed, 45 insertions(+) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index a7865c4..3b8f7fc 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -368,6 +368,10 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue, port_change_bit = warm(BH) reset; break; case USB_PORT_FEAT_C_CONNECTION: + if ((xhci-quirks XHCI_DISCONNECT_QUIRK) + !(readl(addr) PORT_CONNECT)) + return; + status = PORT_CSC; port_change_bit = connect; break; diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 08d402b..3ede6b4 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -33,6 +33,11 @@ static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci) * dev struct in order to setup MSI */ xhci-quirks |= XHCI_PLAT; + + if (dev-parent dev-parent-parent + of_device_is_compatible(dev-parent-parent-of_node, + fujitsu,mb86s70-dwc3)) + xhci-quirks |= XHCI_DISCONNECT_QUIRK; } /* called during probe() after chip reset completes */ diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 01fcbb5..50d757b 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -3584,6 +3584,33 @@ command_cleanup: return ret; } +static void xhci_try_to_clear_csc(struct usb_hcd *hcd, int dev_port_num) +{ + int max_ports; + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + __le32 __iomem **port_array; + u32 status; + + /* print debug info */ + if (hcd-speed == HCD_USB3) { + max_ports = xhci-num_usb3_ports; + port_array = xhci-usb3_ports; + } else { + max_ports = xhci-num_usb2_ports; + port_array = xhci-usb2_ports; + } + + if (dev_port_num max_ports) { + xhci_err(xhci, %s() port number invalid, __func__); + return; + } + status = readl(port_array[dev_port_num - 1]); + + /* write 1 to clear */ + if (!(status PORT_CONNECT) (status PORT_CSC)) + writel(status PORT_CSC, port_array[0]); +} + /* * At this point, the struct usb_device is about to go away, the device has * disconnected, and all traffic has been stopped and the endpoints have been @@ -3649,6 +3676,8 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev) xhci_ring_cmd_db(xhci); spin_unlock_irqrestore(xhci-lock, flags); + if (xhci-quirks XHCI_DISCONNECT_QUIRK) + xhci_try_to_clear_csc(hcd, udev-portnum); /* * Event command completion handler will free any data structures * associated with the slot. XXX Can free sleep? diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index cc7c5bb..e6c820c 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1560,6 +1560,13 @@ struct xhci_hcd { #define XHCI_SPURIOUS_WAKEUP (1 18) /* For controllers with a broken beyond repair streams implementation */ #define XHCI_BROKEN_STREAMS(1 19) +/* + * Synopsis dwc3 core integrated with a config-free phy needs special + * handling during device disconnection to avoid the host controller + * dying. This quirk makes sure PORT_CSC is cleared after the disable + * slot command. + */ +#define XHCI_DISCONNECT_QUIRK (1 20) unsigned intnum_active_eps; unsigned intlimit_active_eps; /* There are two roothubs to keep track of bus suspend info for */ -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe devicetree 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: host: f_usb20ho: add support for Fujitsu ehci/ohci USB 2.0 host controller
This patch adds support for EHCI compliant Host controller found on Fujitsu Socs. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- .../devicetree/bindings/usb/fujitsu-ehci.txt | 22 ++ drivers/usb/host/Kconfig | 11 + drivers/usb/host/Makefile |1 + drivers/usb/host/f_usb20ho_hcd.c | 306 drivers/usb/host/f_usb20ho_hcd.h | 35 +++ 5 files changed, 375 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-ehci.txt create mode 100644 drivers/usb/host/f_usb20ho_hcd.c create mode 100644 drivers/usb/host/f_usb20ho_hcd.h diff --git a/Documentation/devicetree/bindings/usb/fujitsu-ehci.txt b/Documentation/devicetree/bindings/usb/fujitsu-ehci.txt new file mode 100644 index 000..e180860 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/fujitsu-ehci.txt @@ -0,0 +1,22 @@ +FUJITSU GLUE COMPONENTS + +MB86S7x EHCI GLUE + - compatible : Should be fujitsu,f_usb20ho_hcd + - reg : Address and length of the register set for the device. + - interrupts : The irq number of this device that is used to interrupt the + CPU + - clocks: from common clock binding, handle to usb clock. + - clock-names: from common clock binding. + - #stream-id-cells : handle to use arm,mmu-400 ARM IOMMU driver + - fujitsu,power-domain : pd_usb2h node has to be builded, details can be + found in: + Documentation/devicetree/bindings/ + +hcd21: f_usb20ho_hcd { + compatible = fujitsu,f_usb20ho_hcd; + reg = 0 0x3420 0x8; + interrupts = 0 419 0x4; + clocks = clk_main_2_4, clk_main_4_5, clk_usb_0_0; + clock-names = h_clk, p_clk, p_cryclk; + #stream-id-cells = 0; +}; diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index fafc628..9482140 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig @@ -786,6 +786,17 @@ config USB_HCD_SSB If unsure, say N. +config USB_F_USB20HO_HCD + tristate F_USB20HO USB Host Controller + depends on USB ARCH_MB86S7X + default y + help + This driver enables support for USB20HO USB Host Controller, + the driver supports High, Full and Low Speed USB. + + To compile this driver a module, choose M here: the module + will be called f_usb20ho-hcd. + config USB_HCD_TEST_MODE bool HCD test mode support ---help--- diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile index d6216a4..b89e536 100644 --- a/drivers/usb/host/Makefile +++ b/drivers/usb/host/Makefile @@ -78,3 +78,4 @@ obj-$(CONFIG_USB_HCD_SSB) += ssb-hcd.o obj-$(CONFIG_USB_FUSBH200_HCD) += fusbh200-hcd.o obj-$(CONFIG_USB_FOTG210_HCD) += fotg210-hcd.o obj-$(CONFIG_USB_MAX3421_HCD) += max3421-hcd.o +obj-$(CONFIG_USB_F_USB20HO_HCD)+= f_usb20ho_hcd.o diff --git a/drivers/usb/host/f_usb20ho_hcd.c b/drivers/usb/host/f_usb20ho_hcd.c new file mode 100644 index 000..d665487 --- /dev/null +++ b/drivers/usb/host/f_usb20ho_hcd.c @@ -0,0 +1,306 @@ +/** + * f_usb20ho_hcd.c - Fujitsu EHCI platform driver + * + * Copyright (c) 2013 - 2014 FUJITSU SEMICONDUCTOR LIMITED + * http://jp.fujitsu.com/group/fsl + * + * based on bcma-hcd.c + * + * Author: Sneeker Yeh sneeker@tw.fujitsu.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include linux/clk.h +#include linux/delay.h +#include linux/device.h +#include linux/platform_device.h +#include linux/module.h +#include linux/errno.h +#include linux/slab.h +#include linux/kernel.h +#include linux/usb/ehci_pdriver.h +#include linux/usb/ohci_pdriver.h +#include linux/dma-mapping.h +#include linux/of.h +#include linux/pm_runtime.h +#include linux/usb.h +#include linux/usb/hcd.h + +#include f_usb20ho_hcd.h + +static int f_usb20ho_clk_control(struct device *dev, bool on) +{ + int ret, i; + struct clk *clk; + + if (!on) + goto clock_off; + + for (i = 0;; i++) { + clk = of_clk_get(dev-of_node, i); + if (IS_ERR(clk)) + break; + + ret = clk_prepare_enable(clk); + if (ret) { + dev_err(dev, failed to enable clock[%d]\n, i); + goto clock_off; + } + } + + return 0; + +clock_off: + for (i = 0;; i++) { + clk = of_clk_get(dev-of_node, i); + if (IS_ERR(clk)) + break; + + clk_disable_unprepare(clk); + } + + return on; +} + +static struct platform_device *f_usb20ho_hcd_create_pdev( + struct platform_device *pdev, bool ohci) +{ + struct resource *resource; + struct platform_device *hci_dev
[PATCH 2/3] usb: dwc3: add Fujitsu Specific Glue layer
This patch adds support for Synopsis DesignWare USB3 IP Core found on Fujitsu Socs. Signed-off-by: Sneeker Yeh sneeker@tw.fujitsu.com --- .../devicetree/bindings/usb/fujitsu-dwc3.txt | 25 +++ drivers/usb/dwc3/Kconfig | 11 ++ drivers/usb/dwc3/Makefile |1 + drivers/usb/dwc3/dwc3-mb86s70.c| 194 4 files changed, 231 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt create mode 100644 drivers/usb/dwc3/dwc3-mb86s70.c diff --git a/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt new file mode 100644 index 000..df77f91 --- /dev/null +++ b/Documentation/devicetree/bindings/usb/fujitsu-dwc3.txt @@ -0,0 +1,25 @@ +FUJITSU GLUE COMPONENTS + +MB86S7x DWC3 GLUE + - compatible : Should be fujitsu,mb86s70-dwc3 + - clocks: from common clock binding, handle to usb clock. + - clock-names: from common clock binding. + - #address-cells, #size-cells : Must be present if the device has sub-nodes + - ranges: the child address space are mapped 1:1 onto the parent address space + - #stream-id-cells : handle to use arm,mmu-400 ARM IOMMU driver + +Sub-nodes: +The dwc3 core should be added as subnode to MB86S7x dwc3 glue. +- dwc3 : + The binding details of dwc3 can be found in: + Documentation/devicetree/bindings/usb/dwc3.txt + +usb3host: mb86s70_usb3host { + compatible = fujitsu,mb86s70-dwc3; + clocks = clk_alw_1_1; + clock-names = bus_clk; + #address-cells = 2; + #size-cells = 1; + ranges; + #stream-id-cells = 0; +}; diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig index 58b5b2c..3390d42 100644 --- a/drivers/usb/dwc3/Kconfig +++ b/drivers/usb/dwc3/Kconfig @@ -61,6 +61,17 @@ config USB_DWC3_EXYNOS Recent Exynos5 SoCs ship with one DesignWare Core USB3 IP inside, say 'Y' or 'M' if you have one such device. +config USB_DWC3_MB86S70 + tristate MB86S70 Designware USB3 Platform code + default USB_DWC3 + help + MB86S7X SOC ship with DesignWare Core USB3 IP inside, + this implementation also integrated Fujitsu USB PHY inside + this Core USB3 IP. + + say 'Y' or 'M' if you have one such device. + + config USB_DWC3_PCI tristate PCIe-based Platforms depends on PCI diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile index bb34fbc..05d1de2 100644 --- a/drivers/usb/dwc3/Makefile +++ b/drivers/usb/dwc3/Makefile @@ -38,3 +38,4 @@ obj-$(CONFIG_USB_DWC3_PCI)+= dwc3-pci.o obj-$(CONFIG_USB_DWC3_KEYSTONE)+= dwc3-keystone.o obj-$(CONFIG_USB_DWC3_QCOM)+= dwc3-qcom.o obj-$(CONFIG_USB_DWC3_ST) += dwc3-st.o +obj-$(CONFIG_USB_DWC3_MB86S70) += dwc3-mb86s70.o diff --git a/drivers/usb/dwc3/dwc3-mb86s70.c b/drivers/usb/dwc3/dwc3-mb86s70.c new file mode 100644 index 000..241c5bd --- /dev/null +++ b/drivers/usb/dwc3/dwc3-mb86s70.c @@ -0,0 +1,194 @@ +/** + * dwc3-mb86s70.c - Fujitsu mb86s70 DWC3 Specific Glue layer + * + * Copyright (c) 2013 - 2014 FUJITSU SEMICONDUCTOR LIMITED + * http://jp.fujitsu.com/group/fsl + * + * Author: Alice Chan alice.c...@tw.fujitsu.com + * based on dwc3-exynos.c + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include linux/module.h +#include linux/kernel.h +#include linux/slab.h +#include linux/platform_device.h +#include linux/dma-mapping.h +#include linux/interrupt.h +#include linux/of.h +#include linux/of_platform.h +#include linux/pm_runtime.h +#include linux/clk.h + +struct dwc3_mb86s70 { + struct device *dev; + struct clk **clk_table; +}; + +/* return 0 means successful */ +static int dwc3_mb86s70_clk_control(struct device *dev, bool on) +{ + int ret, i; + struct clk *clk; + + if (!on) + goto clock_off; + + for (i = 0;; i++) { + clk = of_clk_get(dev-of_node, i); + if (IS_ERR(clk)) + break; + + ret = clk_prepare_enable(clk); + if (ret) { + dev_err(dev, failed to enable clock[%d]\n, i); + goto clock_off; + } + } + + return 0; + +clock_off: + for (i = 0;; i++) { + clk = of_clk_get(dev-of_node, i); + if (IS_ERR(clk)) + break; + + clk_disable_unprepare(clk); + } + + return on; +} + +static int dwc3_mb86s70_remove_child(struct device *dev, void *unused) +{ + struct platform_device *pdev = to_platform_device(dev); + + of_device_unregister(pdev