Skip to contentSkip to conversation

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

PATCH New Frank Wunderlich 2 participants 11 messages Aug 20, 2020

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

v5 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

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 (8):
phy: mtk-tphy: make shared reg optional for v1
reset: add basic reset controller for pciesys
ahci: mediatek: add ahci driver
clk: mt7622: add needed clocks for ssusb-node
arm: dts: add dts for Bananapi-R64
arm: dts: mt7622: add sata- and asm_sel nodes
arm: dts: mt7622: add USB nodes
arm: dts: mt7623: add USB nodes

 arch/arm/dts/Makefile                    |   1 +
 arch/arm/dts/mt7622-bananapi-bpi-r64.dts | 223 +++++++++++++++++++++++
 arch/arm/dts/mt7622-rfb.dts              |   8 +
 arch/arm/dts/mt7622.dtsi                 |  57 +++++-
 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, 396 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/dts/mt7622-bananapi-bpi-r64.dts
Signature · 1 line
2.25.1
#1 lore raw

PATCH v5 1/8 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 v5 2/8 reset: add basic reset controller for pciesys

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

bind reset controller to pciesys

---
 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
#3 lore raw

PATCH v5 3/8 ahci: mediatek: add ahci driver

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

add AHCI driver ported from linux

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/ata/ahci_mtk.c

---
 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
#4 lore raw

Aw: [PATCH v5 3/8] ahci: mediatek: add ahci driver

mhm, maybe i should change commit-subject/message because there are only changes suggested from sam...same for part2

regards Frank

Quoted 22 lines

Gesendet: Donnerstag, 20. August 2020 um 15:40 Uhr
Von: "Frank Wunderlich" <[email protected]>
Betreff: [PATCH v5 3/8] ahci: mediatek: add ahci driver

add AHCI driver ported from linux

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]>
  */
#5 lore raw

PATCH v5 4/8 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
#6 lore raw

PATCH v5 5/8 arm: dts: add dts for Bananapi-R64

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

add a separate DTS for BananaPi R64 because it has 1GB RAM and SATA-Support

---
v1->v2:
- changed name

---
 arch/arm/dts/Makefile                    |   1 +
 arch/arm/dts/mt7622-bananapi-bpi-r64.dts | 206 +++++++++++++++++++++++
 2 files changed, 207 insertions(+)
 create mode 100644 arch/arm/dts/mt7622-bananapi-bpi-r64.dts
arch/arm/dts/Makefile +1 -0
index b2b5360f6d..68a29faa6a 100644
@@ -961,6 +961,7 @@ dtb-$(CONFIG_SOC_K3_J721E) += k3-j721e-common-proc-board.dtb \
 
 dtb-$(CONFIG_ARCH_MEDIATEK) += \
 	mt7622-rfb.dtb \
+	mt7622-bananapi-bpi-r64.dtb \
 	mt7623a-unielec-u7623-02-emmc.dtb \
 	mt7622-bpi-r64.dtb \
 	mt7623n-bananapi-bpi-r2.dtb \
arch/arm/dts/mt7622-bananapi-bpi-r64.dts new file +206 -0

206 lines not on this page · raw message

Signature · 1 line
2.25.1
#7 lore raw

PATCH v5 5/8 arm: dts: add dts for Bananapi-R64

Here i change to rename the now existing bpi-r64.dts to bananapi-bpi-r64 to follow naming sheme like bpi-2 instead of creating a new one regards Frank

#8 lore raw

PATCH v5 6/8 arm: dts: mt7622: add sata- and asm_sel nodes

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

asm_sel is for switching between sata and pcie mode on r64 there is GPIO90 connected to ASM1480 which switches RX/TX pairs to PCIe/SATA connector output-low means sata-controller is active

---
 arch/arm/dts/mt7622-bananapi-bpi-r64.dts | 9 +++++++++
 arch/arm/dts/mt7622.dtsi                 | 1 -
 2 files changed, 9 insertions(+), 1 deletion(-)
arch/arm/dts/mt7622-bananapi-bpi-r64.dts +9 -0
index 768f15bc2c..c36ec8f8d0 100644
@@ -204,3 +204,12 @@
 		full-duplex;
 	};
 };
+
+&gpio {
+	/*gpio 90 for setting mode to sata*/
+	asm_sel {
+		gpio-hog;
+		gpios = <90 GPIO_ACTIVE_HIGH>;
+		output-low;
+	};
+};
arch/arm/dts/mt7622.dtsi +0 -1
index c43ad65702..6b4260407e 100644
@@ -287,7 +287,6 @@
 
 	sata_phy: sata-phy at 1a243000 {
 		compatible = "mediatek,generic-tphy-v1";
-		reg = <0x1a243000 0x0100>;
 		#address-cells = <1>;
 		#size-cells = <1>;
 		ranges;
Signature · 1 line
2.25.1
#9 lore raw

PATCH v5 7/8 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 c36ec8f8d0..7cd581cf7d 100644
@@ -213,3 +213,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
#10 lore raw

PATCH v5 8/8 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