Skip to contentSkip to conversation

Add and update drivers for MediaTek MT76x8 SoCs

PATCH New Weijie Gao 3 participants 33 messages Sep 25, 2019 – Oct 18, 2019

Subsystems (10)
lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

v3 cover Add and update drivers for MediaTek MT76x8 SoCs

This patch series have the following changes:

- Add pinctrl(both pinmux and pinconf) driver, reset controller driver and clock driver for mt7628.
- Add mt7628 platform to mtk-sd driver.
- Modify mt7628's ethernet & usb phy driver to take advantages from the new drivers.
- Update mt7621-spi driver with a new transfer method.
- Enable fifo, disable flow control, and enable non-DM implementation for mtk hsuart driver.
- Enanble the new drivers for currently existed mt7628 boards.

Changes of v2:
- Change clock gateing driver to a more 'generic' driver which supports output clock rates of CPU/SYS_BUS/peripherals.
- mt7621-spi now uses accurate sys_freq from clock driver.
- Make PHY link detection optional via DT.
- Select essential drivers in Kconfig instead of setting in defconfig files.

Changes of v3:
- Add const qualifier for structs in pinctrl-mt7628.c.
- Make mt76x8-usb-phy depends on SOC_MT7628.
- Simplify logic of card-detection in mtk-sd.c.

Weijie Gao (28):
serial: serial_mtk: enable FIFO and disable flow control
serial: serial_mtk: add non-DM version for SPL
dts: mtmips: move uart property clock-frequency into mt7628an.dtsi
dts: mtmips: enable high-speed UART support for mt7628
clk: add clock driver for MediaTek MT76x8 platform
dts: mtmips: add clock node for mt7628
spi: mt7621-spi: use clock frequency from clk driver
spi: mt7621-spi: remove data cache and rewrite its xfer function
spi: mt7621-spi: restore default register value after each xfer
pinctrl: add support for MediaTek MT7628
dts: mtmips: add pinctrl node for mt7628
dts: mtmips: add default pinctrl for uart nodes
reset: add reset controller driver for MediaTek MIPS platform
dts: mtmips: update reset controller node for mt7628
phy: mt76x8-usb-phy: add slew rate calibration and remove non-mt7628
part
net: mt7628-eth: remove hardcoded gpio settings and regmap-based phy
reset
net: mt7628-eth: make phy link up detection optional via DT
net: mt7628-eth: free rx descriptor on receiving failure
net: mt7628-eth: add support to isolate LAN/WAN ports
dts: mtmips: enable eth port0 led and link poll functions for all
boards
mmc: mtk-sd: add support for MediaTek MT7620/MT7628 SoCs
mmc: mtk-sd: add a dts property cd-active-high for builtin-cd mode
dts: mtmips: add mmc related nodes for mt7628an.dtsi
dts: mtmips: add default pinctrl for gardena-smart-gateway-mt7688
dts: mtmips: add default pinctrl to eth nodes for all boards
mips: mtmips: change baudrate table for all boards
mips: mtmips: select essential drivers in Kconfig
configs: mtmips: remove configs which are selected in Kconfig or
useless

 arch/mips/Kconfig                             |   6 +
 .../mips/dts/gardena-smart-gateway-mt7688.dts |  19 +-
 arch/mips/dts/linkit-smart-7688.dts           |  16 +-
 arch/mips/dts/mt7628a.dtsi                    | 246 +++++++-
 arch/mips/mach-mtmips/Kconfig                 |   2 +
 ...gardena-smart-gateway-mt7688-ram_defconfig |   7 -
 .../gardena-smart-gateway-mt7688_defconfig    |   7 -
 configs/linkit-smart-7688-ram_defconfig       |   7 -
 configs/linkit-smart-7688_defconfig           |   7 -
 drivers/clk/Makefile                          |   1 +
 drivers/clk/mtmips/Makefile                   |   3 +
 drivers/clk/mtmips/clk-mt7628.c               | 158 +++++
 drivers/mmc/Kconfig                           |   2 +-
 drivers/mmc/mtk-sd.c                          |  29 +-
 drivers/net/Kconfig                           |   1 +
 drivers/net/mt7628-eth.c                      | 135 ++--
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/mt76x8-usb-phy.c                  | 225 +++++--
 drivers/pinctrl/Kconfig                       |   1 +
 drivers/pinctrl/Makefile                      |   1 +
 drivers/pinctrl/mtmips/Kconfig                |  13 +
 drivers/pinctrl/mtmips/Makefile               |   7 +
 drivers/pinctrl/mtmips/pinctrl-mt7628.c       | 585 ++++++++++++++++++
 .../pinctrl/mtmips/pinctrl-mtmips-common.c    |  87 +++
 .../pinctrl/mtmips/pinctrl-mtmips-common.h    |  53 ++
 drivers/reset/Kconfig                         |   7 +
 drivers/reset/Makefile                        |   1 +
 drivers/reset/reset-mtmips.c                  |  82 +++
 drivers/serial/serial.c                       |   2 +
 drivers/serial/serial_mtk.c                   | 223 ++++++-
 drivers/spi/mt7621_spi.c                      | 247 ++++----
 .../configs/gardena-smart-gateway-mt7688.h    |   2 +-
 include/configs/linkit-smart-7688.h           |   2 +-
 include/dt-bindings/clock/mt7628-clk.h        |  37 ++
 include/dt-bindings/reset/mt7628-reset.h      |  36 ++
 35 files changed, 1929 insertions(+), 329 deletions(-)
 create mode 100644 drivers/clk/mtmips/Makefile
 create mode 100644 drivers/clk/mtmips/clk-mt7628.c
 create mode 100644 drivers/pinctrl/mtmips/Kconfig
 create mode 100644 drivers/pinctrl/mtmips/Makefile
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7628.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.h
 create mode 100644 drivers/reset/reset-mtmips.c
 create mode 100644 include/dt-bindings/clock/mt7628-clk.h
 create mode 100644 include/dt-bindings/reset/mt7628-reset.h
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v3 1/28 serial: serial_mtk: enable FIFO and disable flow control

This patch adds codes to enable FIFO and disable flow control taken from ns16550 driver.

---
 drivers/serial/serial_mtk.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/serial/serial_mtk.c +21 -0
index bce1be8227..11892a8740 100644
@@ -46,6 +46,22 @@ struct mtk_serial_regs {
 
 #define UART_LSR_DR	0x01		/* Data ready */
 #define UART_LSR_THRE	0x20		/* Xmit holding register empty */
+#define UART_LSR_TEMT	0x40		/* Xmitter empty */
+
+#define UART_MCR_DTR	0x01		/* DTR   */
+#define UART_MCR_RTS	0x02		/* RTS   */
+
+#define UART_FCR_FIFO_EN	0x01	/* Fifo enable */
+#define UART_FCR_RXSR		0x02	/* Receiver soft reset */
+#define UART_FCR_TXSR		0x04	/* Transmitter soft reset */
+
+#define UART_MCRVAL (UART_MCR_DTR | \
+		     UART_MCR_RTS)
+
+/* Clear & enable FIFOs */
+#define UART_FCRVAL (UART_FCR_FIFO_EN | \
+		     UART_FCR_RXSR |	\
+		     UART_FCR_TXSR)
 
 /* the data is correct if the real baud is within 3%. */
 #define BAUD_ALLOW_MAX(baud)	((baud) + (baud) * 3 / 100)
@@ -175,6 +191,9 @@ static int mtk_serial_probe(struct udevice *dev)
 	/* Disable interrupt */
 	writel(0, &priv->regs->ier);
 
+	writel(UART_MCRVAL, &priv->regs->mcr);
+	writel(UART_FCRVAL, &priv->regs->fcr);
+
 	return 0;
 }
 
@@ -248,6 +267,8 @@ static inline void _debug_uart_init(void)
 	priv.clock = CONFIG_DEBUG_UART_CLOCK;
 
 	writel(0, &priv.regs->ier);
+	writel(UART_MCRVAL, &priv.regs->mcr);
+	writel(UART_FCRVAL, &priv.regs->fcr);
 
 	_mtk_serial_setbrg(&priv, CONFIG_BAUDRATE);
 }
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v3 2/28 serial: serial_mtk: add non-DM version for SPL

In reply to Weijie Gao

This patch adds non-DM version for mtk hsuart driver and makes it compatible with ns16550a driver in configuration.
This is needed in SPL with CONFIG_SPL_DM disabled for reducing size.

---
 drivers/serial/serial.c     |   2 +
 drivers/serial/serial_mtk.c | 202 +++++++++++++++++++++++++++++++++---
 2 files changed, 187 insertions(+), 17 deletions(-)
drivers/serial/serial.c +2 -0
index b907508dbe..bf5f39215d 100644
@@ -124,6 +124,7 @@ serial_initfunc(ns16550_serial_initialize);
 serial_initfunc(pl01x_serial_initialize);
 serial_initfunc(pxa_serial_initialize);
 serial_initfunc(sh_serial_initialize);
+serial_initfunc(mtk_serial_initialize);
 
 /**
  * serial_register() - Register serial driver with serial driver core
@@ -177,6 +178,7 @@ void serial_initialize(void)
 	pl01x_serial_initialize();
 	pxa_serial_initialize();
 	sh_serial_initialize();
+	mtk_serial_initialize();
 
 	serial_assign(default_serial_console()->name);
 }
drivers/serial/serial_mtk.c +185 -17

232 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#3 lore raw

PATCH v3 3/28 dts: mtmips: move uart property clock-frequency into mt7628an.dtsi

In reply to Weijie Gao

The UART of MT7628 has fixed 40MHz input clock so there is no need to put clock-frequency in every dts files. Just put it into the common dtsi file.

---
 arch/mips/dts/gardena-smart-gateway-mt7688.dts | 1 -
 arch/mips/dts/linkit-smart-7688.dts            | 1 -
 arch/mips/dts/mt7628a.dtsi                     | 6 ++++++
 3 files changed, 6 insertions(+), 2 deletions(-)
arch/mips/dts/gardena-smart-gateway-mt7688.dts +0 -1
index eedde89dfd..95675a3947 100644
@@ -87,7 +87,6 @@
 
 &uart0 {
 	status = "okay";
-	clock-frequency = <40000000>;
 };
 
 &spi0 {
arch/mips/dts/linkit-smart-7688.dts +0 -1
index bb10402174..935315743c 100644
@@ -28,7 +28,6 @@
 
 &uart2 {
 	status = "okay";
-	clock-frequency = <40000000>;
 };
 
 &spi0 {
arch/mips/dts/mt7628a.dtsi +6 -0
index 1e7d0a6ec5..6bc0722b07 100644
@@ -127,6 +127,8 @@
 			compatible = "ns16550a";
 			reg = <0xc00 0x100>;
 
+			clock-frequency = <40000000>;
+
 			resets = <&resetc 12>;
 			reset-names = "uart0";
 
@@ -140,6 +142,8 @@
 			compatible = "ns16550a";
 			reg = <0xd00 0x100>;
 
+			clock-frequency = <40000000>;
+
 			resets = <&resetc 19>;
 			reset-names = "uart1";
 
@@ -153,6 +157,8 @@
 			compatible = "ns16550a";
 			reg = <0xe00 0x100>;
 
+			clock-frequency = <40000000>;
+
 			resets = <&resetc 20>;
 			reset-names = "uart2";
 
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v3 4/28 dts: mtmips: enable high-speed UART support for mt7628

In reply to Weijie Gao

All three UARTs of mt7628 are actually MediaTek's high-speed UARTs which support baudrate up to 921600.
The high-speed UART is compatible with ns16550 when baudrate <= 115200.

Add compatible string to dtsi file so u-boot can use it when serial_mtk driver is built in.

---
 arch/mips/dts/mt7628a.dtsi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/dts/mt7628a.dtsi +3 -3
index 6bc0722b07..e9241a0737 100644
@@ -124,7 +124,7 @@
 		};
 
 		uart0: uartlite at c00 {
-			compatible = "ns16550a";
+			compatible = "mediatek,hsuart", "ns16550a";
 			reg = <0xc00 0x100>;
 
 			clock-frequency = <40000000>;
@@ -139,7 +139,7 @@
 		};
 
 		uart1: uart1 at d00 {
-			compatible = "ns16550a";
+			compatible = "mediatek,hsuart", "ns16550a";
 			reg = <0xd00 0x100>;
 
 			clock-frequency = <40000000>;
@@ -154,7 +154,7 @@
 		};
 
 		uart2: uart2 at e00 {
-			compatible = "ns16550a";
+			compatible = "mediatek,hsuart", "ns16550a";
 			reg = <0xe00 0x100>;
 
 			clock-frequency = <40000000>;
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v3 5/28 clk: add clock driver for MediaTek MT76x8 platform

In reply to Weijie Gao

This patch adds a clock driver for MediaTek MT7628/7688 SoC. It provides clock gate control as well as getting clock frequency for CPU/SYS/XTAL and some peripherals.

---
v2: Changed to a more generic clock driver rather than a gateing only driver.
Now supports output clock rate of some devices which may be used in DT.

---
 drivers/clk/Makefile                   |   1 +
 drivers/clk/mtmips/Makefile            |   3 +
 drivers/clk/mtmips/clk-mt7628.c        | 158 +++++++++++++++++++++++++
 include/dt-bindings/clock/mt7628-clk.h |  37 ++++++
 4 files changed, 199 insertions(+)
 create mode 100644 drivers/clk/mtmips/Makefile
 create mode 100644 drivers/clk/mtmips/clk-mt7628.c
 create mode 100644 include/dt-bindings/clock/mt7628-clk.h
drivers/clk/Makefile +1 -0
index 68aabe1ca9..6a86894084 100644
@@ -16,6 +16,7 @@ obj-y += imx/
 obj-y += tegra/
 obj-$(CONFIG_ARCH_ASPEED) += aspeed/
 obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/
+obj-$(CONFIG_ARCH_MTMIPS) += mtmips/
 obj-$(CONFIG_ARCH_MESON) += meson/
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
 obj-$(CONFIG_ARCH_SOCFPGA) += altera/
drivers/clk/mtmips/Makefile new file +3 -0
new file mode 100644
index 0000000000..e1938418da
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_SOC_MT7628) += clk-mt7628.o
drivers/clk/mtmips/clk-mt7628.c new file +158 -0

158 lines not on this page · raw message

include/dt-bindings/clock/mt7628-clk.h new file +37 -0
new file mode 100644
index 0000000000..b5866fdc0e
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 MediaTek Inc.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_MT7628_CLK_H_
+#define _DT_BINDINGS_MT7628_CLK_H_
+
+/* Base clocks */
+#define CLK_SYS				34
+#define CLK_CPU				33
+#define CLK_XTAL			32
+
+/* Peripheral clocks */
+#define CLK_PWM				31
+#define CLK_SDXC			30
+#define CLK_CRYPTO			29
+#define CLK_MIPS_CNT			28
+#define CLK_PCIE			26
+#define CLK_UPHY			25
+#define CLK_ETH				23
+#define CLK_UART2			20
+#define CLK_UART1			19
+#define CLK_SPI				18
+#define CLK_I2S				17
+#define CLK_I2C				16
+#define CLK_GDMA			14
+#define CLK_PIO				13
+#define CLK_UART0			12
+#define CLK_PCM				11
+#define CLK_MC				10
+#define CLK_INTC			9
+#define CLK_TIMER			8
+
+#endif /* _DT_BINDINGS_MT7628_CLK_H_ */
Signature · 1 line
2.17.1
author
#6 lore raw

