Re: [RESEND PATCH v2 2/2] usb: xhci-mtk: add an optional xhci_ck clock
On 23/08/2019 08:40, Chunfeng Yun wrote: > Some SoCs may have an optional clock xhci_ck (125M or 200M), it > usually uses the same PLL as sys_ck, so support it. > > Signed-off-by: Chunfeng Yun Reviewed-by: Matthias Brugger > --- > v2 no changes > --- > drivers/usb/host/xhci-mtk.c | 13 + > drivers/usb/host/xhci-mtk.h | 1 + > 2 files changed, 14 insertions(+) > > diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c > index 026fe18972d3..b18a6baef204 100644 > --- a/drivers/usb/host/xhci-mtk.c > +++ b/drivers/usb/host/xhci-mtk.c > @@ -216,6 +216,10 @@ static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) > return PTR_ERR(mtk->sys_clk); > } > > + mtk->xhci_clk = devm_clk_get_optional(dev, "xhci_ck"); > + if (IS_ERR(mtk->xhci_clk)) > + return PTR_ERR(mtk->xhci_clk); > + > mtk->ref_clk = devm_clk_get_optional(dev, "ref_ck"); > if (IS_ERR(mtk->ref_clk)) > return PTR_ERR(mtk->ref_clk); > @@ -244,6 +248,12 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) > goto sys_clk_err; > } > > + ret = clk_prepare_enable(mtk->xhci_clk); > + if (ret) { > + dev_err(mtk->dev, "failed to enable xhci_clk\n"); > + goto xhci_clk_err; > + } > + > ret = clk_prepare_enable(mtk->mcu_clk); > if (ret) { > dev_err(mtk->dev, "failed to enable mcu_clk\n"); > @@ -261,6 +271,8 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) > dma_clk_err: > clk_disable_unprepare(mtk->mcu_clk); > mcu_clk_err: > + clk_disable_unprepare(mtk->xhci_clk); > +xhci_clk_err: > clk_disable_unprepare(mtk->sys_clk); > sys_clk_err: > clk_disable_unprepare(mtk->ref_clk); > @@ -272,6 +284,7 @@ static void xhci_mtk_clks_disable(struct xhci_hcd_mtk > *mtk) > { > clk_disable_unprepare(mtk->dma_clk); > clk_disable_unprepare(mtk->mcu_clk); > + clk_disable_unprepare(mtk->xhci_clk); > clk_disable_unprepare(mtk->sys_clk); > clk_disable_unprepare(mtk->ref_clk); > } > diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h > index 8be8c5f7ff62..5ac458b7d2e0 100644 > --- a/drivers/usb/host/xhci-mtk.h > +++ b/drivers/usb/host/xhci-mtk.h > @@ -139,6 +139,7 @@ struct xhci_hcd_mtk { > struct regulator *vusb33; > struct regulator *vbus; > struct clk *sys_clk;/* sys and mac clock */ > + struct clk *xhci_clk; > struct clk *ref_clk; > struct clk *mcu_clk; > struct clk *dma_clk; >
Re: [v2 PATCH 6/6] usb: mtu3: get optional clock by devm_clk_get_optional()
On 10/04/2019 08:47, Chunfeng Yun wrote: > Use devm_clk_get_optional() to get optional clock > > Signed-off-by: Chunfeng Yun Reviewed-by: Matthias Brugger > --- > v2: new patch, merged into this series from > https://patchwork.kernel.org/patch/10878235/ > --- > drivers/usb/mtu3/mtu3_plat.c | 19 +++ > 1 file changed, 3 insertions(+), 16 deletions(-) > > diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c > index e086630e41a9..745a1da5c9c0 100644 > --- a/drivers/usb/mtu3/mtu3_plat.c > +++ b/drivers/usb/mtu3/mtu3_plat.c > @@ -210,19 +210,6 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb) > mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN); > } > > -/* ignore the error if the clock does not exist */ > -static struct clk *get_optional_clk(struct device *dev, const char *id) > -{ > - struct clk *opt_clk; > - > - opt_clk = devm_clk_get(dev, id); > - /* ignore error number except EPROBE_DEFER */ > - if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER)) > - opt_clk = NULL; > - > - return opt_clk; > -} > - > static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk > *ssusb) > { > struct device_node *node = pdev->dev.of_node; > @@ -245,15 +232,15 @@ static int get_ssusb_rscs(struct platform_device *pdev, > struct ssusb_mtk *ssusb) > return PTR_ERR(ssusb->sys_clk); > } > > - ssusb->ref_clk = get_optional_clk(dev, "ref_ck"); > + ssusb->ref_clk = devm_clk_get_optional(dev, "ref_ck"); > if (IS_ERR(ssusb->ref_clk)) > return PTR_ERR(ssusb->ref_clk); > > - ssusb->mcu_clk = get_optional_clk(dev, "mcu_ck"); > + ssusb->mcu_clk = devm_clk_get_optional(dev, "mcu_ck"); > if (IS_ERR(ssusb->mcu_clk)) > return PTR_ERR(ssusb->mcu_clk); > > - ssusb->dma_clk = get_optional_clk(dev, "dma_ck"); > + ssusb->dma_clk = devm_clk_get_optional(dev, "dma_ck"); > if (IS_ERR(ssusb->dma_clk)) > return PTR_ERR(ssusb->dma_clk); > >
Re: [PATCH v2 3/4] usb: musb: Extract set toggle as a separate interface
On 15/01/2019 02:43, min@mediatek.com wrote: > From: Min Guo > > Add a common interface for set data toggle > > Signed-off-by: Min Guo > --- > drivers/usb/musb/musb_host.c | 37 +++-- > 1 file changed, 23 insertions(+), 14 deletions(-) > > diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c > index b59ce9a..16d0ba4 100644 > --- a/drivers/usb/musb/musb_host.c > +++ b/drivers/usb/musb/musb_host.c > @@ -306,6 +306,25 @@ static inline void musb_save_toggle(struct musb_qh *qh, > int is_in, > usb_settoggle(urb->dev, qh->epnum, !is_in, csr ? 1 : 0); > } > > +static inline u16 musb_set_toggle(struct musb_qh *qh, int is_in, > + struct urb *urb) > +{ > + u16 csr = 0; > + u16 toggle = 0; > + > + toggle = usb_gettoggle(urb->dev, qh->epnum, !is_in); > + > + if (is_in) > + csr = toggle ? (MUSB_RXCSR_H_WR_DATATOGGLE > + | MUSB_RXCSR_H_DATATOGGLE) : 0; > + else > + csr = toggle ? (MUSB_TXCSR_H_WR_DATATOGGLE > + | MUSB_TXCSR_H_DATATOGGLE) > + : MUSB_TXCSR_CLRDATATOG; Can we switch the if and use is_out logic as function parameter. This would make the code easier to understand. Regards, Matthias > + > + return csr; > +} > + > /* > * Advance this hardware endpoint's queue, completing the specified URB and > * advancing to either the next URB queued to that qh, or else invalidating > @@ -772,13 +791,8 @@ static void musb_ep_program(struct musb *musb, u8 epnum, > ); > csr |= MUSB_TXCSR_MODE; > > - if (!hw_ep->tx_double_buffered) { > - if (usb_gettoggle(urb->dev, qh->epnum, 1)) > - csr |= MUSB_TXCSR_H_WR_DATATOGGLE > - | MUSB_TXCSR_H_DATATOGGLE; > - else > - csr |= MUSB_TXCSR_CLRDATATOG; > - } > + if (!hw_ep->tx_double_buffered) > + csr |= musb_set_toggle(qh, !is_out, urb); > > musb_writew(epio, MUSB_TXCSR, csr); > /* REVISIT may need to clear FLUSHFIFO ... */ > @@ -860,17 +874,12 @@ static void musb_ep_program(struct musb *musb, u8 epnum, > > /* IN/receive */ > } else { > - u16 csr; > + u16 csr = 0; > > if (hw_ep->rx_reinit) { > musb_rx_reinit(musb, qh, epnum); > + csr |= musb_set_toggle(qh, !is_out, urb); > > - /* init new state: toggle and NYET, maybe DMA later */ > - if (usb_gettoggle(urb->dev, qh->epnum, 0)) > - csr = MUSB_RXCSR_H_WR_DATATOGGLE > - | MUSB_RXCSR_H_DATATOGGLE; > - else > - csr = 0; > if (qh->type == USB_ENDPOINT_XFER_INT) > csr |= MUSB_RXCSR_DISNYET; > >
Re: [PATCH v2 3/3] dt-bindings: phy-mtk-tphy: add properties for U2 slew rate calibrate
On 03/12/2018 06:25 AM, Chunfeng Yun wrote: > Add two properties of ref_clk and coefficient used by U2 slew rate > calibrate which may vary on different SoCs > > Signed-off-by: Chunfeng Yun Reviewed-by: Matthias Brugger > --- > Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt | 4 > 1 file changed, 4 insertions(+) > > diff --git a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt > b/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt > index 41e09ed..0d34b2b 100644 > --- a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt > +++ b/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt > @@ -27,6 +27,10 @@ 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. > + - mediatek,src-ref-clk-mhz : frequency of reference clock for slew rate > + calibrate > + - mediatek,src-coef : coefficient for slew rate calibrate, depends on > + SoC process > > Required properties (port (child) node): > - reg: address and length of the register set for the port. > -- 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 2/3] phy: phy-mtk-tphy: add configurable parameters for slew rate calibrate
On 03/12/2018 06:25 AM, Chunfeng Yun wrote: > There are two parameters, ref_clk and coefficient, for U2 slew rate > calibrate which may vary on different SoCs, here allow them to be > configurable > > Signed-off-by: Chunfeng Yun Reviewed-by: Matthias Brugger > --- > drivers/phy/mediatek/phy-mtk-tphy.c | 20 +++- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c > b/drivers/phy/mediatek/phy-mtk-tphy.c > index 6073c25..38c281b 100644 > --- a/drivers/phy/mediatek/phy-mtk-tphy.c > +++ b/drivers/phy/mediatek/phy-mtk-tphy.c > @@ -306,6 +306,8 @@ struct mtk_tphy { > const struct mtk_phy_pdata *pdata; > struct mtk_phy_instance **phys; > int nphys; > + int src_ref_clk; /* MHZ, reference clock for slew rate calibrate */ > + int src_coef; /* coefficient for slew rate calibrate */ > }; > > static void hs_slew_rate_calibrate(struct mtk_tphy *tphy, > @@ -360,16 +362,17 @@ static void hs_slew_rate_calibrate(struct mtk_tphy > *tphy, > writel(tmp, fmreg + U3P_U2FREQ_FMMONR1); > > if (fm_out) { > - /* ( 1024 / FM_OUT ) x reference clock frequency x 0.028 */ > - tmp = U3P_FM_DET_CYCLE_CNT * U3P_REF_CLK * U3P_SLEW_RATE_COEF; > - tmp /= fm_out; > + /* ( 1024 / FM_OUT ) x reference clock frequency x coef */ > + tmp = tphy->src_ref_clk * tphy->src_coef; > + tmp = (tmp * U3P_FM_DET_CYCLE_CNT) / fm_out; > calibration_val = DIV_ROUND_CLOSEST(tmp, U3P_SR_COEF_DIVISOR); > } else { > /* if FM detection fail, set default value */ > calibration_val = 4; > } > - dev_dbg(tphy->dev, "phy:%d, fm_out:%d, calib:%d\n", > - instance->index, fm_out, calibration_val); > + dev_dbg(tphy->dev, "phy:%d, fm_out:%d, calib:%d (clk:%d, coef:%d)\n", > + instance->index, fm_out, calibration_val, > + tphy->src_ref_clk, tphy->src_coef); > > /* set HS slew rate */ > tmp = readl(com + U3P_USBPHYACR5); > @@ -1041,6 +1044,13 @@ static int mtk_tphy_probe(struct platform_device *pdev) > tphy->u3phya_ref = NULL; > } > > + tphy->src_ref_clk = U3P_REF_CLK; > + tphy->src_coef = U3P_SLEW_RATE_COEF; > + /* update parameters of slew rate calibrate if exist */ > + device_property_read_u32(dev, "mediatek,src-ref-clk-mhz", > + &tphy->src_ref_clk); > + device_property_read_u32(dev, "mediatek,src-coef", &tphy->src_coef); > + > port = 0; > for_each_child_of_node(np, child_np) { > struct mtk_phy_instance *instance; > -- 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 9/9] dt-bindings: usb: mtk-xhci: remove dummy clocks and add optional ones
On 10/13/2017 10:26 AM, Chunfeng Yun wrote: Remove dummy clocks for usb wakeup and add optional ones for MCU_BUS_CK and DMA_BUS_CK. Signed-off-by: Chunfeng Yun Acked-by: Rob Herring --- Reviewed-by: .../devicetree/bindings/usb/mediatek,mtk-xhci.txt | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt index 2d9b459..3059596 100644 --- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt +++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt @@ -26,10 +26,11 @@ Required properties: - clocks : a list of phandle + clock-specifier pairs, one for each 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 + "sys_ck": controller clock used by normal mode, + the following ones are optional: + "ref_ck": reference clock used by low power mode etc, + "mcu_ck": mcu_bus clock for register access, + "dma_ck": dma_bus clock for data transfer by DMA - phys : a list of phandle + phy specifier pairs @@ -57,9 +58,7 @@ usb30: usb@1127 { 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"; + clock-names = "sys_ck", "ref_ck"; phys = <&phy_port0 PHY_TYPE_USB3>, <&phy_port1 PHY_TYPE_USB2>; vusb33-supply = <&mt6397_vusb_reg>; @@ -91,9 +90,8 @@ Required properties: - clocks : a list of phandle + clock-specifier pairs, one for each entry in clock-names - - clock-names : must be - "sys_ck": for clock of xHCI MAC - "ref_ck": for reference clock of xHCI MAC + - clock-names : must contain "sys_ck", and the following ones are optional: + "ref_ck", "mcu_ck" and "dma_ck" Optional properties: - vbus-supply : reference to the VBUS regulator; -- 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 6/9] usb: xhci-mtk: add optional mcu and dma bus clocks
On 10/13/2017 10:26 AM, Chunfeng Yun wrote: There are mcu_bus and dma_bus clocks needed to be controlled by driver on some SoCs, so add them as optional ones Signed-off-by: Chunfeng Yun --- Reviewed-by: Matthias Brugger drivers/usb/host/xhci-mtk.c | 79 --- drivers/usb/host/xhci-mtk.h |2 ++ 2 files changed, 62 insertions(+), 19 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index d60463c..e5caabe 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -221,6 +221,44 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) return xhci_mtk_host_enable(mtk); } +/* ignore the error if the clock does not exist */ +static struct clk *optional_clk_get(struct device *dev, const char *id) +{ + struct clk *opt_clk; + + opt_clk = devm_clk_get(dev, id); + /* ignore error number except EPROBE_DEFER */ + if (IS_ERR(opt_clk) && (PTR_ERR(opt_clk) != -EPROBE_DEFER)) + opt_clk = NULL; + + return opt_clk; +} + +static int xhci_mtk_clks_get(struct xhci_hcd_mtk *mtk) +{ + struct device *dev = mtk->dev; + + mtk->sys_clk = devm_clk_get(dev, "sys_ck"); + if (IS_ERR(mtk->sys_clk)) { + dev_err(dev, "fail to get sys_ck\n"); + return PTR_ERR(mtk->sys_clk); + } + + mtk->ref_clk = optional_clk_get(dev, "ref_ck"); + if (IS_ERR(mtk->ref_clk)) + return PTR_ERR(mtk->ref_clk); + + mtk->mcu_clk = optional_clk_get(dev, "mcu_ck"); + if (IS_ERR(mtk->mcu_clk)) + return PTR_ERR(mtk->mcu_clk); + + mtk->dma_clk = optional_clk_get(dev, "dma_ck"); + if (IS_ERR(mtk->dma_clk)) + return PTR_ERR(mtk->dma_clk); + + return 0; +} + static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) { int ret; @@ -237,16 +275,34 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) goto sys_clk_err; } + ret = clk_prepare_enable(mtk->mcu_clk); + if (ret) { + dev_err(mtk->dev, "failed to enable mcu_clk\n"); + goto mcu_clk_err; + } + + ret = clk_prepare_enable(mtk->dma_clk); + if (ret) { + dev_err(mtk->dev, "failed to enable dma_clk\n"); + goto dma_clk_err; + } + return 0; +dma_clk_err: + clk_disable_unprepare(mtk->mcu_clk); +mcu_clk_err: + clk_disable_unprepare(mtk->sys_clk); sys_clk_err: clk_disable_unprepare(mtk->ref_clk); ref_clk_err: - return -EINVAL; + return ret; } static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk) { + clk_disable_unprepare(mtk->dma_clk); + clk_disable_unprepare(mtk->mcu_clk); clk_disable_unprepare(mtk->sys_clk); clk_disable_unprepare(mtk->ref_clk); } @@ -529,24 +585,9 @@ static int xhci_mtk_probe(struct platform_device *pdev) return PTR_ERR(mtk->vusb33); } - mtk->sys_clk = devm_clk_get(dev, "sys_ck"); - if (IS_ERR(mtk->sys_clk)) { - dev_err(dev, "fail to get sys_ck\n"); - return PTR_ERR(mtk->sys_clk); - } - - /* -* reference clock is usually a "fixed-clock", make it optional -* for backward compatibility and ignore the error if it does -* not exist. -*/ - mtk->ref_clk = devm_clk_get(dev, "ref_ck"); - if (IS_ERR(mtk->ref_clk)) { - if (PTR_ERR(mtk->ref_clk) == -EPROBE_DEFER) - return -EPROBE_DEFER; - - mtk->ref_clk = NULL; - } + ret = xhci_mtk_clks_get(mtk); + if (ret) + return ret; mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable"); /* optional property, ignore the error if it does not exist */ diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h index 67783a7..45ff5c6 100644 --- a/drivers/usb/host/xhci-mtk.h +++ b/drivers/usb/host/xhci-mtk.h @@ -126,6 +126,8 @@ struct xhci_hcd_mtk { struct regulator *vbus; struct clk *sys_clk;/* sys and mac clock */ struct clk *ref_clk; + struct clk *mcu_clk; + struct clk *dma_clk; struct regmap *pericfg; struct phy **phys; int num_phys; -- 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 5/9] usb: xhci-mtk: remove dummy wakeup debounce clocks
On 10/13/2017 10:26 AM, Chunfeng Yun wrote: The wakeup debounce clocks for each ports in fact are not needed, so remove them. Signed-off-by: Chunfeng Yun --- Reviewed-by: Matthias Brugger drivers/usb/host/xhci-mtk.c | 33 - drivers/usb/host/xhci-mtk.h |2 -- 2 files changed, 35 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 97ba51e..d60463c 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -237,25 +237,8 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) goto sys_clk_err; } - if (mtk->wakeup_src) { - ret = clk_prepare_enable(mtk->wk_deb_p0); - if (ret) { - dev_err(mtk->dev, "failed to enable wk_deb_p0\n"); - goto usb_p0_err; - } - - ret = clk_prepare_enable(mtk->wk_deb_p1); - if (ret) { - dev_err(mtk->dev, "failed to enable wk_deb_p1\n"); - goto usb_p1_err; - } - } return 0; -usb_p1_err: - clk_disable_unprepare(mtk->wk_deb_p0); -usb_p0_err: - clk_disable_unprepare(mtk->sys_clk); sys_clk_err: clk_disable_unprepare(mtk->ref_clk); ref_clk_err: @@ -264,10 +247,6 @@ static int xhci_mtk_clks_enable(struct xhci_hcd_mtk *mtk) static void xhci_mtk_clks_disable(struct xhci_hcd_mtk *mtk) { - if (mtk->wakeup_src) { - clk_disable_unprepare(mtk->wk_deb_p1); - clk_disable_unprepare(mtk->wk_deb_p0); - } clk_disable_unprepare(mtk->sys_clk); clk_disable_unprepare(mtk->ref_clk); } @@ -371,18 +350,6 @@ static int usb_wakeup_of_property_parse(struct xhci_hcd_mtk *mtk, if (!mtk->wakeup_src) return 0; - mtk->wk_deb_p0 = devm_clk_get(dev, "wakeup_deb_p0"); - if (IS_ERR(mtk->wk_deb_p0)) { - dev_err(dev, "fail to get wakeup_deb_p0\n"); - return PTR_ERR(mtk->wk_deb_p0); - } - - mtk->wk_deb_p1 = devm_clk_get(dev, "wakeup_deb_p1"); - if (IS_ERR(mtk->wk_deb_p1)) { - dev_err(dev, "fail to get wakeup_deb_p1\n"); - return PTR_ERR(mtk->wk_deb_p1); - } - mtk->pericfg = syscon_regmap_lookup_by_phandle(dn, "mediatek,syscon-wakeup"); if (IS_ERR(mtk->pericfg)) { diff --git a/drivers/usb/host/xhci-mtk.h b/drivers/usb/host/xhci-mtk.h index db55a12..67783a7 100644 --- a/drivers/usb/host/xhci-mtk.h +++ b/drivers/usb/host/xhci-mtk.h @@ -126,8 +126,6 @@ struct xhci_hcd_mtk { 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; struct phy **phys; int num_phys; -- 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 3/4] dt-bindings: mt8173-mtu3: add generic compatible and rename file
On 08/11/2017 09:00 AM, Chunfeng Yun wrote: On Thu, 2017-08-10 at 21:54 -0500, Rob Herring wrote: On Tue, Aug 08, 2017 at 01:42:51PM +0800, Chunfeng Yun wrote: The mt8173-mtu3.txt actually holds the bindings for all mediatek SoCs with usb3 DRD IP, so add a generic compatible and change the name to mtu3.txt. Signed-off-by: Chunfeng Yun --- .../bindings/usb/{mt8173-mtu3.txt => mtu3.txt} |6 -- 1 file changed, 4 insertions(+), 2 deletions(-) rename Documentation/devicetree/bindings/usb/{mt8173-mtu3.txt => mtu3.txt} (95%) diff --git a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt b/Documentation/devicetree/bindings/usb/mtu3.txt similarity index 95% rename from Documentation/devicetree/bindings/usb/mt8173-mtu3.txt rename to Documentation/devicetree/bindings/usb/mtu3.txt index 1d7c3bc..832741d 100644 --- a/Documentation/devicetree/bindings/usb/mt8173-mtu3.txt +++ b/Documentation/devicetree/bindings/usb/mtu3.txt mediatek,mtu3.txt Ok @@ -1,7 +1,9 @@ The device node for Mediatek USB3.0 DRD controller Required properties: - - compatible : should be "mediatek,mt8173-mtu3" + - compatible : should be one of + "mediatek,mt8173-mtu3" (deprecated, use "mediatek,mtu3" instead), NAK. You can add generic compatibles, but you need SoC specific ones in addition. It's for backward compatibility I think backwards compatibility should be in the driver but not in the binding description. Apart from that device tree files will need to provide a SoC specific binding apart from the generic one, for example: "mediatek,mt8173-mtu3", "mediatek,mtu3": for mt8173 "mediatek,mt7623-mtu3", "mediatek,mtu3": for mt6723 This is needed to cover possible bugs/features that can be found in the future for a specific SoC. The driver can match just against the generic binding and will only implement a match against the SoC specific one if a bug/feature is present. Makes sense? Regards, Matthias -- 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: mtu3: Handle return value of clk_prepare_enable
On 09/06/17 14:03, Arvind Yadav wrote: clk_prepare_enable() can fail here and we must check its return value. Signed-off-by: Arvind Yadav --- drivers/usb/mtu3/mtu3_plat.c | 23 --- 1 file changed, 20 insertions(+), 3 deletions(-) Reviewed-by: Matthias Brugger diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c index 42550c7..0d3ebb3 100644 --- a/drivers/usb/mtu3/mtu3_plat.c +++ b/drivers/usb/mtu3/mtu3_plat.c @@ -458,6 +458,7 @@ static int __maybe_unused mtu3_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct ssusb_mtk *ssusb = platform_get_drvdata(pdev); + int ret; dev_dbg(dev, "%s\n", __func__); @@ -465,12 +466,28 @@ static int __maybe_unused mtu3_resume(struct device *dev) return 0; ssusb_wakeup_disable(ssusb); - clk_prepare_enable(ssusb->sys_clk); - clk_prepare_enable(ssusb->ref_clk); - ssusb_phy_power_on(ssusb); + ret = clk_prepare_enable(ssusb->sys_clk); + if (ret) + goto err_sys_clk; + + ret = clk_prepare_enable(ssusb->ref_clk); + if (ret) + goto err_ref_clk; + + ret = ssusb_phy_power_on(ssusb); + if (ret) + goto err_power_on; + ssusb_host_enable(ssusb); return 0; + +err_power_on: + clk_disable_unprepare(ssusb->ref_clk); +err_ref_clk: + clk_disable_unprepare(ssusb->sys_clk); +err_sys_clk: + return ret; } static const struct dev_pm_ops mtu3_pm_ops = { -- 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 v5 1/9] phy: phy-mt65xx-usb3: improve RX detection stable time
I took DTS parts for v4.12-next. Sorry for the late response. Matthias On 06/04/17 12:28, Kishon Vijay Abraham I wrote: On Friday 31 March 2017 01:05 PM, Chunfeng Yun wrote: The default value of RX detection stable time is 10us, and this margin is too big for some critical cases which cause U3 link fail and link to U2(probability is about 1%). So change it to 5us. merged all the phy patches in this series to linux-phy -next. Thanks Kishon Signed-off-by: Chunfeng Yun --- drivers/phy/phy-mt65xx-usb3.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/drivers/phy/phy-mt65xx-usb3.c b/drivers/phy/phy-mt65xx-usb3.c index d972067..fe2392a 100644 --- a/drivers/phy/phy-mt65xx-usb3.c +++ b/drivers/phy/phy-mt65xx-usb3.c @@ -112,6 +112,14 @@ #define P3D_RG_CDR_BIR_LTD0 GENMASK(12, 8) #define P3D_RG_CDR_BIR_LTD0_VAL(x)((0x1f & (x)) << 8) +#define U3P_U3_PHYD_RXDET1 (SSUSB_SIFSLV_U3PHYD_BASE + 0x128) +#define P3D_RG_RXDET_STB2_SET GENMASK(17, 9) +#define P3D_RG_RXDET_STB2_SET_VAL(x) ((0x1ff & (x)) << 9) + +#define U3P_U3_PHYD_RXDET2 (SSUSB_SIFSLV_U3PHYD_BASE + 0x12c) +#define P3D_RG_RXDET_STB2_SET_P3 GENMASK(8, 0) +#define P3D_RG_RXDET_STB2_SET_P3_VAL(x)(0x1ff & (x)) + #define U3P_XTALCTL3 (SSUSB_SIFSLV_SPLLC + 0x0018) #define XC3_RG_U3_XTAL_RX_PWD BIT(9) #define XC3_RG_U3_FRC_XTAL_RX_PWD BIT(8) @@ -295,6 +303,16 @@ static void phy_instance_init(struct mt65xx_u3phy *u3phy, tmp |= P3D_RG_CDR_BIR_LTD0_VAL(0xc) | P3D_RG_CDR_BIR_LTD1_VAL(0x3); writel(tmp, port_base + U3P_PHYD_CDR1); + tmp = readl(port_base + U3P_U3_PHYD_RXDET1); + tmp &= ~P3D_RG_RXDET_STB2_SET; + tmp |= P3D_RG_RXDET_STB2_SET_VAL(0x10); + writel(tmp, port_base + U3P_U3_PHYD_RXDET1); + + tmp = readl(port_base + U3P_U3_PHYD_RXDET2); + tmp &= ~P3D_RG_RXDET_STB2_SET_P3; + tmp |= P3D_RG_RXDET_STB2_SET_P3_VAL(0x10); + writel(tmp, port_base + U3P_U3_PHYD_RXDET2); + dev_dbg(u3phy->dev, "%s(%d)\n", __func__, index); } -- 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/6] usb: mtu3: add reference clock
On 01/20/2017 03:20 AM, Chunfeng Yun wrote: On Thu, 2017-01-19 at 13:22 +0100, Matthias Brugger wrote: On 18/01/17 07:08, Chunfeng Yun wrote: 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(-) [...] @@ -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); + } + That would break older dts bindings, right? Yes, So I send a new patch for the related dts. Maybe it's not a problem, only one dts file need be updated currently. ref_ck must be optional for the code. I tend to make it be optional for the dts, but not for the code. There are some "fixed-clock" which can be treated as dummy ones, and if a clock is really optional, we can use one fixed-clock in dts, and keep the code simple. In fact, the reference clock is essential for usb controller. Well the thing is that there are devices in the field with an older dtb which would break on a newer kernel. That's why we need to make it work with the old dtb in the code as well. Regards, Matthias Regards, Matthias -- 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, 6/6] dt-bindings: phy-mt65xx-usb: add support for new version phy
Hi Chunfeng, On 01/20/2017 09:18 AM, Chunfeng Yun wrote: add a new compatible string for "mt2712", and move reference clock into each port node; Signed-off-by: Chunfeng Yun --- .../devicetree/bindings/phy/phy-mt65xx-usb.txt | 91 +--- 1 file changed, 77 insertions(+), 14 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt index 33a2b1e..1d06604 100644 --- a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt +++ b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt @@ -6,21 +6,27 @@ 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. 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. +- clocks : a list of phandle + clock-specifier pairs, one for each + entry in clock-names +- clock-names : must contain + "ref_clk": 48M reference clock for HighSpeed analog phy; and + 26M reference clock for SuperSpeed analog phy, sometimes is + 24M, 25M or 27M, depended on platform. - #phy-cells : should be 1 (See second example) cell after port phandle is phy type from: - PHY_TYPE_USB2 The old bindings will need to be supported by the driver, they have to stay here with a comment that they are deprecated. Regards, Matthias @@ -31,21 +37,31 @@ Example: u3phy: usb-phy@1129 { compatible = "mediatek,mt8173-u3phy"; reg = <0 0x1129 0 0x800>; - clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>; - clock-names = "u3phya_ref"; #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>; + clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>; + clock-names = "ref_clk"; #phy-cells = <1>; status = "okay"; }; - phy_port1: port@11291000 { - reg = <0 0x11291000 0 0x800>; + u3port0: port@11290900 { + reg = <0 0x11290800 0 0x700>; + clocks = <&clk26m>; + clock-names = "ref_clk"; + #phy-cells = <1>; + status = "okay"; + }; + + u2port1: port@11291000 { + reg = <0 0x11291000 0 0x100>; + clocks = <&apmixedsys CLK_APMIXED_REF2USB_TX>; + clock-names = "ref_clk"; #phy-cells = <1>; status = "okay"; }; @@ -64,7 +80,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 +0x1100
Re: [PATCH 4/6] arm64: dts: mt8173: add reference clock for usb
On 19/01/17 10:37, Greg Kroah-Hartman wrote: On Wed, Jan 18, 2017 at 02:08:25PM +0800, Chunfeng Yun wrote: 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(-) This patch doesn't apply to my tree :( This patch should go through my tree, but take into account my comment on patch 3/6. From my point of view this series is not ready to be merged. Regards, Matthias -- 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/6] usb: mtu3: add reference clock
On 18/01/17 07:08, Chunfeng Yun wrote: 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); + } + That would break older dts bindings, right? ref_ck must be optional for the code. Regards, Matthias -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/1] usb: return error code when platform_get_irq fails
On 29/11/16 13:57, Pan Bian wrote: In function xhci_mtk_probe(), variable ret takes the return value. Its value should be negative on failures. However, when the call to function platform_get_irq() fails, it does not set the error code, and 0 will be returned. 0 indicates no error. As a result, the callers of function xhci_mtk_probe() will not be able to detect the error. This patch fixes the bug by assigning the return value of platform_get_irq() to variable ret if it fails. Signed-off-by: Pan Bian --- drivers/usb/host/xhci-mtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 79959f1..f2365a4 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -560,8 +560,10 @@ static int xhci_mtk_probe(struct platform_device *pdev) goto disable_ldos; irq = platform_get_irq(pdev, 0); - if (irq < 0) + if (irq < 0) { + ret = irq; goto disable_clk; + } /* Initialize dma_mask and coherent_dma_mask to 32-bits */ ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32)); Reviewed-by: Matthias Brugger Next time please make sure to send the patch to all relevant lists and people (get_maintainer.pl). Regards, Matthias -- 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 6/6] pinctrl: mt8173: set GPIO16 to usb iddig mode
Hi Hongzhou, On 12/05/16 04:55, Hongzhou Yang wrote: On Wed, 2016-05-11 at 19:09 -0700, Hongzhou Yang wrote: On Thu, 2016-05-12 at 09:41 +0800, chunfeng yun wrote: Hi, On Wed, 2016-05-11 at 11:32 -0700, Hongzhou Yang wrote: On Wed, 2016-05-11 at 13:56 +0200, Linus Walleij wrote: On Tue, May 10, 2016 at 10:23 AM, Chunfeng Yun wrote: the default mode of GPIO16 pin is gpio, when set EINT16 to IRQ_TYPE_LEVEL_HIGH, no interrupt is triggered, it can be fixed when set its default mode as usb iddig. Signed-off-by: Chunfeng Yun Chunfeng, GPIO16 can be used as EINT16 mode, but the pinmux should be 0. If you want to set its default mode to iddig, you should set it in dts. I set it in DTS, but it didn't work, because when usb driver requested IRQ, pinmux was switched back to default mode set by MTK_EINT_FUNCTION(). After confirmed, there are something wrong with data sheet and pinmux table, and GPIO16 can only receive interrupt by mode 1. So Acked-by: Hongzhou Yang Linus, We find there are some other pins still have the same problem, so please hold on it. Sorry for so much noise. Did you made any progress on this? I didn't see any patch on the mailing list. Regards, Matthias -- 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 v7, 0/8] Add MediaTek USB3 DRD Driver
Hi Chunfeng, On 10/19/2016 04:28 AM, Chunfeng Yun wrote: These patches introduce the MediaTek USB3 dual-role controller driver. The driver can be configured as Dual-Role Device (DRD), Peripheral Only and Host Only (xHCI) modes. It works well with Mass Storage, RNDIS and g_zero on FS/HS and SS. And it is tested on MT8173 platform which only contains USB2.0 device IP, and on MT6290 platform which contains USB3.0 device IP. Change in v7: 1. split dual-role driver into four patchs 2. remove QMU done tasklet 3. add a bool in xhci_hcd_mtk to signal absence of IPPC Change in v6: 1. handle endianness of GPD and SETUP data 2. remove dummy error log and return suitable error number 3. cancel delay work when deregiseter driver Change in v5: 1. modify some comments 2. rename some unsuitable variables 3. add reg-names property for host node 4. add USB_MTU3_DEBUG to control debug messages Change in v4: 1. fix build errors on non-mediatek platforms 2. provide manual dual-role switch via debugfs instead of sysfs Change in v3: 1. fix some typo error 2. rename mtu3.txt to mt8173-mtu3.txt Change in v2: 1. modify binding docs according to suggestions 2. modify some comments and remove some dummy blank lines 3. fix memory leakage Chunfeng Yun (8): dt-bindings: mt8173-xhci: support host side of dual-role mode dt-bindings: mt8173-mtu3: add devicetree bindings usb: xhci-mtk: make IPPC register optional usb: Add MediaTek USB3 DRD driver usb: mtu3: Super-Speed Peripheral mode support usb: mtu3: host only mode support usb: mtu3: dual-role mode support arm64: dts: mediatek: add USB3 DRD driver I tried the driver with my mt8173-evb, but wasn't able to get USB working (no usb stick detected when adding to the usb port). # dmesg |grep mtu [0.428420] mtu3 11271000.usb: failed to get vusb33 [0.510570] mtu3 11271000.usb: failed to get vbus [0.592103] mtu3 11271000.usb: failed to get vbus Relevant config options: CONFIG_USB_MTU3=y CONFIG_USB_MTU3_HOST=y CONFIG_USB_MTU3_DEBUG=y CONFIG_PHY_MT65XX_USB3=y Looks like an error in the device tree. I can see that the mt6397 regulater get's initialized *after* the mtu3 driver: [0.505166] mt6397-regulator mt6397-regulator: Chip ID = 0x4097 Not sure if this is related. Any idea whats going wrong here? Cheers, Matthias -- 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: [RESEND PATCH v6, 4/5] usb: Add MediaTek USB3 DRD Driver
On 10/11/2016 05:14 AM, Chunfeng Yun wrote: On Mon, 2016-10-10 at 13:00 +0200, Matthias Brugger wrote: On 09/21/2016 07:54 AM, Chunfeng Yun wrote: This patch adds support for the MediaTek USB3 controller integrated into MT8173. It can be configured as Dual-Role Device (DRD), Peripheral Only and Host Only (xHCI) modes. Signed-off-by: Chunfeng Yun --- drivers/usb/Kconfig|2 + drivers/usb/Makefile |1 + drivers/usb/mtu3/Kconfig | 54 +++ drivers/usb/mtu3/Makefile | 19 + drivers/usb/mtu3/mtu3.h| 422 + drivers/usb/mtu3/mtu3_core.c | 871 +++ drivers/usb/mtu3/mtu3_dr.c | 379 drivers/usb/mtu3/mtu3_dr.h | 108 + drivers/usb/mtu3/mtu3_gadget.c | 731 + drivers/usb/mtu3/mtu3_gadget_ep0.c | 883 drivers/usb/mtu3/mtu3_host.c | 294 drivers/usb/mtu3/mtu3_hw_regs.h| 473 +++ drivers/usb/mtu3/mtu3_plat.c | 490 drivers/usb/mtu3/mtu3_qmu.c| 599 drivers/usb/mtu3/mtu3_qmu.h| 43 ++ 15 files changed, 5369 insertions(+) create mode 100644 drivers/usb/mtu3/Kconfig create mode 100644 drivers/usb/mtu3/Makefile create mode 100644 drivers/usb/mtu3/mtu3.h create mode 100644 drivers/usb/mtu3/mtu3_core.c create mode 100644 drivers/usb/mtu3/mtu3_dr.c create mode 100644 drivers/usb/mtu3/mtu3_dr.h create mode 100644 drivers/usb/mtu3/mtu3_gadget.c create mode 100644 drivers/usb/mtu3/mtu3_gadget_ep0.c create mode 100644 drivers/usb/mtu3/mtu3_host.c create mode 100644 drivers/usb/mtu3/mtu3_hw_regs.h create mode 100644 drivers/usb/mtu3/mtu3_plat.c create mode 100644 drivers/usb/mtu3/mtu3_qmu.c create mode 100644 drivers/usb/mtu3/mtu3_qmu.h As Oliver already said, this patch is quiet big which makes it difficult to review. I propose to provide a first implementation with minimal functionality and incremental patches on top of this when the first got merged. You could split the patch in three series/parts: 1. Host only 2. Peripheral only 3. Dual mode What do you think? Ok, I'll split the patch into some small ones as many as possible. There is no direct policy how to do that and it depends a bit on every maintainer what he prefers. As a rule of thumb each commit should compile on it's own without errors. This makes bisecting the kernel much easier. Regards, Matthias Thanks a lot Regards, Matthias -- 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: [RESEND PATCH v6, 3/5] usb: xhci-mtk: make IPPC register optional
On 09/21/2016 07:54 AM, Chunfeng Yun wrote: Make IPPC register optional to support host side of dual-role mode, due to it is moved into common glue layer for simplification. Signed-off-by: Chunfeng Yun --- drivers/usb/host/xhci-mtk.c | 36 +--- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 79959f1..4bf99b9 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -94,6 +94,9 @@ static int xhci_mtk_host_enable(struct xhci_hcd_mtk *mtk) int ret; int i; + if (ippc == NULL) + return 0; + /* power on host ip */ value = readl(&ippc->ip_pw_ctr1); value &= ~CTRL1_IP_HOST_PDN; @@ -139,6 +142,9 @@ static int xhci_mtk_host_disable(struct xhci_hcd_mtk *mtk) int ret; int i; + if (ippc == NULL) + return 0; + /* power down all u3 ports */ for (i = 0; i < mtk->num_u3_ports; i++) { value = readl(&ippc->u3_ctrl_p[i]); @@ -173,6 +179,9 @@ static int xhci_mtk_ssusb_config(struct xhci_hcd_mtk *mtk) struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs; u32 value; + if (ippc == NULL) + return 0; + I would prefer to add a flag/bool in xhci_hcd_mtk to signal the absence of the ippc. Or at least use a macro which checks the presence before calling any of this three functions. Regards, Matthias /* reset whole ip */ value = readl(&ippc->ip_pw_ctr0); value |= CTRL0_IP_SW_RST; @@ -475,6 +484,7 @@ static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci) /* called during probe() after chip reset completes */ static int xhci_mtk_setup(struct usb_hcd *hcd) { + struct xhci_hcd *xhci = hcd_to_xhci(hcd); struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd); int ret; @@ -482,12 +492,21 @@ static int xhci_mtk_setup(struct usb_hcd *hcd) ret = xhci_mtk_ssusb_config(mtk); if (ret) return ret; + } + + ret = xhci_gen_setup(hcd, xhci_mtk_quirks); + if (ret) + return ret; + + if (usb_hcd_is_primary_hcd(hcd)) { + mtk->num_u3_ports = xhci->num_usb3_ports; + mtk->num_u2_ports = xhci->num_usb2_ports; ret = xhci_mtk_sch_init(mtk); if (ret) return ret; } - return xhci_gen_setup(hcd, xhci_mtk_quirks); + return ret; } static int xhci_mtk_probe(struct platform_device *pdev) @@ -586,7 +605,7 @@ static int xhci_mtk_probe(struct platform_device *pdev) mtk->hcd = platform_get_drvdata(pdev); platform_set_drvdata(pdev, mtk); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mac"); hcd->regs = devm_ioremap_resource(dev, res); if (IS_ERR(hcd->regs)) { ret = PTR_ERR(hcd->regs); @@ -595,11 +614,14 @@ static int xhci_mtk_probe(struct platform_device *pdev) hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - mtk->ippc_regs = devm_ioremap_resource(dev, res); - if (IS_ERR(mtk->ippc_regs)) { - ret = PTR_ERR(mtk->ippc_regs); - goto put_usb2_hcd; + mtk->ippc_regs = NULL; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ippc"); + if (res) { /* ippc register is optional */ + mtk->ippc_regs = devm_ioremap_resource(dev, res); + if (IS_ERR(mtk->ippc_regs)) { + ret = PTR_ERR(mtk->ippc_regs); + goto put_usb2_hcd; + } } for (phy_num = 0; phy_num < mtk->num_phys; phy_num++) { -- 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 RFC V3.5] leds: trigger: Introduce an USB port trigger
On 25/08/16 10:03, Jacek Anaszewski wrote: zOn 08/24/2016 07:52 PM, Rafał Miłecki wrote: From: Rafał Miłecki This commit adds a new trigger responsible for turning on LED when USB device gets connected to the specified USB port. This can can useful for various home routers that have USB port(s) and a proper LED telling user a device is connected. The trigger gets its documentation file but basically it just requires specifying USB port in a Linux format (e.g. echo 1-1 > new_port). During work on this trigger there was a plan to add DT bindings for it, but there wasn't an agreement on the format yet. This can be worked on later, a sysfs interface is needed anyway for platforms not using DT. Signed-off-by: Rafał Miłecki --- V2: Trying to add DT support, idea postponed as it will take more time to discuss the bindings. V3: Fix typos in commit and Documentation (thanks Jacek!) Use "ports" sysfs file for adding and removing USB ports (thx Jacek) Check if there is USB device connected after adding new USB port Fix memory leak or two V3.5: Fix e-mail address (thanks Matthias) Simplify conditions in usbport_trig_notify (thx Matthias) Make "ports" a subdirectory with file per port, to match one value per file sysfs rule (thanks Greg) As "ports" couldn't be used for adding and removing ports anymore, there are now "new_port" and "remove_port". Having them makes this API also common with e.g. pci and usb buses. Now writing new_port with "1-1" produces a file named "1-1" in the ports directory with 000 permissions. I think that what Greg had on mind by referring to "one value per file" rule was a set of files representing ports, like "1-1 1-2 2-1", and each file should be readable/writeable. For instance "echo 1 > 1-1" would enable the trigger for the port 1-1 and "echo 0 > 1-1" would disable it. The problem is that we don't know the number of required ports at compilation time and the sysfs attributes would have to be dynamically created on driver instantiation. What is more, as the USB ports can dynamically appear/disappear in the system, the files would have to be created/removed accordingly during LED class device lifetime, which is not the best design for the sysfs interface I think. Therefore, maybe it would be good to follow the "triggers" sysfs attribute pattern, where it lists the available LED triggers? The question is whether there is some mechanism available for notifying addition/removal of a USB port? I think this should be easily doable through the notifier catching USB_BUS_[ADD,REMOVE]. Regards, Matthias Also a description of the device connected to the port would be a nice feature, however I am not certain about the feasibility thereof. The last big missing thing is Documentation update (this is why I'm sending RFC). Greg pointed out we should have some entries in Documentation/ABI, but it seems none of triggers have it. Any idea why is that? Do we need to change it? Or is it required for new code only? If so, should I care about Documentation/leds/ledtrig-usbport.txt at all in this patch? For now I didn't update Documentation/leds/ledtrig-usbport.txt with the new new_port and remove_port API, until I get a clue how to proceed. --- Documentation/leds/ledtrig-usbport.txt | 49 ++ drivers/leds/trigger/Kconfig | 8 + drivers/leds/trigger/Makefile | 1 + drivers/leds/trigger/ledtrig-usbport.c | 309 + 4 files changed, 367 insertions(+) create mode 100644 Documentation/leds/ledtrig-usbport.txt create mode 100644 drivers/leds/trigger/ledtrig-usbport.c diff --git a/Documentation/leds/ledtrig-usbport.txt b/Documentation/leds/ledtrig-usbport.txt new file mode 100644 index 000..fa42227 --- /dev/null +++ b/Documentation/leds/ledtrig-usbport.txt @@ -0,0 +1,49 @@ +USB port LED trigger + + +This LED trigger can be used for signalling to the user a presence of USB device +in a given port. It simply turns on LED when device appears and turns it off +when it disappears. + +It requires specifying a list of USB ports that should be observed. Used format +matches Linux kernel format and consists of a root hub number and a hub port +separated by a dash (e.g. 3-1). + +It is also possible to handle devices with internal hubs (that are always +connected to the root hub). User can simply specify internal hub ports then +(e.g. 1-1.1, 1-1.2, etc.). + +Please note that this trigger allows assigning multiple USB ports to a single +LED. This can be useful in two cases: + +1) Device with single USB LED and few physical ports + +In such a case LED will be turned on as long as there is at least one connected +USB device. + +2) Device with a physical port handled by few controllers + +Some devices have e.g. one controller per PHY standard. E.g. USB 3.0 physical +port may be handled by ohci-platform, ehci-platform and xhci-hcd. If there is +only one LED user will most lik
Re: [PATCH V3] leds: trigger: Introduce an USB port trigger
On 24/08/16 13:02, Rafał Miłecki wrote: On 24 August 2016 at 12:49, Matthias Brugger wrote: On 24/08/16 00:03, Rafał Miłecki wrote: [...] +static int usbport_trig_notify(struct notifier_block *nb, unsigned long action, + void *data) +{ + struct usbport_trig_data *usbport_data = + container_of(nb, struct usbport_trig_data, nb); + struct led_classdev *led_cdev = usbport_data->led_cdev; + + switch (action) { + case USB_DEVICE_ADD: + if (usbport_trig_usb_dev_observed(usbport_data, data)) { Maybe we should switch this and fist see if the usbport is observed before evaluating the action. Also cast data to "struct usb_device *" to make that clear. I'm aware there is one duplicated line of code, I did to first evaluate very quick test (checking unsigned long value), then iterate over ports & keep only 1 switch block. I could move usbport_trig_usb_dev_observed call up, but it would be executed for other actions as well (currently just USB_BUS_ADD and USB_BUS_REMOVE). Ok. I'm a USB noop but from my understanding the notifier is only called when a device or a hub gets added/removed. So this shouldn't happen that much. Therefor it has no impact if we check if the usb device is in the observer list for all actions. + if (usbport_data->count++ == 0) I'm a bit puzzled. I think: if (++usbport_data->count > 0) makes this more consistent with the remove case. Your condition would be always true (as we don't use negative numbers). The point is to enable LED only if it was disabled before. So I need to increase counter unconditionally but enable LED only if initial value (before increasing it) was 0. Got it. My personal opinion is, that adding one line for incrementing/decrementing the counter would help to make this crystal-clear to everyone (at least to me :) Cheers, Matthias +module_init(usbport_trig_init); +module_exit(usbport_trig_exit); + +MODULE_AUTHOR("Rafał Miłecki "); Nit: ra...@milecki.pl Oops, thanks! -- 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] leds: trigger: Introduce an USB port trigger
On 24/08/16 00:03, Rafał Miłecki wrote: From: Rafał Miłecki This commit adds a new trigger responsible for turning on LED when USB device gets connected to the specified USB port. This can can useful for various home routers that have USB port(s) and a proper LED telling user a device is connected. The trigger gets its documentation file but basically it just requires specifying USB port in a Linux format (e.g. echo 1-1 > new_port). During work on this trigger there was a plan to add DT bindings for it, but there wasn't an agreement on the format yet. This can be worked on later, a sysfs interface is needed anyway for platforms not using DT. Signed-off-by: Rafał Miłecki --- V2: Trying to add DT support, idea postponed as it will take more time to discuss the bindings. V3: Fix typos in commit and Documentation (thanks Jacek!) Use "ports" sysfs file for adding and removing USB ports (thx Jacek) Check if there is USB device connected after adding new USB port Fix memory leak or two Felipe: I'd like to ask for your Ack before having this patch pushed. --- Documentation/leds/ledtrig-usbport.txt | 49 +++ drivers/leds/trigger/Kconfig | 8 ++ drivers/leds/trigger/Makefile | 1 + drivers/leds/trigger/ledtrig-usbport.c | 253 + 4 files changed, 311 insertions(+) create mode 100644 Documentation/leds/ledtrig-usbport.txt create mode 100644 drivers/leds/trigger/ledtrig-usbport.c diff --git a/Documentation/leds/ledtrig-usbport.txt b/Documentation/leds/ledtrig-usbport.txt new file mode 100644 index 000..fa42227 --- /dev/null +++ b/Documentation/leds/ledtrig-usbport.txt @@ -0,0 +1,49 @@ +USB port LED trigger + + +This LED trigger can be used for signalling to the user a presence of USB device +in a given port. It simply turns on LED when device appears and turns it off +when it disappears. + +It requires specifying a list of USB ports that should be observed. Used format +matches Linux kernel format and consists of a root hub number and a hub port +separated by a dash (e.g. 3-1). + +It is also possible to handle devices with internal hubs (that are always +connected to the root hub). User can simply specify internal hub ports then +(e.g. 1-1.1, 1-1.2, etc.). + +Please note that this trigger allows assigning multiple USB ports to a single +LED. This can be useful in two cases: + +1) Device with single USB LED and few physical ports + +In such a case LED will be turned on as long as there is at least one connected +USB device. + +2) Device with a physical port handled by few controllers + +Some devices have e.g. one controller per PHY standard. E.g. USB 3.0 physical +port may be handled by ohci-platform, ehci-platform and xhci-hcd. If there is +only one LED user will most likely want to assign ports from all 3 hubs. + + +This trigger can be activated from user space on led class devices as shown +below: + + echo usbport > trigger + +This adds the following sysfs attributes to the LED: + + ports - Reading it lists all USB ports assigned to the trigger. Writing USB + port number to it will make this driver start observing it. It's also + possible to remove USB port from observable list by writing it with a + "-" prefix. + +Example use-case: + + echo usbport > trigger + echo 4-1 > ports + echo 2-1 > ports + echo -4-1 > ports + cat ports diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig index 3f9ddb9..bdd6fd2 100644 --- a/drivers/leds/trigger/Kconfig +++ b/drivers/leds/trigger/Kconfig @@ -126,4 +126,12 @@ config LEDS_TRIGGER_PANIC a different trigger. If unsure, say Y. +config LEDS_TRIGGER_USBPORT + tristate "USB port LED trigger" + depends on LEDS_TRIGGERS && USB + help + This allows LEDs to be controlled by USB events. Enabling this option + allows specifying list of USB ports that should turn on LED when some + USB device gets connected. + endif # LEDS_TRIGGERS diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Makefile index a72c43c..56e1741 100644 --- a/drivers/leds/trigger/Makefile +++ b/drivers/leds/trigger/Makefile @@ -10,3 +10,4 @@ obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) += ledtrig-transient.o obj-$(CONFIG_LEDS_TRIGGER_CAMERA) += ledtrig-camera.o obj-$(CONFIG_LEDS_TRIGGER_PANIC) += ledtrig-panic.o +obj-$(CONFIG_LEDS_TRIGGER_USBPORT) += ledtrig-usbport.o diff --git a/drivers/leds/trigger/ledtrig-usbport.c b/drivers/leds/trigger/ledtrig-usbport.c new file mode 100644 index 000..7f5237c --- /dev/null +++ b/drivers/leds/trigger/ledtrig-usbport.c @@ -0,0 +1,253 @@ +/* + * USB port LED trigger + * + * Copyright (C) 2016 Rafał Miłecki + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free S
Re: [PATCH v2,3/5] dt-bindings: mtu3: add devicetree bindings
On 31/05/16 07:52, Chunfeng Yun wrote: add a DT binding doc for MediaTek USB3 DRD driver Signed-off-by: Chunfeng Yun --- Documentation/devicetree/bindings/usb/mtu3.txt | 85 1 file changed, 85 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/mtu3.txt diff --git a/Documentation/devicetree/bindings/usb/mtu3.txt b/Documentation/devicetree/bindings/usb/mtu3.txt new file mode 100644 index 000..571ae8b --- /dev/null +++ b/Documentation/devicetree/bindings/usb/mtu3.txt The file should be called mt8173-mtu3.txt to be in line with mt8173-xhci.txt @@ -0,0 +1,85 @@ +The device node for Mediatek USB3.0 DRD controller + +Required properties: + - compatible : should be "mediatek,mt8173-mtu3" + - reg : specifies physical base address and size of the registers + - reg-names: should be "mac" for device IP and "ippc" for IP port control + - interrupts : interrupt used by the device IP + - power-domains : a phandle to USB power domain node to control USB's + mtcmos + - 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; + "wakeup_deb_p0" and "wakeup_deb_p1" are optional, they are + depends on "mediatek,enable-wakeup" + - phys : a list of phandle + phy specifier pairs + - dr_mode : should be one of "host", "peripheral" or "otg", + refer to usb/generic.txt + +Optional properties: + - #address-cells, #size-cells : should be '2' if the device has sub-nodes + with 'reg' property + - ranges : allows valid 1:1 translation between child's address space and + parent's address space + - extcon : external connector for vbus and idpin changes detection, needed + when supports dual-role mode. + - vbus-supply : reference to the VBUS regulator, needed when supports + dual-role mode. + - pinctl-names : a pinctrl state named "default" must be defined, + "id_float" and "id_ground" are optinal which depends on + "mediatek,enable-manual-drd" So pinctrl is optional, but if you put it, you need at least "default"? Apart from that, DT maintainers prefer to have the binding patches at the beginning of a series, so it's easier for them to not oversee any. Regards, Matthias + - pinctrl-0 : pin control group + See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt + + - maximum-speed : valid arguments are "super-speed", "high-speed" and + "full-speed"; refer to usb/generic.txt + - enable-manual-drd : supports manual dual-role switch via sysfs; only used + when receptacle is TYPE-A and also wants to support dual-role mode. + - mediatek,enable-wakeup : supports ip sleep wakeup used by host mode + - mediatek,syscon-wakeup : phandle to syscon used to access USB wakeup + control register, it depends on "mediatek,enable-wakeup". + +Sub-nodes: +The xhci should be added as subnode to mtu3 as shown in the following example +if host mode is enabled. The DT binding details of xhci can be found in: +Documentation/devicetree/bindings/usb/mt8173-xhci.txt + +Example: +ssusb: usb@11271000 { + compatible = "mediatek,mt8173-mtu3"; + reg = <0 0x11271000 0 0x3000>, + <0 0x11280700 0 0x0100>; + reg-names = "mac", "ippc"; + interrupts = ; + phys = <&phy_port0 PHY_TYPE_USB3>, + <&phy_port1 PHY_TYPE_USB2>; + power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; + clocks = <&topckgen CLK_TOP_USB30_SEL>, +<&pericfg CLK_PERI_USB0>, +<&pericfg CLK_PERI_USB1>; + clock-names = "sys_ck", + "wakeup_deb_p0", + "wakeup_deb_p1"; + vusb33-supply = <&mt6397_vusb_reg>; + vbus-supply = <&usb_p0_vbus>; + extcon = <&extcon_usb>; + dr_mode = "otg"; + mediatek,enable-wakeup; + mediatek,syscon-wakeup = <&pericfg>; + #address-cells = <2>; + #size-cells = <2>; + ranges; + status = "disabled"; + + usb_host: xhci@1127 { + compatible = "mediatek,mt8173-xhci"; + reg = <0 0x1127 0 0x1000>; + interrupts = ; + power-domains = <&scpsys MT8173_POWER_DOMAIN_USB>; + clocks = <&topckgen CLK_TOP_USB30_SEL>; + clock-names = "sys_ck"; + vusb33-supply = <&mt6397_vusb_reg>; + status = "disabled"; + }; +}; -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/2] dt-bindings: phy-mt65xx-usb: add support for mt2701 platform
On 11/04/16 09:41, Chunfeng Yun wrote: A new compatible string, "mediatek,mt2701-u3phy", is added. Signed-off-by: Chunfeng Yun --- .../devicetree/bindings/phy/phy-mt65xx-usb.txt |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Reviewed-by: Matthias Brugger diff --git a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt index 00100cf..33a2b1e 100644 --- a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt +++ b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt @@ -4,7 +4,9 @@ mt65xx USB3.0 PHY binding This binding describes a usb3.0 phy for mt65xx platforms of Medaitek SoC. Required properties (controller (parent) node): - - compatible : should be "mediatek,mt8173-u3phy" + - compatible : should be one of + "mediatek,mt2701-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 -- 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] phy: phy-mt65xx-usb3: add support for mt2701 platform
On 08/04/16 11:13, Chunfeng Yun wrote: A new compatible string, "mediatek,mt2701-u3phy", is added. Some register settings to avoid RX sensitivity level degradation which may arise on mt8173 platform are separated from other platforms. Signed-off-by: Chunfeng Yun --- .../devicetree/bindings/phy/phy-mt65xx-usb.txt |4 +- drivers/phy/Kconfig|5 +- drivers/phy/phy-mt65xx-usb3.c | 77 +--- 3 files changed, 57 insertions(+), 29 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt index 00100cf..8d2a62f 100644 --- a/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt +++ b/Documentation/devicetree/bindings/phy/phy-mt65xx-usb.txt @@ -4,7 +4,9 @@ mt65xx USB3.0 PHY binding This binding describes a usb3.0 phy for mt65xx platforms of Medaitek SoC. Required properties (controller (parent) node): - - compatible : should be "mediatek,mt8173-u3phy" + - compatible : should be one or more of If there are more then one, which value will avoid_rx_sen_degradation have? There should be only one compatible. Apart from that normally the dts documentation parts are separate patches. Regards, Matthias -- 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/6] usb: xhci-mtk: use __maybe_unused to hide pm functions
On 02/03/16 16:24, Arnd Bergmann wrote: The mediatek XHCI glue driver uses SET_SYSTEM_SLEEP_PM_OPS() to conditionally set the correct suspend/resume options, and also puts both the dev_pm_ops and the functions inside of an #ifdef testing for CONFIG_PM_SLEEP, but those functions then call other code that becomes unused: drivers/usb/host/xhci-mtk.c:135:12: error: 'xhci_mtk_host_disable' defined but not used [-Werror=unused-function] drivers/usb/host/xhci-mtk.c:313:13: error: 'usb_wakeup_enable' defined but not used [-Werror=unused-function] drivers/usb/host/xhci-mtk.c:321:13: error: 'usb_wakeup_disable' defined but not used [-Werror=unused-function] This replaces the #ifdef with __maybe_unused annotations so the compiler knows it can silently drop them instead of warning. For the DEV_PM_OPS definition, we can use an IS_ENABLED() check to avoid defining the structure when CONFIG_PM is not set without the #ifdef. Signed-off-by: Arnd Bergmann --- Reviewed-by: Matthias Brugger drivers/usb/host/xhci-mtk.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c index 9532f5aef71b..79959f17c38c 100644 --- a/drivers/usb/host/xhci-mtk.c +++ b/drivers/usb/host/xhci-mtk.c @@ -695,7 +695,6 @@ static int xhci_mtk_remove(struct platform_device *dev) return 0; } -#ifdef CONFIG_PM_SLEEP /* * if ip sleep fails, and all clocks are disabled, access register will hang * AHB bus, so stop polling roothubs to avoid regs access on bus suspend. @@ -703,7 +702,7 @@ static int xhci_mtk_remove(struct platform_device *dev) * to wake up system immediately after system suspend complete if ip sleep * fails, it is what we wanted. */ -static int xhci_mtk_suspend(struct device *dev) +static int __maybe_unused xhci_mtk_suspend(struct device *dev) { struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); struct usb_hcd *hcd = mtk->hcd; @@ -722,7 +721,7 @@ static int xhci_mtk_suspend(struct device *dev) return 0; } -static int xhci_mtk_resume(struct device *dev) +static int __maybe_unused xhci_mtk_resume(struct device *dev) { struct xhci_hcd_mtk *mtk = dev_get_drvdata(dev); struct usb_hcd *hcd = mtk->hcd; @@ -744,10 +743,7 @@ static int xhci_mtk_resume(struct device *dev) static const struct dev_pm_ops xhci_mtk_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(xhci_mtk_suspend, xhci_mtk_resume) }; -#define DEV_PM_OPS (&xhci_mtk_pm_ops) -#else -#define DEV_PM_OPS NULL -#endif /* CONFIG_PM */ +#define DEV_PM_OPS IS_ENABLED(CONFIG_PM) ? &xhci_mtk_pm_ops : NULL #ifdef CONFIG_OF static const struct of_device_id mtk_xhci_of_match[] = { -- 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/omap2430.c Delete unused variable.
Variable ret is always evaluated as true, so we don't need to check it. Signed-off-by: Matthias Brugger --- drivers/usb/musb/omap2430.c |4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 5fdb9da..2d207c6 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -140,7 +140,6 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) struct usb_otg *otg = musb->xceiv->otg; u8 devctl; unsigned long timeout = jiffies + msecs_to_jiffies(1000); - int ret = 1; /* HDRC controls CPEN, but beware current surges during device * connect. They can trigger transient overcurrent conditions * that must be ignored. @@ -164,12 +163,11 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) if (time_after(jiffies, timeout)) { dev_err(musb->controller, "configured as A device timeout"); - ret = -EINVAL; break; } } - if (ret && otg->set_vbus) + if (otg->set_vbus) otg_set_vbus(otg, 1); } else { musb->is_active = 1; -- 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] usb/musb/omap2430.c Delete unused variable
Signed-off-by: Matthias Brugger --- drivers/usb/musb/omap2430.c |4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 5fdb9da..2d207c6 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -140,7 +140,6 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) struct usb_otg *otg = musb->xceiv->otg; u8 devctl; unsigned long timeout = jiffies + msecs_to_jiffies(1000); - int ret = 1; /* HDRC controls CPEN, but beware current surges during device * connect. They can trigger transient overcurrent conditions * that must be ignored. @@ -164,12 +163,11 @@ static void omap2430_musb_set_vbus(struct musb *musb, int is_on) if (time_after(jiffies, timeout)) { dev_err(musb->controller, "configured as A device timeout"); - ret = -EINVAL; break; } } - if (ret && otg->set_vbus) + if (otg->set_vbus) otg_set_vbus(otg, 1); } else { musb->is_active = 1; -- 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