Skip to contentSkip to conversation

Add MTK AHCI driver, BPI-R64 dts and USB-Nodes for mt7622>

PATCH New Frank Wunderlich 3 participants 16 messages Aug 20, 2020 – Aug 25, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v6 cover Add MTK AHCI driver, BPI-R64 dts and USB-Nodes for mt7622>

From: Frank Wunderlich <[email protected]>

This series adds Mediatek AHCI driver, makes neccessary phy modifications creates new dts for bananapi-r64 (because it's a bit different to rfb) and adds all DTS nodes to get SATA and USB working on mt7622 and mt7623

they are based on top of this:

Add PCIe and its clock support for mt7622
https://patchwork.ozlabs.org/project/uboot/list/?series=194888

and to get USB working (no hard depency, ports get enumerated without it):
usb: xhci: add a member hci_version in xhci_ctrl struct
https://patchwork.ozlabs.org/project/uboot/list/?series=195331

v5->v6:
- fix commit-subjects/messages to take care of actual changes in part 2+3 there are only small changes like dropping comment and reorder Authors
- rename now existing bpi-r64.dts to follow naming convensions
- drop commits creating new r64 dts and adding sata-nodes
v4->v5:
- rebased on master because old series got merged
v3->v4:
- fix wrong squashing of pciesys-comment
v2->v3:
- fixed code style suggested by sam
v1->v2:
- made register of phy optional for tphy v1 and remove it in dts

Frank Wunderlich (7):
phy: mtk-tphy: make shared reg optional for v1
reset: drop unnecessary comment for pciesys
ahci: mediatek: fix copyright and author-lines
clk: mt7622: add needed clocks for ssusb-node
arm: dts: rename mt7622-bpi-r64.dts
arm: dts: mt7622: add USB nodes
arm: dts: mt7623: add USB nodes

 arch/arm/dts/Makefile                         |  2 +-
 ...pi-r64.dts => mt7622-bananapi-bpi-r64.dts} |  8 +++
 arch/arm/dts/mt7622-rfb.dts                   |  8 +++
 arch/arm/dts/mt7622.dtsi                      | 56 +++++++++++++++++++
 arch/arm/dts/mt7623.dtsi                      | 46 +++++++++++++++
 arch/arm/dts/mt7623n-bananapi-bpi-r2.dts      | 16 ++++++
 drivers/ata/mtk_ahci.c                        |  6 +-
 drivers/clk/mediatek/clk-mt7622.c             | 43 +++++++++++++-
 drivers/phy/phy-mtk-tphy.c                    |  5 +-
 9 files changed, 181 insertions(+), 9 deletions(-)
 rename arch/arm/dts/{mt7622-bpi-r64.dts => mt7622-bananapi-bpi-r64.dts} (98%)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v6 1/7 phy: mtk-tphy: make shared reg optional for v1

From: Frank Wunderlich <[email protected]>

make the shared reg optional when version is v1 for sata

---
 drivers/phy/phy-mtk-tphy.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/phy/phy-mtk-tphy.c +2 -3
index 326227a30d..3d7b9cd2b1 100644
@@ -698,11 +698,10 @@ static int mtk_tphy_probe(struct udevice *dev)
 	tphy->dev = dev;
 	tphy->version = dev_get_driver_data(dev);
 