PATCH v3 6/28 dts: mtmips: add clock node for mt7628

In reply to Weijie Gao

This patch adds clkctrl node for mt7628 and adds clocks property for some node.

---
v2: Changed clkgate node to clkctrl node.
Replaced clock-frequency with <&clkctrl CLK_UARTx> for uarts and spi.

---
 arch/mips/dts/mt7628a.dtsi | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
arch/mips/dts/mt7628a.dtsi +17 -4
index e9241a0737..6d2142f429 100644
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <dt-bindings/clock/mt7628-clk.h>
 
 / {
 	#address-cells = <1>;
@@ -48,6 +49,14 @@
 			mask = <0x1>;
 		};
 
+		clkctrl: clkctrl at 0x2c {
+			reg = <0x2c 0x8>, <0x10 0x4>;
+			reg-names = "syscfg0", "clkcfg";
+			compatible = "mediatek,mt7628-clk";
+			#clock-cells = <1>;
+			u-boot,dm-pre-reloc;
+		};
+
 		watchdog: watchdog at 100 {
 			compatible = "ralink,mt7628a-wdt", "mediatek,mt7621-wdt";
 			reg = <0x100 0x30>;
@@ -120,14 +129,14 @@
 			#address-cells = <1>;
 			#size-cells = <0>;
 
-			clock-frequency = <200000000>;
+			clocks = <&clkctrl CLK_SPI>;
 		};
 
 		uart0: uartlite at c00 {
 			compatible = "mediatek,hsuart", "ns16550a";
 			reg = <0xc00 0x100>;
 
-			clock-frequency = <40000000>;
+			clocks = <&clkctrl CLK_UART0>;
 
 			resets = <&resetc 12>;
 			reset-names = "uart0";
@@ -142,7 +151,7 @@
 			compatible = "mediatek,hsuart", "ns16550a";
 			reg = <0xd00 0x100>;
 
-			clock-frequency = <40000000>;
+			clocks = <&clkctrl CLK_UART1>;
 
 			resets = <&resetc 19>;
 			reset-names = "uart1";
@@ -157,7 +166,7 @@
 			compatible = "mediatek,hsuart", "ns16550a";
 			reg = <0xe00 0x100>;
 
-			clock-frequency = <40000000>;
+			clocks = <&clkctrl CLK_UART2>;
 
 			resets = <&resetc 20>;
 			reset-names = "uart2";
@@ -184,8 +193,12 @@
 		#phy-cells = <0>;
 
 		ralink,sysctl = <&sysc>;
+
 		resets = <&resetc 22 &resetc 25>;
 		reset-names = "host", "device";
+
+		clocks = <&clkctrl CLK_UPHY>;
+		clock-names = "cg";
 	};
 
 	ehci at 101c0000 {
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v3 7/28 spi: mt7621-spi: use clock frequency from clk driver

In reply to Weijie Gao

This patch lets the spi driver to use clock provided by the clk driver since the new clk-mt7628 driver provides accurate sys clock frequency.

---
v2: newly added

---
 drivers/spi/mt7621_spi.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/spi/mt7621_spi.c +13 -7
index 107e58f657..b37f859b98 100644
@@ -9,6 +9,7 @@
  */
 
 #include <common.h>
+#include <clk.h>
 #include <dm.h>
 #include <spi.h>
 #include <wait_bit.h>
@@ -266,19 +267,24 @@ static int mt7621_spi_xfer(struct udevice *dev, unsigned int bitlen,
 static int mt7621_spi_probe(struct udevice *dev)
 {
 	struct mt7621_spi *rs = dev_get_priv(dev);
+	struct clk clk;
+	int ret;
 
 	rs->base = dev_remap_addr(dev);
 	if (!rs->base)
 		return -EINVAL;
 
-	/*
-	 * Read input clock via DT for now. At some point this should be
-	 * replaced by implementing a clock driver for this SoC and getting
-	 * the SPI frequency via this clock driver.
-	 */
-	rs->sys_freq = dev_read_u32_default(dev, "clock-frequency", 0);
+	ret = clk_get_by_index(dev, 0, &clk);
+	if (ret < 0) {
+		printf("Please provide a clock!\n");
+		return ret;
+	}
+
+	clk_enable(&clk);
+
+	rs->sys_freq = clk_get_rate(&clk);
 	if (!rs->sys_freq) {
-		printf("Please provide clock-frequency!\n");
+		printf("Please provide a valid clock!\n");
 		return -EINVAL;
 	}
 
Signature · 1 line
2.17.1
author
#8 lore raw

PATCH v3 8/28 spi: mt7621-spi: remove data cache and rewrite its xfer function

In reply to Weijie Gao

The mt7621 spi controller supports continuous generic half-duplex spi transaction. There is no need to cache xfer data at all.

To achieve this goal, the OPADDR register must be used as the first data to be sent. And follows the eight generic DIDO registers. But one thing different between OPADDR and DIDO registers is OPADDR has a reversed byte order.

With this patch, any amount of data can be read/written in a single xfer function call.

---
 drivers/spi/mt7621_spi.c | 197 ++++++++++++++++++---------------------
 1 file changed, 91 insertions(+), 106 deletions(-)
drivers/spi/mt7621_spi.c +91 -106
index b37f859b98..716256ab59 100644
@@ -15,9 +15,8 @@
 #include <wait_bit.h>
 #include <linux/io.h>
 
-#define SPI_MSG_SIZE_MAX	32	/* SPI message chunk size */
-/* Enough for SPI NAND page read / write with page size 2048 bytes */
-#define SPI_MSG_SIZE_OVERALL	(2048 + 16)
+#define MT7621_RX_FIFO_LEN	32
+#define MT7621_TX_FIFO_LEN	36
 
 #define MT7621_SPI_TRANS	0x00
 #define MT7621_SPI_TRANS_START	BIT(8)
@@ -39,11 +38,16 @@
 #define MASTER_RS_CLK_SEL_SHIFT	16
 #define MASTER_RS_SLAVE_SEL	GENMASK(31, 29)
 
+#define MOREBUF_CMD_CNT		GENMASK(29, 24)
+#define MOREBUF_CMD_CNT_SHIFT	24
+#define MOREBUF_MISO_CNT	GENMASK(20, 12)
+#define MOREBUF_MISO_CNT_SHIFT	12
+#define MOREBUF_MOSI_CNT	GENMASK(8, 0)
+#define MOREBUF_MOSI_CNT_SHIFT	0
+
 struct mt7621_spi {
 	void __iomem *base;
 	unsigned int sys_freq;
-	u32 data[(SPI_MSG_SIZE_OVERALL / 4) + 1];
-	int tx_len;
 };
 
 static void mt7621_spi_reset(struct mt7621_spi *rs, int duplex)
@@ -129,20 +133,89 @@ static inline int mt7621_spi_wait_till_ready(struct mt7621_spi *rs)
 	return ret;
 }
 
+static int mt7621_spi_read(struct mt7621_spi *rs, u8 *buf, size_t len)
+{
+	size_t rx_len;
+	int i, ret;
+	u32 val = 0;
+
+	while (len) {
+		rx_len = min_t(size_t, len, MT7621_RX_FIFO_LEN);
+
+		iowrite32((rx_len * 8) << MOREBUF_MISO_CNT_SHIFT,
+			  rs->base + MT7621_SPI_MOREBUF);
+		iowrite32(MT7621_SPI_TRANS_START, rs->base + MT7621_SPI_TRANS);
+
+		ret = mt7621_spi_wait_till_ready(rs);
+		if (ret)
+			return ret;
+
+		for (i = 0; i < rx_len; i++) {
+			if ((i % 4) == 0)
+				val = ioread32(rs->base + MT7621_SPI_DATA0 + i);
+			*buf++ = val & 0xff;
+			val >>= 8;
+		}
+
+		len -= rx_len;
+	}
+
+	return ret;
+}
+
+static int mt7621_spi_write(struct mt7621_spi *rs, const u8 *buf, size_t len)
+{
+	size_t tx_len, opcode_len, dido_len;
+	int i, ret;
+	u32 val;
+
+	while (len) {
+		tx_len = min_t(size_t, len, MT7621_TX_FIFO_LEN);
+
+		opcode_len = min_t(size_t, tx_len, 4);
+		dido_len = tx_len - opcode_len;
+
+		val = 0;
+		for (i = 0; i < opcode_len; i++) {
+			val <<= 8;
+			val |= *buf++;
+		}
+
+		iowrite32(val, rs->base + MT7621_SPI_OPCODE);
+
+		val = 0;
+		for (i = 0; i < dido_len; i++) {
+			val |= (*buf++) << ((i % 4) * 8);
+
+			if ((i % 4 == 3) || (i == dido_len - 1)) {
+				iowrite32(val, rs->base + MT7621_SPI_DATA0 +
+					  (i & ~3));
+				val = 0;
+			}
+		}
+
+		iowrite32(((opcode_len * 8) << MOREBUF_CMD_CNT_SHIFT) |
+			  ((dido_len * 8) << MOREBUF_MOSI_CNT_SHIFT),
+			  rs->base + MT7621_SPI_MOREBUF);
+		iowrite32(MT7621_SPI_TRANS_START, rs->base + MT7621_SPI_TRANS);
+
+		ret = mt7621_spi_wait_till_ready(rs);
+		if (ret)
+			return ret;
+
+		len -= tx_len;
+	}
+
+	return 0;
+}
+
 static int mt7621_spi_xfer(struct udevice *dev, unsigned int bitlen,
 			   const void *dout, void *din, unsigned long flags)
 {
 	struct udevice *bus = dev->parent;
 	struct mt7621_spi *rs = dev_get_priv(bus);
-	const u8 *tx_buf = dout;
-	u8 *ptr = (u8 *)dout;
-	u8 *rx_buf = din;
 	int total_size = bitlen >> 3;
-	int chunk_size;
-	int rx_len = 0;
-	u32 data[(SPI_MSG_SIZE_MAX / 4) + 1] = { 0 };
-	u32 val;
-	int i;
+	int ret = 0;
 
 	debug("%s: dout=%p, din=%p, len=%x, flags=%lx\n", __func__, dout, din,
 	      total_size, flags);
@@ -156,13 +229,6 @@ static int mt7621_spi_xfer(struct udevice *dev, unsigned int bitlen,
 		return -EIO;
 	}
 
-	if (dout) {
-		debug("TX-DATA: ");
-		for (i = 0; i < total_size; i++)
-			debug("%02x ", *ptr++);
-		debug("\n");
-	}
-
 	mt7621_spi_wait_till_ready(rs);
 
 	/*
@@ -172,96 +238,15 @@ static int mt7621_spi_xfer(struct udevice *dev, unsigned int bitlen,
 	if (flags & SPI_XFER_BEGIN)
 		mt7621_spi_set_cs(rs, spi_chip_select(dev), 1);
 
-	while (total_size > 0) {
-		/* Don't exceed the max xfer size */
-		chunk_size = min_t(int, total_size, SPI_MSG_SIZE_MAX);
-
-		/*
-		 * We might have some TX data buffered from the last xfer
-		 * message. Make sure, that this does not exceed the max
-		 * xfer size
-		 */
-		if (rs->tx_len > 4)
-			chunk_size -= rs->tx_len;
-		if (din)
-			rx_len = chunk_size;
-
-		if (tx_buf) {
-			/* Check if this message does not exceed the buffer */
-			if ((chunk_size + rs->tx_len) > SPI_MSG_SIZE_OVERALL) {
-				printf("TX message size too big (%d)\n",
-				       chunk_size + rs->tx_len);
-				return -EMSGSIZE;
-			}
-
-			/*
-			 * Write all TX data into internal buffer to collect
-			 * all TX messages into one buffer (might be split into
-			 * multiple calls to this function)
-			 */
-			for (i = 0; i < chunk_size; i++, rs->tx_len++) {
-				rs->data[rs->tx_len / 4] |=
-					tx_buf[i] << (8 * (rs->tx_len & 3));
-			}
-		}
-
-		if (flags & SPI_XFER_END) {
-			/* Write TX data into controller */
-			if (rs->tx_len) {
-				rs->data[0] = swab32(rs->data[0]);
-				if (rs->tx_len < 4)
-					rs->data[0] >>= (4 - rs->tx_len) * 8;
-
-				for (i = 0; i < rs->tx_len; i += 4) {
-					iowrite32(rs->data[i / 4], rs->base +
-						  MT7621_SPI_OPCODE + i);
-				}
-			}
-
-			/* Write length into controller */
-			val = (min_t(int, rs->tx_len, 4) * 8) << 24;
-			if (rs->tx_len > 4)
-				val |= (rs->tx_len - 4) * 8;
-			val |= (rx_len * 8) << 12;
-			iowrite32(val, rs->base + MT7621_SPI_MOREBUF);
-
-			/* Start the xfer */
-			setbits_le32(rs->base + MT7621_SPI_TRANS,
-				     MT7621_SPI_TRANS_START);
-
-			/* Wait until xfer is finished on bus */
-			mt7621_spi_wait_till_ready(rs);
-
-			/* Reset TX length and TX buffer for next xfer */
-			rs->tx_len = 0;
-			memset(rs->data, 0, sizeof(rs->data));
-		}
-
-		for (i = 0; i < rx_len; i += 4)
-			data[i / 4] = ioread32(rs->base + MT7621_SPI_DATA0 + i);
-
-		if (rx_len) {
-			debug("RX-DATA: ");
-			for (i = 0; i < rx_len; i++) {
-				rx_buf[i] = data[i / 4] >> (8 * (i & 3));
-				debug("%02x ", rx_buf[i]);
-			}
-			debug("\n");
-		}
-
-		if (tx_buf)
-			tx_buf += chunk_size;
-		if (rx_buf)
-			rx_buf += chunk_size;
-		total_size -= chunk_size;
-	}
+	if (din)
+		ret = mt7621_spi_read(rs, din, total_size);
+	else if (dout)
+		ret = mt7621_spi_write(rs, dout, total_size);
 
-	/* Wait until xfer is finished on bus and de-assert CS */
-	mt7621_spi_wait_till_ready(rs);
 	if (flags & SPI_XFER_END)
 		mt7621_spi_set_cs(rs, spi_chip_select(dev), 0);
 
-	return 0;
+	return ret;
 }
 
 static int mt7621_spi_probe(struct udevice *dev)
Signature · 1 line
2.17.1
author
#9 lore raw

PATCH v3 9/28 spi: mt7621-spi: restore default register value after each xfer

In reply to Weijie Gao

Currently this driver uses a different way to implement the spi xfer, by modifying some fields of two registers, which is incompatible with the MTK's original SDK linux driver. This will cause the flash data being damaged by the SDK driver.

This patch lets the mt7621_spi_set_cs() restore the original register fields after cs deactivated.

---
 drivers/spi/mt7621_spi.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/spi/mt7621_spi.c +17 -13
index 716256ab59..90e85c6b44 100644
@@ -21,6 +21,10 @@
 #define MT7621_SPI_TRANS	0x00
 #define MT7621_SPI_TRANS_START	BIT(8)
 #define MT7621_SPI_TRANS_BUSY	BIT(16)
+#define TRANS_ADDR_SZ		GENMASK(20, 19)
+#define TRANS_ADDR_SZ_SHIFT	19
+#define TRANS_MOSI_BCNT		GENMASK(3, 0)
+#define TRANS_MOSI_BCNT_SHIFT	0
 
 #define MT7621_SPI_OPCODE	0x04
 #define MT7621_SPI_DATA0	0x08
@@ -50,20 +54,22 @@ struct mt7621_spi {
 	unsigned int sys_freq;
 };
 
-static void mt7621_spi_reset(struct mt7621_spi *rs, int duplex)
-{
-	setbits_le32(rs->base + MT7621_SPI_MASTER,
-		     MASTER_RS_SLAVE_SEL | MASTER_MORE_BUFMODE);
-}
-
 static void mt7621_spi_set_cs(struct mt7621_spi *rs, int cs, int enable)
 {
-	u32 val = 0;
-
 	debug("%s: cs#%d -> %s\n", __func__, cs, enable ? "enable" : "disable");
-	if (enable)
-		val = BIT(cs);
-	iowrite32(val, rs->base + MT7621_SPI_POLAR);
+
+	if (enable) {
+		setbits_le32(rs->base + MT7621_SPI_MASTER,
+			     MASTER_RS_SLAVE_SEL | MASTER_MORE_BUFMODE);
+		iowrite32(BIT(cs), rs->base + MT7621_SPI_POLAR);
+	} else {
+		iowrite32(0, rs->base + MT7621_SPI_POLAR);
+		iowrite32((2 << TRANS_ADDR_SZ_SHIFT) |
+			  (1 << TRANS_MOSI_BCNT_SHIFT),
+			  rs->base + MT7621_SPI_TRANS);
+		clrbits_le32(rs->base + MT7621_SPI_MASTER,
+			     MASTER_RS_SLAVE_SEL | MASTER_MORE_BUFMODE);
+	}
 }
 
 static int mt7621_spi_set_mode(struct udevice *bus, uint mode)
@@ -273,8 +279,6 @@ static int mt7621_spi_probe(struct udevice *dev)
 		return -EINVAL;
 	}
 
