Re: [PATCH v6 23/25] usb: chipidea: Pullup D+ in device mode via phy APIs
On Tue, Jan 17, 2017 at 09:58:33AM -0800, Stephen Boyd wrote: > Quoting Peter Chen (2017-01-15 19:45:51) > > > > So, you need to call phy_set_mode when switching between host and device. > > Besides, you also need to toggle VBUSVLDEXT when the external vbus > > is on or off at device mode (doesn't need for host mode), is it correct? > > Correct. > > > > > At include/linux/usb/phy.h, we have .set_vbus interface, maybe you need > > to port it to generic phy framework. > > > > Ok. I'll look into that. Can the other patches in this series be picked > up? Otherwise I can resend them all again once I fix the phy_set_mode() > call location and introduce a new phy op. I can pick up chipidea patches after you test the patch I supplied at: [PATCH v6 11/25] usb: chipidea: vbus event may exist before starting gadget You may ping other maintainers to pick up other patches. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 25/28] usb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220
On 1/17/2017 10:58 PM, Stefan Wahren wrote: > Hi John, > > is there a public git repo where this series is already applied? > > Stefan > Hi Stefan, Yes, here: https://github.com/synopsys-usb/linux.git I know you're still waiting for the FIFO stuff. We'll send out a first version of that tomorrow. Thanks, John -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 25/28] usb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220
Hi John, is there a public git repo where this series is already applied? Stefan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] usb: core: update comments for send message functions
Keep sending several times same patch file is totally my fault. I am really sorry about that. (today I said lots of 'sorry'..) My default gmail's view options is conversation view. And this conversation view option makes me misunderstand my resend path is reply the previous mail with subject [PATCH]. Disable conversation view option, I found send email with right subject. This is last mail about this patch until someone give me a feedback. Sorry again making noisy mail. jaejoong 2017-01-18 15:19 GMT+09:00 Jaejoong Kim : > The commonly use of bottom halves are tasklet and workqueue. The big > difference between tasklet and workqueue is that the tasklet runs in > an interrupt context and the workqueue runs in a process context, > which means it can sleep if need be. > > The comment for usb_control/interrupt/bulk_msg() functions note that do > not use this function within an interrupt context, like a 'bottom half' > handler. With this comment, it makes confuse about usage of these > functions. > > To more clarify, remove 'bottom half' comment. > > Signed-off-by: Jaejoong Kim > --- > Changes in v2: > - reformat comments within 80 column > - fix checkpatch warning about 75 column in commit message > --- > drivers/usb/core/message.c | 33 +++-- > 1 file changed, 15 insertions(+), 18 deletions(-) > > diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c > index dea5591..2184ef4 100644 > --- a/drivers/usb/core/message.c > +++ b/drivers/usb/core/message.c > @@ -122,12 +122,11 @@ static int usb_internal_control_msg(struct usb_device > *usb_dev, > * This function sends a simple control message to a specified endpoint and > * waits for the message to complete, or timeout. > * > - * Don't use this function from within an interrupt context, like a bottom > half > - * handler. If you need an asynchronous message, or need to send a message > - * from within interrupt context, use usb_submit_urb(). > - * If a thread in your driver uses this call, make sure your disconnect() > - * method can wait for it to complete. Since you don't have a handle on the > - * URB used, you can't cancel the request. > + * Don't use this function from within an interrupt context. If you need > + * an asynchronous message, or need to send a message from within interrupt > + * context, use usb_submit_urb(). If a thread in your driver uses this call, > + * make sure your disconnect() method can wait for it to complete. Since you > + * don't have a handle on the URB used, you can't cancel the request. > * > * Return: If successful, the number of bytes transferred. Otherwise, a > negative > * error number. > @@ -173,12 +172,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg); > * This function sends a simple interrupt message to a specified endpoint and > * waits for the message to complete, or timeout. > * > - * Don't use this function from within an interrupt context, like a bottom > half > - * handler. If you need an asynchronous message, or need to send a message > - * from within interrupt context, use usb_submit_urb() If a thread in your > - * driver uses this call, make sure your disconnect() method can wait for it > to > - * complete. Since you don't have a handle on the URB used, you can't cancel > - * the request. > + * Don't use this function from within an interrupt context. If you need > + * an asynchronous message, or need to send a message from within interrupt > + * context, use usb_submit_urb() If a thread in your driver uses this call, > + * make sure your disconnect() method can wait for it to complete. Since you > + * don't have a handle on the URB used, you can't cancel the request. > * > * Return: > * If successful, 0. Otherwise a negative error number. The number of actual > @@ -207,12 +205,11 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg); > * This function sends a simple bulk message to a specified endpoint > * and waits for the message to complete, or timeout. > * > - * Don't use this function from within an interrupt context, like a bottom > half > - * handler. If you need an asynchronous message, or need to send a message > - * from within interrupt context, use usb_submit_urb() If a thread in your > - * driver uses this call, make sure your disconnect() method can wait for it > to > - * complete. Since you don't have a handle on the URB used, you can't cancel > - * the request. > + * Don't use this function from within an interrupt context. If you need > + * an asynchronous message, or need to send a message from within interrupt > + * context, use usb_submit_urb() If a thread in your driver uses this call, > + * make sure your disconnect() method can wait for it to complete. Since you > + * don't have a handle on the URB used, you can't cancel the request. > * > * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, > * users are forced to abuse this routine by using it to submit URBs for > -- > 2.7.4 > -- To unsubscr
Re: [PATCH v5 0/4] usb: early: add support for early printk through USB3 debug port
Hi Greg, This patch series has been there for 2 months without further comments. Will you consider it for usb-next? Best regards, Lu Baolu On 11/15/2016 02:02 PM, Lu Baolu wrote: > xHCI debug capability (DbC) is an optional but standalone > functionality provided by an xHCI host controller. With DbC > hardware initialized, the system will present a debug device > through the USB3 debug port (normally the first USB3 port). > The debug device is fully compliant with the USB framework > and provides the equivalent of a very high performance (USB3) > full-duplex serial link between the debug host and target. > The DbC functionality is independent of xHCI host. There > isn't any precondition from xHCI host side for DbC to work. > > This patch set adds support for early printk functionality > through a USB3 debug port by 1) initializing and enabling > the DbC hardware during early boot; 2) registering a boot > console to the system so that early printk messages can go > through the USB3 debug port. It also includes some lines > of changes in usb_debug driver so that it can be bound when > a USB3 debug device is enumerated. > > This code is designed to be used only for kernel debugging > when machine crashes very early before the console code is > initialized. It makes the life of kernel debugging easier > when people work with a modern machine without any legacy > serial ports. > > --- > Change log: > v4->v5: > - add raw_spin_lock to make xdbc_bulk_write() reentrant. > > v3->v4: > - Rename the document with .dst suffix. > - Add the list of hardware that has been succesfuly > tested on in the document. > > v2->v3: > - Removed spinlock usage. > - Removed work queue usage. > - Refined the user guide document. > > v1->v2: > - Refactor the duplicate code in xdbc_early_start() and > xdbc_handle_external_reset(). > - Free resources when hardware not used any more. > - Refine the user guide document. > > Lu Baolu (4): > usb: dbc: early driver for xhci debug capability > x86: add support for earlyprintk via USB3 debug port > usb: serial: usb_debug: add support for dbc debug device > usb: doc: add document for USB3 debug port usage > > Documentation/kernel-parameters.txt |1 + > Documentation/usb/usb3-debug-port.rst | 95 +++ > arch/x86/Kconfig.debug| 14 + > arch/x86/kernel/early_printk.c|5 + > arch/x86/kernel/setup.c |7 + > drivers/usb/Kconfig |3 + > drivers/usb/Makefile |2 +- > drivers/usb/early/Makefile|1 + > drivers/usb/early/xhci-dbc.c | 1068 > + > drivers/usb/early/xhci-dbc.h | 205 +++ > drivers/usb/serial/usb_debug.c| 28 +- > include/linux/usb/xhci-dbgp.h | 22 + > 12 files changed, 1447 insertions(+), 4 deletions(-) > create mode 100644 Documentation/usb/usb3-debug-port.rst > create mode 100644 drivers/usb/early/xhci-dbc.c > create mode 100644 drivers/usb/early/xhci-dbc.h > create mode 100644 include/linux/usb/xhci-dbgp.h > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: core: update comments for send message functions
The commonly use of bottom halves are tasklet and workqueue. The big difference between tasklet and workqueue is that the tasklet runs in an interrupt context and the workqueue runs in a process context, which means it can sleep if need be. The comment for usb_control/interrupt/bulk_msg() functions note that do not use this function within an interrupt context, like a 'bottom half' handler. With this comment, it makes confuse about usage of these functions. To more clarify, remove 'bottom half' comment. Signed-off-by: Jaejoong Kim --- Changes in v2: - reformat comments within 80 column - fix checkpatch warning about 75 column in commit message --- drivers/usb/core/message.c | 33 +++-- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index dea5591..2184ef4 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -122,12 +122,11 @@ static int usb_internal_control_msg(struct usb_device *usb_dev, * This function sends a simple control message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb(). - * If a thread in your driver uses this call, make sure your disconnect() - * method can wait for it to complete. Since you don't have a handle on the - * URB used, you can't cancel the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: If successful, the number of bytes transferred. Otherwise, a negative * error number. @@ -173,12 +172,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg); * This function sends a simple interrupt message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: * If successful, 0. Otherwise a negative error number. The number of actual @@ -207,12 +205,11 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg); * This function sends a simple bulk message to a specified endpoint * and waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, * users are forced to abuse this routine by using it to submit URBs for -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/6] usb: mtu3: get resources that cause deferred probe earlier
Some resources such as regulator, clock usually cause deferred probe, get them earlier to avoid more ineffective processing. Signed-off-by: Chunfeng Yun --- drivers/usb/mtu3/mtu3_plat.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c index 7833678..6344859 100644 --- a/drivers/usb/mtu3/mtu3_plat.c +++ b/drivers/usb/mtu3/mtu3_plat.c @@ -204,6 +204,18 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) int i; int ret; + ssusb->vusb33 = devm_regulator_get(&pdev->dev, "vusb33"); + if (IS_ERR(ssusb->vusb33)) { + dev_err(dev, "failed to get vusb33\n"); + return PTR_ERR(ssusb->vusb33); + } + + ssusb->sys_clk = devm_clk_get(dev, "sys_ck"); + if (IS_ERR(ssusb->sys_clk)) { + dev_err(dev, "failed to get sys clock\n"); + return PTR_ERR(ssusb->sys_clk); + } + ssusb->num_phys = of_count_phandle_with_args(node, "phys", "#phy-cells"); if (ssusb->num_phys > 0) { @@ -230,18 +242,6 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) return PTR_ERR(ssusb->ippc_base); } - ssusb->vusb33 = devm_regulator_get(&pdev->dev, "vusb33"); - if (IS_ERR(ssusb->vusb33)) { - dev_err(dev, "failed to get vusb33\n"); - return PTR_ERR(ssusb->vusb33); - } - - ssusb->sys_clk = devm_clk_get(dev, "sys_ck"); - if (IS_ERR(ssusb->sys_clk)) { - dev_err(dev, "failed to get sys clock\n"); - return PTR_ERR(ssusb->sys_clk); - } - ssusb->dr_mode = usb_get_dr_mode(dev); if (ssusb->dr_mode == USB_DR_MODE_UNKNOWN) { dev_err(dev, "dr_mode is error\n"); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/6] usb: mtu3: add reference clock
usually, the reference clock comes from 26M oscillator directly, but some SoCs are not, add it for compatibility. Signed-off-by: Chunfeng Yun --- drivers/usb/mtu3/mtu3.h |1 + drivers/usb/mtu3/mtu3_plat.c | 21 +++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h index ba9df71..aa6fd6a 100644 --- a/drivers/usb/mtu3/mtu3.h +++ b/drivers/usb/mtu3/mtu3.h @@ -225,6 +225,7 @@ struct ssusb_mtk { /* common power & clock */ struct regulator *vusb33; struct clk *sys_clk; + struct clk *ref_clk; /* otg */ struct otg_switch_mtk otg_switch; enum usb_dr_mode dr_mode; diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c index 6344859..19a345d 100644 --- a/drivers/usb/mtu3/mtu3_plat.c +++ b/drivers/usb/mtu3/mtu3_plat.c @@ -123,7 +123,13 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) ret = clk_prepare_enable(ssusb->sys_clk); if (ret) { dev_err(ssusb->dev, "failed to enable sys_clk\n"); - goto clk_err; + goto sys_clk_err; + } + + ret = clk_prepare_enable(ssusb->ref_clk); + if (ret) { + dev_err(ssusb->dev, "failed to enable ref_clk\n"); + goto ref_clk_err; } ret = ssusb_phy_init(ssusb); @@ -143,8 +149,10 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) phy_err: ssusb_phy_exit(ssusb); phy_init_err: + clk_disable_unprepare(ssusb->ref_clk); +ref_clk_err: clk_disable_unprepare(ssusb->sys_clk); -clk_err: +sys_clk_err: regulator_disable(ssusb->vusb33); vusb33_err: @@ -154,6 +162,7 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb) static void ssusb_rscs_exit(struct ssusb_mtk *ssusb) { clk_disable_unprepare(ssusb->sys_clk); + clk_disable_unprepare(ssusb->ref_clk); regulator_disable(ssusb->vusb33); ssusb_phy_power_off(ssusb); ssusb_phy_exit(ssusb); @@ -216,6 +225,12 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) return PTR_ERR(ssusb->sys_clk); } + ssusb->ref_clk = devm_clk_get(dev, "ref_ck"); + if (IS_ERR(ssusb->ref_clk)) { + dev_err(dev, "failed to get ref clock\n"); + return PTR_ERR(ssusb->ref_clk); + } + ssusb->num_phys = of_count_phandle_with_args(node, "phys", "#phy-cells"); if (ssusb->num_phys > 0) { @@ -428,6 +443,7 @@ static int __maybe_unused mtu3_suspend(struct device *dev) ssusb_host_disable(ssusb, true); ssusb_phy_power_off(ssusb); clk_disable_unprepare(ssusb->sys_clk); + clk_disable_unprepare(ssusb->ref_clk); ssusb_wakeup_enable(ssusb); return 0; @@ -445,6 +461,7 @@ static int __maybe_unused mtu3_resume(struct device *dev) ssusb_wakeup_disable(ssusb); clk_prepare_enable(ssusb->sys_clk); + clk_prepare_enable(ssusb->ref_clk); ssusb_phy_power_on(ssusb); ssusb_host_enable(ssusb); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/6] usb: xhci-mtk: add reference clock
usually, the reference clock comes from 26M oscillator directly, but some SoCs are not, add it for compatibility. Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-mtk.c | 15 +++ drivers/usb/host/xhci-mtk.h |1 + 2 files changed, 16 insertions(+) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 1094ebd..4d75ac5 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -212,6 +212,12 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) { int ret; + ret = clk_prepare_enable(mtk->ref_clk); + if (ret) { + dev_err(mtk->dev, "failed to enable ref_clk\n"); + goto ref_clk_err; + } + ret = clk_prepare_enable(mtk->sys_clk); if (ret) { dev_err(mtk->dev, "failed to enable sys_clk\n"); @@ -238,6 +244,8 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) usb_p0_err: clk_disable_unprepare(mtk->sys_clk); sys_clk_err: + clk_disable_unprepare(mtk->ref_clk); +ref_clk_err: return -EINVAL; } @@ -248,6 +256,7 @@ static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk) clk_disable_unprepare(mtk->wk_deb_p0); } clk_disable_unprepare(mtk->sys_clk); + clk_disable_unprepare(mtk->ref_clk); } /* only clocks can be turn off for ip-sleep wakeup mode */ @@ -550,6 +559,12 @@ static int xhci_mtk_probe(struct platform_device *pdev) return PTR_ERR(mtk->sys_clk); } + mtk->ref_clk = devm_clk_get(dev, "ref_ck"); + if (IS_ERR(mtk->ref_clk)) { + dev_err(dev, "fail to get ref_ck\n"); + return PTR_ERR(mtk->ref_clk); + } + mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); ret = usb_wakeup_of_property_parse(mtk, node); diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h index 2845c49..3aa5e1d 100644 --- a/drivers/usb/host/xhci-mtk.h +++ b/drivers/usb/host/xhci-mtk.h @@ -124,6 +124,7 @@ struct xhci_hcd_mtk { struct regulator *vusb33; struct regulator *vbus; struct clk *sys_clk;/* sys and mac clock */ + struct clk *ref_clk; struct clk *wk_deb_p0; /* port0's wakeup debounce clock */ struct clk *wk_deb_p1; struct regmap *pericfg; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/6] dt-bindings: mt8173-xhci: add reference clock
add a reference clock for compatibility Signed-off-by: Chunfeng Yun --- .../devicetree/bindings/usb/mt8173-xhci.txt| 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt index 2a930bd..ab8bb27 100644 --- a/Documentation/devicetree/bindings/usb/mt8173-xhci.txt +++ b/Documentation/devicetree/bindings/usb/mt8173-xhci.txt @@ -23,6 +23,7 @@ Required properties: entry in clock-names - clock-names : must contain "sys_ck": for clock of xHCI MAC + "ref_ck": for reference clock of xHCI MAC "wakeup_deb_p0": for USB wakeup debounce clock of port0 "wakeup_deb_p1": for USB wakeup debounce clock of port1 @@ -47,10 +48,10 @@ usb30: usb@1127 { reg-names = "mac", "ippc"; interrupts = ; power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; - clocks = <&topckgen CLK_TOP_USB30_SEL>, + clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>, <&pericfg CLK_PERI_USB0>, <&pericfg CLK_PERI_USB1>; - clock-names = "sys_ck", + clock-names = "sys_ck", "ref_ck", "wakeup_deb_p0", "wakeup_deb_p1"; phys = <&phy_port0 PHY_TYPE_USB3>, @@ -82,6 +83,7 @@ Required properties: entry in clock-names - clock-names : must be "sys_ck": for clock of xHCI MAC + "ref_ck": for reference clock of xHCI MAC Optional properties: - vbus-supply : reference to the VBUS regulator; @@ -94,8 +96,8 @@ usb30: usb@1127 { reg-names = "mac"; interrupts = ; power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; - clocks = <&topckgen CLK_TOP_USB30_SEL>; - clock-names = "sys_ck"; + clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>; + clock-names = "sys_ck", "ref_ck"; vusb33-supply = <&mt6397_vusb_reg>; usb3-lpm-capable; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/6] arm64: dts: mt8173: add reference clock for usb
add 26M reference clock for ssusb and xhci nodes Signed-off-by: Chunfeng Yun --- arch/arm64/boot/dts/mediatek/mt8173.dtsi |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index 07fd2eb..e2862b6 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi @@ -729,9 +729,11 @@ <&u2port1 PHY_TYPE_USB2>; power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; clocks = <&topckgen CLK_TOP_USB30_SEL>, +<&clk26m>, <&pericfg CLK_PERI_USB0>, <&pericfg CLK_PERI_USB1>; clock-names = "sys_ck", + "ref_ck", "wakeup_deb_p0", "wakeup_deb_p1"; mediatek,syscon-wakeup = <&pericfg>; @@ -746,8 +748,8 @@ reg-names = "mac"; interrupts = ; power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; - clocks = <&topckgen CLK_TOP_USB30_SEL>; - clock-names = "sys_ck"; + clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>; + clock-names = "sys_ck", "ref_ck"; status = "disabled"; }; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/6] dt-bindings: mt8173-mtu3: add reference clock
add a reference clock for compatibility Signed-off-by: Chunfeng Yun --- .../devicetree/bindings/usb/mt8173-mtu3.txt| 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt b/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt index e049d19..8c976cd 100644 --- a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt +++ b/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt @@ -10,7 +10,7 @@ Required properties: - vusb33-supply : regulator of USB avdd3.3v - clocks : a list of phandle + clock-specifier pairs, one for each entry in clock-names - - clock-names : must contain "sys_ck" for clock of controller; + - clock-names : must contain "sys_ck" and "ref_ck" for clock of controller; "wakeup_deb_p0" and "wakeup_deb_p1" are optional, they are depends on "mediatek,enable-wakeup" - phys : a list of phandle + phy specifier pairs @@ -56,10 +56,10 @@ ssusb: usb@11271000 { phys = <&phy_port0 PHY_TYPE_USB3>, <&phy_port1 PHY_TYPE_USB2>; power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; - clocks = <&topckgen CLK_TOP_USB30_SEL>, + clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>, <&pericfg CLK_PERI_USB0>, <&pericfg CLK_PERI_USB1>; - clock-names = "sys_ck", + clock-names = "sys_ck", "ref_ck", "wakeup_deb_p0", "wakeup_deb_p1"; vusb33-supply = <&mt6397_vusb_reg>; @@ -79,8 +79,8 @@ ssusb: usb@11271000 { reg-names = "mac"; interrupts = ; power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; - clocks = <&topckgen CLK_TOP_USB30_SEL>; - clock-names = "sys_ck"; + clocks = <&topckgen CLK_TOP_USB30_SEL>, <&clk26m>; + clock-names = "sys_ck", "ref_ck"; vusb33-supply = <&mt6397_vusb_reg>; status = "disabled"; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND PATCH 6/6] dt-bindings: phy-mt65xx-usb: add support for mt2712 platform
add a new compatible string for "mt2712", and a new reference clock for SuperSpeed analog phy; Signed-off-by: Chunfeng Yun --- .../devicetree/bindings/phy/phy-mt65xx-usb.txt | 81 +--- 1 file changed, 70 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt index 33a2b1e..8f91136 100644 --- a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt +++ b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt @@ -6,19 +6,25 @@ This binding describes a usb3.0 phy for mt65xx platforms of Medaitek SoC. Required properties (controller (parent) node): - compatible : should be one of "mediatek,mt2701-u3phy" + "mediatek,mt2712-u3phy" "mediatek,mt8173-u3phy" - - reg : offset and length of register for phy, exclude port's - register. - clocks : a list of phandle + clock-specifier pairs, one for each entry in clock-names - clock-names : must contain - "u3phya_ref": for reference clock of usb3.0 analog phy. + "u2ref_clk": 48M reference clock of HighSpeed analog phy. + "u3ref_clk": 26M reference clock of SuperSpeed analog phy, + sometimes is 24M, 25M or 27M, depended on platform. Required nodes : a sub-node is required for each port the controller provides. Address range information including the usual 'reg' property is used inside these nodes to describe the controller's topology. +Optional properties (controller (parent) node): + - reg : offset and length of register shared by multiple ports, + exclude port's private register. It is needed on mt2701 + and mt8173, but not on mt2712. + Required properties (port (child) node): - reg : address and length of the register set for the port. - #phy-cells : should be 1 (See second example) @@ -31,21 +37,27 @@ Example: u3phy: usb-phy@1129 { compatible = "mediatek,mt8173-u3phy"; reg = <0 0x1129 0 0x800>; - clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>; - clock-names = "u3phya_ref"; + clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>, <&clk26m>; + clock-names = "u2ref_clk", "u3ref_clk"; #address-cells = <2>; #size-cells = <2>; ranges; status = "okay"; - phy_port0: port@11290800 { - reg = <0 0x11290800 0 0x800>; + u2port0: port@11290800 { + reg = <0 0x11290800 0 0x100>; + #phy-cells = <1>; + status = "okay"; + }; + + u3port0: port@11290900 { + reg = <0 0x11290800 0 0x700>; #phy-cells = <1>; status = "okay"; }; - phy_port1: port@11291000 { - reg = <0 0x11291000 0 0x800>; + u2port1: port@11291000 { + reg = <0 0x11291000 0 0x100>; #phy-cells = <1>; status = "okay"; }; @@ -64,7 +76,54 @@ Example: usb30: usb@1127 { ... - phys = <&phy_port0 PHY_TYPE_USB3>; - phy-names = "usb3-0"; + phys = <&u2port0 PHY_TYPE_USB2>, <&u3port0 PHY_TYPE_USB3>; + phy-names = "usb2-0", "usb3-0"; ... }; + + +Layout differences of banks between mt8173/mt2701 and mt2712 +- +mt8173 and mt2701: +portoffsetbank +shared 0xSPLLC +0x0100FMREG +u2 port00x0800U2PHY_COM +u3 port00x0900U3PHYD +0x0a00U3PHYD_BANK2 +0x0b00U3PHYA +0x0c00U3PHYA_DA +u2 port10x1000U2PHY_COM +u3 port10x1100U3PHYD +0x1200U3PHYD_BANK2 +0x1300U3PHYA +0x1400U3PHYA_DA +u2 port20x1800U2PHY_COM +... + +mt2712: +portoffsetbank +u2 port00xMISC +0x0100FMREG +0x0300U2PHY_COM +u3 port00x0700SPLLC +0x0800CHIP +0x0900U3PHYD +0x0a00U3PHYD_BANK2 +0x0b00U3PHYA +0x0c00U3PHYA_DA +u2 port10x1000MISC +0x1100FMREG +0x1300U2PHY_COM +u3 port10x1700SPLLC +0x1800CHIP +0x1900U3PHYD +0x1a00U3PHYD_BANK2 +0x1b00U3PHYA +0x1c00U3PHYA_DA +u2 port20x2000MISC +... + +SPLLC shared by u3 ports and FMREG shared by u2 ports on +mt8173/mt2701 are put back into each port; a new bank MISC for +u2 ports and CHIP for u3 ports are added on mt2712. -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo in
[RESEND PATCH 2/6] phy: phy-mt65xx-usb3: split SuperSpeed port into two ones
Currently usb3 port in fact includes two sub-ports, but it is not flexible for some cases, such as following one: usb3 port0 includes u2port0 and u3port0; usb2 port0 includes u2port1; If wants to support only HS, we can use u2port0 or u2port1, when select u2port0, u3port0 is not needed; If wants to support SS, we can compound u2port0 and u3port0, or u2port1 and u3port0, if select latter one, u2port0 is not needed. So it's more flexible to split usb3 port into two ones and also try best to save power by disabling unnecessary ports. Signed-off-by: Chunfeng Yun --- drivers/phy/phy-mt65xx-usb3.c | 124 - 1 file changed, 61 insertions(+), 63 deletions(-) diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c index fc9a4f0..c187a3b 100644 --- a/drivers/phy/phy-mt65xx-usb3.c +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -30,11 +30,11 @@ #define SSUSB_SIFSLV_SPLLC 0x #define SSUSB_SIFSLV_U2FREQ0x0100 -/* offsets of sub-segment in each port registers */ +/* offsets of banks in each u2phy registers */ #define SSUSB_SIFSLV_U2PHY_COM_BASE0x -#define SSUSB_SIFSLV_U3PHYD_BASE 0x0100 -#define SSUSB_USB30_PHYA_SIV_B_BASE0x0300 -#define SSUSB_SIFSLV_U3PHYA_DA_BASE0x0400 +/* offsets of banks in each u3phy registers */ +#define SSUSB_SIFSLV_U3PHYD_BASE 0x +#define SSUSB_SIFSLV_U3PHYA_BASE 0x0200 #define U3P_USBPHYACR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x) #define PA0_RG_U2PLL_FORCE_ON BIT(15) @@ -49,7 +49,6 @@ #define PA5_RG_U2_HS_100U_U3_ENBIT(11) #define U3P_USBPHYACR6 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0018) -#define PA6_RG_U2_ISO_EN BIT(31) #define PA6_RG_U2_BC11_SW_EN BIT(23) #define PA6_RG_U2_OTG_VBUSCMP_EN BIT(20) #define PA6_RG_U2_SQTH GENMASK(3, 0) @@ -91,18 +90,18 @@ #define P2C_RG_SESSEND BIT(4) #define P2C_RG_AVALID BIT(2) -#define U3P_U3_PHYA_REG0 (SSUSB_USB30_PHYA_SIV_B_BASE + 0x) +#define U3P_U3_PHYA_REG0 (SSUSB_SIFSLV_U3PHYA_BASE + 0x) #define P3A_RG_U3_VUSB10_ONBIT(5) -#define U3P_U3_PHYA_REG6 (SSUSB_USB30_PHYA_SIV_B_BASE + 0x0018) +#define U3P_U3_PHYA_REG6 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0018) #define P3A_RG_TX_EIDLE_CM GENMASK(31, 28) #define P3A_RG_TX_EIDLE_CM_VAL(x) ((0xf & (x)) << 28) -#define U3P_U3_PHYA_REG9 (SSUSB_USB30_PHYA_SIV_B_BASE + 0x0024) +#define U3P_U3_PHYA_REG9 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0024) #define P3A_RG_RX_DAC_MUX GENMASK(5, 1) #define P3A_RG_RX_DAC_MUX_VAL(x) ((0x1f & (x)) << 1) -#define U3P_U3PHYA_DA_REG0 (SSUSB_SIFSLV_U3PHYA_DA_BASE + 0x) +#define U3P_U3PHYA_DA_REG0 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0100) #define P3A_RG_XTAL_EXT_EN_U3 GENMASK(11, 10) #define P3A_RG_XTAL_EXT_EN_U3_VAL(x) ((0x3 & (x)) << 10) @@ -148,7 +147,7 @@ struct mt65xx_phy_instance { struct mt65xx_u3phy { struct device *dev; - void __iomem *sif_base; /* include sif2, but exclude port's */ + void __iomem *sif_base; /* only shared sif */ struct clk *u2ref_clk; /* reference clock of u2 analog phy */ struct clk *u3ref_clk; /* reference clock of u3 analog phy */ const struct mt65xx_phy_pdata *pdata; @@ -179,7 +178,7 @@ static void hs_slew_rate_calibrate(struct mt65xx_u3phy *u3phy, tmp = readl(sif_base + U3P_U2FREQ_FMCR0); tmp &= ~(P2F_RG_CYCLECNT | P2F_RG_MONCLK_SEL); tmp |= P2F_RG_CYCLECNT_VAL(U3P_FM_DET_CYCLE_CNT); - tmp |= P2F_RG_MONCLK_SEL_VAL(instance->index); + tmp |= P2F_RG_MONCLK_SEL_VAL(instance->index >> 1); writel(tmp, sif_base + U3P_U2FREQ_FMCR0); /* enable frequency meter */ @@ -227,6 +226,41 @@ static void hs_slew_rate_calibrate(struct mt65xx_u3phy *u3phy, writel(tmp, instance->port_base + U3P_USBPHYACR5); } +static void u3_phy_instance_init(struct mt65xx_u3phy *u3phy, + struct mt65xx_phy_instance *instance) +{ + void __iomem *port_base = instance->port_base; + u32 tmp; + + /* gating PCIe Analog XTAL clock */ + tmp = readl(u3phy->sif_base + U3P_XTALCTL3); + tmp |= XC3_RG_U3_XTAL_RX_PWD | XC3_RG_U3_FRC_XTAL_RX_PWD; + writel(tmp, u3phy->sif_base + U3P_XTALCTL3); + + /* gating XSQ */ + tmp = readl(port_base + U3P_U3PHYA_DA_REG0); + tmp &= ~P3A_RG_XTAL_EXT_EN_U3; + tmp |= P3A_RG_XTAL_EXT_EN_U3_VAL(2); + writel(tmp, port_base + U3P_U3PHYA_DA_REG0); + + tmp = readl(port_base + U3P_U3_PHYA_REG9); + tmp &= ~P3A_RG_RX_DAC_MUX; + tmp |= P3A_RG_RX_DAC_MUX_VAL(4); + writel(tmp, port_base + U3P_U3_PHYA_REG9); + + tmp = readl(port_base + U3P_U3_PHYA_REG6); + tmp &= ~P3A_RG_TX_EIDLE_CM; + tmp |= P3A_RG_TX_EIDLE_CM_VAL(0xe); + writel(tmp, port_base + U3P_U3_PHYA_REG6); + + tmp = readl(port_base + U3P_PHYD_
[RESEND PATCH 4/6] arm64: dts: mt8173: add a new reference clock for usb3 analog phy
add a new reference clock which comes from 26M oscillator directly for SuperSpeed analog phy. and the old one which comes for PLL is 48M for HighSpeed analog phy. Signed-off-by: Chunfeng Yun --- arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index 12e7027..5d1663b 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi @@ -754,8 +754,8 @@ u3phy: usb-phy@1129 { compatible = "mediatek,mt8173-u3phy"; reg = <0 0x1129 0 0x800>; - clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>; - clock-names = "u3phya_ref"; + clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>, <&clk26m>; + clock-names = "u2ref_clk", "u3ref_clk"; #address-cells = <2>; #size-cells = <2>; ranges; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND PATCH 1/6] phy: phy-mt65xx-usb3: add reference clock of usb3 analog phy
usually, the reference clock of usb3 analog phy comes from 26M oscillator directly, but some SoCs are not, add it for compatibility. Signed-off-by: Chunfeng Yun --- drivers/phy/phy-mt65xx-usb3.c | 36 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c index d972067..fc9a4f0 100644 --- a/drivers/phy/phy-mt65xx-usb3.c +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -149,7 +149,8 @@ struct mt65xx_phy_instance { struct mt65xx_u3phy { struct device *dev; void __iomem *sif_base; /* include sif2, but exclude port's */ - struct clk *u3phya_ref; /* reference clock of usb3 anolog phy */ + struct clk *u2ref_clk; /* reference clock of u2 analog phy */ + struct clk *u3ref_clk; /* reference clock of u3 analog phy */ const struct mt65xx_phy_pdata *pdata; struct mt65xx_phy_instance **phys; int nphys; @@ -429,11 +430,17 @@ static int mt65xx_phy_init(struct phy *phy) { struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); + struct clk *ref_clk; int ret; - ret = clk_prepare_enable(u3phy->u3phya_ref); + if (instance->type == PHY_TYPE_USB2) + ref_clk = u3phy->u2ref_clk; + else + ref_clk = u3phy->u3ref_clk; + + ret = clk_prepare_enable(ref_clk); if (ret) { - dev_err(u3phy->dev, "failed to enable u3phya_ref\n"); + dev_err(u3phy->dev, "failed to enable ref clk\n"); return ret; } @@ -464,9 +471,16 @@ static int mt65xx_phy_exit(struct phy *phy) { struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); + struct clk *ref_clk; phy_instance_exit(u3phy, instance); - clk_disable_unprepare(u3phy->u3phya_ref); + + if (instance->type == PHY_TYPE_USB2) + ref_clk = u3phy->u2ref_clk; + else + ref_clk = u3phy->u3ref_clk; + + clk_disable_unprepare(ref_clk); return 0; } @@ -566,10 +580,16 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev) return PTR_ERR(u3phy->sif_base); } - u3phy->u3phya_ref = devm_clk_get(dev, "u3phya_ref"); - if (IS_ERR(u3phy->u3phya_ref)) { - dev_err(dev, "error to get u3phya_ref\n"); - return PTR_ERR(u3phy->u3phya_ref); + u3phy->u2ref_clk = devm_clk_get(dev, "u2ref_clk"); + if (IS_ERR(u3phy->u2ref_clk)) { + dev_err(dev, "failed to get u2ref_clk\n"); + return PTR_ERR(u3phy->u2ref_clk); + } + + u3phy->u3ref_clk = devm_clk_get(dev, "u3ref_clk"); + if (IS_ERR(u3phy->u3ref_clk)) { + dev_err(dev, "failed to get u3ref_clk\n"); + return PTR_ERR(u3phy->u3ref_clk); } port = 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[RESEND PATCH 3/6] phy: phy-mt65xx-usb3: add support for mt2712 platform
There are some variations from mt2701 to mt2712: 1. banks shared by multiple ports are put back into each port, such as SPLLC and U2FREQ; 2. add a new bank MISC for u2port, and CHIP for u3port; 3. bank's offset in each port are also rearranged; Signed-off-by: Chunfeng Yun --- drivers/phy/phy-mt65xx-usb3.c | 326 ++--- 1 file changed, 208 insertions(+), 118 deletions(-) diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c index c187a3b..d515c69 100644 --- a/drivers/phy/phy-mt65xx-usb3.c +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -23,46 +23,54 @@ #include #include -/* - * for sifslv2 register, but exclude port's; - * relative to USB3_SIF2_BASE base address - */ -#define SSUSB_SIFSLV_SPLLC 0x -#define SSUSB_SIFSLV_U2FREQ0x0100 - -/* offsets of banks in each u2phy registers */ -#define SSUSB_SIFSLV_U2PHY_COM_BASE0x -/* offsets of banks in each u3phy registers */ -#define SSUSB_SIFSLV_U3PHYD_BASE 0x -#define SSUSB_SIFSLV_U3PHYA_BASE 0x0200 - -#define U3P_USBPHYACR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x) +/* version V1 sub-banks offset base address */ +/* banks shared by multiple phys */ +#define SSUSB_SIFSLV_V1_SPLLC 0x000 /* shared by u3 phys */ +#define SSUSB_SIFSLV_V1_U2FREQ 0x100 /* shared by u2 phys */ +/* u2 phy bank */ +#define SSUSB_SIFSLV_V1_U2PHY_COM 0x000 +/* u3 phy banks */ +#define SSUSB_SIFSLV_V1_U3PHYD 0x000 +#define SSUSB_SIFSLV_V1_U3PHYA 0x200 + +/* version V2 sub-banks offset base address */ +/* u2 phy banks */ +#define SSUSB_SIFSLV_V2_MISC 0x000 +#define SSUSB_SIFSLV_V2_U2FREQ 0x100 +#define SSUSB_SIFSLV_V2_U2PHY_COM 0x300 +/* u3 phy banks */ +#define SSUSB_SIFSLV_V2_SPLLC 0x000 +#define SSUSB_SIFSLV_V2_CHIP 0x100 +#define SSUSB_SIFSLV_V2_U3PHYD 0x200 +#define SSUSB_SIFSLV_V2_U3PHYA 0x400 + +#define U3P_USBPHYACR0 0x000 #define PA0_RG_U2PLL_FORCE_ON BIT(15) -#define U3P_USBPHYACR2 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0008) +#define U3P_USBPHYACR2 0x008 #define PA2_RG_SIF_U2PLL_FORCE_EN BIT(18) -#define U3P_USBPHYACR5 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0014) +#define U3P_USBPHYACR5 0x014 #define PA5_RG_U2_HSTX_SRCAL_ENBIT(15) #define PA5_RG_U2_HSTX_SRCTRL GENMASK(14, 12) #define PA5_RG_U2_HSTX_SRCTRL_VAL(x) ((0x7 & (x)) << 12) #define PA5_RG_U2_HS_100U_U3_ENBIT(11) -#define U3P_USBPHYACR6 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0018) +#define U3P_USBPHYACR6 0x018 #define PA6_RG_U2_BC11_SW_EN BIT(23) #define PA6_RG_U2_OTG_VBUSCMP_EN BIT(20) #define PA6_RG_U2_SQTH GENMASK(3, 0) #define PA6_RG_U2_SQTH_VAL(x) (0xf & (x)) -#define U3P_U2PHYACR4 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0020) +#define U3P_U2PHYACR4 0x020 #define P2C_RG_USB20_GPIO_CTL BIT(9) #define P2C_USB20_GPIO_MODEBIT(8) #define P2C_U2_GPIO_CTR_MSK(P2C_RG_USB20_GPIO_CTL | P2C_USB20_GPIO_MODE) -#define U3D_U2PHYDCR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0060) +#define U3D_U2PHYDCR0 0x060 #define P2C_RG_SIF_U2PLL_FORCE_ON BIT(24) -#define U3P_U2PHYDTM0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0068) +#define U3P_U2PHYDTM0 0x068 #define P2C_FORCE_UART_EN BIT(26) #define P2C_FORCE_DATAIN BIT(23) #define P2C_FORCE_DM_PULLDOWN BIT(21) @@ -84,47 +92,44 @@ P2C_FORCE_TERMSEL | P2C_RG_DMPULLDOWN | \ P2C_RG_DPPULLDOWN | P2C_RG_TERMSEL) -#define U3P_U2PHYDTM1 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x006C) +#define U3P_U2PHYDTM1 0x06C #define P2C_RG_UART_EN BIT(16) #define P2C_RG_VBUSVALID BIT(5) #define P2C_RG_SESSEND BIT(4) #define P2C_RG_AVALID BIT(2) -#define U3P_U3_PHYA_REG0 (SSUSB_SIFSLV_U3PHYA_BASE + 0x) -#define P3A_RG_U3_VUSB10_ONBIT(5) - -#define U3P_U3_PHYA_REG6 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0018) +#define U3P_U3_PHYA_REG6 0x018 #define P3A_RG_TX_EIDLE_CM GENMASK(31, 28) #define P3A_RG_TX_EIDLE_CM_VAL(x) ((0xf & (x)) << 28) -#define U3P_U3_PHYA_REG9 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0024) +#define U3P_U3_PHYA_REG9 0x024 #define P3A_RG_RX_DAC_MUX GENMASK(5, 1) #define P3A_RG_RX_DAC_MUX_VAL(x) ((0x1f & (x)) << 1) -#define U3P_U3PHYA_DA_REG0 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0100) +#define U3P_U3_PHYA_DA_REG00x100 #define P3A_RG_XTAL_EXT_EN_U3 GENMASK(11, 10) #define P3A_RG_XTAL_EXT_EN_U3_VAL(x) ((0x3 & (x)) << 10) -#define U3P_PHYD_CDR1 (SSUSB_SIFSLV_U3PHYD_BASE + 0x005c) +#define U3P_U3_PHYD_CDR1 0x05c #define P3D_RG_CDR_BIR_LTD1GENMASK(28, 24) #define P3D_RG_CDR_BIR_LTD1_VAL(x) ((0x1f & (x)) << 24) #define P3D_RG_CDR_BIR_
[RESEND PATCH 5/6] arm64: dts: mt8173: split usb SuperSpeed port into two ports
split the old SuperSpeed port node into a HighSpeed one and a new SuperSpeed one. Signed-off-by: Chunfeng Yun --- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index 5d1663b..07fd2eb 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi @@ -724,8 +724,9 @@ <0 0x11280700 0 0x0100>; reg-names = "mac", "ippc"; interrupts = ; - phys = <&phy_port0 PHY_TYPE_USB3>, - <&phy_port1 PHY_TYPE_USB2>; + phys = <&u2port0 PHY_TYPE_USB2>, + <&u3port0 PHY_TYPE_USB3>, + <&u2port1 PHY_TYPE_USB2>; power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; clocks = <&topckgen CLK_TOP_USB30_SEL>, <&pericfg CLK_PERI_USB0>, @@ -761,14 +762,20 @@ ranges; status = "okay"; - phy_port0: port@11290800 { - reg = <0 0x11290800 0 0x800>; + u2port0: port@11290800 { + reg = <0 0x11290800 0 0x100>; #phy-cells = <1>; status = "okay"; }; - phy_port1: port@11291000 { - reg = <0 0x11291000 0 0x800>; + u3port0: port@11290900 { + reg = <0 0x11290900 0 0x700>; + #phy-cells = <1>; + status = "okay"; + }; + + u2port1: port@11291000 { + reg = <0 0x11291000 0 0x100>; #phy-cells = <1>; status = "okay"; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/6] phy: phy-mt65xx-usb3: add support for mt2712 platform
There are some variations from mt2701 to mt2712: 1. banks shared by multiple ports are put back into each port, such as SPLLC and U2FREQ; 2. add a new bank MISC for u2port, and CHIP for u3port; 3. bank's offset in each port are also rearranged; Signed-off-by: Chunfeng Yun --- drivers/phy/phy-mt65xx-usb3.c | 326 ++--- 1 file changed, 208 insertions(+), 118 deletions(-) diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c index c187a3b..d515c69 100644 --- a/drivers/phy/phy-mt65xx-usb3.c +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -23,46 +23,54 @@ #include #include -/* - * for sifslv2 register, but exclude port's; - * relative to USB3_SIF2_BASE base address - */ -#define SSUSB_SIFSLV_SPLLC 0x -#define SSUSB_SIFSLV_U2FREQ0x0100 - -/* offsets of banks in each u2phy registers */ -#define SSUSB_SIFSLV_U2PHY_COM_BASE0x -/* offsets of banks in each u3phy registers */ -#define SSUSB_SIFSLV_U3PHYD_BASE 0x -#define SSUSB_SIFSLV_U3PHYA_BASE 0x0200 - -#define U3P_USBPHYACR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x) +/* version V1 sub-banks offset base address */ +/* banks shared by multiple phys */ +#define SSUSB_SIFSLV_V1_SPLLC 0x000 /* shared by u3 phys */ +#define SSUSB_SIFSLV_V1_U2FREQ 0x100 /* shared by u2 phys */ +/* u2 phy bank */ +#define SSUSB_SIFSLV_V1_U2PHY_COM 0x000 +/* u3 phy banks */ +#define SSUSB_SIFSLV_V1_U3PHYD 0x000 +#define SSUSB_SIFSLV_V1_U3PHYA 0x200 + +/* version V2 sub-banks offset base address */ +/* u2 phy banks */ +#define SSUSB_SIFSLV_V2_MISC 0x000 +#define SSUSB_SIFSLV_V2_U2FREQ 0x100 +#define SSUSB_SIFSLV_V2_U2PHY_COM 0x300 +/* u3 phy banks */ +#define SSUSB_SIFSLV_V2_SPLLC 0x000 +#define SSUSB_SIFSLV_V2_CHIP 0x100 +#define SSUSB_SIFSLV_V2_U3PHYD 0x200 +#define SSUSB_SIFSLV_V2_U3PHYA 0x400 + +#define U3P_USBPHYACR0 0x000 #define PA0_RG_U2PLL_FORCE_ON BIT(15) -#define U3P_USBPHYACR2 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0008) +#define U3P_USBPHYACR2 0x008 #define PA2_RG_SIF_U2PLL_FORCE_EN BIT(18) -#define U3P_USBPHYACR5 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0014) +#define U3P_USBPHYACR5 0x014 #define PA5_RG_U2_HSTX_SRCAL_ENBIT(15) #define PA5_RG_U2_HSTX_SRCTRL GENMASK(14, 12) #define PA5_RG_U2_HSTX_SRCTRL_VAL(x) ((0x7 & (x)) << 12) #define PA5_RG_U2_HS_100U_U3_ENBIT(11) -#define U3P_USBPHYACR6 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0018) +#define U3P_USBPHYACR6 0x018 #define PA6_RG_U2_BC11_SW_EN BIT(23) #define PA6_RG_U2_OTG_VBUSCMP_EN BIT(20) #define PA6_RG_U2_SQTH GENMASK(3, 0) #define PA6_RG_U2_SQTH_VAL(x) (0xf & (x)) -#define U3P_U2PHYACR4 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0020) +#define U3P_U2PHYACR4 0x020 #define P2C_RG_USB20_GPIO_CTL BIT(9) #define P2C_USB20_GPIO_MODEBIT(8) #define P2C_U2_GPIO_CTR_MSK(P2C_RG_USB20_GPIO_CTL | P2C_USB20_GPIO_MODE) -#define U3D_U2PHYDCR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0060) +#define U3D_U2PHYDCR0 0x060 #define P2C_RG_SIF_U2PLL_FORCE_ON BIT(24) -#define U3P_U2PHYDTM0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0068) +#define U3P_U2PHYDTM0 0x068 #define P2C_FORCE_UART_EN BIT(26) #define P2C_FORCE_DATAIN BIT(23) #define P2C_FORCE_DM_PULLDOWN BIT(21) @@ -84,47 +92,44 @@ P2C_FORCE_TERMSEL | P2C_RG_DMPULLDOWN | \ P2C_RG_DPPULLDOWN | P2C_RG_TERMSEL) -#define U3P_U2PHYDTM1 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x006C) +#define U3P_U2PHYDTM1 0x06C #define P2C_RG_UART_EN BIT(16) #define P2C_RG_VBUSVALID BIT(5) #define P2C_RG_SESSEND BIT(4) #define P2C_RG_AVALID BIT(2) -#define U3P_U3_PHYA_REG0 (SSUSB_SIFSLV_U3PHYA_BASE + 0x) -#define P3A_RG_U3_VUSB10_ONBIT(5) - -#define U3P_U3_PHYA_REG6 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0018) +#define U3P_U3_PHYA_REG6 0x018 #define P3A_RG_TX_EIDLE_CM GENMASK(31, 28) #define P3A_RG_TX_EIDLE_CM_VAL(x) ((0xf & (x)) << 28) -#define U3P_U3_PHYA_REG9 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0024) +#define U3P_U3_PHYA_REG9 0x024 #define P3A_RG_RX_DAC_MUX GENMASK(5, 1) #define P3A_RG_RX_DAC_MUX_VAL(x) ((0x1f & (x)) << 1) -#define U3P_U3PHYA_DA_REG0 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0100) +#define U3P_U3_PHYA_DA_REG00x100 #define P3A_RG_XTAL_EXT_EN_U3 GENMASK(11, 10) #define P3A_RG_XTAL_EXT_EN_U3_VAL(x) ((0x3 & (x)) << 10) -#define U3P_PHYD_CDR1 (SSUSB_SIFSLV_U3PHYD_BASE + 0x005c) +#define U3P_U3_PHYD_CDR1 0x05c #define P3D_RG_CDR_BIR_LTD1GENMASK(28, 24) #define P3D_RG_CDR_BIR_LTD1_VAL(x) ((0x1f & (x)) << 24) #define P3D_RG_CDR_BIR_
[PATCH 2/6] phy: phy-mt65xx-usb3: split SuperSpeed port into two ones
Currently usb3 port in fact includes two sub-ports, but it is not flexible for some cases, such as following one: usb3 port0 includes u2port0 and u3port0; usb2 port0 includes u2port1; If wants to support only HS, we can use u2port0 or u2port1, when select u2port0, u3port0 is not needed; If wants to support SS, we can compound u2port0 and u3port0, or u2port1 and u3port0, if select latter one, u2port0 is not needed. So it's more flexible to split usb3 port into two ones and also try best to save power by disabling unnecessary ports. Signed-off-by: Chunfeng Yun --- drivers/phy/phy-mt65xx-usb3.c | 124 - 1 file changed, 61 insertions(+), 63 deletions(-) diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c index fc9a4f0..c187a3b 100644 --- a/drivers/phy/phy-mt65xx-usb3.c +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -30,11 +30,11 @@ #define SSUSB_SIFSLV_SPLLC 0x #define SSUSB_SIFSLV_U2FREQ0x0100 -/* offsets of sub-segment in each port registers */ +/* offsets of banks in each u2phy registers */ #define SSUSB_SIFSLV_U2PHY_COM_BASE0x -#define SSUSB_SIFSLV_U3PHYD_BASE 0x0100 -#define SSUSB_USB30_PHYA_SIV_B_BASE0x0300 -#define SSUSB_SIFSLV_U3PHYA_DA_BASE0x0400 +/* offsets of banks in each u3phy registers */ +#define SSUSB_SIFSLV_U3PHYD_BASE 0x +#define SSUSB_SIFSLV_U3PHYA_BASE 0x0200 #define U3P_USBPHYACR0 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x) #define PA0_RG_U2PLL_FORCE_ON BIT(15) @@ -49,7 +49,6 @@ #define PA5_RG_U2_HS_100U_U3_ENBIT(11) #define U3P_USBPHYACR6 (SSUSB_SIFSLV_U2PHY_COM_BASE + 0x0018) -#define PA6_RG_U2_ISO_EN BIT(31) #define PA6_RG_U2_BC11_SW_EN BIT(23) #define PA6_RG_U2_OTG_VBUSCMP_EN BIT(20) #define PA6_RG_U2_SQTH GENMASK(3, 0) @@ -91,18 +90,18 @@ #define P2C_RG_SESSEND BIT(4) #define P2C_RG_AVALID BIT(2) -#define U3P_U3_PHYA_REG0 (SSUSB_USB30_PHYA_SIV_B_BASE + 0x) +#define U3P_U3_PHYA_REG0 (SSUSB_SIFSLV_U3PHYA_BASE + 0x) #define P3A_RG_U3_VUSB10_ONBIT(5) -#define U3P_U3_PHYA_REG6 (SSUSB_USB30_PHYA_SIV_B_BASE + 0x0018) +#define U3P_U3_PHYA_REG6 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0018) #define P3A_RG_TX_EIDLE_CM GENMASK(31, 28) #define P3A_RG_TX_EIDLE_CM_VAL(x) ((0xf & (x)) << 28) -#define U3P_U3_PHYA_REG9 (SSUSB_USB30_PHYA_SIV_B_BASE + 0x0024) +#define U3P_U3_PHYA_REG9 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0024) #define P3A_RG_RX_DAC_MUX GENMASK(5, 1) #define P3A_RG_RX_DAC_MUX_VAL(x) ((0x1f & (x)) << 1) -#define U3P_U3PHYA_DA_REG0 (SSUSB_SIFSLV_U3PHYA_DA_BASE + 0x) +#define U3P_U3PHYA_DA_REG0 (SSUSB_SIFSLV_U3PHYA_BASE + 0x0100) #define P3A_RG_XTAL_EXT_EN_U3 GENMASK(11, 10) #define P3A_RG_XTAL_EXT_EN_U3_VAL(x) ((0x3 & (x)) << 10) @@ -148,7 +147,7 @@ struct mt65xx_phy_instance { struct mt65xx_u3phy { struct device *dev; - void __iomem *sif_base; /* include sif2, but exclude port's */ + void __iomem *sif_base; /* only shared sif */ struct clk *u2ref_clk; /* reference clock of u2 analog phy */ struct clk *u3ref_clk; /* reference clock of u3 analog phy */ const struct mt65xx_phy_pdata *pdata; @@ -179,7 +178,7 @@ static void hs_slew_rate_calibrate(struct mt65xx_u3phy *u3phy, tmp = readl(sif_base + U3P_U2FREQ_FMCR0); tmp &= ~(P2F_RG_CYCLECNT | P2F_RG_MONCLK_SEL); tmp |= P2F_RG_CYCLECNT_VAL(U3P_FM_DET_CYCLE_CNT); - tmp |= P2F_RG_MONCLK_SEL_VAL(instance->index); + tmp |= P2F_RG_MONCLK_SEL_VAL(instance->index >> 1); writel(tmp, sif_base + U3P_U2FREQ_FMCR0); /* enable frequency meter */ @@ -227,6 +226,41 @@ static void hs_slew_rate_calibrate(struct mt65xx_u3phy *u3phy, writel(tmp, instance->port_base + U3P_USBPHYACR5); } +static void u3_phy_instance_init(struct mt65xx_u3phy *u3phy, + struct mt65xx_phy_instance *instance) +{ + void __iomem *port_base = instance->port_base; + u32 tmp; + + /* gating PCIe Analog XTAL clock */ + tmp = readl(u3phy->sif_base + U3P_XTALCTL3); + tmp |= XC3_RG_U3_XTAL_RX_PWD | XC3_RG_U3_FRC_XTAL_RX_PWD; + writel(tmp, u3phy->sif_base + U3P_XTALCTL3); + + /* gating XSQ */ + tmp = readl(port_base + U3P_U3PHYA_DA_REG0); + tmp &= ~P3A_RG_XTAL_EXT_EN_U3; + tmp |= P3A_RG_XTAL_EXT_EN_U3_VAL(2); + writel(tmp, port_base + U3P_U3PHYA_DA_REG0); + + tmp = readl(port_base + U3P_U3_PHYA_REG9); + tmp &= ~P3A_RG_RX_DAC_MUX; + tmp |= P3A_RG_RX_DAC_MUX_VAL(4); + writel(tmp, port_base + U3P_U3_PHYA_REG9); + + tmp = readl(port_base + U3P_U3_PHYA_REG6); + tmp &= ~P3A_RG_TX_EIDLE_CM; + tmp |= P3A_RG_TX_EIDLE_CM_VAL(0xe); + writel(tmp, port_base + U3P_U3_PHYA_REG6); + + tmp = readl(port_base + U3P_PHYD_
[PATCH 4/6] arm64: dts: mt8173: add a new reference clock for usb3 analog phy
add a new reference clock which comes from 26M oscillator directly for SuperSpeed analog phy. and the old one which comes for PLL is 48M for HighSpeed analog phy. Signed-off-by: Chunfeng Yun --- arch/arm64/boot/dts/mediatek/mt8173.dtsi |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index 12e7027..5d1663b 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi @@ -754,8 +754,8 @@ u3phy: usb-phy@1129 { compatible = "mediatek,mt8173-u3phy"; reg = <0 0x1129 0 0x800>; - clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>; - clock-names = "u3phya_ref"; + clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>, <&clk26m>; + clock-names = "u2ref_clk", "u3ref_clk"; #address-cells = <2>; #size-cells = <2>; ranges; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 5/6] arm64: dts: mt8173: split usb SuperSpeed port into two ports
split the old SuperSpeed port node into a HighSpeed one and a new SuperSpeed one. Signed-off-by: Chunfeng Yun --- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 19 +-- 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi index 5d1663b..07fd2eb 100644 --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi @@ -724,8 +724,9 @@ <0 0x11280700 0 0x0100>; reg-names = "mac", "ippc"; interrupts = ; - phys = <&phy_port0 PHY_TYPE_USB3>, - <&phy_port1 PHY_TYPE_USB2>; + phys = <&u2port0 PHY_TYPE_USB2>, + <&u3port0 PHY_TYPE_USB3>, + <&u2port1 PHY_TYPE_USB2>; power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; clocks = <&topckgen CLK_TOP_USB30_SEL>, <&pericfg CLK_PERI_USB0>, @@ -761,14 +762,20 @@ ranges; status = "okay"; - phy_port0: port@11290800 { - reg = <0 0x11290800 0 0x800>; + u2port0: port@11290800 { + reg = <0 0x11290800 0 0x100>; #phy-cells = <1>; status = "okay"; }; - phy_port1: port@11291000 { - reg = <0 0x11291000 0 0x800>; + u3port0: port@11290900 { + reg = <0 0x11290900 0 0x700>; + #phy-cells = <1>; + status = "okay"; + }; + + u2port1: port@11291000 { + reg = <0 0x11291000 0 0x100>; #phy-cells = <1>; status = "okay"; }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/6] dt-bindings: phy-mt65xx-usb: add support for mt2712 platform
add a new compatible string for "mt2712", and a new reference clock for SuperSpeed analog phy; Signed-off-by: Chunfeng Yun --- .../devicetree/bindings/phy/phy-mt65xx-usb.txt | 81 +--- 1 file changed, 70 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt index 33a2b1e..8f91136 100644 --- a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt +++ b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt @@ -6,19 +6,25 @@ This binding describes a usb3.0 phy for mt65xx platforms of Medaitek SoC. Required properties (controller (parent) node): - compatible : should be one of "mediatek,mt2701-u3phy" + "mediatek,mt2712-u3phy" "mediatek,mt8173-u3phy" - - reg : offset and length of register for phy, exclude port's - register. - clocks : a list of phandle + clock-specifier pairs, one for each entry in clock-names - clock-names : must contain - "u3phya_ref": for reference clock of usb3.0 analog phy. + "u2ref_clk": 48M reference clock of HighSpeed analog phy. + "u3ref_clk": 26M reference clock of SuperSpeed analog phy, + sometimes is 24M, 25M or 27M, depended on platform. Required nodes : a sub-node is required for each port the controller provides. Address range information including the usual 'reg' property is used inside these nodes to describe the controller's topology. +Optional properties (controller (parent) node): + - reg : offset and length of register shared by multiple ports, + exclude port's private register. It is needed on mt2701 + and mt8173, but not on mt2712. + Required properties (port (child) node): - reg : address and length of the register set for the port. - #phy-cells : should be 1 (See second example) @@ -31,21 +37,27 @@ Example: u3phy: usb-phy@1129 { compatible = "mediatek,mt8173-u3phy"; reg = <0 0x1129 0 0x800>; - clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>; - clock-names = "u3phya_ref"; + clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>, <&clk26m>; + clock-names = "u2ref_clk", "u3ref_clk"; #address-cells = <2>; #size-cells = <2>; ranges; status = "okay"; - phy_port0: port@11290800 { - reg = <0 0x11290800 0 0x800>; + u2port0: port@11290800 { + reg = <0 0x11290800 0 0x100>; + #phy-cells = <1>; + status = "okay"; + }; + + u3port0: port@11290900 { + reg = <0 0x11290800 0 0x700>; #phy-cells = <1>; status = "okay"; }; - phy_port1: port@11291000 { - reg = <0 0x11291000 0 0x800>; + u2port1: port@11291000 { + reg = <0 0x11291000 0 0x100>; #phy-cells = <1>; status = "okay"; }; @@ -64,7 +76,54 @@ Example: usb30: usb@1127 { ... - phys = <&phy_port0 PHY_TYPE_USB3>; - phy-names = "usb3-0"; + phys = <&u2port0 PHY_TYPE_USB2>, <&u3port0 PHY_TYPE_USB3>; + phy-names = "usb2-0", "usb3-0"; ... }; + + +Layout differences of banks between mt8173/mt2701 and mt2712 +- +mt8173 and mt2701: +portoffsetbank +shared 0xSPLLC +0x0100FMREG +u2 port00x0800U2PHY_COM +u3 port00x0900U3PHYD +0x0a00U3PHYD_BANK2 +0x0b00U3PHYA +0x0c00U3PHYA_DA +u2 port10x1000U2PHY_COM +u3 port10x1100U3PHYD +0x1200U3PHYD_BANK2 +0x1300U3PHYA +0x1400U3PHYA_DA +u2 port20x1800U2PHY_COM +... + +mt2712: +portoffsetbank +u2 port00xMISC +0x0100FMREG +0x0300U2PHY_COM +u3 port00x0700SPLLC +0x0800CHIP +0x0900U3PHYD +0x0a00U3PHYD_BANK2 +0x0b00U3PHYA +0x0c00U3PHYA_DA +u2 port10x1000MISC +0x1100FMREG +0x1300U2PHY_COM +u3 port10x1700SPLLC +0x1800CHIP +0x1900U3PHYD +0x1a00U3PHYD_BANK2 +0x1b00U3PHYA +0x1c00U3PHYA_DA +u2 port20x2000MISC +... + +SPLLC shared by u3 ports and FMREG shared by u2 ports on +mt8173/mt2701 are put back into each port; a new bank MISC for +u2 ports and CHIP for u3 ports are added on mt2712. -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo in
[PATCH 1/6] phy: phy-mt65xx-usb3: add reference clock of usb3 analog phy
usually, the reference clock of usb3 analog phy comes from 26M oscillator directly, but some SoCs are not, add it for compatibility. Signed-off-by: Chunfeng Yun --- drivers/phy/phy-mt65xx-usb3.c | 36 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c index d972067..fc9a4f0 100644 --- a/drivers/phy/phy-mt65xx-usb3.c +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -149,7 +149,8 @@ struct mt65xx_phy_instance { struct mt65xx_u3phy { struct device *dev; void __iomem *sif_base; /* include sif2, but exclude port's */ - struct clk *u3phya_ref; /* reference clock of usb3 anolog phy */ + struct clk *u2ref_clk; /* reference clock of u2 analog phy */ + struct clk *u3ref_clk; /* reference clock of u3 analog phy */ const struct mt65xx_phy_pdata *pdata; struct mt65xx_phy_instance **phys; int nphys; @@ -429,11 +430,17 @@ static int mt65xx_phy_init(struct phy *phy) { struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); + struct clk *ref_clk; int ret; - ret = clk_prepare_enable(u3phy->u3phya_ref); + if (instance->type == PHY_TYPE_USB2) + ref_clk = u3phy->u2ref_clk; + else + ref_clk = u3phy->u3ref_clk; + + ret = clk_prepare_enable(ref_clk); if (ret) { - dev_err(u3phy->dev, "failed to enable u3phya_ref\n"); + dev_err(u3phy->dev, "failed to enable ref clk\n"); return ret; } @@ -464,9 +471,16 @@ static int mt65xx_phy_exit(struct phy *phy) { struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); + struct clk *ref_clk; phy_instance_exit(u3phy, instance); - clk_disable_unprepare(u3phy->u3phya_ref); + + if (instance->type == PHY_TYPE_USB2) + ref_clk = u3phy->u2ref_clk; + else + ref_clk = u3phy->u3ref_clk; + + clk_disable_unprepare(ref_clk); return 0; } @@ -566,10 +580,16 @@ static int mt65xx_u3phy_probe(struct platform_device *pdev) return PTR_ERR(u3phy->sif_base); } - u3phy->u3phya_ref = devm_clk_get(dev, "u3phya_ref"); - if (IS_ERR(u3phy->u3phya_ref)) { - dev_err(dev, "error to get u3phya_ref\n"); - return PTR_ERR(u3phy->u3phya_ref); + u3phy->u2ref_clk = devm_clk_get(dev, "u2ref_clk"); + if (IS_ERR(u3phy->u2ref_clk)) { + dev_err(dev, "failed to get u2ref_clk\n"); + return PTR_ERR(u3phy->u2ref_clk); + } + + u3phy->u3ref_clk = devm_clk_get(dev, "u3ref_clk"); + if (IS_ERR(u3phy->u3ref_clk)) { + dev_err(dev, "failed to get u3ref_clk\n"); + return PTR_ERR(u3phy->u3ref_clk); } port = 0; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 22/28] usb: dwc2: Avoid sleeping while holding hsotg->lock
From: John Stultz Basically when plugging in various cables in different orders, I'm occasionally seeing the following BUG splat: [ 86.215403] BUG: scheduling while atomic: kworker/u16:2/53/0x0002 [ 86.219164] usb 1-1: USB disconnect, device number 9 [ 86.226845] Preemption disabled at:[ 86.230218] [] dwc2_conn_id_status_change+0x120/0x250 [ 86.236894] CPU: 0 PID: 53 Comm: kworker/u16:2 Tainted: GW 4.9.0-rc8-00051-gd5a7979-dirty #1702 [ 86.246836] Hardware name: HiKey Development Board (DT) [ 86.252100] Workqueue: dwc2 dwc2_conn_id_status_change [ 86.257279] Call trace: [ 86.259771] [] dump_backtrace+0x0/0x1a0 [ 86.265210] [] show_stack+0x14/0x20 [ 86.270308] [] dump_stack+0x90/0xb0 [ 86.275401] [] __schedule_bug+0x6c/0xb8 [ 86.280841] [] __schedule+0x4f8/0x5b0 [ 86.286099] [] schedule+0x38/0xa0 [ 86.291017] [] schedule_hrtimeout_range_clock+0x8c/0xf0 [ 86.297846] [] schedule_hrtimeout_range+0x10/0x18 [ 86.304150] [] usleep_range+0x50/0x58 [ 86.309418] [] dwc2_wait_for_mode.isra.4+0x54/0xd0 [ 86.315815] [] dwc2_core_reset+0xe0/0x168 [ 86.321431] [] dwc2_hsotg_core_init_disconnected+0x2c/0x310 [ 86.328602] [] dwc2_conn_id_status_change+0x130/0x250 [ 86.335254] [] process_one_work+0x118/0x370 [ 86.341035] [] worker_thread+0x48/0x498 [ 86.346473] [] kthread+0xd0/0xe8 [ 86.351299] [] ret_from_fork+0x10/0x50 This seems to be caused by the dwc2_wait_for_mode() calling usleep_range() while the hstog->lock spinlock is held, since we take that before calling dwc2_hsotg_core_init_disconnected(). This patch avoids the issue by adding an extra argument to dwc2_core_reset(), as suggested by John Youn, which allows us to skip the waiting, which should be unnecessary when calling from dwc2_hsotg_core_init_disconnected(). Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Vardan Mikayelyan Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: John Stultz Signed-off-by: John Youn --- drivers/usb/dwc2/core.c | 6 +++--- drivers/usb/dwc2/core.h | 2 +- drivers/usb/dwc2/gadget.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index c987547a1e7b..7195366e26bf 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -313,7 +313,7 @@ static bool dwc2_iddig_filter_enabled(struct dwc2_hsotg *hsotg) * Do core a soft reset of the core. Be careful with this because it * resets all the internal state machines of the core. */ -int dwc2_core_reset(struct dwc2_hsotg *hsotg) +int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait) { u32 greset; int count = 0; @@ -369,7 +369,7 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg) } } while (!(greset & GRSTCTL_AHBIDLE)); - if (wait_for_host_mode) + if (wait_for_host_mode && !skip_wait) dwc2_wait_for_mode(hsotg, true); return 0; @@ -500,7 +500,7 @@ int dwc2_core_reset_and_force_dr_mode(struct dwc2_hsotg *hsotg) { int retval; - retval = dwc2_core_reset(hsotg); + retval = dwc2_core_reset(hsotg, false); if (retval) return retval; diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 2bd3ea624cfc..b07bf7be2034 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -1088,7 +1088,7 @@ static inline bool dwc2_is_hs_iot(struct dwc2_hsotg *hsotg) * The following functions support initialization of the core driver component * and the DWC_otg controller */ -int dwc2_core_reset(struct dwc2_hsotg *hsotg); +int dwc2_core_reset(struct dwc2_hsotg *hsotg, bool skip_wait); int dwc2_core_reset_and_force_dr_mode(struct dwc2_hsotg *hsotg); int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg); int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool restore); diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index ce5a1fb3a8ef..288402d44fce 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3161,7 +3161,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, kill_all_requests(hsotg, hsotg->eps_out[0], -ECONNRESET); if (!is_usb_reset) - if (dwc2_core_reset(hsotg)) + if (dwc2_core_reset(hsotg, true)) return; /* -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 00/28] usb: dwc2: Rework params, checkpatch, and other changes
Hi Felipe, This is a consolidation, rebase, and resend of several dwc2 patch series that were submitted to linux-usb in the past month or so. These should all be applied to testing/next for 4.11. See the following links for the original list messages: https://www.spinics.net/lists/linux-usb/msg151693.html https://www.spinics.net/lists/linux-usb/msg151872.html https://www.spinics.net/lists/linux-usb/msg151929.html https://www.spinics.net/lists/linux-usb/msg151927.html https://www.spinics.net/lists/linux-usb/msg151923.html To apply to your testing/next you need the following changes. This series depends on the dwc2 fixes for 4.10-rc5 in your fixes branch. Remove these from testing/next as they aren't needed any more. This issue is addressed at the end of this series. e0beae49474c ("usb: dwc2: pci: Add AHB burst property for HAPS") 70033c5ec15b ("usb: dwc2: Use the ahb_burst param") 605f91f9f5a6 ("usb: dwc2: Read in the AHB burst property") d067dad79548 ("Documentation: devictree: dwc2: Add AHB burst binding") Remove these from testing/next as they cause conflict and I have added fixed-up versions in this series: d91a6eb219b8 ("usb: dwc2: host: use true/false for boolean") 52e3773e1ff9 ("usb: dwc2: host: use msleep() for long delays") This commit in testing/next is already in fixes: 20c8ab4105b9 ("usb: dwc2: use u32 for DT binding parameters") With those changes you should be able to apply this series cleanly. Regards, John Chen Yu (2): usb: dwc2: Force port resume on switching to device mode usb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220 John Stultz (2): usb: dwc2: Avoid sleeping while holding hsotg->lock usb: dwc2: Workaround case where GOTGCTL state is wrong John Youn (21): usb: dwc2: Cleanup some checkpatch issues usb: dwc2: Add identifier in prototypes usb: dwc2: Fix comment alignment and format usb: dwc2: Fix logical continuations usb: dwc2: Fix brace usage usb: dwc2: Fix lines over 80 characters usb: dwc2: Fix code indentation after conditionals usb: dwc2: Remove 'return' from void function usb: dwc2: Fix sizeof in kzalloc usb: dwc2: Remove unused otg_ver parameter usb: dwc2: Set core parameters to default values usb: dwc2: Get device properties usb: dwc2: Update parameter types usb: dwc2: Rearrange param structure members usb: dwc2: Check core parameters usb: dwc2: Remove platform static params usb: dwc2: Fix usage of bool params usb: dwc2: Remove unnecessary parameters usb: dwc2: Add debugfs file to show params usb: dwc2: Remove debug prints in params.c usb: dwc2: Show dr_mode via debugfs Nicholas Mc Guire (3): usb: dwc2: host: use msleep() for long delay usb: dwc2: host: use true/false for boolean usb: dwc2: host: use msleep() for long delays drivers/usb/dwc2/core.c | 39 +- drivers/usb/dwc2/core.h | 189 +++--- drivers/usb/dwc2/core_intr.c | 11 +- drivers/usb/dwc2/debug.h |4 +- drivers/usb/dwc2/debugfs.c | 182 +- drivers/usb/dwc2/gadget.c| 217 +++ drivers/usb/dwc2/hcd.c | 249 +--- drivers/usb/dwc2/hcd.h | 76 +-- drivers/usb/dwc2/hcd_ddma.c | 23 +- drivers/usb/dwc2/hcd_intr.c | 98 +-- drivers/usb/dwc2/hcd_queue.c | 40 +- drivers/usb/dwc2/hw.h| 596 +- drivers/usb/dwc2/params.c| 1437 ++ drivers/usb/dwc2/pci.c |2 +- drivers/usb/dwc2/platform.c | 14 +- 15 files changed, 1318 insertions(+), 1859 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 05/28] usb: dwc2: Fix brace usage
* Remove braces for one-line statements * Add missing braces where another arm in if-statement uses braces Signed-off-by: John Youn --- drivers/usb/dwc2/gadget.c | 10 -- drivers/usb/dwc2/platform.c | 12 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 2049afb1ffb1..dd839780da35 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1644,9 +1644,8 @@ static int dwc2_hsotg_process_req_feature(struct dwc2_hsotg *hsotg, } /* If we have pending request, then start it */ - if (!ep->req) { + if (!ep->req) dwc2_gadget_start_next_request(ep); - } } break; @@ -1938,9 +1937,8 @@ static void dwc2_hsotg_complete_request(struct dwc2_hsotg *hsotg, * so be careful when doing this. */ - if (!hs_ep->req && result >= 0) { + if (!hs_ep->req && result >= 0) dwc2_gadget_start_next_request(hs_ep); - } } /* @@ -4043,9 +4041,9 @@ static int dwc2_hsotg_ep_sethalt(struct usb_ep *ep, int value, bool now) epreg = DOEPCTL(index); epctl = dwc2_readl(hs->regs + epreg); - if (value) + if (value) { epctl |= DXEPCTL_STALL; - else { + } else { epctl &= ~DXEPCTL_STALL; xfertype = epctl & DXEPCTL_EPTYPE_MASK; if (xfertype == DXEPCTL_EPTYPE_BULK || diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 649d7b9a714b..3f59a73de248 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -136,11 +136,11 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg) return ret; } - if (hsotg->uphy) + if (hsotg->uphy) { ret = usb_phy_init(hsotg->uphy); - else if (hsotg->plat && hsotg->plat->phy_init) + } else if (hsotg->plat && hsotg->plat->phy_init) { ret = hsotg->plat->phy_init(pdev, hsotg->plat->phy_type); - else { + } else { ret = phy_power_on(hsotg->phy); if (ret == 0) ret = phy_init(hsotg->phy); @@ -170,11 +170,11 @@ static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg) struct platform_device *pdev = to_platform_device(hsotg->dev); int ret = 0; - if (hsotg->uphy) + if (hsotg->uphy) { usb_phy_shutdown(hsotg->uphy); - else if (hsotg->plat && hsotg->plat->phy_exit) + } else if (hsotg->plat && hsotg->plat->phy_exit) { ret = hsotg->plat->phy_exit(pdev, hsotg->plat->phy_type); - else { + } else { ret = phy_exit(hsotg->phy); if (ret == 0) ret = phy_power_off(hsotg->phy); -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 02/28] usb: dwc2: Add identifier in prototypes
Fixes checkpatch warning: WARNING: function definition argument 'struct dwc2_hsotg *' should also have an identifier name Signed-off-by: John Youn --- drivers/usb/dwc2/debug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/debug.h b/drivers/usb/dwc2/debug.h index d3e52dd32f57..8222783e6822 100644 --- a/drivers/usb/dwc2/debug.h +++ b/drivers/usb/dwc2/debug.h @@ -17,8 +17,8 @@ #include "core.h" #ifdef CONFIG_DEBUG_FS -int dwc2_debugfs_init(struct dwc2_hsotg *); -void dwc2_debugfs_exit(struct dwc2_hsotg *); +int dwc2_debugfs_init(struct dwc2_hsotg *hsotg); +void dwc2_debugfs_exit(struct dwc2_hsotg *hsotg); #else static inline int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) { return 0; } -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 19/28] usb: dwc2: Add debugfs file to show params
Show the core params and hardware params. Signed-off-by: John Youn --- drivers/usb/dwc2/debugfs.c | 127 + 1 file changed, 127 insertions(+) diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c index cad621f02972..57747b0df595 100644 --- a/drivers/usb/dwc2/debugfs.c +++ b/drivers/usb/dwc2/debugfs.c @@ -725,6 +725,120 @@ static const struct debugfs_reg32 dwc2_regs[] = { dump_register(HCDMAB(15)), }; +#define print_param(_seq, _ptr, _param) \ +seq_printf((_seq), "%-30s: %d\n", #_param, (_ptr)->_param) + +#define print_param_hex(_seq, _ptr, _param) \ +seq_printf((_seq), "%-30s: 0x%x\n", #_param, (_ptr)->_param) + +static int params_show(struct seq_file *seq, void *v) +{ + struct dwc2_hsotg *hsotg = seq->private; + struct dwc2_core_params *p = &hsotg->params; + int i; + + print_param(seq, p, otg_cap); + print_param(seq, p, dma_desc_enable); + print_param(seq, p, dma_desc_fs_enable); + print_param(seq, p, speed); + print_param(seq, p, enable_dynamic_fifo); + print_param(seq, p, en_multiple_tx_fifo); + print_param(seq, p, host_rx_fifo_size); + print_param(seq, p, host_nperio_tx_fifo_size); + print_param(seq, p, host_perio_tx_fifo_size); + print_param(seq, p, max_transfer_size); + print_param(seq, p, max_packet_count); + print_param(seq, p, host_channels); + print_param(seq, p, phy_type); + print_param(seq, p, phy_utmi_width); + print_param(seq, p, phy_ulpi_ddr); + print_param(seq, p, phy_ulpi_ext_vbus); + print_param(seq, p, i2c_enable); + print_param(seq, p, ulpi_fs_ls); + print_param(seq, p, host_support_fs_ls_low_power); + print_param(seq, p, host_ls_low_power_phy_clk); + print_param(seq, p, ts_dline); + print_param(seq, p, reload_ctl); + print_param_hex(seq, p, ahbcfg); + print_param(seq, p, uframe_sched); + print_param(seq, p, external_id_pin_ctl); + print_param(seq, p, hibernation); + print_param(seq, p, host_dma); + print_param(seq, p, g_dma); + print_param(seq, p, g_dma_desc); + print_param(seq, p, g_rx_fifo_size); + print_param(seq, p, g_np_tx_fifo_size); + + for (i = 0; i < MAX_EPS_CHANNELS; i++) { + char str[32]; + + snprintf(str, 32, "g_tx_fifo_size[%d]", i); + seq_printf(seq, "%-30s: %d\n", str, p->g_tx_fifo_size[i]); + } + + return 0; +} + +static int params_open(struct inode *inode, struct file *file) +{ + return single_open(file, params_show, inode->i_private); +} + +static const struct file_operations params_fops = { + .owner = THIS_MODULE, + .open = params_open, + .read = seq_read, + .llseek = seq_lseek, + .release= single_release, +}; + +static int hw_params_show(struct seq_file *seq, void *v) +{ + struct dwc2_hsotg *hsotg = seq->private; + struct dwc2_hw_params *hw = &hsotg->hw_params; + + print_param(seq, hw, op_mode); + print_param(seq, hw, arch); + print_param(seq, hw, dma_desc_enable); + print_param(seq, hw, enable_dynamic_fifo); + print_param(seq, hw, en_multiple_tx_fifo); + print_param(seq, hw, rx_fifo_size); + print_param(seq, hw, host_nperio_tx_fifo_size); + print_param(seq, hw, dev_nperio_tx_fifo_size); + print_param(seq, hw, host_perio_tx_fifo_size); + print_param(seq, hw, nperio_tx_q_depth); + print_param(seq, hw, host_perio_tx_q_depth); + print_param(seq, hw, dev_token_q_depth); + print_param(seq, hw, max_transfer_size); + print_param(seq, hw, max_packet_count); + print_param(seq, hw, host_channels); + print_param(seq, hw, hs_phy_type); + print_param(seq, hw, fs_phy_type); + print_param(seq, hw, i2c_enable); + print_param(seq, hw, num_dev_ep); + print_param(seq, hw, num_dev_perio_in_ep); + print_param(seq, hw, total_fifo_size); + print_param(seq, hw, power_optimized); + print_param(seq, hw, utmi_phy_data_width); + print_param_hex(seq, hw, snpsid); + print_param_hex(seq, hw, dev_ep_dirs); + + return 0; +} + +static int hw_params_open(struct inode *inode, struct file *file) +{ + return single_open(file, hw_params_show, inode->i_private); +} + +static const struct file_operations hw_params_fops = { + .owner = THIS_MODULE, + .open = hw_params_open, + .read = seq_read, + .llseek = seq_lseek, + .release= single_release, +}; + int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) { int ret; @@ -736,6 +850,19 @@ int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) goto err0; } + file = debugfs_create_file("params", 0444, + hsotg->debug_root, +
[PATCH v2 24/28] usb: dwc2: Force port resume on switching to device mode
From: Chen Yu We've seen failures when switching between host and gadget mode, which was diagnosed as being caused due to the bus being auto-suspended when we switched. So this patch forces a port resume when switching to device mode if the bus is suspended. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Vardan Mikayelyan Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: Chen Yu Signed-off-by: John Stultz Signed-off-by: John Youn --- drivers/usb/dwc2/hcd.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 274d64b5355c..abd477c38d89 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -54,6 +54,8 @@ #include "core.h" #include "hcd.h" +static void dwc2_port_resume(struct dwc2_hsotg *hsotg); + /* * = * Host Core Layer Functions @@ -3231,6 +3233,11 @@ static void dwc2_conn_id_status_change(struct work_struct *work) if (gotgctl & GOTGCTL_CONID_B) { /* Wait for switch to device mode */ dev_dbg(hsotg->dev, "connId B\n"); + if (hsotg->bus_suspended) { + dev_info(hsotg->dev, +"Do port resume before switching to device mode\n"); + dwc2_port_resume(hsotg); + } while (!dwc2_is_device_mode(hsotg)) { dev_info(hsotg->dev, "Waiting for Peripheral Mode, Mode=%s\n", -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 25/28] usb: dwc2: Add a quirk to allow speed negotiation for Hisilicon Hi6220
From: Chen Yu The Hi6220's usb controller is limited in that it does not support "Split Transactions", so it does not support communicating with low-speed and full-speed devices behind a high-speed hub. Thus it requires a quirk so that we can manually drop the usb speed when low/full-speed are attached, and bump back to high speed when they are removed. Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Vardan Mikayelyan Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Signed-off-by: Chen Yu [jstultz: Reworked to simplify the patch, and made commit log to be more specific about the issue] Signed-off-by: John Stultz Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 7 ++ drivers/usb/dwc2/hcd.c| 60 +++ drivers/usb/dwc2/params.c | 1 + 3 files changed, 68 insertions(+) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index b07bf7be2034..a473853ca39c 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -444,6 +444,11 @@ enum dwc2_ep0_state { * in DWORDS with possible values from from * 16-32768 (default: 256, 256, 256, 256, 768, * 768, 768, 768, 0, 0, 0, 0, 0, 0, 0). + * @change_speed_quirk: Change speed configuration to DWC2_SPEED_PARAM_FULL + * while full&low speed device connect. And change speed + * back to DWC2_SPEED_PARAM_HIGH while device is gone. + * 0 - No (default) + * 1 - Yes * * The following parameters may be specified when starting the module. These * parameters define how the DWC_otg controller should be configured. A @@ -501,6 +506,8 @@ struct dwc2_core_params { u32 g_rx_fifo_size; u32 g_np_tx_fifo_size; u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; + + bool change_speed_quirk; }; /** diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index abd477c38d89..2617b67dd1df 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4871,6 +4871,61 @@ static void _dwc2_hcd_clear_tt_buffer_complete(struct usb_hcd *hcd, spin_unlock_irqrestore(&hsotg->lock, flags); } +/* + * HPRT0_SPD_HIGH_SPEED: high speed + * HPRT0_SPD_FULL_SPEED: full speed + */ +static void dwc2_change_bus_speed(struct usb_hcd *hcd, int speed) +{ + struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); + + if (hsotg->params.speed == speed) + return; + + hsotg->params.speed = speed; + queue_work(hsotg->wq_otg, &hsotg->wf_otg); +} + +static void dwc2_free_dev(struct usb_hcd *hcd, struct usb_device *udev) +{ + struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); + + if (!hsotg->params.change_speed_quirk) + return; + + /* +* On removal, set speed to default high-speed. +*/ + if (udev->parent && udev->parent->speed > USB_SPEED_UNKNOWN && + udev->parent->speed < USB_SPEED_HIGH) { + dev_info(hsotg->dev, "Set speed to default high-speed\n"); + dwc2_change_bus_speed(hcd, HPRT0_SPD_HIGH_SPEED); + } +} + +static int dwc2_reset_device(struct usb_hcd *hcd, struct usb_device *udev) +{ + struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); + + if (!hsotg->params.change_speed_quirk) + return 0; + + if (udev->speed == USB_SPEED_HIGH) { + dev_info(hsotg->dev, "Set speed to high-speed\n"); + dwc2_change_bus_speed(hcd, HPRT0_SPD_HIGH_SPEED); + } else if ((udev->speed == USB_SPEED_FULL || + udev->speed == USB_SPEED_LOW)) { + /* +* Change speed setting to full-speed if there's +* a full-speed or low-speed device plugged in. +*/ + dev_info(hsotg->dev, "Set speed to full-speed\n"); + dwc2_change_bus_speed(hcd, HPRT0_SPD_FULL_SPEED); + } + + return 0; +} + static struct hc_driver dwc2_hc_driver = { .description = "dwc2_hsotg", .product_desc = "DWC OTG Controller", @@ -5026,6 +5081,11 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) dev_warn(hsotg->dev, "can't set coherent DMA mask\n"); } + if (hsotg->params.change_speed_quirk) { + dwc2_hc_driver.free_dev = dwc2_free_dev; + dwc2_hc_driver.reset_device = dwc2_reset_device; + } + hcd = usb_create_hcd(&dwc2_hc_driver, hsotg->dev, dev_name(hsotg->dev)); if (!hcd) goto error1; diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 620b02723f0d..8e5039e2d3fc 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -68,6 +68,7 @@ static void dwc2_set_his_params(struct dwc2_hsotg *hsotg) p->ahbcfg = GAHBC
[PATCH v2 27/28] usb: dwc2: host: use true/false for boolean
From: Nicholas Mc Guire For boolean variables true/false is preferred over 1/0 for readability. [johnyoun: minor rebase] Signed-off-by: Nicholas Mc Guire Signed-off-by: John Youn --- drivers/usb/dwc2/hcd.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 2617b67dd1df..de24c3e8f5c7 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -2965,7 +2965,7 @@ static void dwc2_process_periodic_channels(struct dwc2_hsotg *hsotg) qspcavail = (tx_status & TXSTS_QSPCAVAIL_MASK) >> TXSTS_QSPCAVAIL_SHIFT; if (qspcavail == 0) { - no_queue_space = 1; + no_queue_space = true; break; } @@ -2994,7 +2994,7 @@ static void dwc2_process_periodic_channels(struct dwc2_hsotg *hsotg) TXSTS_FSPCAVAIL_SHIFT; status = dwc2_queue_transaction(hsotg, qh->channel, fspcavail); if (status < 0) { - no_fifo_space = 1; + no_fifo_space = true; break; } @@ -3308,7 +3308,7 @@ static void dwc2_wakeup_detected(unsigned long data) dwc2_readl(hsotg->regs + HPRT0)); dwc2_hcd_rem_wakeup(hsotg); - hsotg->bus_suspended = 0; + hsotg->bus_suspended = false; /* Change to L0 state */ hsotg->lx_state = DWC2_L0; @@ -3344,7 +3344,7 @@ static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, u16 windex) hprt0 |= HPRT0_SUSP; dwc2_writel(hprt0, hsotg->regs + HPRT0); - hsotg->bus_suspended = 1; + hsotg->bus_suspended = true; /* * If hibernation is supported, Phy clock will be suspended @@ -3406,7 +3406,7 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg) hprt0 = dwc2_read_hprt0(hsotg); hprt0 &= ~(HPRT0_RES | HPRT0_SUSP); dwc2_writel(hprt0, hsotg->regs + HPRT0); - hsotg->bus_suspended = 0; + hsotg->bus_suspended = false; spin_unlock_irqrestore(&hsotg->lock, flags); } -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 20/28] usb: dwc2: Remove debug prints in params.c
Remove debugging prints to show params. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 56 --- 1 file changed, 56 deletions(-) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 0e7f0f92c18f..620b02723f0d 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -513,8 +513,6 @@ static void dwc2_get_host_hwparams(struct dwc2_hsotg *hsotg) gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ); hptxfsiz = dwc2_readl(hsotg->regs + HPTXFSIZ); - dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz); - dev_dbg(hsotg->dev, "hptxfsiz=%08x\n", hptxfsiz); if (forced) dwc2_clear_force_mode(hsotg); @@ -542,7 +540,6 @@ static void dwc2_get_dev_hwparams(struct dwc2_hsotg *hsotg) forced = dwc2_force_mode_if_needed(hsotg, false); gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ); - dev_dbg(hsotg->dev, "gnptxfsiz=%08x\n", gnptxfsiz); if (forced) dwc2_clear_force_mode(hsotg); @@ -588,12 +585,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) hwcfg4 = dwc2_readl(hsotg->regs + GHWCFG4); grxfsiz = dwc2_readl(hsotg->regs + GRXFSIZ); - dev_dbg(hsotg->dev, "hwcfg1=%08x\n", hwcfg1); - dev_dbg(hsotg->dev, "hwcfg2=%08x\n", hwcfg2); - dev_dbg(hsotg->dev, "hwcfg3=%08x\n", hwcfg3); - dev_dbg(hsotg->dev, "hwcfg4=%08x\n", hwcfg4); - dev_dbg(hsotg->dev, "grxfsiz=%08x\n", grxfsiz); - /* * Host specific hardware parameters. Reading these parameters * requires the controller to be in host mode. The mode will @@ -653,53 +644,6 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) hw->rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >> GRXFSIZ_DEPTH_SHIFT; - dev_dbg(hsotg->dev, "Detected values from hardware:\n"); - dev_dbg(hsotg->dev, " op_mode=%d\n", - hw->op_mode); - dev_dbg(hsotg->dev, " arch=%d\n", - hw->arch); - dev_dbg(hsotg->dev, " dma_desc_enable=%d\n", - hw->dma_desc_enable); - dev_dbg(hsotg->dev, " power_optimized=%d\n", - hw->power_optimized); - dev_dbg(hsotg->dev, " i2c_enable=%d\n", - hw->i2c_enable); - dev_dbg(hsotg->dev, " hs_phy_type=%d\n", - hw->hs_phy_type); - dev_dbg(hsotg->dev, " fs_phy_type=%d\n", - hw->fs_phy_type); - dev_dbg(hsotg->dev, " utmi_phy_data_width=%d\n", - hw->utmi_phy_data_width); - dev_dbg(hsotg->dev, " num_dev_ep=%d\n", - hw->num_dev_ep); - dev_dbg(hsotg->dev, " num_dev_perio_in_ep=%d\n", - hw->num_dev_perio_in_ep); - dev_dbg(hsotg->dev, " host_channels=%d\n", - hw->host_channels); - dev_dbg(hsotg->dev, " max_transfer_size=%d\n", - hw->max_transfer_size); - dev_dbg(hsotg->dev, " max_packet_count=%d\n", - hw->max_packet_count); - dev_dbg(hsotg->dev, " nperio_tx_q_depth=0x%0x\n", - hw->nperio_tx_q_depth); - dev_dbg(hsotg->dev, " host_perio_tx_q_depth=0x%0x\n", - hw->host_perio_tx_q_depth); - dev_dbg(hsotg->dev, " dev_token_q_depth=0x%0x\n", - hw->dev_token_q_depth); - dev_dbg(hsotg->dev, " enable_dynamic_fifo=%d\n", - hw->enable_dynamic_fifo); - dev_dbg(hsotg->dev, " en_multiple_tx_fifo=%d\n", - hw->en_multiple_tx_fifo); - dev_dbg(hsotg->dev, " total_fifo_size=%d\n", - hw->total_fifo_size); - dev_dbg(hsotg->dev, " rx_fifo_size=%d\n", - hw->rx_fifo_size); - dev_dbg(hsotg->dev, " host_nperio_tx_fifo_size=%d\n", - hw->host_nperio_tx_fifo_size); - dev_dbg(hsotg->dev, " host_perio_tx_fifo_size=%d\n", - hw->host_perio_tx_fifo_size); - dev_dbg(hsotg->dev, "\n"); - return 0; } -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 23/28] usb: dwc2: Workaround case where GOTGCTL state is wrong
From: John Stultz When removing a USB-A to USB-otg adapter cable, we get a change status irq, and then in dwc2_conn_id_status_change, we erroniously see the GOTGCTL_CONID_B flag set. This causes us to get stuck in the "while (!dwc2_is_device_mode(hsotg))" loop, spitting out "Waiting for Peripheral Mode, Mode=Host" warnings until it fails out many seconds later. This patch works around the issue by re-reading the GOTGCTL state to check if the GOTGCTL_CONID_B is still set and if not restarting the change status logic. I suspect this isn't the best solution, but it seems to work well for me. Feedback would be greatly appreciated! Cc: Wei Xu Cc: Guodong Xu Cc: Amit Pundir Cc: Rob Herring Cc: John Youn Cc: Douglas Anderson Cc: Chen Yu Cc: Vardan Mikayelyan Cc: Kishon Vijay Abraham I Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Reviewed-by: Vardan Mikayelyan Signed-off-by: John Stultz Signed-off-by: John Youn --- drivers/usb/dwc2/hcd.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 2c13a35922e1..274d64b5355c 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -3237,6 +3237,14 @@ static void dwc2_conn_id_status_change(struct work_struct *work) dwc2_is_host_mode(hsotg) ? "Host" : "Peripheral"); usleep_range(2, 4); + /* +* Sometimes the initial GOTGCTRL read is wrong, so +* check it again and jump to host mode if that was +* the case. +*/ + gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); + if (!(gotgctl & GOTGCTL_CONID_B)) + goto host; if (++count > 250) break; } @@ -3251,6 +3259,7 @@ static void dwc2_conn_id_status_change(struct work_struct *work) spin_unlock_irqrestore(&hsotg->lock, flags); dwc2_hsotg_core_connect(hsotg); } else { +host: /* A-Device connector (Host Mode) */ dev_dbg(hsotg->dev, "connId A\n"); while (!dwc2_is_host_mode(hsotg)) { -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 26/28] usb: dwc2: host: use msleep() for long delay
From: Nicholas Mc Guire ulseep_range() uses hrtimers and provides no advantage over msleep() for larger delays. Fix up the 100ms delays here passing the adjusted "min" value to msleep(). This helps reduce the load on the hrtimer subsystem. Link: http://lkml.org/lkml/2017/1/11/377 Fixes: commit 2938fc63e0c2 ("usb: dwc2: Properly account for the force mode delays") Signed-off-by: Nicholas Mc Guire Signed-off-by: John Youn --- drivers/usb/dwc2/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 7195366e26bf..1b6612c2cdda 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -455,7 +455,7 @@ void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg) dwc2_writel(gusbcfg, hsotg->regs + GUSBCFG); if (dwc2_iddig_filter_enabled(hsotg)) - usleep_range(10, 11); + msleep(100); } /* -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 06/28] usb: dwc2: Fix lines over 80 characters
Fix lines over 80 characters. Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 13 + drivers/usb/dwc2/gadget.c | 14 +- drivers/usb/dwc2/hcd.c | 4 ++-- drivers/usb/dwc2/hcd_intr.c | 13 +++-- drivers/usb/dwc2/params.c | 14 +++--- 5 files changed, 34 insertions(+), 24 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index ef67f268d3da..2fdd74d502c0 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -127,6 +127,8 @@ static const char * const dwc2_hsotg_supply_names[] = { "vusb_a", /* analog USB supply, 1.1V */ }; +#define DWC2_NUM_SUPPLIES ARRAY_SIZE(dwc2_hsotg_supply_names) + /* * EP0_MPS_LIMIT * @@ -246,7 +248,8 @@ struct dwc2_hsotg_req { void *saved_req_buf; }; -#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) +#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ + IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) #define call_gadget(_hs, _entry) \ do { \ if ((_hs)->gadget.speed != USB_SPEED_UNKNOWN && \ @@ -922,7 +925,7 @@ struct dwc2_hsotg { struct phy *phy; struct usb_phy *uphy; struct dwc2_hsotg_plat *plat; - struct regulator_bulk_data supplies[ARRAY_SIZE(dwc2_hsotg_supply_names)]; + struct regulator_bulk_data supplies[DWC2_NUM_SUPPLIES]; u32 phyif; spinlock_t lock; @@ -1034,7 +1037,8 @@ struct dwc2_hsotg { #endif #endif /* CONFIG_USB_DWC2_HOST || CONFIG_USB_DWC2_DUAL_ROLE */ -#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) +#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ + IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) /* Gadget structures */ struct usb_gadget_driver *driver; int fifo_mem; @@ -1177,7 +1181,8 @@ void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg); u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg); /* Gadget defines */ -#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) +#if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ + IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg); int dwc2_hsotg_suspend(struct dwc2_hsotg *dwc2); int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2); diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index dd839780da35..09fadc26023f 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -1113,7 +1113,8 @@ static int dwc2_hsotg_map_dma(struct dwc2_hsotg *hsotg, } static int dwc2_hsotg_handle_unaligned_buf_start(struct dwc2_hsotg *hsotg, -struct dwc2_hsotg_ep *hs_ep, struct dwc2_hsotg_req *hs_req) +struct dwc2_hsotg_ep *hs_ep, +struct dwc2_hsotg_req *hs_req) { void *req_buf = hs_req->req.buf; @@ -1143,8 +1144,10 @@ static int dwc2_hsotg_handle_unaligned_buf_start(struct dwc2_hsotg *hsotg, return 0; } -static void dwc2_hsotg_handle_unaligned_buf_complete(struct dwc2_hsotg *hsotg, -struct dwc2_hsotg_ep *hs_ep, struct dwc2_hsotg_req *hs_req) +static void +dwc2_hsotg_handle_unaligned_buf_complete(struct dwc2_hsotg *hsotg, +struct dwc2_hsotg_ep *hs_ep, +struct dwc2_hsotg_req *hs_req) { /* If dma is not being used or buffer was aligned */ if (!using_dma(hsotg) || !hs_req->saved_req_buf) @@ -4441,8 +,9 @@ static int dwc2_hsotg_hw_cfg(struct dwc2_hsotg *hsotg) /* Add ep0 */ hsotg->num_of_eps++; - hsotg->eps_in[0] = devm_kzalloc(hsotg->dev, sizeof(struct dwc2_hsotg_ep), - GFP_KERNEL); + hsotg->eps_in[0] = devm_kzalloc(hsotg->dev, + sizeof(struct dwc2_hsotg_ep), + GFP_KERNEL); if (!hsotg->eps_in[0]) return -ENOMEM; /* Same dwc2_hsotg_ep is used in both directions for ep0 */ diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index fc27c1b97309..96454b121f77 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4236,7 +4236,7 @@ void dwc2_host_complete(struct dwc2_hsotg *hsotg, struct dwc2_qtd *qtd, if (ep) dwc2_free_bus_bandwidth(dwc2_hsotg_to_hcd(hsotg), - dwc2_hcd_get_ep_bandwidth(hsotg, ep), + dwc2_hcd_get_ep_bandwidth(hsotg, ep), urb); } @@ -4685,7 +4685,7 @@ static int _dwc2_hcd_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, if (alloc_bandwidth) { dwc2_allocate_bus_bandwidth(hcd, -
[PATCH v2 28/28] usb: dwc2: host: use msleep() for long delays
From: Nicholas Mc Guire ulseep_range() uses hrtimers and provides no advantage over msleep() for larger delays. Fix up the 20+ ms delays here passing the adjusted "min" value to msleep(). This helps reduce the load on the hrtimer subsystem. [johnyoun: minor rebase] Signed-off-by: Nicholas Mc Guire Signed-off-by: John Youn --- drivers/usb/dwc2/hcd.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index de24c3e8f5c7..6d399485501f 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -2152,7 +2152,7 @@ static int dwc2_hcd_endpoint_disable(struct dwc2_hsotg *hsotg, } spin_unlock_irqrestore(&hsotg->lock, flags); - usleep_range(2, 4); + msleep(20); spin_lock_irqsave(&hsotg->lock, flags); qh = ep->hcpriv; if (!qh) { @@ -3243,7 +3243,7 @@ static void dwc2_conn_id_status_change(struct work_struct *work) "Waiting for Peripheral Mode, Mode=%s\n", dwc2_is_host_mode(hsotg) ? "Host" : "Peripheral"); - usleep_range(2, 4); + msleep(20); /* * Sometimes the initial GOTGCTRL read is wrong, so * check it again and jump to host mode if that was @@ -3273,7 +3273,7 @@ static void dwc2_conn_id_status_change(struct work_struct *work) dev_info(hsotg->dev, "Waiting for Host Mode, Mode=%s\n", dwc2_is_host_mode(hsotg) ? "Host" : "Peripheral"); - usleep_range(2, 4); + msleep(20); if (++count > 250) break; } @@ -3366,7 +3366,7 @@ static void dwc2_port_suspend(struct dwc2_hsotg *hsotg, u16 windex) spin_unlock_irqrestore(&hsotg->lock, flags); - usleep_range(20, 25); + msleep(200); } else { spin_unlock_irqrestore(&hsotg->lock, flags); } @@ -3390,7 +3390,7 @@ static void dwc2_port_resume(struct dwc2_hsotg *hsotg) pcgctl &= ~PCGCTL_STOPPCLK; dwc2_writel(pcgctl, hsotg->regs + PCGCTL); spin_unlock_irqrestore(&hsotg->lock, flags); - usleep_range(2, 4); + msleep(20); spin_lock_irqsave(&hsotg->lock, flags); } @@ -3703,7 +3703,7 @@ static int dwc2_hcd_hub_control(struct dwc2_hsotg *hsotg, u16 typereq, } /* Clear reset bit in 10ms (FS/LS) or 50ms (HS) */ - usleep_range(5, 7); + msleep(50); hprt0 &= ~HPRT0_RST; dwc2_writel(hprt0, hsotg->regs + HPRT0); hsotg->lx_state = DWC2_L0; /* Now back to On state */ -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 21/28] usb: dwc2: Show dr_mode via debugfs
Show the value of dr_mode via a debufs file. Signed-off-by: John Youn --- drivers/usb/dwc2/debugfs.c | 29 + 1 file changed, 29 insertions(+) diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c index 57747b0df595..794b959a7c8c 100644 --- a/drivers/usb/dwc2/debugfs.c +++ b/drivers/usb/dwc2/debugfs.c @@ -839,6 +839,29 @@ static const struct file_operations hw_params_fops = { .release= single_release, }; +static int dr_mode_show(struct seq_file *seq, void *v) +{ + struct dwc2_hsotg *hsotg = seq->private; + const char *dr_mode = ""; + + device_property_read_string(hsotg->dev, "dr_mode", &dr_mode); + seq_printf(seq, "%s\n", dr_mode); + return 0; +} + +static int dr_mode_open(struct inode *inode, struct file *file) +{ + return single_open(file, dr_mode_show, inode->i_private); +} + +static const struct file_operations dr_mode_fops = { + .owner = THIS_MODULE, + .open = dr_mode_open, + .read = seq_read, + .llseek = seq_lseek, + .release= single_release, +}; + int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) { int ret; @@ -863,6 +886,12 @@ int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) dev_err(hsotg->dev, "%s: failed to create hw_params\n", __func__); + file = debugfs_create_file("dr_mode", 0444, + hsotg->debug_root, + hsotg, &dr_mode_fops); + if (IS_ERR(file)) + dev_err(hsotg->dev, "%s: failed to create dr_mode\n", __func__); + /* Add gadget debugfs nodes */ dwc2_hsotg_create_debug(hsotg); -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 18/28] usb: dwc2: Remove unnecessary parameters
Further reduce the set of parameters set by platforms. Many of them are unnecessary as they should be reported by hardware. They should only need to be overridden if there is a problem. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 11 --- 1 file changed, 11 deletions(-) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index b872f6128cc2..0e7f0f92c18f 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -42,19 +42,9 @@ static void dwc2_set_bcm_params(struct dwc2_hsotg *hsotg) { struct dwc2_core_params *p = &hsotg->params; - p->otg_cap = DWC2_CAP_PARAM_HNP_SRP_CAPABLE; - p->speed = DWC2_SPEED_PARAM_HIGH; p->host_rx_fifo_size = 774; - p->host_nperio_tx_fifo_size = 256; - p->host_perio_tx_fifo_size = 512; p->max_transfer_size = 65535; p->max_packet_count = 511; - p->host_channels = 8; - p->phy_type = 1; - p->phy_utmi_width = 8; - p->i2c_enable = false; - p->host_ls_low_power_phy_clk = false; - p->reload_ctl = false; p->ahbcfg = 0x10; p->uframe_sched = false; } @@ -74,7 +64,6 @@ static void dwc2_set_his_params(struct dwc2_hsotg *hsotg) p->phy_type = DWC2_PHY_TYPE_PARAM_UTMI; p->phy_utmi_width = 8; p->i2c_enable = false; - p->host_ls_low_power_phy_clk = false; p->reload_ctl = false; p->ahbcfg = GAHBCFG_HBSTLEN_INCR16 << GAHBCFG_HBSTLEN_SHIFT; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 14/28] usb: dwc2: Rearrange param structure members
Group the members by global, host, and gadget params. Formatting and organizational change only. Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 51 ++--- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index c6f62648ad97..011e88017ce8 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -457,53 +457,48 @@ struct dwc2_core_params { #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE1 #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2 - bool dma_desc_enable; - bool dma_desc_fs_enable; - u8 speed; -#define DWC2_SPEED_PARAM_HIGH 0 -#define DWC2_SPEED_PARAM_FULL 1 -#define DWC2_SPEED_PARAM_LOW 2 - - bool enable_dynamic_fifo; - bool en_multiple_tx_fifo; - u16 host_rx_fifo_size; - u16 host_nperio_tx_fifo_size; - u16 host_perio_tx_fifo_size; - u32 max_transfer_size; - u16 max_packet_count; - u8 host_channels; u8 phy_type; #define DWC2_PHY_TYPE_PARAM_FS 0 #define DWC2_PHY_TYPE_PARAM_UTMI 1 #define DWC2_PHY_TYPE_PARAM_ULPI 2 + u8 speed; +#define DWC2_SPEED_PARAM_HIGH 0 +#define DWC2_SPEED_PARAM_FULL 1 +#define DWC2_SPEED_PARAM_LOW 2 + u8 phy_utmi_width; bool phy_ulpi_ddr; bool phy_ulpi_ext_vbus; -#define DWC2_PHY_ULPI_INTERNAL_VBUS0 -#define DWC2_PHY_ULPI_EXTERNAL_VBUS1 +#define DWC2_PHY_ULPI_INTERNAL_VBUS0 +#define DWC2_PHY_ULPI_EXTERNAL_VBUS1 + bool enable_dynamic_fifo; + bool en_multiple_tx_fifo; bool i2c_enable; bool ulpi_fs_ls; - bool host_support_fs_ls_low_power; - bool host_ls_low_power_phy_clk; -#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0 -#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1 - bool ts_dline; bool reload_ctl; - u32 ahbcfg; bool uframe_sched; bool external_id_pin_ctl; bool hibernation; - - /* -* The following parameters are *only* set via device -* properties and cannot be set directly in this structure. -*/ + u16 max_packet_count; + u32 max_transfer_size; + u32 ahbcfg; /* Host parameters */ bool host_dma; + bool dma_desc_enable; + bool dma_desc_fs_enable; + bool host_support_fs_ls_low_power; + bool host_ls_low_power_phy_clk; +#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0 +#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1 + + u8 host_channels; + u16 host_rx_fifo_size; + u16 host_nperio_tx_fifo_size; + u16 host_perio_tx_fifo_size; /* Gadget parameters */ bool g_dma; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 13/28] usb: dwc2: Update parameter types
Update the param types to appropriately sized ints and bools. Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 52 - 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 7256b9f7097a..c6f62648ad97 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -452,50 +452,50 @@ enum dwc2_ep0_state { * default described above. */ struct dwc2_core_params { - int otg_cap; + u8 otg_cap; #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE 0 #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE1 #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2 - int dma_desc_enable; - int dma_desc_fs_enable; - int speed; + bool dma_desc_enable; + bool dma_desc_fs_enable; + u8 speed; #define DWC2_SPEED_PARAM_HIGH 0 #define DWC2_SPEED_PARAM_FULL 1 #define DWC2_SPEED_PARAM_LOW 2 - int enable_dynamic_fifo; - int en_multiple_tx_fifo; - int host_rx_fifo_size; - int host_nperio_tx_fifo_size; - int host_perio_tx_fifo_size; - int max_transfer_size; - int max_packet_count; - int host_channels; - int phy_type; + bool enable_dynamic_fifo; + bool en_multiple_tx_fifo; + u16 host_rx_fifo_size; + u16 host_nperio_tx_fifo_size; + u16 host_perio_tx_fifo_size; + u32 max_transfer_size; + u16 max_packet_count; + u8 host_channels; + u8 phy_type; #define DWC2_PHY_TYPE_PARAM_FS 0 #define DWC2_PHY_TYPE_PARAM_UTMI 1 #define DWC2_PHY_TYPE_PARAM_ULPI 2 - int phy_utmi_width; - int phy_ulpi_ddr; - int phy_ulpi_ext_vbus; + u8 phy_utmi_width; + bool phy_ulpi_ddr; + bool phy_ulpi_ext_vbus; #define DWC2_PHY_ULPI_INTERNAL_VBUS0 #define DWC2_PHY_ULPI_EXTERNAL_VBUS1 - int i2c_enable; - int ulpi_fs_ls; - int host_support_fs_ls_low_power; - int host_ls_low_power_phy_clk; + bool i2c_enable; + bool ulpi_fs_ls; + bool host_support_fs_ls_low_power; + bool host_ls_low_power_phy_clk; #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0 #define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1 - int ts_dline; - int reload_ctl; - int ahbcfg; - int uframe_sched; - int external_id_pin_ctl; - int hibernation; + bool ts_dline; + bool reload_ctl; + u32 ahbcfg; + bool uframe_sched; + bool external_id_pin_ctl; + bool hibernation; /* * The following parameters are *only* set via device -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 04/28] usb: dwc2: Fix logical continuations
Fix the formatting of logical statements to end the line with the logical operator. Signed-off-by: John Youn --- drivers/usb/dwc2/core_intr.c | 5 ++--- drivers/usb/dwc2/hcd_ddma.c | 8 drivers/usb/dwc2/hcd_queue.c | 5 ++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c index 0d4a25dd..2f161bcf5f83 100644 --- a/drivers/usb/dwc2/core_intr.c +++ b/drivers/usb/dwc2/core_intr.c @@ -159,9 +159,8 @@ static void dwc2_handle_otg_intr(struct dwc2_hsotg *hsotg) " ++OTG Interrupt: Session Request Success Status Change++\n"); gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); if (gotgctl & GOTGCTL_SESREQSCS) { - if (hsotg->params.phy_type == - DWC2_PHY_TYPE_PARAM_FS - && hsotg->params.i2c_enable > 0) { + if (hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS && + hsotg->params.i2c_enable > 0) { hsotg->srp_success = 1; } else { /* Clear Session Request */ diff --git a/drivers/usb/dwc2/hcd_ddma.c b/drivers/usb/dwc2/hcd_ddma.c index db4876c9b5d6..4341f7578caa 100644 --- a/drivers/usb/dwc2/hcd_ddma.c +++ b/drivers/usb/dwc2/hcd_ddma.c @@ -89,8 +89,8 @@ static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh, { struct kmem_cache *desc_cache; - if (qh->ep_type == USB_ENDPOINT_XFER_ISOC - && qh->dev_speed == USB_SPEED_HIGH) + if (qh->ep_type == USB_ENDPOINT_XFER_ISOC && + qh->dev_speed == USB_SPEED_HIGH) desc_cache = hsotg->desc_hsisoc_cache; else desc_cache = hsotg->desc_gen_cache; @@ -123,8 +123,8 @@ static void dwc2_desc_list_free(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh) { struct kmem_cache *desc_cache; - if (qh->ep_type == USB_ENDPOINT_XFER_ISOC - && qh->dev_speed == USB_SPEED_HIGH) + if (qh->ep_type == USB_ENDPOINT_XFER_ISOC && + qh->dev_speed == USB_SPEED_HIGH) desc_cache = hsotg->desc_hsisoc_cache; else desc_cache = hsotg->desc_gen_cache; diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index 06d036f608f1..faf45dfbf652 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c @@ -76,9 +76,8 @@ static int dwc2_periodic_channel_available(struct dwc2_hsotg *hsotg) int num_channels; num_channels = hsotg->params.host_channels; - if (hsotg->periodic_channels + hsotg->non_periodic_channels < - num_channels - && hsotg->periodic_channels < num_channels - 1) { + if ((hsotg->periodic_channels + hsotg->non_periodic_channels < +num_channels) && (hsotg->periodic_channels < num_channels - 1)) { status = 0; } else { dev_dbg(hsotg->dev, -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 16/28] usb: dwc2: Remove platform static params
Remove the platform-specific static param structs and set only those params that are necessary for each platform. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 262 +++--- 1 file changed, 108 insertions(+), 154 deletions(-) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 6ea9d2dafd74..949d988f13cc 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -38,166 +38,111 @@ #include "core.h" -static const struct dwc2_core_params params_hi6220 = { - .otg_cap= 2,/* No HNP/SRP capable */ - .dma_desc_enable= 0, - .dma_desc_fs_enable = 0, - .speed = 0,/* High Speed */ - .enable_dynamic_fifo= 1, - .en_multiple_tx_fifo= 1, - .host_rx_fifo_size = 512, - .host_nperio_tx_fifo_size = 512, - .host_perio_tx_fifo_size= 512, - .max_transfer_size = 65535, - .max_packet_count = 511, - .host_channels = 16, - .phy_type = 1,/* UTMI */ - .phy_utmi_width = 8, - .phy_ulpi_ddr = 0,/* Single */ - .phy_ulpi_ext_vbus = 0, - .i2c_enable = 0, - .ulpi_fs_ls = 0, - .host_support_fs_ls_low_power = 0, - .host_ls_low_power_phy_clk = 0,/* 48 MHz */ - .ts_dline = 0, - .reload_ctl = 0, - .ahbcfg = GAHBCFG_HBSTLEN_INCR16 << - GAHBCFG_HBSTLEN_SHIFT, - .uframe_sched = 0, - .external_id_pin_ctl= -1, - .hibernation= -1, -}; +static void dwc2_set_bcm_params(struct dwc2_hsotg *hsotg) +{ + struct dwc2_core_params *p = &hsotg->params; -static const struct dwc2_core_params params_bcm2835 = { - .otg_cap= 0,/* HNP/SRP capable */ - .dma_desc_enable= 0, - .dma_desc_fs_enable = 0, - .speed = 0,/* High Speed */ - .enable_dynamic_fifo= 1, - .en_multiple_tx_fifo= 1, - .host_rx_fifo_size = 774, /* 774 DWORDs */ - .host_nperio_tx_fifo_size = 256, /* 256 DWORDs */ - .host_perio_tx_fifo_size= 512, /* 512 DWORDs */ - .max_transfer_size = 65535, - .max_packet_count = 511, - .host_channels = 8, - .phy_type = 1,/* UTMI */ - .phy_utmi_width = 8,/* 8 bits */ - .phy_ulpi_ddr = 0,/* Single */ - .phy_ulpi_ext_vbus = 0, - .i2c_enable = 0, - .ulpi_fs_ls = 0, - .host_support_fs_ls_low_power = 0, - .host_ls_low_power_phy_clk = 0,/* 48 MHz */ - .ts_dline = 0, - .reload_ctl = 0, - .ahbcfg = 0x10, - .uframe_sched = 0, - .external_id_pin_ctl= -1, - .hibernation= -1, -}; + p->otg_cap = DWC2_CAP_PARAM_HNP_SRP_CAPABLE; + p->speed = DWC2_SPEED_PARAM_HIGH; + p->host_rx_fifo_size = 774; + p->host_nperio_tx_fifo_size = 256; + p->host_perio_tx_fifo_size = 512; + p->max_transfer_size = 65535; + p->max_packet_count = 511; + p->host_channels = 8; + p->phy_type = 1; + p->phy_utmi_width = 8; + p->i2c_enable = false; + p->host_ls_low_power_phy_clk = 0; + p->reload_ctl = false; + p->ahbcfg = 0x10; + p->uframe_sched = false; +} -static const struct dwc2_core_params params_rk3066 = { - .otg_cap= 2,/* non-HNP/non-SRP */ - .dma_desc_enable= 0, - .dma_desc_fs_enable = 0, - .speed = -1, - .enable_dynamic_fifo= 1, - .en_multiple_tx_fifo= -1, - .host_rx_fifo_size = 525, /* 525 DWORDs */ - .host_nperio_tx_fifo_size = 128, /* 128 DWORDs */ - .host_perio_tx_fifo_size= 256, /* 256 DWORDs */ - .max_transfer_size = -1, - .max_packet_count = -1, - .host_channels = -1, - .phy_type = -1, - .phy_utmi_width = -1, - .phy_ulpi_ddr = -1, - .phy_ulpi_ext_vbus = -1, - .i2c_enable = -1, - .ulpi_fs_ls = -1, - .host_support_fs_ls_low_power = -1,
[PATCH v2 15/28] usb: dwc2: Check core parameters
Check that core parameters have valid values and adjust them if they aren't. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 185 ++ 1 file changed, 185 insertions(+) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 4416eae09647..6ea9d2dafd74 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -377,6 +377,189 @@ static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg) } } +static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg) +{ + int valid = 1; + + switch (hsotg->params.otg_cap) { + case DWC2_CAP_PARAM_HNP_SRP_CAPABLE: + if (hsotg->hw_params.op_mode != GHWCFG2_OP_MODE_HNP_SRP_CAPABLE) + valid = 0; + break; + case DWC2_CAP_PARAM_SRP_ONLY_CAPABLE: + switch (hsotg->hw_params.op_mode) { + case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE: + case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE: + case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE: + case GHWCFG2_OP_MODE_SRP_CAPABLE_HOST: + break; + default: + valid = 0; + break; + } + break; + case DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE: + /* always valid */ + break; + default: + valid = 0; + break; + } + + if (!valid) + dwc2_set_param_otg_cap(hsotg); +} + +static void dwc2_check_param_phy_type(struct dwc2_hsotg *hsotg) +{ + int valid = 0; + u32 hs_phy_type; + u32 fs_phy_type; + + hs_phy_type = hsotg->hw_params.hs_phy_type; + fs_phy_type = hsotg->hw_params.fs_phy_type; + + switch (hsotg->params.phy_type) { + case DWC2_PHY_TYPE_PARAM_FS: + if (fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED) + valid = 1; + break; + case DWC2_PHY_TYPE_PARAM_UTMI: + if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI) || + (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI_ULPI)) + valid = 1; + break; + case DWC2_PHY_TYPE_PARAM_ULPI: + if ((hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI) || + (hs_phy_type == GHWCFG2_HS_PHY_TYPE_UTMI_ULPI)) + valid = 1; + break; + default: + break; + } + + if (!valid) + dwc2_set_param_phy_type(hsotg); +} + +static void dwc2_check_param_speed(struct dwc2_hsotg *hsotg) +{ + int valid = 1; + int phy_type = hsotg->params.phy_type; + int speed = hsotg->params.speed; + + switch (speed) { + case DWC2_SPEED_PARAM_HIGH: + if ((hsotg->params.speed == DWC2_SPEED_PARAM_HIGH) && + (phy_type == DWC2_PHY_TYPE_PARAM_FS)) + valid = 0; + break; + case DWC2_SPEED_PARAM_FULL: + case DWC2_SPEED_PARAM_LOW: + break; + default: + valid = 0; + break; + } + + if (!valid) + dwc2_set_param_speed(hsotg); +} + +static void dwc2_check_param_phy_utmi_width(struct dwc2_hsotg *hsotg) +{ + int valid = 0; + int param = hsotg->params.phy_utmi_width; + int width = hsotg->hw_params.utmi_phy_data_width; + + switch (width) { + case GHWCFG4_UTMI_PHY_DATA_WIDTH_8: + valid = (param == 8); + break; + case GHWCFG4_UTMI_PHY_DATA_WIDTH_16: + valid = (param == 16); + break; + case GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16: + valid = (param == 8 || param == 16); + break; + } + + if (!valid) + dwc2_set_param_phy_utmi_width(hsotg); +} + +#define CHECK_RANGE(_param, _min, _max, _def) do { \ + if ((hsotg->params._param) < (_min) || \ + (hsotg->params._param) > (_max)) { \ + dev_warn(hsotg->dev, "%s: Invalid parameter %s=%d\n", \ +__func__, #_param, hsotg->params._param); \ + hsotg->params._param = (_def); \ + } \ + } while (0) + +#define CHECK_BOOL(_param, _check) do { \ + if (hsotg->params._param && !(_check)) {\ + dev_warn(hsotg->dev, "%s: Invalid parameter %s=%d\n", \ +__func__, #_param, hsotg->params._param); \ + hsotg->params._param = false; \ + } \ + } while (0) + +static void dwc2_check_params(struct dwc2_hso
[PATCH v2 17/28] usb: dwc2: Fix usage of bool params
Check these parameters only for true or false. There is no need to check for greater or less than 0. Signed-off-by: John Youn --- drivers/usb/dwc2/core.c | 4 +- drivers/usb/dwc2/core.h | 5 -- drivers/usb/dwc2/core_intr.c | 2 +- drivers/usb/dwc2/gadget.c| 2 +- drivers/usb/dwc2/hcd.c | 115 +-- drivers/usb/dwc2/hcd_ddma.c | 4 +- drivers/usb/dwc2/hcd_intr.c | 45 + drivers/usb/dwc2/hcd_queue.c | 14 +++--- drivers/usb/dwc2/params.c| 4 +- 9 files changed, 94 insertions(+), 101 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 0d322b7d4b28..c987547a1e7b 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -541,7 +541,7 @@ void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg) addr = hsotg->regs + HAINTMSK; dev_dbg(hsotg->dev, "HAINTMSK@0x%08lX : 0x%08X\n", (unsigned long)addr, dwc2_readl(addr)); - if (hsotg->params.dma_desc_enable > 0) { + if (hsotg->params.dma_desc_enable) { addr = hsotg->regs + HFLBADDR; dev_dbg(hsotg->dev, "HFLBADDR @0x%08lX : 0x%08X\n", (unsigned long)addr, dwc2_readl(addr)); @@ -571,7 +571,7 @@ void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg) addr = hsotg->regs + HCDMA(i); dev_dbg(hsotg->dev, "HCDMA @0x%08lX : 0x%08X\n", (unsigned long)addr, dwc2_readl(addr)); - if (hsotg->params.dma_desc_enable > 0) { + if (hsotg->params.dma_desc_enable) { addr = hsotg->regs + HCDMAB(i); dev_dbg(hsotg->dev, "HCDMAB @0x%08lX : 0x%08X\n", (unsigned long)addr, dwc2_readl(addr)); diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 011e88017ce8..2bd3ea624cfc 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -470,9 +470,6 @@ struct dwc2_core_params { u8 phy_utmi_width; bool phy_ulpi_ddr; bool phy_ulpi_ext_vbus; -#define DWC2_PHY_ULPI_INTERNAL_VBUS0 -#define DWC2_PHY_ULPI_EXTERNAL_VBUS1 - bool enable_dynamic_fifo; bool en_multiple_tx_fifo; bool i2c_enable; @@ -492,8 +489,6 @@ struct dwc2_core_params { bool dma_desc_fs_enable; bool host_support_fs_ls_low_power; bool host_ls_low_power_phy_clk; -#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_48MHZ 0 -#define DWC2_HOST_LS_LOW_POWER_PHY_CLK_PARAM_6MHZ 1 u8 host_channels; u16 host_rx_fifo_size; diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c index 2f161bcf5f83..b8bcb007c92a 100644 --- a/drivers/usb/dwc2/core_intr.c +++ b/drivers/usb/dwc2/core_intr.c @@ -160,7 +160,7 @@ static void dwc2_handle_otg_intr(struct dwc2_hsotg *hsotg) gotgctl = dwc2_readl(hsotg->regs + GOTGCTL); if (gotgctl & GOTGCTL_SESREQSCS) { if (hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM_FS && - hsotg->params.i2c_enable > 0) { + hsotg->params.i2c_enable) { hsotg->srp_success = 1; } else { /* Clear Session Request */ diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index b457522c20f8..ce5a1fb3a8ef 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3224,7 +3224,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, if (!using_desc_dma(hsotg)) intmsk |= GINTSTS_INCOMPL_SOIN | GINTSTS_INCOMPL_SOOUT; - if (hsotg->params.external_id_pin_ctl <= 0) + if (!hsotg->params.external_id_pin_ctl) intmsk |= GINTSTS_CONIDSTSCHNG; dwc2_writel(intmsk, hsotg->regs + GINTMSK); diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index efd2c733695c..2c13a35922e1 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -79,9 +79,9 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg *hsotg) /* Enable the interrupts in the GINTMSK */ intmsk = GINTSTS_MODEMIS | GINTSTS_OTGINT; - if (hsotg->params.host_dma <= 0) + if (!hsotg->params.host_dma) intmsk |= GINTSTS_RXFLVL; - if (hsotg->params.external_id_pin_ctl <= 0) + if (!hsotg->params.external_id_pin_ctl) intmsk |= GINTSTS_CONIDSTSCHNG; intmsk |= GINTSTS_WKUPINT | GINTSTS_USBSUSP | @@ -100,7 +100,7 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg) if ((hsotg->hw_params.hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI && hsotg->hw_params.fs_phy_type == GHWCFG2_FS_PHY_TYPE_DEDICATED && -hsotg->params.ulpi_fs_ls > 0) || +hsotg->params.ulpi_fs_ls) || hsotg->params.phy_type == DWC2_PHY_TYPE_PARAM
[PATCH v2 01/28] usb: dwc2: Cleanup some checkpatch issues
This commmit is the result of running checkpatch --fix. The results were verified for correctness. Some of the fixes result in line over 80 char which we will fix manually later. The following is a summary of what was done by checkpatch: * Remove externs on function prototypes. * Replace symbolic permissions with octal. * Align code to open parens. * Replace 'unsigned' with 'unsigned int'. * Remove unneccessary blank lines. * Add blank lines after declarations. * Add spaces around operators. * Remove unnecessary spaces after casts. * Replace 'x == NULL' with '!x'. * Replace kzalloc() with kcalloc(). * Concatenate multi-line strings. * Use the BIT() macro. Signed-off-by: John Youn --- drivers/usb/dwc2/core.c | 22 +- drivers/usb/dwc2/core.h | 69 ++--- drivers/usb/dwc2/core_intr.c | 6 +- drivers/usb/dwc2/debug.h | 4 +- drivers/usb/dwc2/debugfs.c | 26 +- drivers/usb/dwc2/gadget.c| 142 +-- drivers/usb/dwc2/hcd.c | 35 ++- drivers/usb/dwc2/hcd.h | 76 +++--- drivers/usb/dwc2/hcd_ddma.c | 11 +- drivers/usb/dwc2/hcd_intr.c | 23 +- drivers/usb/dwc2/hcd_queue.c | 20 +- drivers/usb/dwc2/hw.h| 596 +-- drivers/usb/dwc2/params.c| 14 +- drivers/usb/dwc2/pci.c | 2 +- drivers/usb/dwc2/platform.c | 2 +- 15 files changed, 521 insertions(+), 527 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 11d8ae9aead1..0446f3d6d54a 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -104,7 +104,7 @@ static int dwc2_restore_global_registers(struct dwc2_hsotg *hsotg) gr = &hsotg->gr_backup; if (!gr->valid) { dev_err(hsotg->dev, "%s: no global registers to restore\n", - __func__); + __func__); return -EINVAL; } gr->valid = false; @@ -155,21 +155,21 @@ int dwc2_exit_hibernation(struct dwc2_hsotg *hsotg, bool restore) ret = dwc2_restore_global_registers(hsotg); if (ret) { dev_err(hsotg->dev, "%s: failed to restore registers\n", - __func__); + __func__); return ret; } if (dwc2_is_host_mode(hsotg)) { ret = dwc2_restore_host_registers(hsotg); if (ret) { dev_err(hsotg->dev, "%s: failed to restore host registers\n", - __func__); + __func__); return ret; } } else { ret = dwc2_restore_device_registers(hsotg); if (ret) { dev_err(hsotg->dev, "%s: failed to restore device registers\n", - __func__); + __func__); return ret; } } @@ -195,7 +195,7 @@ int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg) ret = dwc2_backup_global_registers(hsotg); if (ret) { dev_err(hsotg->dev, "%s: failed to backup global registers\n", - __func__); + __func__); return ret; } @@ -203,14 +203,14 @@ int dwc2_enter_hibernation(struct dwc2_hsotg *hsotg) ret = dwc2_backup_host_registers(hsotg); if (ret) { dev_err(hsotg->dev, "%s: failed to backup host registers\n", - __func__); + __func__); return ret; } } else { ret = dwc2_backup_device_registers(hsotg); if (ret) { dev_err(hsotg->dev, "%s: failed to backup device registers\n", - __func__); + __func__); return ret; } } @@ -793,7 +793,7 @@ void dwc2_disable_global_interrupts(struct dwc2_hsotg *hsotg) } /* Returns the controller's GHWCFG2.OTG_MODE. */ -unsigned dwc2_op_mode(struct dwc2_hsotg *hsotg) +unsigned int dwc2_op_mode(struct dwc2_hsotg *hsotg) { u32 ghwcfg2 = dwc2_readl(hsotg->regs + GHWCFG2); @@ -804,7 +804,7 @@ unsigned dwc2_op_mode(struct dwc2_hsotg *hsotg) /* Returns true if the controller is capable of DRD. */ bool dwc2_hw_is_otg(struct dwc2_hsotg *hsotg) { - unsigned op_mode = dwc2_op_mode(hsotg); + unsigned int op_mode = dwc2_op_mode(hsotg); return (op_mode == GHWCFG2_OP_MODE_HNP_SRP_CAPABLE) || (op_mode == GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE) || @@ -814,7 +814,7 @@ bool dwc2_
[PATCH v2 03/28] usb: dwc2: Fix comment alignment and format
Fix misaligned and over 80-character comments. Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 19 ++- drivers/usb/dwc2/gadget.c | 43 +++ drivers/usb/dwc2/hcd.c | 2 +- drivers/usb/dwc2/hcd_intr.c | 37 + 4 files changed, 55 insertions(+), 46 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index ddc4654e0096..ef67f268d3da 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -603,8 +603,8 @@ struct dwc2_hw_params { #define DWC2_CTRL_BUFF_SIZE 8 /** - * struct dwc2_gregs_backup - Holds global registers state before entering partial - * power down + * struct dwc2_gregs_backup - Holds global registers state before + * entering partial power down * @gotgctl: Backup of GOTGCTL register * @gintmsk: Backup of GINTMSK register * @gahbcfg: Backup of GAHBCFG register @@ -634,8 +634,8 @@ struct dwc2_gregs_backup { }; /** - * struct dwc2_dregs_backup - Holds device registers state before entering partial - * power down + * struct dwc2_dregs_backup - Holds device registers state before + * entering partial power down * @dcfg: Backup of DCFG register * @dctl: Backup of DCTL register * @daintmsk: Backup of DAINTMSK register @@ -664,8 +664,8 @@ struct dwc2_dregs_backup { }; /** - * struct dwc2_hregs_backup - Holds host registers state before entering partial - * power down + * struct dwc2_hregs_backup - Holds host registers state before + * entering partial power down * @hcfg: Backup of HCFG register * @haintmsk: Backup of HAINTMSK register * @hcintmsk: Backup of HCINTMSK register @@ -782,9 +782,10 @@ struct dwc2_hregs_backup { * @gadget_enabled Peripheral mode sub-driver initialization indicator. * @ll_hw_enabled Status of low-level hardware resources. * @phy:The otg phy transceiver structure for phy control. - * @uphy: The otg phy transceiver structure for old USB phy control. - * @plat: The platform specific configuration data. This can be removed once - * all SoCs support usb transceiver. + * @uphy: The otg phy transceiver structure for old USB phy + * control. + * @plat: The platform specific configuration data. This can be + * removed once all SoCs support usb transceiver. * @supplies: Definition of USB power supplies * @phyif: PHY interface width * @lock: Spinlock that protects all the driver data structures diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index f54a8e7754a4..2049afb1ffb1 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -581,11 +581,11 @@ static unsigned int get_ep_limit(struct dwc2_hsotg_ep *hs_ep) } /** -* dwc2_hsotg_read_frameno - read current frame number -* @hsotg: The device instance -* -* Return the current frame number -*/ + * dwc2_hsotg_read_frameno - read current frame number + * @hsotg: The device instance + * + * Return the current frame number + */ static u32 dwc2_hsotg_read_frameno(struct dwc2_hsotg *hsotg) { u32 dsts; @@ -1467,8 +1467,11 @@ static int dwc2_hsotg_process_req_status(struct dwc2_hsotg *hsotg, switch (ctrl->bRequestType & USB_RECIP_MASK) { case USB_RECIP_DEVICE: - reply = cpu_to_le16(0); /* bit 0 => self powered, -* bit 1 => remote wakeup */ + /* +* bit 0 => self powered +* bit 1 => remote wakeup +*/ + reply = cpu_to_le16(0); break; case USB_RECIP_INTERFACE: @@ -2750,19 +2753,19 @@ static void dwc2_gadget_handle_out_token_ep_disabled(struct dwc2_hsotg_ep *ep) } /** -* dwc2_gadget_handle_nak - handle NAK interrupt -* @hs_ep: The endpoint on which interrupt is asserted. -* -* This is starting point for ISOC-IN transfer, synchronization done with -* first IN token received from host while corresponding EP is disabled. -* -* Device does not know when first one token will arrive from host. On first -* token arrival HW generates 2 interrupts: 'in token received while FIFO empty' -* and 'NAK'. NAK interrupt for ISOC-IN means that token has arrived and ZLP was -* sent in response to that as there was no data in FIFO. SW is basing on this -* interrupt to obtain frame in which token has come and then based on the -* interval calculates next frame for transfer. -*/ + * dwc2_gadget_handle_nak - handle NAK interrupt + * @hs_ep: The endpoint on which interrupt is asserted. + * + * This is starting point for ISOC-IN transfer, synchronization done with + * first IN token received from host while corresponding EP is disabled. + * + * Device does not know when first one token wil
[PATCH v2 12/28] usb: dwc2: Get device properties
After setting the default core parameter values, read in the device properties and modify core parameter values if needed. Signed-off-by: John Youn --- drivers/usb/dwc2/params.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 6729f14d25de..4416eae09647 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -343,6 +343,40 @@ static void dwc2_set_default_params(struct dwc2_hsotg *hsotg) } } +/** + * dwc2_get_device_properties() - Read in device properties. + * + * Read in the device properties and adjust core parameters if needed. + */ +static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg) +{ + struct dwc2_core_params *p = &hsotg->params; + int num; + + if ((hsotg->dr_mode == USB_DR_MODE_PERIPHERAL) || + (hsotg->dr_mode == USB_DR_MODE_OTG)) { + device_property_read_u32(hsotg->dev, "g-rx-fifo-size", +&p->g_rx_fifo_size); + + device_property_read_u32(hsotg->dev, "g-np-tx-fifo-size", +&p->g_np_tx_fifo_size); + + num = device_property_read_u32_array(hsotg->dev, +"g-tx-fifo-size", +NULL, 0); + + if (num > 0) { + num = min(num, 15); + memset(p->g_tx_fifo_size, 0, + sizeof(p->g_tx_fifo_size)); + device_property_read_u32_array(hsotg->dev, + "g-tx-fifo-size", + &p->g_tx_fifo_size[1], + num); + } + } +} + /* * Gets host hardware parameters. Forces host mode if not currently in * host mode. Should be called immediately after a core soft reset in @@ -555,6 +589,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) int dwc2_init_params(struct dwc2_hsotg *hsotg) { dwc2_set_default_params(hsotg); + dwc2_get_device_properties(hsotg); return 0; } -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 10/28] usb: dwc2: Remove unused otg_ver parameter
The otg_ver parameter only controls the SRP pulsing method and defaults to the 1.3 behavior. It is unused and can be removed. Signed-off-by: John Youn --- drivers/usb/dwc2/core.c | 5 - drivers/usb/dwc2/core.h | 9 - drivers/usb/dwc2/hcd.c| 3 --- drivers/usb/dwc2/params.c | 23 --- 4 files changed, 40 deletions(-) diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c index 0446f3d6d54a..0d322b7d4b28 100644 --- a/drivers/usb/dwc2/core.c +++ b/drivers/usb/dwc2/core.c @@ -751,11 +751,6 @@ bool dwc2_force_mode_if_needed(struct dwc2_hsotg *hsotg, bool host) return dwc2_force_mode(hsotg, host); } -u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg) -{ - return hsotg->params.otg_ver == 1 ? 0x0200 : 0x0103; -} - bool dwc2_is_controller_alive(struct dwc2_hsotg *hsotg) { if (dwc2_readl(hsotg->regs + GSNPSID) == 0x) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 2fdd74d502c0..73514f263e40 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -298,9 +298,6 @@ enum dwc2_ep0_state { * 1 - SRP Only capable * 2 - No HNP/SRP capable (always available) * Defaults to best available option (0, 1, then 2) - * @otg_ver:OTG version supported - * 0 - 1.3 (default) - * 1 - 2.0 * @host_dma: Specifies whether to use slave or DMA mode for accessing * the data FIFOs. The driver will automatically detect the * value for this parameter if none is specified. @@ -464,7 +461,6 @@ struct dwc2_core_params { #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE1 #define DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE 2 - int otg_ver; int dma_desc_enable; int dma_desc_fs_enable; int speed; @@ -1175,11 +1171,6 @@ void dwc2_dump_dev_registers(struct dwc2_hsotg *hsotg); void dwc2_dump_host_registers(struct dwc2_hsotg *hsotg); void dwc2_dump_global_registers(struct dwc2_hsotg *hsotg); -/* - * Return OTG version - either 1.3 or 2.0 - */ -u16 dwc2_get_otg_version(struct dwc2_hsotg *hsotg); - /* Gadget defines */ #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 96454b121f77..efd2c733695c 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -2260,10 +2260,7 @@ static int dwc2_core_init(struct dwc2_hsotg *hsotg, bool initial_setup) /* Program the GOTGCTL register */ otgctl = dwc2_readl(hsotg->regs + GOTGCTL); otgctl &= ~GOTGCTL_OTGVER; - if (hsotg->params.otg_ver > 0) - otgctl |= GOTGCTL_OTGVER; dwc2_writel(otgctl, hsotg->regs + GOTGCTL); - dev_dbg(hsotg->dev, "OTG VER PARAM: %d\n", hsotg->params.otg_ver); /* Clear the SRP success bit for FS-I2c */ hsotg->srp_success = 0; diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index bcd1e19b4076..074f4061206a 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -40,7 +40,6 @@ static const struct dwc2_core_params params_hi6220 = { .otg_cap= 2,/* No HNP/SRP capable */ - .otg_ver= 0,/* 1.3 */ .dma_desc_enable= 0, .dma_desc_fs_enable = 0, .speed = 0,/* High Speed */ @@ -71,7 +70,6 @@ static const struct dwc2_core_params params_hi6220 = { static const struct dwc2_core_params params_bcm2835 = { .otg_cap= 0,/* HNP/SRP capable */ - .otg_ver= 0,/* 1.3 */ .dma_desc_enable= 0, .dma_desc_fs_enable = 0, .speed = 0,/* High Speed */ @@ -101,7 +99,6 @@ static const struct dwc2_core_params params_bcm2835 = { static const struct dwc2_core_params params_rk3066 = { .otg_cap= 2,/* non-HNP/non-SRP */ - .otg_ver= -1, .dma_desc_enable= 0, .dma_desc_fs_enable = 0, .speed = -1, @@ -132,7 +129,6 @@ static const struct dwc2_core_params params_rk3066 = { static const struct dwc2_core_params params_ltq = { .otg_cap= 2,/* non-HNP/non-SRP */ - .otg_ver= -1, .dma_desc_enable= -1, .dma_desc_fs_enable = -1, .speed = -1, @@ -163,7 +159,6 @@ static const struct dwc2_core_params params_ltq = { static const struct dwc2_core_params params_amlogic = { .otg_cap= DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE, - .otg_ver= -1,
[PATCH v2 08/28] usb: dwc2: Remove 'return' from void function
The function returns void so a return is unnecessary. Signed-off-by: John Youn --- drivers/usb/dwc2/hcd_queue.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/dwc2/hcd_queue.c b/drivers/usb/dwc2/hcd_queue.c index faf45dfbf652..b1fc9fed6ebe 100644 --- a/drivers/usb/dwc2/hcd_queue.c +++ b/drivers/usb/dwc2/hcd_queue.c @@ -556,7 +556,6 @@ static void dwc2_qh_schedule_print(struct dwc2_hsotg *hsotg, DWC2_HS_SCHEDULE_UFRAMES, "uFrame", "us", dwc2_qh_print, &print_data); } - return; } #else static inline void dwc2_qh_schedule_print(struct dwc2_hsotg *hsotg, -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 11/28] usb: dwc2: Set core parameters to default values
Initialize the core parameters to their default, auto-detected values. Remove all the previous dwc2_set_param* methods. Most of what this code is doing is handling defaults for "not set" values and other trivial checks. The checking can be simplified and will be done in a later commit. This allows us to change only those parameters that won't work with default settings. It also allows us to use non-int parameters. Signed-off-by: John Youn --- drivers/usb/dwc2/core.h | 4 - drivers/usb/dwc2/params.c | 990 -- 2 files changed, 75 insertions(+), 919 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 73514f263e40..7256b9f7097a 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -452,10 +452,6 @@ enum dwc2_ep0_state { * default described above. */ struct dwc2_core_params { - /* -* Don't add any non-int members here, this will break -* dwc2_set_all_params! -*/ int otg_cap; #define DWC2_CAP_PARAM_HNP_SRP_CAPABLE 0 #define DWC2_CAP_PARAM_SRP_ONLY_CAPABLE1 diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 074f4061206a..6729f14d25de 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -187,42 +187,6 @@ static const struct dwc2_core_params params_amlogic = { .hibernation= -1, }; -static const struct dwc2_core_params params_default = { - .otg_cap= -1, - - /* -* Disable descriptor dma mode by default as the HW can support -* it, but does not support it for SPLIT transactions. -* Disable it for FS devices as well. -*/ - .dma_desc_enable= 0, - .dma_desc_fs_enable = 0, - - .speed = -1, - .enable_dynamic_fifo= -1, - .en_multiple_tx_fifo= -1, - .host_rx_fifo_size = -1, - .host_nperio_tx_fifo_size = -1, - .host_perio_tx_fifo_size= -1, - .max_transfer_size = -1, - .max_packet_count = -1, - .host_channels = -1, - .phy_type = -1, - .phy_utmi_width = -1, - .phy_ulpi_ddr = -1, - .phy_ulpi_ext_vbus = -1, - .i2c_enable = -1, - .ulpi_fs_ls = -1, - .host_support_fs_ls_low_power = -1, - .host_ls_low_power_phy_clk = -1, - .ts_dline = -1, - .reload_ctl = -1, - .ahbcfg = -1, - .uframe_sched = -1, - .external_id_pin_ctl= -1, - .hibernation= -1, -}; - const struct of_device_id dwc2_of_match_table[] = { { .compatible = "brcm,bcm2835-usb", .data = ¶ms_bcm2835 }, { .compatible = "hisilicon,hi6220-usb", .data = ¶ms_hi6220 }, @@ -238,913 +202,131 @@ const struct of_device_id dwc2_of_match_table[] = { }; MODULE_DEVICE_TABLE(of, dwc2_of_match_table); -static void dwc2_get_device_property(struct dwc2_hsotg *hsotg, -char *property, u8 size, u64 *value) +static void dwc2_set_param_otg_cap(struct dwc2_hsotg *hsotg) { - u32 val32; + u8 val; - switch (size) { - case 0: - *value = device_property_read_bool(hsotg->dev, property); + switch (hsotg->hw_params.op_mode) { + case GHWCFG2_OP_MODE_HNP_SRP_CAPABLE: + val = DWC2_CAP_PARAM_HNP_SRP_CAPABLE; break; - case 1: - case 2: - case 4: - if (device_property_read_u32(hsotg->dev, property, &val32)) - return; - - *value = val32; - break; - case 8: - if (device_property_read_u64(hsotg->dev, property, value)) - return; - + case GHWCFG2_OP_MODE_SRP_ONLY_CAPABLE: + case GHWCFG2_OP_MODE_SRP_CAPABLE_DEVICE: + case GHWCFG2_OP_MODE_SRP_CAPABLE_HOST: + val = DWC2_CAP_PARAM_SRP_ONLY_CAPABLE; break; default: - /* -* The size is checked by the only function that calls -* this so this should never happen. -*/ - WARN_ON(1); - return; - } -} - -static void dwc2_set_core_param(void *param, u8 size, u64 value) -{ - switch (size) { - case 0: - *((bool *)param) = !!value; - break; - case 1: - *((u8 *)param) = (u8)value; - break; - case 2: - *((u16 *)param) = (u16)value; - break; - case 4: - *((u32 *)param) = (u32)value; - break; - case 8: -
[PATCH v2 07/28] usb: dwc2: Fix code indentation after conditionals
The indent should be only one tab. Signed-off-by: John Youn --- drivers/usb/dwc2/gadget.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 09fadc26023f..559c01e591dc 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3603,7 +3603,7 @@ static irqreturn_t dwc2_hsotg_irq(int irq, void *pw) */ if (gintsts & IRQ_RETRY_MASK && --retry_count > 0) - goto irq_retry; + goto irq_retry; spin_unlock(&hsotg->lock); @@ -4037,7 +4037,7 @@ static int dwc2_hsotg_ep_sethalt(struct usb_ep *ep, int value, bool now) xfertype = epctl & DXEPCTL_EPTYPE_MASK; if (xfertype == DXEPCTL_EPTYPE_BULK || xfertype == DXEPCTL_EPTYPE_INTERRUPT) - epctl |= DXEPCTL_SETD0PID; + epctl |= DXEPCTL_SETD0PID; } dwc2_writel(epctl, hs->regs + epreg); } else { @@ -4051,7 +4051,7 @@ static int dwc2_hsotg_ep_sethalt(struct usb_ep *ep, int value, bool now) xfertype = epctl & DXEPCTL_EPTYPE_MASK; if (xfertype == DXEPCTL_EPTYPE_BULK || xfertype == DXEPCTL_EPTYPE_INTERRUPT) - epctl |= DXEPCTL_SETD0PID; + epctl |= DXEPCTL_SETD0PID; } dwc2_writel(epctl, hs->regs + epreg); } -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 09/28] usb: dwc2: Fix sizeof in kzalloc
Take the sizeof '*req' instead of 'struct dwc2_hsotg_req'. Signed-off-by: John Youn --- drivers/usb/dwc2/gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 559c01e591dc..b457522c20f8 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -281,7 +281,7 @@ static struct usb_request *dwc2_hsotg_ep_alloc_request(struct usb_ep *ep, { struct dwc2_hsotg_req *req; - req = kzalloc(sizeof(struct dwc2_hsotg_req), flags); + req = kzalloc(sizeof(*req), flags); if (!req) return NULL; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc2: fix "iomem 0x00000000" message by setting iomem parameters in usb_hcd
On 1/17/2017 12:13 AM, Felipe Balbi wrote: > > Hi, > > Heiner Kallweit writes: >> Am 16.01.2017 um 15:05 schrieb Felipe Balbi: >>> >>> Hi, >>> >>> Heiner Kallweit writes: Set the iomem parameters in the usb_hcd to fix this misleading message during driver load: dwc2 c910.usb: irq 22, io mem 0x Signed-off-by: Heiner Kallweit --- drivers/usb/dwc2/core.h | 3 ++- drivers/usb/dwc2/hcd.c | 5 - drivers/usb/dwc2/hcd.h | 3 ++- drivers/usb/dwc2/platform.c | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 9548d3e0..b66eaeea 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -1229,7 +1229,8 @@ static inline void dwc2_hcd_connect(struct dwc2_hsotg *hsotg) {} static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force) {} static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {} static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {} -static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) +static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, + struct resource *res) { return 0; } static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) { return 0; } diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 911c3b36..2cfbd10e 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4964,7 +4964,7 @@ static void dwc2_hcd_release(struct dwc2_hsotg *hsotg) * USB bus with the core and calls the hc_driver->start() function. It returns * a negative error on failure. */ -int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) +int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, struct resource *res) { struct usb_hcd *hcd; struct dwc2_host_chan *channel; @@ -5021,6 +5021,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) hcd->has_tt = 1; + hcd->rsrc_start = res->start; + hcd->rsrc_len = resource_size(res); + ((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg; hsotg->priv = hcd; diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h index 1ed5fa2b..2305b5fb 100644 --- a/drivers/usb/dwc2/hcd.h +++ b/drivers/usb/dwc2/hcd.h @@ -521,7 +521,8 @@ static inline u8 dwc2_hcd_is_pipe_out(struct dwc2_hcd_pipe_info *pipe) return !dwc2_hcd_is_pipe_in(pipe); } -extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq); +extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, + struct resource *res); extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg); /* Transaction Execution Functions */ diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 4fc8c603..5ddc8860 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -445,7 +445,7 @@ static int dwc2_driver_probe(struct platform_device *dev) } if (hsotg->dr_mode != USB_DR_MODE_PERIPHERAL) { - retval = dwc2_hcd_init(hsotg, hsotg->irq); + retval = dwc2_hcd_init(hsotg, hsotg->irq, res); >>> >>> This is a good idea, but there's more work that can come out of this, if >>> you're interested: >>> >>> i) devm_ioremap_resource() could be called by the generic layer >>> ii) devm_request_irq() could be move to the generic layer >>> iii) dwc2_hcd_init() could also be called generically as long as dr_mode >>> is set properly. >>> iv) dwc2_debugfs_init() could be called generically as well >>> >>> IOW, dwc2_driver_probe() could be as minimal as: >>> >>> static int dwc2_driver_probe(struct platform_device *dev) >>> { >>> struct dwc2_hsotg *hsotg; >>> struct resource *res; >>> int retval; >>> >>> hsotg = devm_kzalloc(&dev->dev, sizeof(*hsotg), GFP_KERNEL); >>> if (!hsotg) >>> return -ENOMEM; >>> >>> hsotg->dev = &dev->dev; >>> >>> if (!dev->dev.dma_mask) >>> dev->dev.dma_mask = &dev->dev.coherent_dma_mask; >>> >>> retval = dma_set_coherent_mask(&dev->dev, DMA_BIT_MASK(32)); >>> if (retval) >>> return retval; >>> >>> hsotg->res = platform_get_resource(dev, IORESOURCE_MEM, 0); >>> hsotg->irq = platform_get_irq(dev, 0); >>> >>> retval = dwc2_get_dr_mode(hsotg); >>> if (retval) >>> return retval; >>> >>> retval = dwc2_get_hwparams(hsotg); >>> if (retval) >>> return retval; >>> >>> platform_set_drvdata(dev, hsotg); >>> >>> retval = dwc2_core_init(hsotg); >>> if (retval) >>> return retval; >>> >>> return 0; >>> } >>> >>> dwc2_core_init() needs to implemented, of course, but it could h
Re: [PATCH v2] usb: core: update comments for send message functions
I just want to send v2 patch with new mail thread with subject [PATCH v2] not reply I don't understand why v2 patch mail is followed previous mail thread. --no-chain-reply-to : fail ( this is wrong option for in this case) --subject-prefix "PATCH v2" : fail.. why? This is what I did for send patch file. git send-email --to st...@rowland.harvard.edu --to gre...@linuxfoundation.org --cc linux-usb@vger.kernel.org --subject-prefix "PATCH v2" --annotate v2-0001-usb-core-update-comments-for-send-message-functio.patch Please, anybody help me to send patch with new mail thread with subject [PATCH v#] I am really sorry for noisy mail thread. Thanks jaejoong 2017-01-18 12:05 GMT+09:00 Jaejoong Kim : > The commonly use of bottom halves are tasklet and workqueue. The big > difference between tasklet and workqueue is that the tasklet runs in > an interrupt context and the workqueue runs in a process context, > which means it can sleep if need be. > > The comment for usb_control/interrupt/bulk_msg() functions note that do > not use this function within an interrupt context, like a 'bottom half' > handler. With this comment, it makes confuse about usage of these > functions. > > To more clarify, remove 'bottom half' comment. > > Signed-off-by: Jaejoong Kim > --- > Changes in v2: > - reformat comments within 80 column > - fix checkpatch warning about 75 column in commit message > --- > drivers/usb/core/message.c | 33 +++-- > 1 file changed, 15 insertions(+), 18 deletions(-) > > diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c > index dea5591..2184ef4 100644 > --- a/drivers/usb/core/message.c > +++ b/drivers/usb/core/message.c > @@ -122,12 +122,11 @@ static int usb_internal_control_msg(struct usb_device > *usb_dev, > * This function sends a simple control message to a specified endpoint and > * waits for the message to complete, or timeout. > * > - * Don't use this function from within an interrupt context, like a bottom > half > - * handler. If you need an asynchronous message, or need to send a message > - * from within interrupt context, use usb_submit_urb(). > - * If a thread in your driver uses this call, make sure your disconnect() > - * method can wait for it to complete. Since you don't have a handle on the > - * URB used, you can't cancel the request. > + * Don't use this function from within an interrupt context. If you need > + * an asynchronous message, or need to send a message from within interrupt > + * context, use usb_submit_urb(). If a thread in your driver uses this call, > + * make sure your disconnect() method can wait for it to complete. Since you > + * don't have a handle on the URB used, you can't cancel the request. > * > * Return: If successful, the number of bytes transferred. Otherwise, a > negative > * error number. > @@ -173,12 +172,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg); > * This function sends a simple interrupt message to a specified endpoint and > * waits for the message to complete, or timeout. > * > - * Don't use this function from within an interrupt context, like a bottom > half > - * handler. If you need an asynchronous message, or need to send a message > - * from within interrupt context, use usb_submit_urb() If a thread in your > - * driver uses this call, make sure your disconnect() method can wait for it > to > - * complete. Since you don't have a handle on the URB used, you can't cancel > - * the request. > + * Don't use this function from within an interrupt context. If you need > + * an asynchronous message, or need to send a message from within interrupt > + * context, use usb_submit_urb() If a thread in your driver uses this call, > + * make sure your disconnect() method can wait for it to complete. Since you > + * don't have a handle on the URB used, you can't cancel the request. > * > * Return: > * If successful, 0. Otherwise a negative error number. The number of actual > @@ -207,12 +205,11 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg); > * This function sends a simple bulk message to a specified endpoint > * and waits for the message to complete, or timeout. > * > - * Don't use this function from within an interrupt context, like a bottom > half > - * handler. If you need an asynchronous message, or need to send a message > - * from within interrupt context, use usb_submit_urb() If a thread in your > - * driver uses this call, make sure your disconnect() method can wait for it > to > - * complete. Since you don't have a handle on the URB used, you can't cancel > - * the request. > + * Don't use this function from within an interrupt context. If you need > + * an asynchronous message, or need to send a message from within interrupt > + * context, use usb_submit_urb() If a thread in your driver uses this call, > + * make sure your disconnect() method can wait for it to complete. Since you > + * don't have a handle on the URB used, you can't cancel the request. > * > * Bec
[PATCH v2] usb: core: update comments for send message functions
The commonly use of bottom halves are tasklet and workqueue. The big difference between tasklet and workqueue is that the tasklet runs in an interrupt context and the workqueue runs in a process context, which means it can sleep if need be. The comment for usb_control/interrupt/bulk_msg() functions note that do not use this function within an interrupt context, like a 'bottom half' handler. With this comment, it makes confuse about usage of these functions. To more clarify, remove 'bottom half' comment. Signed-off-by: Jaejoong Kim --- Changes in v2: - reformat comments within 80 column - fix checkpatch warning about 75 column in commit message --- drivers/usb/core/message.c | 33 +++-- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index dea5591..2184ef4 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -122,12 +122,11 @@ static int usb_internal_control_msg(struct usb_device *usb_dev, * This function sends a simple control message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb(). - * If a thread in your driver uses this call, make sure your disconnect() - * method can wait for it to complete. Since you don't have a handle on the - * URB used, you can't cancel the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: If successful, the number of bytes transferred. Otherwise, a negative * error number. @@ -173,12 +172,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg); * This function sends a simple interrupt message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: * If successful, 0. Otherwise a negative error number. The number of actual @@ -207,12 +205,11 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg); * This function sends a simple bulk message to a specified endpoint * and waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, * users are forced to abuse this routine by using it to submit URBs for -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: core: update comments for send message functions
The commonly use of bottom halves are tasklet and workqueue. The big difference between tasklet and workqueue is that the tasklet runs in an interrupt context and the workqueue runs in a process context, which means it can sleep if need be. The comment for usb_control/interrupt/bulk_msg() functions note that do not use this function within an interrupt context, like a 'bottom half' handler. With this comment, it makes confuse about usage of these functions. To more clarify, remove 'bottom half' comment. Signed-off-by: Jaejoong Kim --- Changes in v2: - reformat comments within 80 column - fix checkpatch warning about 75 column in commit message --- drivers/usb/core/message.c | 33 +++-- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index dea5591..2184ef4 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -122,12 +122,11 @@ static int usb_internal_control_msg(struct usb_device *usb_dev, * This function sends a simple control message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb(). - * If a thread in your driver uses this call, make sure your disconnect() - * method can wait for it to complete. Since you don't have a handle on the - * URB used, you can't cancel the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: If successful, the number of bytes transferred. Otherwise, a negative * error number. @@ -173,12 +172,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg); * This function sends a simple interrupt message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: * If successful, 0. Otherwise a negative error number. The number of actual @@ -207,12 +205,11 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg); * This function sends a simple bulk message to a specified endpoint * and waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, * users are forced to abuse this routine by using it to submit URBs for -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] usb: core: update comments for send message functions
The commonly use of bottom halves are tasklet and workqueue. The big difference between tasklet and workqueue is that the tasklet runs in an interrupt context and the workqueue runs in a process context, which means it can sleep if need be. The comment for usb_control/interrupt/bulk_msg() functions note that do not use this function within an interrupt context, like a 'bottom half' handler. With this comment, it makes confuse about usage of these functions. To more clarify, remove 'bottom half' comment. Signed-off-by: Jaejoong Kim --- Changes in v2: - reformat comments within 80 column - fix checkpatch warning about 75 column in commit message --- drivers/usb/core/message.c | 33 +++-- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index dea5591..2184ef4 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -122,12 +122,11 @@ static int usb_internal_control_msg(struct usb_device *usb_dev, * This function sends a simple control message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb(). - * If a thread in your driver uses this call, make sure your disconnect() - * method can wait for it to complete. Since you don't have a handle on the - * URB used, you can't cancel the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: If successful, the number of bytes transferred. Otherwise, a negative * error number. @@ -173,12 +172,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg); * This function sends a simple interrupt message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: * If successful, 0. Otherwise a negative error number. The number of actual @@ -207,12 +205,11 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg); * This function sends a simple bulk message to a specified endpoint * and waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, * users are forced to abuse this routine by using it to submit URBs for -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: core: update comments for send message functions
really really sorry for noisy mail. Please ignore this mail. I will resend patch with right subject.. Jaejoong 2017-01-18 10:46 GMT+09:00 Jaejoong Kim : > The commonly use of bottom halves are tasklet and workqueue. The big > difference between tasklet and workqueue is that the tasklet runs in > an interrupt context and the workqueue runs in a process context, > which means it can sleep if need be. > > The comment for usb_control/interrupt/bulk_msg() functions note that do > not use this function within an interrupt context, like a 'bottom half' > handler. With this comment, it makes confuse about usage of these > functions. > > To more clarify, remove 'bottom half' comment. > > Signed-off-by: Jaejoong Kim > --- > v2 : reformat comments within 80-column > fix checkpatch.pl warning about 75 column in commit message > > --- > drivers/usb/core/message.c | 33 +++-- > 1 file changed, 15 insertions(+), 18 deletions(-) > > diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c > index dea5591..2184ef4 100644 > --- a/drivers/usb/core/message.c > +++ b/drivers/usb/core/message.c > @@ -122,12 +122,11 @@ static int usb_internal_control_msg(struct usb_device > *usb_dev, > * This function sends a simple control message to a specified endpoint and > * waits for the message to complete, or timeout. > * > - * Don't use this function from within an interrupt context, like a bottom > half > - * handler. If you need an asynchronous message, or need to send a message > - * from within interrupt context, use usb_submit_urb(). > - * If a thread in your driver uses this call, make sure your disconnect() > - * method can wait for it to complete. Since you don't have a handle on the > - * URB used, you can't cancel the request. > + * Don't use this function from within an interrupt context. If you need > + * an asynchronous message, or need to send a message from within interrupt > + * context, use usb_submit_urb(). If a thread in your driver uses this call, > + * make sure your disconnect() method can wait for it to complete. Since you > + * don't have a handle on the URB used, you can't cancel the request. > * > * Return: If successful, the number of bytes transferred. Otherwise, a > negative > * error number. > @@ -173,12 +172,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg); > * This function sends a simple interrupt message to a specified endpoint and > * waits for the message to complete, or timeout. > * > - * Don't use this function from within an interrupt context, like a bottom > half > - * handler. If you need an asynchronous message, or need to send a message > - * from within interrupt context, use usb_submit_urb() If a thread in your > - * driver uses this call, make sure your disconnect() method can wait for it > to > - * complete. Since you don't have a handle on the URB used, you can't cancel > - * the request. > + * Don't use this function from within an interrupt context. If you need > + * an asynchronous message, or need to send a message from within interrupt > + * context, use usb_submit_urb() If a thread in your driver uses this call, > + * make sure your disconnect() method can wait for it to complete. Since you > + * don't have a handle on the URB used, you can't cancel the request. > * > * Return: > * If successful, 0. Otherwise a negative error number. The number of actual > @@ -207,12 +205,11 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg); > * This function sends a simple bulk message to a specified endpoint > * and waits for the message to complete, or timeout. > * > - * Don't use this function from within an interrupt context, like a bottom > half > - * handler. If you need an asynchronous message, or need to send a message > - * from within interrupt context, use usb_submit_urb() If a thread in your > - * driver uses this call, make sure your disconnect() method can wait for it > to > - * complete. Since you don't have a handle on the URB used, you can't cancel > - * the request. > + * Don't use this function from within an interrupt context. If you need > + * an asynchronous message, or need to send a message from within interrupt > + * context, use usb_submit_urb() If a thread in your driver uses this call, > + * make sure your disconnect() method can wait for it to complete. Since you > + * don't have a handle on the URB used, you can't cancel the request. > * > * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, > * users are forced to abuse this routine by using it to submit URBs for > -- > 2.7.4 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: core: update comments for send message functions
The commonly use of bottom halves are tasklet and workqueue. The big difference between tasklet and workqueue is that the tasklet runs in an interrupt context and the workqueue runs in a process context, which means it can sleep if need be. The comment for usb_control/interrupt/bulk_msg() functions note that do not use this function within an interrupt context, like a 'bottom half' handler. With this comment, it makes confuse about usage of these functions. To more clarify, remove 'bottom half' comment. Signed-off-by: Jaejoong Kim --- v2 : reformat comments within 80-column fix checkpatch.pl warning about 75 column in commit message --- drivers/usb/core/message.c | 33 +++-- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index dea5591..2184ef4 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -122,12 +122,11 @@ static int usb_internal_control_msg(struct usb_device *usb_dev, * This function sends a simple control message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb(). - * If a thread in your driver uses this call, make sure your disconnect() - * method can wait for it to complete. Since you don't have a handle on the - * URB used, you can't cancel the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb(). If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: If successful, the number of bytes transferred. Otherwise, a negative * error number. @@ -173,12 +172,11 @@ EXPORT_SYMBOL_GPL(usb_control_msg); * This function sends a simple interrupt message to a specified endpoint and * waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Return: * If successful, 0. Otherwise a negative error number. The number of actual @@ -207,12 +205,11 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg); * This function sends a simple bulk message to a specified endpoint * and waits for the message to complete, or timeout. * - * Don't use this function from within an interrupt context, like a bottom half - * handler. If you need an asynchronous message, or need to send a message - * from within interrupt context, use usb_submit_urb() If a thread in your - * driver uses this call, make sure your disconnect() method can wait for it to - * complete. Since you don't have a handle on the URB used, you can't cancel - * the request. + * Don't use this function from within an interrupt context. If you need + * an asynchronous message, or need to send a message from within interrupt + * context, use usb_submit_urb() If a thread in your driver uses this call, + * make sure your disconnect() method can wait for it to complete. Since you + * don't have a handle on the URB used, you can't cancel the request. * * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, * users are forced to abuse this routine by using it to submit URBs for -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: musb: dsps: make dsps_musb_clear_ep_rxintr() static
On Tue, Jan 17, 2017 at 05:23:48PM +0100, Greg KH wrote: > On Tue, Jan 17, 2017 at 09:32:05AM -0600, Bin Liu wrote: > > From: Wei Yongjun > > > > Fixes the following sparse warning: > > > > drivers/usb/musb/musb_dsps.c:270:6: warning: > > symbol 'dsps_musb_clear_ep_rxintr' was not declared. Should it be static? > > > > Signed-off-by: Wei Yongjun > > Signed-off-by: Bin Liu > > --- > > drivers/usb/musb/musb_dsps.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > You're kidding right? > > {sigh} > > Didn't we go through this last time? Last time was an accident, it was code cleanup which should go to -rc1. But this compile warning is caused by a patch in v4.10-rc3, so I consider it is a regression which should be addressed in -rc. I believe I see others sending compile warning fixes in -rc. I can feel your frustration from your lines of words, but sorry, this is the only way I can learn how to be a maintainer. Please let me know if you have recommendations. Regards, -Bin. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: core: update comments for send message functions
Hi Alan 2017-01-18 0:57 GMT+09:00 Alan Stern : > On Tue, 17 Jan 2017, Jaejoong Kim wrote: > >> The commonly use of a bottom half are tasklet and workqueue. The big >> difference between tasklet and workqueue is that the tasklet runs in >> an interrupt context and the workqueue runs in a process context, >> which means it can sleep if need be. >> >> The comment for usb_control/interrupt/bulk_msg() functions note that >> do not use this function within an interrupt context, like a 'bottom half' >> handler. With this comment, it makes confuse about usage of these functions. >> >> To more clarify, remove 'bottom half' comment. >> >> Signed-off-by: Jaejoong Kim >> --- >> >> I not sure this change is needed. Just with my background, the bottom half >> technics >> are softirq(rarely used), tasklet and workqueue over 2.5 kernel version. >> And softirq and tasklet runs in interrupt context and workqueue runs in >> process contex. >> >> This functions are quite old but commonly used in usb device driver. That's >> why I read >> these function comments. :) >> >> If there are something wrong with my patch and patch's comment, please tell >> me. >> I am really appreciate with sharing your time for review this patch. > > Removing the stuff about bottom halves from the comments is fine. But > when you reformat the comments, you should not exceed the 80-column > limit. OK. I will resend a patch. Thanks for a comment. Jaejoong -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc3 dwc3_exynos_probe() change goto labels to meaningful names
On 01/16/2017 03:33 AM, Felipe Balbi wrote: > > Hi, > > Shuah Khan writes: >> Change goto labels to meaningful names from a series of errNs. >> >> Signed-off-by: Shuah Khan > > doesn't apply to testing/next, please rebase. > Hi Felipe, This patch is dependent on the usb: dwc3: exynos fix axius clock error path to do cleanup https://lkml.org/lkml/2017/1/10/1081 The above made it into usb-linus. It will apply to usb-next or usb-testing after it gets merged. I can resend it after the dependent patch makes it into the next rc release. thanks, -- Shuah -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2] dmaengine: cppi41: Fix oops in cppi41_runtime_resume
On Tue, Jan 17, 2017 at 09:39:23AM -0800, Tony Lindgren wrote: > * Bin Liu [170117 08:49]: > > On Tue, Jan 17, 2017 at 08:31:03AM -0800, Tony Lindgren wrote: > > > * Bin Liu [170117 08:22]: > > > > On Tue, Jan 17, 2017 at 08:11:39AM -0800, Tony Lindgren wrote: > > > > > * Bin Liu [170117 05:00]: > > > > > > On Mon, Jan 16, 2017 at 03:54:29PM -0800, Tony Lindgren wrote: > > > > > > > Anyways, for the -rc series oops, we can just leave out the > > > > > > > WARN_ON > > > > > > > parts for now until drivers/usb/musb/musb_cppi41.c is fixed too. > > > > > > > > > > > > Giving that cppi is a submodule inside the usb subsysytem and it > > > > > > does't > > > > > > have separate power rail or clock, what is the benefit to adding > > > > > > runtime > > > > > > PM in the cppi driver? > > > > > > > > > > Good question. We need at least minimal support to enable things for > > > > > probe and then idle cppi41 properly if only cppi41.ko is loaded with > > > > > no > > > > > USB modules. > > > > > > > > > > But yeah now that musb does runtime PM based on the cable detection, > > > > > we > > > > > pretty much guarantee that cppi41 is always enabled when USB is in > > > > > use. > > > > > > > > > > And if there are no other devices using cppi41 dma on davinci, we can > > > > > simplify the PM runtime a bit for cppi41. > > > > > > > > This might be a good idea. I didn't have much time to play with this > > > > cppi41 runtime PM, but it seems I am having more issues than you and > > > > others seeing. > > > > > > What kind of additional issues are you seeing not described in the > > > $subject > > > patch? > > > > I didn't take a note and don't remember if those are in the $subject > > patch. But > > > > - enumeration begining with a reset that the device doesn't accept > > address X, error code -71; or > > Some of this could be fixed by $subject patch if caused by a race. > Some of it I'm suspecting might be a different issue where cppi41 dma > will just hang until the device is disconnected on 1 sized in dma transfer. > See the experimental patch below. > > > - console fooding with cppi error code -115 after thumb drive enumeration. > > This should get fixed with the $subject patch if we additionally set > the autosuspend_delay to something sufficient, like 1000. > > > Again, I only tried for a few minutes and didn't take a note, since I > > don't have time to look at this ATM. > > Well I'll post what I think we should fix for the -rc series for cppi41. > If you can then please test that a bit and see if it works. Assuming > things work, then all the other changes can be done later on with no > rush. Sure, I will spend some time on this tomorrow morning, and let you know. > > Regards, > > Tony > > 8< > diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c > --- a/drivers/usb/musb/musb_host.c > +++ b/drivers/usb/musb/musb_host.c > @@ -751,6 +751,15 @@ static void musb_ep_program(struct musb *musb, u8 epnum, > hw_ep->tx_channel = NULL; > } > > + /* > + * At least cppi41 in dma will just hang with size of 1 until the > + * device is connected. For sizes less than 8 it seems to take a > + * long time to complete. Let's use minimum size of 16 to avoid > + * tiny in DMA transfers. > + */ > + if (!is_out && (len < 16)) > + use_dma = 0; I think you also need to add more cleanup in here when not use dma, as in musb_ep_program(): 746 if (is_out && !len) { 747 use_dma = 0; 748 csr = musb_readw(epio, MUSB_TXCSR); 749 csr &= ~MUSB_TXCSR_DMAENAB; 750 musb_writew(epio, MUSB_TXCSR, csr); 751 hw_ep->tx_channel = NULL; 752 } Regards, -Bin. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
usb: gadget: Kernel panic (NULL pointer dereference) when using fsl_udc2_core on i.MX31 PDK
Hi I tried the fsl_udc_core gadget driver on the i.MX31 PDK board and got a kernel panic (NULL pointer dereference) when connecting the USB cable. I had the g_serial module loaded as well. The NULL pointer panic comes from gadget/udc/core.c usb_gadget_giveback_request() which calls req->complete() and in some cases req->complete is NULL. Commit 304f7e5e1d08 ("usb: gadget: Refactor request completion") changed fsl_udc2_core.c (and several other files) and in fsl_udc2_core.c a check that req->complete is non-NULL was removed: --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c @@ -197,10 +197,8 @@ __acquires(ep->udc->lock) ep->stopped = 1; spin_unlock(&ep->udc->lock); - /* complete() is from gadget layer, -* eg fsg->bulk_in_complete() */ - if (req->req.complete) - req->req.complete(&ep->ep, &req->req); + + usb_gadget_giveback_request(&ep->ep, &req->req); spin_lock(&ep->udc->lock); ep->stopped = stopped; If I re-introduce the check (either in fsl_udc_core.c or core.c) at least USB gadget operation using g_serial seems to work just fine. I don't know the logic in detail to understand whether this is a proper fix or if there is some other more problem with the fls_udc_core driver. Does anyone have input in this matter? I can produce a proper patch that fixes this problem by re-introducing the check (in either fsl_udc_core.c or core.c) if that is a proper solution and I can also assist in testing other fixes to the problem. Thanks, Magnus -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc2: fix "iomem 0x00000000" message by setting iomem parameters in usb_hcd
Am 17.01.2017 um 21:08 schrieb Heiner Kallweit: > Am 17.01.2017 um 09:11 schrieb Felipe Balbi: >> >> Hi, >> >> Heiner Kallweit writes: >>> Am 16.01.2017 um 15:05 schrieb Felipe Balbi: Hi, Heiner Kallweit writes: > Set the iomem parameters in the usb_hcd to fix this misleading > message during driver load: > dwc2 c910.usb: irq 22, io mem 0x > > Signed-off-by: Heiner Kallweit > --- > drivers/usb/dwc2/core.h | 3 ++- > drivers/usb/dwc2/hcd.c | 5 - > drivers/usb/dwc2/hcd.h | 3 ++- > drivers/usb/dwc2/platform.c | 2 +- > 4 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h > index 9548d3e0..b66eaeea 100644 > --- a/drivers/usb/dwc2/core.h > +++ b/drivers/usb/dwc2/core.h > @@ -1229,7 +1229,8 @@ static inline void dwc2_hcd_connect(struct > dwc2_hsotg *hsotg) {} > static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool > force) {} > static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {} > static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {} > -static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) > +static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, > + struct resource *res) > { return 0; } > static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) > { return 0; } > diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c > index 911c3b36..2cfbd10e 100644 > --- a/drivers/usb/dwc2/hcd.c > +++ b/drivers/usb/dwc2/hcd.c > @@ -4964,7 +4964,7 @@ static void dwc2_hcd_release(struct dwc2_hsotg > *hsotg) > * USB bus with the core and calls the hc_driver->start() function. It > returns > * a negative error on failure. > */ > -int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) > +int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, struct resource > *res) > { > struct usb_hcd *hcd; > struct dwc2_host_chan *channel; > @@ -5021,6 +5021,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) > > hcd->has_tt = 1; > > + hcd->rsrc_start = res->start; > + hcd->rsrc_len = resource_size(res); > + > ((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg; > hsotg->priv = hcd; > > diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h > index 1ed5fa2b..2305b5fb 100644 > --- a/drivers/usb/dwc2/hcd.h > +++ b/drivers/usb/dwc2/hcd.h > @@ -521,7 +521,8 @@ static inline u8 dwc2_hcd_is_pipe_out(struct > dwc2_hcd_pipe_info *pipe) > return !dwc2_hcd_is_pipe_in(pipe); > } > > -extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq); > +extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, > + struct resource *res); > extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg); > > /* Transaction Execution Functions */ > diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c > index 4fc8c603..5ddc8860 100644 > --- a/drivers/usb/dwc2/platform.c > +++ b/drivers/usb/dwc2/platform.c > @@ -445,7 +445,7 @@ static int dwc2_driver_probe(struct platform_device > *dev) > } > > if (hsotg->dr_mode != USB_DR_MODE_PERIPHERAL) { > - retval = dwc2_hcd_init(hsotg, hsotg->irq); > + retval = dwc2_hcd_init(hsotg, hsotg->irq, res); This is a good idea, but there's more work that can come out of this, if you're interested: i) devm_ioremap_resource() could be called by the generic layer ii) devm_request_irq() could be move to the generic layer iii) dwc2_hcd_init() could also be called generically as long as dr_mode is set properly. iv) dwc2_debugfs_init() could be called generically as well IOW, dwc2_driver_probe() could be as minimal as: static int dwc2_driver_probe(struct platform_device *dev) { struct dwc2_hsotg *hsotg; struct resource *res; int retval; hsotg = devm_kzalloc(&dev->dev, sizeof(*hsotg), GFP_KERNEL); if (!hsotg) return -ENOMEM; hsotg->dev = &dev->dev; if (!dev->dev.dma_mask) dev->dev.dma_mask = &dev->dev.coherent_dma_mask; retval = dma_set_coherent_mask(&dev->dev, DMA_BIT_MASK(32)); if (retval) return retval; hsotg->res = platform_get_resource(dev, IORESOURCE_MEM, 0); hsotg->irq = platform_get_irq(dev, 0); retval = dwc2_get_dr_mode(hsotg); if (retval) return retval; retval = dwc2_get_hwparams(hsotg); if (retval) return retval; platform_set_drvdata(dev, hsotg); retval
[PATCH] usb: dwc2: remove dead function dwc2_pci_quirks
Commit 9962b62f1be9 "Deprecate g-use-dma binding" removed the only property in dwc2_pci_quirks. This function is dead code now. Maybe it was kept intentionally to be prepared for the case that another quirk-related property needs to be added in future. If not it can be removed. Signed-off-by: Heiner Kallweit --- drivers/usb/dwc2/pci.c | 18 -- 1 file changed, 18 deletions(-) diff --git a/drivers/usb/dwc2/pci.c b/drivers/usb/dwc2/pci.c index a23329e3..ae419615 100644 --- a/drivers/usb/dwc2/pci.c +++ b/drivers/usb/dwc2/pci.c @@ -62,20 +62,6 @@ struct dwc2_pci_glue { struct platform_device *phy; }; -static int dwc2_pci_quirks(struct pci_dev *pdev, struct platform_device *dwc2) -{ - if (pdev->vendor == PCI_VENDOR_ID_SYNOPSYS && - pdev->device == PCI_PRODUCT_ID_HAPS_HSOTG) { - struct property_entry properties[] = { - { }, - }; - - return platform_device_add_properties(dwc2, properties); - } - - return 0; -} - static void dwc2_pci_remove(struct pci_dev *pci) { struct dwc2_pci_glue *glue = pci_get_drvdata(pci); @@ -136,10 +122,6 @@ static int dwc2_pci_probe(struct pci_dev *pci, return PTR_ERR(phy); } - ret = dwc2_pci_quirks(pci, dwc2); - if (ret) - goto err; - ret = platform_device_add(dwc2); if (ret) { dev_err(dev, "failed to register dwc2 device\n"); -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2] dmaengine: cppi41: Fix oops in cppi41_runtime_resume
* Bin Liu [170117 11:47]: > On Tue, Jan 17, 2017 at 09:39:23AM -0800, Tony Lindgren wrote: > > * Bin Liu [170117 08:49]: > > > On Tue, Jan 17, 2017 at 08:31:03AM -0800, Tony Lindgren wrote: > > > > * Bin Liu [170117 08:22]: > > > > > On Tue, Jan 17, 2017 at 08:11:39AM -0800, Tony Lindgren wrote: > > > > > > * Bin Liu [170117 05:00]: > > > > > > > On Mon, Jan 16, 2017 at 03:54:29PM -0800, Tony Lindgren wrote: > > > > > > > > Anyways, for the -rc series oops, we can just leave out the > > > > > > > > WARN_ON > > > > > > > > parts for now until drivers/usb/musb/musb_cppi41.c is fixed too. > > > > > > > > > > > > > > Giving that cppi is a submodule inside the usb subsysytem and it > > > > > > > does't > > > > > > > have separate power rail or clock, what is the benefit to adding > > > > > > > runtime > > > > > > > PM in the cppi driver? > > > > > > > > > > > > Good question. We need at least minimal support to enable things for > > > > > > probe and then idle cppi41 properly if only cppi41.ko is loaded > > > > > > with no > > > > > > USB modules. > > > > > > > > > > > > But yeah now that musb does runtime PM based on the cable > > > > > > detection, we > > > > > > pretty much guarantee that cppi41 is always enabled when USB is in > > > > > > use. > > > > > > > > > > > > And if there are no other devices using cppi41 dma on davinci, we > > > > > > can > > > > > > simplify the PM runtime a bit for cppi41. > > > > > > > > > > This might be a good idea. I didn't have much time to play with this > > > > > cppi41 runtime PM, but it seems I am having more issues than you and > > > > > others seeing. > > > > > > > > What kind of additional issues are you seeing not described in the > > > > $subject > > > > patch? > > > > > > I didn't take a note and don't remember if those are in the $subject > > > patch. But > > > > > > - enumeration begining with a reset that the device doesn't accept > > > address X, error code -71; or > > > > Some of this could be fixed by $subject patch if caused by a race. > > Some of it I'm suspecting might be a different issue where cppi41 dma > > will just hang until the device is disconnected on 1 sized in dma transfer. > > See the experimental patch below. > > > > > - console fooding with cppi error code -115 after thumb drive enumeration. > > > > This should get fixed with the $subject patch if we additionally set > > the autosuspend_delay to something sufficient, like 1000. > > > > > Again, I only tried for a few minutes and didn't take a note, since I > > > don't have time to look at this ATM. > > > > Well I'll post what I think we should fix for the -rc series for cppi41. > > If you can then please test that a bit and see if it works. Assuming > > things work, then all the other changes can be done later on with no > > rush. > > Sure, I will spend some time on this tomorrow morning, and let you know. > > > > > Regards, > > > > Tony > > > > 8< > > diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c > > --- a/drivers/usb/musb/musb_host.c > > +++ b/drivers/usb/musb/musb_host.c > > @@ -751,6 +751,15 @@ static void musb_ep_program(struct musb *musb, u8 > > epnum, > > hw_ep->tx_channel = NULL; > > } > > > > + /* > > +* At least cppi41 in dma will just hang with size of 1 until the > > +* device is connected. For sizes less than 8 it seems to take a > > +* long time to complete. Let's use minimum size of 16 to avoid > > +* tiny in DMA transfers. > > +*/ > > + if (!is_out && (len < 16)) > > + use_dma = 0; > > I think you also need to add more cleanup in here when not use dma, > as in musb_ep_program(): > > 746 if (is_out && !len) { > > 747 use_dma = 0; > > 748 csr = musb_readw(epio, MUSB_TXCSR); > > 749 csr &= ~MUSB_TXCSR_DMAENAB; > > 750 musb_writew(epio, MUSB_TXCSR, csr); > > 751 hw_ep->tx_channel = NULL; > > 752 } Oh OK. Yeah this one is in the mysteries to unravel category. And I noticed the -71 resets with another USB mass storage device I tried with this patch so clearly not the right fix for that one. Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] phy: sun4i-usb: support PHY0 on H3 in MUSB mode
On Wed, Jan 18, 2017 at 12:57:08AM +0800, Icenowy Zheng wrote: > > > 17.01.2017, 16:06, "Maxime Ripard" : > > On Tue, Jan 17, 2017 at 03:14:46AM +0800, Icenowy Zheng wrote: > >> Â The PHY0 on H3 can be wired either to MUSB controller or OHCI/EHCI > >> Â controller. > >> > >> Â The original driver wired it to OHCI/EHCI controller; however, as the > >> Â code to use PHY0 as OHCI/EHCI is missing, it makes the PHY fully > >> Â unusable. > >> > >> Â Rename the register (according to its function and the name in BSP > >> Â driver), and remove the code which wires the PHY0 to OHCI/EHCI, as MUSB > >> Â can support both peripheral and host mode (although the host mode of > >> Â MUSB is buggy). > > > > Can you elaborate on that? What's wrong with it? > > The configuration is at bit 0 of register 0x20 in PHY. > > When the PHY is reseted, it defaults as MUSB mode. > > However, the original author of the H3 PHY code seems to be lack of > this knowledge (He named it PHY_UNK_H3), and changed the PHY to HCI > mode. > > I just removed the code that wires it to HCI mode, thus it will work > in MUSB mode, with my sun8i-h3-musb patch. I have no idea what you mean by MUSB mode. Do you mean that the previous code was only working in host mode, and now it only works in peripheral? Maxime -- Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com signature.asc Description: PGP signature
Re: [PATCH 1/4] phy: sun4i-usb: support PHY0 on H3 in MUSB mode
Hi, On Wed, Jan 18, 2017 at 4:06 AM, Maxime Ripard wrote: > On Wed, Jan 18, 2017 at 12:57:08AM +0800, Icenowy Zheng wrote: >> >> >> 17.01.2017, 16:06, "Maxime Ripard" : >> > On Tue, Jan 17, 2017 at 03:14:46AM +0800, Icenowy Zheng wrote: >> >> The PHY0 on H3 can be wired either to MUSB controller or OHCI/EHCI >> >> controller. >> >> >> >> The original driver wired it to OHCI/EHCI controller; however, as the >> >> code to use PHY0 as OHCI/EHCI is missing, it makes the PHY fully >> >> unusable. >> >> >> >> Rename the register (according to its function and the name in BSP >> >> driver), and remove the code which wires the PHY0 to OHCI/EHCI, as MUSB >> >> can support both peripheral and host mode (although the host mode of >> >> MUSB is buggy). >> > >> > Can you elaborate on that? What's wrong with it? >> >> The configuration is at bit 0 of register 0x20 in PHY. >> >> When the PHY is reseted, it defaults as MUSB mode. >> >> However, the original author of the H3 PHY code seems to be lack of >> this knowledge (He named it PHY_UNK_H3), and changed the PHY to HCI >> mode. >> >> I just removed the code that wires it to HCI mode, thus it will work >> in MUSB mode, with my sun8i-h3-musb patch. > > I have no idea what you mean by MUSB mode. > > Do you mean that the previous code was only working in host mode, and > now it only works in peripheral? >From what I understand, with the H3, Allwinner has put a mux in front of the MUSB controller. The mux can send the USB data to/from the MUSB controller, or a standard EHCI/OHCI pair. This register controls said mux. This means we can use a proper USB host for host mode, instead of the limited support in MUSB. ChenYu > > Maxime > > -- > Maxime Ripard, Free Electrons > Embedded Linux and Kernel engineering > http://free-electrons.com -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc2: fix "iomem 0x00000000" message by setting iomem parameters in usb_hcd
Am 17.01.2017 um 09:11 schrieb Felipe Balbi: > > Hi, > > Heiner Kallweit writes: >> Am 16.01.2017 um 15:05 schrieb Felipe Balbi: >>> >>> Hi, >>> >>> Heiner Kallweit writes: Set the iomem parameters in the usb_hcd to fix this misleading message during driver load: dwc2 c910.usb: irq 22, io mem 0x Signed-off-by: Heiner Kallweit --- drivers/usb/dwc2/core.h | 3 ++- drivers/usb/dwc2/hcd.c | 5 - drivers/usb/dwc2/hcd.h | 3 ++- drivers/usb/dwc2/platform.c | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 9548d3e0..b66eaeea 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -1229,7 +1229,8 @@ static inline void dwc2_hcd_connect(struct dwc2_hsotg *hsotg) {} static inline void dwc2_hcd_disconnect(struct dwc2_hsotg *hsotg, bool force) {} static inline void dwc2_hcd_start(struct dwc2_hsotg *hsotg) {} static inline void dwc2_hcd_remove(struct dwc2_hsotg *hsotg) {} -static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) +static inline int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, + struct resource *res) { return 0; } static inline int dwc2_backup_host_registers(struct dwc2_hsotg *hsotg) { return 0; } diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 911c3b36..2cfbd10e 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4964,7 +4964,7 @@ static void dwc2_hcd_release(struct dwc2_hsotg *hsotg) * USB bus with the core and calls the hc_driver->start() function. It returns * a negative error on failure. */ -int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) +int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, struct resource *res) { struct usb_hcd *hcd; struct dwc2_host_chan *channel; @@ -5021,6 +5021,9 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq) hcd->has_tt = 1; + hcd->rsrc_start = res->start; + hcd->rsrc_len = resource_size(res); + ((struct wrapper_priv_data *) &hcd->hcd_priv)->hsotg = hsotg; hsotg->priv = hcd; diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h index 1ed5fa2b..2305b5fb 100644 --- a/drivers/usb/dwc2/hcd.h +++ b/drivers/usb/dwc2/hcd.h @@ -521,7 +521,8 @@ static inline u8 dwc2_hcd_is_pipe_out(struct dwc2_hcd_pipe_info *pipe) return !dwc2_hcd_is_pipe_in(pipe); } -extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq); +extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq, + struct resource *res); extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg); /* Transaction Execution Functions */ diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 4fc8c603..5ddc8860 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -445,7 +445,7 @@ static int dwc2_driver_probe(struct platform_device *dev) } if (hsotg->dr_mode != USB_DR_MODE_PERIPHERAL) { - retval = dwc2_hcd_init(hsotg, hsotg->irq); + retval = dwc2_hcd_init(hsotg, hsotg->irq, res); >>> >>> This is a good idea, but there's more work that can come out of this, if >>> you're interested: >>> >>> i) devm_ioremap_resource() could be called by the generic layer >>> ii) devm_request_irq() could be move to the generic layer >>> iii) dwc2_hcd_init() could also be called generically as long as dr_mode >>> is set properly. >>> iv) dwc2_debugfs_init() could be called generically as well >>> >>> IOW, dwc2_driver_probe() could be as minimal as: >>> >>> static int dwc2_driver_probe(struct platform_device *dev) >>> { >>> struct dwc2_hsotg *hsotg; >>> struct resource *res; >>> int retval; >>> >>> hsotg = devm_kzalloc(&dev->dev, sizeof(*hsotg), GFP_KERNEL); >>> if (!hsotg) >>> return -ENOMEM; >>> >>> hsotg->dev = &dev->dev; >>> >>> if (!dev->dev.dma_mask) >>> dev->dev.dma_mask = &dev->dev.coherent_dma_mask; >>> >>> retval = dma_set_coherent_mask(&dev->dev, DMA_BIT_MASK(32)); >>> if (retval) >>> return retval; >>> >>> hsotg->res = platform_get_resource(dev, IORESOURCE_MEM, 0); >>> hsotg->irq = platform_get_irq(dev, 0); >>> >>> retval = dwc2_get_dr_mode(hsotg); >>> if (retval) >>> return retval; >>> >>> retval = dwc2_get_hwparams(hsotg); >>> if (retval) >>> return retval; >>> >>> platform_set_drvdata(dev, hsotg); >>> >>> retval = dwc2_core_init(hsotg); >>> if (retval) >>> return retval; >>> >>> return 0; >>> } >>> >>> dwc2_core_init() needs to implemented, o
Re: [PATCH] usb: musb: dsps: make dsps_musb_clear_ep_rxintr() static
On Tue, Jan 17, 2017 at 07:28:29PM +0100, Greg KH wrote: > On Tue, Jan 17, 2017 at 10:43:28AM -0600, Bin Liu wrote: > > On Tue, Jan 17, 2017 at 05:23:48PM +0100, Greg KH wrote: > > > On Tue, Jan 17, 2017 at 09:32:05AM -0600, Bin Liu wrote: > > > > From: Wei Yongjun > > > > > > > > Fixes the following sparse warning: > > > > > > > > drivers/usb/musb/musb_dsps.c:270:6: warning: > > > > symbol 'dsps_musb_clear_ep_rxintr' was not declared. Should it be > > > > static? > > > > > > > > Signed-off-by: Wei Yongjun > > > > Signed-off-by: Bin Liu > > > > --- > > > > drivers/usb/musb/musb_dsps.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > You're kidding right? > > > > > > {sigh} > > > > > > Didn't we go through this last time? > > > > Last time was an accident, it was code cleanup which should go to -rc1. > > But this compile warning is caused by a patch in v4.10-rc3, so I > > consider it is a regression which should be addressed in -rc. I believe > > I see others sending compile warning fixes in -rc. > > It's not a normal warning fix, it's only if you run sparse! Ok. > > > I can feel your frustration from your lines of words, but sorry, this is > > the only way I can learn how to be a maintainer. Please let me know if > > you have recommendations. > > If it's not a bugfix or regression, then it needs to wait until the next > major kernel release. Fixing up sparse "warnings" is not a normal I know the role. The issue I have is how to correctly judge if a patch is bugfix/regression or not, more accurately, if a fixup patch should wait until next -rc1 or not... > thing, and it can wait as obviously no one trips over this in normal > operation. I will try to use this on my judgement. > > You might want to read Documentation/development_model/ again :) Sure, I will. Regards, -Bin. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: musb: dsps: make dsps_musb_clear_ep_rxintr() static
On Tue, Jan 17, 2017 at 10:43:28AM -0600, Bin Liu wrote: > On Tue, Jan 17, 2017 at 05:23:48PM +0100, Greg KH wrote: > > On Tue, Jan 17, 2017 at 09:32:05AM -0600, Bin Liu wrote: > > > From: Wei Yongjun > > > > > > Fixes the following sparse warning: > > > > > > drivers/usb/musb/musb_dsps.c:270:6: warning: > > > symbol 'dsps_musb_clear_ep_rxintr' was not declared. Should it be static? > > > > > > Signed-off-by: Wei Yongjun > > > Signed-off-by: Bin Liu > > > --- > > > drivers/usb/musb/musb_dsps.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > You're kidding right? > > > > {sigh} > > > > Didn't we go through this last time? > > Last time was an accident, it was code cleanup which should go to -rc1. > But this compile warning is caused by a patch in v4.10-rc3, so I > consider it is a regression which should be addressed in -rc. I believe > I see others sending compile warning fixes in -rc. It's not a normal warning fix, it's only if you run sparse! > I can feel your frustration from your lines of words, but sorry, this is > the only way I can learn how to be a maintainer. Please let me know if > you have recommendations. If it's not a bugfix or regression, then it needs to wait until the next major kernel release. Fixing up sparse "warnings" is not a normal thing, and it can wait as obviously no one trips over this in normal operation. You might want to read Documentation/development_model/ again :) thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCHv3] dmaengine: cppi41: Fix oops in cppi41_runtime_resume
Commit fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support") together with recent MUSB changes allowed USB and DMA on BeagleBone to idle when no cable is connected. But looks like few corner case issues still remain. Looks like just by re-plugging USB cable about ten or so times on BeagleBone when configured in USB peripheral mode we can get warnings and eventually trigger an oops in cppi41 DMA: WARNING: CPU: 0 PID: 14 at drivers/dma/cppi41.c:1154 cppi41_runtime_suspend+ x28/0x38 [cppi41] ... WARNING: CPU: 0 PID: 14 at drivers/dma/cppi41.c:452 push_desc_queue+0x94/0x9c [cppi41] ... Unable to handle kernel NULL pointer dereference at virtual address 0104 pgd = c0004000 [0104] *pgd= Internal error: Oops: 805 [#1] SMP ARM ... [] (cppi41_runtime_resume [cppi41]) from [] (__rpm_callback+0xc0/0x214) [] (__rpm_callback) from [] (rpm_callback+0x20/0x80) [] (rpm_callback) from [] (rpm_resume+0x504/0x78c) [] (rpm_resume) from [] (pm_runtime_work+0x60/0xa8) [] (pm_runtime_work) from [] (process_one_work+0x2b4/0x808) This is because of a race with runtime PM and cppi41_dma_issue_pending() as reported by Alexandre Bailon in earlier set of patches. Based on mailing list discussions we however came to the conclusion that a different fix from Alexandre's fix is needed in order to guarantee that DMA is really active when we try to use it. To fix the issue, we need to add a driver specific flag as we otherwise can have -EINPROGRESS state set by runtime PM and can't rely on pm_runtime_active() to tell us when we can use the DMA. And we need to make sure the DMA transfers get triggered in the queued order. So let's always queue the transfers, then flush the queue from both cppi41_dma_issue_pending() and cppi41_runtime_resume() as suggested by Grygorii Strashko in an earlier example patch. For reference, this is also documented in Documentation/power/runtime_pm.txt in the example at the end of the file as pointed out by Grygorii Strashko . Based on earlier patches from Alexandre Bailon and Grygorii Strashko modified based on testing and what was discussed on the mailing lists. Note that additional patches are still needed depending on how we want to handle the cppi41 runtime PM. So far cppi41 is always coupled with musb driver, and musb guarantees that cppi41 is always active during use. So until we have a better solution, let's just set the cppi41 autosuspend delay 1 second to avoid pointless EINPROGRESS warnings during USB mass storage enumeration. As cppi41 is properly clocked with musb being active, we can safely do this. Fixes: fdea2d09b997 ("dmaengine: cppi41: Add basic PM runtime support") Cc: Andy Shevchenko Cc: Bin Liu Cc: Grygorii Strashko Cc: Kevin Hilman Cc: Patrick Titiano Cc: Sergei Shtylyov Reported-by: Alexandre Bailon Signed-off-by: Tony Lindgren --- Here's what I think we should merge as a minimal fix for the -rc series, can you guys please test? Changes since v2: - Change autosuspend delay to 1000 to avoid warnings with USB mass storage as cppi41 is always clocked with musb during use - Drop warning changes to cppi41_irq(), those can be dealt with later with the autosuspend delay change - Update description accordingly --- drivers/dma/cppi41.c | 42 ++ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c @@ -153,6 +153,8 @@ struct cppi41_dd { /* context for suspend/resume */ unsigned int dma_tdfdq; + + bool is_suspended; }; #define FIST_COMPLETION_QUEUE 93 @@ -457,20 +459,26 @@ static void push_desc_queue(struct cppi41_channel *c) cppi_writel(reg, cdd->qmgr_mem + QMGR_QUEUE_D(c->q_num)); } -static void pending_desc(struct cppi41_channel *c) +/* + * Caller must hold cdd->lock to prevent push_desc_queue() + * getting called out of order. We have both cppi41_dma_issue_pending() + * and cppi41_runtime_resume() call this function. + */ +static void cppi41_run_queue(struct cppi41_dd *cdd) { - struct cppi41_dd *cdd = c->cdd; - unsigned long flags; + struct cppi41_channel *c, *_c; - spin_lock_irqsave(&cdd->lock, flags); - list_add_tail(&c->node, &cdd->pending); - spin_unlock_irqrestore(&cdd->lock, flags); + list_for_each_entry_safe(c, _c, &cdd->pending, node) { + push_desc_queue(c); + list_del(&c->node); + } } static void cppi41_dma_issue_pending(struct dma_chan *chan) { struct cppi41_channel *c = to_cpp41_chan(chan); struct cppi41_dd *cdd = c->cdd; + unsigned long flags; int error; error = pm_runtime_get(cdd->ddev.dev); @@ -482,10 +490,11 @@ static void cppi41_dma_issue_pending(struct dma_chan *chan) return; } - if (likely(pm_runtime_active(cdd->ddev.dev))) - push_desc_queue(c); - else -
Re: [PATCHv2] dmaengine: cppi41: Fix oops in cppi41_runtime_resume
* Bin Liu [170117 08:49]: > On Tue, Jan 17, 2017 at 08:31:03AM -0800, Tony Lindgren wrote: > > * Bin Liu [170117 08:22]: > > > On Tue, Jan 17, 2017 at 08:11:39AM -0800, Tony Lindgren wrote: > > > > * Bin Liu [170117 05:00]: > > > > > On Mon, Jan 16, 2017 at 03:54:29PM -0800, Tony Lindgren wrote: > > > > > > Anyways, for the -rc series oops, we can just leave out the WARN_ON > > > > > > parts for now until drivers/usb/musb/musb_cppi41.c is fixed too. > > > > > > > > > > Giving that cppi is a submodule inside the usb subsysytem and it > > > > > does't > > > > > have separate power rail or clock, what is the benefit to adding > > > > > runtime > > > > > PM in the cppi driver? > > > > > > > > Good question. We need at least minimal support to enable things for > > > > probe and then idle cppi41 properly if only cppi41.ko is loaded with no > > > > USB modules. > > > > > > > > But yeah now that musb does runtime PM based on the cable detection, we > > > > pretty much guarantee that cppi41 is always enabled when USB is in use. > > > > > > > > And if there are no other devices using cppi41 dma on davinci, we can > > > > simplify the PM runtime a bit for cppi41. > > > > > > This might be a good idea. I didn't have much time to play with this > > > cppi41 runtime PM, but it seems I am having more issues than you and > > > others seeing. > > > > What kind of additional issues are you seeing not described in the $subject > > patch? > > I didn't take a note and don't remember if those are in the $subject > patch. But > > - enumeration begining with a reset that the device doesn't accept > address X, error code -71; or Some of this could be fixed by $subject patch if caused by a race. Some of it I'm suspecting might be a different issue where cppi41 dma will just hang until the device is disconnected on 1 sized in dma transfer. See the experimental patch below. > - console fooding with cppi error code -115 after thumb drive enumeration. This should get fixed with the $subject patch if we additionally set the autosuspend_delay to something sufficient, like 1000. > Again, I only tried for a few minutes and didn't take a note, since I > don't have time to look at this ATM. Well I'll post what I think we should fix for the -rc series for cppi41. If you can then please test that a bit and see if it works. Assuming things work, then all the other changes can be done later on with no rush. Regards, Tony 8< diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -751,6 +751,15 @@ static void musb_ep_program(struct musb *musb, u8 epnum, hw_ep->tx_channel = NULL; } + /* +* At least cppi41 in dma will just hang with size of 1 until the +* device is connected. For sizes less than 8 it seems to take a +* long time to complete. Let's use minimum size of 16 to avoid +* tiny in DMA transfers. +*/ + if (!is_out && (len < 16)) + use_dma = 0; + /* candidate for DMA? */ dma_controller = musb->dma_controller; if (use_dma && is_dma_capable() && epnum && dma_controller) { -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2] dmaengine: cppi41: Fix oops in cppi41_runtime_resume
On Tue, Jan 17, 2017 at 08:31:03AM -0800, Tony Lindgren wrote: > * Bin Liu [170117 08:22]: > > On Tue, Jan 17, 2017 at 08:11:39AM -0800, Tony Lindgren wrote: > > > * Bin Liu [170117 05:00]: > > > > On Mon, Jan 16, 2017 at 03:54:29PM -0800, Tony Lindgren wrote: > > > > > Anyways, for the -rc series oops, we can just leave out the WARN_ON > > > > > parts for now until drivers/usb/musb/musb_cppi41.c is fixed too. > > > > > > > > Giving that cppi is a submodule inside the usb subsysytem and it does't > > > > have separate power rail or clock, what is the benefit to adding runtime > > > > PM in the cppi driver? > > > > > > Good question. We need at least minimal support to enable things for > > > probe and then idle cppi41 properly if only cppi41.ko is loaded with no > > > USB modules. > > > > > > But yeah now that musb does runtime PM based on the cable detection, we > > > pretty much guarantee that cppi41 is always enabled when USB is in use. > > > > > > And if there are no other devices using cppi41 dma on davinci, we can > > > simplify the PM runtime a bit for cppi41. > > > > This might be a good idea. I didn't have much time to play with this > > cppi41 runtime PM, but it seems I am having more issues than you and > > others seeing. > > What kind of additional issues are you seeing not described in the $subject > patch? I didn't take a note and don't remember if those are in the $subject patch. But - enumeration begining with a reset that the device doesn't accept address X, error code -71; or - console fooding with cppi error code -115 after thumb drive enumeration. Again, I only tried for a few minutes and didn't take a note, since I don't have time to look at this ATM. Regards, -Bin. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2] dmaengine: cppi41: Fix oops in cppi41_runtime_resume
* Bin Liu [170117 08:22]: > On Tue, Jan 17, 2017 at 08:11:39AM -0800, Tony Lindgren wrote: > > * Bin Liu [170117 05:00]: > > > On Mon, Jan 16, 2017 at 03:54:29PM -0800, Tony Lindgren wrote: > > > > Anyways, for the -rc series oops, we can just leave out the WARN_ON > > > > parts for now until drivers/usb/musb/musb_cppi41.c is fixed too. > > > > > > Giving that cppi is a submodule inside the usb subsysytem and it does't > > > have separate power rail or clock, what is the benefit to adding runtime > > > PM in the cppi driver? > > > > Good question. We need at least minimal support to enable things for > > probe and then idle cppi41 properly if only cppi41.ko is loaded with no > > USB modules. > > > > But yeah now that musb does runtime PM based on the cable detection, we > > pretty much guarantee that cppi41 is always enabled when USB is in use. > > > > And if there are no other devices using cppi41 dma on davinci, we can > > simplify the PM runtime a bit for cppi41. > > This might be a good idea. I didn't have much time to play with this > cppi41 runtime PM, but it seems I am having more issues than you and > others seeing. What kind of additional issues are you seeing not described in the $subject patch? Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: musb: dsps: make dsps_musb_clear_ep_rxintr() static
On Tue, Jan 17, 2017 at 09:32:05AM -0600, Bin Liu wrote: > From: Wei Yongjun > > Fixes the following sparse warning: > > drivers/usb/musb/musb_dsps.c:270:6: warning: > symbol 'dsps_musb_clear_ep_rxintr' was not declared. Should it be static? > > Signed-off-by: Wei Yongjun > Signed-off-by: Bin Liu > --- > drivers/usb/musb/musb_dsps.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) You're kidding right? {sigh} Didn't we go through this last time? greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2] dmaengine: cppi41: Fix oops in cppi41_runtime_resume
On Tue, Jan 17, 2017 at 08:11:39AM -0800, Tony Lindgren wrote: > * Bin Liu [170117 05:00]: > > On Mon, Jan 16, 2017 at 03:54:29PM -0800, Tony Lindgren wrote: > > > Anyways, for the -rc series oops, we can just leave out the WARN_ON > > > parts for now until drivers/usb/musb/musb_cppi41.c is fixed too. > > > > Giving that cppi is a submodule inside the usb subsysytem and it does't > > have separate power rail or clock, what is the benefit to adding runtime > > PM in the cppi driver? > > Good question. We need at least minimal support to enable things for > probe and then idle cppi41 properly if only cppi41.ko is loaded with no > USB modules. > > But yeah now that musb does runtime PM based on the cable detection, we > pretty much guarantee that cppi41 is always enabled when USB is in use. > > And if there are no other devices using cppi41 dma on davinci, we can > simplify the PM runtime a bit for cppi41. This might be a good idea. I didn't have much time to play with this cppi41 runtime PM, but it seems I am having more issues than you and others seeing. Regards, -Bin. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 0/5] usb: dwc2: Add support for USB OTG on STM32F4x9
The STM32F4x9 MCU family has two DWC2 USB OTG cores on it. One core is USB OTG FS and other core is USB OTG HS. The USB FS core only works with its internal phy whilst the USF HS core can work in HS with external ulpi phy or in FS/LS speed with the embedded FS PHY. The goal of this patch series is to enable the use of USB OTG FS/HS cores in FS mode using the internal phy. Changes since v3: - Removed commented lines from patch (sent by mistake) - Split DTS patch by boards and SOC - Removed unnecessary pinctrl nodes from DTS files Changes since v2: - Rename driver variables to meet the driver standard - Add compatible string for HS core Changes since v1: - Add dwc2_core_params structure for stm32f4 otg fs - Add compatible string for FS core/mode - Use GGPIO register to deativate power down of the phy Bruno Herrera (5): usb: dwc2: Add support for STM32F429/439/469 USB OTG HS/FS in FS mode (internal PHY) ARM: dts: stm32: Add USB FS support for STM32F429 MCU ARM: dts: stm32: Enable USB FS on stm32f469-disco ARM: dts: stm32: Enable USB HS in FS mode (embedded phy) on stm32f429-disco dt-bindings: Document the STM32 USB OTG DWC2 core binding Documentation/devicetree/bindings/usb/dwc2.txt | 4 ++ arch/arm/boot/dts/stm32f429-disco.dts | 16 arch/arm/boot/dts/stm32f429.dtsi | 31 arch/arm/boot/dts/stm32f469-disco.dts | 16 drivers/usb/dwc2/core.h| 4 ++ drivers/usb/dwc2/hcd.c | 13 ++- drivers/usb/dwc2/hw.h | 2 + drivers/usb/dwc2/params.c | 51 ++ 8 files changed, 136 insertions(+), 1 deletion(-) -- 2.10.1 (Apple Git-78) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/5] usb: dwc2: Add support for STM32F429/439/469 USB OTG HS/FS in FS mode (internal PHY)
This patch introduces a new parameter to activate USB OTG HS/FS core embedded phy transceiver. The STM32F4x9 SoC uses the GGPIO register to enable the transceiver. Also add the dwc2_core_params structure for stm32f4 otg fs. Signed-off-by: Bruno Herrera --- drivers/usb/dwc2/core.h | 4 drivers/usb/dwc2/hcd.c| 13 +++- drivers/usb/dwc2/hw.h | 2 ++ drivers/usb/dwc2/params.c | 51 +++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 9548d3e..e3199c5 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -430,6 +430,9 @@ enum dwc2_ep0_state { * needed. * 0 - No (default) * 1 - Yes + * @activate_transceiver: Activate internal transceiver using GGPIO register. + * 0 - Deactivate the transceiver (default) + * 1 - Activate the transceiver * @g_dma: Enables gadget dma usage (default: autodetect). * @g_dma_desc: Enables gadget descriptor DMA (default: autodetect). * @g_rx_fifo_size:The periodic rx fifo size for the device, in @@ -501,6 +504,7 @@ struct dwc2_core_params { int uframe_sched; int external_id_pin_ctl; int hibernation; + int activate_transceiver; /* * The following parameters are *only* set via device diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 911c3b3..6bee529 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -118,7 +118,7 @@ static void dwc2_init_fs_ls_pclk_sel(struct dwc2_hsotg *hsotg) static int dwc2_fs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) { - u32 usbcfg, i2cctl; + u32 usbcfg, ggpio, i2cctl; int retval = 0; /* @@ -142,6 +142,17 @@ static int dwc2_fs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy) return retval; } } + + ggpio = dwc2_readl(hsotg->regs + GGPIO); + if (!(ggpio & GGPIO_STM32_OTG_GCCFG_PWRDWN) && + (hsotg->params.activate_transceiver > 0)) { + dev_dbg(hsotg->dev, "Activating transceiver\n"); + /* STM32F4xx uses the GGPIO register as general core +* configuration register. +*/ + ggpio |= GGPIO_STM32_OTG_GCCFG_PWRDWN; + dwc2_writel(ggpio, hsotg->regs + GGPIO); + } } /* diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h index 5be056b..a84e93b 100644 --- a/drivers/usb/dwc2/hw.h +++ b/drivers/usb/dwc2/hw.h @@ -225,6 +225,8 @@ #define GPVNDCTL HSOTG_REG(0x0034) #define GGPIO HSOTG_REG(0x0038) +#define GGPIO_STM32_OTG_GCCFG_PWRDWN (1 << 16) + #define GUID HSOTG_REG(0x003c) #define GSNPSIDHSOTG_REG(0x0040) #define GHWCFG1HSOTG_REG(0x0044) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 11fe68a..dbb054d 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -192,6 +192,37 @@ static const struct dwc2_core_params params_amlogic = { .hibernation= -1, }; +static const struct dwc2_core_params params_stm32f4_otgfs = { + .otg_cap= DWC2_CAP_PARAM_NO_HNP_SRP_CAPABLE, + .otg_ver= -1, + .dma_desc_enable= 0, + .dma_desc_fs_enable = 0, + .speed = DWC2_SPEED_PARAM_FULL, + .enable_dynamic_fifo= -1, + .en_multiple_tx_fifo= -1, + .host_rx_fifo_size = 128, /* 128 DWORDs */ + .host_nperio_tx_fifo_size = 96, /* 96 DWORDs */ + .host_perio_tx_fifo_size= 96, /* 96 DWORDs */ + .max_transfer_size = -1, + .max_packet_count = 256, + .host_channels = -1, + .phy_type = DWC2_PHY_TYPE_PARAM_FS, + .phy_utmi_width = -1, + .phy_ulpi_ddr = -1, + .phy_ulpi_ext_vbus = -1, + .i2c_enable = 0, + .ulpi_fs_ls = -1, + .host_support_fs_ls_low_power = -1, + .host_ls_low_power_phy_clk = -1, + .ts_dline = -1, + .reload_ctl = -1, + .ahbcfg = -1, + .uframe_sched = 0, + .external_id_pin_ctl= -1, + .hibernation= -1, + .activate_transceiver = 1, +}; + static const struct dwc2_core_params params_default = {
[PATCH v3 2/5] ARM: dts: stm32: Add USB FS support for STM32F429 MCU
This patch adds the USB pins and nodes for USB FS core. Signed-off-by: Bruno Herrera --- arch/arm/boot/dts/stm32f429.dtsi | 31 +++ 1 file changed, 31 insertions(+) diff --git a/arch/arm/boot/dts/stm32f429.dtsi b/arch/arm/boot/dts/stm32f429.dtsi index e4dae0e..26f2395 100644 --- a/arch/arm/boot/dts/stm32f429.dtsi +++ b/arch/arm/boot/dts/stm32f429.dtsi @@ -316,6 +316,28 @@ }; }; + usbotg_fs_pins_a: usbotg_fs@0 { + pins { + pinmux = , + , + ; + bias-disable; + drive-push-pull; + slew-rate = <2>; + }; + }; + + usbotg_fs_pins_b: usbotg_fs@1 { + pins { + pinmux = , + , + ; + bias-disable; + drive-push-pull; + slew-rate = <2>; + }; + }; + usbotg_hs_pins_a: usbotg_hs@0 { pins { pinmux = , @@ -420,6 +442,15 @@ status = "disabled"; }; + usbotg_fs: usb@5000 { + compatible = "st,stm32f4xx-fsotg"; + reg = <0x5000 0x4>; + interrupts = <67>; + clocks = <&rcc 0 39>; + clock-names = "otg"; + status = "disabled"; + }; + rng: rng@50060800 { compatible = "st,stm32-rng"; reg = <0x50060800 0x400>; -- 2.10.1 (Apple Git-78) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 3/5] ARM: dts: stm32: Enable USB FS on stm32f469-disco
This patch enables USB FS on stm32f469-disco with 5V VBUS enable. Signed-off-by: Bruno Herrera --- arch/arm/boot/dts/stm32f469-disco.dts | 16 1 file changed, 16 insertions(+) diff --git a/arch/arm/boot/dts/stm32f469-disco.dts b/arch/arm/boot/dts/stm32f469-disco.dts index 8877c00..3e0a83e 100644 --- a/arch/arm/boot/dts/stm32f469-disco.dts +++ b/arch/arm/boot/dts/stm32f469-disco.dts @@ -68,6 +68,15 @@ soc { dma-ranges = <0xc000 0x0 0x1000>; }; + + /* This turns on vbus for otg for host mode (dwc2) */ + vcc5v_otg: vcc5v-otg-regulator { + compatible = "regulator-fixed"; + enable-active-high; + gpio = <&gpiob 2 0>; + regulator-name = "vcc5_host1"; + regulator-always-on; + }; }; &rcc { @@ -81,3 +90,10 @@ &usart3 { status = "okay"; }; + +&usbotg_fs { + dr_mode = "host"; + pinctrl-0 = <&usbotg_fs_pins_a>; + pinctrl-names = "default"; + status = "okay"; +}; -- 2.10.1 (Apple Git-78) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 4/5] ARM: dts: stm32: Enable USB HS in FS mode (embedded phy) on stm32f429-disco
This patch enables USB HS working in FS mode on stm32f429-disco with 5V VBUS enable. Signed-off-by: Bruno Herrera --- arch/arm/boot/dts/stm32f429-disco.dts | 16 1 file changed, 16 insertions(+) diff --git a/arch/arm/boot/dts/stm32f429-disco.dts b/arch/arm/boot/dts/stm32f429-disco.dts index 7d0415e..0b2b017 100644 --- a/arch/arm/boot/dts/stm32f429-disco.dts +++ b/arch/arm/boot/dts/stm32f429-disco.dts @@ -88,6 +88,14 @@ gpios = <&gpioa 0 0>; }; }; + + /* This turns on vbus for otg for host mode (dwc2) */ + vcc5v_otg: vcc5v-otg-regulator { + compatible = "regulator-fixed"; + gpio = <&gpioc 4 0>; + regulator-name = "vcc5_host1"; + regulator-always-on; + }; }; &clk_hse { @@ -99,3 +107,11 @@ pinctrl-names = "default"; status = "okay"; }; + +&usbotg_hs { + compatible = "st,stm32f4xx-fsotg"; + dr_mode = "host"; + pinctrl-0 = <&usbotg_fs_pins_b>; + pinctrl-names = "default"; + status = "okay"; +}; -- 2.10.1 (Apple Git-78) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2] dmaengine: cppi41: Fix oops in cppi41_runtime_resume
* Bin Liu [170117 05:00]: > On Mon, Jan 16, 2017 at 03:54:29PM -0800, Tony Lindgren wrote: > > Anyways, for the -rc series oops, we can just leave out the WARN_ON > > parts for now until drivers/usb/musb/musb_cppi41.c is fixed too. > > Giving that cppi is a submodule inside the usb subsysytem and it does't > have separate power rail or clock, what is the benefit to adding runtime > PM in the cppi driver? Good question. We need at least minimal support to enable things for probe and then idle cppi41 properly if only cppi41.ko is loaded with no USB modules. But yeah now that musb does runtime PM based on the cable detection, we pretty much guarantee that cppi41 is always enabled when USB is in use. And if there are no other devices using cppi41 dma on davinci, we can simplify the PM runtime a bit for cppi41. Regards, Tony -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 5/5] dt-bindings: Document the STM32 USB OTG DWC2 core binding
This patch adds the documentation for STM32F4x9 USB OTG FS/HS compatible strings. Signed-off-by: Bruno Herrera --- Documentation/devicetree/bindings/usb/dwc2.txt | 4 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt index 6c7c2bce..637223a 100644 --- a/Documentation/devicetree/bindings/usb/dwc2.txt +++ b/Documentation/devicetree/bindings/usb/dwc2.txt @@ -14,6 +14,10 @@ Required properties: - "amlogic,meson-gxbb-usb": The DWC2 USB controller instance in Amlogic S905 SoCs; - "amcc,dwc-otg": The DWC2 USB controller instance in AMCC Canyonlands 460EX SoCs; - snps,dwc2: A generic DWC2 USB controller with default parameters. + - "st,stm32f4xx-fsotg": The DWC2 USB FS/HS controller instance in STM32F4xx SoCs + configured in FS mode; + - "st,stm32f4xx-hsotg": The DWC2 USB HS controller instance in STM32F4xx SoCs + configured in HS mode; - reg : Should contain 1 register range (address and length) - interrupts : Should contain 1 interrupt - clocks: clock provider specifier -- 2.10.1 (Apple Git-78) -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] usb: dwc3: ep0: Fix the possible missed request for handling delay STATUS phase
On Mon, 16 Jan 2017, Felipe Balbi wrote: > > The gadget driver never calls usb_ep_queue in order to receive the next > > SETUP packet; the UDC driver takes care of SETUP handling > > automatically. > > yeah, that's another thing I'd like to change. Currently, we have no > means to either try to implement device-initiated LPM without adding a > ton of hacks to UDC drivers. If we require upper layers (composite.c, > most of the time) to usb_ep_queue() separate requests for all 3 phases > of a ctrl transfer, we can actually rely on the fact that a new SETUP > phase hasn't been queued yet to trigger U3 entry. I haven't given any thought to LPM. However, requiring gadget drivers to request SETUP packets seems rather questionable. It flies against the USB spec, which requires peripherals to accept SETUP packets at any time -- a device is not allowed to NAK or STALL a SETUP packet (see 8.4.6.4 in the USB-2 spec). In fact, the hardware in UDCs probably isn't capable of doing it. This means that to do what you want, the UDC driver would have to accept SETUP packets at any time, and store the most recent packet contents. Then, when the gadget driver submits a request, the UDC driver would give it this stored data. It would also have to detect and prevent a nasty race where the gadget driver tries to queue a request on ep0 that is a response to an old SETUP, one that has already been overwritten. I'm not even sure preventing this race would be possible in your scheme. The advantage to invoking the gadget driver's setup callback directly from the UDC driver's interrupt handler is that the gadget driver will know immediately when an old SETUP has become stale. (That's what ep0_req_tag is for in f_mass_storage.) It also provides a concurrency guarantee, because the driver does not re-enable UDC SETUP interrupts until the handler is finished. > Another detail that this helps is that PM (overall) becomes simpler as, > most likely, we won't need to mess with transfer cancellation, for > example. System PM on a gadget is always troublesome. Even if the USB connection is a wakeup source, it may not be possible to guarantee that the gadget can wake up quickly enough to handle an incoming packet. > > You are suggesting that status stage requests should not be queued > > automatically by UDC drivers but instead queued explicitly by gadget > > drivers. This would mean changing every UDC driver and every gadget > > driver. > > yes, a bit of work but has been done before. One example that comes to > mind is when I added ->udc_start() and ->udc_stop(). It's totally > doable. We can, for instance, add a temporary > "wants_explicit_ctrl_phases" flag to struct usb_gadget which, if set, > will tell composite.c (or whatever) that the UDC wants explicitly queued > ctrl phases. The term used in the USB spec is "stage", not "phase". "Phase" refers to the packets making up a single transaction: token, data, and handshake. Also, data stages are already explicit. So your temporary flag might better be called "wants_explicit_status_stages". > Then add support for that to each UDC and set the flag. Once all are > converted, add one extra patch to remove the flag and the legacy > code. This has, of course, the draw back of increasing complexity until > everything is converted over; but if it's all done in a single series, I > can't see any problems with that. > > > Also, it won't fix the race that Baolin Wang found. The setup routine > > well, it will help... see below. > > > is always called in interrupt context, so it can't sleep. Doing > > anything non-trivial will require a separate task, and it's possible > > that this task will try to enqueue the data-stage or status-stage > > request before the UDC driver is ready to handle it (for example, > > before or shortly after the setup routine returns). > > > > To work properly, the UDC driver must be able to accept a request for > > ep0 any time after it invokes the setup callback -- either before the > > callback returns or after. > > Right, all UDCs are *already* required to support this case anyway > because of USB_GADGET_DELAYED_STATUS. There was a bug in DWC3, sure, but > it was already required to support this case. > > By removing USB_GADGET_DELAYED_STATUS altogether and making phases more > explict, we enforce this requirement and it'll be much easier to test > for it IMO. Okay, I can see the point of requiring explicit status requests. Implementing it will be a little tricky, because right now some status requests already are explicit (those for length-0 OUT transfers) while others are implicit. (One possible approach would be to have the setup routine return different values for explicit and implicit status stages -- for example, return 1 if it wants to submit an explicit status request. That wouldn't be very different from the current USB_GADGET_DELAYED_STATUS approach.) On the other hand, I am very doubtful about requiring explic
Re: [PATCH] usb: core: update comments for send message functions
On Tue, 17 Jan 2017, Jaejoong Kim wrote: > The commonly use of a bottom half are tasklet and workqueue. The big > difference between tasklet and workqueue is that the tasklet runs in > an interrupt context and the workqueue runs in a process context, > which means it can sleep if need be. > > The comment for usb_control/interrupt/bulk_msg() functions note that > do not use this function within an interrupt context, like a 'bottom half' > handler. With this comment, it makes confuse about usage of these functions. > > To more clarify, remove 'bottom half' comment. > > Signed-off-by: Jaejoong Kim > --- > > I not sure this change is needed. Just with my background, the bottom half > technics > are softirq(rarely used), tasklet and workqueue over 2.5 kernel version. > And softirq and tasklet runs in interrupt context and workqueue runs in > process contex. > > This functions are quite old but commonly used in usb device driver. That's > why I read > these function comments. :) > > If there are something wrong with my patch and patch's comment, please tell > me. > I am really appreciate with sharing your time for review this patch. Removing the stuff about bottom halves from the comments is fine. But when you reformat the comments, you should not exceed the 80-column limit. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] musb fixes for v4.10-rc5
Hi Greg, Here is musb fixes for v4.10-rc5, it is to fix a sparse warning. Please let me know if any change is needed. Regards, -Bin. Wei Yongjun (1): usb: musb: dsps: make dsps_musb_clear_ep_rxintr() static drivers/usb/musb/musb_dsps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: musb: dsps: make dsps_musb_clear_ep_rxintr() static
From: Wei Yongjun Fixes the following sparse warning: drivers/usb/musb/musb_dsps.c:270:6: warning: symbol 'dsps_musb_clear_ep_rxintr' was not declared. Should it be static? Signed-off-by: Wei Yongjun Signed-off-by: Bin Liu --- drivers/usb/musb/musb_dsps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 9f125e179acd..144e7e04807a 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -267,7 +267,7 @@ static void otg_timer(unsigned long _musb) pm_runtime_put_autosuspend(dev); } -void dsps_musb_clear_ep_rxintr(struct musb *musb, int epnum) +static void dsps_musb_clear_ep_rxintr(struct musb *musb, int epnum) { u32 epintr; struct dsps_glue *glue = dev_get_drvdata(musb->controller->parent); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] USB: Add uPD78F0730 USB to Serial Adaptor Driver
On Tue, Jan 17, 2017 at 04:25:18PM +0300, Maksim Salau wrote: > Hi Johan, > > > I think it's right to keep them as in the current version of the patch > > (i.e. active high) which is accordance with the datasheet, but if > > possible you should verify the levels when using hardware flow control > > to be certain that the polarity is not inverted when enabling hardware > > flow control. > > It seems to me that CTSRTS flow control is not implemented > in the device I have. I tried to send lots of data to cause level change > of the RTS signal with no success. Also I tried to: > 1. open port; > 2. disable CTSRTS flow control; > 3. set RTS to a specific level; > 4. enable CTSRTS flow control; > 5. send some data. > > I tried the sequence above with RTS set and reset, and I can conclude that > step 4 doesn't affect RTS signal at all. Ok, thanks for testing. Better leave CRTSCTS unimplemented for now then. And keep the current modem-control-signal polarity. What are the levels of these signals when coming out of reset (i.e. after having connected the device, but not opened it yet)? Thanks, Johan -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: functionfs on dwc3, xhci host: endpoint cannot be used in both directions ?
On Mon, 16 Jan 2017 14:48:31 +, Vincent Pelletier wrote: > 3) I declared 4 endpoints (2 IN, 2 OUT). And I went one level deeper >down the rabbit hole: now enumeration fails with this message on >host: Aaand... I dug this part of the hole myself. In the library part of my python module, and I was looking at the test program. Shame on me. Next tests: After a bit of patching f_fs so it accepts creating 30 endpoints, more endpoints seem to have issues above the 7th (ignoring direction). 1IN bandwidth: 0 B/s (0.20s) 1OUTbandwidth: 30230053 B/s (0.21s) 2IN bandwidth: 29541962 B/s (0.22s) 2OUTbandwidth: 29995671 B/s (0.22s) 3IN bandwidth: 28787881 B/s (0.22s) 3OUTbandwidth: 30428794 B/s (0.22s) 4IN bandwidth: 29768777 B/s (0.22s) 4OUTbandwidth: 30377747 B/s (0.22s) 5IN bandwidth: 29521290 B/s (0.22s) 5OUTbandwidth: 30133012 B/s (0.22s) 6IN bandwidth: 29662245 B/s (0.22s) 6OUTbandwidth: 30335271 B/s (0.22s) 7IN bandwidth: 29467489 B/s (0.22s) 7OUTbandwidth: 30387586 B/s (0.22s) 8IN bandwidth: 0 B/s (0.20s) 8OUTbandwidth: 0 B/s (0.20s) 9IN bandwidth: 0 B/s (0.20s) 9OUTbandwidth: 30174377 B/s (0.22s) 10INbandwidth: 0 B/s (0.20s) 10OUT bandwidth: 30389703 B/s (0.22s) 11INbandwidth: 0 B/s (0.20s) 11OUT bandwidth: 29947720 B/s (0.21s) 12INbandwidth: 0 B/s (0.20s) 12OUT bandwidth: 29386298 B/s (0.21s) 13INbandwidth: 0 B/s (0.20s) 13OUT bandwidth: 30097119 B/s (0.22s) 14INbandwidth: 0 B/s (0.20s) 14OUT bandwidth: 30099782 B/s (0.22s) 15INbandwidth: 0 B/s (0.20s) 15OUT bandwidth: 31122053 B/s (0.21s) Would this pattern ring a bell ? I did the stall test again (on all endpoints and on 8IN + 9IN), and the halted endpoints behave as expected. I also verified the right data reaches/comes from the right endpoint (for those which work), without error. I did not check with my protocol analyser yet. I attach the patch against f_fs.c as an RFC. Regards, -- Vincent Pelletier >From fc77bb86dfbf088ce4a63510867210c2f2d8b0af Mon Sep 17 00:00:00 2001 Message-Id: From: Vincent Pelletier Date: Tue, 17 Jan 2017 12:57:39 + Subject: usb: gadget: f_fs: Accept up to 30 endpoints. It is allowed by the USB specification to enabled same-address, opposite- direction endpoints simultaneously, which means 30 non-zero endpoints are allowed. So double eps_addrmap length to 30. The original code only accepted 14 descriptors, because the first eps_addrmap entry is unused (it is a placeholder for endpoint zero). So increase eps_addrmap length by one to 31. Signed-off-by: Vincent Pelletier --- drivers/usb/gadget/function/f_fs.c | 2 +- drivers/usb/gadget/function/u_fs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 5c91a6f4613b..206184b561b7 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2101,7 +2101,7 @@ static int __ffs_data_do_entity(enum ffs_entity_type type, case FFS_ENDPOINT: d = (void *)desc; helper->eps_count++; - if (helper->eps_count >= 15) + if (helper->eps_count >= 31) return -EINVAL; /* Check if descriptors for any speed were already parsed */ if (!helper->ffs->eps_count && !helper->ffs->interfaces_count) diff --git a/drivers/usb/gadget/function/u_fs.h b/drivers/usb/gadget/function/u_fs.h index 60139854e0b1..8eaf473d1ac0 100644 --- a/drivers/usb/gadget/function/u_fs.h +++ b/drivers/usb/gadget/function/u_fs.h @@ -247,7 +247,7 @@ struct ffs_data { unsigned user_flags; - u8eps_addrmap[15]; + u8eps_addrmap[31]; unsigned short strings_count; unsigned short interfaces_count; -- 2.11.0
Re: [PATCH] usb: musb: constify dev_pm_ops structures
On Sun, Jan 15, 2017 at 05:30:46PM +0530, Bhumika Goyal wrote: > Declare dev_pm_ops structures as const as they are only stored in the pm > field of a device_driver structure. This field is of type const, so > dev_pm_ops structures having similar properties can be declared const > too. > > Size details after cross compiling the .o file for arm > architecture. > > File size before: drivers/usb/musb/omap2430.o >text data bss dec hex filename >4141 400 8454911c5 usb/musb/omap2430.o > > File size after: drivers/usb/musb/omap2430.o >text data bss dec hex filename >4333 200 8454111bd usb/musb/omap2430.o > > Signed-off-by: Bhumika Goyal Applied. Thanks. [b-...@ti.com: added omap2430 in commit subject prefix] -Bin. > --- > drivers/usb/musb/omap2430.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c > index 8b73214..456f3e6 100644 > --- a/drivers/usb/musb/omap2430.c > +++ b/drivers/usb/musb/omap2430.c > @@ -575,7 +575,7 @@ static int omap2430_runtime_resume(struct device *dev) > return 0; > } > > -static struct dev_pm_ops omap2430_pm_ops = { > +static const struct dev_pm_ops omap2430_pm_ops = { > .runtime_suspend = omap2430_runtime_suspend, > .runtime_resume = omap2430_runtime_resume, > }; > -- > 1.9.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/4] musb: sunxi: add support for the variant in H3/V3s SoC
On Fri, Jan 06, 2017 at 02:57:15PM +0100, Maxime Ripard wrote: > On Tue, Jan 03, 2017 at 11:25:32PM +0800, Icenowy Zheng wrote: > > Allwinner H3/V3s features a variant of MUSB controller, which lacks one > > endpoint. > > > > Add support for it. > > > > Signed-off-by: Icenowy Zheng > > Acked-by: Maxime Ripard Applied. Thanks. -Bin. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCHv2] usb: musb: Add support for optional VBUS irq to dsps glue layer
On Thu, Jan 12, 2017 at 01:40:46PM -0800, Tony Lindgren wrote: > We can now configure the PMIC interrupt to provide us VBUS > events. In that case we don't need to constantly poll the > status and can make it optional. This is only wired up > for the mini-B interface on beaglebone. > > Note that eventually we should get also the connect status > for the host interface when the am335x internal PM coprocessor > provides us with an IRQ chip. For now, we still need to poll > for the host mode status. > > Signed-off-by: Tony Lindgren Applied. Thanks. -Bin. > --- > > Changes since v1: > > - Updated based on comments from Bin mostly to limit to peripheral > mode only > > --- > drivers/usb/musb/musb_dsps.c | 117 > ++- > 1 file changed, 93 insertions(+), 24 deletions(-) > > diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c > --- a/drivers/usb/musb/musb_dsps.c > +++ b/drivers/usb/musb/musb_dsps.c > @@ -118,6 +118,7 @@ struct dsps_glue { > struct device *dev; > struct platform_device *musb; /* child musb pdev */ > const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ > + int vbus_irq; /* optional vbus irq */ > struct timer_list timer;/* otg_workaround timer */ > unsigned long last_timer;/* last timer data for each instance */ > bool sw_babble_enabled; > @@ -145,6 +146,29 @@ static const struct debugfs_reg32 dsps_musb_regs[] = { > { "mode", 0xe8 }, > }; > > +static void dsps_mod_timer(struct dsps_glue *glue, int wait_ms) > +{ > + int wait; > + > + if (wait_ms < 0) > + wait = msecs_to_jiffies(glue->wrp->poll_timeout); > + else > + wait = msecs_to_jiffies(wait_ms); > + > + mod_timer(&glue->timer, jiffies + wait); > +} > + > +/* > + * If no vbus irq from the PMIC is configured, we need to poll VBUS status. > + */ > +static void dsps_mod_timer_optional(struct dsps_glue *glue) > +{ > + if (glue->vbus_irq) > + return; > + > + dsps_mod_timer(glue, -1); > +} > + > /** > * dsps_musb_enable - enable interrupts > */ > @@ -167,8 +191,7 @@ static void dsps_musb_enable(struct musb *musb) > /* start polling for ID change in dual-role idle mode */ > if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && > musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) > - mod_timer(&glue->timer, jiffies + > - msecs_to_jiffies(wrp->poll_timeout)); > + dsps_mod_timer(glue, -1); > } > > /** > @@ -199,6 +222,9 @@ static int dsps_check_status(struct musb *musb, void > *unused) > u8 devctl; > int skip_session = 0; > > + if (glue->vbus_irq) > + del_timer(&glue->timer); > + > /* >* We poll because DSPS IP's won't expose several OTG-critical >* status change events (from the transceiver) otherwise. > @@ -209,8 +235,7 @@ static int dsps_check_status(struct musb *musb, void > *unused) > > switch (musb->xceiv->otg->state) { > case OTG_STATE_A_WAIT_VRISE: > - mod_timer(&glue->timer, jiffies + > - msecs_to_jiffies(wrp->poll_timeout)); > + dsps_mod_timer_optional(glue); > break; > case OTG_STATE_A_WAIT_BCON: > musb_writeb(musb->mregs, MUSB_DEVCTL, 0); > @@ -219,17 +244,19 @@ static int dsps_check_status(struct musb *musb, void > *unused) > > case OTG_STATE_A_IDLE: > case OTG_STATE_B_IDLE: > - if (devctl & MUSB_DEVCTL_BDEVICE) { > - musb->xceiv->otg->state = OTG_STATE_B_IDLE; > - MUSB_DEV_MODE(musb); > - } else { > - musb->xceiv->otg->state = OTG_STATE_A_IDLE; > - MUSB_HST_MODE(musb); > + if (!glue->vbus_irq) { > + if (devctl & MUSB_DEVCTL_BDEVICE) { > + musb->xceiv->otg->state = OTG_STATE_B_IDLE; > + MUSB_DEV_MODE(musb); > + } else { > + musb->xceiv->otg->state = OTG_STATE_A_IDLE; > + MUSB_HST_MODE(musb); > + } > + if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session) > + musb_writeb(mregs, MUSB_DEVCTL, > + MUSB_DEVCTL_SESSION); > } > - if (!(devctl & MUSB_DEVCTL_SESSION) && !skip_session) > - musb_writeb(mregs, MUSB_DEVCTL, MUSB_DEVCTL_SESSION); > - mod_timer(&glue->timer, jiffies + > - msecs_to_jiffies(wrp->poll_timeout)); > + dsps_mod_timer_optional(glue); > break; > case OTG_STATE_A_WAIT_VFALL: > musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; > @@ -332,15 +359,13 @@
[PATCH 2/2] tools: usb: ffs-test: add SS descriptors
Without SS descriptors, we have no possibility of running on SS controllers such as DWC3. Signed-off-by: Felipe Balbi --- tools/usb/ffs-test.c | 50 +- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c index 64fc72acc892..95dd14648ba5 100644 --- a/tools/usb/ffs-test.c +++ b/tools/usb/ffs-test.c @@ -110,16 +110,25 @@ static const struct { struct usb_functionfs_descs_head_v2 header; __le32 fs_count; __le32 hs_count; + __le32 ss_count; struct { struct usb_interface_descriptor intf; struct usb_endpoint_descriptor_no_audio sink; struct usb_endpoint_descriptor_no_audio source; } __attribute__((packed)) fs_descs, hs_descs; + struct { + struct usb_interface_descriptor intf; + struct usb_endpoint_descriptor_no_audio sink; + struct usb_ss_ep_comp_descriptor sink_comp; + struct usb_endpoint_descriptor_no_audio source; + struct usb_ss_ep_comp_descriptor source_comp; + } ss_descs; } __attribute__((packed)) descriptors = { .header = { .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2), .flags = cpu_to_le32(FUNCTIONFS_HAS_FS_DESC | -FUNCTIONFS_HAS_HS_DESC), +FUNCTIONFS_HAS_HS_DESC | +FUNCTIONFS_HAS_SS_DESC), .length = cpu_to_le32(sizeof descriptors), }, .fs_count = cpu_to_le32(3), @@ -171,6 +180,45 @@ static const struct { .bInterval = 1, /* NAK every 1 uframe */ }, }, + .ss_count = cpu_to_le32(5), + .ss_descs = { + .intf = { + .bLength = sizeof descriptors.fs_descs.intf, + .bDescriptorType = USB_DT_INTERFACE, + .bNumEndpoints = 2, + .bInterfaceClass = USB_CLASS_VENDOR_SPEC, + .iInterface = 1, + }, + .sink = { + .bLength = sizeof descriptors.hs_descs.sink, + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 1 | USB_DIR_IN, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), + }, + .sink_comp = { + .bLength = USB_DT_SS_EP_COMP_SIZE, + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + .bMaxBurst = 0, + .bmAttributes = 0, + .wBytesPerInterval = 0, + }, + .source = { + .bLength = sizeof descriptors.hs_descs.source, + .bDescriptorType = USB_DT_ENDPOINT, + .bEndpointAddress = 2 | USB_DIR_OUT, + .bmAttributes = USB_ENDPOINT_XFER_BULK, + .wMaxPacketSize = cpu_to_le16(1024), + .bInterval = 1, /* NAK every 1 uframe */ + }, + .source_comp = { + .bLength = USB_DT_SS_EP_COMP_SIZE, + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, + .bMaxBurst = 0, + .bmAttributes = 0, + .wBytesPerInterval = 0, + }, + }, }; static size_t descs_to_legacy(void **legacy, const void *descriptors_v2) -- 2.11.0.295.gd7dffce1ce -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] tools: usb: ffs-test: switch to _DEFAULT_SOURCE
_BSD_SOURCE is deprecated and gives a build warning. Let's use _DEFAULT_SOURCE instead. Signed-off-by: Felipe Balbi --- tools/usb/ffs-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/usb/ffs-test.c b/tools/usb/ffs-test.c index 88d5e71be044..64fc72acc892 100644 --- a/tools/usb/ffs-test.c +++ b/tools/usb/ffs-test.c @@ -22,7 +22,7 @@ /* $(CROSS_COMPILE)cc -Wall -Wextra -g -o ffs-test ffs-test.c -lpthread */ -#define _BSD_SOURCE /* for endian.h */ +#define _DEFAULT_SOURCE /* for endian.h */ #include #include -- 2.11.0.295.gd7dffce1ce -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3] USB: Add uPD78F0730 USB to Serial Adaptor Driver
Hi Johan, > I think it's right to keep them as in the current version of the patch > (i.e. active high) which is accordance with the datasheet, but if > possible you should verify the levels when using hardware flow control > to be certain that the polarity is not inverted when enabling hardware > flow control. It seems to me that CTSRTS flow control is not implemented in the device I have. I tried to send lots of data to cause level change of the RTS signal with no success. Also I tried to: 1. open port; 2. disable CTSRTS flow control; 3. set RTS to a specific level; 4. enable CTSRTS flow control; 5. send some data. I tried the sequence above with RTS set and reset, and I can conclude that step 4 doesn't affect RTS signal at all. Best regards, Maksim. -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
usb: gadger: f_fs: Do not copy past descriptor end.
Endpoint descriptors come in 2 sizes, struct usb_endpoint_descriptor being the largest. Use bLength to stop on endpoint descriptor boundary, and not 2 bytes too far. Signed-off-by: Vincent Pelletier --- drivers/usb/gadget/function/f_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 5490fc51638e..5c91a6f4613b 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1230,7 +1230,7 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code, desc = epfile->ep->descs[desc_idx]; spin_unlock_irq(&epfile->ffs->eps_lock); - ret = copy_to_user((void *)value, desc, sizeof(*desc)); + ret = copy_to_user((void *)value, desc, desc->bLength); if (ret) ret = -EFAULT; return ret; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[try2] usb: gadger: f_fs: Do not copy past descriptor end.
Changes since try1: - do not involve sizeof(*desc) in copy length. - remove explicit cast to size_t, which was needed to compare bLength to sizeof(). -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html