Skip to contentSkip to conversation

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

PATCH Superseded Frank Wunderlich 4 participants 20 messages Aug 19, 2020 – Aug 20, 2020

Subsystems (7)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add MTK AHCI driver, BPI-R64 dts and USB-Nodes for mt7622/mt7623

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

v1->v2:
- made register of phy optional for tphy v1 and remove it in dts

Frank Wunderlich (11):
arm: dts: mt7622: add SATA reset constants
phy: mtk-tphy: add PHY_TYPE_SATA
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 watchdog-reboot node for mt7622
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                 |  92 ++++++++++
 arch/arm/dts/mt7623.dtsi                 |  46 +++++
 arch/arm/dts/mt7623n-bananapi-bpi-r2.dts |  16 ++
 drivers/ata/Kconfig                      |   8 +
 drivers/ata/Makefile                     |   1 +
 drivers/ata/mtk_ahci.c                   | 130 +++++++++++++
 drivers/clk/mediatek/clk-mt7622.c        |  57 ++++++
 drivers/phy/phy-mtk-tphy.c               | 110 ++++++++++-
 include/dt-bindings/reset/mt7629-reset.h |   5 +-
 12 files changed, 693 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/mt7622-bananapi-bpi-r64.dts
 create mode 100644 drivers/ata/mtk_ahci.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/11 arm: dts: mt7622: add SATA reset constants

From: Frank Wunderlich <[email protected]>

add reset constants used for SATA to header file

---
 include/dt-bindings/reset/mt7629-reset.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/dt-bindings/reset/mt7629-reset.h +4 -1
index 8f1634f7a6..311a5cb3d0 100644
@@ -6,7 +6,10 @@
 #ifndef _DT_BINDINGS_MTK_RESET_H_
 #define _DT_BINDINGS_MTK_RESET_H_
 
-/* PCIe Subsystem resets */
+/* PCIe/SATA Subsystem resets */
+#define MT7622_SATA_PHY_REG_RST			12
+#define MT7622_SATA_PHY_SW_RST			13
+#define MT7622_SATA_AXI_BUS_RST			15
 #define PCIE1_CORE_RST			19
 #define PCIE1_MMIO_RST			20
 #define PCIE1_HRST			21
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/11 phy: mtk-tphy: add PHY_TYPE_SATA

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

add support for PHY_TYPE_SATA to Mediateks TPHY driver

---
 drivers/phy/phy-mtk-tphy.c | 105 +++++++++++++++++++++++++++++++++++++
 1 file changed, 105 insertions(+)
drivers/phy/phy-mtk-tphy.c +105 -0
index 1e65c24356..326227a30d 100644
@@ -175,6 +175,65 @@
 #define XC3_RG_U3_XTAL_RX_PWD		BIT(9)
 #define XC3_RG_U3_FRC_XTAL_RX_PWD	BIT(8)
 
