Skip to contentSkip to conversation

arm: airoha: add AN7583 SoC support

PATCH Superseded Christian Marangi 2 participants 19 messages Oct 22 – Nov 2

Subsystems (6)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover arm: airoha: add AN7583 SoC support

This patch series adds AN7583 SoC support. It is based on u-boot patches of Christian Marangi airoha openwrt branch

https://github.com/Ansuel/openwrt/commits/main-airoha-6.12/

AN7583 is not included to upstream linux, but actively supported by upstream openwrt. The patches were adapted for latest U-Boot.

Since I'm not seeing progress, I'm again taking over the series [1] from Mikhail.

[1] https://lore.kernel.org/all/[email protected]/

Changes v3:
- Rebase on top of next
- Fix MAINTAINERS spacing
- Improve commit title and description
- Don't pollute dts/upstream for clk but use dedicated header
- Update 7583.dtsi for new scuclk node (reflect new upstream proposal)
- Fix some minor checkpatch warning on reset header
- Reorganize patch for better bisectability

Changes v2: (from Mikhail)
- fixed arch/arm/mach-airoha/an7583/init.c compilation issue
- added an7583 specific helper needed for clk-airoha
- patches for proper support of clk, reset, network

Christian Marangi (13):
dt-bindings: clock: airoha: Document support for AN7583 clock
dt-bindings: reset: airoha: Document support for AN7583 reset
airoha: add support for Airoha AN7583 SoC
clk: airoha: add support for Airoha AN7583 SoC clock
reset: airoha: Add support for Airoha AN7583 reset
net: airoha: add support for Airoha AN7583
ARM: dts: an7583: add Ethernet node
ARM: dts: an7583: add MMC node
net: airoha: add support for Airoha AN7583 PCS driver
ARM: dts: an7583: add PCS nodes
configs: an7583: enable PCS for Airoha AN7583
net: Add support for Airoha AN7583 MDIO Controller
configs: an7583: enable MDIO_AIROHA by default

Mikhail Kshevetskiy (3):
arm: airoha: introduce AN7583 helpers to get SCU and CHIP_SCU regmaps
configs: an7583: add mii/mdio support
ARM: dts: an7583: add mdio child node to switch node

 arch/arm/dts/an7583-evb.dts                   |   85 +
 arch/arm/dts/an7583.dtsi                      |  526 ++++
 arch/arm/include/asm/arch-an7583              |    1 +
 arch/arm/mach-airoha/Kconfig                  |   14 +
 arch/arm/mach-airoha/Makefile                 |    1 +
 arch/arm/mach-airoha/an7583/Makefile          |    4 +
 arch/arm/mach-airoha/an7583/init.c            |   66 +
 arch/arm/mach-airoha/an7583/scu-regmap.c      |   30 +
 board/airoha/an7583/MAINTAINERS               |    5 +
 board/airoha/an7583/Makefile                  |    3 +
 board/airoha/an7583/an7583_rfb.c              |   16 +
 configs/an7583_evb_defconfig                  |   83 +
 drivers/clk/airoha/clk-airoha.c               |  159 ++
 drivers/net/Kconfig                           |    7 +
 drivers/net/Makefile                          |    1 +
 drivers/net/airoha/Kconfig                    |    8 +
 drivers/net/airoha/Makefile                   |    1 +
 drivers/net/airoha/pcs-airoha-common.c        |   27 +
 drivers/net/airoha/pcs-airoha.h               |   17 +
 drivers/net/airoha/pcs-an7583.c               | 2202 +++++++++++++++++
 drivers/net/airoha_eth.c                      |   94 +
 drivers/net/mdio-airoha.c                     |  221 ++
 drivers/reset/reset-airoha.c                  |   60 +
 include/configs/an7583.h                      |   19 +
 include/dt-bindings/clock/an7583-clk.h        |    9 +
 .../dt-bindings/reset/airoha,an7583-reset.h   |   62 +
 26 files changed, 3721 insertions(+)
 create mode 100644 arch/arm/dts/an7583-evb.dts
 create mode 100644 arch/arm/dts/an7583.dtsi
 create mode 120000 arch/arm/include/asm/arch-an7583
 create mode 100644 arch/arm/mach-airoha/an7583/Makefile
 create mode 100644 arch/arm/mach-airoha/an7583/init.c
 create mode 100644 arch/arm/mach-airoha/an7583/scu-regmap.c
 create mode 100644 board/airoha/an7583/MAINTAINERS
 create mode 100644 board/airoha/an7583/Makefile
 create mode 100644 board/airoha/an7583/an7583_rfb.c
 create mode 100644 configs/an7583_evb_defconfig
 create mode 100644 drivers/net/airoha/pcs-an7583.c
 create mode 100644 drivers/net/mdio-airoha.c
 create mode 100644 include/configs/an7583.h
 create mode 100644 include/dt-bindings/clock/an7583-clk.h
 create mode 100644 include/dt-bindings/reset/airoha,an7583-reset.h
Signature · 1 line
2.55.0
#1 lore raw

PATCH v3 1/16 dt-bindings: clock: airoha: Document support for AN7583 clock

Document support for Airoha AN7583 clock. This is based on the EN7523 clock schema with the new requirement of the "airoha,chip-scu" (previously optional for EN7581).

Add additional binding for additional clock and reset lines.

---
 include/dt-bindings/clock/an7583-clk.h | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 include/dt-bindings/clock/an7583-clk.h
include/dt-bindings/clock/an7583-clk.h new file +9 -0
new file mode 100644
index 000000000000..e832961d0663
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+
+/*
+ * This adds up on top of upstream
+ * include/dt-bindings/clock/en7523-clk.h
+ */
+
+#define AN7583_CLK_MDIO0	9
+#define AN7583_CLK_MDIO1	10
Signature · 1 line
2.55.0
#2 lore raw

PATCH v3 2/16 dt-bindings: reset: airoha: Document support for AN7583 reset

In reply to Christian Marangi

Document support for Airoha AN7583 reset. Add the reset bindings for each reset line on the SoC.

---
 .../dt-bindings/reset/airoha,an7583-reset.h   | 62 +++++++++++++++++++
 1 file changed, 62 insertions(+)
 create mode 100644 include/dt-bindings/reset/airoha,an7583-reset.h
include/dt-bindings/reset/airoha,an7583-reset.h new file +62 -0
new file mode 100644
index 000000000000..7ff07986f8ba
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (c) 2024 AIROHA Inc
+ * Author: Christian Marangi <[email protected]>
+ */
+
+#ifndef __DT_BINDINGS_RESET_CONTROLLER_AIROHA_AN7583_H_
+#define __DT_BINDINGS_RESET_CONTROLLER_AIROHA_AN7583_H_
+
+/* RST_CTRL2 */
+#define AN7583_XPON_PHY_RST		 0
+#define AN7583_GPON_OLT_RST		 1
+#define AN7583_CPU_TIMER2_RST		 2
+#define AN7583_HSUART_RST		 3
+#define AN7583_UART4_RST		 4
+#define AN7583_UART5_RST		 5
+#define AN7583_I2C2_RST			 6
+#define AN7583_XSI_MAC_RST		 7
+#define AN7583_XSI_PHY_RST		 8
+#define AN7583_NPU_RST			 9
+#define AN7583_TRNG_MSTART_RST		10
+#define AN7583_DUAL_HSI0_RST		11
+#define AN7583_DUAL_HSI1_RST		12
+#define AN7583_DUAL_HSI0_MAC_RST	13
+#define AN7583_DUAL_HSI1_MAC_RST	14
+#define AN7583_XPON_XFI_RST             15
+#define AN7583_WDMA_RST			16
+#define AN7583_WOE0_RST			17
+#define AN7583_HSDMA_RST		18
+#define AN7583_TDMA_RST			19
+#define AN7583_EMMC_RST			20
+#define AN7583_SOE_RST			21
+#define AN7583_XFP_MAC_RST		22
+#define AN7583_MDIO0                    23
+#define AN7583_MDIO1                    24
+/* RST_CTRL1 */
+#define AN7583_PCM1_ZSI_ISI_RST		25
+#define AN7583_FE_PDMA_RST		26
+#define AN7583_FE_QDMA_RST		27
+#define AN7583_PCM_SPIWP_RST		28
+#define AN7583_CRYPTO_RST		29
+#define AN7583_TIMER_RST		30
+#define AN7583_PCM1_RST			31
+#define AN7583_UART_RST			32
+#define AN7583_GPIO_RST			33
+#define AN7583_GDMA_RST			34
+#define AN7583_I2C_MASTER_RST		35
+#define AN7583_PCM2_ZSI_ISI_RST		36
+#define AN7583_SFC_RST			37
+#define AN7583_UART2_RST		38
+#define AN7583_GDMP_RST			39
+#define AN7583_FE_RST			40
+#define AN7583_USB_HOST_P0_RST		41
+#define AN7583_GSW_RST			42
+#define AN7583_SFC2_PCM_RST		43
+#define AN7583_PCIE0_RST		44
+#define AN7583_PCIE1_RST		45
+#define AN7583_CPU_TIMER_RST		46
+#define AN7583_PCIE_HB_RST		47
+#define AN7583_XPON_MAC_RST		48
+
+#endif /* __DT_BINDINGS_RESET_CONTROLLER_AIROHA_AN7583_H_ */
Signature · 1 line
2.55.0
#3 lore raw

