Skip to contentSkip to conversation

mips: add EcoNet/Airoha EN75xx (EN7512/EN7528) SoC support

PATCH Superseded AK Sharma 4 participants 26 messages Aug 25 – Aug 26 1 message not in the archive

Subsystems (7)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

AK Sharma

author
#1 lore raw

cover mips: add EcoNet/Airoha EN75xx (EN7512/EN7528) SoC support

This series adds U-Boot support for the EcoNet/Airoha EN75xx MIPS SoC
family: the big-endian MIPS34Kc EN7512/EN7521 and the little-endian MIPS1004Kc EN7528, used in many GPON/XPON ONT home gateways. It extends the existing Airoha SNFI SPI-NAND and GDM Ethernet drivers.

It brings up the SoC (TPL/SPL, cache/CM init), and adds the UART, the EN75 BMT SPI-NAND bad-block mapping, weak bootm decompression hooks for the coherent CM, and Ethernet. Reference boards for the EN7512 and EN7528 are included, plus the EN7528 R3-hook boot variant.

The DDR calibration stage is a vendor artifact and is not shipped in-tree. The reference board packages it as a binman "blob-ext"; build those configs with BINMAN_ALLOW_MISSING=1 and supply the blob to run (see arch/mips/mach-en75xx/README.ddr-blob). A native DDR-init implementation is a known TODO.

Tested on a Nokia G-2425G-A (EN7528, MT29F2G01 SPI-NAND): boots to the prompt with correct 256 MiB DRAM, working Ethernet/TFTP and SPI-NAND.

AK Sharma (12):
mips: en75xx: add EcoNet/Airoha EN75xx SoC support
mips: en75xx: add TPL and SPL early boot stages
serial: en75xx: add EcoNet/Airoha EN75xx UART driver
spi: airoha-snfi: add EN7528 SPI-NAND controller support
mtd: spi-nand: add EN75 BMT bad-block management support
net: airoha-eth: add EN7528 Ethernet support
mtd: env, cmd: add EN75 NAND remap handling
boot: image: add weak hooks for the decompression buffer and flush
mips: dts: add EcoNet EN75xx device trees
board: econet: add EN7512 reference board
board: econet: add EN7528 board support
doc: board: econet: add EN75xx documentation

 arch/mips/Kconfig                             |  21 +
 arch/mips/Makefile                            |   2 +
 arch/mips/cpu/start.S                         |   2 +
 arch/mips/dts/Makefile                        |   2 +
 .../dts/econet,en7512-reference-u-boot.dtsi   |  58 ++
 arch/mips/dts/econet,en7512-reference.dts     |  27 +
 arch/mips/dts/econet,en7512.dtsi              |  88 ++
 arch/mips/dts/econet,en7528-ram-u-boot.dtsi   |   6 +
 arch/mips/dts/econet,en7528-ram.dts           |  72 ++
 .../dts/econet,en7528-reference-u-boot.dtsi   |  62 ++
 arch/mips/dts/econet,en7528-reference.dts     |  25 +
 arch/mips/dts/econet,en7528.dtsi              | 164 ++++
 arch/mips/mach-en75xx/Kconfig                 | 118 +++
 arch/mips/mach-en75xx/Makefile                |  17 +
 arch/mips/mach-en75xx/README.ddr-blob         |  21 +
 arch/mips/mach-en75xx/cache.c                 | 121 +++
 arch/mips/mach-en75xx/cpu.c                   |  95 ++
 arch/mips/mach-en75xx/early_sfc.c             | 352 ++++++++
 arch/mips/mach-en75xx/include/mach/en75xx.h   | 104 +++
 arch/mips/mach-en75xx/spl/Makefile            |   2 +
 arch/mips/mach-en75xx/spl/spl.c               |  47 +
 arch/mips/mach-en75xx/tpl/Makefile            |   3 +
 arch/mips/mach-en75xx/tpl/start.S             | 101 +++
 arch/mips/mach-en75xx/tpl/tpl.c               | 158 ++++
 board/econet/en7512/MAINTAINERS               |   8 +
 board/econet/en7512/Makefile                  |   2 +
 board/econet/en7512/board.c                   |  34 +
 board/econet/en7528/MAINTAINERS               |  13 +
 board/econet/en7528/Makefile                  |   2 +
 board/econet/en7528/board.c                   | 110 +++
 board/econet/en7528/mk_tclinux_uboot.py       | 112 +++
 board/econet/en7528/tclinux_stub.S            |  65 ++
 boot/image.c                                  |  34 +-
 cmd/mtd.c                                     |  30 +-
 configs/en7512_reference_defconfig            |  93 ++
 configs/en7528_jcow414_r3hook_defconfig       |  76 ++
 configs/en7528_ram_defconfig                  |  62 ++
 configs/en7528_reference_defconfig            |  40 +
 defenvs/en7528_jcow414_r3hook_env             |   5 +
 doc/board/econet/en7512.rst                   |  70 ++
 doc/board/econet/en7528.rst                   |  39 +
 doc/board/econet/index.rst                    |  10 +
 doc/board/index.rst                           |   1 +
 drivers/mtd/nand/spi/Kconfig                  |   8 +
 drivers/mtd/nand/spi/Makefile                 |   1 +
 drivers/mtd/nand/spi/core.c                   |   9 +-
 drivers/mtd/nand/spi/en75_bmt.c               | 665 ++++++++++++++
 drivers/mtd/nand/spi/en75_bmt.h               |  24 +
 drivers/net/Kconfig                           |   8 +-
 drivers/net/airoha_eth.c                      | 850 +++++++++++++++++-
 drivers/phy/Kconfig                           |   2 +-
 drivers/serial/Kconfig                        |   7 +
 drivers/serial/Makefile                       |   1 +
 drivers/serial/serial_en75xx.c                | 170 ++++
 drivers/spi/Kconfig                           |   3 +-
 drivers/spi/airoha_snfi_spi.c                 | 409 +++++++--
 drivers/usb/host/Kconfig                      |   2 +-
 env/Kconfig                                   |   2 +-
 env/mtd.c                                     |  98 +-
 include/configs/en7512.h                      |   8 +
 include/configs/en7528.h                      |   9 +
 include/image.h                               |   5 +
 62 files changed, 4578 insertions(+), 177 deletions(-)
 create mode 100644 arch/mips/dts/econet,en7512-reference-u-boot.dtsi
 create mode 100644 arch/mips/dts/econet,en7512-reference.dts
 create mode 100644 arch/mips/dts/econet,en7512.dtsi
 create mode 100644 arch/mips/dts/econet,en7528-ram-u-boot.dtsi
 create mode 100644 arch/mips/dts/econet,en7528-ram.dts
 create mode 100644 arch/mips/dts/econet,en7528-reference-u-boot.dtsi
 create mode 100644 arch/mips/dts/econet,en7528-reference.dts
 create mode 100644 arch/mips/dts/econet,en7528.dtsi
 create mode 100644 arch/mips/mach-en75xx/Kconfig
 create mode 100644 arch/mips/mach-en75xx/Makefile
 create mode 100644 arch/mips/mach-en75xx/README.ddr-blob
 create mode 100644 arch/mips/mach-en75xx/cache.c
 create mode 100644 arch/mips/mach-en75xx/cpu.c
 create mode 100644 arch/mips/mach-en75xx/early_sfc.c
 create mode 100644 arch/mips/mach-en75xx/include/mach/en75xx.h
 create mode 100644 arch/mips/mach-en75xx/spl/Makefile
 create mode 100644 arch/mips/mach-en75xx/spl/spl.c
 create mode 100644 arch/mips/mach-en75xx/tpl/Makefile
 create mode 100644 arch/mips/mach-en75xx/tpl/start.S
 create mode 100644 arch/mips/mach-en75xx/tpl/tpl.c
 create mode 100644 board/econet/en7512/MAINTAINERS
 create mode 100644 board/econet/en7512/Makefile
 create mode 100644 board/econet/en7512/board.c
 create mode 100644 board/econet/en7528/MAINTAINERS
 create mode 100644 board/econet/en7528/Makefile
 create mode 100644 board/econet/en7528/board.c
 create mode 100644 board/econet/en7528/mk_tclinux_uboot.py
 create mode 100644 board/econet/en7528/tclinux_stub.S
 create mode 100644 configs/en7512_reference_defconfig
 create mode 100644 configs/en7528_jcow414_r3hook_defconfig
 create mode 100644 configs/en7528_ram_defconfig
 create mode 100644 configs/en7528_reference_defconfig
 create mode 100644 defenvs/en7528_jcow414_r3hook_env
 create mode 100644 doc/board/econet/en7512.rst
 create mode 100644 doc/board/econet/en7528.rst
 create mode 100644 doc/board/econet/index.rst
 create mode 100644 drivers/mtd/nand/spi/en75_bmt.c
 create mode 100644 drivers/mtd/nand/spi/en75_bmt.h
 create mode 100644 drivers/serial/serial_en75xx.c
 create mode 100644 include/configs/en7512.h
 create mode 100644 include/configs/en7528.h