+/* SATA register setting */
+#define PHYD_CTRL_SIGNAL_MODE4		0x1c
+/* CDR Charge Pump P-path current adjustment */
+#define RG_CDR_BICLTD1_GEN1_MSK		GENMASK(23, 20)
+#define RG_CDR_BICLTD1_GEN1_VAL(x)	((0xf & (x)) << 20)
+#define RG_CDR_BICLTD0_GEN1_MSK		GENMASK(11, 8)
+#define RG_CDR_BICLTD0_GEN1_VAL(x)	((0xf & (x)) << 8)
+
+#define PHYD_DESIGN_OPTION2		0x24
+/* Symbol lock count selection */
+#define RG_LOCK_CNT_SEL_MSK		GENMASK(5, 4)
+#define RG_LOCK_CNT_SEL_VAL(x)		((0x3 & (x)) << 4)
+
+#define PHYD_DESIGN_OPTION9		0x40
+/* COMWAK GAP width window */
+#define RG_TG_MAX_MSK			GENMASK(20, 16)
+#define RG_TG_MAX_VAL(x)		((0x1f & (x)) << 16)
+/* COMINIT GAP width window */
+#define RG_T2_MAX_MSK			GENMASK(13, 8)
+#define RG_T2_MAX_VAL(x)		((0x3f & (x)) << 8)
+/* COMWAK GAP width window */
+#define RG_TG_MIN_MSK			GENMASK(7, 5)
+#define RG_TG_MIN_VAL(x)		((0x7 & (x)) << 5)
+/* COMINIT GAP width window */
+#define RG_T2_MIN_MSK			GENMASK(4, 0)
+#define RG_T2_MIN_VAL(x)		(0x1f & (x))
+
+#define ANA_RG_CTRL_SIGNAL1		0x4c
+/* TX driver tail current control for 0dB de-empahsis mdoe for Gen1 speed */
+#define RG_IDRV_0DB_GEN1_MSK		GENMASK(13, 8)
+#define RG_IDRV_0DB_GEN1_VAL(x)		((0x3f & (x)) << 8)
+
+#define ANA_RG_CTRL_SIGNAL4		0x58
+#define RG_CDR_BICLTR_GEN1_MSK		GENMASK(23, 20)
+#define RG_CDR_BICLTR_GEN1_VAL(x)	((0xf & (x)) << 20)
+/* Loop filter R1 resistance adjustment for Gen1 speed */
+#define RG_CDR_BR_GEN2_MSK		GENMASK(10, 8)
+#define RG_CDR_BR_GEN2_VAL(x)		((0x7 & (x)) << 8)
+
+#define ANA_RG_CTRL_SIGNAL6		0x60
+/* I-path capacitance adjustment for Gen1 */
+#define RG_CDR_BC_GEN1_MSK		GENMASK(28, 24)
+#define RG_CDR_BC_GEN1_VAL(x)		((0x1f & (x)) << 24)
+#define RG_CDR_BIRLTR_GEN1_MSK		GENMASK(4, 0)
+#define RG_CDR_BIRLTR_GEN1_VAL(x)	(0x1f & (x))
+
+#define ANA_EQ_EYE_CTRL_SIGNAL1		0x6c
+/* RX Gen1 LEQ tuning step */
+#define RG_EQ_DLEQ_LFI_GEN1_MSK		GENMASK(11, 8)
+#define RG_EQ_DLEQ_LFI_GEN1_VAL(x)	((0xf & (x)) << 8)
+
+#define ANA_EQ_EYE_CTRL_SIGNAL4		0xd8
+#define RG_CDR_BIRLTD0_GEN1_MSK		GENMASK(20, 16)
+#define RG_CDR_BIRLTD0_GEN1_VAL(x)	((0x1f & (x)) << 16)
+
+#define ANA_EQ_EYE_CTRL_SIGNAL5		0xdc
+#define RG_CDR_BIRLTD0_GEN3_MSK		GENMASK(4, 0)
+#define RG_CDR_BIRLTD0_GEN3_VAL(x)	(0x1f & (x))
+
 enum mtk_phy_version {
 	MTK_TPHY_V1 = 1,
 	MTK_TPHY_V2,
@@ -372,6 +431,45 @@ static void pcie_phy_instance_init(struct mtk_tphy *tphy,
 	udelay(3000);
 }
 
+static void sata_phy_instance_init(struct mtk_tphy *tphy,
+				   struct mtk_phy_instance *instance)
+{
+	struct u3phy_banks *u3_banks = &instance->u3_banks;
+
+	clrsetbits_le32(u3_banks->phyd + ANA_RG_CTRL_SIGNAL6,
+			RG_CDR_BIRLTR_GEN1_MSK | RG_CDR_BC_GEN1_MSK,
+			RG_CDR_BIRLTR_GEN1_VAL(0x6) |
+			RG_CDR_BC_GEN1_VAL(0x1a));
+	clrsetbits_le32(u3_banks->phyd + ANA_EQ_EYE_CTRL_SIGNAL4,
+			RG_CDR_BIRLTD0_GEN1_MSK,
+			RG_CDR_BIRLTD0_GEN1_VAL(0x18));
+	clrsetbits_le32(u3_banks->phyd + ANA_EQ_EYE_CTRL_SIGNAL5,
+			RG_CDR_BIRLTD0_GEN3_MSK,
+			RG_CDR_BIRLTD0_GEN3_VAL(0x06));
+	clrsetbits_le32(u3_banks->phyd + ANA_RG_CTRL_SIGNAL4,
+			RG_CDR_BICLTR_GEN1_MSK | RG_CDR_BR_GEN2_MSK,
+			RG_CDR_BICLTR_GEN1_VAL(0x0c) |
+			RG_CDR_BR_GEN2_VAL(0x07));
+	clrsetbits_le32(u3_banks->phyd + PHYD_CTRL_SIGNAL_MODE4,
+			RG_CDR_BICLTD0_GEN1_MSK | RG_CDR_BICLTD1_GEN1_MSK,
+			RG_CDR_BICLTD0_GEN1_VAL(0x08) |
+			RG_CDR_BICLTD1_GEN1_VAL(0x02));
+	clrsetbits_le32(u3_banks->phyd + PHYD_DESIGN_OPTION2,
+			RG_LOCK_CNT_SEL_MSK,
+			RG_LOCK_CNT_SEL_VAL(0x02));
+	clrsetbits_le32(u3_banks->phyd + PHYD_DESIGN_OPTION9,
+			RG_T2_MIN_MSK | RG_TG_MIN_MSK |
+			RG_T2_MAX_MSK | RG_TG_MAX_MSK,
+			RG_T2_MIN_VAL(0x12) | RG_TG_MIN_VAL(0x04) |
+			RG_T2_MAX_VAL(0x31) | RG_TG_MAX_VAL(0x0e));
+	clrsetbits_le32(u3_banks->phyd + ANA_RG_CTRL_SIGNAL1,
+			RG_IDRV_0DB_GEN1_MSK,
+			RG_IDRV_0DB_GEN1_VAL(0x20));
+	clrsetbits_le32(u3_banks->phyd + ANA_EQ_EYE_CTRL_SIGNAL1,
+			RG_EQ_DLEQ_LFI_GEN1_MSK,
+			RG_EQ_DLEQ_LFI_GEN1_VAL(0x03));
+}
+
 static void pcie_phy_instance_power_on(struct mtk_tphy *tphy,
 				       struct mtk_phy_instance *instance)
 {
@@ -414,6 +512,9 @@ static void phy_v1_banks_init(struct mtk_tphy *tphy,
 		u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V1_U3PHYD;
 		u3_banks->phya = instance->port_base + SSUSB_SIFSLV_V1_U3PHYA;
 		break;
+	case PHY_TYPE_SATA:
+		u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V1_U3PHYD;
+		break;
 	default:
 		dev_err(tphy->dev, "incompatible PHY type\n");
 		return;
@@ -474,6 +575,9 @@ static int mtk_phy_init(struct phy *phy)
 	case PHY_TYPE_PCIE:
 		pcie_phy_instance_init(tphy, instance);
 		break;
+	case PHY_TYPE_SATA:
+		sata_phy_instance_init(tphy, instance);
+		break;
 	default:
 		dev_err(tphy->dev, "incompatible PHY type\n");
 		return -EINVAL;
@@ -552,6 +656,7 @@ static int mtk_phy_xlate(struct phy *phy,
 	instance->type = args->args[1];
 	if (!(instance->type == PHY_TYPE_USB2 ||
 	      instance->type == PHY_TYPE_USB3 ||
+	      instance->type == PHY_TYPE_SATA ||
 	      instance->type == PHY_TYPE_PCIE)) {
 		dev_err(phy->dev, "unsupported device type\n");
 		return -EINVAL;
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/11 phy: mtk-tphy: make shared reg optional for v1

In reply to Frank Wunderlich

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

PATCH v2 4/11 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 | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/clk/mediatek/clk-mt7622.c +15 -0
index bd86b5b974..d53ed69189 100644
@@ -594,6 +594,20 @@ static int mt7622_pciesys_probe(struct udevice *dev)
 	return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, pcie_cgs);
 }
 
+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");
+	}
+
+	return ret;
+}
+
 static int mt7622_ethsys_probe(struct udevice *dev)
 {
 	return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, eth_cgs);
@@ -710,6 +724,7 @@ U_BOOT_DRIVER(mtk_clk_pciesys) = {
 	.id = UCLASS_CLK,
 	.of_match = mt7622_pciesys_compat,
 	.probe = mt7622_pciesys_probe,
+	.bind = mt7622_pciesys_bind,
 	.priv_auto_alloc_size = sizeof(struct mtk_cg_priv),
 	.ops = &mtk_clk_gate_ops,
 };
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 5/11 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/Kconfig    |   8 +++
 drivers/ata/Makefile   |   1 +
 drivers/ata/mtk_ahci.c | 130 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 139 insertions(+)
 create mode 100644 drivers/ata/mtk_ahci.c
drivers/ata/Kconfig +8 -0
index d8c9756c2a..f2f8275aec 100644
@@ -130,4 +130,12 @@ config AHCI_MVEBU
 	  onboard AHCI SATA.
 
 	  If unsure, say N.
+
+config MTK_AHCI
+	bool "Enable Mediatek AHCI driver support"
+	depends on AHCI
+	help
+	  Enable this driver to support Sata devices through
+	  Mediatek AHCI controller (e.g. MT7622).
+
 endmenu
drivers/ata/Makefile +1 -0
index a69edb10f7..98fb480700 100644
@@ -19,3 +19,4 @@ obj-$(CONFIG_SATA_SIL) += sata_sil.o
 obj-$(CONFIG_SANDBOX) += sata_sandbox.o
 obj-$(CONFIG_AHCI_MVEBU) += ahci_mvebu.o
 obj-$(CONFIG_SUNXI_AHCI) += ahci_sunxi.o
+obj-$(CONFIG_MTK_AHCI) += mtk_ahci.o
drivers/ata/mtk_ahci.c new file +130 -0

130 lines not on this page · raw message

Signature · 1 line
2.25.1
#11 lore raw

PATCH v2 6/11 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 d53ed69189..ebb45498db 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,
@@ -631,6 +654,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" },
 	{ }
@@ -671,6 +699,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,
@@ -747,3 +780,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
#12 lore raw

PATCH v2 7/11 arm: dts: add watchdog-reboot node for mt7622

In reply to Frank Wunderlich

From: Frank Wunderlich <[email protected]>

adding a wdt-reboot node to mt7622 dtsi

---
 arch/arm/dts/mt7622.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/dts/mt7622.dtsi +5 -0
index d0783bc9ff..fec071643e 100644
@@ -142,6 +142,11 @@
 		reg = <0x10212000 0x800>;
 	};
 