-	mt7621_spi_reset(rs, 0);
-
 	return 0;
 }
 
Signature · 1 line
2.17.1
author
#10 lore raw

PATCH v3 10/28 pinctrl: add support for MediaTek MT7628

In reply to Weijie Gao

This patch adds pinctrl support for mt7628, with a file for common pinmux functions and a file for mt7628 which has additional support for pinconf.

---
v3: Add const qualifier for variables with type struct mtmips_pmx_func.

---
 drivers/pinctrl/Kconfig                       |   1 +
 drivers/pinctrl/Makefile                      |   1 +
 drivers/pinctrl/mtmips/Kconfig                |  13 +
 drivers/pinctrl/mtmips/Makefile               |   7 +
 drivers/pinctrl/mtmips/pinctrl-mt7628.c       | 585 ++++++++++++++++++
 .../pinctrl/mtmips/pinctrl-mtmips-common.c    |  87 +++
 .../pinctrl/mtmips/pinctrl-mtmips-common.h    |  53 ++
 7 files changed, 747 insertions(+)
 create mode 100644 drivers/pinctrl/mtmips/Kconfig
 create mode 100644 drivers/pinctrl/mtmips/Makefile
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7628.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.h
drivers/pinctrl/Kconfig +1 -0
index a0ac167d14..1634dffb35 100644
@@ -244,6 +244,7 @@ source "drivers/pinctrl/exynos/Kconfig"
 source "drivers/pinctrl/mediatek/Kconfig"
 source "drivers/pinctrl/meson/Kconfig"
 source "drivers/pinctrl/mscc/Kconfig"
+source "drivers/pinctrl/mtmips/Kconfig"
 source "drivers/pinctrl/mvebu/Kconfig"
 source "drivers/pinctrl/nxp/Kconfig"
 source "drivers/pinctrl/renesas/Kconfig"
drivers/pinctrl/Makefile +1 -0
index 4b080b74dc..ce0879a2b7 100644
@@ -9,6 +9,7 @@ obj-y					+= nxp/
 obj-$(CONFIG_$(SPL_)PINCTRL_ROCKCHIP)	+= rockchip/
 obj-$(CONFIG_ARCH_ASPEED) += aspeed/
 obj-$(CONFIG_ARCH_ATH79) += ath79/
+obj-$(CONFIG_ARCH_MTMIPS) += mtmips/
 obj-$(CONFIG_ARCH_RMOBILE) += renesas/
 obj-$(CONFIG_PINCTRL_SANDBOX)	+= pinctrl-sandbox.o
 
drivers/pinctrl/mtmips/Kconfig new file +13 -0
new file mode 100644
index 0000000000..8482a38ebc
@@ -0,0 +1,13 @@
+
+config PINCTRL_MTMIPS
+	depends on ARCH_MTMIPS
+	bool
+
+config PINCTRL_MT7628
+	bool "MediaTek MT7628 pin control driver"
+	select PINCTRL_MTMIPS
+	depends on SOC_MT7628 && PINCTRL_GENERIC
+	help
+	  Support pin multiplexing control on MediaTek MT7628.
+	  The driver is controlled by a device tree node which contains
+	  the pin mux functions for each available pin groups.
drivers/pinctrl/mtmips/Makefile new file +7 -0
new file mode 100644
index 0000000000..3ba5c0c66d
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# Core
+obj-$(CONFIG_PINCTRL_MTMIPS) += pinctrl-mtmips-common.o
+
+# SoC Drivers
+obj-$(CONFIG_PINCTRL_MT7628) += pinctrl-mt7628.o
drivers/pinctrl/mtmips/pinctrl-mt7628.c new file +585 -0

585 lines not on this page · raw message

drivers/pinctrl/mtmips/pinctrl-mtmips-common.c new file +87 -0

87 lines not on this page · raw message

drivers/pinctrl/mtmips/pinctrl-mtmips-common.h new file +53 -0

53 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#11 lore raw

PATCH v3 11/28 dts: mtmips: add pinctrl node for mt7628

In reply to Weijie Gao

This patch adds pinctrl node with default pin state for mt7628an.dtsi.

---
 arch/mips/dts/mt7628a.dtsi | 150 +++++++++++++++++++++++++++++++++++++
 1 file changed, 150 insertions(+)
arch/mips/dts/mt7628a.dtsi +150 -0
index 6d2142f429..8afea1865d 100644
@@ -57,6 +57,156 @@
 			u-boot,dm-pre-reloc;
 		};
 
