Skip to contentSkip to conversation

Add USB2.0 support

PATCH New Biju Das 2 participants 24 messages Aug 28, 2019 – Aug 29, 2019

Subsystems (5)
lore
Share & tools
lore

Biju Das

author
#0 lore raw

cover Add USB2.0 support

This patch series add USB2.0 support for iWave iwg23s sbc based on RZ/G1C.

This patch series is based on linux-4.4.y-cip and all the patches in this series are cherry-picked from linux rc tree.

Biju Das (16):
dt-bindings: phy: rcar-gen2: Add r8a7744 support
dt-bindings: phy: rcar-gen2: Add r8a77470 support
dt-bindings: rcar-gen3-phy-usb2: Add r8a77470 support
phy: phy-rcar-gen2: Add support for r8a77470
phy: rcar-gen3-usb2: Add support for r8a77470
ARM: dts: r8a77470: Add USB-DMAC device nodes
ARM: dts: r8a77470: Add USB PHY DT support
ARM: dts: r8a77470: Add USB2.0 Host (EHCI/OHCI) device
ARM: shmobile: Enable PHY_RCAR_GEN3_USB2 in shmobile_defconfig
ARM: shmobile: Enable USB [EO]HCI HCD PLATFORM support in
shmobile_defconfig
ARM: dts: iwg23s-sbc: Enable USB Phy[01]
ARM: dts: iwg23s-sbc: Enable USB USB2.0 Host
dt-bindings: usb: renesas_usbhs: Add support for r8a7744
dt-bindings: usb: renesas_usbhs: Add support for r8a77470
ARM: dts: r8a77470: Add HSUSB device nodes
ARM: dts: iwg23s-sbc: Enable HS-USB

Yoshihiro Shimoda (1):
phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver

 .../devicetree/bindings/phy/rcar-gen2-phy.txt      |  48 ++++-
 .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |  39 ++++
 .../devicetree/bindings/usb/renesas_usbhs.txt      |   2 +
 arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts          |  44 ++++
 arch/arm/boot/dts/r8a77470.dtsi                    | 185 ++++++++++++++++
 arch/arm/configs/shmobile_defconfig                |   3 +
 drivers/phy/Kconfig                                |   7 +
 drivers/phy/Makefile                               |   1 +
 drivers/phy/phy-rcar-gen2.c                        | 130 ++++++++++--
 drivers/phy/phy-rcar-gen3-usb2.c                   | 236 +++++++++++++++++++++
 10 files changed, 682 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
 create mode 100644 drivers/phy/phy-rcar-gen3-usb2.c
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/17 dt-bindings: phy: rcar-gen2: Add r8a7744 support

commit b3da72593e14511967a5f96f5e329b022239a90e upstream.

Add USB PHY support for r8a7744 SoC. Renesas RZ/G1N (R8A7744) USB PHY is identical to the R-Car Gen2 family.

---
 Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt +1 -0
index 75abc6d..f38f42b 100644
@@ -5,6 +5,7 @@ This file provides information on what the device node for the R-Car generation
 
 Required properties:
 - compatible: "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC.
+	      "renesas,usb-phy-r8a7744" if the device is a part of R8A7744 SoC.
 	      "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC.
 	      "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC.
 	      "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC.
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/17 dt-bindings: phy: rcar-gen2: Add r8a77470 support

In reply to Biju Das

commit f56511d0080ce33a17f7192a3f43d65e614da5cf upstream.

Add USB PHY support for r8a77470 SoC. Renesas RZ/G1C (R8A77470) USB PHY is similar to the R-Car Gen2 family, but has the below feature compared to other RZ/G1 and R-Car Gen2/3 SoCs

It has a shared pll reset for usbphy0/usbphy1 and this register reside in usbphy0 block.

---
 .../devicetree/bindings/phy/rcar-gen2-phy.txt      | 47 +++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt +46 -1
index f38f42b..35c51d8 100644
@@ -7,6 +7,7 @@ Required properties:
 - compatible: "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC.
 	      "renesas,usb-phy-r8a7744" if the device is a part of R8A7744 SoC.
 	      "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC.
+	      "renesas,usb-phy-r8a77470" if the device is a part of R8A77470 SoC.
 	      "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC.
 	      "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC.
 	      "renesas,usb-phy-r8a7794" if the device is a part of R8A7794 SoC.
@@ -29,7 +30,7 @@ channels. These subnodes must contain the following properties:
 - #phy-cells: see phy-bindings.txt in the same directory, must be <1>.
 
 The phandle's argument in the PHY specifier is the USB controller selector for
-the USB channel; see the selector meanings below:
+the USB channel other than r8a77470 SoC; see the selector meanings below:
 
 +-----------+---------------+---------------+
 |\ Selector |               |               |
@@ -40,6 +41,16 @@ the USB channel; see the selector meanings below:
 | 2         | PCI EHCI/OHCI | xHCI          |
 +-----------+---------------+---------------+
 
+For r8a77470 SoC;see the selector meaning below:
+
++-----------+---------------+---------------+
+|\ Selector |               |               |
++ --------- +       0       |       1       |
+| Channel  \|               |               |
++-----------+---------------+---------------+
+| 0         | EHCI/OHCI     | HS-USB        |
++-----------+---------------+---------------+
+
 Example (Lager board):
 
 	usb-phy at e6590100 {
@@ -59,3 +70,37 @@ Example (Lager board):
 			#phy-cells = <1>;
 		};
 	};
+
+Example (iWave RZ/G1C sbc):
+
+	usbphy0: usb-phy0 at e6590100 {
+		compatible = "renesas,usb-phy-r8a77470",
+			     "renesas,rcar-gen2-usb-phy";
+		reg = <0 0xe6590100 0 0x100>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		clocks = <&mstp7_clks R8A77470_CLK_USBHS0>;
+		clock-names = "usbhs";
+		power-domains = <&cpg_clocks>;
+
+		usb0: usb-channel at 0 {
+			reg = <0>;
+			#phy-cells = <1>;
+		};
+	};
+
+	usbphy1: usb-phy at e6598100 {
+		compatible = "renesas,usb-phy-r8a77470",
+			     "renesas,rcar-gen2-usb-phy";
+		reg = <0 0xe6598100 0 0x100>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		clocks = <&mstp7_clks R8A77470_CLK_USBHS1>;
+		clock-names = "usbhs";
+		power-domains = <&cpg_clocks>;
+
+		usb1: usb-channel at 0 {
+			reg = <0>;
+			#phy-cells = <1>;
+		};
+	};
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 3/17 phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver

In reply to Biju Das

From: Yoshihiro Shimoda <[email protected]>

commit f3b5a8d9b50d71b8c9fb72aa9c8ea948ad1a4ef9 upstream.