+	wdt-reboot {
+		compatible = "wdt-reboot";
+		wdt = <&watchdog>;
+	};
+
 	gic: interrupt-controller at 10300000 {
 		compatible = "arm,gic-400";
 		interrupt-controller;
Signature · 1 line
2.25.1
#13 lore raw

PATCH v2 8/11 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 8ecf63e988..ff0e76f808 100644
@@ -959,6 +959,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 \
 	mt7623n-bananapi-bpi-r2.dtb \
 	mt7629-rfb.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
#14 lore raw

PATCH v2 9/11 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                 | 31 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
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 +31 -0
index fec071643e..6b4260407e 100644
@@ -10,6 +10,7 @@
 #include <dt-bindings/power/mt7629-power.h>
 #include <dt-bindings/reset/mt7629-reset.h>
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/phy/phy.h>
 
 / {
 	compatible = "mediatek,mt7622";
@@ -270,6 +271,36 @@
 		};
 	};
 
+	sata: sata at 1a200000 {
+		compatible = "mediatek,mtk-ahci";
+		reg = <0x1a200000 0x1100>;
+		resets = <&pciesys MT7622_SATA_AXI_BUS_RST>,
+			<&pciesys MT7622_SATA_PHY_SW_RST>,
+			<&pciesys MT7622_SATA_PHY_REG_RST>;
+		reset-names = "axi", "sw", "reg";
+		mediatek,phy-mode = <&pciesys>;
+		ports-implemented = <0x1>;
+		phys = <&sata_port PHY_TYPE_SATA>;
+		phy-names = "sata-phy";
+		status = "okay";
+	};
+
+	sata_phy: sata-phy at 1a243000 {
+		compatible = "mediatek,generic-tphy-v1";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+		status = "okay";
+
+		sata_port: sata-phy at 1a243000 {
+			reg = <0x1a243000 0x0100>;
+			clocks = <&topckgen CLK_TOP_ETH_500M>;
+			clock-names = "ref";
+			#phy-cells = <1>;
+			status = "okay";
+		};
+	};
+
 	ethsys: syscon at 1b000000 {
 		compatible = "mediatek,mt7622-ethsys", "syscon";
 		reg = <0x1b000000 0x1000>;
Signature · 1 line
2.25.1
#18 lore raw

PATCH v2 10/11 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
#19 lore raw

PATCH v2 11/11 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
#4 lore raw

PATCH v2 3/11 phy: mtk-tphy: make shared reg optional for v1

In reply to Frank Wunderlich
Quoted 16 lines · Frank Wunderlich

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 +0 -0
index 326227a30d..3d7b9cd2b1 100644
@@ -698,11 +698,10 @@ static int mtk_tphy_probe(struct udevice *dev)
 	tphy->dev = dev;

drivers/phy/phy-mtk-tphy.c static int mtk_tphy_probe(struct udevice *dev) · line 705

Quoted 10 lines
drivers/phy/phy-mtk-tphy.c +2 -3
 	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;
 	}