+		pinctrl: pinctrl at 60 {
+			compatible = "mediatek,mt7628-pinctrl";
+			reg = <0x3c 0x2c>, <0x1300 0x100>;
+			reg-names = "gpiomode", "padconf";
+
+			pinctrl-names = "default";
+			pinctrl-0 = <&state_default>;
+
+			state_default: pin_state {
+			};
+
+			spi_single_pins: spi_single_pins {
+				groups = "spi";
+				function = "spi";
+			};
+
+			spi_dual_pins: spi_dual_pins {
+				spi_master_pins {
+					groups = "spi";
+					function = "spi";
+				};
+
+				spi_cs1_pin {
+					groups = "spi cs1";
+					function = "spi cs1";
+				};
+			};
+
+			uart0_pins: uart0_pins {
+				groups = "uart0";
+				function = "uart0";
+			};
+
+			uart1_pins: uart1_pins {
+				groups = "uart1";
+				function = "uart1";
+			};
+
+			uart2_pins: uart2_pins {
+				groups = "uart2";
+				function = "uart2";
+			};
+
+			i2c_pins: i2c_pins {
+				groups = "i2c";
+				function = "i2c";
+			};
+
+			ephy_iot_mode: ephy_iot_mode {
+				ephy4_1_dis {
+					groups = "ephy4_1_pad";
+					function = "digital";
+				};
+
+				ephy0_en {
+					groups = "ephy0";
+					function = "enable";
+				};
+			};
+
+			ephy_router_mode: ephy_router_mode {
+				ephy4_1_en {
+					groups = "ephy4_1_pad";
+					function = "analog";
+				};
+
+				ephy0_en {
+					groups = "ephy0";
+					function = "enable";
+				};
+			};
+
+			sd_iot_mode: sd_iot_mode {
+				ephy4_1_dis {
+					groups = "ephy4_1_pad";
+					function = "digital";
+				};
+
+				sdxc_en {
+					groups = "sdmode";
+					function = "sdxc";
+				};
+
+				sdxc_iot_mode {
+					groups = "sd router";
+					function = "iot";
+				};
+
+				sd_clk_pad {
+					pins = "sd_clk";
+					drive-strength-4g = <8>;
+				};
+			};
+
+			sd_router_mode: sd_router_mode {
+				sdxc_router_mode {
+					groups = "sd router";
+					function = "router";
+				};
+
+				sdxc_map_pins {
+					groups = "gpio0", "i2s", "sdmode", \
+						 "i2c", "uart1";
+					function = "gpio";
+				};
+
+				sd_clk_pad {
+					pins = "gpio0";
+					drive-strength-28 = <8>;
+				};
+			};
+
+			emmc_iot_8bit_mode: emmc_iot_8bit_mode {
+				ephy4_1_dis {
+					groups = "ephy4_1_pad";
+					function = "digital";
+				};
+
+				emmc_en {
+					groups = "sdmode";
+					function = "sdxc";
+				};
+
+				emmc_iot_mode {
+					groups = "sd router";
+					function = "iot";
+				};
+
+				emmc_d4_d5 {
+					groups = "uart2";
+					function = "sdxc d5 d4";
+				};
+
+				emmc_d6 {
+					groups = "pwm1";
+					function = "sdxc d6";
+				};
+
+				emmc_d7 {
+					groups = "pwm0";
+					function = "sdxc d7";
+				};
+
+				sd_clk_pad {
+					pins = "sd_clk";
+					drive-strength-4g = <8>;
+				};
+			};
+		};
+
 		watchdog: watchdog at 100 {
 			compatible = "ralink,mt7628a-wdt", "mediatek,mt7621-wdt";
 			reg = <0x100 0x30>;
Signature · 1 line
2.17.1
author
#12 lore raw

PATCH v3 12/28 dts: mtmips: add default pinctrl for uart nodes

In reply to Weijie Gao

This patch adds default pinctrl for uart nodes

---
 arch/mips/dts/mt7628a.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/mips/dts/mt7628a.dtsi +9 -0
index 8afea1865d..44fbbd5b25 100644
@@ -286,6 +286,9 @@
 			compatible = "mediatek,hsuart", "ns16550a";
 			reg = <0xc00 0x100>;
 
+			pinctrl-names = "default";
+			pinctrl-0 = <&uart0_pins>;
+
 			clocks = <&clkctrl CLK_UART0>;
 
 			resets = <&resetc 12>;
@@ -301,6 +304,9 @@
 			compatible = "mediatek,hsuart", "ns16550a";
 			reg = <0xd00 0x100>;
 
+			pinctrl-names = "default";
+			pinctrl-0 = <&uart1_pins>;
+
 			clocks = <&clkctrl CLK_UART1>;
 
 			resets = <&resetc 19>;
@@ -316,6 +322,9 @@
 			compatible = "mediatek,hsuart", "ns16550a";
 			reg = <0xe00 0x100>;
 
+			pinctrl-names = "default";
+			pinctrl-0 = <&uart2_pins>;
+
 			clocks = <&clkctrl CLK_UART2>;
 
 			resets = <&resetc 20>;
Signature · 1 line
2.17.1
author
#13 lore raw

PATCH v3 13/28 reset: add reset controller driver for MediaTek MIPS platform

In reply to Weijie Gao

This patch adds reset controller driver for MediaTek MIPS platform and header file for mt7628.

---
 drivers/reset/Kconfig                    |  7 ++
 drivers/reset/Makefile                   |  1 +
 drivers/reset/reset-mtmips.c             | 82 ++++++++++++++++++++++++
 include/dt-bindings/reset/mt7628-reset.h | 36 +++++++++++
 4 files changed, 126 insertions(+)
 create mode 100644 drivers/reset/reset-mtmips.c
 create mode 100644 include/dt-bindings/reset/mt7628-reset.h
drivers/reset/Kconfig +7 -0
index 6ec6f39c85..76866a2e90 100644
@@ -113,6 +113,13 @@ config RESET_MEDIATEK
 	help
 	  Support for reset controller on MediaTek SoCs.
 
+config RESET_MTMIPS
+	bool "Reset controller driver for MediaTek MIPS platform"
+	depends on DM_RESET && ARCH_MTMIPS
+	default y
+	help
+	  Support for reset controller on MediaTek MIPS platform.
+
 config RESET_SUNXI
 	bool "RESET support for Allwinner SoCs"
 	depends on DM_RESET && ARCH_SUNXI
drivers/reset/Makefile +1 -0
index 7fec75bb49..87d2bc4f18 100644
@@ -18,5 +18,6 @@ obj-$(CONFIG_RESET_ROCKCHIP) += reset-rockchip.o
 obj-$(CONFIG_RESET_MESON) += reset-meson.o
 obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o
 obj-$(CONFIG_RESET_MEDIATEK) += reset-mediatek.o
+obj-$(CONFIG_RESET_MTMIPS) += reset-mtmips.o
 obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
 obj-$(CONFIG_RESET_HISILICON) += reset-hisilicon.o
drivers/reset/reset-mtmips.c new file +82 -0

82 lines not on this page · raw message

include/dt-bindings/reset/mt7628-reset.h new file +36 -0
new file mode 100644
index 0000000000..2a674c1ea7
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 MediaTek Inc.
+ *
+ * Author:  Weijie Gao <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_MT7628_RESET_H_
+#define _DT_BINDINGS_MT7628_RESET_H_
+
+#define MT7628_PWM_RST			31
+#define MT7628_SDXC_RST			30
+#define MT7628_CRYPTO_RST		29
+#define MT7628_AUX_STCK_RST		28
+#define MT7628_PCIE_RST			26
+#define MT7628_EPHY_RST			24
+#define MT7628_ETH_RST			23
+#define MT7628_UPHY_RST			22
+#define MT7628_UART2_RST		20
+#define MT7628_UART1_RST		19
+#define MT7628_SPI_RST			18
+#define MT7628_I2S_RST			17
+#define MT7628_I2C_RST			16
+#define MT7628_GDMA_RST			14
+#define MT7628_PIO_RST			13
+#define MT7628_UART0_RST		12
+#define MT7628_PCM_RST			11
+#define MT7628_MC_RST			10
+#define MT7628_INT_RST			9
+#define MT7628_TIMER_RST		8
+#define MT7628_HIF_RST			5
+#define MT7628_WIFI_RST			4
+#define MT7628_SPIS_RST			3
+#define MT7628_SYS_RST			0
+
+#endif /* _DT_BINDINGS_MT7628_RESET_H_ */
Signature · 1 line
2.17.1
author
#14 lore raw

PATCH v3 14/28 dts: mtmips: update reset controller node for mt7628

In reply to Weijie Gao

This patch updates reset controller node for mt7628

---
 arch/mips/dts/mt7628a.dtsi | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)
arch/mips/dts/mt7628a.dtsi +24 -12
index 44fbbd5b25..b0e0ed7ec8 100644
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <dt-bindings/clock/mt7628-clk.h>
+#include <dt-bindings/reset/mt7628-reset.h>
 
 / {
 	#address-cells = <1>;
@@ -17,11 +18,6 @@
 		};
 	};
 
-	resetc: reset-controller {
-		compatible = "ralink,rt2880-reset";
-		#reset-cells = <1>;
-	};
-
 	cpuintc: interrupt-controller {
 		#address-cells = <0>;
 		#interrupt-cells = <1>;
@@ -57,6 +53,12 @@
 			u-boot,dm-pre-reloc;
 		};
 