PATCH v3 3/16 airoha: add support for Airoha AN7583 SoC

In reply to Christian Marangi

Add support for Airoha AN7583 SoC. This adds the Kconfig and Makefile entry for the SoC, DTSI and initial config for it. Also add the code for CPU and RAM initialization. Everything is mostly based on AN7581 that share lots of common piece.

---
 arch/arm/dts/an7583-evb.dts          |  67 +++++
 arch/arm/dts/an7583.dtsi             | 390 +++++++++++++++++++++++++++
 arch/arm/mach-airoha/Kconfig         |  14 +
 arch/arm/mach-airoha/Makefile        |   1 +
 arch/arm/mach-airoha/an7583/Makefile |   3 +
 arch/arm/mach-airoha/an7583/init.c   |  66 +++++
 board/airoha/an7583/MAINTAINERS      |   5 +
 board/airoha/an7583/Makefile         |   3 +
 board/airoha/an7583/an7583_rfb.c     |  16 ++
 configs/an7583_evb_defconfig         |  79 ++++++
 include/configs/an7583.h             |  19 ++
 11 files changed, 663 insertions(+)
 create mode 100644 arch/arm/dts/an7583-evb.dts
 create mode 100644 arch/arm/dts/an7583.dtsi
 create mode 100644 arch/arm/mach-airoha/an7583/Makefile
 create mode 100644 arch/arm/mach-airoha/an7583/init.c
 create mode 100644 board/airoha/an7583/MAINTAINERS
 create mode 100644 board/airoha/an7583/Makefile
 create mode 100644 board/airoha/an7583/an7583_rfb.c
 create mode 100644 configs/an7583_evb_defconfig
 create mode 100644 include/configs/an7583.h
arch/arm/dts/an7583-evb.dts new file +67 -0
new file mode 100644
index 000000000000..d02cd194e8a3
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+/dts-v1/;
+
+/* Bootloader installs ATF here */
+/memreserve/ 0x80000000 0x200000;
+
+#include <dt-bindings/leds/common.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include "an7583.dtsi"
+
+/ {
+	model = "Airoha AN7583 Evaluation Board";
+	compatible = "airoha,an7583-evb", "airoha,an7583", "airoha,en7583";
+
+	aliases {
+		serial0 = &uart1;
+	};
+
+	chosen {
+		bootargs = "console=ttyS0,115200 earlycon";
+		stdout-path = "serial0:115200n8";
+		linux,usable-memory-range = <0x0 0x80200000 0x0 0x1fe00000>;
+	};
+
+	/* When running as a first-stage bootloader this isn't filled in automatically */
+	memory@80000000 {
+		device_type = "memory";
+		reg = <0x0 0x80000000 0x0 0x20000000>;
+	};
+};
+
+&an7583_pinctrl {
+	pcie0_rst_pins: pcie0-rst-pins {
+		conf {
+			pins = "pcie_reset0";
+			drive-open-drain = <1>;
+		};
+	};
+
+	pcie1_rst_pins: pcie1-rst-pins {
+		conf {
+			pins = "pcie_reset1";
+			drive-open-drain = <1>;
+		};
+	};
+};
+
+&pcie0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie0_rst_pins>;
+	status = "okay";
+};
+
+&pcie1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pcie1_rst_pins>;
+	status = "okay";
+};
+
+&i2c0 {
+	status = "okay";
+};
+
+&snfi {
+	status = "okay";
+};
arch/arm/dts/an7583.dtsi new file +390 -0

390 lines not on this page · raw message

arch/arm/mach-airoha/Kconfig +14 -0
index 4b0374001d0c..72cd14542086 100644
@@ -29,19 +29,33 @@ config TARGET_AN7581
 	  Peripherals include Gigabit Ethernet, switch, USB3.0 and OTG, PCIe,
 	  I2S, PCM, S/PDIF, UART, SPI, I2C, IR TX/RX, and PWM.
 
+config TARGET_AN7583
+	bool "Airoha AN7583 SoC"
+	select ARM64
+	help
+	  The Airoha AN7583 is a ARM-based SoC with a quad-core Cortex-A7
+	  including NEON and GPU, Mali-450 graphics, several DDR3 options,
+	  crypto engine, built-in Wi-Fi / Bluetooth combo chip, JPEG decoder,
+	  video interfaces supporting HDMI and MIPI, and video codec support.
+	  Peripherals include Gigabit Ethernet, switch, USB3.0 and OTG, PCIe,
+	  I2S, PCM, S/PDIF, UART, SPI, I2C, IR TX/RX, and PWM.
+
 endchoice
 
 config SYS_SOC
 	default "en7523" if TARGET_EN7523
 	default "an7581" if TARGET_AN7581
+	default "an7583" if TARGET_AN7583
 
 config SYS_BOARD
 	default "en7523" if TARGET_EN7523
 	default "an7581" if TARGET_AN7581
+	default "an7583" if TARGET_AN7583
 
 config SYS_CONFIG_NAME
 	default "en7523" if TARGET_EN7523
 	default "an7581" if TARGET_AN7581
+	default "an7583" if TARGET_AN7583
 
 endif
 
arch/arm/mach-airoha/Makefile +1 -0
index 91395b8a8503..51d82ea3e217 100644
@@ -4,3 +4,4 @@ obj-y	+= cpu.o
 
 obj-$(CONFIG_TARGET_EN7523) += en7523/
 obj-$(CONFIG_TARGET_AN7581) += an7581/
+obj-$(CONFIG_TARGET_AN7583) += an7583/
arch/arm/mach-airoha/an7583/Makefile new file +3 -0
new file mode 100644
index 000000000000..886ab7e4eb9f
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier:	GPL-2.0
+
+obj-y += init.o
arch/arm/mach-airoha/an7583/init.c new file +66 -0

66 lines not on this page · raw message

board/airoha/an7583/MAINTAINERS new file +5 -0
new file mode 100644
index 000000000000..baa5228a57eb
@@ -0,0 +1,5 @@
+AN7583
+M:	Christian Marangi <[email protected]>
+S:	Maintained
+N:	airoha
+N:	an7583
board/airoha/an7583/Makefile new file +3 -0
new file mode 100644
index 000000000000..d582684d1f7f
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier:	GPL-2.0
+
+obj-y	+= an7583_rfb.o
board/airoha/an7583/an7583_rfb.c new file +16 -0
new file mode 100644
index 000000000000..aa73679d929e
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Author: Christian Marangi <[email protected]>
+ */
+
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+	/* address of boot parameters */
+	gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
+
+	return 0;
+}
configs/an7583_evb_defconfig new file +79 -0

79 lines not on this page · raw message

