Backport USB support for RZ/G2E
cover Backport USB support for RZ/G2E
Dear All,
this series backports SoC specific USB Host 2.0/HSUSB/USB 3.0 DRD support for the RZ/G2E (a.k.a. R8A774C0).
While at it, this series also cherry-picks some patches useful for the RZ/G2M (a.k.a. R8A774A1).
Thanks,
Fab
Fabrizio Castro (11):
dt-bindings: rcar-gen3-phy-usb2: Add r8a774a1 support
dt-bindings: rcar-gen3-phy-usb2: Add r8a774c0 support
arm64: dts: renesas: r8a774c0: Add USB2.0 phy and host device nodes
usb: renesas_usbhs: add support for RZ/G2E
dt-bindings: usb: renesas_usbhs: Add r8a774c0 support
dt-bindings: dmaengine: usb-dmac: Add binding for r8a774c0
arm64: dts: renesas: r8a774c0: Add USB-DMAC and HSUSB device nodes
usb: gadget: udc: renesas_usb3: add support for r8a774c0
usb: gadget: udc: renesas_usb3: Add r8a774a1 support
usb: gadget: udc: renesas_usb3: Add bindings for r8a774c0
arm64: dts: renesas: r8a774c0: Add USB3.0 device nodes
Yoshihiro Shimoda (6):
usb: renesas_usbhs: Add reset_control
usb: renesas_usbhs: Add multiple clocks management Revert "usb: renesas_usbhs: add extcon notifier to set mode for
non-otg channel"
dt-bindings: usb: renesas_usbhs: add clock-names property
usb: gadget: udc: renesas_usb3: add support for r8a77990
usb: gadget: udc: renesas_usb3: add a safety connection way for
forced_b_device
.../devicetree/bindings/dma/renesas,usb-dmac.txt | 1 + .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 11 +- .../devicetree/bindings/usb/renesas_usb3.txt | 6 +- .../devicetree/bindings/usb/renesas_usbhs.txt | 7 +- arch/arm64/boot/dts/renesas/r8a774c0.dtsi | 104 +++++++++++++++++++ drivers/usb/gadget/udc/renesas_usb3.c | 30 +++++- drivers/usb/renesas_usbhs/common.c | 113 +++++++++++++++++++-- drivers/usb/renesas_usbhs/common.h | 5 +- drivers/usb/renesas_usbhs/rcar3.c | 11 -- 9 files changed, 256 insertions(+), 32 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/17 dt-bindings: rcar-gen3-phy-usb2: Add r8a774a1 support
commit ad05573080997aab7b5d0ea6187d88ef996ae3e5 upstream.
Document RZ/G2M (R8A774A1) SoC bindings.
--- Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt +6 -3
@@ -1,10 +1,12 @@ * Renesas R-Car generation 3 USB 2.0 PHY This file provides information on what the device node for the R-Car generation -3 USB 2.0 PHY contains. +3 and RZ/G2 USB 2.0 PHY contain. Required properties: -- compatible: "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795 +- compatible: "renesas,usb2-phy-r8a774a1" if the device is a part of an R8A774A1 + SoC. + "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795 SoC. "renesas,usb2-phy-r8a7796" if the device is a part of an R8A7796 SoC.
@@ -14,7 +16,8 @@ Required properties: R8A77990 SoC. "renesas,usb2-phy-r8a77995" if the device is a part of an R8A77995 SoC. - "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 compatible device. + "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 or RZ/G2 + compatible device. When compatible with the generic version, nodes must list the SoC-specific version corresponding to the platform first
Signature · 1 line
2.7.4
PATCH 2/17 dt-bindings: rcar-gen3-phy-usb2: Add r8a774c0 support
In reply to Fabrizio Castrocommit 4f0960ba7a6aedee18d5749e13ac74afe939bf2e upstream.
Document RZ/G2E (R8A774C0) SoC bindings.
--- Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt +2 -0
@@ -6,6 +6,8 @@ This file provides information on what the device node for the R-Car generation Required properties: - compatible: "renesas,usb2-phy-r8a774a1" if the device is a part of an R8A774A1 SoC. + "renesas,usb2-phy-r8a774c0" if the device is a part of an R8A774C0 + SoC. "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795 SoC. "renesas,usb2-phy-r8a7796" if the device is a part of an R8A7796
Signature · 1 line
2.7.4
PATCH 3/17 arm64: dts: renesas: r8a774c0: Add USB2.0 phy and host device nodes
In reply to Fabrizio Castrocommit 89893580cf561fd67a3f70ee812e02eac9966096 upstream.
Add USB2.0 phy and host (EHCI/OHCI) device tree nodes to the RZ/G2E SoC dtsi.
--- arch/arm64/boot/dts/renesas/r8a774c0.dtsi | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
arch/arm64/boot/dts/renesas/r8a774c0.dtsi +37 -0
@@ -943,6 +943,43 @@ status = "disabled"; }; + ohci0: usb at ee080000 { + compatible = "generic-ohci"; + reg = <0 0xee080000 0 0x100>; + interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cpg CPG_MOD 703>, <&cpg CPG_MOD 704>; + phys = <&usb2_phy0>; + phy-names = "usb"; + power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; + resets = <&cpg 703>, <&cpg 704>; + status = "disabled"; + }; + + ehci0: usb at ee080100 { + compatible = "generic-ehci"; + reg = <0 0xee080100 0 0x100>; + interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cpg CPG_MOD 703>, <&cpg CPG_MOD 704>; + phys = <&usb2_phy0>; + phy-names = "usb"; + companion = <&ohci0>; + power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; + resets = <&cpg 703>, <&cpg 704>; + status = "disabled"; + }; + + usb2_phy0: usb-phy at ee080200 { + compatible = "renesas,usb2-phy-r8a774c0", + "renesas,rcar-gen3-usb2-phy"; + reg = <0 0xee080200 0 0x700>; + interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cpg CPG_MOD 703>, <&cpg CPG_MOD 704>; + power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; + resets = <&cpg 703>, <&cpg 704>; + #phy-cells = <0>; + status = "disabled"; + }; + sdhi0: sd at ee100000 { compatible = "renesas,sdhi-r8a774c0", "renesas,rcar-gen3-sdhi";
Signature · 1 line
2.7.4
PATCH 4/17 usb: renesas_usbhs: add support for RZ/G2E
In reply to Fabrizio Castrocommit 1d6e81a288e28d8d0e38e0501a324216f79bba35 upstream.
HS-USB found in RZ/G2E (a.k.a. r8a774c0) is very similar to the one found in R-Car E3 (a.k.a. r8a77990), as it needs to release the PLL reset by the UGCTRL register like R-Car E3, therefore add r8a774c0 support in a similar fashion to what was done for the r8a77990.
--- drivers/usb/renesas_usbhs/common.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/renesas_usbhs/common.c +4 -0
@@ -458,6 +458,10 @@ static int usbhsc_drvcllbck_notify_hotplug(struct platform_device *pdev)*/ static const struct of_device_id usbhs_of_match[] = { { + .compatible ="renesas,usbhs-r8a774c0" , + .data = (void *)USBHS_TYPE_RCAR_GEN3_WITH_PLL , + }, + { .compatible ="renesas,usbhs-r8a7790" , .data = (void *)USBHS_TYPE_RCAR_GEN2 , },
Signature · 1 line
2.7.4
PATCH 5/17 usb: renesas_usbhs: Add reset_control
In reply to Fabrizio CastroFrom: Yoshihiro Shimoda <[email protected]>
commit f181dbb4824130e84f46e5be5b49cf6456f96683 upstream.
R-Car Gen3 needs to deassert resets of both host and peripheral. Since [eo]hci-platform is possible to assert the reset(s) when the probing failed, renesas_usbhs driver doesn't work correctly regardless of finished probing. To fix this issue, this patch adds reset_control on this renesas_usbhs driver.
--- drivers/usb/renesas_usbhs/common.c | 12 ++++++++++++ drivers/usb/renesas_usbhs/common.h | 2 ++ 2 files changed, 14 insertions(+)
drivers/usb/renesas_usbhs/common.c +12 -0
@@ -12,6 +12,7 @@#include <linux/of_device.h> #include <linux/of_gpio.h> #include <linux/pm_runtime.h> +#include <linux/reset.h> #include <linux/slab.h> #include <linux/sysfs.h> #include "common.h"
@@ -578,6 +579,10 @@ static int usbhs_probe(struct platform_device *pdev)return PTR_ERR (priv->edev); } + priv->rsts =devm_reset_control_array_get_optional_shared (&pdev->dev); +if (IS_ERR (priv->rsts)) +return PTR_ERR (priv->rsts); +/* * care platform info */
@@ -662,6 +667,10 @@ static int usbhs_probe(struct platform_device *pdev)/* dev_set_drvdata should be called after usbhs_mod_init */ platform_set_drvdata (pdev, priv); + ret =reset_control_deassert (priv->rsts); +if (ret) + goto probe_fail_rst; +/* * deviece reset here because * USB device might be used in boot loader.
@@ -715,6 +724,8 @@ static int usbhs_probe(struct platform_device *pdev)return ret; probe_end_mod_exit: +reset_control_assert (priv->rsts); +probe_fail_rst:usbhs_mod_remove (priv); probe_end_fifo_exit:usbhs_fifo_remove (priv);
@@ -743,6 +754,7 @@ static int usbhs_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev);usbhs_platform_call (priv, hardware_exit, pdev); +reset_control_assert (priv->rsts);usbhs_mod_remove (priv);usbhs_fifo_remove (priv);usbhs_pipe_remove (priv);
drivers/usb/renesas_usbhs/common.h +2 -0
@@ -10,6 +10,7 @@#include <linux/extcon.h> #include <linux/platform_device.h> +#include <linux/reset.h> #include <linux/usb/renesas_usbhs.h> struct usbhs_priv ;
@@ -277,6 +278,7 @@ struct usbhs_priv {struct usbhs_fifo_info fifo_info;struct phy *phy; +struct reset_control *rsts; };/*
Signature · 1 line
2.7.4
PATCH 6/17 usb: renesas_usbhs: Add multiple clocks management
In reply to Fabrizio CastroFrom: Yoshihiro Shimoda <[email protected]>
commit 3df0e240caba641e0d70640e3baf34d34c105176 upstream.
R-Car Gen3 needs to enable clocks of both host and peripheral. Since [eo]hci-platform disables the reset(s) when the drivers are removed, renesas_usbhs driver doesn't work correctly. To fix this issue, this patch adds multiple clocks management on this renesas_usbhs driver.
--- drivers/usb/renesas_usbhs/common.c | 88 ++++++++++++++++++++++++++++++++++++++ drivers/usb/renesas_usbhs/common.h | 2 + 2 files changed, 90 insertions(+)
drivers/usb/renesas_usbhs/common.c +88 -0
@@ -5,6 +5,7 @@* Copyright (C) 2011 Renesas Solutions Corp. * Kuninori Morimoto <[email protected]> */ +#include <linux/clk.h> #include <linux/err.h> #include <linux/gpio.h> #include <linux/io.h>
@@ -291,6 +292,79 @@ static void usbhsc_set_buswait(struct usbhs_priv *priv)usbhs_bset (priv,BUSWAIT ,0x000F , wait); } +static bool usbhsc_is_multi_clks (struct usbhs_priv *priv) +{ +if (priv->dparam.type ==USBHS_TYPE_RCAR_GEN3 || + priv->dparam.type ==USBHS_TYPE_RCAR_GEN3_WITH_PLL ) +return true; + +return false; +} + +static int usbhsc_clk_get (struct device *dev,struct usbhs_priv *priv) +{ +if (!usbhsc_is_multi_clks (priv)) +return 0 ; + +/* The first clock should exist */ + priv->clks[0 ] =of_clk_get (dev->of_node,0 ); +if (IS_ERR (priv->clks[0 ])) +return PTR_ERR (priv->clks[0 ]); + +/* +* To backward compatibility with old DT, this driver checks the return +* value if it's -ENOENT or not. +*/ + priv->clks[1 ] =of_clk_get (dev->of_node,1 ); +if (PTR_ERR (priv->clks[1 ]) == -ENOENT ) + priv->clks[1 ] =NULL ; +else if (IS_ERR (priv->clks[1 ])) +return PTR_ERR (priv->clks[1 ]); + +return 0 ; +} + +static void usbhsc_clk_put (struct usbhs_priv *priv) +{ +int i; + +if (!usbhsc_is_multi_clks (priv)) +return ; + +for (i =0 ; i <ARRAY_SIZE (priv->clks); i++) +clk_put (priv->clks[i]); +} + +static int usbhsc_clk_prepare_enable (struct usbhs_priv *priv) +{ +int i, ret; + +if (!usbhsc_is_multi_clks (priv)) +return 0 ; + +for (i =0 ; i <ARRAY_SIZE (priv->clks); i++) { + ret =clk_prepare_enable (priv->clks[i]); +if (ret) { +while (--i >=0 ) +clk_disable_unprepare (priv->clks[i]); +return ret; + } + } + +return ret; +} + +static void usbhsc_clk_disable_unprepare (struct usbhs_priv *priv) +{ +int i; + +if (!usbhsc_is_multi_clks (priv)) +return ; + +for (i =0 ; i <ARRAY_SIZE (priv->clks); i++) +clk_disable_unprepare (priv->clks[i]); +} +/* * platform default param */
@@ -341,6 +415,10 @@ static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable)/* enable PM */ pm_runtime_get_sync (dev); +/* enable clks */ +if (usbhsc_clk_prepare_enable (priv)) +return ; +/* enable platform power */ usbhs_platform_call (priv, power_ctrl, pdev, priv->base, enable);
@@ -353,6 +431,9 @@ static void usbhsc_power_ctrl(struct usbhs_priv *priv, int enable)/* disable platform power */ usbhs_platform_call (priv, power_ctrl, pdev, priv->base, enable); +/* disable clks */ +usbhsc_clk_disable_unprepare (priv); +/* disable PM */ pm_runtime_put_sync (dev); }
@@ -671,6 +752,10 @@ static int usbhs_probe(struct platform_device *pdev)if (ret) goto probe_fail_rst; + ret =usbhsc_clk_get (&pdev->dev, priv); +if (ret) + goto probe_fail_clks; +/* * deviece reset here because * USB device might be used in boot loader.
@@ -724,6 +809,8 @@ static int usbhs_probe(struct platform_device *pdev)return ret; probe_end_mod_exit: +usbhsc_clk_put (priv); +probe_fail_clks:reset_control_assert (priv->rsts); probe_fail_rst:usbhs_mod_remove (priv);
@@ -754,6 +841,7 @@ static int usbhs_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev);usbhs_platform_call (priv, hardware_exit, pdev); +usbhsc_clk_put (priv);reset_control_assert (priv->rsts);usbhs_mod_remove (priv);usbhs_fifo_remove (priv);
drivers/usb/renesas_usbhs/common.h +2 -0
@@ -8,6 +8,7 @@#ifndef RENESAS_USB_DRIVER_H #define RENESAS_USB_DRIVER_H +#include <linux/clk.h> #include <linux/extcon.h> #include <linux/platform_device.h> #include <linux/reset.h>
@@ -279,6 +280,7 @@ struct usbhs_priv {struct phy *phy;struct reset_control *rsts; +struct clk *clks[2 ]; };/*
Signature · 1 line
2.7.4
PATCH 6/17 usb: renesas_usbhs: Add multiple clocks management
Hi!
drivers/usb/renesas_usbhs/common.c static void usbhsc_set_buswait(struct usbhs_priv *priv) · line 322
Quoted 9 lines
drivers/usb/renesas_usbhs/common.c +9
-0+/* +* To backward compatibility with old DT, this driver checks the return +* value if it's -ENOENT or not. +*/ + priv->clks[1 ] =of_clk_get (dev->of_node,1 ); +if (PTR_ERR (priv->clks[1 ]) == -ENOENT ) + priv->clks[1 ] =NULL ; +else if (IS_ERR (priv->clks[1 ])) +return PTR_ERR (priv->clks[1 ]);
I'd really use temporary variable here.
Something like
if (IS_ERR()) {
err = PTR_ERR();
if (err != -ENOENT)
return err;
priv->clks[1] = NULL;
}But this is -cip, so no need to fix it here, but consider fixing it in mainline.
Pavel
Signature · 9 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: <http://lists.cip-project.org/pipermail/cip-dev/attachments/20190425/e9cb0faf/attachment.sig>
PATCH 7/17 Revert "usb: renesas_usbhs: add extcon notifier to set mode for non-otg channel"
In reply to Fabrizio CastroFrom: Yoshihiro Shimoda <[email protected]>
commit 91b20c5a5be0088f9534483276f86230c3a5872f upstream.
This reverts commit 8ada211d0383b72878582bd312b984a9eae62b30.
R-Car D3 can use OTG mode in fact. So, the commit doesn't need anymore. In other words, like other R-Car Gen3 SoCs, R-Car D3 can change the mode by using the phy-rcar-gen3-usb2 driver.
--- drivers/usb/renesas_usbhs/common.c | 9 --------- drivers/usb/renesas_usbhs/common.h | 1 - drivers/usb/renesas_usbhs/rcar3.c | 11 ----------- 3 files changed, 21 deletions(-)
drivers/usb/renesas_usbhs/common.c +0 -9
@@ -681,15 +681,6 @@ static int usbhs_probe(struct platform_device *pdev)break ;case USBHS_TYPE_RCAR_GEN3_WITH_PLL : priv->pfunc = usbhs_rcar3_with_pll_ops; -if (!IS_ERR_OR_NULL (priv->edev)) { - priv->nb.notifier_call = priv->pfunc.notifier; - ret =devm_extcon_register_notifier (&pdev->dev, - priv->edev, -EXTCON_USB_HOST , - &priv->nb); -if (ret <0 ) -dev_err (&pdev->dev,"no notifier registered\n" ); - }break ;case USBHS_TYPE_RZA1 : priv->pfunc = usbhs_rza1_ops;
drivers/usb/renesas_usbhs/common.h +0 -1
@@ -257,7 +257,6 @@ struct usbhs_priv {struct platform_device *pdev;struct extcon_dev *edev; -struct notifier_block nb;spinlock_t lock;
drivers/usb/renesas_usbhs/rcar3.c +0 -11
@@ -112,16 +112,6 @@ static int usbhs_rcar3_get_id(struct platform_device *pdev)return USBHS_GADGET ; } -static int usbhs_rcar3_notifier (struct notifier_block *nb,unsigned long event, -void *data) -{ - struct usbhs_priv *priv = container_of(nb, struct usbhs_priv, nb); - -usbhs_rcar3_set_usbsel (priv, !!event); - -return NOTIFY_DONE ; -} -const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = { .power_ctrl = usbhs_rcar3_power_ctrl, .get_id = usbhs_rcar3_get_id,
@@ -130,5 +120,4 @@ const struct renesas_usbhs_platform_callback usbhs_rcar3_ops = {const struct renesas_usbhs_platform_callback usbhs_rcar3_with_pll_ops = { .power_ctrl = usbhs_rcar3_power_and_pll_ctrl, .get_id = usbhs_rcar3_get_id, - .notifier = usbhs_rcar3_notifier, };
Signature · 1 line
2.7.4
PATCH 8/17 dt-bindings: usb: renesas_usbhs: add clock-names property
In reply to Fabrizio CastroFrom: Yoshihiro Shimoda <[email protected]>
commit 8e0d368a59bf87efa5ee4daea142527d01447864 upstream.
R-Car Gen3 needs to enable clocks of both host and peripheral. Otherwise, other side device cannot work correctly. So, this patch adds a property of clock-names for R-Car Gen3 as an optional.
--- Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/usb/renesas_usbhs.txt +5 -1
@@ -25,7 +25,11 @@ Required properties: - reg: Base address and length of the register for the USBHS - interrupts: Interrupt specifier for the USBHS - - clocks: A list of phandle + clock specifier pairs + - clocks: A list of phandle + clock specifier pairs. + - In case of "renesas,rcar-gen3-usbhs", two clocks are required. + First clock should be peripheral and second one should be host. + - In case of except above, one clock is required. First clock + should be peripheral. Optional properties: - renesas,buswait: Integer to use BUSWAIT register
Signature · 1 line
2.7.4
PATCH 9/17 dt-bindings: usb: renesas_usbhs: Add r8a774c0 support
In reply to Fabrizio Castrocommit 539cf1039165ac59d217d916bc8f88bde8be73bd upstream.
Document RZ/G2E (R8A774C0) SoC bindings.
--- Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/renesas_usbhs.txt +1 -0
@@ -5,6 +5,7 @@ Required properties: - "renesas,usbhs-r8a7743" for r8a7743 (RZ/G1M) compatible device - "renesas,usbhs-r8a7745" for r8a7745 (RZ/G1E) compatible device + - "renesas,usbhs-r8a774c0" for r8a774c0 (RZ/G2E) compatible device - "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device - "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device - "renesas,usbhs-r8a7792" for r8a7792 (R-Car V2H) compatible device
Signature · 1 line
2.7.4
PATCH 10/17 dt-bindings: dmaengine: usb-dmac: Add binding for r8a774c0
In reply to Fabrizio Castrocommit 3eaba568b54e572187a3f4a08d5582d4d623e7e3 upstream.
This patch adds bindings for the r8a774c0 (RZ/G2E).
--- Documentation/devicetree/bindings/dma/renesas,usb-dmac.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/dma/renesas,usb-dmac.txt +1 -0
@@ -5,6 +5,7 @@ Required Properties: Examples with soctypes are: - "renesas,r8a7743-usb-dmac" (RZ/G1M) - "renesas,r8a7745-usb-dmac" (RZ/G1E) + - "renesas,r8a774c0-usb-dmac" (RZ/G2E) - "renesas,r8a7790-usb-dmac" (R-Car H2) - "renesas,r8a7791-usb-dmac" (R-Car M2-W) - "renesas,r8a7793-usb-dmac" (R-Car M2-N)
Signature · 1 line
2.7.4
PATCH 11/17 arm64: dts: renesas: r8a774c0: Add USB-DMAC and HSUSB device nodes
In reply to Fabrizio Castrocommit 19777736ced78c4ea9b171ff758f62e04915f005 upstream.
Add usb dmac and hsusb device nodes on RZ/G2E SoC dtsi.
--- arch/arm64/boot/dts/renesas/r8a774c0.dtsi | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
arch/arm64/boot/dts/renesas/r8a774c0.dtsi +45 -0
@@ -637,6 +637,51 @@ status = "disabled"; }; + hsusb: usb at e6590000 { + compatible = "renesas,usbhs-r8a774c0", + "renesas,rcar-gen3-usbhs"; + reg = <0 0xe6590000 0 0x200>; + interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cpg CPG_MOD 704>, <&cpg CPG_MOD 703>; + dmas = <&usb_dmac0 0>, <&usb_dmac0 1>, + <&usb_dmac1 0>, <&usb_dmac1 1>; + dma-names = "ch0", "ch1", "ch2", "ch3"; + renesas,buswait = <11>; + phys = <&usb2_phy0>; + phy-names = "usb"; + power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; + resets = <&cpg 704>, <&cpg 703>; + status = "disabled"; + }; + + usb_dmac0: dma-controller at e65a0000 { + compatible = "renesas,r8a774c0-usb-dmac", + "renesas,usb-dmac"; + reg = <0 0xe65a0000 0 0x100>; + interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH + GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "ch0", "ch1"; + clocks = <&cpg CPG_MOD 330>; + power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; + resets = <&cpg 330>; + #dma-cells = <1>; + dma-channels = <2>; + }; + + usb_dmac1: dma-controller at e65b0000 { + compatible = "renesas,r8a774c0-usb-dmac", + "renesas,usb-dmac"; + reg = <0 0xe65b0000 0 0x100>; + interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH + GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "ch0", "ch1"; + clocks = <&cpg CPG_MOD 331>; + power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; + resets = <&cpg 331>; + #dma-cells = <1>; + dma-channels = <2>; + }; + dmac0: dma-controller at e6700000 { compatible = "renesas,dmac-r8a774c0", "renesas,rcar-dmac";
Signature · 1 line
2.7.4
PATCH 12/17 usb: gadget: udc: renesas_usb3: add support for r8a77990
In reply to Fabrizio CastroFrom: Yoshihiro Shimoda <[email protected]>
commit 30025efa8b5e75f545e38a592158c34b3169423b upstream.
Since r8a77990 (R-Car E3) doesn't have VBUS detect pin and number of ramif is 4, this patch adds a new renesas_usb3_priv variable for the SoC.
--- drivers/usb/gadget/udc/renesas_usb3.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/usb/gadget/udc/renesas_usb3.c +11 -0
@@ -2603,6 +2603,13 @@ static const struct renesas_usb3_priv renesas_usb3_priv_gen3 = { .ramsize_per_pipe = SZ_4K, }; +static const struct renesas_usb3_priv renesas_usb3_priv_r8a77990 = { + .ramsize_per_ramif =SZ_16K , + .num_ramif =4 , + .ramsize_per_pipe =SZ_4K , + .workaround_for_vbus = true, +}; +static const struct of_device_id usb3_of_match[] = { { .compatible ="renesas,r8a7795-usb3-peri" ,
@@ -2621,6 +2628,10 @@ static const struct soc_device_attribute renesas_usb3_quirks_match[] = { .soc_id = "r8a7795", .revision = "ES1.*", .data = &renesas_usb3_priv_r8a7795_es1, }, + { + .soc_id = "r8a77990", + .data = &renesas_usb3_priv_r8a77990, + }, { /* sentinel */ }, };
Signature · 1 line
2.7.4
PATCH 13/17 usb: gadget: udc: renesas_usb3: add a safety connection way for forced_b_device
In reply to Fabrizio CastroFrom: Yoshihiro Shimoda <[email protected]>
commit ceb94bc52c437463f0903e61060a94a2226fb672 upstream.
This patch adds a safety connection way for "forced_b_device" with "workaround_for_vbus" like below:
< Example for R-Car E3 Ebisu >
# modprobe <any usb gadget driver> # echo 1 > /sys/kernel/debug/ee020000.usb/b_device (connect a usb cable to host side.) # echo 2 > /sys/kernel/debug/ee020000.usb/b_device
Previous code should have connected a usb cable before the "b_device" is set to 1 on the Ebisu board. However, if xHCI driver on the board is probed, it causes some troubles:
- Conflicts USB VBUS/signals between the board and another host.
- "Cannot enable. Maybe the USB cable is bad?" might happen on both the board and another host with a usb hub.
- Cannot enumerate a usb gadget correctly because an interruption of VBUS change happens unexpectedly.
--- drivers/usb/gadget/udc/renesas_usb3.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/usb/gadget/udc/renesas_usb3.c +10 -5
@@ -358,6 +358,7 @@ struct renesas_usb3 {bool extcon_host;/* check id and set EXTCON_USB_HOST */ bool extcon_usb;/* check vbus and set EXTCON_USB */ bool forced_b_device; +bool start_to_connect; };#define gadget_to_renesas_usb3 (_gadget) \
@@ -476,7 +477,8 @@ static void usb3_init_axi_bridge(struct renesas_usb3 *usb3)static void usb3_init_epc_registers (struct renesas_usb3 *usb3) {usb3_write (usb3, ~0 ,USB3_USB_INT_STA_1 ); -usb3_enable_irq_1 (usb3,USB_INT_1_VBUS_CNG ); +if (!usb3->workaround_for_vbus) +usb3_enable_irq_1 (usb3,USB_INT_1_VBUS_CNG ); }static bool usb3_wakeup_usb2_phy (struct renesas_usb3 *usb3)
@@ -700,8 +702,7 @@ static void usb3_mode_config(struct renesas_usb3 *usb3, bool host, bool a_dev)usb3_set_mode_by_role_sw (usb3, host);usb3_vbus_out (usb3, a_dev);/* for A-Peripheral or forced B-device mode */ -if ((!host && a_dev) || - (usb3->workaround_for_vbus && usb3->forced_b_device)) +if ((!host && a_dev) || usb3->start_to_connect)usb3_connect (usb3);spin_unlock_irqrestore (&usb3->lock, flags); }
@@ -2432,7 +2433,11 @@ static ssize_t renesas_usb3_b_device_write(struct file *file,if (copy_from_user (&buf, ubuf,min_t (size_t,sizeof (buf) -1 , count)))return -EFAULT ; -if (!strncmp (buf,"1" ,1 )) + usb3->start_to_connect = false; +if (usb3->workaround_for_vbus && usb3->forced_b_device && + !strncmp (buf,"2" ,1 )) + usb3->start_to_connect = true; +else if (!strncmp (buf,"1" ,1 )) usb3->forced_b_device = true;else usb3->forced_b_device = false;
@@ -2440,7 +2445,7 @@ static ssize_t renesas_usb3_b_device_write(struct file *file,if (usb3->workaround_for_vbus)usb3_disconnect (usb3); -/* Let this driver call usb3_connect() anyway */ +/* Let this driver call usb3_connect() if needed */ usb3_check_id (usb3);return count;
Signature · 1 line
2.7.4
PATCH 13/17 usb: gadget: udc: renesas_usb3: add a safety connection way for forced_b_device
Hi!
Quoted 6 lines
From: Yoshihiro Shimoda <[email protected]>
commit
ceb94bc52c437463f0903e61060a94a2226fb672upstream.This patch adds a safety connection way for "
forced_b_device" with "workaround_for_vbus" like below:
I don't understand what "safety connection way" is.
drivers/usb/gadget/udc/renesas_usb3.c static ssize_t renesas_usb3_b_device_write(struct file *file, · line 2443
Quoted 13 lines
drivers/usb/gadget/udc/renesas_usb3.c +5
-1@@ -2432,7 +2433,11 @@ static ssize_t renesas_usb3_b_device_write(struct file *file,if (copy_from_user (&buf, ubuf,min_t (size_t,sizeof (buf) -1 , count)))return -EFAULT ; -if (!strncmp (buf,"1" ,1 )) + usb3->start_to_connect = false; +if (usb3->workaround_for_vbus && usb3->forced_b_device && + !strncmp (buf,"2" ,1 )) + usb3->start_to_connect = true; +else if (!strncmp (buf,"1" ,1 )) usb3->forced_b_device = true;else usb3->forced_b_device = false;
I don't think this is correct. If user writes "12" to the file, (!strncmp(buf, "1", 1)) will still be true, AFAICT. Similar problem exists elsewhere in the file, with (!strncmp(buf, "host", strlen("host"))).
This is adding new option to kernel interface. ("2" to sysfs file). I believe that should be documented in Documentation/ABI.
Anyway, I'll most likely apply the patch, as problem needs to be fixed in the mainline, first.
Best regards,
Pavel
Signature · 9 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: <http://lists.cip-project.org/pipermail/cip-dev/attachments/20190425/1670d415/attachment.sig>
PATCH 14/17 usb: gadget: udc: renesas_usb3: add support for r8a774c0
In reply to Fabrizio Castrocommit 546970fdab1da5fead4f0f5c8cbf4b1c68213707 upstream.
RZ/G2E USB 3.0 implementation is like the one found on R-Car E3, therefore add the same quirk.
--- drivers/usb/gadget/udc/renesas_usb3.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/gadget/udc/renesas_usb3.c +4 -0
@@ -2630,6 +2630,10 @@ MODULE_DEVICE_TABLE(of, usb3_of_match);static const struct soc_device_attribute renesas_usb3_quirks_match[] = { { + .soc_id ="r8a774c0" , + .data = &renesas_usb3_priv_r8a77990, + }, + { .soc_id ="r8a7795" , .revision ="ES1.*" , .data = &renesas_usb3_priv_r8a7795_es1, },
Signature · 1 line
2.7.4
PATCH 15/17 usb: gadget: udc: renesas_usb3: Add r8a774a1 support
In reply to Fabrizio Castrocommit a1acad03aa77bde2d7fda7b1391ee72a55a705da upstream.
Document RZ/G2M (R8A774A1) SoC bindings.
--- Documentation/devicetree/bindings/usb/renesas_usb3.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/usb/renesas_usb3.txt +3 -2
@@ -2,11 +2,12 @@ Renesas Electronics USB3.0 Peripheral driver Required properties: - compatible: Must contain one of the following: + - "renesas,r8a774a1-usb3-peri" - "renesas,r8a7795-usb3-peri" - "renesas,r8a7796-usb3-peri" - "renesas,r8a77965-usb3-peri" - - "renesas,rcar-gen3-usb3-peri" for a generic R-Car Gen3 compatible - device + - "renesas,rcar-gen3-usb3-peri" for a generic R-Car Gen3 or RZ/G2 + compatible device When compatible with the generic version, nodes must list the SoC-specific version corresponding to the platform first
Signature · 1 line
2.7.4
PATCH 16/17 usb: gadget: udc: renesas_usb3: Add bindings for r8a774c0
In reply to Fabrizio Castrocommit 35ed6229c0f0d079f28b22b60b0af3114f9226fb upstream.
Document RZ/G2E (R8A774C0) SoC bindings.
--- Documentation/devicetree/bindings/usb/renesas_usb3.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/renesas_usb3.txt +1 -0
@@ -3,6 +3,7 @@ Renesas Electronics USB3.0 Peripheral driver Required properties: - compatible: Must contain one of the following: - "renesas,r8a774a1-usb3-peri" + - "renesas,r8a774c0-usb3-peri" - "renesas,r8a7795-usb3-peri" - "renesas,r8a7796-usb3-peri" - "renesas,r8a77965-usb3-peri"
Signature · 1 line
2.7.4
PATCH 17/17 arm64: dts: renesas: r8a774c0: Add USB3.0 device nodes
In reply to Fabrizio Castrocommit 3a6addcaedecf2a8261c3491693be38b28a75444 upstream.
Add usb3.0 host and function device nodes to the RZ/G2E SoC dtsi.
--- arch/arm64/boot/dts/renesas/r8a774c0.dtsi | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/arm64/boot/dts/renesas/r8a774c0.dtsi +22 -0
@@ -988,6 +988,28 @@ status = "disabled"; }; + xhci0: usb at ee000000 { + compatible = "renesas,xhci-r8a774c0", + "renesas,rcar-gen3-xhci"; + reg = <0 0xee000000 0 0xc00>; + interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cpg CPG_MOD 328>; + power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; + resets = <&cpg 328>; + status = "disabled"; + }; + + usb3_peri0: usb at ee020000 { + compatible = "renesas,r8a774c0-usb3-peri", + "renesas,rcar-gen3-usb3-peri"; + reg = <0 0xee020000 0 0x400>; + interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cpg CPG_MOD 328>; + power-domains = <&sysc R8A774C0_PD_ALWAYS_ON>; + resets = <&cpg 328>; + status = "disabled"; + }; + ohci0: usb at ee080000 { compatible = "generic-ohci"; reg = <0 0xee080000 0 0x100>;
Signature · 1 line
2.7.4
cover Backport USB support for RZ/G2E
In reply to Fabrizio CastroHi Fabrizio,
Quoted 33 lines
Dear All,
this series backports SoC specific USB Host 2.0/HSUSB/USB 3.0 DRD support for the RZ/G2E (a.k.a. R8A774C0).
While at it, this series also cherry-picks some patches useful for the RZ/G2M (a.k.a. R8A774A1).Thanks,
FabFabrizio Castro (11):
dt-bindings: rcar-gen3-phy-usb2: Add r8a774a1 support
dt-bindings: rcar-gen3-phy-usb2: Add r8a774c0 support
arm64: dts: renesas: r8a774c0: Add USB2.0 phy and host device nodes
usb:renesas_usbhs: add support for RZ/G2E
dt-bindings: usb:renesas_usbhs: Add r8a774c0 support
dt-bindings: dmaengine: usb-dmac: Add binding for r8a774c0
arm64: dts: renesas: r8a774c0: Add USB-DMAC and HSUSB device nodes
usb: gadget: udc:renesas_usb3: add support for r8a774c0
usb: gadget: udc:renesas_usb3: Add r8a774a1 support
usb: gadget: udc:renesas_usb3: Add bindings for r8a774c0
arm64: dts: renesas: r8a774c0: Add USB3.0 device nodesYoshihiro Shimoda (6):
usb:renesas_usbhs: Addreset_control
usb:renesas_usbhs: Add multiple clocks management Revert "usb:renesas_usbhs: add extcon notifier to set mode for
non-otg channel"
dt-bindings: usb:renesas_usbhs: add clock-names property
usb: gadget: udc:renesas_usb3: add support for r8a77990
usb: gadget: udc:renesas_usb3: add a safety connection way for
forced_b_device
Quoted 11 lines
.../devicetree/bindings/dma/renesas,usb-dmac.txt | 1 + .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 11 +- .../devicetree/bindings/usb/renesas_usb3.txt | 6 +- .../devicetree/bindings/usb/renesas_usbhs.txt | 7 +- arch/arm64/boot/dts/renesas/r8a774c0.dtsi | 104 +++++++++++++++++++ drivers/usb/gadget/udc/renesas_usb3.c | 30 +++++- drivers/usb/renesas_usbhs/common.c | 113 +++++++++++++++++++-- drivers/usb/renesas_usbhs/common.h | 5 +- drivers/usb/renesas_usbhs/rcar3.c | 11 -- 9 files changed, 256 insertions(+), 32 deletions(-)
Looks good to me all patches.
Pavel, do you have a comment about this series?
Best regards,
Nobuhiro
________________________________________
???: cip-dev-bounces at lists.cip-project.org <[email protected]> ? Fabrizio Castro <[email protected]> ?????? ????: 2019?4?25? 2:20
??: cip-dev at lists.cip-project.org
CC: Biju Das
??: [cip-dev] [PATCH 4.19.y 00/17] Backport USB support for RZ/G2E
Dear All,
this series backports SoC specific USB Host 2.0/HSUSB/USB 3.0 DRD support for the RZ/G2E (a.k.a. R8A774C0).
While at it, this series also cherry-picks some patches useful for the RZ/G2M (a.k.a. R8A774A1).
Thanks,
Fab
Fabrizio Castro (11):
dt-bindings: rcar-gen3-phy-usb2: Add r8a774a1 support
dt-bindings: rcar-gen3-phy-usb2: Add r8a774c0 support
arm64: dts: renesas: r8a774c0: Add USB2.0 phy and host device nodes
usb: renesas_usbhs: add support for RZ/G2E
dt-bindings: usb: renesas_usbhs: Add r8a774c0 support
dt-bindings: dmaengine: usb-dmac: Add binding for r8a774c0
arm64: dts: renesas: r8a774c0: Add USB-DMAC and HSUSB device nodes
usb: gadget: udc: renesas_usb3: add support for r8a774c0
usb: gadget: udc: renesas_usb3: Add r8a774a1 support
usb: gadget: udc: renesas_usb3: Add bindings for r8a774c0
arm64: dts: renesas: r8a774c0: Add USB3.0 device nodes
Yoshihiro Shimoda (6):
usb: renesas_usbhs: Add reset_control
usb: renesas_usbhs: Add multiple clocks management Revert "usb: renesas_usbhs: add extcon notifier to set mode for
non-otg channel"
dt-bindings: usb: renesas_usbhs: add clock-names property
usb: gadget: udc: renesas_usb3: add support for r8a77990
usb: gadget: udc: renesas_usb3: add a safety connection way for
forced_b_device
.../devicetree/bindings/dma/renesas,usb-dmac.txt | 1 + .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 11 +- .../devicetree/bindings/usb/renesas_usb3.txt | 6 +- .../devicetree/bindings/usb/renesas_usbhs.txt | 7 +- arch/arm64/boot/dts/renesas/r8a774c0.dtsi | 104 +++++++++++++++++++ drivers/usb/gadget/udc/renesas_usb3.c | 30 +++++- drivers/usb/renesas_usbhs/common.c | 113 +++++++++++++++++++-- drivers/usb/renesas_usbhs/common.h | 5 +- drivers/usb/renesas_usbhs/rcar3.c | 11 -- 9 files changed, 256 insertions(+), 32 deletions(-)
--
2.7.4
_______________________________________________
cip-dev mailing list
cip-dev at lists.cip-project.org
https://lists.cip-project.org/mailman/listinfo/cip-dev
cover Backport USB support for RZ/G2E
Hi!
Quoted 2 lines
Looks good to me all patches.
Pavel, do you have a comment about this series?
Let me take a look. I'll apply them to the tree if there's no problem with them...?
Best regards,
Pavel
Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: <http://lists.cip-project.org/pipermail/cip-dev/attachments/20190425/3125502d/attachment.sig>
cover Backport USB support for RZ/G2E
In reply to Fabrizio CastroHi!
Quoted 4 lines
this series backports SoC specific USB Host 2.0/HSUSB/USB 3.0 DRD support for the RZ/G2E (a.k.a. R8A774C0).
While at it, this series also cherry-picks some patches useful for the RZ/G2M (a.k.a. R8A774A1).
Thanks for the series, applied, and pushed to kernel.org.
Best regards,
Pavel
Signature · 9 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 181 bytes Desc: Digital signature URL: <http://lists.cip-project.org/pipermail/cip-dev/attachments/20190425/f9bad5f6/attachment.sig>