+		rstctrl: rstctrl at 0x34 {
+			reg = <0x34 0x4>;
+			compatible = "mediatek,mtmips-reset";
+			#reset-cells = <1>;
+		};
+
 		pinctrl: pinctrl at 60 {
 			compatible = "mediatek,mt7628-pinctrl";
 			reg = <0x3c 0x2c>, <0x1300 0x100>;
@@ -211,7 +213,7 @@
 			compatible = "ralink,mt7628a-wdt", "mediatek,mt7621-wdt";
 			reg = <0x100 0x30>;
 
-			resets = <&resetc 8>;
+			resets = <&rstctrl MT7628_TIMER_RST>;
 			reset-names = "wdt";
 
 			interrupt-parent = <&intc>;
@@ -225,7 +227,7 @@
 			interrupt-controller;
 			#interrupt-cells = <1>;
 
-			resets = <&resetc 9>;
+			resets = <&rstctrl MT7628_INT_RST>;
 			reset-names = "intc";
 
 			interrupt-parent = <&cpuintc>;
@@ -248,6 +250,9 @@
 			compatible = "mtk,mt7628-gpio", "mtk,mt7621-gpio";
 			reg = <0x600 0x100>;
 
+			resets = <&rstctrl MT7628_PIO_RST>;
+			reset-names = "pio";
+
 			interrupt-parent = <&intc>;
 			interrupts = <6>;
 
@@ -276,6 +281,10 @@
 		spi0: spi at b00 {
 			compatible = "ralink,mt7621-spi";
 			reg = <0xb00 0x40>;
+
+			resets = <&rstctrl MT7628_SPI_RST>;
+			reset-names = "spi";
+
 			#address-cells = <1>;
 			#size-cells = <0>;
 
@@ -291,7 +300,7 @@
 
 			clocks = <&clkctrl CLK_UART0>;
 
-			resets = <&resetc 12>;
+			resets = <&rstctrl MT7628_UART0_RST>;
 			reset-names = "uart0";
 
 			interrupt-parent = <&intc>;
@@ -309,7 +318,7 @@
 
 			clocks = <&clkctrl CLK_UART1>;
 
-			resets = <&resetc 19>;
+			resets = <&rstctrl MT7628_UART1_RST>;
 			reset-names = "uart1";
 
 			interrupt-parent = <&intc>;
@@ -327,7 +336,7 @@
 
 			clocks = <&clkctrl CLK_UART2>;
 
-			resets = <&resetc 20>;
+			resets = <&rstctrl MT7628_UART2_RST>;
 			reset-names = "uart2";
 
 			interrupt-parent = <&intc>;
@@ -342,6 +351,9 @@
 		reg = <0x10100000 0x10000
 		       0x10110000 0x8000>;
 
+		resets = <&rstctrl MT7628_EPHY_RST>;
+		reset-names = "ephy";
+
 		syscon = <&sysc>;
 	};
 
@@ -353,8 +365,8 @@
 
 		ralink,sysctl = <&sysc>;
 
-		resets = <&resetc 22 &resetc 25>;
-		reset-names = "host", "device";
+		resets = <&rstctrl MT7628_UPHY_RST>;
+		reset-names = "phy";
 
 		clocks = <&clkctrl CLK_UPHY>;
 		clock-names = "cg";
Signature · 1 line
2.17.1
author
#15 lore raw

PATCH v3 15/28 phy: mt76x8-usb-phy: add slew rate calibration and remove non-mt7628 part

In reply to Weijie Gao

This patch adds slew rate calibration for mt76x8-usb-phy, removes code which belongs to mt7620, and gets rid of using syscon and regmap by using clock driver and reset controller.

---
v3: depends on SOC_MT7628.

---
 drivers/phy/Kconfig          |   1 +
 drivers/phy/mt76x8-usb-phy.c | 225 ++++++++++++++++++++++++-----------
 2 files changed, 158 insertions(+), 68 deletions(-)
drivers/phy/Kconfig +1 -0
index 02312273e2..6aac019fa7 100644
@@ -200,6 +200,7 @@ config KEYSTONE_USB_PHY
 config MT76X8_USB_PHY
 	bool "MediaTek MT76x8 (7628/88) USB PHY support"
 	depends on PHY
+	depends on SOC_MT7628
 	help
           Support the USB PHY in MT76x8 SoCs
 
drivers/phy/mt76x8-usb-phy.c +157 -68

291 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#16 lore raw

PATCH v3 16/28 net: mt7628-eth: remove hardcoded gpio settings and regmap-based phy reset

In reply to Weijie Gao

This patch removes hardcoded gpio settings as they have been replaced by pinctrl in dts, and also replaces regmap-based phy reset with a more generic reset controller.

---
 drivers/net/mt7628-eth.c | 45 +++++++---------------------------------
 1 file changed, 8 insertions(+), 37 deletions(-)
drivers/net/mt7628-eth.c +8 -37
index 7833b2f47a..4675b0f003 100644
@@ -18,23 +18,12 @@
 #include <malloc.h>
 #include <miiphy.h>
 #include <net.h>
-#include <regmap.h>
-#include <syscon.h>
+#include <reset.h>
 #include <wait_bit.h>
 #include <asm/io.h>
 #include <linux/bitfield.h>
 #include <linux/err.h>
 
-/* System controller register */
-#define MT7628_RSTCTRL_REG	0x34
-#define RSTCTRL_EPHY_RST	BIT(24)
-
-#define MT7628_AGPIO_CFG_REG	0x3c
-#define MT7628_EPHY_GPIO_AIO_EN	GENMASK(20, 17)
-#define MT7628_EPHY_P0_DIS	BIT(16)
-
-#define MT7628_GPIO2_MODE_REG	0x64
-
 /* Ethernet frame engine register */
 #define PDMA_RELATED		0x0800
 
@@ -137,7 +126,6 @@ struct fe_tx_dma {
 struct mt7628_eth_dev {
 	void __iomem *base;		/* frame engine base address */
 	void __iomem *eth_sw_base;	/* switch base address */
-	struct regmap *sysctrl_regmap;	/* system-controller reg-map */
 
 	struct mii_dev *bus;
 
@@ -150,6 +138,8 @@ struct mt7628_eth_dev {
 	int rx_dma_idx;
 	/* Point to the next TXD in TXD Ring0 CPU wants to use */
 	int tx_dma_idx;
+
+	struct reset_ctl	rst_ephy;
 };
 
 static int mdio_wait_read(struct mt7628_eth_dev *priv, u32 mask, bool mask_set)
@@ -301,20 +291,9 @@ static void rt305x_esw_init(struct mt7628_eth_dev *priv)
 	/* 1us cycle number=125 (FE's clock=125Mhz) */
 	writel(0x7d000000, base + MT7628_SWITCH_BMU_CTRL);
 
-	/* Configure analog GPIO setup */
-	regmap_update_bits(priv->sysctrl_regmap, MT7628_AGPIO_CFG_REG,
-			   MT7628_EPHY_P0_DIS, MT7628_EPHY_GPIO_AIO_EN);
-
 	/* Reset PHY */
-	regmap_update_bits(priv->sysctrl_regmap, MT7628_RSTCTRL_REG,
-			   0, RSTCTRL_EPHY_RST);
-	regmap_update_bits(priv->sysctrl_regmap, MT7628_RSTCTRL_REG,
-			   RSTCTRL_EPHY_RST, 0);
-	mdelay(10);
-
-	/* Set P0 EPHY LED mode */
-	regmap_update_bits(priv->sysctrl_regmap, MT7628_GPIO2_MODE_REG,
-			   0x0ffc0ffc, 0x05540554);
+	reset_assert(&priv->rst_ephy);
+	reset_deassert(&priv->rst_ephy);
 	mdelay(10);
 
 	mt7628_ephy_init(priv);
@@ -558,7 +537,6 @@ static void mt7628_eth_stop(struct udevice *dev)
 static int mt7628_eth_probe(struct udevice *dev)
 {
 	struct mt7628_eth_dev *priv = dev_get_priv(dev);
-	struct udevice *syscon;
 	struct mii_dev *bus;
 	int ret;
 	int i;
@@ -573,20 +551,13 @@ static int mt7628_eth_probe(struct udevice *dev)
 	if (IS_ERR(priv->eth_sw_base))
 		return PTR_ERR(priv->eth_sw_base);
 
-	/* Get system controller regmap */
-	ret = uclass_get_device_by_phandle(UCLASS_SYSCON, dev,
-					   "syscon", &syscon);
+	/* Reset controller */
+	ret = reset_get_by_name(dev, "ephy", &priv->rst_ephy);
 	if (ret) {
-		pr_err("unable to find syscon device\n");
+		pr_err("unable to find reset controller for ethernet PHYs\n");
 		return ret;
 	}
 
-	priv->sysctrl_regmap = syscon_get_regmap(syscon);
-	if (!priv->sysctrl_regmap) {
-		pr_err("unable to find regmap\n");
-		return -ENODEV;
-	}
-
 	/* Put rx and tx rings into KSEG1 area (uncached) */
 	priv->tx_ring = (struct fe_tx_dma *)
 		KSEG1ADDR(memalign(ARCH_DMA_MINALIGN,
Signature · 1 line
2.17.1
author
#17 lore raw

PATCH v3 17/28 net: mt7628-eth: make phy link up detection optional via DT

In reply to Weijie Gao

The mt7628 has an embedded ethernet switch (5 phy ports + 1 cpu port). Although in IOT mode only port0 is usable, the phy0 is still connected to the switch, not the ethernet gmac directly.

This patch rewrites it and makes it optional. It can be turned on by adding mediatek,poll-link-phy = <?> explicitly into the eth node. By default the driver is switch mode with all 5 phy ports working without link detection.

---
v2: Make link detection optional rather than removing directly.

---
 drivers/net/Kconfig      |  1 +
 drivers/net/mt7628-eth.c | 59 ++++++++++++++++++++--------------------
 2 files changed, 31 insertions(+), 29 deletions(-)
drivers/net/Kconfig +1 -0
index 2ce3092db0..eb3d7ed45f 100644
@@ -322,6 +322,7 @@ config MACB_ZYNQ
 config MT7628_ETH
 	bool "MediaTek MT7628 Ethernet Interface"
 	depends on SOC_MT7628
+	select PHYLIB
 	help
 	  The MediaTek MT7628 ethernet interface is used on MT7628 and
 	  MT7688 based boards.
drivers/net/mt7628-eth.c +30 -29

108 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#18 lore raw

PATCH v3 18/28 net: mt7628-eth: free rx descriptor on receiving failure

In reply to Weijie Gao

When received a packet with an invalid length recorded in rx descriptor, we should free this rx descriptor to allow us to continue to receive following packets.
Without doing so, u-boot will stuck in a dead loop trying to process this invalid rx descriptor.

This patch adds a call to mt7628_eth_free_pkt() after received an invalid packet length.

---
 drivers/net/mt7628-eth.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/net/mt7628-eth.c +3 -0
index abfdc75ad8..d77da26d50 100644
@@ -142,6 +142,8 @@ struct mt7628_eth_dev {
 	struct phy_device *phy;
 };
 
+static int mt7628_eth_free_pkt(struct udevice *dev, uchar *packet, int length);
+
 static int mdio_wait_read(struct mt7628_eth_dev *priv, u32 mask, bool mask_set)
 {
 	void __iomem *base = priv->eth_sw_base;
@@ -403,6 +405,7 @@ static int mt7628_eth_recv(struct udevice *dev, int flags, uchar **packetp)
 	length = FIELD_GET(RX_DMA_PLEN0, priv->rx_ring[idx].rxd2);
 	if (length == 0 || length > MTK_QDMA_PAGE_SIZE) {
 		printf("%s: invalid length (%d bytes)\n", __func__, length);
+		mt7628_eth_free_pkt(dev, NULL, 0);
 		return -EIO;
 	}
 
Signature · 1 line
2.17.1
author
#19 lore raw

PATCH v3 19/28 net: mt7628-eth: add support to isolate LAN/WAN ports

In reply to Weijie Gao

This patch add support for mt7628-eth to isolate LAN/WAN ports mainly to prevent LAN devices from getting IP address from WAN.

---
 drivers/net/mt7628-eth.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
drivers/net/mt7628-eth.c +32 -0
index d77da26d50..a1d12f6902 100644
@@ -57,6 +57,11 @@
 /* Ethernet switch register */
 #define MT7628_SWITCH_FCT0	0x0008
 #define MT7628_SWITCH_PFC1	0x0014
+#define MT7628_SWITCH_PVIDC0	0x0040
+#define MT7628_SWITCH_PVIDC1	0x0044
+#define MT7628_SWITCH_PVIDC2	0x0048
+#define MT7628_SWITCH_PVIDC3	0x004c
+#define MT7628_SWITCH_VMSC0	0x0070
 #define MT7628_SWITCH_FPA	0x0084
 #define MT7628_SWITCH_SOCPC	0x008c
 #define MT7628_SWITCH_POC0	0x0090
@@ -140,6 +145,8 @@ struct mt7628_eth_dev {
 	struct reset_ctl	rst_ephy;
 
 	struct phy_device *phy;
+
+	int wan_port;
 };
 
 static int mt7628_eth_free_pkt(struct udevice *dev, uchar *packet, int length);
@@ -272,6 +279,9 @@ static void mt7628_ephy_init(struct mt7628_eth_dev *priv)
 static void rt305x_esw_init(struct mt7628_eth_dev *priv)
 {
 	void __iomem *base = priv->eth_sw_base;
+	void __iomem *reg;
+	u32 val = 0, pvid;
+	int i;
 
 	/*
 	 * FC_RLS_TH=200, FC_SET_TH=160
@@ -293,6 +303,25 @@ static void rt305x_esw_init(struct mt7628_eth_dev *priv)
 	/* 1us cycle number=125 (FE's clock=125Mhz) */
 	writel(0x7d000000, base + MT7628_SWITCH_BMU_CTRL);
 
+	/* LAN/WAN partition, WAN port will be unusable in u-boot network */
+	if (priv->wan_port >= 0 && priv->wan_port < 6) {
+		for (i = 0; i < 8; i++) {
+			pvid = i == priv->wan_port ? 2 : 1;
+			reg = base + MT7628_SWITCH_PVIDC0 + (i / 2) * 4;
+			if (i % 2 == 0) {
+				val = pvid;
+			} else {
+				val |= (pvid << 12);
+				writel(val, reg);
+			}
+		}
+
+		val = 0xffff407f;
+		val |= 1 << (8 + priv->wan_port);
+		val &= ~(1 << priv->wan_port);
+		writel(val, base + MT7628_SWITCH_VMSC0);
+	}
+
 	/* Reset PHY */
 	reset_assert(&priv->rst_ephy);
 	reset_deassert(&priv->rst_ephy);
@@ -543,6 +572,9 @@ static int mt7628_eth_probe(struct udevice *dev)
 		return ret;
 	}
 
+	/* WAN port will be isolated from LAN ports */
+	priv->wan_port = dev_read_u32_default(dev, "mediatek,wan-port", -1);
+
 	/* Put rx and tx rings into KSEG1 area (uncached) */
 	priv->tx_ring = (struct fe_tx_dma *)
 		KSEG1ADDR(memalign(ARCH_DMA_MINALIGN,
Signature · 1 line
2.17.1
author
#20 lore raw

PATCH v3 20/28 dts: mtmips: enable eth port0 led and link poll functions for all boards

In reply to Weijie Gao

This patch adds default p0led status and phy0 link polling for all boards.

---
v2: Add phy link detection for all boards.

---
 arch/mips/dts/gardena-smart-gateway-mt7688.dts | 13 +++++++++++++
 arch/mips/dts/linkit-smart-7688.dts            | 13 +++++++++++++
 arch/mips/dts/mt7628a.dtsi                     |  2 +-
 3 files changed, 27 insertions(+), 1 deletion(-)
arch/mips/dts/gardena-smart-gateway-mt7688.dts +13 -0
index 95675a3947..fc1f5e93dd 100644
@@ -85,6 +85,15 @@
 	};
 };
 
+&pinctrl {
+	state_default: pin_state {
+		p0led {
+			groups = "p0led_a";
+			function = "led";
+		};
+	};
+};
+
 &uart0 {
 	status = "okay";
 };
@@ -109,3 +118,7 @@
 		reg = <1>;
 	};
 };
+
+&eth {
+	mediatek,poll-link-phy = <0>;
+};
arch/mips/dts/linkit-smart-7688.dts +13 -0
index 935315743c..740b73b3d1 100644
@@ -26,6 +26,15 @@
 	};
 };
 
+&pinctrl {
+	state_default: pin_state {
+		p0led {
+			groups = "p0led_a";
+			function = "led";
+		};
+	};
+};
+
 &uart2 {
 	status = "okay";
 };
@@ -42,3 +51,7 @@
 		reg = <0>;
 	};
 };
+
+&eth {
+	mediatek,poll-link-phy = <0>;
+};
arch/mips/dts/mt7628a.dtsi +1 -1
index b0e0ed7ec8..5fd83c1623 100644
@@ -346,7 +346,7 @@
 		};
 	};
 