Signature · 1 line
2.53.0
author
#2 lore raw

PATCH 1/12 mips: en75xx: add EcoNet/Airoha EN75xx SoC support

Add the core support for the EcoNet/Airoha EN75xx MIPS SoC family: the big-endian MIPS34Kc EN7512/EN7521 and the little-endian MIPS1004Kc EN7528. This adds the ARCH_EN75XX Kconfig entry, the mach-en75xx CPU and cache init, and the SoC register definitions.

dram_init() takes the DRAM size published by the DDR stage in REG_SAVE_INFO and falls back to probing with get_ram_size() when that field reads back an implausibly small value (some bootbases leave it unset), sizing through the uncached KSEG1 alias and capping the scan at 256 MiB to stay clear of the SoC register island.

---
 arch/mips/Kconfig                           |  21 ++++
 arch/mips/Makefile                          |   2 +
 arch/mips/cpu/start.S                       |   2 +
 arch/mips/mach-en75xx/Kconfig               | 118 +++++++++++++++++++
 arch/mips/mach-en75xx/Makefile              |  17 +++
 arch/mips/mach-en75xx/cache.c               | 121 ++++++++++++++++++++
 arch/mips/mach-en75xx/cpu.c                 |  95 +++++++++++++++
 arch/mips/mach-en75xx/include/mach/en75xx.h | 104 +++++++++++++++++
 8 files changed, 480 insertions(+)
 create mode 100644 arch/mips/mach-en75xx/Kconfig
 create mode 100644 arch/mips/mach-en75xx/Makefile
 create mode 100644 arch/mips/mach-en75xx/cache.c
 create mode 100644 arch/mips/mach-en75xx/cpu.c
 create mode 100644 arch/mips/mach-en75xx/include/mach/en75xx.h
arch/mips/Kconfig +21 -0
index 36612756..c0c98f37 100644
@@ -88,6 +88,26 @@ config ARCH_MTMIPS
 	select SUPPORT_LITTLE_ENDIAN
 	select SUPPORT_SPL
 
+config ARCH_EN75XX
+	bool "Support EcoNet/Airoha EN75xx MIPS platforms"
+	select HAS_FIXED_TIMER_FREQUENCY
+	select DM
+	select DM_SERIAL
+	select EN75XX_SERIAL
+	select OF_CONTROL
+	select ROM_EXCEPTION_VECTORS
+	select SUPPORT_BIG_ENDIAN
+	select SUPPORT_LITTLE_ENDIAN
+	select SUPPORTS_CPU_MIPS32_R2
+	select SUPPORT_SPL
+	select SPL_SKIP_LOWLEVEL_INIT if SPL
+	select SUPPORT_TPL
+	select SYS_CACHE_SHIFT_5
+	select MIPS_TUNE_34KC
+	help
+	  Support the EcoNet/Airoha EN75xx MIPS SoCs: the big-endian MIPS34Kc
+	  EN7512/EN7521 and the little-endian MIPS1004Kc EN7528.
+
 config ARCH_JZ47XX
 	bool "Support Ingenic JZ47xx"
 	select SUPPORT_SPL
@@ -201,6 +221,7 @@ source "arch/mips/mach-mscc/Kconfig"
 source "arch/mips/mach-bmips/Kconfig"
 source "arch/mips/mach-jz47xx/Kconfig"
 source "arch/mips/mach-pic32/Kconfig"
+source "arch/mips/mach-en75xx/Kconfig"
 source "arch/mips/mach-mtmips/Kconfig"
 source "arch/mips/mach-octeon/Kconfig"
 
arch/mips/Makefile +2 -0
index 453c7885..7c3976aa 100644
@@ -9,6 +9,7 @@ endif
 
 ifeq ($(CONFIG_TPL_BUILD),y)
 head-$(CONFIG_SOC_MT7621) := arch/mips/mach-mtmips/mt7621/tpl/start.o
+head-$(CONFIG_ARCH_EN75XX) := arch/mips/mach-en75xx/tpl/start.o
 endif
 
 libs-y += arch/mips/cpu/
@@ -16,6 +17,7 @@ libs-y += arch/mips/lib/
 
 machine-$(CONFIG_ARCH_ATH79) += ath79
 machine-$(CONFIG_ARCH_BMIPS) += bmips
+machine-$(CONFIG_ARCH_EN75XX) += en75xx
 machine-$(CONFIG_ARCH_JZ47XX) += jz47xx
 machine-$(CONFIG_MACH_PIC32) += pic32
 machine-$(CONFIG_ARCH_MTMIPS) += mtmips
arch/mips/cpu/start.S +2 -0
index a95c95bc..48eb69b1 100644
@@ -124,7 +124,9 @@ ENTRY(_start)
 #endif
 
 reset:
+#ifndef CONFIG_MIPS_SKIP_CP0_COUNT_CLEAR
 	mtc0	zero, CP0_COUNT	# clear cp0 count for most accurate boot timing
+#endif
 #if __mips_isa_rev >= 6
 	mfc0	t0, CP0_CONFIG, 5
 	and	t0, t0, MIPS_CONF5_VP
arch/mips/mach-en75xx/Kconfig new file +118 -0

118 lines not on this page · raw message

arch/mips/mach-en75xx/Makefile new file +17 -0
new file mode 100644
index 00000000..f40e49ec
@@ -0,0 +1,17 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+ifeq ($(CONFIG_TPL_BUILD),y)
+obj-y += early_sfc.o
+obj-y += tpl/
+else
+obj-y += cpu.o
+ifeq ($(CONFIG_SPL_BUILD),y)
+obj-y += early_sfc.o
+obj-y += spl/
+else
+# U-Boot proper
+obj-y += cache.o
+# PIO SFC reader for `en75 sfctest` vs the DM SPI-NAND path.
+obj-$(CONFIG_CMD_EN75BOOT) += early_sfc.o
+endif
+endif
arch/mips/mach-en75xx/cache.c new file +121 -0

121 lines not on this page · raw message

arch/mips/mach-en75xx/cpu.c new file +95 -0

95 lines not on this page · raw message

arch/mips/mach-en75xx/include/mach/en75xx.h new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
2.53.0
author
#3 lore raw

PATCH 2/12 mips: en75xx: add TPL and SPL early boot stages

In reply to AK Sharma

Add the TPL and SPL stages for the EN75xx. The TPL brings up the cache and SoC straps, runs the vendor DDR calibration stage from flash via the early SFC (serial-flash controller) reader, then the SPL loads U-Boot proper.

The DDR calibration stage is a vendor artifact read from flash at boot and is not shipped in-tree; see arch/mips/mach-en75xx/README.ddr-blob for how to obtain it and its checksums.

---
 arch/mips/mach-en75xx/README.ddr-blob |  21 ++
 arch/mips/mach-en75xx/early_sfc.c     | 352 ++++++++++++++++++++++++++
 arch/mips/mach-en75xx/spl/Makefile    |   2 +
 arch/mips/mach-en75xx/spl/spl.c       |  47 ++++
 arch/mips/mach-en75xx/tpl/Makefile    |   3 +
 arch/mips/mach-en75xx/tpl/start.S     | 101 ++++++++
 arch/mips/mach-en75xx/tpl/tpl.c       | 158 ++++++++++++
 7 files changed, 684 insertions(+)
 create mode 100644 arch/mips/mach-en75xx/README.ddr-blob
 create mode 100644 arch/mips/mach-en75xx/early_sfc.c
 create mode 100644 arch/mips/mach-en75xx/spl/Makefile
 create mode 100644 arch/mips/mach-en75xx/spl/spl.c
 create mode 100644 arch/mips/mach-en75xx/tpl/Makefile
 create mode 100644 arch/mips/mach-en75xx/tpl/start.S
 create mode 100644 arch/mips/mach-en75xx/tpl/tpl.c
arch/mips/mach-en75xx/README.ddr-blob new file +21 -0
new file mode 100644
index 00000000..b0074941
@@ -0,0 +1,21 @@
+EN75xx DDR calibration blob
+===========================
+
+The EN75xx TPL runs a small vendor DDR calibration stage that is NOT part
+of the U-Boot source tree. The TPL reads it from SPI-NAND at
+EN75XX_DDR_BLOB_OFFSET (0x8000) with the early SFC reader (see tpl/tpl.c)
+and executes it from FE-SRAM before DRAM is available.
+
+Obtain the blob by extracting the FE-SRAM DDR calibration stage
+("spram.bin") from the device's vendor bootloader and flashing it at
+EN75XX_DDR_BLOB_OFFSET.
+
+Expected images:
+
+  EN7512/EN7521  20336 bytes, linked/entered at 0x9fa32800
+                 sha256 792068a4573b20cb8c39cb27df06c45683c11034e6fd07da24ddf7084828faa5
+  EN7528         23152 bytes
+                 sha256 c2ff94b25100d46c0f2d8b42ebeb887bd6bfd0d49cd1ba5df61eea84ac227540
+
+Providing a source implementation of the DDR2/DDR3 calibration to remove
+this runtime dependency is a known TODO.
arch/mips/mach-en75xx/early_sfc.c new file +352 -0