This patch adds support for R-Car generation 3 USB2 PHY driver. This SoC has 3 EHCI/OHCI channels, and the channel 0 is shared with the HSUSB (USB2.0 peripheral) device. And each channel has independent registers about the PHYs.

So, the purpose of this driver is:
1) initializes some registers of SoC specific to use the {ehci,ohci}-platform driver.

2) detects id pin to select host or peripheral on the channel 0.

For now, this driver only supports 1) above.

---
 .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |  37 ++++
 drivers/phy/Kconfig                                |   7 +
 drivers/phy/Makefile                               |   1 +
 drivers/phy/phy-rcar-gen3-usb2.c                   | 217 +++++++++++++++++++++
 4 files changed, 262 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
 create mode 100644 drivers/phy/phy-rcar-gen3-usb2.c
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt new file +37 -0
new file mode 100644
index 0000000..affa0f7
@@ -0,0 +1,37 @@
+* 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.
+
+Required properties:
+- compatible: "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795
+	      SoC.
+- reg: offset and length of the partial USB 2.0 Host register block.
+- reg-names: must be "usb2_host".
+- clocks: clock phandle and specifier pair(s).
+- #phy-cells: see phy-bindings.txt in the same directory, must be <0>.
+
+Optional properties:
+To use a USB channel where USB 2.0 Host and HSUSB (USB 2.0 Peripheral) are
+combined, the device tree node should set HSUSB properties to reg and reg-names
+properties. This is because HSUSB has registers to select USB 2.0 host or
+peripheral at that channel:
+- reg: offset and length of the partial HSUSB register block.
+- reg-names: must be "hsusb".
+
+Example (R-Car H3):
+
+	usb-phy at ee080200 {
+		compatible = "renesas,usb2-phy-r8a7795";
+		reg = <0 0xee080200 0 0x700>, <0 0xe6590100 0 0x100>;
+		reg-names = "usb2_host", "hsusb";
+		clocks = <&mstp7_clks R8A7795_CLK_EHCI0>,
+			 <&mstp7_clks R8A7795_CLK_HSUSB>;
+	};
+
+	usb-phy at ee0a0200 {
+		compatible = "renesas,usb2-phy-r8a7795";
+		reg = <0 0xee0a0200 0 0x700>;
+		reg-names = "usb2_host";
+		clocks = <&mstp7_clks R8A7795_CLK_EHCI0>;
+	};
drivers/phy/Kconfig +7 -0
index b5679fb..014a420 100644
@@ -118,6 +118,13 @@ config PHY_RCAR_GEN2
 	help
 	  Support for USB PHY found on Renesas R-Car generation 2 SoCs.
 
+config PHY_RCAR_GEN3_USB2
+	tristate "Renesas R-Car generation 3 USB 2.0 PHY driver"
+	depends on OF && ARCH_SHMOBILE
+	select GENERIC_PHY
+	help
+	  Support for USB 2.0 PHY found on Renesas R-Car generation 3 SoCs.
+
 config OMAP_CONTROL_PHY
 	tristate "OMAP CONTROL PHY Driver"
 	depends on ARCH_OMAP2PLUS || COMPILE_TEST
drivers/phy/Makefile +1 -0
index 075db1a..91d7a62 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_PHY_MVEBU_SATA)		+= phy-mvebu-sata.o
 obj-$(CONFIG_PHY_MIPHY28LP) 		+= phy-miphy28lp.o
 obj-$(CONFIG_PHY_MIPHY365X)		+= phy-miphy365x.o
 obj-$(CONFIG_PHY_RCAR_GEN2)		+= phy-rcar-gen2.o
+obj-$(CONFIG_PHY_RCAR_GEN3_USB2)	+= phy-rcar-gen3-usb2.o
 obj-$(CONFIG_OMAP_CONTROL_PHY)		+= phy-omap-control.o
 obj-$(CONFIG_OMAP_USB2)			+= phy-omap-usb2.o
 obj-$(CONFIG_TI_PIPE3)			+= phy-ti-pipe3.o
drivers/phy/phy-rcar-gen3-usb2.c new file +217 -0

217 lines not on this page · raw message

Signature · 1 line
2.7.4
#4 lore raw

PATCH 3/17 phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver

Hi!

Quoted 6 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +3 -0
@@ -0,0 +1,217 @@
+/*
+ * Renesas R-Car Gen3 for USB2.0 PHY driver
+ *

drivers/phy/phy-rcar-gen3-usb2.c line 13

Quoted 10 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +10 -0
+ * Copyright (C) 2015 Renesas Electronics Corporation
+ *
+ * This is based on the phy-rcar-gen2 driver:
+ * Copyright (C) 2014 Renesas Solutions Corp.
+ * Copyright (C) 2014 Cogent Embedded, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */

I see the mainline version already uses SPDX. Is there reason for older version to be backported?

drivers/phy/phy-rcar-gen3-usb2.c line 118

Quoted 4 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +4 -0
+	/*
+	 * TODO: To reduce power consuming, this driver should set the SUSPM
+	 *	after the PHY detects ID pin as peripheral.
+	 */

Plus I don't see the TODO in the mainline version.

Quoted 8 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +8 -0
+	channel = devm_kzalloc(dev, sizeof(*channel), GFP_KERNEL);
+	if (!channel)
+		return -ENOMEM;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "usb2_host");
+	channel->usb2.base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(channel->usb2.base))
+		return PTR_ERR(channel->usb2.base);

drivers/phy/phy-rcar-gen3-usb2.c line 188

Quoted 10 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +10 -0
+
+	/* "hsusb" memory resource is optional */
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hsusb");
+
+	/* To avoid error message by devm_ioremap_resource() */
+	if (res) {
+		channel->hsusb.base = devm_ioremap_resource(dev, res);
+		if (IS_ERR(channel->hsusb.base))
+			channel->hsusb.base = NULL;
+	}

What is going on here? If ioremap fails for some transient reason, do we want to continue without the resource?

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/20190828/61a21905/attachment.sig>
author
#5 lore raw

PATCH 3/17 phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver

Hi Pavel,

Thanks for the feedback.

Quoted 17 lines

Subject: Re: [cip-dev] [PATCH 4.4.y-cip 03/17] phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver

Hi!

Quoted 12 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +9 -0
@@ -0,0 +1,217 @@
+/*
+ * Renesas R-Car Gen3 for USB2.0 PHY driver
+ *
+ * Copyright (C) 2015 Renesas Electronics Corporation
+ *
+ * This is based on the phy-rcar-gen2 driver:
+ * Copyright (C) 2014 Renesas Solutions Corp.
+ * Copyright (C) 2014 Cogent Embedded, Inc.
+ *
Quoted 9 lines

drivers/phy/phy-rcar-gen3-usb2.c line 13

Quoted 5 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +5 -0
+ * This program is free software; you can redistribute it and/or
+modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */

I see the mainline version already uses SPDX. Is there reason for older version to be backported?

I have backported the commit "f3b5a8d9b50d71b8c9fb72aa9c8ea948ad1a4ef9" phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver (Linux 4.7 kernel) This has the file path (drivers/phy/phy-rcar-gen3-usb2.c) which is inline with (Linux 4.4 kernel), instead of the later versions (drivers/phy/renesas/ phy-rcar-gen3-usb2.c)

Only RZ/G1C driver uses Gen3 phy driver, it is basically for initializing timing/interrupt generation registers for {ehci,ohci}-platform driver.

The original patch doesn't use SPDX, that is the reason.

Quoted 8 lines

drivers/phy/phy-rcar-gen3-usb2.c line 16

Quoted 3 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +2 -0
+	/*
+	 * TODO: To reduce power consuming, this driver should set the

SUSPM

drivers/phy/phy-rcar-gen3-usb2.c line 118

Quoted 2 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +2 -0
+	 *	after the PHY detects ID pin as peripheral.
+	 */

Plus I don't see the TODO in the mainline version.

The original commit has this comment ("f3b5a8d9b50d71b8c9fb72aa9c8ea948ad1a4ef9" phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver). Moreover RZ/G1C SoC doesn't use hsusb block of this driver .

Quoted 14 lines

drivers/phy/phy-rcar-gen3-usb2.c

Quoted 5 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +5 -0
+	channel = devm_kzalloc(dev, sizeof(*channel), GFP_KERNEL);
+	if (!channel)
+		return -ENOMEM;
+
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"usb2_host");

drivers/phy/phy-rcar-gen3-usb2.c

Quoted 6 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +6 -0
+	channel->usb2.base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(channel->usb2.base))
+		return PTR_ERR(channel->usb2.base);
+
+	/* "hsusb" memory resource is optional */
+	res = platform_get_resource_byname(pdev, IORESOURCE_MEM,

"hsusb");[>] :q!

Quoted 10 lines

drivers/phy/phy-rcar-gen3-usb2.c line 188

Quoted 7 lines
drivers/phy/phy-rcar-gen3-usb2.c new file +7 -0
+
+	/* To avoid error message by devm_ioremap_resource() */
+	if (res) {
+		channel->hsusb.base = devm_ioremap_resource(dev, res);
+		if (IS_ERR(channel->hsusb.base))
+			channel->hsusb.base = NULL;
+	}

What is going on here? If ioremap fails for some transient reason, do we want to continue without the resource?

RZ/G1C doesn't use the hsusb block of this driver. So it is ok.
The purpose of this driver is to initialize some registers of SoC specific to use the {ehci,ohci}-platform driver.

I hope this helps.

Regards,
Biju

author
#6 lore raw

PATCH 4/17 dt-bindings: rcar-gen3-phy-usb2: Add r8a77470 support

In reply to Biju Das

commit d6c4aee8d1218d5cd73ce5e6f27ac68ad8b9430b upstream.

Document RZ/G1C (R8A77470) SoC bindings.

For RZ/G1C, this driver is used to enable interrupt generation and initializing timing registers which is part of phy_init code.

---
 Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt +4 -2
index affa0f7..c0cf9f4 100644
@@ -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/G1C USB 2.0 PHY contains.
 
 Required properties:
-- compatible: "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795
+- compatible: "renesas,usb2-phy-r8a77470" if the device is a part of an R8A77470
+	      SoC.
+	      "renesas,usb2-phy-r8a7795" if the device is a part of an R8A7795
 	      SoC.
 - reg: offset and length of the partial USB 2.0 Host register block.
 - reg-names: must be "usb2_host".
Signature · 1 line
2.7.4
author
#7 lore raw

PATCH 5/17 phy: phy-rcar-gen2: Add support for r8a77470

In reply to Biju Das

commit b7187e001a103f49ccb118bb2fb62ad31961b666 upstream.

This patch adds support for RZ/G1C (r8a77470) SoC. RZ/G1C SoC has a PLL register shared between hsusb0 and hsusb1. Compared to other RZ/G1 and R-Car Gen2/3, USB Host needs to deassert the pll reset.

[Backported to 4.4 cip kernel]
---
 drivers/phy/phy-rcar-gen2.c | 130 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 118 insertions(+), 12 deletions(-)
drivers/phy/phy-rcar-gen2.c +118 -12
index aa02b19..0817356 100644
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 2014 Renesas Solutions Corp.
  * Copyright (C) 2014 Cogent Embedded, Inc.
+ * Copyright (C) 2019 Renesas Electronics Corp.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -18,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
 #include <linux/atomic.h>
+#include <linux/of_device.h>
 
 #define USBHS_LPSTS			0x02
 #define USBHS_UGCTRL			0x80
@@ -38,6 +40,8 @@
 #define USBHS_UGCTRL2_USB0SEL		0x00000030
 #define USBHS_UGCTRL2_USB0SEL_PCI	0x00000010
 #define USBHS_UGCTRL2_USB0SEL_HS_USB	0x00000030
+#define USBHS_UGCTRL2_USB0SEL_USB20	0x00000010
+#define USBHS_UGCTRL2_USB0SEL_HS_USB20	0x00000020
 
 /* USB General status register (UGSTS) */
 #define USBHS_UGSTS_LOCK		0x00000100 /* From technical update */
@@ -67,6 +71,11 @@ struct rcar_gen2_phy_driver {
 	struct rcar_gen2_channel *channels;
 };
 
+struct rcar_gen2_phy_data {
+	const struct phy_ops *gen2_phy_ops;
+	const u32 (*select_value)[PHYS_PER_CHANNEL];
+};
+
 static int rcar_gen2_phy_init(struct phy *p)
 {
 	struct rcar_gen2_phy *phy = phy_get_drvdata(p);
@@ -183,6 +192,60 @@ static int rcar_gen2_phy_power_off(struct phy *p)
 	return 0;
 }
 