include/configs/an7583.h new file +19 -0
new file mode 100644
index 000000000000..c865afea1a2a
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Configuration for Airoha AN7583
+ */
+
+#ifndef __AN7583_H
+#define __AN7583_H
+
+#include <linux/sizes.h>
+
+#define CFG_SYS_UBOOT_BASE		CONFIG_TEXT_BASE
+
+#define CFG_SYS_INIT_RAM_ADDR           CONFIG_TEXT_BASE
+#define CFG_SYS_INIT_RAM_SIZE           SZ_2M
+
+/* DRAM */
+#define CFG_SYS_SDRAM_BASE		0x80000000
+
+#endif
Signature · 1 line
2.55.0
#4 lore raw

PATCH v3 4/16 arm: airoha: introduce AN7583 helpers to get SCU and CHIP_SCU regmaps

In reply to Christian Marangi

From: Mikhail Kshevetskiy <[email protected]>

We need access SCU and CHIP_SCU regmaps in several places (clk-airoha, reset-airoha, airoha_eth). Unfortunately these regmaps can't be easily retrieved with a common code, because of different Airoha SoCs uses a different dts structure.

To make life easy we can write a commonly named SoC specific helpers for these tasks. This patch implements helpers for Airoha AN7583 SoC.

---
 arch/arm/include/asm/arch-an7583         |  1 +
 arch/arm/mach-airoha/an7583/Makefile     |  1 +
 arch/arm/mach-airoha/an7583/scu-regmap.c | 30 ++++++++++++++++++++++++
 3 files changed, 32 insertions(+)
 create mode 120000 arch/arm/include/asm/arch-an7583
 create mode 100644 arch/arm/mach-airoha/an7583/scu-regmap.c
arch/arm/include/asm/arch-an7583 new file +1 -0
new file mode 120000
index 000000000000..d2317ed3bc3c
@@ -0,0 +1 @@
+arch-airoha
\ No newline at end of file
arch/arm/mach-airoha/an7583/Makefile +1 -0
index 886ab7e4eb9f..51f978aa1017 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier:	GPL-2.0
 
 obj-y += init.o
+obj-y += scu-regmap.o
arch/arm/mach-airoha/an7583/scu-regmap.c new file +30 -0
new file mode 100644
index 000000000000..544cee8adbc6
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Author: Mikhail Kshevetskiy <[email protected]>
+ */
+
+#include <syscon.h>
+#include <linux/err.h>
+#include <asm/arch/scu-regmap.h>
+
+struct regmap *airoha_get_scu_regmap(void)
+{
+	ofnode node;
+
+	node = ofnode_by_compatible(ofnode_null(), "airoha,an7583-scu");
+	if (!ofnode_valid(node))
+		return ERR_PTR(-EINVAL);
+
+	return syscon_node_to_regmap(node);
+}
+
+struct regmap *airoha_get_chip_scu_regmap(void)
+{
+	ofnode node;
+
+	node = ofnode_by_compatible(ofnode_null(), "airoha,en7581-chip-scu");
+	if (!ofnode_valid(node))
+		return ERR_PTR(-EINVAL);
+
+	return syscon_node_to_regmap(node);
+}
Signature · 1 line
2.55.0
#5 lore raw

PATCH v3 5/16 clk: airoha: add support for Airoha AN7583 SoC clock

In reply to Christian Marangi

Add support for Airoha AN7583 SoC clock that implement more base values for clocks compared to AN7581.

---
 drivers/clk/airoha/clk-airoha.c | 159 ++++++++++++++++++++++++++++++++
 1 file changed, 159 insertions(+)
drivers/clk/airoha/clk-airoha.c +159 -0
index 89a8b4cb1cf8..5e73455573eb 100644
@@ -19,6 +19,7 @@
 #include <asm/arch/scu-regmap.h>
 
 #include <dt-bindings/clock/en7523-clk.h>
+#include <dt-bindings/clock/an7583-clk.h>
 
 #define REG_GSW_CLK_DIV_SEL		0x1b4
 #define REG_EMI_CLK_DIV_SEL		0x1b8
@@ -36,6 +37,7 @@
 
 #define EN7523_MAX_CLKS			8
 #define EN7581_MAX_CLKS			9