-	/* v1 has shared banks */
+	/* v1 has shared banks for usb/pcie mode, */
+	/* but not for sata mode */
 	if (tphy->version == MTK_TPHY_V1) {
 		tphy->sif_base = dev_read_addr_ptr(dev);
-		if (!tphy->sif_base)
-			return -ENOENT;
 	}
 
 	dev_for_each_subnode(subnode, dev) {
Signature · 1 line
2.25.1
#2 lore raw

PATCH v6 1/7 phy: mtk-tphy: make shared reg optional for v1

Quoted 7 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

make the shared reg optional when version is v1 for sata

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200825/9ca4e8c7/attachment.sig>
#3 lore raw

PATCH v6 2/7 reset: drop unnecessary comment for pciesys

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

after review from sam this comment should be removed

---
 drivers/clk/mediatek/clk-mt7622.c | 1 -
 1 file changed, 1 deletion(-)
drivers/clk/mediatek/clk-mt7622.c +0 -1
index d53ed69189..a1a35f72a3 100644
@@ -599,7 +599,6 @@ static int mt7622_pciesys_bind(struct udevice *dev)
 	int ret = 0;
 
 	if (IS_ENABLED(CONFIG_RESET_MEDIATEK)) {
-//	PCIESYS uses in linux also 0x34 = ETHSYS reset controller
 	ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1);
 	if (ret)
 		debug("Warning: failed to bind reset controller\n");
Signature · 1 line
2.25.1
#4 lore raw

PATCH v6 2/7 reset: drop unnecessary comment for pciesys

Quoted 5 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

after review from sam this comment should be removed

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200825/60e984b9/attachment.sig>
#5 lore raw

PATCH v6 3/7 ahci: mediatek: fix copyright and author-lines

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

after review of sam copyright should be on one line and link should not between author lines

just remove the link and put ryder first as he is author of linux-driver

---
 drivers/ata/mtk_ahci.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/ata/mtk_ahci.c +2 -4
index 8e09c5f9e6..4ad260a5bb 100644
@@ -2,12 +2,10 @@
 /*
  * MTK SATA platform driver
  *
- * (C) Copyright 2020
- *     Mediatek
+ * Copyright (C) 2020 MediaTek Inc.
  *
- * Author: Frank Wunderlich <[email protected]>
- * based on https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/ata/ahci_mtk.c
  * Author: Ryder Lee <[email protected]>
+ * Author: Frank Wunderlich <[email protected]>
  */
 
 #include <common.h>
Signature · 1 line
2.25.1
#6 lore raw

PATCH v6 3/7 ahci: mediatek: fix copyright and author-lines

Quoted 8 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

after review of sam copyright should be on one line and link should not between author lines

just remove the link and put ryder first as he is author of linux-driver

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200825/69811fc8/attachment.sig>
#7 lore raw

PATCH v6 4/7 clk: mt7622: add needed clocks for ssusb-node

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

MT7622 needs additional clock definitions to work properly

---
 drivers/clk/mediatek/clk-mt7622.c | 42 +++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
drivers/clk/mediatek/clk-mt7622.c +42 -0
index a1a35f72a3..0246149107 100644
@@ -521,6 +521,20 @@ static const struct mtk_gate_regs sgmii_cg_regs = {
 	.flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN,	\
 }
 
+static const struct mtk_gate_regs ssusb_cg_regs = {
+	.set_ofs = 0x30,
+	.clr_ofs = 0x30,
+	.sta_ofs = 0x30,
+};
+
+#define GATE_SSUSB(_id, _parent, _shift) {                      \
+	.id = _id,                                              \
+	.parent = _parent,                                      \
+	.regs = &ssusb_cg_regs,                                 \
+	.shift = _shift,                                        \
+	.flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN,  \
+}
+
 static const struct mtk_gate sgmii_cgs[] = {
 	GATE_SGMII(CLK_SGMII_TX250M_EN, CLK_TOP_SSUSB_TX250M, 2),
 	GATE_SGMII(CLK_SGMII_RX250M_EN, CLK_TOP_SSUSB_EQ_RX250M, 3),
@@ -528,6 +542,15 @@ static const struct mtk_gate sgmii_cgs[] = {
 	GATE_SGMII(CLK_SGMII_CDR_FB, CLK_TOP_SSUSB_CDR_FB, 5),
 };
 
+static const struct mtk_gate ssusb_cgs[] = {
+	GATE_SSUSB(CLK_SSUSB_U2_PHY_1P_EN, CLK_TOP_TO_U2_PHY_1P, 0),
+	GATE_SSUSB(CLK_SSUSB_U2_PHY_EN, CLK_TOP_TO_U2_PHY, 1),
+	GATE_SSUSB(CLK_SSUSB_REF_EN, CLK_TOP_TO_USB3_REF, 5),
+	GATE_SSUSB(CLK_SSUSB_SYS_EN, CLK_TOP_TO_USB3_SYS, 6),
+	GATE_SSUSB(CLK_SSUSB_MCU_EN, CLK_TOP_AXI_SEL, 7),
+	GATE_SSUSB(CLK_SSUSB_DMA_EN, CLK_TOP_HIF_SEL, 8),
+};
+
 static const struct mtk_clk_tree mt7622_clk_tree = {
 	.xtal_rate = 25 * MHZ,
 	.xtal2_rate = 25 * MHZ,
@@ -630,6 +653,11 @@ static int mt7622_sgmiisys_probe(struct udevice *dev)
 	return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, sgmii_cgs);
 }
 