Thanks

Quoted 2 lines
drivers/phy/phy-mtk-tphy.c +0 -0
 	dev_for_each_subnode(subnode, dev) {
#6 lore raw

PATCH v2 4/11 reset: add basic reset controller for pciesys

In reply to Frank Wunderlich

Hi Frank,

Thanks your for your patches.
some suggestions for coding style.

Quoted 14 lines · Frank Wunderlich

From: Frank Wunderlich <[email protected]>

bind reset controller to pciesys

---
 drivers/clk/mediatek/clk-mt7622.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/clk/mediatek/clk-mt7622.c +0 -0
index bd86b5b974..d53ed69189 100644

drivers/clk/mediatek/clk-mt7622.c static int mt7622_pciesys_probe(struct udevice *dev) · line 602

Quoted 9 lines
drivers/clk/mediatek/clk-mt7622.c +6 -0
@@ -594,6 +594,20 @@ static int mt7622_pciesys_probe(struct udevice *dev)
 	return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, pcie_cgs);
 }
 
+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

No need to add special comments that are not easy to understand, and please uses "/* */" instead of "//".

Thanks,
Best Regards,
Sam Shih

#9 lore raw

PATCH v2 5/11 ahci: mediatek: add ahci driver

In reply to Frank Wunderlich

Hi Frank,
Thanks your for your patches.
some suggestions for coding style.O