-	eth at 10110000 {
+	eth: eth at 10110000 {
 		compatible = "mediatek,mt7628-eth";
 		reg = <0x10100000 0x10000
 		       0x10110000 0x8000>;
Signature · 1 line
2.17.1
author
#21 lore raw

PATCH v3 21/28 mmc: mtk-sd: add support for MediaTek MT7620/MT7628 SoCs

In reply to Weijie Gao

This patch adds mmc support for MediaTek MT7620/MT7628 SoCs.

---
v2: Removed unnecessary braces in Kconfig

---
 drivers/mmc/Kconfig  |  2 +-
 drivers/mmc/mtk-sd.c | 23 ++++++++++++++++++++---
 2 files changed, 21 insertions(+), 4 deletions(-)
drivers/mmc/Kconfig +1 -1
index 7361bcaf8e..a05c6fc736 100644
@@ -681,7 +681,7 @@ config FTSDC010_SDIO
 
 config MMC_MTK
 	bool "MediaTek SD/MMC Card Interface support"
-	depends on ARCH_MEDIATEK
+	depends on ARCH_MEDIATEK || ARCH_MTMIPS
 	depends on BLK && DM_MMC
 	depends on OF_CONTROL
 	help
drivers/mmc/mtk-sd.c +20 -3
index f555357af2..7069fe8948 100644
@@ -217,6 +217,7 @@ struct mtk_sd_regs {
 
 struct msdc_compatible {
 	u8 clk_div_bits;
+	u8 sclk_cycle_shift;
 	bool pad_tune0;
 	bool async_fifo;
 	bool data_tune;
@@ -664,7 +665,7 @@ static int msdc_ops_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
 
 static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks)
 {
-	u32 timeout, clk_ns;
+	u32 timeout, clk_ns, shift;
 	u32 mode = 0;
 
 	host->timeout_ns = ns;
@@ -673,10 +674,11 @@ static void msdc_set_timeout(struct msdc_host *host, u32 ns, u32 clks)
 	if (host->sclk == 0) {
 		timeout = 0;
 	} else {
+		shift = host->dev_comp->sclk_cycle_shift;
 		clk_ns = 1000000000UL / host->sclk;
 		timeout = (ns + clk_ns - 1) / clk_ns + clks;
 		/* unit is 1048576 sclk cycles */
-		timeout = (timeout + (0x1 << 20) - 1) >> 20;
+		timeout = (timeout + (0x1 << shift) - 1) >> shift;
 		if (host->dev_comp->clk_div_bits == 8)
 			mode = (readl(&host->base->msdc_cfg) &
 				MSDC_CFG_CKMOD_M) >> MSDC_CFG_CKMOD_S;
@@ -1301,7 +1303,7 @@ static int msdc_drv_probe(struct udevice *dev)
 
 	host->mmc = &plat->mmc;
 	host->timeout_ns = 100000000;
-	host->timeout_clks = 3 * 1048576;
+	host->timeout_clks = 3 * (1 << host->dev_comp->sclk_cycle_shift);
 
 #ifdef CONFIG_PINCTRL
 	pinctrl_select_state(dev, "default");
@@ -1374,8 +1376,20 @@ static const struct dm_mmc_ops msdc_ops = {
 #endif
 };
 
+static const struct msdc_compatible mt7620_compat = {
+	.clk_div_bits = 8,
+	.sclk_cycle_shift = 16,
+	.pad_tune0 = false,
+	.async_fifo = false,
+	.data_tune = false,
+	.busy_check = false,
+	.stop_clk_fix = false,
+	.enhance_rx = false
+};
+
 static const struct msdc_compatible mt7623_compat = {
 	.clk_div_bits = 12,
+	.sclk_cycle_shift = 20,
 	.pad_tune0 = true,
 	.async_fifo = true,
 	.data_tune = true,
@@ -1386,6 +1400,7 @@ static const struct msdc_compatible mt7623_compat = {
 
 static const struct msdc_compatible mt8516_compat = {
 	.clk_div_bits = 12,
+	.sclk_cycle_shift = 20,
 	.pad_tune0 = true,
 	.async_fifo = true,
 	.data_tune = true,
@@ -1395,6 +1410,7 @@ static const struct msdc_compatible mt8516_compat = {
 
 static const struct msdc_compatible mt8183_compat = {
 	.clk_div_bits = 12,
+	.sclk_cycle_shift = 20,
 	.pad_tune0 = true,
 	.async_fifo = true,
 	.data_tune = true,
@@ -1403,6 +1419,7 @@ static const struct msdc_compatible mt8183_compat = {
 };
 
 static const struct udevice_id msdc_ids[] = {
+	{ .compatible = "mediatek,mt7620-mmc", .data = (ulong)&mt7620_compat },
 	{ .compatible = "mediatek,mt7623-mmc", .data = (ulong)&mt7623_compat },
 	{ .compatible = "mediatek,mt8516-mmc", .data = (ulong)&mt8516_compat },
 	{ .compatible = "mediatek,mt8183-mmc", .data = (ulong)&mt8183_compat },
Signature · 1 line
2.17.1
author
#22 lore raw

PATCH v3 22/28 mmc: mtk-sd: add a dts property cd-active-high for builtin-cd mode

In reply to Weijie Gao

This patch adds a dts property cd-active-high for builtin-cd mode to make it configurable instead of using hardcoded active-low.

---
v3: Simplify logic of card-detection.

---
 drivers/mmc/mtk-sd.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mmc/mtk-sd.c +5 -1
index 7069fe8948..ffd647fac7 100644
@@ -270,6 +270,7 @@ struct msdc_host {
 
 	/* whether to use gpio detection or built-in hw detection */
 	bool builtin_cd;
+	bool cd_active_high;
 
 	/* card detection / write protection GPIOs */
 #if CONFIG_IS_ENABLED(DM_GPIO)
@@ -852,7 +853,9 @@ static int msdc_ops_get_cd(struct udevice *dev)
 
 	if (host->builtin_cd) {
 		val = readl(&host->base->msdc_ps);
-		return !(val & MSDC_PS_CDSTS);
+		val = !!(val & MSDC_PS_CDSTS);
+
+		return !val ^ host->cd_active_high;
 	}
 
 #if CONFIG_IS_ENABLED(DM_GPIO)
@@ -1355,6 +1358,7 @@ static int msdc_ofdata_to_platdata(struct udevice *dev)
 	host->latch_ck = dev_read_u32_default(dev, "latch-ck", 0);
 	host->r_smpl = dev_read_u32_default(dev, "r_smpl", 0);
 	host->builtin_cd = dev_read_u32_default(dev, "builtin-cd", 0);
+	host->cd_active_high = dev_read_bool(dev, "cd-active-high");
 
 	return 0;
 }
Signature · 1 line
2.17.1
author
#23 lore raw

PATCH v3 23/28 dts: mtmips: add mmc related nodes for mt7628an.dtsi

In reply to Weijie Gao

This patch adds mmc related nodes for mt7628an.dtsi

---
 arch/mips/dts/mt7628a.dtsi | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/mips/dts/mt7628a.dtsi +22 -0
index 5fd83c1623..76a80c8952 100644
@@ -25,6 +25,14 @@
 		compatible = "mti,cpu-interrupt-controller";
 	};
 
+	clk48m: clk48m at 0 {
+		compatible = "fixed-clock";
+
+		clock-frequency = <48000000>;
+
+		#clock-cells = <0>;
+	};
+
 	palmbus at 10000000 {
 		compatible = "palmbus", "simple-bus";
 		reg = <0x10000000 0x200000>;
@@ -382,4 +390,18 @@
 		interrupt-parent = <&intc>;
 		interrupts = <18>;
 	};
+
+	mmc: mmc at 10130000 {
+		compatible = "mediatek,mt7620-mmc";
+		reg = <0x10130000 0x4000>;
+		builtin-cd = <1>;
+		r_smpl = <1>;
+
+		clocks = <&clk48m>, <&clkctrl CLK_SDXC>;
+		clock-names = "source", "hclk";
+
+		resets = <&rstctrl MT7628_SDXC_RST>;
+
+		status = "disabled";
+	};
 };
Signature · 1 line
2.17.1
author
#24 lore raw

PATCH v3 24/28 dts: mtmips: add default pinctrl for gardena-smart-gateway-mt7688

In reply to Weijie Gao

This adds default pinctrl (dual SPI chip select) for gardena smart gateway

---
 arch/mips/dts/gardena-smart-gateway-mt7688.dts | 3 +++
 1 file changed, 3 insertions(+)
arch/mips/dts/gardena-smart-gateway-mt7688.dts +3 -0
index fc1f5e93dd..987824a76c 100644
@@ -102,6 +102,9 @@
 	status = "okay";
 	num-cs = <2>;
 
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi_dual_pins>;
+
 	spi-flash at 0 {
 		#address-cells = <1>;
 		#size-cells = <1>;
Signature · 1 line
2.17.1
author
#25 lore raw

PATCH v3 25/28 dts: mtmips: add default pinctrl to eth nodes for all boards

In reply to Weijie Gao

This patch adds default eth pinctrl for all boards.

There are two pinctrl nodes used for two scenarios:
ephy_iot_mode - for IOT boards which have only one port (PHY0)
ephy_router_mode - For routers which have more than one ports

---
 arch/mips/dts/gardena-smart-gateway-mt7688.dts | 2 ++
 arch/mips/dts/linkit-smart-7688.dts            | 2 ++
 2 files changed, 4 insertions(+)
arch/mips/dts/gardena-smart-gateway-mt7688.dts +2 -0
index 987824a76c..b7b5a24058 100644
@@ -123,5 +123,7 @@
 };
 
 &eth {
+	pinctrl-names = "default";
+	pinctrl-0 = <&ephy_iot_mode>;
 	mediatek,poll-link-phy = <0>;
 };
arch/mips/dts/linkit-smart-7688.dts +2 -0
index 740b73b3d1..f154aae190 100644
@@ -53,5 +53,7 @@
 };
 
 &eth {
+	pinctrl-names = "default";
+	pinctrl-0 = <&ephy_iot_mode>;
 	mediatek,poll-link-phy = <0>;
 };
Signature · 1 line
2.17.1
author
#26 lore raw

PATCH v3 26/28 mips: mtmips: change baudrate table for all boards

In reply to Weijie Gao

This patch changes baudrate table for all boards preparing for using mtk highspeed uart driver.

---
v2: Removed configs in defconfig files.

---
 include/configs/gardena-smart-gateway-mt7688.h | 2 +-
 include/configs/linkit-smart-7688.h            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/configs/gardena-smart-gateway-mt7688.h +1 -1
index b3b89d2ab9..e83a96ad5e 100644
@@ -22,7 +22,7 @@
 
 /* UART */
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200, \
-					  230400, 500000, 1500000 }
+					  230400, 460800, 921600 }
 
 /* RAM */
 #define CONFIG_SYS_MEMTEST_START	0x80100000
include/configs/linkit-smart-7688.h +1 -1
index 2adf38545a..4d30d98abf 100644
@@ -22,7 +22,7 @@
 
 /* UART */
 #define CONFIG_SYS_BAUDRATE_TABLE	{ 9600, 19200, 38400, 57600, 115200, \
-					  230400, 500000, 1500000 }
+					  230400, 460800, 921600 }
 
 /* RAM */
 #define CONFIG_SYS_MEMTEST_START	0x80100000
Signature · 1 line
2.17.1
author
#27 lore raw

PATCH v3 27/28 mips: mtmips: select essential drivers in Kconfig

In reply to Weijie Gao

Some drivers (clk, pinctrl, reset, ...) are necessary for reset of the system, they should be always selected.

---
v2: newly added

---
 arch/mips/Kconfig             | 6 ++++++
 arch/mips/mach-mtmips/Kconfig | 2 ++
 2 files changed, 8 insertions(+)
arch/mips/Kconfig +6 -0
index e3e7945567..fd3bf18bd7 100644
@@ -76,12 +76,18 @@ config ARCH_BMIPS
 
 config ARCH_MTMIPS
 	bool "Support MediaTek MIPS platforms"
+	select CLK
 	imply CMD_DM
 	select DISPLAY_CPUINFO
 	select DM
 	imply DM_ETH
 	imply DM_GPIO
+	select DM_RESET
 	select DM_SERIAL
+	select PINCTRL
+	select PINMUX
+	select PINCONF
+	select RESET_MTMIPS
 	imply DM_SPI
 	imply DM_SPI_FLASH
 	select LAST_STAGE_INIT
arch/mips/mach-mtmips/Kconfig +2 -0
index 4af2d54528..c8dcf19c0d 100644
@@ -13,6 +13,8 @@ choice
 config SOC_MT7628
 	bool "MT7628"
 	select MIPS_L1_CACHE_SHIFT_5
+	select PINCTRL_MT7628
+	select MTK_SERIAL
 	help
 	  This supports MediaTek MT7628/MT7688.
 
Signature · 1 line
2.17.1
author
#28 lore raw

PATCH v3 28/28 configs: mtmips: remove configs which are selected in Kconfig or useless

In reply to Weijie Gao

Some configs are selected in Kconfig and is no longer needed in the defconfig files. Some configs (power domain, ram) are never used.

---
v2: newly added

---
 configs/gardena-smart-gateway-mt7688-ram_defconfig | 7 -------
 configs/gardena-smart-gateway-mt7688_defconfig     | 7 -------
 configs/linkit-smart-7688-ram_defconfig            | 7 -------
 configs/linkit-smart-7688_defconfig                | 7 -------
 4 files changed, 28 deletions(-)
configs/gardena-smart-gateway-mt7688-ram_defconfig +0 -7
index 1a1167b2a6..d1bb59c124 100644
@@ -45,7 +45,6 @@ CONFIG_NET_RANDOM_ETHADDR=y
 # CONFIG_DM_DEVICE_REMOVE is not set
 CONFIG_HAVE_BLOCK_DEVICE=y
 CONFIG_BOOTCOUNT_LIMIT=y
-CONFIG_CLK=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
 CONFIG_LED_GPIO=y
@@ -60,15 +59,9 @@ CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_FLASH_XMC=y
 CONFIG_SPI_FLASH_MTD=y
 CONFIG_MTD_UBI_BEB_LIMIT=22
-CONFIG_PHYLIB=y
-CONFIG_PHY_FIXED=y
 CONFIG_MT7628_ETH=y
 CONFIG_PHY=y
-CONFIG_POWER_DOMAIN=y
-CONFIG_RAM=y
-CONFIG_DM_RESET=y
 # CONFIG_SPL_SERIAL_PRESENT is not set
-CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_MT7621_SPI=y
 CONFIG_SYSRESET_SYSCON=y
configs/gardena-smart-gateway-mt7688_defconfig +0 -7
index a456e3b575..552ea37164 100644
@@ -48,7 +48,6 @@ CONFIG_NET_RANDOM_ETHADDR=y
 # CONFIG_DM_DEVICE_REMOVE is not set
 CONFIG_HAVE_BLOCK_DEVICE=y
 CONFIG_BOOTCOUNT_LIMIT=y
-CONFIG_CLK=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
 CONFIG_LED_GPIO=y
@@ -63,15 +62,9 @@ CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_FLASH_XMC=y
 CONFIG_SPI_FLASH_MTD=y
 CONFIG_MTD_UBI_BEB_LIMIT=22
-CONFIG_PHYLIB=y
-CONFIG_PHY_FIXED=y
 CONFIG_MT7628_ETH=y
 CONFIG_PHY=y
-CONFIG_POWER_DOMAIN=y
-CONFIG_RAM=y
-CONFIG_DM_RESET=y
 # CONFIG_SPL_SERIAL_PRESENT is not set
-CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_MT7621_SPI=y
 CONFIG_SYSRESET_SYSCON=y
configs/linkit-smart-7688-ram_defconfig +0 -7
index aa76633802..bec6dd030c 100644
@@ -35,7 +35,6 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_NET_RANDOM_ETHADDR=y
 # CONFIG_DM_DEVICE_REMOVE is not set
 CONFIG_BLK=y
-CONFIG_CLK=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
 CONFIG_LED_GPIO=y
@@ -46,16 +45,10 @@ CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_FLASH_MTD=y
-CONFIG_PHYLIB=y
-CONFIG_PHY_FIXED=y
 CONFIG_MT7628_ETH=y
 CONFIG_PHY=y
 CONFIG_MT76X8_USB_PHY=y
-CONFIG_POWER_DOMAIN=y
-CONFIG_RAM=y
-CONFIG_DM_RESET=y
 # CONFIG_SPL_SERIAL_PRESENT is not set
-CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_MT7621_SPI=y
 CONFIG_SYSRESET_SYSCON=y
configs/linkit-smart-7688_defconfig +0 -7
index 3750e59a4b..e8db9070e6 100644
@@ -39,7 +39,6 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_NET_RANDOM_ETHADDR=y
 # CONFIG_DM_DEVICE_REMOVE is not set
 CONFIG_BLK=y
-CONFIG_CLK=y
 CONFIG_LED=y
 CONFIG_LED_BLINK=y
 CONFIG_LED_GPIO=y
@@ -50,16 +49,10 @@ CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_FLASH_MTD=y
-CONFIG_PHYLIB=y
-CONFIG_PHY_FIXED=y
 CONFIG_MT7628_ETH=y
 CONFIG_PHY=y
 CONFIG_MT76X8_USB_PHY=y
-CONFIG_POWER_DOMAIN=y
-CONFIG_RAM=y
-CONFIG_DM_RESET=y
 # CONFIG_SPL_SERIAL_PRESENT is not set
-CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_MT7621_SPI=y
 CONFIG_SYSRESET_SYSCON=y
Signature · 1 line
2.17.1
#29 lore raw

v3 cover Add and update drivers for MediaTek MT76x8 SoCs

In reply to Weijie Gao

Am 25.09.19 um 11:45 schrieb Weijie Gao:

Quoted 19 lines

This patch series have the following changes:

- Add pinctrl(both pinmux and pinconf) driver, reset controller driver and clock driver for mt7628.
- Add mt7628 platform to mtk-sd driver.
- Modify mt7628's ethernet & usb phy driver to take advantages from the new drivers.
- Update mt7621-spi driver with a new transfer method.
- Enable fifo, disable flow control, and enable non-DM implementation for mtk hsuart driver.
- Enanble the new drivers for currently existed mt7628 boards.

Changes of v2:
- Change clock gateing driver to a more 'generic' driver which supports output clock rates of CPU/SYS_BUS/peripherals.
- mt7621-spi now uses accurate sys_freq from clock driver.
- Make PHY link detection optional via DT.
- Select essential drivers in Kconfig instead of setting in defconfig files.

Quoted 4 lines

Changes of v3:
- Add const qualifier for structs in pinctrl-mt7628.c.
- Make mt76x8-usb-phy depends on SOC_MT7628.
- Simplify logic of card-detection in mtk-sd.c.

from my side for the whole series:

it would be great if Stefan could give a Tested-by for the Gardena boards ;)

Quoted 82 lines

Weijie Gao (28):
serial: serial_mtk: enable FIFO and disable flow control
serial: serial_mtk: add non-DM version for SPL
dts: mtmips: move uart property clock-frequency into mt7628an.dtsi
dts: mtmips: enable high-speed UART support for mt7628
clk: add clock driver for MediaTek MT76x8 platform
dts: mtmips: add clock node for mt7628
spi: mt7621-spi: use clock frequency from clk driver
spi: mt7621-spi: remove data cache and rewrite its xfer function
spi: mt7621-spi: restore default register value after each xfer
pinctrl: add support for MediaTek MT7628
dts: mtmips: add pinctrl node for mt7628
dts: mtmips: add default pinctrl for uart nodes
reset: add reset controller driver for MediaTek MIPS platform
dts: mtmips: update reset controller node for mt7628
phy: mt76x8-usb-phy: add slew rate calibration and remove non-mt7628
part
net: mt7628-eth: remove hardcoded gpio settings and regmap-based phy
reset
net: mt7628-eth: make phy link up detection optional via DT
net: mt7628-eth: free rx descriptor on receiving failure
net: mt7628-eth: add support to isolate LAN/WAN ports
dts: mtmips: enable eth port0 led and link poll functions for all
boards
mmc: mtk-sd: add support for MediaTek MT7620/MT7628 SoCs
mmc: mtk-sd: add a dts property cd-active-high for builtin-cd mode
dts: mtmips: add mmc related nodes for mt7628an.dtsi
dts: mtmips: add default pinctrl for gardena-smart-gateway-mt7688
dts: mtmips: add default pinctrl to eth nodes for all boards
mips: mtmips: change baudrate table for all boards
mips: mtmips: select essential drivers in Kconfig
configs: mtmips: remove configs which are selected in Kconfig or
useless

 arch/mips/Kconfig                             |   6 +
 .../mips/dts/gardena-smart-gateway-mt7688.dts |  19 +-
 arch/mips/dts/linkit-smart-7688.dts           |  16 +-
 arch/mips/dts/mt7628a.dtsi                    | 246 +++++++-
 arch/mips/mach-mtmips/Kconfig                 |   2 +
 ...gardena-smart-gateway-mt7688-ram_defconfig |   7 -
 .../gardena-smart-gateway-mt7688_defconfig    |   7 -
 configs/linkit-smart-7688-ram_defconfig       |   7 -
 configs/linkit-smart-7688_defconfig           |   7 -
 drivers/clk/Makefile                          |   1 +
 drivers/clk/mtmips/Makefile                   |   3 +
 drivers/clk/mtmips/clk-mt7628.c               | 158 +++++
 drivers/mmc/Kconfig                           |   2 +-
 drivers/mmc/mtk-sd.c                          |  29 +-
 drivers/net/Kconfig                           |   1 +
 drivers/net/mt7628-eth.c                      | 135 ++--
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/mt76x8-usb-phy.c                  | 225 +++++--
 drivers/pinctrl/Kconfig                       |   1 +
 drivers/pinctrl/Makefile                      |   1 +
 drivers/pinctrl/mtmips/Kconfig                |  13 +
 drivers/pinctrl/mtmips/Makefile               |   7 +
 drivers/pinctrl/mtmips/pinctrl-mt7628.c       | 585 ++++++++++++++++++
 .../pinctrl/mtmips/pinctrl-mtmips-common.c    |  87 +++
 .../pinctrl/mtmips/pinctrl-mtmips-common.h    |  53 ++
 drivers/reset/Kconfig                         |   7 +
 drivers/reset/Makefile                        |   1 +
 drivers/reset/reset-mtmips.c                  |  82 +++
 drivers/serial/serial.c                       |   2 +
 drivers/serial/serial_mtk.c                   | 223 ++++++-
 drivers/spi/mt7621_spi.c                      | 247 ++++----
 .../configs/gardena-smart-gateway-mt7688.h    |   2 +-
 include/configs/linkit-smart-7688.h           |   2 +-
 include/dt-bindings/clock/mt7628-clk.h        |  37 ++
 include/dt-bindings/reset/mt7628-reset.h      |  36 ++
 35 files changed, 1929 insertions(+), 329 deletions(-)
 create mode 100644 drivers/clk/mtmips/Makefile
 create mode 100644 drivers/clk/mtmips/clk-mt7628.c
 create mode 100644 drivers/pinctrl/mtmips/Kconfig
 create mode 100644 drivers/pinctrl/mtmips/Makefile
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7628.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.h
 create mode 100644 drivers/reset/reset-mtmips.c
 create mode 100644 include/dt-bindings/clock/mt7628-clk.h
 create mode 100644 include/dt-bindings/reset/mt7628-reset.h
Signature · 1 line
- Daniel
#30 lore raw

v3 cover Add and update drivers for MediaTek MT76x8 SoCs

Hi Daniel,

Quoted 27 lines · Daniel Schwierzeck

Am 25.09.19 um 11:45 schrieb Weijie Gao:

Quoted 19 lines

This patch series have the following changes:

- Add pinctrl(both pinmux and pinconf) driver, reset controller driver and clock driver for mt7628.
- Add mt7628 platform to mtk-sd driver.
- Modify mt7628's ethernet & usb phy driver to take advantages from the new drivers.
- Update mt7621-spi driver with a new transfer method.
- Enable fifo, disable flow control, and enable non-DM implementation for mtk hsuart driver.
- Enanble the new drivers for currently existed mt7628 boards.

Changes of v2:
- Change clock gateing driver to a more 'generic' driver which supports output clock rates of CPU/SYS_BUS/peripherals.
- mt7621-spi now uses accurate sys_freq from clock driver.
- Make PHY link detection optional via DT.
- Select essential drivers in Kconfig instead of setting in defconfig files.

Quoted 4 lines

Changes of v3:
- Add const qualifier for structs in pinctrl-mt7628.c.
- Make mt76x8-usb-phy depends on SOC_MT7628.
- Simplify logic of card-detection in mtk-sd.c.

Quoted 5 lines

from my side for the whole series:

it would be great if Stefan could give a Tested-by for the Gardena boards ;)

I'm just back from vacation and will try to review and test this patch series beginning (latest mid) of next week.

Thanks,
Stefan

Quoted 74 lines
Quoted 74 lines

Weijie Gao (28):
serial: serial_mtk: enable FIFO and disable flow control
serial: serial_mtk: add non-DM version for SPL
dts: mtmips: move uart property clock-frequency into mt7628an.dtsi
dts: mtmips: enable high-speed UART support for mt7628
clk: add clock driver for MediaTek MT76x8 platform
dts: mtmips: add clock node for mt7628
spi: mt7621-spi: use clock frequency from clk driver
spi: mt7621-spi: remove data cache and rewrite its xfer function
spi: mt7621-spi: restore default register value after each xfer
pinctrl: add support for MediaTek MT7628
dts: mtmips: add pinctrl node for mt7628
dts: mtmips: add default pinctrl for uart nodes
reset: add reset controller driver for MediaTek MIPS platform
dts: mtmips: update reset controller node for mt7628
phy: mt76x8-usb-phy: add slew rate calibration and remove non-mt7628
part
net: mt7628-eth: remove hardcoded gpio settings and regmap-based phy
reset
net: mt7628-eth: make phy link up detection optional via DT
net: mt7628-eth: free rx descriptor on receiving failure
net: mt7628-eth: add support to isolate LAN/WAN ports
dts: mtmips: enable eth port0 led and link poll functions for all
boards
mmc: mtk-sd: add support for MediaTek MT7620/MT7628 SoCs
mmc: mtk-sd: add a dts property cd-active-high for builtin-cd mode
dts: mtmips: add mmc related nodes for mt7628an.dtsi
dts: mtmips: add default pinctrl for gardena-smart-gateway-mt7688
dts: mtmips: add default pinctrl to eth nodes for all boards
mips: mtmips: change baudrate table for all boards
mips: mtmips: select essential drivers in Kconfig
configs: mtmips: remove configs which are selected in Kconfig or
useless

  arch/mips/Kconfig                             |   6 +
  .../mips/dts/gardena-smart-gateway-mt7688.dts |  19 +-
  arch/mips/dts/linkit-smart-7688.dts           |  16 +-
  arch/mips/dts/mt7628a.dtsi                    | 246 +++++++-
  arch/mips/mach-mtmips/Kconfig                 |   2 +
  ...gardena-smart-gateway-mt7688-ram_defconfig |   7 -
  .../gardena-smart-gateway-mt7688_defconfig    |   7 -
  configs/linkit-smart-7688-ram_defconfig       |   7 -
  configs/linkit-smart-7688_defconfig           |   7 -
  drivers/clk/Makefile                          |   1 +
  drivers/clk/mtmips/Makefile                   |   3 +
  drivers/clk/mtmips/clk-mt7628.c               | 158 +++++
  drivers/mmc/Kconfig                           |   2 +-
  drivers/mmc/mtk-sd.c                          |  29 +-
  drivers/net/Kconfig                           |   1 +
  drivers/net/mt7628-eth.c                      | 135 ++--
  drivers/phy/Kconfig                           |   1 +
  drivers/phy/mt76x8-usb-phy.c                  | 225 +++++--
  drivers/pinctrl/Kconfig                       |   1 +
  drivers/pinctrl/Makefile                      |   1 +
  drivers/pinctrl/mtmips/Kconfig                |  13 +
  drivers/pinctrl/mtmips/Makefile               |   7 +
  drivers/pinctrl/mtmips/pinctrl-mt7628.c       | 585 ++++++++++++++++++
  .../pinctrl/mtmips/pinctrl-mtmips-common.c    |  87 +++
  .../pinctrl/mtmips/pinctrl-mtmips-common.h    |  53 ++
  drivers/reset/Kconfig                         |   7 +
  drivers/reset/Makefile                        |   1 +
  drivers/reset/reset-mtmips.c                  |  82 +++
  drivers/serial/serial.c                       |   2 +
  drivers/serial/serial_mtk.c                   | 223 ++++++-
  drivers/spi/mt7621_spi.c                      | 247 ++++----
  .../configs/gardena-smart-gateway-mt7688.h    |   2 +-
  include/configs/linkit-smart-7688.h           |   2 +-
  include/dt-bindings/clock/mt7628-clk.h        |  37 ++
  include/dt-bindings/reset/mt7628-reset.h      |  36 ++
  35 files changed, 1929 insertions(+), 329 deletions(-)

create mode 100644 drivers/clk/mtmips/Makefile create mode 100644 drivers/clk/mtmips/clk-mt7628.c create mode 100644 drivers/pinctrl/mtmips/Kconfig

Quoted 9 lines
Quoted 8 lines

create mode 100644 drivers/pinctrl/mtmips/Makefile create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7628.c create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.c create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.h create mode 100644 drivers/reset/reset-mtmips.c
create mode 100644 include/dt-bindings/clock/mt7628-clk.h create mode 100644 include/dt-bindings/reset/mt7628-reset.h

Viele Grüße,
Stefan

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
#31 lore raw

v3 cover Add and update drivers for MediaTek MT76x8 SoCs

In reply to Daniel Schwierzeck
Quoted 25 lines · Daniel Schwierzeck

Am 25.09.19 um 11:45 schrieb Weijie Gao:

Quoted 19 lines

This patch series have the following changes:

- Add pinctrl(both pinmux and pinconf) driver, reset controller driver and clock driver for mt7628.
- Add mt7628 platform to mtk-sd driver.
- Modify mt7628's ethernet & usb phy driver to take advantages from the new drivers.
- Update mt7621-spi driver with a new transfer method.
- Enable fifo, disable flow control, and enable non-DM implementation for mtk hsuart driver.
- Enanble the new drivers for currently existed mt7628 boards.

Changes of v2:
- Change clock gateing driver to a more 'generic' driver which supports output clock rates of CPU/SYS_BUS/peripherals.
- mt7621-spi now uses accurate sys_freq from clock driver.
- Make PHY link detection optional via DT.
- Select essential drivers in Kconfig instead of setting in defconfig files.

Quoted 4 lines

Changes of v3:
- Add const qualifier for structs in pinctrl-mt7628.c.
- Make mt76x8-usb-phy depends on SOC_MT7628.
- Simplify logic of card-detection in mtk-sd.c.

Quoted 5 lines

from my side for the whole series:

it would be great if Stefan could give a Tested-by for the Gardena boards ;)

Okay, here we go (for the whole series):

Thanks,
Stefan

#32 lore raw

v3 cover Add and update drivers for MediaTek MT76x8 SoCs

In reply to Weijie Gao

Am 25.09.19 um 11:45 schrieb Weijie Gao:

Quoted 96 lines

This patch series have the following changes:

- Add pinctrl(both pinmux and pinconf) driver, reset controller driver and clock driver for mt7628.
- Add mt7628 platform to mtk-sd driver.
- Modify mt7628's ethernet & usb phy driver to take advantages from the new drivers.
- Update mt7621-spi driver with a new transfer method.
- Enable fifo, disable flow control, and enable non-DM implementation for mtk hsuart driver.
- Enanble the new drivers for currently existed mt7628 boards.

Changes of v2:
- Change clock gateing driver to a more 'generic' driver which supports output clock rates of CPU/SYS_BUS/peripherals.
- mt7621-spi now uses accurate sys_freq from clock driver.
- Make PHY link detection optional via DT.
- Select essential drivers in Kconfig instead of setting in defconfig files.

Changes of v3:
- Add const qualifier for structs in pinctrl-mt7628.c.
- Make mt76x8-usb-phy depends on SOC_MT7628.
- Simplify logic of card-detection in mtk-sd.c.

Weijie Gao (28):
serial: serial_mtk: enable FIFO and disable flow control
serial: serial_mtk: add non-DM version for SPL
dts: mtmips: move uart property clock-frequency into mt7628an.dtsi
dts: mtmips: enable high-speed UART support for mt7628
clk: add clock driver for MediaTek MT76x8 platform
dts: mtmips: add clock node for mt7628
spi: mt7621-spi: use clock frequency from clk driver
spi: mt7621-spi: remove data cache and rewrite its xfer function
spi: mt7621-spi: restore default register value after each xfer
pinctrl: add support for MediaTek MT7628
dts: mtmips: add pinctrl node for mt7628
dts: mtmips: add default pinctrl for uart nodes
reset: add reset controller driver for MediaTek MIPS platform
dts: mtmips: update reset controller node for mt7628
phy: mt76x8-usb-phy: add slew rate calibration and remove non-mt7628
part
net: mt7628-eth: remove hardcoded gpio settings and regmap-based phy
reset
net: mt7628-eth: make phy link up detection optional via DT
net: mt7628-eth: free rx descriptor on receiving failure
net: mt7628-eth: add support to isolate LAN/WAN ports
dts: mtmips: enable eth port0 led and link poll functions for all
boards
mmc: mtk-sd: add support for MediaTek MT7620/MT7628 SoCs
mmc: mtk-sd: add a dts property cd-active-high for builtin-cd mode
dts: mtmips: add mmc related nodes for mt7628an.dtsi
dts: mtmips: add default pinctrl for gardena-smart-gateway-mt7688
dts: mtmips: add default pinctrl to eth nodes for all boards
mips: mtmips: change baudrate table for all boards
mips: mtmips: select essential drivers in Kconfig
configs: mtmips: remove configs which are selected in Kconfig or
useless

 arch/mips/Kconfig                             |   6 +
 .../mips/dts/gardena-smart-gateway-mt7688.dts |  19 +-
 arch/mips/dts/linkit-smart-7688.dts           |  16 +-
 arch/mips/dts/mt7628a.dtsi                    | 246 +++++++-
 arch/mips/mach-mtmips/Kconfig                 |   2 +
 ...gardena-smart-gateway-mt7688-ram_defconfig |   7 -
 .../gardena-smart-gateway-mt7688_defconfig    |   7 -
 configs/linkit-smart-7688-ram_defconfig       |   7 -
 configs/linkit-smart-7688_defconfig           |   7 -
 drivers/clk/Makefile                          |   1 +
 drivers/clk/mtmips/Makefile                   |   3 +
 drivers/clk/mtmips/clk-mt7628.c               | 158 +++++
 drivers/mmc/Kconfig                           |   2 +-
 drivers/mmc/mtk-sd.c                          |  29 +-
 drivers/net/Kconfig                           |   1 +
 drivers/net/mt7628-eth.c                      | 135 ++--
 drivers/phy/Kconfig                           |   1 +
 drivers/phy/mt76x8-usb-phy.c                  | 225 +++++--
 drivers/pinctrl/Kconfig                       |   1 +
 drivers/pinctrl/Makefile                      |   1 +
 drivers/pinctrl/mtmips/Kconfig                |  13 +
 drivers/pinctrl/mtmips/Makefile               |   7 +
 drivers/pinctrl/mtmips/pinctrl-mt7628.c       | 585 ++++++++++++++++++
 .../pinctrl/mtmips/pinctrl-mtmips-common.c    |  87 +++
 .../pinctrl/mtmips/pinctrl-mtmips-common.h    |  53 ++
 drivers/reset/Kconfig                         |   7 +
 drivers/reset/Makefile                        |   1 +
 drivers/reset/reset-mtmips.c                  |  82 +++
 drivers/serial/serial.c                       |   2 +
 drivers/serial/serial_mtk.c                   | 223 ++++++-
 drivers/spi/mt7621_spi.c                      | 247 ++++----
 .../configs/gardena-smart-gateway-mt7688.h    |   2 +-
 include/configs/linkit-smart-7688.h           |   2 +-
 include/dt-bindings/clock/mt7628-clk.h        |  37 ++
 include/dt-bindings/reset/mt7628-reset.h      |  36 ++
 35 files changed, 1929 insertions(+), 329 deletions(-)
 create mode 100644 drivers/clk/mtmips/Makefile
 create mode 100644 drivers/clk/mtmips/clk-mt7628.c
Quoted 9 lines
 create mode 100644 drivers/pinctrl/mtmips/Kconfig
 create mode 100644 drivers/pinctrl/mtmips/Makefile
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mt7628.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.c
 create mode 100644 drivers/pinctrl/mtmips/pinctrl-mtmips-common.h
 create mode 100644 drivers/reset/reset-mtmips.c
 create mode 100644 include/dt-bindings/clock/mt7628-clk.h
 create mode 100644 include/dt-bindings/reset/mt7628-reset.h

series applied to u-boot-mips, thanks.

Signature · 1 line
- Daniel