+#define EN7583_MAX_CLKS			11
 
 struct airoha_clk_desc {
 	int id;
@@ -78,6 +80,14 @@ static const u32 bus7581_base[] = { 600000000, 540000000 };
 static const u32 npu7581_base[] = { 800000000, 750000000, 720000000, 600000000 };
 static const u32 crypto_base[] = { 540000000, 480000000 };
 static const u32 emmc7581_base[] = { 200000000, 150000000 };
+/* AN7583 */
+static const u32 gsw7583_base[] = { 540672000, 270336000, 400000000, 200000000 };
+static const u32 emi7583_base[] = { 540672000, 480000000, 400000000, 300000000 };
+static const u32 bus7583_base[] = { 600000000, 540672000, 480000000, 400000000 };
+static const u32 spi7583_base[] = { 400000000, 12500000 };
+static const u32 npu7583_base[] = { 666000000, 800000000, 720000000, 600000000 };
+static const u32 crypto7583_base[] = { 540672000, 400000000 };
+static const u32 emmc7583_base[] = { 150000000, 200000000 };
 
 static const struct airoha_clk_desc en7523_base_clks[EN7523_MAX_CLKS] = {
 	[EN7523_CLK_GSW] = {
@@ -293,6 +303,147 @@ static const struct airoha_clk_desc en7581_base_clks[EN7581_MAX_CLKS] = {
 	}
 };
 
+static const struct airoha_clk_desc an7583_base_clks[EN7583_MAX_CLKS] = {
+	[EN7523_CLK_GSW] = {
+		.id = EN7523_CLK_GSW,
+		.name = "gsw",
+
+		.base_reg = REG_GSW_CLK_DIV_SEL,
+		.base_bits = 2,
+		.base_shift = 8,
+		.base_values = gsw7583_base,
+		.n_base_values = ARRAY_SIZE(gsw7583_base),
+
+		.div_bits = 3,
+		.div_shift = 0,
+		.div_step = 1,
+		.div_offset = 1,
+	},
+	[EN7523_CLK_EMI] = {
+		.id = EN7523_CLK_EMI,
+		.name = "emi",
+
+		.base_reg = REG_EMI_CLK_DIV_SEL,
+		.base_bits = 2,
+		.base_shift = 8,
+		.base_values = emi7583_base,
+		.n_base_values = ARRAY_SIZE(emi7583_base),
+
+		.div_bits = 3,
+		.div_shift = 0,
+		.div_step = 1,
+		.div_offset = 1,
+	},
+	[EN7523_CLK_BUS] = {
+		.id = EN7523_CLK_BUS,
+		.name = "bus",
+
+		.base_reg = REG_BUS_CLK_DIV_SEL,
+		.base_bits = 2,
+		.base_shift = 8,
+		.base_values = bus7583_base,
+		.n_base_values = ARRAY_SIZE(bus7583_base),
+
+		.div_bits = 3,
+		.div_shift = 0,
+		.div_step = 1,
+		.div_offset = 1,
+	},
+	[EN7523_CLK_SLIC] = {
+		.id = EN7523_CLK_SLIC,
+		.name = "slic",
+
+		.base_reg = REG_SPI_CLK_FREQ_SEL,
+		.base_bits = 1,
+		.base_shift = 1,
+		.base_values = slic_base,
+		.n_base_values = ARRAY_SIZE(slic_base),
+
+		.div_reg = REG_SPI_CLK_DIV_SEL,
+		.div_bits = 5,
+		.div_shift = 24,
+		.div_val0 = 20,
+		.div_step = 2,
+	},
+	[EN7523_CLK_SPI] = {
+		.id = EN7523_CLK_SPI,
+		.name = "spi",
+
+		.base_reg = REG_SPI_CLK_FREQ_SEL,
+		.base_bits = 1,
+		.base_shift = 0,
+		.base_values = spi7583_base,
+		.n_base_values = ARRAY_SIZE(spi7583_base),
+
+		.div_reg = REG_SPI_CLK_DIV_SEL,
+		.div_bits = 5,
+		.div_shift = 8,
+		.div_val0 = 40,
+		.div_step = 2,
+	},
+	[EN7523_CLK_NPU] = {
+		.id = EN7523_CLK_NPU,
+		.name = "npu",
+
+		.base_reg = REG_NPU_CLK_DIV_SEL,
+		.base_bits = 2,
+		.base_shift = 9,
+		.base_values = npu7583_base,
+		.n_base_values = ARRAY_SIZE(npu7583_base),
+
+		.div_bits = 3,
+		.div_shift = 0,
+		.div_step = 1,
+		.div_offset = 1,
+	},
+	[EN7523_CLK_CRYPTO] = {
+		.id = EN7523_CLK_CRYPTO,
+		.name = "crypto",
+
+		.base_reg = REG_CRYPTO_CLKSRC2,
+		.base_bits = 1,
+		.base_shift = 0,
+		.base_values = crypto7583_base,
+		.n_base_values = ARRAY_SIZE(crypto7583_base),
+	},
+	[EN7581_CLK_EMMC] = {
+		.id = EN7581_CLK_EMMC,
+		.name = "emmc",
+
+		.base_reg = REG_CRYPTO_CLKSRC2,
+		.base_bits = 1,
+		.base_shift = 13,
+		.base_values = emmc7583_base,
+		.n_base_values = ARRAY_SIZE(emmc7583_base),
+	},
+	[AN7583_CLK_MDIO0] = {
+		.id = AN7583_CLK_MDIO0,
+		.name = "mdio0",
+
+		.base_reg = REG_CRYPTO_CLKSRC2,
+
+		.base_value = 25000000,
+
+		.div_bits = 4,
+		.div_shift = 15,
+		.div_step = 1,
+		.div_offset = 1,
+	},
+	[AN7583_CLK_MDIO1] = {
+		.id = AN7583_CLK_MDIO1,
+		.name = "mdio1",
+
+		.base_reg = REG_CRYPTO_CLKSRC2,
+
+		.base_value = 25000000,
+
+		.div_bits = 4,
+		.div_shift = 19,
+		.div_step = 1,
+		.div_offset = 1,
+	}
+};
+
 static u32 airoha_clk_get_base_rate(const struct airoha_clk_desc *desc, u32 val)
 {
 	if (!desc->base_bits)
@@ -542,6 +693,11 @@ static const struct airoha_clk_soc_data en7581_data = {
 	.descs = en7581_base_clks,
 };
 
+static const struct airoha_clk_soc_data an7583_data = {
+	.num_clocks = ARRAY_SIZE(an7583_base_clks),
+	.descs = an7583_base_clks,
+};
+
 static const struct udevice_id airoha_clk_ids[] = {
 	{ .compatible = "airoha,en7523-scu",
 	  .data = (ulong)&en7523_data,
@@ -549,6 +705,9 @@ static const struct udevice_id airoha_clk_ids[] = {
 	{ .compatible = "airoha,en7581-scu",
 	  .data = (ulong)&en7581_data,
 	},
+	{ .compatible = "airoha,an7583-scu",
+	  .data = (ulong)&an7583_data,
+	},
 	{ }
 };
 
Signature · 1 line
2.55.0
#6 lore raw

PATCH v3 6/16 reset: airoha: Add support for Airoha AN7583 reset

In reply to Christian Marangi

Adapt the Airoha reset driver to support Airoha AN7583 node structure. In AN7583 the register is exposed by the parent syscon hence a different logic needs to be applied. Also the reset line differ from AN7581 hence a dedicated table is needed.

---
 drivers/reset/reset-airoha.c | 60 ++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
drivers/reset/reset-airoha.c +60 -0
index ef8c47a067bb..071f29b6f222 100644
@@ -15,6 +15,7 @@
 
 #include <dt-bindings/reset/airoha,en7523-reset.h>
 #include <dt-bindings/reset/airoha,en7581-reset.h>
+#include <dt-bindings/reset/airoha,an7583-reset.h>
 
 #define RST_NR_PER_BANK			32
 
@@ -138,6 +139,60 @@ static const u16 en7581_rst_map[] = {
 	[EN7581_XPON_MAC_RST]		= RST_NR_PER_BANK + 31,
 };
 
+static const u16 an7583_rst_map[] = {
+	/* RST_CTRL2 */
+	[AN7583_XPON_PHY_RST]		= 0,
+	[AN7583_GPON_OLT_RST]		= 1,
+	[AN7583_CPU_TIMER2_RST]		= 2,
+	[AN7583_HSUART_RST]		= 3,
+	[AN7583_UART4_RST]		= 4,
+	[AN7583_UART5_RST]		= 5,
+	[AN7583_I2C2_RST]		= 6,
+	[AN7583_XSI_MAC_RST]		= 7,
+	[AN7583_XSI_PHY_RST]		= 8,
+	[AN7583_NPU_RST]		= 9,
+	[AN7583_TRNG_MSTART_RST]	= 12,
+	[AN7583_DUAL_HSI0_RST]		= 13,
+	[AN7583_DUAL_HSI1_RST]		= 14,
+	[AN7583_DUAL_HSI0_MAC_RST]	= 16,
+	[AN7583_DUAL_HSI1_MAC_RST]	= 17,
+	[AN7583_XPON_XFI_RST]		= 18,
+	[AN7583_WDMA_RST]		= 19,
+	[AN7583_WOE0_RST]		= 20,
+	[AN7583_HSDMA_RST]		= 22,
+	[AN7583_TDMA_RST]		= 24,
+	[AN7583_EMMC_RST]		= 25,
+	[AN7583_SOE_RST]		= 26,
+	[AN7583_XFP_MAC_RST]		= 28,
+	[AN7583_MDIO0]			= 30,
+	[AN7583_MDIO1]			= 31,
+	/* RST_CTRL1 */
+	[AN7583_PCM1_ZSI_ISI_RST]	= RST_NR_PER_BANK + 0,
+	[AN7583_FE_PDMA_RST]		= RST_NR_PER_BANK + 1,
+	[AN7583_FE_QDMA_RST]		= RST_NR_PER_BANK + 2,
+	[AN7583_PCM_SPIWP_RST]		= RST_NR_PER_BANK + 4,
+	[AN7583_CRYPTO_RST]		= RST_NR_PER_BANK + 6,
+	[AN7583_TIMER_RST]		= RST_NR_PER_BANK + 8,
+	[AN7583_PCM1_RST]		= RST_NR_PER_BANK + 11,
+	[AN7583_UART_RST]		= RST_NR_PER_BANK + 12,
+	[AN7583_GPIO_RST]		= RST_NR_PER_BANK + 13,
+	[AN7583_GDMA_RST]		= RST_NR_PER_BANK + 14,
+	[AN7583_I2C_MASTER_RST]		= RST_NR_PER_BANK + 16,
+	[AN7583_PCM2_ZSI_ISI_RST]	= RST_NR_PER_BANK + 17,
+	[AN7583_SFC_RST]		= RST_NR_PER_BANK + 18,
+	[AN7583_UART2_RST]		= RST_NR_PER_BANK + 19,
+	[AN7583_GDMP_RST]		= RST_NR_PER_BANK + 20,
+	[AN7583_FE_RST]			= RST_NR_PER_BANK + 21,
+	[AN7583_USB_HOST_P0_RST]	= RST_NR_PER_BANK + 22,
+	[AN7583_GSW_RST]		= RST_NR_PER_BANK + 23,
+	[AN7583_SFC2_PCM_RST]		= RST_NR_PER_BANK + 25,
+	[AN7583_PCIE0_RST]		= RST_NR_PER_BANK + 26,
+	[AN7583_PCIE1_RST]		= RST_NR_PER_BANK + 27,
+	[AN7583_CPU_TIMER_RST]		= RST_NR_PER_BANK + 28,
+	[AN7583_PCIE_HB_RST]		= RST_NR_PER_BANK + 29,
+	[AN7583_XPON_MAC_RST]		= RST_NR_PER_BANK + 31,
+};
+
 static int airoha_reset_update(struct airoha_reset_priv *priv,
 			       unsigned long id, bool assert)
 {
@@ -227,6 +282,11 @@ static int airoha_reset_probe(struct udevice *dev)
 		return reset_init(dev, en7581_rst_map,
 				  ARRAY_SIZE(en7581_rst_map));
 
+	if (ofnode_device_is_compatible(dev_ofnode(dev),
+					"airoha,an7583-scu"))
+		return reset_init(dev, an7583_rst_map,
+				 ARRAY_SIZE(an7583_rst_map));
+
 	return -ENODEV;
 }
 
Signature · 1 line
2.55.0
#7 lore raw

PATCH v3 7/16 net: airoha: add support for Airoha AN7583

In reply to Christian Marangi

Add support for Ethernet controller present in Airoha AN7583. This follow the same implementation of Airoha AN7581 with the only difference of having a different reset number and a different logic to reach the SCU node.

Generalize the driver for these 2 part to account for these minor difference.

The switch init part also required some care as the Switch Internal PHY enable BMCR_PDOWN by default and tweak to GEPHY_CONN_CFG is also needed.

---
 drivers/net/airoha_eth.c | 94 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)
drivers/net/airoha_eth.c +94 -0
index ac72df5b6608..f530521692fc 100644
@@ -24,6 +24,7 @@
 #include <linux/ethtool.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
+#include <linux/mii.h>
 #include <linux/time.h>
 #include <asm/arch/scu-regmap.h>
 
@@ -34,6 +35,11 @@
 #define AIROHA_MAX_NUM_RSTS		3
 #define AIROHA_MAX_NUM_XSI_RSTS		4
 
+#define AIROHA_MAX_NUM_SWITCH_PORT	4
+#define AIROHA_MAX_PBUS_TRY		10
+#define AIROHA_PBUS_SLEEP		100
+#define AIROHA_PBUS_C22_MASK		0x800000
+
 #define AIROHA_MAX_PACKET_SIZE		2048
 #define AIROHA_NUM_TX_RING		1
 #define AIROHA_NUM_RX_RING		1
@@ -86,6 +92,19 @@
 #define   SWITCH_PHY_PRE_EN		BIT(15)
 #define   SWITCH_PHY_END_ADDR		GENMASK(12, 8)
 #define   SWITCH_PHY_ST_ADDR		GENMASK(4, 0)
+#define SWITCH_GEPHY_CONN_CFG		0x7c14
+#define   SWITCH_DPHY_CKIN_SEL		BIT(31)
+#define   SWITCH_PHY_CORE_REG_CLK_SEL	BIT(30)
+#define   SWITCH_ETHER_AFE_PWD		GENMASK(28, 24)
+#define SWITCH_PBUS_PHY_IAC		0x7c20
+#define   SWITCH_PBUS_PHY_START		BIT(31)
+#define   SWITCH_PBUS_PHY_CMD		BIT(30)
+#define   SWITCH_PBUS_PHY_CMD_READ	FIELD_PREP(SWITCH_PBUS_PHY_CMD, 0x0)
+#define   SWITCH_PBUS_PHY_CMD_WRITE	FIELD_PREP(SWITCH_PBUS_PHY_CMD, 0x1)
+#define   SWITCH_PBUS_PHY_PORTADDR	GENMASK(28, 24)
+#define   SWITCH_PBUS_PHY_REGADDR	GENMASK(23, 0)
+#define SWITCH_PBUS_PHY_IAWD		0x7c24
+#define SWITCH_PBUS_PHY_IARD		0x7c28
 
 /* FE */
 #define PSE_BASE			0x0100
@@ -365,6 +384,12 @@ static const char * const en7581_xsi_rsts_names[] = {
 	"xfp-mac",
 };
 
+static const char * const an7583_xsi_rsts_names[] = {
+	"hsi0-mac",
+	"hsi1-mac",
+	"xfp-mac",
+};
+
 static u32 airoha_rr(void __iomem *base, u32 offset)
 {
 	return readl(base + offset);
@@ -405,8 +430,12 @@ static u32 airoha_rmw(void __iomem *base, u32 offset, u32 mask, u32 val)
 #define airoha_qdma_clear(qdma, offset, val)			\
 	airoha_rmw((qdma)->regs, (offset), (val), 0)
 
+#define airoha_switch_rr(eth, offset)				\
+	airoha_rr((eth)->switch_regs, (offset))
 #define airoha_switch_wr(eth, offset, val)			\
 	airoha_wr((eth)->switch_regs, (offset), (val))
+#define airoha_switch_rmw(eth, offset, mask, val)		\
+	airoha_rmw((eth)->switch_regs, (offset), (mask), (val))
 
 static inline dma_addr_t dma_map_unaligned(void *vaddr, size_t len,
 					   enum dma_data_direction dir)
@@ -438,6 +467,8 @@ static int airoha_get_fe_port(struct airoha_gdm_port *port)
 	case 0x7523:
 		/* FIXME: GDM1 is the only supported port */
 		return FE_PSE_PORT_GDM1;
+	case 0x7583:
+		return port->id == 3 ? FE_PSE_PORT_GDM3 : port->id;
 	case 0x7581:
 	default:
 		return port->id == 4 ? FE_PSE_PORT_GDM4 : port->id;
@@ -809,6 +840,59 @@ static int airoha_switch_init(struct udevice *dev, struct airoha_eth *eth)
 			 FIELD_PREP(SWITCH_PHY_END_ADDR, 0xc) |
 			 FIELD_PREP(SWITCH_PHY_ST_ADDR, 0x8));
 
+	/* AN7583 require tweak to GEPHY_CONN_CFG and clear PHY BMCR_PDOWN */
+	if (!strcmp(data->switch_compatible, "airoha,an7583-switch")) {
+		int i;
+
+		airoha_switch_rmw(eth, SWITCH_GEPHY_CONN_CFG,
+				  SWITCH_DPHY_CKIN_SEL |
+				  SWITCH_PHY_CORE_REG_CLK_SEL |
+				  SWITCH_ETHER_AFE_PWD,
+				  SWITCH_DPHY_CKIN_SEL |
+				  SWITCH_PHY_CORE_REG_CLK_SEL |
+				  FIELD_PREP(SWITCH_ETHER_AFE_PWD, 0));
+
+		/* Disable BMCR_PDOWN for every PHY */
+		for (i = 0; i < AIROHA_MAX_NUM_SWITCH_PORT; i++) {
+			int try;
+			u32 val;
+
+			airoha_switch_wr(eth, SWITCH_PBUS_PHY_IAC,
+					 SWITCH_PBUS_PHY_START |
+					 SWITCH_PBUS_PHY_CMD_READ |
+					 FIELD_PREP(SWITCH_PBUS_PHY_PORTADDR, i) |
+					 FIELD_PREP(SWITCH_PBUS_PHY_REGADDR,
+						    AIROHA_PBUS_C22_MASK | MII_BMCR));
+
+			for (try = 0; try < AIROHA_MAX_PBUS_TRY; try++) {
+				val = airoha_switch_rr(eth, SWITCH_PBUS_PHY_IAC);
+				if (!(val & SWITCH_PBUS_PHY_START))
+					break;
+
+				udelay(AIROHA_PBUS_SLEEP);
+			}
+
+			val = airoha_switch_rr(eth, SWITCH_PBUS_PHY_IARD);
+			val &= ~BMCR_PDOWN;
+
+			airoha_switch_wr(eth, SWITCH_PBUS_PHY_IAWD, val);
+			airoha_switch_wr(eth, SWITCH_PBUS_PHY_IAC,
+					 SWITCH_PBUS_PHY_START |
+					 SWITCH_PBUS_PHY_CMD_WRITE |
+					 FIELD_PREP(SWITCH_PBUS_PHY_PORTADDR, i) |
+					 FIELD_PREP(SWITCH_PBUS_PHY_REGADDR,
+						    AIROHA_PBUS_C22_MASK | MII_BMCR));
+
+			for (try = 0; try < AIROHA_MAX_PBUS_TRY; try++) {
+				val = airoha_switch_rr(eth, SWITCH_PBUS_PHY_IAC);
+				if (!(val & SWITCH_PBUS_PHY_START))
+					break;
+
+				udelay(AIROHA_PBUS_SLEEP);
+			}
+		}
+	}
+
 	return 0;
 }
 
@@ -1269,6 +1353,13 @@ static const struct airoha_eth_soc_data en7581_data = {
 	.switch_compatible = "airoha,en7581-switch",
 };
 
+static const struct airoha_eth_soc_data an7583_data = {
+	.version = 0x7583,
+	.xsi_rsts_names = an7583_xsi_rsts_names,
+	.num_xsi_rsts = ARRAY_SIZE(an7583_xsi_rsts_names),
+	.switch_compatible = "airoha,an7583-switch",
+};
+
 static const struct udevice_id airoha_eth_ids[] = {
 	{ .compatible = "airoha,en7523-eth",
 	  .data = (ulong)&en7523_data,
@@ -1276,6 +1367,9 @@ static const struct udevice_id airoha_eth_ids[] = {
 	{ .compatible = "airoha,en7581-eth",
 	  .data = (ulong)&en7581_data,
 	},
+	{ .compatible = "airoha,an7583-eth",
+	  .data = (ulong)&an7583_data,
+	},
 	{ }
 };
 
Signature · 1 line
2.55.0
#8 lore raw

PATCH v3 8/16 ARM: dts: an7583: add Ethernet node

In reply to Christian Marangi

Add Ethernet node in AN7583 dtsi to add support for the integrated Ethernet Controller.

---
 arch/arm/dts/an7583.dtsi | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
arch/arm/dts/an7583.dtsi +23 -0
index dd7bf49dbbc3..629f0e64de6d 100644
@@ -131,6 +131,29 @@
 			reg = <0x0 0x1fa20000 0x0 0x388>;
 		};
 
+		eth: ethernet@1fb50000 {
+			compatible = "airoha,an7583-eth";
+			reg = <0 0x1fb50000 0 0x2600>,
+				<0 0x1fb54000 0 0x2000>,
+				<0 0x1fb56000 0 0x2000>;
+			reg-names = "fe", "qdma0", "qdma1";
+
+			resets = <&scuclk AN7583_FE_RST>,
+				 <&scuclk AN7583_FE_PDMA_RST>,
+				 <&scuclk AN7583_FE_QDMA_RST>,
+				 <&scuclk AN7583_DUAL_HSI0_MAC_RST>,
+				 <&scuclk AN7583_DUAL_HSI1_MAC_RST>,
+				 <&scuclk AN7583_XFP_MAC_RST>;
+			reset-names = "fe", "pdma", "qdma",
+				      "hsi0-mac", "hsi1-mac",
+				      "xfp-mac";
+		};
+
+		switch: switch@1fb58000 {
+			compatible = "airoha,an7583-switch";
+			reg = <0 0x1fb58000 0 0x8000>;
+		};
+
 		syscon@1fbe3400 {
 			compatible = "airoha,en7581-pbus-csr", "syscon";
 			reg = <0x0 0x1fbe3400 0x0 0xff>;
Signature · 1 line
2.55.0
#9 lore raw

PATCH v3 9/16 ARM: dts: an7583: add MMC node

In reply to Christian Marangi

Add MMC node for Airoha AN7583. These follow the same node of Airoha AN7581.

Similar to Airoha AN7581, add the fixed regulator and fixed clock for MMC.

---
 arch/arm/dts/an7583.dtsi | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
arch/arm/dts/an7583.dtsi +33 -0
index 629f0e64de6d..4f7b41665b1c 100644
@@ -106,6 +106,21 @@
 			     <GIC_PPI 10 IRQ_TYPE_LEVEL_LOW>;
 	};
 
+	clk25m: oscillator {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <25000000>;
+		clock-output-names = "clkxtal";
+	};
+
+	vmmc_3v3: regulator-vmmc-3v3 {
+		compatible = "regulator-fixed";
+		regulator-name = "vmmc";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-always-on;
+	};
+
 	soc {
 		compatible = "simple-bus";
 		#address-cells = <2>;
@@ -262,6 +277,24 @@
 			};
 		};
 
+		mmc0: mmc@1fa0e000 {
+			compatible = "mediatek,mt7622-mmc";
+			reg = <0x0 0x1fa0e000 0x0 0x1000>,
+				<0x0 0x1fa0c000 0x0 0x60>;
+			interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&scuclk EN7581_CLK_EMMC>, <&clk25m>;
+			clock-names = "source", "hclk";
+			bus-width = <4>;
+			max-frequency = <52000000>;
+			vmmc-supply = <&vmmc_3v3>;
+			disable-wp;
+			cap-mmc-highspeed;
+			non-removable;
+
+			assigned-clocks = <&scuclk EN7581_CLK_EMMC>;
+			assigned-clock-rates = <200000000>;
+		};
+
 		uart1: serial@1fbf0000 {
 			compatible = "ns16550";
 			reg = <0x0 0x1fbf0000 0x0 0x30>;
Signature · 1 line
2.55.0
#10 lore raw

PATCH v3 10/16 configs: an7583: add mii/mdio support

In reply to Christian Marangi

From: Mikhail Kshevetskiy <[email protected]>

Enable mdio/mii command support for Airoha AN7583 default config.

[ improve commit description ]
---
 configs/an7583_evb_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/an7583_evb_defconfig +2 -0
index 16466be51b27..7178f45e3f83 100644
@@ -32,6 +32,7 @@ CONFIG_CMD_MTD=y
 CONFIG_CMD_SF_TEST=y
 CONFIG_CMD_SPI=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_MII=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_EXT4=y
 CONFIG_CMD_FAT=y
@@ -63,6 +64,7 @@ CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_FLASH_MTD=y
+CONFIG_DM_MDIO=y
 CONFIG_AIROHA_ETH=y
 CONFIG_PHY=y
 CONFIG_PINCTRL=y
Signature · 1 line
2.55.0
#11 lore raw

PATCH v3 11/16 ARM: dts: an7583: add mdio child node to switch node

In reply to Christian Marangi

From: Mikhail Kshevetskiy <[email protected]>

Add mdio node to be able see integrated switch port states with mdio tools.

[ improve commit title and description ]
---
 arch/arm/dts/an7583.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/dts/an7583.dtsi +5 -0
index 4f7b41665b1c..f0ba3da21c07 100644
@@ -167,6 +167,11 @@
 		switch: switch@1fb58000 {
 			compatible = "airoha,an7583-switch";
 			reg = <0 0x1fb58000 0 0x8000>;
+
+			mdio: mdio {
+				#address-cells = <1>;
+				#size-cells = <0>;
+			};
 		};
 
 		syscon@1fbe3400 {
Signature · 1 line
2.55.0
#12 lore raw

PATCH v3 12/16 net: airoha: add support for Airoha AN7583 PCS driver

In reply to Christian Marangi

Add support for the PCS interface on Airoha AN7583 SoC. This is based on the AN7581 SoC with difference in the calibration and Analog PHY handling.

---
 drivers/net/airoha/Kconfig             |    8 +
 drivers/net/airoha/Makefile            |    1 +
 drivers/net/airoha/pcs-airoha-common.c |   27 +
 drivers/net/airoha/pcs-airoha.h        |   17 +
 drivers/net/airoha/pcs-an7583.c        | 2202 ++++++++++++++++++++++++
 5 files changed, 2255 insertions(+)
 create mode 100644 drivers/net/airoha/pcs-an7583.c
drivers/net/airoha/Kconfig +8 -0
index d0c007ced80e..5f660bb280f8 100644
@@ -11,3 +11,11 @@ config PCS_AIROHA_AN7581
 	help
 	  This module provides helper to phylink for managing the Airoha
 	  AN7581 PCS for SoC Ethernet and PON SERDES.
+
+config PCS_AIROHA_AN7583
+	bool "Airoha AN7583 PCS driver"
+	depends on ARCH_AIROHA
+	select PCS_AIROHA
+	help
+	  This module provides helper to phylink for managing the Airoha
+	  AN7583 PCS for SoC Ethernet and PON SERDES.
drivers/net/airoha/Makefile +1 -0
index 81fd26cf8131..a3b84518129c 100644
@@ -2,3 +2,4 @@
 
 obj-$(CONFIG_PCS_AIROHA)	+= pcs-airoha-common.o
 obj-$(CONFIG_PCS_AIROHA_AN7581)	+= pcs-an7581.o
+obj-$(CONFIG_PCS_AIROHA_AN7583)	+= pcs-an7583.o
drivers/net/airoha/pcs-airoha-common.c +27 -0
index 1263092fcdd4..bc64263fad91 100644
@@ -17,6 +17,7 @@
 static void airoha_pcs_setup_scu_eth(struct airoha_pcs_priv *priv,
 				     phy_interface_t interface)
 {
+	struct udevice *dev = priv->dev;
 	u32 xsi_sel;
 
 	switch (interface) {
@@ -34,6 +35,12 @@ static void airoha_pcs_setup_scu_eth(struct airoha_pcs_priv *priv,
 	regmap_update_bits(priv->scu, AIROHA_SCU_SSR3,
 			   AIROHA_SCU_ETH_XSI_SEL,
 			   xsi_sel);
+
+	/* AN7583 require additional setting */
+	if (device_is_compatible(dev, "airoha,an7583-pcs-eth"))
+		regmap_update_bits(priv->scu, AIROHA_SCU_WAN_CONF,
+				   AIROHA_SCU_ETH_MAC_SEL,
+				   AIROHA_SCU_ETH_MAC_SEL_XFI);
 }
 
 static void airoha_pcs_setup_scu_pon(struct airoha_pcs_priv *priv,
@@ -810,11 +817,31 @@ static const struct airoha_pcs_match_data an7581_pcs_pon = {
 	.link_up = an7581_pcs_phya_link_up,
 };
 
+static const struct airoha_pcs_match_data an7583_pcs_eth = {
+	.port_type = AIROHA_PCS_ETH,
+	.usxgmii_rx_gb_out_vld_tweak = true,
+	.usxgmii_xfi_mode_sel = true,
+	.bringup = an7583_pcs_common_phya_bringup,
+	.link_up = an7583_pcs_common_phya_link_up,
+};
+
+static const struct airoha_pcs_match_data an7583_pcs_pon = {
+	.port_type = AIROHA_PCS_PON,
+	.usxgmii_rx_gb_out_vld_tweak = true,
+	.usxgmii_xfi_mode_sel = true,
+	.bringup = an7583_pcs_common_phya_bringup,
+	.link_up = an7583_pcs_common_phya_link_up,
+};
+
 static const struct udevice_id airoha_pcs_of_table[] = {
 	{ .compatible = "airoha,an7581-pcs-eth",
 	  .data = (ulong)&an7581_pcs_eth },
 	{ .compatible = "airoha,an7581-pcs-pon",
 	  .data = (ulong)&an7581_pcs_pon },
+	{ .compatible = "airoha,an7583-pcs-eth",
+	  .data = (ulong)&an7583_pcs_eth },
+	{ .compatible = "airoha,an7583-pcs-pon",
+	  .data = (ulong)&an7583_pcs_pon },
 	{ },
 };
 
drivers/net/airoha/pcs-airoha.h +17 -0
index 714d2ebe520b..fddeda5ca36c 100644
@@ -1218,3 +1218,20 @@ static inline void an7581_pcs_phya_link_up(struct airoha_pcs_priv *priv)
 {
 }
 #endif
+
+#ifdef CONFIG_PCS_AIROHA_AN7583
+int an7583_pcs_common_phya_bringup(struct airoha_pcs_priv *priv,
+				   phy_interface_t interface);
+
+void an7583_pcs_common_phya_link_up(struct airoha_pcs_priv *priv);
+#else
+static inline int an7583_pcs_common_phya_bringup(struct airoha_pcs_priv *priv,
+						 phy_interface_t interface)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline void an7583_pcs_common_phya_link_up(struct airoha_pcs_priv *priv)
+{
+}
+#endif
drivers/net/airoha/pcs-an7583.c new file +2202 -0

2,202 lines not on this page · raw message

Signature · 1 line
2.55.0
#13 lore raw

PATCH v3 13/16 ARM: dts: an7583: add PCS nodes

In reply to Christian Marangi

Add PCS node for Airoha AN7583 SoC to enable support for Serdes Ethernet and PON port.

---
 arch/arm/dts/an7583-evb.dts | 18 +++++++++
 arch/arm/dts/an7583.dtsi    | 75 +++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+)
arch/arm/dts/an7583-evb.dts +18 -0
index d02cd194e8a3..714c90eadfee 100644
@@ -65,3 +65,21 @@
 &snfi {
 	status = "okay";
 };
+
+&gdm1 {
+	status = "okay";
+};
+
+&gdm2 {
+	status = "okay";
+
+	managed = "in-band-status";
+	phy-mode = "usxgmii";
+};
+
+&gdm3 {
+	status = "okay";
+
+	managed = "in-band-status";
+	phy-mode = "2500base-x";
+};
arch/arm/dts/an7583.dtsi +75 -0

87 lines not on this page · raw message

Signature · 1 line
2.55.0
#14 lore raw

PATCH v3 14/16 configs: an7583: enable PCS for Airoha AN7583

In reply to Christian Marangi

Enable PCS config for Airoha AN7583 SoC by default to enable support fo External PHY.

---
 configs/an7583_evb_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/an7583_evb_defconfig +1 -0
index 7178f45e3f83..8b076c1cfe5c 100644
@@ -65,6 +65,7 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_FLASH_MTD=y
 CONFIG_DM_MDIO=y
+CONFIG_PCS_AIROHA_AN7583=y
 CONFIG_AIROHA_ETH=y
 CONFIG_PHY=y
 CONFIG_PINCTRL=y
Signature · 1 line
2.55.0
#15 lore raw

PATCH v3 15/16 net: Add support for Airoha AN7583 MDIO Controller

In reply to Christian Marangi

The Airoha AN7583 SoC have 2 dedicated MDIO controller in the SCU register map. Add a dedicated driver for it ported from linux kernel.

---
 drivers/net/Kconfig       |   7 ++
 drivers/net/Makefile      |   1 +
 drivers/net/mdio-airoha.c | 221 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 229 insertions(+)
 create mode 100644 drivers/net/mdio-airoha.c
drivers/net/Kconfig +7 -0
index c057504cf66b..a93268736a4f 100644
@@ -118,6 +118,13 @@ config AG7XXX
 	  This driver supports the Atheros AG7xxx Ethernet MAC. This MAC is
 	  present in the Atheros AR7xxx, AR9xxx and QCA9xxx MIPS chips.
 
+config MDIO_AIROHA
+	bool "Airoha AN7583 MDIO interface support"
+	depends on DM_MDIO
+	help
+	  This driver supports the MDIO interface found in Airoha
+	  AN7583 SoC.
+
 source "drivers/net/airoha/Kconfig"
 
 config AIROHA_ETH
drivers/net/Makefile +1 -0
index 96ec6fb187a8..5f712ca241e2 100644
@@ -63,6 +63,7 @@ obj-$(CONFIG_KSZ9477) += ksz9477.o
 obj-$(CONFIG_LITEETH) += liteeth.o
 obj-$(CONFIG_MACB) += macb.o
 obj-$(CONFIG_MCFFEC) += mcffec.o mcfmii.o
+obj-$(CONFIG_MDIO_AIROHA) += mdio-airoha.o
 obj-$(CONFIG_MDIO_GPIO_BITBANG) += mdio_gpio.o
 obj-$(CONFIG_MDIO_IPQ4019) += mdio-ipq4019.o
 obj-$(CONFIG_MDIO_MSCC_MIIM) += mdio-mscc-miim.o
drivers/net/mdio-airoha.c new file +221 -0

221 lines not on this page · raw message

Signature · 1 line
2.55.0
#16 lore raw

PATCH v3 16/16 configs: an7583: enable MDIO_AIROHA by default

In reply to Christian Marangi

Enable MDIO_AIROHA in the default config for Airoha AN7583.

---
 configs/an7583_evb_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/an7583_evb_defconfig +1 -0
index 8b076c1cfe5c..08bcbd52c99a 100644
@@ -65,6 +65,7 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_WINBOND=y
 CONFIG_SPI_FLASH_MTD=y
 CONFIG_DM_MDIO=y
+CONFIG_MDIO_AIROHA=y
 CONFIG_PCS_AIROHA_AN7583=y
 CONFIG_AIROHA_ETH=y
 CONFIG_PHY=y
Signature · 1 line
2.55.0
#17 lore raw
In reply to Christian Marangi

Il giorno gio 22 ott 2026 alle ore 21:02 Christian Marangi <[email protected]> ha scritto:

Quoted 82 lines

This patch series adds AN7583 SoC support. It is based on u-boot patches of Christian Marangi airoha openwrt branch

https://github.com/Ansuel/openwrt/commits/main-airoha-6.12/

AN7583 is not included to upstream linux, but actively supported by upstream openwrt. The patches were adapted for latest U-Boot.

Since I'm not seeing progress, I'm again taking over the series [1] from Mikhail.

[1] https://lore.kernel.org/all/[email protected]/

Changes v3:
- Rebase on top of next
- Fix MAINTAINERS spacing
- Improve commit title and description
- Don't pollute dts/upstream for clk but use dedicated header
- Update 7583.dtsi for new scuclk node (reflect new upstream proposal)
- Fix some minor checkpatch warning on reset header
- Reorganize patch for better bisectability

Changes v2: (from Mikhail)
- fixed arch/arm/mach-airoha/an7583/init.c compilation issue
- added an7583 specific helper needed for clk-airoha
- patches for proper support of clk, reset, network

Christian Marangi (13):
dt-bindings: clock: airoha: Document support for AN7583 clock
dt-bindings: reset: airoha: Document support for AN7583 reset
airoha: add support for Airoha AN7583 SoC
clk: airoha: add support for Airoha AN7583 SoC clock
reset: airoha: Add support for Airoha AN7583 reset
net: airoha: add support for Airoha AN7583
ARM: dts: an7583: add Ethernet node
ARM: dts: an7583: add MMC node
net: airoha: add support for Airoha AN7583 PCS driver
ARM: dts: an7583: add PCS nodes
configs: an7583: enable PCS for Airoha AN7583
net: Add support for Airoha AN7583 MDIO Controller
configs: an7583: enable MDIO_AIROHA by default

Mikhail Kshevetskiy (3):
arm: airoha: introduce AN7583 helpers to get SCU and CHIP_SCU regmaps
configs: an7583: add mii/mdio support
ARM: dts: an7583: add mdio child node to switch node

 arch/arm/dts/an7583-evb.dts                   |   85 +
 arch/arm/dts/an7583.dtsi                      |  526 ++++
 arch/arm/include/asm/arch-an7583              |    1 +
 arch/arm/mach-airoha/Kconfig                  |   14 +
 arch/arm/mach-airoha/Makefile                 |    1 +
 arch/arm/mach-airoha/an7583/Makefile          |    4 +
 arch/arm/mach-airoha/an7583/init.c            |   66 +
 arch/arm/mach-airoha/an7583/scu-regmap.c      |   30 +
 board/airoha/an7583/MAINTAINERS               |    5 +
 board/airoha/an7583/Makefile                  |    3 +
 board/airoha/an7583/an7583_rfb.c              |   16 +
 configs/an7583_evb_defconfig                  |   83 +
 drivers/clk/airoha/clk-airoha.c               |  159 ++
 drivers/net/Kconfig                           |    7 +
 drivers/net/Makefile                          |    1 +
 drivers/net/airoha/Kconfig                    |    8 +
 drivers/net/airoha/Makefile                   |    1 +
 drivers/net/airoha/pcs-airoha-common.c        |   27 +
 drivers/net/airoha/pcs-airoha.h               |   17 +
 drivers/net/airoha/pcs-an7583.c               | 2202 +++++++++++++++++
 drivers/net/airoha_eth.c                      |   94 +
 drivers/net/mdio-airoha.c                     |  221 ++
 drivers/reset/reset-airoha.c                  |   60 +
 include/configs/an7583.h                      |   19 +
 include/dt-bindings/clock/an7583-clk.h        |    9 +
 .../dt-bindings/reset/airoha,an7583-reset.h   |   62 +
 26 files changed, 3721 insertions(+)
 create mode 100644 arch/arm/dts/an7583-evb.dts
 create mode 100644 arch/arm/dts/an7583.dtsi
 create mode 120000 arch/arm/include/asm/arch-an7583
 create mode 100644 arch/arm/mach-airoha/an7583/Makefile
 create mode 100644 arch/arm/mach-airoha/an7583/init.c
 create mode 100644 arch/arm/mach-airoha/an7583/scu-regmap.c
 create mode 100644 board/airoha/an7583/MAINTAINERS
Quoted 9 lines
 create mode 100644 board/airoha/an7583/Makefile
 create mode 100644 board/airoha/an7583/an7583_rfb.c
 create mode 100644 configs/an7583_evb_defconfig
 create mode 100644 drivers/net/airoha/pcs-an7583.c
 create mode 100644 drivers/net/mdio-airoha.c
 create mode 100644 include/configs/an7583.h
 create mode 100644 include/dt-bindings/clock/an7583-clk.h
 create mode 100644 include/dt-bindings/reset/airoha,an7583-reset.h

For Tom. Clarification on the status of dtsi and some dt-binding header. I'm fighting upstream for the missing piece but it seems no maintainer are picking clk changes. The DT patch already have review and ack tag so they got approved. I would really like to clean all the pending patch from OpenWrt for this target. The idea here is that we have these temp header and they get dropped as soon as everything is up with the target migrated to OF_UPSTREAM. I hope you understand the situation with the A(I)pocalyps.

(forgot to include this in the cover letter)

#18 lore raw
In reply to Christian Marangi
Quoted 9 lines · Christian Marangi

This patch series adds AN7583 SoC support. It is based on u-boot patches of Christian Marangi airoha openwrt branch

https://github.com/Ansuel/openwrt/commits/main-airoha-6.12/

AN7583 is not included to upstream linux, but actively supported by upstream openwrt. The patches were adapted for latest U-Boot.

[...]

Applied to u-boot/main, thanks!

[01/16] dt-bindings: clock: airoha: Document support for AN7583 clock

        commit: a074405c48d8cda0b0ceed10c7e51ba511dcba36
[02/16] dt-bindings: reset: airoha: Document support for AN7583 reset
        commit: 3d2f384cbdbb89519d71d8072185ec13eb7086ea
[03/16] airoha: add support for Airoha AN7583 SoC
        commit: 67f0bfe5ce35b1c712ba8800fa4130b07f903fd6
[04/16] arm: airoha: introduce AN7583 helpers to get SCU and CHIP_SCU regmaps
        commit: 28dbc043651eb2e426f010a706eb69120f456dcb
[05/16] clk: airoha: add support for Airoha AN7583 SoC clock
        commit: c91d9d30a6f25847fb8e75a31081ea1c83b4f43c
[06/16] reset: airoha: Add support for Airoha AN7583 reset
        commit: 351414dfeb8b8b23150b2cc605c97d4c30ed320c
[07/16] net: airoha: add support for Airoha AN7583
        commit: e9d7edcd068ae33bbd7f29bb3a01c1dee44f1234
[08/16] ARM: dts: an7583: add Ethernet node
        commit: d3d644d4bc7d0e90c4b0d82de8572e12a627d462
[09/16] ARM: dts: an7583: add MMC node
        commit: a0467e7700f0eb89f2b7cd6181e8b01298dea560
[10/16] configs: an7583: add mii/mdio support
        commit: c6a541aab0bd0882b1194189f02448e3de0b0278
[11/16] ARM: dts: an7583: add mdio child node to switch node
        commit: 662e7018c5ccae2a3023fa29f9fcb151cc3b27e3
[12/16] net: airoha: add support for Airoha AN7583 PCS driver
        commit: f35d551d7c90c4883584820bc68a0b44efb8ce20
[13/16] ARM: dts: an7583: add PCS nodes
        commit: 62dfad4272919b72b6c99e50ac7b755a63d95b1c
[14/16] configs: an7583: enable PCS for Airoha AN7583
        commit: 1e3dabfc93766895c89e30aafa1383014fe12548
[15/16] net: Add support for Airoha AN7583 MDIO Controller
        commit: 69d5621eb75fffd705a806a6bcc0cbdd5d02eca4
[16/16] configs: an7583: enable MDIO_AIROHA by default
        commit: 8a37399973625005675b0f6b26a0b69a86ce1dc3
Signature · 1 line
Tom