+static int mt7622_ssusbsys_probe(struct udevice *dev)
+{
+	return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, ssusb_cgs);
+}
+
 static const struct udevice_id mt7622_apmixed_compat[] = {
 	{ .compatible = "mediatek,mt7622-apmixedsys" },
 	{ }
@@ -670,6 +698,11 @@ static const struct udevice_id mt7622_mcucfg_compat[] = {
 	{ }
 };
 
+static const struct udevice_id mt7622_ssusbsys_compat[] = {
+	{ .compatible = "mediatek,mt7622-ssusbsys" },
+	{ }
+};
+
 U_BOOT_DRIVER(mtk_mcucfg) = {
 	.name = "mt7622-mcucfg",
 	.id = UCLASS_SYSCON,
@@ -746,3 +779,12 @@ U_BOOT_DRIVER(mtk_clk_sgmiisys) = {
 	.priv_auto_alloc_size = sizeof(struct mtk_cg_priv),
 	.ops = &mtk_clk_gate_ops,
 };
+
+U_BOOT_DRIVER(mtk_clk_ssusbsys) = {
+	.name = "mt7622-clock-ssusbsys",
+	.id = UCLASS_CLK,
+	.of_match = mt7622_ssusbsys_compat,
+	.probe = mt7622_ssusbsys_probe,
+	.priv_auto_alloc_size = sizeof(struct mtk_cg_priv),
+	.ops = &mtk_clk_gate_ops,
+};
Signature · 1 line
2.25.1
#8 lore raw

PATCH v6 4/7 clk: mt7622: add needed clocks for ssusb-node

Quoted 5 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

MT7622 needs additional clock definitions to work properly

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200825/eb4a631a/attachment.sig>
#9 lore raw

PATCH v6 5/7 arm: dts: rename mt7622-bpi-r64.dts

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

rename mt7622-bpi-r64.dts to mt7622-bananapi-bpi-r64.dts to follow naming convensions

---
 arch/arm/dts/Makefile                                           | 2 +-
 .../arm/dts/{mt7622-bpi-r64.dts => mt7622-bananapi-bpi-r64.dts} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename arch/arm/dts/{mt7622-bpi-r64.dts => mt7622-bananapi-bpi-r64.dts} (100%)
arch/arm/dts/Makefile +1 -1
index b2b5360f6d..9a28958103 100644
@@ -962,7 +962,7 @@ dtb-$(CONFIG_SOC_K3_J721E) += k3-j721e-common-proc-board.dtb \
 dtb-$(CONFIG_ARCH_MEDIATEK) += \
 	mt7622-rfb.dtb \
 	mt7623a-unielec-u7623-02-emmc.dtb \
-	mt7622-bpi-r64.dtb \
+	mt7622-bananapi-bpi-r64.dtb \
 	mt7623n-bananapi-bpi-r2.dtb \
 	mt7629-rfb.dtb \
 	mt8512-bm1-emmc.dtb \
arch/arm/dts/mt7622-bananapi-bpi-r64.dts renamed from arch/arm/dts/mt7622-bpi-r64.dts +0 -0
similarity index 100%
rename from arch/arm/dts/mt7622-bpi-r64.dts
rename to arch/arm/dts/mt7622-bananapi-bpi-r64.dts
Signature · 1 line
2.25.1
#10 lore raw

PATCH v6 5/7 arm: dts: rename mt7622-bpi-r64.dts

Quoted 6 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

rename mt7622-bpi-r64.dts to mt7622-bananapi-bpi-r64.dts to follow naming convensions

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200825/43780bd5/attachment.sig>
#11 lore raw

PATCH v6 6/7 arm: dts: mt7622: add USB nodes

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

Add DTS nodes for MT7622/BPI-R64

---
v1->v2:
- remove clk25m as it's not needed

---
 arch/arm/dts/mt7622-bananapi-bpi-r64.dts |  8 ++++
 arch/arm/dts/mt7622-rfb.dts              |  8 ++++
 arch/arm/dts/mt7622.dtsi                 | 56 ++++++++++++++++++++++++
 3 files changed, 72 insertions(+)
arch/arm/dts/mt7622-bananapi-bpi-r64.dts +8 -0
index 51287cea3a..4f2f04851d 100644
@@ -244,3 +244,11 @@
 		output-low;
 	};
 };