Quoted 17 lines

From: Frank Wunderlich <[email protected]>

drivers/ata/Makefile +1 -0
index a69edb10f7..98fb480700 100644
@@ -19,3 +19,4 @@ obj-$(CONFIG_SATA_SIL) += sata_sil.o
 obj-$(CONFIG_SANDBOX) += sata_sandbox.o
 obj-$(CONFIG_AHCI_MVEBU) += ahci_mvebu.o
 obj-$(CONFIG_SUNXI_AHCI) += ahci_sunxi.o
+obj-$(CONFIG_MTK_AHCI) += mtk_ahci.o
drivers/ata/mtk_ahci.c new file +0 -0
new file mode 100644
index 0000000000..8e09c5f9e6

drivers/ata/mtk_ahci.c line 6

Quoted 6 lines
drivers/ata/mtk_ahci.c new file +6 -0
@@ -0,0 +1,130 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * MTK SATA platform driver
+ *
+ * (C) Copyright 2020
+ *     Mediatek

Please make copyright in the same line.
Copyright (C) 2020 MediaTek Inc.

drivers/ata/mtk_ahci.c line 9

Quoted 3 lines
drivers/ata/mtk_ahci.c new file +3 -0
+ *
+ * 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

Don't place this line between the Author tags

drivers/ata/mtk_ahci.c line 11