+static int rz_g1c_phy_power_on(struct phy *p)
+{
+	struct rcar_gen2_phy *phy = phy_get_drvdata(p);
+	struct rcar_gen2_phy_driver *drv = phy->channel->drv;
+	void __iomem *base = drv->base;
+	unsigned long flags;
+	u32 value;
+
+	spin_lock_irqsave(&drv->lock, flags);
+
+	/* Power on USBHS PHY */
+	value = readl(base + USBHS_UGCTRL);
+	value &= ~USBHS_UGCTRL_PLLRESET;
+	writel(value, base + USBHS_UGCTRL);
+
+	/* As per the data sheet wait 340 micro sec for power stable */
+	udelay(340);
+
+	if (phy->select_value == USBHS_UGCTRL2_USB0SEL_HS_USB20) {
+		value = readw(base + USBHS_LPSTS);
+		value |= USBHS_LPSTS_SUSPM;
+		writew(value, base + USBHS_LPSTS);
+	}
+
+	spin_unlock_irqrestore(&drv->lock, flags);
+
+	return 0;
+}
+
+static int rz_g1c_phy_power_off(struct phy *p)
+{
+	struct rcar_gen2_phy *phy = phy_get_drvdata(p);
+	struct rcar_gen2_phy_driver *drv = phy->channel->drv;
+	void __iomem *base = drv->base;
+	unsigned long flags;
+	u32 value;
+
+	spin_lock_irqsave(&drv->lock, flags);
+	/* Power off USBHS PHY */
+	if (phy->select_value == USBHS_UGCTRL2_USB0SEL_HS_USB20) {
+		value = readw(base + USBHS_LPSTS);
+		value &= ~USBHS_LPSTS_SUSPM;
+		writew(value, base + USBHS_LPSTS);
+	}
+
+	value = readl(base + USBHS_UGCTRL);
+	value |= USBHS_UGCTRL_PLLRESET;
+	writel(value, base + USBHS_UGCTRL);
+
+	spin_unlock_irqrestore(&drv->lock, flags);
+
+	return 0;
+}
+
 static const struct phy_ops rcar_gen2_phy_ops = {
 	.init		= rcar_gen2_phy_init,
 	.exit		= rcar_gen2_phy_exit,
@@ -191,12 +254,55 @@ static const struct phy_ops rcar_gen2_phy_ops = {
 	.owner		= THIS_MODULE,
 };
 
+static const struct phy_ops rz_g1c_phy_ops = {
+	.init		= rcar_gen2_phy_init,
+	.exit		= rcar_gen2_phy_exit,
+	.power_on	= rz_g1c_phy_power_on,
+	.power_off	= rz_g1c_phy_power_off,
+	.owner		= THIS_MODULE,
+};
+
+static const u32 pci_select_value[][PHYS_PER_CHANNEL] = {
+	[0]	= { USBHS_UGCTRL2_USB0SEL_PCI, USBHS_UGCTRL2_USB0SEL_HS_USB },
+	[2]	= { USBHS_UGCTRL2_USB2SEL_PCI, USBHS_UGCTRL2_USB2SEL_USB30 },
+};
+
+static const u32 usb20_select_value[][PHYS_PER_CHANNEL] = {
+	{ USBHS_UGCTRL2_USB0SEL_USB20, USBHS_UGCTRL2_USB0SEL_HS_USB20 },
+};
+
+static const struct rcar_gen2_phy_data rcar_gen2_usb_phy_data = {
+	.gen2_phy_ops = &rcar_gen2_phy_ops,
+	.select_value = pci_select_value,
+};
+
+static const struct rcar_gen2_phy_data rz_g1c_usb_phy_data = {
+	.gen2_phy_ops = &rz_g1c_phy_ops,
+	.select_value = usb20_select_value,
+};
+
 static const struct of_device_id rcar_gen2_phy_match_table[] = {
-	{ .compatible = "renesas,usb-phy-r8a7790" },
-	{ .compatible = "renesas,usb-phy-r8a7791" },
-	{ .compatible = "renesas,usb-phy-r8a7794" },
-	{ .compatible = "renesas,rcar-gen2-usb-phy" },
-	{ }
+	{
+		.compatible = "renesas,usb-phy-r8a77470",
+		.data = &rz_g1c_usb_phy_data,
+	},
+	{
+		.compatible = "renesas,usb-phy-r8a7790",
+		.data = &rcar_gen2_usb_phy_data,
+	},
+	{
+		.compatible = "renesas,usb-phy-r8a7791",
+		.data = &rcar_gen2_usb_phy_data,
+	},
+	{
+		.compatible = "renesas,usb-phy-r8a7794",
+		.data = &rcar_gen2_usb_phy_data,
+	},
+	{
+		.compatible = "renesas,rcar-gen2-usb-phy",
+		.data = &rcar_gen2_usb_phy_data,
+	},
+	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, rcar_gen2_phy_match_table);
 
@@ -227,11 +333,6 @@ static const u32 select_mask[] = {
 	[2]	= USBHS_UGCTRL2_USB2SEL,
 };
 
-static const u32 select_value[][PHYS_PER_CHANNEL] = {
-	[0]	= { USBHS_UGCTRL2_USB0SEL_PCI, USBHS_UGCTRL2_USB0SEL_HS_USB },
-	[2]	= { USBHS_UGCTRL2_USB2SEL_PCI, USBHS_UGCTRL2_USB2SEL_USB30 },
-};
-
 static int rcar_gen2_phy_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -241,6 +342,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 	struct resource *res;
 	void __iomem *base;
 	struct clk *clk;
+	const struct rcar_gen2_phy_data *data;
 	int i = 0;
 
 	if (!dev->of_node) {
@@ -269,6 +371,10 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 	drv->clk = clk;
 	drv->base = base;
 
+	data = of_device_get_match_data(dev);
+	if (!data)
+		return -EINVAL;
+
 	drv->num_channels = of_get_child_count(dev->of_node);
 	drv->channels = devm_kcalloc(dev, drv->num_channels,
 				     sizeof(struct rcar_gen2_channel),
@@ -298,10 +404,10 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 
 			phy->channel = channel;
 			phy->number = n;
-			phy->select_value = select_value[channel_num][n];
+			phy->select_value = data->select_value[channel_num][n];
 
 			phy->phy = devm_phy_create(dev, NULL,
-						   &rcar_gen2_phy_ops);
+						   data->gen2_phy_ops);
 			if (IS_ERR(phy->phy)) {
 				dev_err(dev, "Failed to create PHY\n");
 				of_node_put(np);
Signature · 1 line
2.7.4
#8 lore raw

PATCH 5/17 phy: phy-rcar-gen2: Add support for r8a77470

Hi!

PHYS_PER_CHANNEL is 2.

drivers/phy/phy-rcar-gen2.c struct rcar_gen2_phy_driver { · line 76

Quoted 1 line
drivers/phy/phy-rcar-gen2.c +1 -0
+	const u32 (*select_value)[PHYS_PER_CHANNEL];

This is ... quite "interesting" declaration. Does it actually match the arrays below?

If I read it correctly:

const u32 (...)[PHYS_PER_CHANNEL]

this is array of two items.

drivers/phy/phy-rcar-gen2.c static const struct phy_ops rcar_gen2_phy_ops = { · line 268

Quoted 4 lines
drivers/phy/phy-rcar-gen2.c +4 -0
+static const u32 pci_select_value[][PHYS_PER_CHANNEL] = {
+	[0]	= { USBHS_UGCTRL2_USB0SEL_PCI, USBHS_UGCTRL2_USB0SEL_HS_USB },
+	[2]	= { USBHS_UGCTRL2_USB2SEL_PCI, USBHS_UGCTRL2_USB2SEL_USB30 },
+};

But here we have three items (0, 1 and 2), yet we are assigning that to same pointer.

Correct me if I'm wrong.

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/20190828/559202eb/attachment.sig>
author
#9 lore raw

PATCH 5/17 phy: phy-rcar-gen2: Add support for r8a77470

Hi Pavel,

Thanks for the feedback.

Quoted 26 lines

-----Original Message-----
From: Pavel Machek <[email protected]>
Sent: Wednesday, August 28, 2019 12:12 PM
To: Biju Das <[email protected]>
Cc: cip-dev at lists.cip-project.org
Subject: Re: [cip-dev] [PATCH 4.4.y-cip 05/17] phy: phy-rcar-gen2: Add support for r8a77470

Hi!

PHYS_PER_CHANNEL is 2.

drivers/phy/phy-rcar-gen2.c struct rcar_gen2_phy_driver { · line 76

Quoted 1 line
drivers/phy/phy-rcar-gen2.c +1 -0
+	const u32 (*select_value)[PHYS_PER_CHANNEL];

This is ... quite "interesting" declaration. Does it actually match the arrays below?

If I read it correctly:

   const u32 (...)[PHYS_PER_CHANNEL]

this is array of two items.

Review

Quoted 2 lines
(quoted diff) +2 -0
+static const u32 pci_select_value[][PHYS_PER_CHANNEL] = {
+	[0]	= { USBHS_UGCTRL2_USB0SEL_PCI,

USBHS_UGCTRL2_USB0SEL_HS_USB },

Quoted 9 lines

Review

Quoted 1 line
(quoted diff) +1 -0
+	[2]	= { USBHS_UGCTRL2_USB2SEL_PCI,

USBHS_UGCTRL2_USB2SEL_USB30 },

Quoted 1 line

+};

But here we have three items (0, 1 and 2), yet we are assigning that to same pointer.

Correct me if I'm wrong.

Please compile the below code and check the results for 2 dimensional arrays.

#include <stdio.h>

static int test[][2] = {
        [0] = { 0, 1 },
        [2] = { 2, 3 },
};

main()

{
        int i;
        for (i=0;i<3;i++)
                printf("values %d0=%d,%d1=%d\n",i,test[i][0],i,test[i][1] );
}

Regards,
Biju

#10 lore raw

PATCH 5/17 phy: phy-rcar-gen2: Add support for r8a77470

Hi!

Quoted 18 lines
Quoted 18 lines

PHYS_PER_CHANNEL is 2.

drivers/phy/phy-rcar-gen2.c struct rcar_gen2_phy_driver { · line 76

Quoted 1 line
drivers/phy/phy-rcar-gen2.c +1 -0
+	const u32 (*select_value)[PHYS_PER_CHANNEL];

This is ... quite "interesting" declaration. Does it actually match the arrays below?

If I read it correctly:

   const u32 (...)[PHYS_PER_CHANNEL]

this is array of two items.

Review

Quoted 2 lines
(quoted diff) +2 -0
+static const u32 pci_select_value[][PHYS_PER_CHANNEL] = {
+	[0]	= { USBHS_UGCTRL2_USB0SEL_PCI,

USBHS_UGCTRL2_USB0SEL_HS_USB },

Review

Quoted 1 line
(quoted diff) +1 -0
+	[2]	= { USBHS_UGCTRL2_USB2SEL_PCI,

USBHS_UGCTRL2_USB2SEL_USB30 },

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

+};

But here we have three items (0, 1 and 2), yet we are assigning that to same pointer.

Correct me if I'm wrong.

Please compile the below code and check the results for 2 dimensional arrays.

I'm sorry, I got confused. Sorry for the noise.

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/20190829/bba3d043/attachment.sig>
author
#11 lore raw

PATCH 6/17 phy: rcar-gen3-usb2: Add support for r8a77470

In reply to Biju Das

commit 5d8042e95fd471d0e342cf14f127194f1a867a01 upstream.

This patch adds support for r8a77470 (RZ/G1C). We can reuse this driver for initializing timing/interrupt generation registers.

---
 drivers/phy/phy-rcar-gen3-usb2.c | 25 ++++++++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
drivers/phy/phy-rcar-gen3-usb2.c +22 -3
index 2696152..355a671 100644
@@ -18,6 +18,7 @@
 #include <linux/of_address.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/of_device.h>
 
 /******* USB2.0 Host registers (original offset is +0x200) *******/
 #define USB2_INT_ENABLE		0x000
@@ -150,9 +151,22 @@ static struct phy_ops rcar_gen3_phy_usb2_ops = {
 	.owner		= THIS_MODULE,
 };
 
+static const struct phy_ops rz_g1c_phy_usb2_ops = {
+	.init		= rcar_gen3_phy_usb2_init,
+	.exit		= rcar_gen3_phy_usb2_exit,
+	.owner		= THIS_MODULE,
+};
+
 static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
-	{ .compatible = "renesas,usb2-phy-r8a7795" },
-	{ }
+	{
+		.compatible = "renesas,usb2-phy-r8a77470",
+		.data = &rz_g1c_phy_usb2_ops,
+	},
+	{
+		.compatible = "renesas,usb2-phy-r8a7795",
+		.data = &rcar_gen3_phy_usb2_ops,
+	},
+	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table);
 
@@ -162,6 +176,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 	struct rcar_gen3_chan *channel;
 	struct phy_provider *provider;
 	struct resource *res;
+	const struct phy_ops *phy_usb2_ops;
 
 	if (!dev->of_node) {
 		dev_err(dev, "This driver needs device tree\n");
@@ -188,7 +203,11 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
 	}
 
 	/* devm_phy_create() will call pm_runtime_enable(dev); */
-	channel->phy = devm_phy_create(dev, NULL, &rcar_gen3_phy_usb2_ops);
+	phy_usb2_ops = of_device_get_match_data(dev);
+	if (!phy_usb2_ops)
+		return -EINVAL;
+
+	channel->phy = devm_phy_create(dev, NULL, phy_usb2_ops);
 	if (IS_ERR(channel->phy)) {
 		dev_err(dev, "Failed to create USB2 PHY\n");
 		return PTR_ERR(channel->phy);
Signature · 1 line
2.7.4
author
#12 lore raw

PATCH 7/17 ARM: dts: r8a77470: Add USB-DMAC device nodes

In reply to Biju Das

commit 92c3ccd9b847a6cf130e10aa305e9e349626e4f0 upstream.

This patch adds USB DMAC nodes.

[Reworked clocks and power-domains properties. Removed resets properties]
---
 arch/arm/boot/dts/r8a77470.dtsi | 52 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
arch/arm/boot/dts/r8a77470.dtsi +52 -0
index 524bba6..2c9cd0b 100644
@@ -279,6 +279,58 @@
 			status = "disabled";
 		};
 
+		usb_dmac00: dma-controller at e65a0000 {
+			compatible = "renesas,r8a77470-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 = <&mstp3_clks R8A77470_CLK_USBHS_DMAC0_CH0>;
+			power-domains = <&cpg_clocks>;
+			#dma-cells = <1>;
+			dma-channels = <2>;
+		};
+
+		usb_dmac10: dma-controller at e65b0000 {
+			compatible = "renesas,r8a77470-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 = <&mstp3_clks R8A77470_CLK_USBHS_DMAC1_CH0>;
+			power-domains = <&cpg_clocks>;
+			#dma-cells = <1>;
+			dma-channels = <2>;
+		};
+
+		usb_dmac01: dma-controller at e65a8000 {
+			compatible = "renesas,r8a77470-usb-dmac",
+				     "renesas,usb-dmac";
+			reg = <0 0xe65a8000 0 0x100>;
+			interrupts = <GIC_SPI 293 IRQ_TYPE_LEVEL_HIGH
+				      GIC_SPI 293 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "ch0", "ch1";
+			clocks = <&mstp3_clks R8A77470_CLK_USBHS_DMAC0_CH1>;
+			power-domains = <&cpg_clocks>;
+			#dma-cells = <1>;
+			dma-channels = <2>;
+		};
+
+		usb_dmac11: dma-controller at e65b8000 {
+			compatible = "renesas,r8a77470-usb-dmac",
+				     "renesas,usb-dmac";
+			reg = <0 0xe65b8000 0 0x100>;
+			interrupts = <GIC_SPI 292 IRQ_TYPE_LEVEL_HIGH
+				      GIC_SPI 292 IRQ_TYPE_LEVEL_HIGH>;
+			interrupt-names = "ch0", "ch1";
+			clocks = <&mstp3_clks R8A77470_CLK_USBHS_DMAC1_CH1>;
+			power-domains = <&cpg_clocks>;
+			#dma-cells = <1>;
+			dma-channels = <2>;
+		};
+
 		dmac0: dma-controller at e6700000 {
 			compatible = "renesas,dmac-r8a77470",
 				     "renesas,rcar-dmac";
Signature · 1 line
2.7.4
author
#13 lore raw

PATCH 8/17 ARM: dts: r8a77470: Add USB PHY DT support

In reply to Biju Das

commit 1a675db44002ed9674d6e534b1400a9d756ef34b upstream.

Define the r8a77470 generic part of the USB PHY device node.

[Reworked clocks and power-domains properties. Removed resets properties
Added usb2_host regname]

---
 arch/arm/boot/dts/r8a77470.dtsi | 54 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
arch/arm/boot/dts/r8a77470.dtsi +54 -0
index 2c9cd0b..e407954 100644
@@ -279,6 +279,40 @@
 			status = "disabled";
 		};
 
+		usbphy0: usb-phy at e6590100 {
+			compatible = "renesas,usb-phy-r8a77470",
+				     "renesas,rcar-gen2-usb-phy";
+			reg = <0 0xe6590100 0 0x100>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			clocks = <&mstp7_clks R8A77470_CLK_USBHS0>;
+			clock-names = "usbhs";
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+
+			usb0: usb-channel at 0 {
+				reg = <0>;
+				#phy-cells = <1>;
+			};
+		};
+
+		usbphy1: usb-phy at e6598100 {
+			compatible = "renesas,usb-phy-r8a77470",
+				     "renesas,rcar-gen2-usb-phy";
+			reg = <0 0xe6598100 0 0x100>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			clocks = <&mstp7_clks R8A77470_CLK_USBHS1>;
+			clock-names = "usbhs";
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+
+			usb1: usb-channel at 0 {
+				reg = <0>;
+				#phy-cells = <1>;
+			};
+		};
+
 		usb_dmac00: dma-controller at e65a0000 {
 			compatible = "renesas,r8a77470-usb-dmac",
 				     "renesas,usb-dmac";
@@ -522,6 +556,26 @@
 			status = "disabled";
 		};
 
+		usb2_phy0: usb-phy at ee080200 {
+			compatible = "renesas,usb2-phy-r8a77470";
+			reg = <0 0xee080200 0 0x700>;
+			reg-names = "usb2_host";
+			clocks = <&mstp7_clks R8A77470_CLK_USB_EHCI_0>;
+			power-domains = <&cpg_clocks>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+
+		usb2_phy1: usb-phy at ee0c0200 {
+			compatible = "renesas,usb2-phy-r8a77470";
+			reg = <0 0xee0c0200 0 0x700>;
+			reg-names = "usb2_host";
+			clocks = <&mstp7_clks R8A77470_CLK_USB_EHCI_1>;
+			power-domains = <&cpg_clocks>;
+			#phy-cells = <0>;
+			status = "disabled";
+		};
+
 		gic: interrupt-controller at f1001000 {
 			compatible = "arm,gic-400";
 			#interrupt-cells = <3>;
Signature · 1 line
2.7.4
author
#14 lore raw

PATCH 9/17 ARM: dts: r8a77470: Add USB2.0 Host (EHCI/OHCI) device

In reply to Biju Das

commit ce5940798cf1eb1ba70e94702cbb334ca370f96b upstream.

Define the r8a77470 generic part of the USB2.0 Host Controller device nodes (ehci[01]/ohci[01]).

[Reworked clocks and power-domains properties. Removed resets properties]
---
 arch/arm/boot/dts/r8a77470.dtsi | 46 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
arch/arm/boot/dts/r8a77470.dtsi +46 -0
index e407954..36538c8 100644
@@ -556,6 +556,29 @@
 			status = "disabled";
 		};
 
+		ohci0: usb at ee080000 {
+			compatible = "generic-ohci";
+			reg = <0 0xee080000 0 0x100>;
+			interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp7_clks R8A77470_CLK_USB_EHCI_0>;
+			phys = <&usb0 0>, <&usb2_phy0>;
+			phy-names = "usb";
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
+		ehci0: usb at ee080100 {
+			compatible = "generic-ehci";
+			reg = <0 0xee080100 0 0x100>;
+			interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp7_clks R8A77470_CLK_USB_EHCI_0>;
+			phys = <&usb0 0>, <&usb2_phy0>;
+			phy-names = "usb";
+			companion = <&ohci0>;
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
 		usb2_phy0: usb-phy at ee080200 {
 			compatible = "renesas,usb2-phy-r8a77470";
 			reg = <0 0xee080200 0 0x700>;
@@ -566,6 +589,29 @@
 			status = "disabled";
 		};
 
+		ohci1: usb at ee0c0000 {
+			compatible = "generic-ohci";
+			reg = <0 0xee0c0000 0 0x100>;
+			interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp7_clks R8A77470_CLK_USB_EHCI_1>;
+			phys = <&usb0 1>, <&usb2_phy1>, <&usb1 0>;
+			phy-names = "usb";
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
+		ehci1: usb at ee0c0100 {
+			compatible = "generic-ehci";
+			reg = <0 0xee0c0100 0 0x100>;
+			interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp7_clks R8A77470_CLK_USB_EHCI_1>;
+			phys = <&usb0 1>, <&usb2_phy1>, <&usb1 0>;
+			phy-names = "usb";
+			companion = <&ohci1>;
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
 		usb2_phy1: usb-phy at ee0c0200 {
 			compatible = "renesas,usb2-phy-r8a77470";
 			reg = <0 0xee0c0200 0 0x700>;
Signature · 1 line
2.7.4
author
#15 lore raw

PATCH 10/17 ARM: shmobile: Enable PHY_RCAR_GEN3_USB2 in shmobile_defconfig

In reply to Biju Das

commit 0cd4f4f10245d1d9616e00245093f46acd198141 upstream.

Enable PHY_RCAR_GEN3_USB2 in shmobile_defconfig so that boards based on RZ/G1C SoC design can use the corresponding driver.

---
 arch/arm/configs/shmobile_defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm/configs/shmobile_defconfig +1 -0
index 4074631..b1dd3037 100644
@@ -204,6 +204,7 @@ CONFIG_PWM_RCAR=y
 CONFIG_PWM_RENESAS_TPU=y
 CONFIG_GENERIC_PHY=y
 CONFIG_PHY_RCAR_GEN2=y
+CONFIG_PHY_RCAR_GEN3_USB2=y
 # CONFIG_DNOTIFY is not set
 CONFIG_MSDOS_FS=y
 CONFIG_VFAT_FS=y
Signature · 1 line
2.7.4
author
#16 lore raw

PATCH 11/17 ARM: shmobile: Enable USB [EO]HCI HCD PLATFORM support in shmobile_defconfig

In reply to Biju Das

commit b266731b76d5c33c0f6d781c449e43ad9991fb70 upstream.

The USB [EO]HCI controller on RZ/G1C SoC doesn't have PCI bridge like other R-Car Gen2 devices. So enable generic USB [EO]HCI HCD PLATFORM support in shmobile_defconfig.

---
 arch/arm/configs/shmobile_defconfig | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/configs/shmobile_defconfig +2 -0
index b1dd3037..6f5522f 100644
@@ -173,7 +173,9 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_RCAR=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_HCD_PLATFORM=y
 CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_HCD_PLATFORM=y
 CONFIG_USB_R8A66597_HCD=y
 CONFIG_USB_RENESAS_USBHS=y
 CONFIG_USB_RCAR_PHY=y
Signature · 1 line
2.7.4
author
#17 lore raw

PATCH 12/17 ARM: dts: iwg23s-sbc: Enable USB Phy[01]

In reply to Biju Das

commit e18cfb6e0418e099e42c9fb697dfba24096c90ca upstream.

Enable USB phy[01] on iWave iwg23s sbc based on RZ/G1C SoC.

---
 arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts | 32 +++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts +32 -0
index fea316d..c164f26 100644
@@ -81,6 +81,16 @@
 		groups = "scif1_data_b";
 		function = "scif1";
 	};
+
+	usb0_pins: usb0 {
+		groups = "usb0";
+		function = "usb0";
+	};
+
+	usb1_pins: usb1 {
+		groups = "usb1";
+		function = "usb1";
+	};
 };
 
 &qspi0 {
@@ -110,3 +120,25 @@
 
 	status = "okay";
 };
+
+&usb2_phy0 {
+	status = "okay";
+};
+
+&usb2_phy1 {
+	status = "okay";
+};
+
+&usbphy0 {
+	pinctrl-0 = <&usb0_pins>;
+	pinctrl-names = "default";
+
+	status = "okay";
+};
+
+&usbphy1 {
+	pinctrl-0 = <&usb1_pins>;
+	pinctrl-names = "default";
+
+	status = "okay";
+};
Signature · 1 line
2.7.4
author
#18 lore raw

PATCH 13/17 ARM: dts: iwg23s-sbc: Enable USB USB2.0 Host

In reply to Biju Das

commit 034484c4a3c77113304c8b5e1b35a9fad048274e upstream.

Enable USB2.0 host on the iwg23s sbc.

---
 arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts +8 -0
index c164f26..5c20c4c 100644
@@ -44,6 +44,10 @@
 	};
 };
 
+&ehci1 {
+	status = "okay";
+};
+
 &extal_clk {
 	clock-frequency = <20000000>;
 };
@@ -61,6 +65,10 @@
 	};
 };
 
+&ohci1 {
+	status = "okay";
+};
+
 &pfc {
 	avb_pins: avb {
 		groups = "avb_mdio", "avb_gmii_tx_rx";
Signature · 1 line
2.7.4
author
#19 lore raw

PATCH 14/17 dt-bindings: usb: renesas_usbhs: Add support for r8a7744

In reply to Biju Das

commit 77d3bf9391d40234cc764316e1d18aab6ad788d9 upstream.

Document support for RZ/G1N (R8A7744) SoC.

---
 Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/renesas_usbhs.txt +1 -0
index 65af38c..9fdfc01 100644
@@ -4,6 +4,7 @@ Required properties:
   - compatible: Must contain one or more of the following:
 
 	- "renesas,usbhs-r8a7743" for r8a7743 (RZ/G1M) compatible device
+	- "renesas,usbhs-r8a7744" for r8a7744 (RZ/G1N) compatible device
 	- "renesas,usbhs-r8a7745" for r8a7745 (RZ/G1E) compatible device
 	- "renesas,usbhs-r8a7790" for r8a7790 (R-Car H2) compatible device
 	- "renesas,usbhs-r8a7791" for r8a7791 (R-Car M2-W) compatible device
Signature · 1 line
2.7.4
author
#20 lore raw

PATCH 15/17 dt-bindings: usb: renesas_usbhs: Add support for r8a77470

In reply to Biju Das

commit 5f2c54e7153f2b30b7ee5c65ec5eb2b38a7b962d upstream.

Document support for RZ/G1C (R8A77470) SoC.

---
 Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/renesas_usbhs.txt +1 -0
index 9fdfc01..5a26dee 100644
@@ -6,6 +6,7 @@ Required properties:
 	- "renesas,usbhs-r8a7743" for r8a7743 (RZ/G1M) compatible device
 	- "renesas,usbhs-r8a7744" for r8a7744 (RZ/G1N) compatible device
 	- "renesas,usbhs-r8a7745" for r8a7745 (RZ/G1E) compatible device
+	- "renesas,usbhs-r8a77470" for r8a77470 (RZ/G1C) 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-r8a7794" for r8a7794 (R-Car E2) compatible device
Signature · 1 line
2.7.4
author
#21 lore raw

PATCH 16/17 ARM: dts: r8a77470: Add HSUSB device nodes

In reply to Biju Das

commit 307ca5cf4778b6bf0d2a025b0e4f653742214de8 upstream.

Define the r8a77470 generic part of the HSUSB0/1 device nodes.

Currently the renesas_usbhs driver doesn't handle multiple phys and we don't have a proper hardware to validate such driver changes.

So for hsusb1 it is assumed that usbphy0 will be enabled by either channel0 host or device.

In future, if any boards support hsusb1, we will need to add multiple phy support in the renesas_usbhs driver and override the board dts to enable the same.

[Reworked clocks and power-domains properties. Removed resets properties]
---
 arch/arm/boot/dts/r8a77470.dtsi | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
arch/arm/boot/dts/r8a77470.dtsi +33 -0
index 36538c8..568f650 100644
@@ -279,6 +279,22 @@
 			status = "disabled";
 		};
 
+		hsusb0: hsusb at e6590000 {
+			compatible = "renesas,usbhs-r8a77470",
+				     "renesas,rcar-gen2-usbhs";
+			reg = <0 0xe6590000 0 0x100>;
+			interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp7_clks R8A77470_CLK_USBHS0>;
+			dmas = <&usb_dmac00 0>, <&usb_dmac00 1>,
+			       <&usb_dmac10 0>, <&usb_dmac10 1>;
+			dma-names = "ch0", "ch1", "ch2", "ch3";
+			renesas,buswait = <4>;
+			phys = <&usb0 1>;
+			phy-names = "usb";
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
 		usbphy0: usb-phy at e6590100 {
 			compatible = "renesas,usb-phy-r8a77470",
 				     "renesas,rcar-gen2-usb-phy";
@@ -296,6 +312,23 @@
 			};
 		};
 
+		hsusb1: hsusb at e6598000 {
+			compatible = "renesas,usbhs-r8a77470",
+				     "renesas,rcar-gen2-usbhs";
+			reg = <0 0xe6598000 0 0x100>;
+			interrupts = <GIC_SPI 291 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&mstp7_clks R8A77470_CLK_USBHS1>;
+			dmas = <&usb_dmac01 0>, <&usb_dmac01 1>,
+			       <&usb_dmac11 0>, <&usb_dmac11 1>;
+			dma-names = "ch0", "ch1", "ch2", "ch3";
+			renesas,buswait = <4>;
+			/* We need to turn on usbphy0 to make usbphy1 to work */
+			phys = <&usb1 1>;
+			phy-names = "usb";
+			power-domains = <&cpg_clocks>;
+			status = "disabled";
+		};
+
 		usbphy1: usb-phy at e6598100 {
 			compatible = "renesas,usb-phy-r8a77470",
 				     "renesas,rcar-gen2-usb-phy";
Signature · 1 line
2.7.4
author
#22 lore raw

PATCH 17/17 ARM: dts: iwg23s-sbc: Enable HS-USB

In reply to Biju Das

commit 0725a5478e3b7080666512e6889c94bc361e7b88 upstream.

Enable HS-USB device for the iWave SBC based on RZ/G1C.

---
 arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts +4 -0
index 5c20c4c..273acc8 100644
@@ -52,6 +52,10 @@
 	clock-frequency = <20000000>;
 };
 
+&hsusb0 {
+	status = "okay";
+};
+
 &i2c3 {
 	pinctrl-0 = <&i2c3_pins>;
 	pinctrl-names = "default";
Signature · 1 line
2.7.4
#23 lore raw

cover Add USB2.0 support

In reply to Biju Das
Quoted 4 lines · Biju Das

This patch series add USB2.0 support for iWave iwg23s sbc based on RZ/G1C.

This patch series is based on linux-4.4.y-cip and all the patches in this series are cherry-picked from linux rc tree.

Thanks for the series, applied and pushed out.

Best regards,
Pavel

Quoted 36 lines

Biju Das (16):
dt-bindings: phy: rcar-gen2: Add r8a7744 support
dt-bindings: phy: rcar-gen2: Add r8a77470 support
dt-bindings: rcar-gen3-phy-usb2: Add r8a77470 support
phy: phy-rcar-gen2: Add support for r8a77470
phy: rcar-gen3-usb2: Add support for r8a77470
ARM: dts: r8a77470: Add USB-DMAC device nodes
ARM: dts: r8a77470: Add USB PHY DT support
ARM: dts: r8a77470: Add USB2.0 Host (EHCI/OHCI) device
ARM: shmobile: Enable PHY_RCAR_GEN3_USB2 in shmobile_defconfig
ARM: shmobile: Enable USB [EO]HCI HCD PLATFORM support in
shmobile_defconfig
ARM: dts: iwg23s-sbc: Enable USB Phy[01]
ARM: dts: iwg23s-sbc: Enable USB USB2.0 Host
dt-bindings: usb: renesas_usbhs: Add support for r8a7744
dt-bindings: usb: renesas_usbhs: Add support for r8a77470
ARM: dts: r8a77470: Add HSUSB device nodes
ARM: dts: iwg23s-sbc: Enable HS-USB

Yoshihiro Shimoda (1):
phy: rcar-gen3-usb2: Add R-Car Gen3 USB2 PHY driver

 .../devicetree/bindings/phy/rcar-gen2-phy.txt      |  48 ++++-
 .../devicetree/bindings/phy/rcar-gen3-phy-usb2.txt |  39 ++++
 .../devicetree/bindings/usb/renesas_usbhs.txt      |   2 +
 arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts          |  44 ++++
 arch/arm/boot/dts/r8a77470.dtsi                    | 185 ++++++++++++++++
 arch/arm/configs/shmobile_defconfig                |   3 +
 drivers/phy/Kconfig                                |   7 +
 drivers/phy/Makefile                               |   1 +
 drivers/phy/phy-rcar-gen2.c                        | 130 ++++++++++--
 drivers/phy/phy-rcar-gen3-usb2.c                   | 236 +++++++++++++++++++++
 10 files changed, 682 insertions(+), 13 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
 create mode 100644 drivers/phy/phy-rcar-gen3-usb2.c
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/20190829/e3838ed3/attachment.sig>