+
+&ssusb {
+	status = "okay";
+};
+
+&u3phy {
+	status = "okay";
+};
arch/arm/dts/mt7622-rfb.dts +8 -0
index 317fc78abd..ef7d0f0270 100644
@@ -222,3 +222,11 @@
 		full-duplex;
 	};
 };
+
+&ssusb {
+	status = "okay";
+};
+
+&u3phy {
+       status = "okay";
+};
arch/arm/dts/mt7622.dtsi +56 -0

68 lines not on this page · raw message

Signature · 1 line
2.25.1
#12 lore raw

PATCH v6 6/7 arm: dts: mt7622: add USB nodes

Quoted 6 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

Add DTS nodes for MT7622/BPI-R64

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200825/a3b20a26/attachment.sig>
#13 lore raw

PATCH v6 7/7 arm: dts: mt7623: add USB nodes

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

This adds USB nodes for MT7623/BPI-R2

---
 arch/arm/dts/mt7623.dtsi                 | 46 ++++++++++++++++++++++++
 arch/arm/dts/mt7623n-bananapi-bpi-r2.dts | 16 +++++++++
 2 files changed, 62 insertions(+)
arch/arm/dts/mt7623.dtsi +46 -0
index 0452889ef8..b5a802552b 100644
@@ -352,6 +352,52 @@
 		};
 	};
 
+	usb1: usb at 1a1c0000 {
+		compatible = "mediatek,mt7623-xhci", "mediatek,mtk-xhci";
+		reg = <0x1a1c0000 0x1000>, <0x1a1c4700 0x0100>;
+		reg-names = "mac", "ippc";
+		power-domains = <&scpsys MT7623_POWER_DOMAIN_HIF>;
+		clocks = <&hifsys CLK_HIFSYS_USB0PHY>, <&topckgen CLK_TOP_ETHIF_SEL>;
+		clock-names = "sys_ck", "ref_ck";
+		phys = <&u2port0 PHY_TYPE_USB2>, <&u3port0 PHY_TYPE_USB3>;
+		status = "disabled";
+	};
+
+	u3phy1: usb-phy at 1a1c4000 {
+		compatible = "mediatek,mt7623-tphy", "mediatek,generic-tphy-v1";
+
+		reg = <0x1a1c4000 0x0700>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+		status = "disabled";
+
+		u2port0: usb-phy at 1a1c4800 {
+			reg = <0x1a1c4800 0x0100>;
+			#phy-cells = <1>;
+			clocks = <&topckgen CLK_TOP_USB_PHY48M>;
+			clock-names = "ref";
+		};
+
+		u3port0: usb-phy at 1a1c4900 {
+			reg = <0x1a1c4900 0x0700>;
+			#phy-cells = <1>;
+			clocks = <&clk26m>;
+			clock-names = "ref";
+		};
+	};
+
+	usb2: usb at 1a240000 {
+		compatible = "mediatek,mt7623-xhci", "mediatek,mtk-xhci";
+		reg = <0x1a240000 0x1000>, <0x1a244700 0x0100>;
+		reg-names = "mac", "ippc";
+		power-domains = <&scpsys MT7623_POWER_DOMAIN_HIF>;
+		clocks = <&hifsys CLK_HIFSYS_USB1PHY>, <&topckgen CLK_TOP_ETHIF_SEL>;
+		clock-names = "sys_ck", "ref_ck";
+		phys = <&u2port1 PHY_TYPE_USB2>, <&u3port1 PHY_TYPE_USB3>;
+		status = "disabled";
+	};
+
 	u3phy2: usb-phy at 1a244000 {
 		compatible = "mediatek,generic-tphy-v1";
 		reg = <0x1a244000 0x0700>;
arch/arm/dts/mt7623n-bananapi-bpi-r2.dts +16 -0
index bcedcf20f1..ef07369627 100644
@@ -248,3 +248,19 @@
 	pinctrl-0 = <&uart2_pins_a>;
 	status = "okay";
 };
+
+&usb1 {
+	status = "okay";
+};
+
+&u3phy1 {
+	status = "okay";
+};
+
+&usb2 {
+	status = "okay";
+};
+
+&u3phy2 {
+	status = "okay";
+};
Signature · 1 line
2.25.1
#14 lore raw

PATCH v6 7/7 arm: dts: mt7623: add USB nodes

Quoted 6 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

This adds USB nodes for MT7623/BPI-R2

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200825/86df8bc6/attachment.sig>