Quoted 2 lines
drivers/ata/mtk_ahci.c new file +2 -0
+ * Author: Ryder Lee <[email protected]>
+ */

Thanks,
Best Regards,
Sam Shih

#15 lore raw

PATCH v2 9/11 arm: dts: mt7622: add sata- and asm_sel nodes

In reply to Frank Wunderlich
Quoted 55 lines · 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                 | 31 ++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
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 +10 -0
index fec071643e..6b4260407e 100644
@@ -10,6 +10,7 @@
 #include <dt-bindings/power/mt7629-power.h>
 #include <dt-bindings/reset/mt7629-reset.h>
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/phy/phy.h>
 
 / {
 	compatible = "mediatek,mt7622";
@@ -270,6 +271,36 @@
 		};
 	};
 
+	sata: sata at 1a200000 {
+		compatible = "mediatek,mtk-ahci";
+		reg = <0x1a200000 0x1100>;
+		resets = <&pciesys MT7622_SATA_AXI_BUS_RST>,
+			<&pciesys MT7622_SATA_PHY_SW_RST>,
+			<&pciesys MT7622_SATA_PHY_REG_RST>;
+		reset-names = "axi", "sw", "reg";
+		mediatek,phy-mode = <&pciesys>;
+		ports-implemented = <0x1>;

arch/arm/dts/mt7622.dtsi line 292

Quoted 10 lines
arch/arm/dts/mt7622.dtsi +10 -0
+		phys = <&sata_port PHY_TYPE_SATA>;
+		phy-names = "sata-phy";
+		status = "okay";
+	};
+
+	sata_phy: sata-phy at 1a243000 {
+		compatible = "mediatek,generic-tphy-v1";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;

we can use ranges with parameters if you send next version, otherwise no change is also fine to me.

ranges=<0 0x1a243000 0x100>;

arch/arm/dts/mt7622.dtsi line 296

Quoted 4 lines
arch/arm/dts/mt7622.dtsi +4 -0
+		status = "okay";
+
+		sata_port: sata-phy at 1a243000 {
+			reg = <0x1a243000 0x0100>;
sata_port: sata-phy at 0 {
	reg = <0x0 0x0100>;

arch/arm/dts/mt7622.dtsi line 302

Quoted 6 lines
arch/arm/dts/mt7622.dtsi +6 -0
+			clocks = <&topckgen CLK_TOP_ETH_500M>;
+			clock-names = "ref";
+			#phy-cells = <1>;
+			status = "okay";
+		};
+	};

For phy part,

thanks

Quoted 4 lines
arch/arm/dts/mt7622.dtsi +1 -0
+
 	ethsys: syscon at 1b000000 {
 		compatible = "mediatek,mt7622-ethsys", "syscon";
 		reg = <0x1b000000 0x1000>;
#16 lore raw

Aw: Re: [PATCH v2 09/11] arm: dts: mt7622: add sata- and asm_sel nodes

Hi

Quoted 11 lines

Gesendet: Mittwoch, 19. August 2020 um 10:54 Uhr
Von: "Chunfeng Yun" <[email protected]>

arch/arm/dts/mt7622.dtsi line 292

Quoted 5 lines
arch/arm/dts/mt7622.dtsi +5 -0
+	sata_phy: sata-phy at 1a243000 {
+		compatible = "mediatek,generic-tphy-v1";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;

we can use ranges with parameters if you send next version, otherwise no change is also fine to me.

ranges=<0 0x1a243000 0x100>;

i took the dts-part from linux where ranges is also empty

https://elixir.bootlin.com/linux/latest/source/arch/arm64/boot/dts/mediatek/mt7622.dtsi#L880

why should ranges have a value when i recently removed the reg (after making it optional)?

Quoted 2 lines

For phy part,

any issues in sata-node/gpio-hog?

regards Frank

#7 lore raw

Aw: Re: [PATCH v2 04/11] reset: add basic reset controller for pciesys

In reply to Sam Shih

Hi

Quoted 7 lines

Gesendet: Mittwoch, 19. August 2020 um 10:33 Uhr
Von: "Sam Shih" <[email protected]>

drivers/clk/mediatek/clk-mt7622.c static int mt7622_pciesys_probe(struct udevice *dev) · line 602

Quoted 2 lines
drivers/clk/mediatek/clk-mt7622.c +2 -0
+	if (IS_ENABLED(CONFIG_RESET_MEDIATEK)) {
+//	PCIESYS uses in linux also 0x34 = ETHSYS reset controller

No need to add special comments that are not easy to understand, and please uses "/* */" instead of "//".

should i remove it or use other words?

maybe we can use mt7622_ethsys_bind for binding pciesys? basicly it's same code

regards Frank

#10 lore raw

Aw: Re: [PATCH v2 05/11] ahci: mediatek: add ahci driver

In reply to Sam Shih

Hi

Quoted 5 lines

Gesendet: Mittwoch, 19. August 2020 um 10:38 Uhr
Von: "Sam Shih" <[email protected]>

Please make copyright in the same line.
Copyright (C) 2020 MediaTek Inc.

OK

Quoted 8 lines
Quoted 3 lines

+ *
+ * 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

Don't place this line between the Author tags

Quoted 2 lines

+ * Author: Ryder Lee <[email protected]>
+ */

should i drop the link? and put ryder first because original code in linux was from him...meybe this way it is more clear without link to linux-code

regards Frank

#17 lore raw

Aw: Re: [PATCH v2 09/11] arm: dts: mt7622: add sata- and asm_sel nodes

In reply to Frank Wunderlich
Quoted 12 lines · Frank Wunderlich

Hi

Quoted 10 lines

Gesendet: Mittwoch, 19. August 2020 um 10:54 Uhr
Von: "Chunfeng Yun" <[email protected]>

arch/arm/dts/mt7622.dtsi line 292

Quoted 5 lines
arch/arm/dts/mt7622.dtsi +5 -0
+	sata_phy: sata-phy at 1a243000 {
+		compatible = "mediatek,generic-tphy-v1";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;

we can use ranges with parameters if you send next version, otherwise no change is also fine to me.

Quoted 6 lines
Quoted 1 line

ranges=<0 0x1a243000 0x100>;

i took the dts-part from linux where ranges is also empty

https://elixir.bootlin.com/linux/latest/source/arch/arm64/boot/dts/mediatek/mt7622.dtsi#L880

I think it follows the early dt-binding doc of tphy, I modify it later.

Quoted 1 line

why should ranges have a value when i recently removed the reg (after making it optional)?

Both are ok, but prefer to use translation way:)

Without shared registers, it's simple and clear to use address translation from parent-bus-address to child-bus-address.
e.g. subnode: usb-phy at 0, usb-phy at 1000, they tell us the offset at the same time.

Quoted 5 lines
Quoted 3 lines

For phy part,

any issues in sata-node/gpio-hog?

Also looks good to me

Quoted 2 lines

regards Frank