352 lines not on this page · raw message

arch/mips/mach-en75xx/spl/Makefile new file +2 -0
new file mode 100644
index 00000000..d19fc6e6
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0+
+obj-y += spl.o
arch/mips/mach-en75xx/spl/spl.c new file +47 -0

47 lines not on this page · raw message

arch/mips/mach-en75xx/tpl/Makefile new file +3 -0
new file mode 100644
index 00000000..da834c75
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+extra-y += start.o
+obj-y += tpl.o
arch/mips/mach-en75xx/tpl/start.S new file +101 -0

101 lines not on this page · raw message

arch/mips/mach-en75xx/tpl/tpl.c new file +158 -0

158 lines not on this page · raw message

Signature · 1 line
2.53.0
#4 lore raw

Re: [PATCH v1 02/12] mips: en75xx: add TPL and SPL early boot stages

Quoted 5 lines · AK Sharma

Add the TPL and SPL stages for the EN75xx. The TPL brings up the cache and SoC straps, runs the vendor DDR calibration stage from flash via the early SFC (serial-flash controller) reader, then the SPL loads U-Boot proper.

Quoted 7 lines

The DDR calibration stage is a vendor artifact read from flash at boot and is not shipped in-tree; see arch/mips/mach-en75xx/README.ddr-blob for how to obtain it and its checksums.

---
 arch/mips/mach-en75xx/README.ddr-blob |  21 ++

Documentation needs to be in rST format and under doc/ (and then make KDOC_WERROR=1 htmldocs must be clean).

Signature · 1 line
Tom
author
#5 lore raw

PATCH 3/12 serial: en75xx: add EcoNet/Airoha EN75xx UART driver

In reply to AK Sharma

Add a DM serial driver for the UART on the EcoNet/Airoha EN75xx SoCs.

---
 drivers/serial/Kconfig         |   7 ++
 drivers/serial/Makefile        |   1 +
 drivers/serial/serial_en75xx.c | 170 +++++++++++++++++++++++++++++++++
 3 files changed, 178 insertions(+)
 create mode 100644 drivers/serial/serial_en75xx.c
drivers/serial/Kconfig +7 -0
index 5f8b98f0..2a8fee98 100644
@@ -1098,6 +1098,13 @@ config ZYNQ_SERIAL
 	  This driver supports the Cadence UART. It is found e.g. in Xilinx
 	  Zynq/ZynqMP.
 
+config EN75XX_SERIAL
+	bool "EcoNet/Airoha EN75xx serial port support"
+	depends on ARCH_EN75XX
+	help
+	  Support the byte-lane 16550-like UART used by EN7512/EN7521/EN7528.
+	  The controller also uses a vendor-specific fractional divider.
+
 config MTK_SERIAL
 	bool "MediaTek High-speed UART support"
 	depends on DM_SERIAL
drivers/serial/Makefile +1 -0
index 66088b44..75ec49b7 100644
@@ -55,6 +55,7 @@ obj-$(CONFIG_OWL_SERIAL) += serial_owl.o
 obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o
 obj-$(CONFIG_MTK_SERIAL) += serial_mtk.o
 obj-$(CONFIG_MT7620_SERIAL) += serial_mt7620.o
+obj-$(CONFIG_EN75XX_SERIAL) += serial_en75xx.o
 obj-$(CONFIG_HTIF_CONSOLE) += serial_htif.o
 obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o
 obj-$(CONFIG_XEN_SERIAL) += serial_xen.o
drivers/serial/serial_en75xx.c new file +170 -0

170 lines not on this page · raw message

Signature · 1 line
2.53.0
author
#6 lore raw

PATCH 4/12 spi: airoha-snfi: add EN7528 SPI-NAND controller support

In reply to AK Sharma

Extend the Airoha SNFI driver for the serial-NAND controller on the EN7528, including the two-plane column handling required by the MT29F2G01 SPI-NAND.

---
 drivers/spi/Kconfig           |   3 +-
 drivers/spi/airoha_snfi_spi.c | 409 ++++++++++++++++++++++++++++------
 2 files changed, 337 insertions(+), 75 deletions(-)
drivers/spi/Kconfig +2 -1
index cfbedd64..83a79bee 100644
@@ -62,7 +62,8 @@ config ADI_SPI3
 
 config AIROHA_SNFI_SPI
 	bool "Airoha SPI memory controller driver"
-	depends on ARCH_AIROHA
+	depends on ARCH_AIROHA || ARCH_EN75XX
+	select REGMAP
 	select SPI_MEM
 	help
 	  Enable the Airoha SPI memory controller driver. This driver is
drivers/spi/airoha_snfi_spi.c +335 -74

639 lines not on this page · raw message

Signature · 1 line
2.53.0
author
#7 lore raw

PATCH 5/12 mtd: spi-nand: add EN75 BMT bad-block management support

In reply to AK Sharma

Add read support for the EcoNet/Airoha BMT/BBT (bad-block management table) layout used by the EN75xx vendor bootloaders, so U-Boot maps the SPI-NAND logical blocks the same way as the vendor firmware.

---
 drivers/mtd/nand/spi/Kconfig    |   8 +
 drivers/mtd/nand/spi/Makefile   |   1 +
 drivers/mtd/nand/spi/core.c     |   9 +-
 drivers/mtd/nand/spi/en75_bmt.c | 665 ++++++++++++++++++++++++++++++++
 drivers/mtd/nand/spi/en75_bmt.h |  24 ++
 5 files changed, 706 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/en75_bmt.c
 create mode 100644 drivers/mtd/nand/spi/en75_bmt.h
drivers/mtd/nand/spi/Kconfig +8 -0
index 1124dada..09531914 100644
@@ -6,3 +6,11 @@ menuconfig MTD_SPI_NAND
 	select SPI_MEM
 	help
 	  This is the framework for the SPI NAND device drivers.
+
+config MTD_EN75_BMT
+	bool "EcoNet EN75xx vendor BMT/BBT translation (read-only)"
+	depends on MTD_SPI_NAND
+	help
+	  Honour the EcoNet/Airoha factory BBT and BMT so logical NAND
+	  addresses match the bootbase and Linux. Read-only: never rewrite
+	  the tables.
drivers/mtd/nand/spi/Makefile +1 -0
index a7a0b2cb..20aa718d 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 spinand-objs := core.o otp.o
+spinand-objs += $(if $(CONFIG_MTD_EN75_BMT),en75_bmt.o)
 spinand-objs += alliancememory.o ato.o esmt.o fmsh.o foresee.o gigadevice.o macronix.o
 spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c +8 -1
index 14af4264..29fdefe2 100644
@@ -33,6 +33,7 @@
 #include <linux/mtd/spinand.h>
 #include <linux/printk.h>
 #include <linux/delay.h>
