mips: add EcoNet/Airoha EN75xx (EN7512/EN7528) SoC support
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
v2 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.
This is a minimal core: SoC bring-up (TPL/SPL, cache/CM init), UART, SPI-NAND, Ethernet, device trees, EN7512/EN7528 reference boards and documentation. It boots to the U-Boot prompt with working Ethernet/TFTP and SPI-NAND. The vendor-specific pieces from v1 (the BMT bad-block translation, the env/cmd MTD changes, the boot/image decompression hooks and the R3-hook boot variant) are dropped from this series and will return as separate, justified changes, as discussed on v1.
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 doc/board/econet/en7528.rst). A native DDR-init implementation is a known TODO.
Tested on a Nokia G-2425G-A (EN7528, MT29F2G01 SPI-NAND) via RAM-loaded
U-Boot: boots to the prompt with correct 256 MiB DRAM, working Ethernet/TFTP and SPI-NAND. All defconfigs build and are in savedefconfig form; checkpatch reports no errors.
Apart from the usual registration wiring (arch/mips Makefile/Kconfig for the new SoC, the driver Kconfig/Makefile entries and the DT Makefile), the only change to generic behaviour is one opt-in Kconfig flag, MIPS_SKIP_CP0_COUNT_CLEAR in arch/mips/Kconfig (added alongside the existing MIPS_CACHE_SETUP / ROM_EXCEPTION_VECTORS start.S options), and the two-line #ifndef guard it gates in arch/mips/cpu/start.S: the EN7528 CP0 Count register is GIC/CM backed and the reset-time clear in arch/mips/cpu/start.S stalls the CPU. It defaults off and changes nothing for other targets; happy to move it to a mach reset path if preferred.
Changes in v2:
- Reworked from a full vendor port into a minimal bootable core, per review feedback (Tom Rini). Dropped from the series, to return as separate, justified changes:
- spi-nand BMT: no chip-specific code in the spinand core; the bad-block-table support will go to the Linux kernel first, then sync to U-Boot (Frieder Schrempf, Tom Rini).
- boot/image decompression weak hooks: to be replaced by bootm_size and an uncached load address from the environment (Tom Rini).
- cmd/mtd and env/mtd changes: to be resubmitted standalone as generic fixes, not tied to this SoC (Tom Rini).
- the R3-hook board variant and its image packaging (to return using binman and a board default environment).
- Documentation moved to reStructuredText under doc/ (Tom Rini).
- MAINTAINERS uses N: en75xx / N: en7528 pattern entries (Tom Rini).
- Device trees noted as not yet in Linux; the bindings and DTs will be submitted to the kernel and kept in sync (Tom Rini).
- Defconfigs regenerated in savedefconfig form.
Known follow-ups (not in this minimal core; direction welcome):
- The extended airoha-snfi/airoha-eth drivers use a small CKSEG1 uncached shim for DMA buffers instead of a MIPS dma_alloc_coherent(); a proper arch DMA-mapping implementation would remove the per-arch #if.
- The SNFI controller selects its variant from the root-node machine compatible; keying off the device's own compatible would be cleaner.
- A native DDR-init to remove the vendor DDR-blob dependency.
- USB: the EN7528 xHCI controller and its T-PHY bring-up (reuses the existing MediaTek xHCI driver) is left out of this core and will come back as a follow-up.
Link to v1:
https://lore.kernel.org/u-boot/[email protected]/
AK Sharma (9):
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 EN75xx SPI-NAND controller support
net: airoha-eth: add EN7528 Ethernet support
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 | 29 + 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 | 154 ++++ arch/mips/mach-en75xx/Kconfig | 100 +++ arch/mips/mach-en75xx/Makefile | 15 + arch/mips/mach-en75xx/cache.c | 85 ++ arch/mips/mach-en75xx/cpu.c | 95 ++ arch/mips/mach-en75xx/early_sfc.c | 352 ++++++++ arch/mips/mach-en75xx/include/mach/en75xx.h | 103 +++ 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 | 37 + configs/en7512_reference_defconfig | 90 ++ configs/en7528_ram_defconfig | 43 + configs/en7528_reference_defconfig | 38 + doc/board/econet/en7512.rst | 66 ++ doc/board/econet/en7528.rst | 66 ++ doc/board/econet/index.rst | 10 + doc/board/index.rst | 1 + drivers/net/Kconfig | 8 +- drivers/net/airoha_eth.c | 850 +++++++++++++++++- drivers/serial/Kconfig | 7 + drivers/serial/Makefile | 1 + drivers/serial/serial_en75xx.c | 170 ++++ drivers/spi/Kconfig | 3 +- drivers/spi/airoha_snfi_spi.c | 412 +++++++-- include/configs/en7512.h | 8 + include/configs/en7528.h | 9 + 45 files changed, 3339 insertions(+), 127 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/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 configs/en7512_reference_defconfig create mode 100644 configs/en7528_ram_defconfig create mode 100644 configs/en7528_reference_defconfig 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/serial/serial_en75xx.c create mode 100644 include/configs/en7512.h create mode 100644 include/configs/en7528.h
Signature · 1 line
2.53.0
PATCH v2 1/9 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 | 29 ++++++ arch/mips/Makefile | 2 + arch/mips/cpu/start.S | 2 + arch/mips/mach-en75xx/Kconfig | 100 +++++++++++++++++++ arch/mips/mach-en75xx/Makefile | 15 +++ arch/mips/mach-en75xx/cache.c | 85 ++++++++++++++++ arch/mips/mach-en75xx/cpu.c | 95 ++++++++++++++++++ arch/mips/mach-en75xx/include/mach/en75xx.h | 103 ++++++++++++++++++++ 8 files changed, 431 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 +29 -0
@@ -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"
@@ -322,6 +343,14 @@ config MIPS_MACH_EARLY_INIT and at this stage the PC might not match the linking address (CONFIG_TEXT_BASE) - no absolute jump done until this call. +config MIPS_SKIP_CP0_COUNT_CLEAR + bool + help + Do not clear the CP0 Count register (mtc0 zero, CP0_COUNT) at reset + in arch/mips/cpu/start.S. On some SoCs the Count register is GIC/CM + backed and that write stalls the CPU; such targets select this. + Other MIPS targets keep the generic clear. + config MIPS_CACHE_SETUP bool "Allow generic start code to initialize and setup caches" default n if SKIP_LOWLEVEL_INIT
arch/mips/Makefile +2 -0
@@ -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
@@ -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 +100 -0
100 lines not on this page · raw message
arch/mips/mach-en75xx/Makefile new file +15 -0
@@ -0,0 +1,15 @@ +# 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 +endif +endif
arch/mips/mach-en75xx/cache.c new file +85 -0
85 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 +103 -0
103 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 2/9 mips: en75xx: add TPL and SPL early boot stages
In reply to AK SharmaAdd 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 doc/board/econet/en7528.rst for how to obtain it and its checksums.
--- 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 +++++++++++++ 6 files changed, 663 insertions(+) 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/early_sfc.c new file +352 -0
@@ -0,0 +1,352 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Minimal EN7512/EN7521 serial-flash reader used before driver model. +* Reconstructed from the vendor TCBoot move_data stage. +*/ + +#include <linux/bitops.h> +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/types.h> +#include <asm/io.h> +#include <mach/en75xx.h> + +#define SF_READ_IDLE_EN 0x004 +#define SF_MTX_MODE_TOG 0x014 +#define SF_RDCTL_FSM 0x018 +#define SF_MACMUX_SEL 0x01c +#define SF_MANUAL_EN 0x020 +#define SF_MANUAL_OPFIFO_EMPTY 0x024 +#define SF_MANUAL_OPFIFO_WDATA 0x028 +#define SF_MANUAL_OPFIFO_FULL 0x02c +#define SF_MANUAL_OPFIFO_WR 0x030 +#define SF_MANUAL_DFIFO_FULL 0x034 +#define SF_MANUAL_DFIFO_WDATA 0x038 +#define SF_MANUAL_DFIFO_EMPTY 0x03c +#define SF_MANUAL_DFIFO_RD 0x040 +#define SF_MANUAL_DFIFO_RDATA 0x044 +#define SF_SI_CK_SEL 0x09c +#define SF_STRAP 0x114 + +#define SF_STRAP_ADDR_4B BIT(0) +#define SF_STRAP_SPI_NAND BIT(1) +#define SF_STRAP_DUMMY_APPEND BIT(2) + +#define OP_CSH 0x00 +#define OP_CSL 0x01 +#define OP_CK 0x02 +#define OP_OUTS 0x08 +#define OP_INS 0x0c + +#define OP_SHIFT 9 +#define OP_CMD_MASK 0x1f +#define OP_LEN_MASK 0x1ff + +#define SPIN_LIMIT 1000000 +#define NAND_PAGE_SIZE 2048 +#define NOR_READ_CHUNK 1024 + +static inline void __iomem *sf_reg (u32 reg) +{ +return (void __iomem *)(EN75XX_SFC_BASE + reg); +} + +static int sf_wait_eq (u32 reg,u32 expected) +{ +unsigned int timeout =SPIN_LIMIT ; + +while (timeout--) { +if (__raw_readl (sf_reg (reg)) == expected) +return 0 ; + } + +return -ETIMEDOUT ; +} + +static int sf_op (u32 op,u32 len) +{ +u32 val = ((op &OP_CMD_MASK ) <<OP_SHIFT ) | (len &OP_LEN_MASK ); +int ret; + + ret =sf_wait_eq (SF_MANUAL_OPFIFO_FULL ,0 ); +if (ret) +return ret; + +__raw_writel (val,sf_reg (SF_MANUAL_OPFIFO_WDATA )); +__raw_writel (1 ,sf_reg (SF_MANUAL_OPFIFO_WR )); + +return sf_wait_eq (SF_MANUAL_OPFIFO_EMPTY ,1 ); +} + +static int sf_put_byte (u8 val) +{ +int ret =sf_wait_eq (SF_MANUAL_DFIFO_FULL ,0 ); + +if (ret) +return ret; + +__raw_writel (val,sf_reg (SF_MANUAL_DFIFO_WDATA )); +return 0 ; +} + +static int sf_put_bytes (const u8 *buf,size_t len) +{ +size_t i; +int ret; + +for (i =0 ; i < len; i++) { + ret =sf_put_byte (buf[i]); +if (ret) +return ret; + } + +return 0 ; +} + +static int sf_get_byte (u8 *val) +{ +int ret =sf_wait_eq (SF_MANUAL_DFIFO_EMPTY ,0 ); + +if (ret) +return ret; + + *val =__raw_readl (sf_reg (SF_MANUAL_DFIFO_RDATA )) &0xff ; +__raw_writel (1 ,sf_reg (SF_MANUAL_DFIFO_RD )); +return 0 ; +} + +static int sf_finish (void ) +{ +int ret; + + ret =sf_op (OP_CSH ,1 ); +if (ret) +return ret; + +return sf_op (OP_CK ,5 ); +} + +int en75xx_sfc_init (void ) +{ +int ret; + +__raw_writel (0x9 ,sf_reg (SF_SI_CK_SEL )); +__raw_writel (0 ,sf_reg (SF_READ_IDLE_EN )); + + ret =sf_wait_eq (SF_RDCTL_FSM ,0 ); +if (ret) +return ret; + +__raw_writel (0x9 ,sf_reg (SF_MTX_MODE_TOG )); +__raw_writel (1 ,sf_reg (SF_MACMUX_SEL )); +__raw_writel (1 ,sf_reg (SF_MANUAL_EN )); + +return 0 ; +} + +static int sf_nand_load_page (u32 page) +{ +u8 page_addr[] = { page >>16 , page >>8 , page }; +u8 status; +unsigned int timeout =SPIN_LIMIT ; +int ret; + + ret =sf_op (OP_CSL ,1 ); +if (ret) +return ret; + ret =sf_op (OP_OUTS ,1 ); +if (ret) +return ret; + ret =sf_put_byte (0x13 ); +if (ret) +return ret; + ret =sf_op (OP_OUTS ,ARRAY_SIZE (page_addr)); +if (ret) +return ret; + ret =sf_put_bytes (page_addr,ARRAY_SIZE (page_addr)); +if (ret) +return ret; + ret =sf_finish (); +if (ret) +return ret; + +while (timeout--) { + ret =sf_op (OP_CSL ,1 ); +if (ret) +return ret; + ret =sf_op (OP_OUTS ,1 ); +if (ret) +return ret; + ret =sf_put_byte (0x0f ); +if (ret) +return ret; + ret =sf_op (OP_OUTS ,1 ); +if (ret) +return ret; + ret =sf_put_byte (0xc0 ); +if (ret) +return ret; + ret =sf_op (OP_INS ,1 ); +if (ret) +return ret; + ret =sf_get_byte (&status); +if (ret) +return ret; + ret =sf_finish (); +if (ret) +return ret; +if (!(status &BIT (0 ))) +return 0 ; + } + +return -ETIMEDOUT ; +} + +static int sf_nand_read_cache (u32 column,u8 *dst,size_t len, +bool dummy_append) +{ +u8 address[3 ]; +size_t i; +int ret; + +if (dummy_append) { + address[0 ] = column >>8 ; + address[1 ] = column; + address[2 ] =0 ; + }else { + address[0 ] =0 ; + address[1 ] = column >>8 ; + address[2 ] = column; + } + + ret =sf_op (OP_CSL ,1 ); +if (ret) +return ret; + ret =sf_op (OP_OUTS ,1 ); +if (ret) +return ret; + ret =sf_put_byte (0x03 ); +if (ret) +return ret; + ret =sf_op (OP_OUTS ,ARRAY_SIZE (address)); +if (ret) +return ret; + ret =sf_put_bytes (address,ARRAY_SIZE (address)); +if (ret) +return ret; + +for (i =0 ; i < len; i++) { + ret =sf_op (OP_INS ,1 ); +if (ret) +return ret; + ret =sf_get_byte (&dst[i]); +if (ret) +return ret; + } + +return sf_finish (); +} + +static int sf_nor_read_once (u32 offset,u8 *dst,size_t len,bool addr4b, +bool dummy_append) +{ +u8 address[4 ]; +size_t addr_len =0 ; +size_t i; +int ret; + +if (addr4b) + address[addr_len++] = offset >>24 ; +if (dummy_append) { + address[addr_len++] = offset >>8 ; + address[addr_len++] = offset; + address[addr_len++] =0 ; + }else { + address[addr_len++] = offset >>16 ; + address[addr_len++] = offset >>8 ; + address[addr_len++] = offset; + } + + ret =sf_op (OP_CSL ,1 ); +if (ret) +return ret; + ret =sf_op (OP_OUTS ,1 ); +if (ret) +return ret; + ret =sf_put_byte (0x03 ); +if (ret) +return ret; + + ret =sf_op (OP_OUTS , addr_len); +if (ret) +return ret; + ret =sf_put_bytes (address, addr_len); +if (ret) +return ret; + +for (i =0 ; i < len; i++) { + ret =sf_op (OP_INS ,1 ); +if (ret) +return ret; + ret =sf_get_byte (&dst[i]); +if (ret) +return ret; + } + +return sf_finish (); +} + +static int sf_nor_read (u32 offset,u8 *dst,size_t len,bool addr4b, +bool dummy_append) +{ +while (len) { +size_t chunk =NOR_READ_CHUNK - (offset %NOR_READ_CHUNK ); +int ret; + +if (chunk > len) + chunk = len; + ret =sf_nor_read_once (offset, dst, chunk, addr4b, + dummy_append); +if (ret) +return ret; + offset += chunk; + dst += chunk; + len -= chunk; + } + +return 0 ; +} + +int en75xx_sfc_read (u32 offset,void *dst,size_t len) +{ +u32 strap =__raw_readl (sf_reg (SF_STRAP )); +u8 *buf = dst; +int ret; + +if (!(strap &SF_STRAP_SPI_NAND )) +return sf_nor_read (offset, buf, len, strap &SF_STRAP_ADDR_4B , + strap &SF_STRAP_DUMMY_APPEND ); + +while (len) { +u32 page = offset /NAND_PAGE_SIZE ; +u32 column = offset %NAND_PAGE_SIZE ; +size_t chunk =NAND_PAGE_SIZE - column; + +if (chunk > len) + chunk = len; + + ret =sf_nand_load_page (page); +if (ret) +return ret; + ret =sf_nand_read_cache (column, buf, chunk, + strap &SF_STRAP_DUMMY_APPEND ); +if (ret) +return ret; + + offset += chunk; + buf += chunk; + len -= chunk; + } + +return 0 ; +}
arch/mips/mach-en75xx/spl/Makefile new file +2 -0
@@ -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
@@ -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
PATCH v2 3/9 serial: en75xx: add EcoNet/Airoha EN75xx UART driver
In reply to AK SharmaAdd a DM serial driver for the 16550-style UART on the EcoNet/Airoha EN75xx SoCs. The block uses a fractional (X/Y) baud-rate divider rather than the classic DLL/DLM divisor, and is accessed big-endian on the EN7512/EN7521 and little-endian on the EN7528; the driver handles both.
--- 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
@@ -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
@@ -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
PATCH v2 4/9 spi: airoha-snfi: add EN75xx SPI-NAND controller support
In reply to AK SharmaExtend the existing Airoha SNFI serial-NAND controller driver to the EN75xx family: the big-endian EN7512/EN7521/EN751221 and the little-endian EN7528. This adds the family match, the controller bring-up for these parts, and the uncached (CKSEG1) DMA cache-window handling the EN7528 needs for the dirmap transfer buffer.
--- drivers/spi/Kconfig | 3 +- drivers/spi/airoha_snfi_spi.c | 412 +++++++++++++++++++++++++++------- 2 files changed, 339 insertions(+), 76 deletions(-)
drivers/spi/Kconfig +2 -1
@@ -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 +337 -75
641 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 5/9 net: airoha-eth: add EN7528 Ethernet support
In reply to AK SharmaExtend the existing Airoha GDM Ethernet driver to support the EN7528: add the SoC match, the frame-engine and GDMA/QDMA descriptor-ring setup, the MAC initialisation and the wiring to the embedded gigabit switch (MT7530) and its PHYs, so the port comes up and can run DHCP/TFTP/ping.
--- drivers/net/Kconfig | 8 +- drivers/net/airoha_eth.c | 850 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 807 insertions(+), 51 deletions(-)
drivers/net/Kconfig +4 -4
@@ -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
Signature · 1 line
2.53.0
PATCH v2 6/9 mips: dts: add EcoNet EN75xx device trees
In reply to AK SharmaAdd the device trees for the EN7512 and EN7528 reference boards and the EN7528 RAM-boot variant.
These device trees are not yet in the Linux kernel; the bindings and device trees will be submitted to the kernel and kept in sync with U-Boot.
--- 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 | 154 ++++++++++++++++++ 9 files changed, 494 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
@@ -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
@@ -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
@@ -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
@@ -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 +154 -0
154 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 7/9 board: econet: add EN7512 reference board
In reply to AK SharmaAdd 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 | 90 ++++++++++++++++++++++++++++++ doc/board/econet/en7512.rst | 66 ++++++++++++++++++++++ include/configs/en7512.h | 8 +++ 6 files changed, 208 insertions(+) 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
@@ -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
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0+ +obj-y += board.o
board/econet/en7512/board.c new file +34 -0
@@ -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 +90 -0
90 lines not on this page · raw message
doc/board/econet/en7512.rst new file +66 -0
66 lines not on this page · raw message
include/configs/en7512.h new file +8 -0
@@ -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
PATCH v2 8/9 board: econet: add EN7528 board support
In reply to AK SharmaAdd the EcoNet EN7528 board: board glue, the reference and RAM defconfigs, and the board header.
--- board/econet/en7528/MAINTAINERS | 13 +++++++++ board/econet/en7528/Makefile | 2 ++ board/econet/en7528/board.c | 37 +++++++++++++++++++++++++ configs/en7528_ram_defconfig | 43 ++++++++++++++++++++++++++++++ configs/en7528_reference_defconfig | 38 ++++++++++++++++++++++++++ include/configs/en7528.h | 9 +++++++ 6 files changed, 142 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 configs/en7528_ram_defconfig create mode 100644 configs/en7528_reference_defconfig create mode 100644 include/configs/en7528.h
board/econet/en7528/MAINTAINERS new file +13 -0
@@ -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: doc/board/econet/en7528.rst +F: doc/board/econet/index.rst +F: drivers/serial/serial_en75xx.c +F: include/configs/en7528.h +N: en75xx +N: en7528
board/econet/en7528/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0+ +obj-y += board.o
board/econet/en7528/board.c new file +37 -0
@@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <dm.h> +#include <init.h> +#include <asm/io.h> +#include <linux/bitops.h> +#include <linux/delay.h> +#include <linux/errno.h> +#include <stdio.h> + +#if CONFIG_IS_ENABLED (AIROHA_ETH ) +extern U_BOOT_DRIVER (airoha_eth); +#endif + +int board_init (void ) +{ +return 0 ; +} + +int board_late_init (void ) +{ +#if CONFIG_IS_ENABLED (AIROHA_ETH ) +struct udevice *dev; +int ret; + +/* +* Probe the EN751221-family Ethernet parent after the console is up and +* just before initr_net() enumerates UCLASS_ETH devices (mirrors the +* EN7512 reference board). +*/ + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_DRIVER_GET (airoha_eth), &dev); +if (ret && ret != -ENODEV ) +printf ("EN7528 Ethernet probe failed: %d\n" , ret); +#endif +return 0 ; +}
configs/en7528_ram_defconfig new file +43 -0
43 lines not on this page · raw message
configs/en7528_reference_defconfig new file +38 -0
@@ -0,0 +1,38 @@ +CONFIG_MIPS=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_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_SYS_LITTLE_ENDIAN=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_SPL_OF_CONTROL=y +CONFIG_SPL_DM=y
include/configs/en7528.h new file +9 -0
@@ -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
PATCH v2 9/9 doc: board: econet: add EN75xx documentation
In reply to AK SharmaAdd the EcoNet documentation index and the EN7528 board documentation.
--- doc/board/econet/en7528.rst | 66 +++++++++++++++++++++++++++++++++++++ doc/board/econet/index.rst | 10 ++++++ doc/board/index.rst | 1 + 3 files changed, 77 insertions(+) create mode 100644 doc/board/econet/en7528.rst create mode 100644 doc/board/econet/index.rst
doc/board/econet/en7528.rst new file +66 -0
@@ -0,0 +1,66 @@ +.. 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 +----- + +The RAM / chainloaded build has no external dependency: + +.. code-block:: bash + + make en7528_ram_defconfig + make CROSS_COMPILE=mipsel-linux- + +The reference board additionally packages the vendor DDR calibration blob +(see below). Build it with ``BINMAN_ALLOW_MISSING=1`` when the blob is not +present: + +.. code-block:: bash + + make en7528_reference_defconfig + make CROSS_COMPILE=mipsel-linux- BINMAN_ALLOW_MISSING=1 + +Defconfigs +---------- + +- ``en7528_reference_defconfig`` - reference board (DASAN H660GM-A) +- ``en7528_ram_defconfig`` - RAM / chainloaded build + +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 the 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 the +DDR blob offset. The reference-board binman image expects it as +``arch/mips/mach-en75xx/en7528_ddr.bin`` (``en7512_ddr.bin`` for the +EN7512 reference board). + +Expected images: + +- EN7512 / EN7521: 20336 bytes, + 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.
doc/board/econet/index.rst new file +10 -0
@@ -0,0 +1,10 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +EcoNet/Airoha +============= + +.. toctree:: + :maxdepth: 2 + + en7512 + en7528
doc/board/index.rst +1 -0
@@ -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