+#include "en75_bmt.h"
 #endif
 
 struct spinand_plat {
@@ -1703,15 +1704,21 @@ static int spinand_probe(struct udevice *dev)
 #ifndef __UBOOT__
 	ret = mtd_device_register(mtd, NULL, 0);
 #else
+	ret = en75_bmt_attach(mtd);
+	if (ret)
+		goto err_spinand_cleanup;
+
 	ret = add_mtd_device(mtd);
 #endif
 	if (ret)
-		goto err_spinand_cleanup;
+		goto err_bmt_detach;
 
 	plat->mtd = mtd;
 
 	return 0;
 
+err_bmt_detach:
+	en75_bmt_detach(mtd);
 err_spinand_cleanup:
 	spinand_cleanup(spinand);
 
drivers/mtd/nand/spi/en75_bmt.c new file +665 -0

665 lines not on this page · raw message

drivers/mtd/nand/spi/en75_bmt.h new file +24 -0
new file mode 100644
index 00000000..e9d50b8d
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * EcoNet/Airoha EN75xx vendor BMT/BBT translation layer (read-only).
+ */
+#ifndef __EN75_BMT_H
+#define __EN75_BMT_H
+
+struct mtd_info;
+
+#if CONFIG_IS_ENABLED(MTD_EN75_BMT)
+/*
+ * Install the translation layer on a NAND whose DT node carries "econet,bmt".
+ * Must be called before add_mtd_device(), because it shrinks mtd->size to the
+ * user area and partitions are validated against that.
+ * Returns 0 when attached *or* when the node opts out; negative on error.
+ */
+int en75_bmt_attach(struct mtd_info *mtd);
+void en75_bmt_detach(struct mtd_info *mtd);
+#else
+static inline int en75_bmt_attach(struct mtd_info *mtd) { return 0; }
+static inline void en75_bmt_detach(struct mtd_info *mtd) { }
+#endif
+
+#endif /* __EN75_BMT_H */
Signature · 1 line
2.53.0
#8 lore raw

Re: [PATCH v1 05/12] mtd: spi-nand: add EN75 BMT bad-block management support

Quoted 67 lines · AK Sharma

Add read support for the EcoNet/Airoha BMT/BBT (bad-block management table) layout used by the EN75xx vendor bootloaders, so U-Boot maps the SPI-NAND logical blocks the same way as the vendor firmware.

---
 drivers/mtd/nand/spi/Kconfig    |   8 +
 drivers/mtd/nand/spi/Makefile   |   1 +
 drivers/mtd/nand/spi/core.c     |   9 +-
 drivers/mtd/nand/spi/en75_bmt.c | 665 ++++++++++++++++++++++++++++++++
 drivers/mtd/nand/spi/en75_bmt.h |  24 ++
 5 files changed, 706 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/en75_bmt.c
 create mode 100644 drivers/mtd/nand/spi/en75_bmt.h
drivers/mtd/nand/spi/Kconfig +8 -0
index 1124dada..09531914 100644
@@ -6,3 +6,11 @@ menuconfig MTD_SPI_NAND
 	select SPI_MEM
 	help
 	  This is the framework for the SPI NAND device drivers.
+
+config MTD_EN75_BMT
+	bool "EcoNet EN75xx vendor BMT/BBT translation (read-only)"
+	depends on MTD_SPI_NAND
+	help
+	  Honour the EcoNet/Airoha factory BBT and BMT so logical NAND
+	  addresses match the bootbase and Linux. Read-only: never rewrite
+	  the tables.
drivers/mtd/nand/spi/Makefile +1 -0
index a7a0b2cb..20aa718d 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 spinand-objs := core.o otp.o
+spinand-objs += $(if $(CONFIG_MTD_EN75_BMT),en75_bmt.o)
 spinand-objs += alliancememory.o ato.o esmt.o fmsh.o foresee.o gigadevice.o macronix.o
 spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c +5 -1
index 14af4264..29fdefe2 100644
@@ -33,6 +33,7 @@
 #include <linux/mtd/spinand.h>
 #include <linux/printk.h>
 #include <linux/delay.h>
+#include "en75_bmt.h"
 #endif
 
 struct spinand_plat {
@@ -1703,15 +1704,21 @@ static int spinand_probe(struct udevice *dev)
 #ifndef __UBOOT__
 	ret = mtd_device_register(mtd, NULL, 0);
 #else
+	ret = en75_bmt_attach(mtd);
+	if (ret)
+		goto err_spinand_cleanup;
+
 	ret = add_mtd_device(mtd);
 #endif
 	if (ret)
-		goto err_spinand_cleanup;

drivers/mtd/nand/spi/core.c static int spinand_probe(struct udevice *dev) · line 1723

Quoted 10 lines
drivers/mtd/nand/spi/core.c +3 -0
+		goto err_bmt_detach;
 
 	plat->mtd = mtd;
 
 	return 0;
 
+err_bmt_detach:
+	en75_bmt_detach(mtd);
 err_spinand_cleanup:
 	spinand_cleanup(spinand);

I am concerned about generic code path changes here, how is this handled in the upstream kernel?

Signature · 1 line
Tom
#9 lore raw

Re: [PATCH v1 05/12] mtd: spi-nand: add EN75 BMT bad-block management support

Quoted 75 lines · Tom Rini
Quoted 73 lines · AK Sharma

Add read support for the EcoNet/Airoha BMT/BBT (bad-block management table) layout used by the EN75xx vendor bootloaders, so U-Boot maps the SPI-NAND logical blocks the same way as the vendor firmware.

---
 drivers/mtd/nand/spi/Kconfig    |   8 +
 drivers/mtd/nand/spi/Makefile   |   1 +
 drivers/mtd/nand/spi/core.c     |   9 +-
 drivers/mtd/nand/spi/en75_bmt.c | 665 ++++++++++++++++++++++++++++++++
 drivers/mtd/nand/spi/en75_bmt.h |  24 ++
 5 files changed, 706 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mtd/nand/spi/en75_bmt.c
 create mode 100644 drivers/mtd/nand/spi/en75_bmt.h
drivers/mtd/nand/spi/Kconfig +8 -0
index 1124dada..09531914 100644
@@ -6,3 +6,11 @@ menuconfig MTD_SPI_NAND
 	select SPI_MEM
 	help
 	  This is the framework for the SPI NAND device drivers.
+
+config MTD_EN75_BMT
+	bool "EcoNet EN75xx vendor BMT/BBT translation (read-only)"
+	depends on MTD_SPI_NAND
+	help
+	  Honour the EcoNet/Airoha factory BBT and BMT so logical NAND
+	  addresses match the bootbase and Linux. Read-only: never rewrite
+	  the tables.
drivers/mtd/nand/spi/Makefile +1 -0
index a7a0b2cb..20aa718d 100644
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 spinand-objs := core.o otp.o
+spinand-objs += $(if $(CONFIG_MTD_EN75_BMT),en75_bmt.o)
 spinand-objs += alliancememory.o ato.o esmt.o fmsh.o foresee.o gigadevice.o macronix.o
 spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o
 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c +6 -1
index 14af4264..29fdefe2 100644
@@ -33,6 +33,7 @@
 #include <linux/mtd/spinand.h>
 #include <linux/printk.h>
 #include <linux/delay.h>
+#include "en75_bmt.h"
 #endif
 
 struct spinand_plat {
@@ -1703,15 +1704,21 @@ static int spinand_probe(struct udevice *dev)
 #ifndef __UBOOT__
 	ret = mtd_device_register(mtd, NULL, 0);
 #else
+	ret = en75_bmt_attach(mtd);
+	if (ret)
+		goto err_spinand_cleanup;
+
 	ret = add_mtd_device(mtd);
 #endif
 	if (ret)
-		goto err_spinand_cleanup;
+		goto err_bmt_detach;
 
 	plat->mtd = mtd;
 
 	return 0;
 
Quoted 7 lines

drivers/mtd/nand/spi/core.c static int spinand_probe(struct udevice *dev) · line 1723

Quoted 4 lines
drivers/mtd/nand/spi/core.c +2 -0
+err_bmt_detach:
+	en75_bmt_detach(mtd);
 err_spinand_cleanup:
 	spinand_cleanup(spinand);

I am concerned about generic code path changes here, how is this handled in the upstream kernel?

I agree. I don't see any justification or explanation for adding chip-specific code to the spinand core.

Also, would it be possible for you to upstream the support to the Linux kernel first and then sync back to U-Boot?

author
#10 lore raw

PATCH 6/12 net: airoha-eth: add EN7528 Ethernet support

In reply to AK Sharma

Extend the Airoha GDM Ethernet driver to support the EN7528: the gigabit switch (mt7530) ports, the GDMA/QDMA rings and the MAC init.

---
 drivers/net/Kconfig      |   8 +-
 drivers/net/airoha_eth.c | 850 ++++++++++++++++++++++++++++++++++++---
 drivers/phy/Kconfig      |   2 +-
 3 files changed, 808 insertions(+), 52 deletions(-)
drivers/net/Kconfig +4 -4
index 66661868..7bcc58ad 100644
@@ -122,13 +122,13 @@ source "drivers/net/airoha/Kconfig"
 
 config AIROHA_ETH
 	bool "Airoha Ethernet QDMA Driver"
-	depends on ARCH_AIROHA
+	depends on ARCH_AIROHA || ARCH_EN75XX
 	select MISC
 	select PHYLIB
 	select DEVRES
-	select DM_ETH_PHY
-	select DM_RESET
-	select MDIO_MT7531_MMIO
+	select DM_ETH_PHY if ARCH_AIROHA
+	select DM_RESET if ARCH_AIROHA
+	select MDIO_MT7531_MMIO if ARCH_AIROHA
 	help
 	  This Driver support Airoha Ethernet QDMA Driver
 	  Say Y to enable support for the Airoha Ethernet QDMA.
drivers/net/airoha_eth.c +803 -47

1,130 lines not on this page · raw message

drivers/phy/Kconfig +1 -1
index 5c8ec2b1..28909d49 100644
@@ -272,7 +272,7 @@ config PHY_EXYNOS_USBDRD
 config PHY_MTK_TPHY
 	bool "MediaTek T-PHY Driver"
 	depends on PHY
-	depends on ARCH_MEDIATEK || SOC_MT7621
+	depends on ARCH_MEDIATEK || SOC_MT7621 || ARCH_EN75XX
 	select REGMAP
 	select SYSCON
 	help
Signature · 1 line
2.53.0
author
#11 lore raw

PATCH 7/12 mtd: env, cmd: add EN75 NAND remap handling

In reply to AK Sharma

Honour the EcoNet/Airoha NAND "remap" region attribute when reading and writing MTD partitions from the env and the mtd command, matching the vendor block layout.

---
 cmd/mtd.c   | 30 ++++++++++++++--
 env/Kconfig |  2 +-
 env/mtd.c   | 98 +++++++++++++++++++++++++++++++++--------------------
 3 files changed, 89 insertions(+), 41 deletions(-)
cmd/mtd.c +27 -3
index 7f251440..d7b8fa3b 100644
@@ -519,6 +519,13 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
 		goto out_put_mtd;
 	}
 
+	if (start_off >= mtd->size) {
+		printf("Offset 0x%llx is past the end of %s (size 0x%llx)\n",
+		       start_off, mtd->name, mtd->size);
+		ret = CMD_RET_FAILURE;
+		goto out_put_mtd;
+	}
+
 	default_len = dump ? mtd->writesize : mtd->size;
 	len = argc > 1 ? hextoul(argv[1], NULL) : default_len;
 	if (!mtd_is_aligned_with_min_io_size(mtd, len)) {
@@ -557,11 +564,21 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
 	io_op.datbuf = buf;
 	io_op.oobbuf = woob ? &buf[len] : NULL;
 
-	/* Search for the first good block after the given offset */
+	/*
+	 * Search for the first good block after the given offset.
+	 * Bounded: mtd_block_isbad() returns a negative errno past the end of
+	 * the device, which is nonzero and would otherwise spin forever.
+	 */
 	off = start_off;
-	while (mtd_block_isbad(mtd, off))
+	while (off < mtd->size && mtd_block_isbad(mtd, off) > 0)
 		off += mtd->erasesize;
 
+	if (off >= mtd->size) {
+		printf("No good block found after offset 0x%llx\n", start_off);
+		ret = CMD_RET_FAILURE;
+		goto out_put_mtd;
+	}
+
 	led_activity_blink();
 
 	if (benchmark)
@@ -569,9 +586,16 @@ static int do_mtd_io(struct cmd_tbl *cmdtp, int flag, int argc,
 
 	/* Loop over the pages to do the actual read/write */
 	while (remaining) {
+		if (off >= mtd->size) {
+			printf("Reached the end of %s before completing\n",
+			       mtd->name);
+			ret = -EIO;
+			break;
+		}
+
 		/* Skip the block if it is bad */
 		if (mtd_is_aligned_with_block_size(mtd, off) &&
-		    mtd_block_isbad(mtd, off)) {
+		    mtd_block_isbad(mtd, off) > 0) {
 			off += mtd->erasesize;
 			continue;
 		}
env/Kconfig +1 -1
index 7abd82ab..ba45d194 100644
@@ -652,7 +652,7 @@ config ENV_OFFSET_RELATIVE_END
 config ENV_OFFSET_REDUND
 	hex "Redundant environment offset"
 	depends on (ENV_IS_IN_EEPROM || ENV_IS_IN_MMC || ENV_IS_IN_NAND || \
-		    ENV_IS_IN_SPI_FLASH) && ENV_REDUNDANT
+		    ENV_IS_IN_SPI_FLASH || ENV_IS_IN_MTD) && ENV_REDUNDANT
 	default 0x10C0000 if MICROBLAZE
 	default 0x0
 	help
env/mtd.c +61 -37

171 lines not on this page · raw message

Signature · 1 line
2.53.0
#12 lore raw

Re: [PATCH v1 07/12] mtd: env, cmd: add EN75 NAND remap handling

Quoted 9 lines · AK Sharma

Honour the EcoNet/Airoha NAND "remap" region attribute when reading and writing MTD partitions from the env and the mtd command, matching the vendor block layout.

---
 cmd/mtd.c   | 30 ++++++++++++++--
 env/Kconfig |  2 +-
 env/mtd.c   | 98 +++++++++++++++++++++++++++++++++--------------------

This is another place where I am concerned about a lot of changes to generic code to support a specific platform.

Signature · 1 line
Tom
author
#13 lore raw

PATCH 8/12 boot: image: add weak hooks for the decompression buffer and flush

In reply to AK Sharma

Add two weak hooks around the bootm image decompression:
image_get_decomp_buf() lets a platform redirect the decompression destination (e.g. to an uncached window), and image_decomp_flush() lets it flush the caches over the decompressed image. Both default to no-ops, so existing platforms are unaffected. The EN75xx uses them to keep the kernel coherent on its cache-coherent CM.

---
 boot/image.c    | 34 +++++++++++++++++++++++++++-------
 include/image.h |  5 +++++
 2 files changed, 32 insertions(+), 7 deletions(-)
boot/image.c +27 -7
index 185d52ba..680a78da 100644
@@ -442,15 +442,31 @@ int image_decomp_type(const unsigned char *buf, ulong len)
 	return cmagic->comp_id;
 }
 
+#if !defined(USE_HOSTCC)
+void *__weak image_get_decomp_buf(void *load_buf)
+{
+	return load_buf;
+}
+
+void __weak image_decomp_flush(ulong load, ulong image_len)
+{
+}
+#endif
+
 int image_decomp(int comp, ulong load, ulong image_start, int type,
 		 void *load_buf, void *image_buf, ulong image_len,
 		 uint unc_len, ulong *load_end)
 {
 	int ret = -ENOSYS;
+	void *dst = load_buf;
 
 	*load_end = load;
 	print_decomp_msg(comp, type, load == image_start, load);
 
+#if !defined(USE_HOSTCC)
+	dst = image_get_decomp_buf(load_buf);
+#endif
+
 	/*
 	 * Load the image to the right place, decompressing if needed. After
 	 * this, image_len will be set to the number of uncompressed bytes
@@ -462,13 +478,13 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		if (load == image_start)
 			break;
 		if (image_len <= unc_len)
-			memmove_wd(load_buf, image_buf, image_len, CHUNKSZ);
+			memmove_wd(dst, image_buf, image_len, CHUNKSZ);
 		else
 			ret = -ENOSPC;
 		break;
 	case IH_COMP_GZIP:
 		if (!tools_build() && CONFIG_IS_ENABLED(GZIP))
-			ret = gunzip(load_buf, unc_len, image_buf, &image_len);
+			ret = gunzip(dst, unc_len, image_buf, &image_len);
 		break;
 	case IH_COMP_BZIP2:
 		if (!tools_build() && CONFIG_IS_ENABLED(BZIP2)) {
@@ -479,7 +495,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 			 * use slower decompression algorithm which requires
 			 * at most 2300 KB of memory.
 			 */
-			ret = BZ2_bzBuffToBuffDecompress(load_buf, &size,
+			ret = BZ2_bzBuffToBuffDecompress(dst, &size,
 				image_buf, image_len, CONSERVE_MEMORY, 0);
 			image_len = size;
 		}
@@ -488,7 +504,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		if (!tools_build() && CONFIG_IS_ENABLED(LZMA)) {
 			SizeT lzma_len = unc_len;
 
-			ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
+			ret = lzmaBuffToBuffDecompress(dst, &lzma_len,
 						       image_buf, image_len);
 			image_len = lzma_len;
 		}
@@ -497,7 +513,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		if (!tools_build() && CONFIG_IS_ENABLED(LZO)) {
 			size_t size = unc_len;
 
-			ret = lzop_decompress(image_buf, image_len, load_buf, &size);
+			ret = lzop_decompress(image_buf, image_len, dst, &size);
 			image_len = size;
 		}
 		break;
@@ -505,7 +521,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		if (!tools_build() && CONFIG_IS_ENABLED(LZ4)) {
 			size_t size = unc_len;
 
-			ret = ulz4fn(image_buf, image_len, load_buf, &size);
+			ret = ulz4fn(image_buf, image_len, dst, &size);
 			image_len = size;
 		}
 		break;
@@ -514,7 +530,7 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 			struct abuf in, out;
 
 			abuf_init_set(&in, image_buf, image_len);
-			abuf_init_set(&out, load_buf, unc_len);
+			abuf_init_set(&out, dst, unc_len);
 			ret = zstd_decompress(&in, &out);
 			if (ret >= 0) {
 				image_len = ret;
@@ -532,6 +548,10 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 	if (ret)
 		return ret;
 
+#if !defined(USE_HOSTCC)
+	image_decomp_flush(load, image_len);
+#endif
+
 	return 0;
 }
 
include/image.h +5 -0
index 34efac60..b2a6c536 100644
@@ -1014,6 +1014,11 @@ int image_decomp(int comp, ulong load, ulong image_start, int type,
 		 void *load_buf, void *image_buf, ulong image_len,
 		 uint unc_len, ulong *load_end);
 
+#ifndef USE_HOSTCC
+void *image_get_decomp_buf(void *load_buf);
+void image_decomp_flush(ulong load, ulong image_len);
+#endif
+
 /**
  * Set up properties in the FDT
  *
Signature · 1 line
2.53.0
#14 lore raw

Re: [PATCH v1 08/12] boot: image: add weak hooks for the decompression buffer and flush

Quoted 7 lines · AK Sharma

Add two weak hooks around the bootm image decompression:
image_get_decomp_buf() lets a platform redirect the decompression destination (e.g. to an uncached window), and image_decomp_flush() lets it flush the caches over the decompressed image. Both default to no-ops, so existing platforms are unaffected. The EN75xx uses them to keep the kernel coherent on its cache-coherent CM.

Quoted 5 lines
---
 boot/image.c    | 34 +++++++++++++++++++++++++++-------
 include/image.h |  5 +++++
 2 files changed, 32 insertions(+), 7 deletions(-)

This seems like something that should be possible with the normal environment-based restrictions documented in doc/usage/environment.rst around bootm_size and similar.

Signature · 1 line
Tom
author
#15 lore raw

PATCH 9/12 mips: dts: add EcoNet EN75xx device trees

In reply to AK Sharma

Add the device trees for the EN7512 and EN7528 reference boards and the EN7528 RAM-boot variant.

---
 arch/mips/dts/Makefile                        |   2 +
 .../dts/econet,en7512-reference-u-boot.dtsi   |  58 +++++++
 arch/mips/dts/econet,en7512-reference.dts     |  27 +++
 arch/mips/dts/econet,en7512.dtsi              |  88 ++++++++++
 arch/mips/dts/econet,en7528-ram-u-boot.dtsi   |   6 +
 arch/mips/dts/econet,en7528-ram.dts           |  72 ++++++++
 .../dts/econet,en7528-reference-u-boot.dtsi   |  62 +++++++
 arch/mips/dts/econet,en7528-reference.dts     |  25 +++
 arch/mips/dts/econet,en7528.dtsi              | 164 ++++++++++++++++++
 9 files changed, 504 insertions(+)
 create mode 100644 arch/mips/dts/econet,en7512-reference-u-boot.dtsi
 create mode 100644 arch/mips/dts/econet,en7512-reference.dts
 create mode 100644 arch/mips/dts/econet,en7512.dtsi
 create mode 100644 arch/mips/dts/econet,en7528-ram-u-boot.dtsi
 create mode 100644 arch/mips/dts/econet,en7528-ram.dts
 create mode 100644 arch/mips/dts/econet,en7528-reference-u-boot.dtsi
 create mode 100644 arch/mips/dts/econet,en7528-reference.dts
 create mode 100644 arch/mips/dts/econet,en7528.dtsi
arch/mips/dts/Makefile +2 -0
index 7c4ee8b6..3e0347dd 100644
@@ -6,6 +6,8 @@ dtb-$(CONFIG_TARGET_AP152) += ap152.dtb
 dtb-$(CONFIG_TARGET_MALTA) += mti,malta.dtb
 dtb-$(CONFIG_TARGET_PIC32MZDASK) += pic32mzda_sk.dtb
 dtb-$(CONFIG_TARGET_XILFPGA) += nexys4ddr.dtb
+dtb-$(CONFIG_ARCH_EN75XX) += econet,en7512-reference.dtb \
+	econet,en7528-reference.dtb econet,en7528-ram.dtb
 dtb-$(CONFIG_BOARD_BROADCOM_BCM968380GERG) += brcm,bcm968380gerg.dtb
 dtb-$(CONFIG_BOARD_COMTREND_AR5315U) += comtrend,ar-5315u.dtb
 dtb-$(CONFIG_BOARD_COMTREND_AR5387UN) += comtrend,ar-5387un.dtb
arch/mips/dts/econet,en7512-reference-u-boot.dtsi new file +58 -0

58 lines not on this page · raw message

arch/mips/dts/econet,en7512-reference.dts new file +27 -0
new file mode 100644
index 00000000..b8a3aba5
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+#include "econet,en7512.dtsi"
+
+/ {
+	model = "EcoNet EN7512/EN7521 reference board";
+	compatible = "econet,en7512-reference", "econet,en751221",
+		     "econet,en7512";
+
+	aliases {
+		serial0 = &uart0;
+		ethernet0 = &gmac0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&sfc {
+	status = "okay";
+};
arch/mips/dts/econet,en7512.dtsi new file +88 -0

88 lines not on this page · raw message

arch/mips/dts/econet,en7528-ram-u-boot.dtsi new file +6 -0
new file mode 100644
index 00000000..94512540
@@ -0,0 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0+
+/* RAM-boot: no binman image; just make the console available pre-relocation. */
+
+&uart0 {
+	bootph-all;
+};
arch/mips/dts/econet,en7528-ram.dts new file +72 -0

72 lines not on this page · raw message

arch/mips/dts/econet,en7528-reference-u-boot.dtsi new file +62 -0

62 lines not on this page · raw message

arch/mips/dts/econet,en7528-reference.dts new file +25 -0
new file mode 100644
index 00000000..d029f41c
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+#include "econet,en7528.dtsi"
+
+/ {
+	model = "EcoNet EN7528 reference board (DASAN H660GM-A)";
+	compatible = "econet,en7528-reference", "econet,en7528";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&sfc {
+	status = "okay";
+};
arch/mips/dts/econet,en7528.dtsi new file +164 -0

164 lines not on this page · raw message

Signature · 1 line
2.53.0
#16 lore raw

Re: [PATCH v1 09/12] mips: dts: add EcoNet EN75xx device trees

Quoted 15 lines · AK Sharma

Add the device trees for the EN7512 and EN7528 reference boards and the EN7528 RAM-boot variant.

---
 arch/mips/dts/Makefile                        |   2 +
 .../dts/econet,en7512-reference-u-boot.dtsi   |  58 +++++++
 arch/mips/dts/econet,en7512-reference.dts     |  27 +++
 arch/mips/dts/econet,en7512.dtsi              |  88 ++++++++++
 arch/mips/dts/econet,en7528-ram-u-boot.dtsi   |   6 +
 arch/mips/dts/econet,en7528-ram.dts           |  72 ++++++++
 .../dts/econet,en7528-reference-u-boot.dtsi   |  62 +++++++
 arch/mips/dts/econet,en7528-reference.dts     |  25 +++
 arch/mips/dts/econet,en7528.dtsi              | 164 ++++++++++++++++++
 9 files changed, 504 insertions(+)
Quoted 8 lines
 create mode 100644 arch/mips/dts/econet,en7512-reference-u-boot.dtsi
 create mode 100644 arch/mips/dts/econet,en7512-reference.dts
 create mode 100644 arch/mips/dts/econet,en7512.dtsi
 create mode 100644 arch/mips/dts/econet,en7528-ram-u-boot.dtsi
 create mode 100644 arch/mips/dts/econet,en7528-ram.dts
 create mode 100644 arch/mips/dts/econet,en7528-reference-u-boot.dtsi
 create mode 100644 arch/mips/dts/econet,en7528-reference.dts
 create mode 100644 arch/mips/dts/econet,en7528.dtsi

What is the status of upstreaming all of these dts files? Thanks.

Signature · 1 line
Tom
author
#17 lore raw

PATCH 10/12 board: econet: add EN7512 reference board

In reply to AK Sharma

Add the EcoNet EN7512 reference board: board glue, defconfig, board header and documentation.

---
 board/econet/en7512/MAINTAINERS    |  8 +++
 board/econet/en7512/Makefile       |  2 +
 board/econet/en7512/board.c        | 34 +++++++++++
 configs/en7512_reference_defconfig | 93 ++++++++++++++++++++++++++++++
 doc/board/econet/en7512.rst        | 70 ++++++++++++++++++++++
 drivers/usb/host/Kconfig           |  2 +-
 include/configs/en7512.h           |  8 +++
 7 files changed, 216 insertions(+), 1 deletion(-)
 create mode 100644 board/econet/en7512/MAINTAINERS
 create mode 100644 board/econet/en7512/Makefile
 create mode 100644 board/econet/en7512/board.c
 create mode 100644 configs/en7512_reference_defconfig
 create mode 100644 doc/board/econet/en7512.rst
 create mode 100644 include/configs/en7512.h
board/econet/en7512/MAINTAINERS new file +8 -0
new file mode 100644
index 00000000..0c1b931a
@@ -0,0 +1,8 @@
+ECONET EN7512 REFERENCE BOARD
+M:	AK Sharma <[email protected]>
+S:	Maintained
+F:	arch/mips/dts/econet,en7512*
+F:	board/econet/en7512/
+F:	configs/en7512_reference_defconfig
+F:	doc/board/econet/en7512.rst
+F:	include/configs/en7512.h
board/econet/en7512/Makefile new file +2 -0
new file mode 100644
index 00000000..bcca1a9f
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0+
+obj-y += board.o
board/econet/en7512/board.c new file +34 -0
new file mode 100644
index 00000000..c20597e8
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <dm.h>
+#include <init.h>
+#include <linux/errno.h>
+#include <stdio.h>
+
+extern U_BOOT_DRIVER(airoha_eth);
+
+int board_init(void)
+{
+	return 0;
+}
+
+int board_late_init(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	if (!IS_ENABLED(CONFIG_AIROHA_ETH))
+		return 0;
+
+	/*
+	 * The EN751221 Ethernet parent is intentionally not probed while the
+	 * driver model is being initialized. Probe it after the console is
+	 * usable and just before initr_net() enumerates UCLASS_ETH devices.
+	 */
+	ret = uclass_get_device_by_driver(UCLASS_MISC,
+					  DM_DRIVER_GET(airoha_eth), &dev);
+	if (ret && ret != -ENODEV)
+		printf("EN751221 Ethernet probe failed: %d\n", ret);
+
+	return 0;
+}
configs/en7512_reference_defconfig new file +93 -0

93 lines not on this page · raw message

doc/board/econet/en7512.rst new file +70 -0

70 lines not on this page · raw message

drivers/usb/host/Kconfig +1 -1
index d75883e2..fbd6690a 100644
@@ -54,7 +54,7 @@ config USB_XHCI_EXYNOS
 
 config USB_XHCI_MTK
 	bool "Support for MediaTek on-chip xHCI USB controller"
-	depends on ARCH_MEDIATEK || SOC_MT7621
+	depends on ARCH_MEDIATEK || SOC_MT7621 || ARCH_EN75XX
 	help
 	  Enables support for the on-chip xHCI controller on MediaTek SoCs.
 
include/configs/en7512.h new file +8 -0
new file mode 100644
index 00000000..93e1c485
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#ifndef __CONFIG_EN7512_H
+#define __CONFIG_EN7512_H
+
+#define CFG_SYS_SDRAM_BASE	0x80000000
+#define CFG_SYS_INIT_SP_OFFSET	0x00800000
+
+#endif
Signature · 1 line
2.53.0
author
#18 lore raw

PATCH 11/12 board: econet: add EN7528 board support

In reply to AK Sharma

Add the EcoNet EN7528 board: board glue, the reference/RAM/tclinux and JCOW414 R3-hook defconfigs, board header and default environment.

---
 board/econet/en7528/MAINTAINERS         |  13 +++
 board/econet/en7528/Makefile            |   2 +
 board/econet/en7528/board.c             | 110 +++++++++++++++++++++++
 board/econet/en7528/mk_tclinux_uboot.py | 112 ++++++++++++++++++++++++
 board/econet/en7528/tclinux_stub.S      |  65 ++++++++++++++
 configs/en7528_jcow414_r3hook_defconfig |  76 ++++++++++++++++
 configs/en7528_ram_defconfig            |  62 +++++++++++++
 configs/en7528_reference_defconfig      |  40 +++++++++
 defenvs/en7528_jcow414_r3hook_env       |   5 ++
 include/configs/en7528.h                |   9 ++
 10 files changed, 494 insertions(+)
 create mode 100644 board/econet/en7528/MAINTAINERS
 create mode 100644 board/econet/en7528/Makefile
 create mode 100644 board/econet/en7528/board.c
 create mode 100644 board/econet/en7528/mk_tclinux_uboot.py
 create mode 100644 board/econet/en7528/tclinux_stub.S
 create mode 100644 configs/en7528_jcow414_r3hook_defconfig
 create mode 100644 configs/en7528_ram_defconfig
 create mode 100644 configs/en7528_reference_defconfig
 create mode 100644 defenvs/en7528_jcow414_r3hook_env
 create mode 100644 include/configs/en7528.h
board/econet/en7528/MAINTAINERS new file +13 -0
new file mode 100644
index 00000000..69cefe4a
@@ -0,0 +1,13 @@
+ECONET/AIROHA EN75XX
+M:	AK Sharma <[email protected]>
+S:	Maintained
+F:	arch/mips/mach-en75xx/
+F:	arch/mips/dts/econet,en7528*
+F:	board/econet/en7528/
+F:	configs/en7528_*_defconfig
+F:	defenvs/en7528_jcow414_r3hook_env
+F:	doc/board/econet/en7528.rst
+F:	doc/board/econet/index.rst
+F:	drivers/mtd/nand/spi/en75_bmt.*
+F:	drivers/serial/serial_en75xx.c
+F:	include/configs/en7528.h
board/econet/en7528/Makefile new file +2 -0
new file mode 100644
index 00000000..bcca1a9f
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0+
+obj-y += board.o
board/econet/en7528/board.c new file +110 -0

110 lines not on this page · raw message

board/econet/en7528/mk_tclinux_uboot.py new file +112 -0

112 lines not on this page · raw message

board/econet/en7528/tclinux_stub.S new file +65 -0

65 lines not on this page · raw message

configs/en7528_jcow414_r3hook_defconfig new file +76 -0

76 lines not on this page · raw message

configs/en7528_ram_defconfig new file +62 -0

62 lines not on this page · raw message

configs/en7528_reference_defconfig new file +40 -0
new file mode 100644
index 00000000..6811c7e3
@@ -0,0 +1,40 @@
+CONFIG_MIPS=y
+CONFIG_SYS_LITTLE_ENDIAN=y
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_SYS_MALLOC_LEN=0x100000
+CONFIG_SPL_LIBCOMMON_SUPPORT=y
+CONFIG_SPL_LIBGENERIC_SUPPORT=y
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_ENV_SIZE=0x1000
+CONFIG_DEFAULT_DEVICE_TREE="econet,en7528-reference"
+CONFIG_SPL_SYS_MALLOC_F_LEN=0x10000
+CONFIG_SPL_SERIAL=y
+CONFIG_TPL_SYS_MALLOC_F_LEN=0x1000
+CONFIG_SPL_BSS_START_ADDR=0x80080000
+CONFIG_SPL_BSS_MAX_SIZE=0x10000
+CONFIG_SYS_LOAD_ADDR=0x81800000
+CONFIG_SPL=y
+CONFIG_ARCH_EN75XX=y
+CONFIG_BUILD_TARGET="u-boot.bin"
+CONFIG_BOARD_EN7528_REFERENCE=y
+CONFIG_SYS_MIPS_TIMER_FREQ=150000000
+CONFIG_MIPS_CACHE_SETUP=y
+CONFIG_MIPS_CACHE_DISABLE=y
+CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y
+CONFIG_MIPS_BOOT_FDT=y
+CONFIG_FIT=y
+CONFIG_BOOTDELAY=3
+CONFIG_DISPLAY_CPUINFO=y
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_SPL_MAX_SIZE=0x30000
+CONFIG_SPL_SYS_MALLOC_SIMPLE=y
+CONFIG_TPL=y
+# CONFIG_TPL_FRAMEWORK is not set
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="EN7528> "
+CONFIG_SYS_MAXARGS=8
+CONFIG_CMD_MEMINFO=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_ENV_IS_NOWHERE=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_SPL_DM=y
defenvs/en7528_jcow414_r3hook_env new file +5 -0
new file mode 100644
index 00000000..4bc9e278
@@ -0,0 +1,5 @@
+ipaddr=192.168.1.111
+serverip=192.168.1.166
+loadaddr=0x82000000
+bootdelay=2
+bootcmd=mtd read spi-nand0 ${loadaddr} 0x100000 0x1000000; bootm ${loadaddr}
include/configs/en7528.h new file +9 -0
new file mode 100644
index 00000000..b8dc2410
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+#ifndef __CONFIG_EN7528_H
+#define __CONFIG_EN7528_H
+
+#define CFG_SYS_SDRAM_BASE	0x80000000
+/* Above FIT scratch (0x82000000) and kernel load (0x80020000, up to ~32 MiB). */
+#define CFG_SYS_INIT_SP_OFFSET	0x04000000
+
+#endif
Signature · 1 line
2.53.0
#19 lore raw

Re: [PATCH v1 11/12] board: econet: add EN7528 board support

Quoted 4 lines · AK Sharma

Add the EcoNet EN7528 board: board glue, the reference/RAM/tclinux and JCOW414 R3-hook defconfigs, board header and default environment.

[snip]

Quoted 9 lines
board/econet/en7528/MAINTAINERS new file +3 -0
new file mode 100644
index 00000000..69cefe4a
@@ -0,0 +1,13 @@
+ECONET/AIROHA EN75XX
+M:	AK Sharma <[email protected]>
+S:	Maintained

board/econet/en7528/MAINTAINERS line 13

Quoted 10 lines
board/econet/en7528/MAINTAINERS new file +10 -0
+F:	arch/mips/mach-en75xx/
+F:	arch/mips/dts/econet,en7528*
+F:	board/econet/en7528/
+F:	configs/en7528_*_defconfig
+F:	defenvs/en7528_jcow414_r3hook_env
+F:	doc/board/econet/en7528.rst
+F:	doc/board/econet/index.rst
+F:	drivers/mtd/nand/spi/en75_bmt.*
+F:	drivers/serial/serial_en75xx.c
+F:	include/configs/en7528.h

You should make use of the "N:" format to match on things like en75xx or en7528 and so forth.

[snip]

Quoted 24 lines
board/econet/en7528/mk_tclinux_uboot.py new file +18 -0
new file mode 100644
index 00000000..d63f46a3
@@ -0,0 +1,112 @@
+#!/usr/bin/env python3
+"""
+Package U-Boot as an EcoNet/TrendChip "tclinux" HDR2 image, so the stock
+bootbase will load and run it exactly the way it loads the stock kernel.
+
+The bootbase decompresses a slot's LZMA payload to a fixed 0x80002000 and jumps
+there. U-Boot cannot be linked at that address (MIPS relocation needs the
+relocation delta 64 KiB aligned, and reserve_uboot() force-aligns relocaddr to
+64 KiB, so a TEXT_BASE of 0x80002000 always panics "Mis-aligned relocation").
+So the payload is a small relocator stub followed by a U-Boot linked at
+0x81000000; the stub copies it up and jumps.
+
+  payload = [stub @0x80002000][pad to 0x100][u-boot.bin linked @0x81000000]
+  image   = [HDR2 header 0x100][LZMA(payload)]
+
+Header layout, confirmed against the stock image on a live board
+(0x100 + kernel_len + rootfs_len == total, exactly):
+

board/econet/en7528/mk_tclinux_uboot.py line 28

Quoted 10 lines
board/econet/en7528/mk_tclinux_uboot.py new file +10 -0
+  0x00  "HDR2"
+  0x08  u32 LE  total size, including the 0x100 header
+  0x0c  u32 LE  JAMCRC of everything after the header
+  0x10  version string
+  0x50  u32 LE  kernel length
+  0x54  u32 LE  rootfs length
+  0x100         LZMA kernel, then the rootfs
+
+Usage: mk_tclinux_uboot.py <stub.bin> <u-boot.bin> <out.trx> [version]
+"""

This should be part of the binman support I believe.

Signature · 1 line
Tom
#20 lore raw

Re: [PATCH v1 11/12] board: econet: add EN7528 board support

In reply to AK Sharma
Quoted 4 lines · AK Sharma

Add the EcoNet EN7528 board: board glue, the reference/RAM/tclinux and JCOW414 R3-hook defconfigs, board header and default environment.

[snip]

defenvs/en7528_jcow414_r3hook_env line 5

Quoted 11 lines
defenvs/en7528_jcow414_r3hook_env new file +5 -0
new file mode 100644
index 00000000..4bc9e278
@@ -0,0 +1,5 @@
+ipaddr=192.168.1.111
+serverip=192.168.1.166
+loadaddr=0x82000000
+bootdelay=2
+bootcmd=mtd read spi-nand0 ${loadaddr} 0x100000 0x1000000; bootm ${loadaddr}

This should just be in the board directory as other platforms do.

Signature · 1 line
Tom
author
#21 lore raw

PATCH 12/12 doc: board: econet: add EN75xx documentation

In reply to AK Sharma

Add the EcoNet vendor index and the EN7528 porting notes.

---
 doc/board/econet/en7528.rst | 39 +++++++++++++++++++++++++++++++++++++
 doc/board/econet/index.rst  | 10 ++++++++++
 doc/board/index.rst         |  1 +
 3 files changed, 50 insertions(+)
 create mode 100644 doc/board/econet/en7528.rst
 create mode 100644 doc/board/econet/index.rst
doc/board/econet/en7528.rst new file +39 -0
new file mode 100644
index 00000000..fc4eaf2e
@@ -0,0 +1,39 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+EN7528 reference board
+======================
+
+This target provides the U-Boot port for the MIPS-based EcoNet/Airoha
+EN7528 SoC (MIPS 1004Kc, little-endian), used in many GPON/XPON ONT home
+gateways. It replaces the proprietary multi-stage TCBoot flow with the
+U-Boot TPL, SPL and U-Boot proper stages.
+
+Boot flow
+---------
+
+The boot ROM starts the TPL from the uncached flash window at
+``0xbfc00000``. The TPL enables the Front-End SRAM, initializes the serial
+port and reads the DDR calibration image and SPL through the early SFC
+reader. After DDR initialization, SPL loads ``u-boot.img`` into DRAM.
+
+Build
+-----
+
+.. code-block:: bash
+
+    make en7528_reference_defconfig
+    make CROSS_COMPILE=mipsel-linux-
+
+Defconfigs
+----------
+
+- ``en7528_reference_defconfig`` - reference board (DASAN H660GM-A)
+- ``en7528_ram_defconfig`` - RAM / chainloaded build
+- ``en7528_jcow414_r3hook_defconfig`` - JioFiber JCOW414 R3-hook variant
+
+DDR calibration blob
+--------------------
+
+The TPL loads a vendor DDR calibration stage from flash; it is not part of
+the U-Boot source. See ``arch/mips/mach-en75xx/README.ddr-blob`` for how to
+extract it from the vendor bootloader and where to flash it.
doc/board/econet/index.rst new file +10 -0
new file mode 100644
index 00000000..d691db07
@@ -0,0 +1,10 @@
+.. SPDX-License-Identifier: GPL-2.0+
+
+EcoNet/Airoha
+=============
+
+.. toctree::
+   :maxdepth: 2
+
+   en7512
+   en7528
doc/board/index.rst +1 -0
index fcb4224b..60d75003 100644
@@ -29,6 +29,7 @@ Board-specific doc
    coreboot/index
    emcraft/index
    emulation/index
+   econet/index
    gateworks/index
    google/index
    highbank/index
Signature · 1 line
2.53.0
#22 lore raw
In reply to AK Sharma
Quoted 10 lines · AK Sharma

This series adds U-Boot support for the EcoNet/Airoha EN75xx MIPS SoC
family: the big-endian MIPS34Kc EN7512/EN7521 and the little-endian MIPS1004Kc EN7528, used in many GPON/XPON ONT home gateways. It extends the existing Airoha SNFI SPI-NAND and GDM Ethernet drivers.

It brings up the SoC (TPL/SPL, cache/CM init), and adds the UART, the EN75 BMT SPI-NAND bad-block mapping, weak bootm decompression hooks for the coherent CM, and Ethernet. Reference boards for the EN7512 and EN7528 are included, plus the EN7528 R3-hook boot variant.

Quoted 8 lines

The DDR calibration stage is a vendor artifact and is not shipped in-tree. The reference board packages it as a binman "blob-ext"; build those configs with BINMAN_ALLOW_MISSING=1 and supply the blob to run (see arch/mips/mach-en75xx/README.ddr-blob). A native DDR-init implementation is a known TODO.

Tested on a Nokia G-2425G-A (EN7528, MT29F2G01 SPI-NAND): boots to the prompt with correct 256 MiB DRAM, working Ethernet/TFTP and SPI-NAND.

I am glad to see this effort. I am, after reviewing a few of the patches, worried that this is still too much of a vendor port rather than re-working the vendor port to match upstream best practices. Perhaps one thing that would help is to keep in mind what the minimum set of additions required are, to get a good amount of functionality. And then follow-up patches once the core is in. Thanks.

Signature · 1 line
Tom
#23 lore raw
In reply to AK Sharma

Dude, if you're going to get other people's patchers and not even mention that someone else used the base, don't even send the patchers, I just made a draft for the SoC en751221 and en7528, on the openwrt forum itself I said that the boot was unstable, especially the ethernet of the en7528 and the spi0

#24 lore raw
Quoted 1 line · Matheus Sampaio Queiroga

Dude, if you're going to get other people's patchers and not even mention that someone else used the base, don't even send the patchers, I just made a draft for the SoC en751221 and en7528, on the openwrt forum itself I said that the boot was unstable, especially the ethernet of the en7528 and the spi0

Posting someone elses work violates the rules in
https://docs.u-boot.org/en/latest/develop/sending_patches.html#attributing-code-copyrights-signing
and specifically https://developercertificate.org/

Signature · 1 line
Tom
author
#25 lore raw

Please drop this series — do not apply it. It is derived from Matheus Sampaio Queiroga's GPL-2.0+ work in github.com/sirherobrine23/en7523_u-boot (the en751221 branch), which I submitted without crediting him and without his agreement; it was also an early draft, not ready for mainline. I apologize to Matheus and to the list. If a corrected series is sent later it will carry proper authorship and his sign-off. Sorry for the noise.

Regards,
Ak

Quoted 12 lines · Tom Rini
Quoted 1 line · Matheus Sampaio Queiroga

Dude, if you're going to get other people's patchers and not even mention that someone else used the base, don't even send the patchers, I just made a draft for the SoC en751221 and en7528, on the openwrt forum itself I said that the boot was unstable, especially the ethernet of the en7528 and the spi0

Posting someone elses work violates the rules in
https://docs.u-boot.org/en/latest/develop/sending_patches.html#attributing-code-copyrights-signing
and specifically https://developercertificate.org/

Signature · 1 line
Tom
#26 lore raw
Quoted 1 line · AK Sharma

Please drop this series — do not apply it. It is derived from Matheus Sampaio Queiroga's GPL-2.0+ work in github.com/sirherobrine23/en7523_u-boot (the en751221 branch), which I submitted without crediting him and without his agreement; it was also an early draft, not ready for mainline. I apologize to Matheus and to the list. If a corrected series is sent later it will carry proper authorship and his sign-off. Sorry for the noise.

Thank you for the responsible follow-up.

Signature · 1 line
Tom