Re: [PATCH v3 01/15] ARM: mvebu: add Netgear RN102 support

"Sascha Hauer" <[email protected]> Mon, 03 Aug 2026 12:53:04 +0000
Newsgroups org.infradead.lists.barebox
Message-ID <[email protected]>
On 2026-08-02 15:16, Luca Lauro via B4 Relay wrote:
> From: Luca Lauro <[email protected]>
>=20
> This adds full support for the Netgear ReadyNAS 102, including:
>=20
>  - board driver matching on "netgear,rn102"
>  - lowlevel initialization
>  - barebox overlay with environment, state backend and
> 	NAND partition layout
>  - Kconfig entry
>  - image support
>=20
> Signed-off-by: Luca Lauro <[email protected]>
> ---
>  arch/arm/boards/Makefile                 |   1 +
>  arch/arm/boards/netgear-rn102/Makefile   |   4 +
>  arch/arm/boards/netgear-rn102/board.c    | 243 +++++++++++++++++++++++++=
++++++
>  arch/arm/boards/netgear-rn102/lowlevel.c |  58 ++++++++
>  arch/arm/dts/Makefile                    |   1 +
>  arch/arm/dts/armada-370-rn102-bb.dts     |  82 +++++++++++
>  arch/arm/mach-mvebu/Kconfig              |   4 +
>  images/Makefile.mvebu                    |  10 ++
>  8 files changed, 403 insertions(+)
>=20
> diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
> index dd2f2c324e..aca1b45a81 100644
> --- a/arch/arm/boards/Makefile
> +++ b/arch/arm/boards/Makefile
> @@ -64,6 +64,7 @@ obj-$(CONFIG_MACH_MARVELL_ARMADA_XP_DB)		+=3D marvell-a=
rmada-xp-db/
>  obj-$(CONFIG_MACH_MX23EVK)			+=3D freescale-mx23-evk/
>  obj-$(CONFIG_MACH_MX28EVK)			+=3D freescale-mx28-evk/
>  obj-$(CONFIG_MACH_MYIRTECH_X335X)		+=3D myirtech-x335x/
> +obj-$(CONFIG_MACH_NETGEAR_RN102)		+=3D netgear-rn102/
>  obj-$(CONFIG_MACH_NETGEAR_RN104)		+=3D netgear-rn104/
>  obj-$(CONFIG_MACH_NETGEAR_RN2120)		+=3D netgear-rn2120/
>  obj-$(CONFIG_MACH_NVIDIA_BEAVER)		+=3D nvidia-beaver/
> diff --git a/arch/arm/boards/netgear-rn102/Makefile b/arch/arm/boards/net=
gear-rn102/Makefile
> new file mode 100644
> index 0000000000..da63d2625f
> --- /dev/null
> +++ b/arch/arm/boards/netgear-rn102/Makefile
> @@ -0,0 +1,4 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +obj-y +=3D board.o
> +lwl-y +=3D lowlevel.o
> diff --git a/arch/arm/boards/netgear-rn102/board.c b/arch/arm/boards/netg=
ear-rn102/board.c
> new file mode 100644
> index 0000000000..dba3d11518
> --- /dev/null
> +++ b/arch/arm/boards/netgear-rn102/board.c
> @@ -0,0 +1,243 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <common.h>
> +#include <init.h>
> +#include <gpio.h>
> +#include <driver.h>
> +#include <of.h>
> +#include <linux/device.h>
> +#include <linux/mbus.h>
> +#include <mach/mvebu/armada-370-xp-regs.h>
> +#include <bbu.h>
> +
> +/*
> + *  Early GPIO0 MMIO
> + *
> + * GPIO driver arrives too late for the disks to be
> + * ready in time for AHCI driver probe.

barebox supports deep probe which means the devices are made available
once needed or requested. Provided your dts carries the
barebox,deep-probe property you can do this:

of_device_ensure_probed_by_alias("gpio0");
of_device_ensure_probed_by_alias("gpio1");
of_device_ensure_probed_by_alias("gpio2");

>From that on the GPIO driver should be probed and you can use it.

It shouldn't be necessary to duplicate the GPIO driver here.

> +/*
> + * RN102 board driver
> + *
> + * Preferred pattern: board-specific code as a platform driver
> + * matching on the root DT node ("netgear,rn102").
> + */
> +static int rn102_probe(struct device *dev)
> +{
> +	/* CFU configuration */
> +	writel(0xC6, 0xf1020228);
> +
> +	setup_usb0();
> +	setup_bays();
> +	init_disks();
> +
> +	/* Barebox Update handlers */
> +	bbu_register_std_file_update("bootloader", 0,
> +					 "/dev/nand0.bootloader",
> +					 filetype_kwbimage_v1);
> +
> +	bbu_register_std_file_update("kernel", 0,
> +					 "/dev/nand0.kernel",
> +					 filetype_arm_zimage);
> +
> +	bbu_register_std_file_update("minirootfs", 0,
> +					 "/dev/nand0.minirootfs",
> +					 filetype_gzip);

That is a creative use of barebox update handlers. They are designed for
updating barebox itself, not arbitrary other components.

I must think about this.

> +
> +	return 0;
> +}
> +
> +static const struct of_device_id rn102_of_match[] =3D {
> +	{ .compatible =3D "netgear,rn102" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, rn102_of_match);
> +
> +static struct driver rn102_driver =3D {
> +	.name =3D "rn102",
> +	.probe =3D rn102_probe,
> +	.of_match_table =3D rn102_of_match,
> +};
> +
> +device_platform_driver(rn102_driver);
> diff --git a/arch/arm/boards/netgear-rn102/lowlevel.c b/arch/arm/boards/n=
etgear-rn102/lowlevel.c
> new file mode 100644
> index 0000000000..c1680cee82
> --- /dev/null
> +++ b/arch/arm/boards/netgear-rn102/lowlevel.c
> @@ -0,0 +1,58 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <common.h>
> +#include <asm/barebox-arm.h>
> +#include <mach/mvebu/lowlevel.h>
> +#include <mach/mvebu/barebox-arm-head.h>
> +#include <mach/mvebu/armada-370-xp-regs.h>
> +
> +extern char __dtb_armada_370_rn102_bb_start[];
> +
> +#define INTERNAL_REG_BASE_ADDR	0x20080
> +
> +static __always_inline void mvebu_remap_registers(void)
> +{
> +	void __iomem *base =3D mvebu_get_initial_int_reg_base();
> +
> +	writel(MVEBU_REMAP_INT_REG_BASE, base + INTERNAL_REG_BASE_ADDR);
> +}
> +
> +/*
> + * NOTE:
> + * armada_370_xp_barebox_entry() cannot be used here because the
> + * upstream SDRAM size detection for Armada 370-XP misinterprets
> + * the DDR_SIZE_CSn registers on this board and reports an incorrect
> + * memory size (256MB instead of 512MB on RN102).
> + *
> + * Until the generic detection code is fixed, we compute the SDRAM
> + * size manually using the DDR_SIZE_CSn values.
> + */
> +static unsigned long armada_370_xp_memory_find(void)
> +{
> +	unsigned long mem_size =3D 0;
> +
> +	for (int cs =3D 0; cs < 4; cs++) {
> +		u32 ctrl =3D readl(ARMADA_370_XP_SDRAM_BASE + DDR_SIZE_CSn(cs));
> +
> +		/* Skip non-enabled CS */
> +		if ((ctrl & DDR_SIZE_ENABLED) !=3D DDR_SIZE_ENABLED)
> +			continue;
> +
> +		mem_size +=3D (ctrl | ~DDR_SIZE_MASK) + 1;
> +	}
> +
> +	return mem_size;
> +}
> +
> +ENTRY_FUNCTION_MVEBU(start_netgear_rn102, r0, r1, r2)
> +{
> +	void *fdt;
> +
> +	arm_cpu_lowlevel_init();
> +
> +	fdt =3D __dtb_armada_370_rn102_bb_start +
> +		get_runtime_offset();
> +
> +	mvebu_remap_registers();
> +	barebox_arm_entry(0, armada_370_xp_memory_find(), fdt);
> +}
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index a84e09e388..5d1b21b615 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -51,6 +51,7 @@ lwl-$(CONFIG_MACH_MARVELL_ARMADA_XP_GP) +=3D armada-xp-=
gp-bb.dtb.o
>  lwl-$(CONFIG_MACH_MARVELL_ARMADA_XP_DB) +=3D armada-xp-db-bb.dtb.o
>  lwl-$(CONFIG_MACH_MX28EVK) +=3D imx28-evk.dtb.o
>  lwl-$(CONFIG_MACH_MYIRTECH_X335X) +=3D am335x-myirtech-myd.dtb.o am335x-=
myirtech-myd-mlo.dtb.o
> +lwl-$(CONFIG_MACH_NETGEAR_RN102) +=3D armada-370-rn102-bb.dtb.o
>  lwl-$(CONFIG_MACH_NETGEAR_RN104) +=3D armada-370-rn104-bb.dtb.o
>  lwl-$(CONFIG_MACH_NETGEAR_RN2120) +=3D armada-xp-rn2120-bb.dtb.o
>  lwl-$(CONFIG_MACH_NITROGEN6) +=3D imx6q-nitrogen6x.dtb.o imx6dl-nitrogen=
6x.dtb.o imx6qp-nitrogen6_max.dtb.o
> diff --git a/arch/arm/dts/armada-370-rn102-bb.dts b/arch/arm/dts/armada-3=
70-rn102-bb.dts
> new file mode 100644
> index 0000000000..47064cb11a
> --- /dev/null
> +++ b/arch/arm/dts/armada-370-rn102-bb.dts
> @@ -0,0 +1,82 @@
> +/*
> + * Barebox specific DT overlay for Netgear ReadyNAS 102
> + */
> +
> +#include "arm/marvell/armada-370-netgear-rn102.dts"
> +
> +/ {
> +	chosen {
> +		stdout-path =3D &uart0;
> +	};
> +
> +	aliases {
> +		state =3D &state_nand;
> +	};
> +
> +	/* configure nand partition to store barebox environment */
> +	environment {
> +		compatible =3D "barebox,environment";
> +		device-path =3D &nand_controller, "partname:environment";
> +	};
> +
> +	/* configure nand partition to store barebox-state backend */
> +	state_nand: nand_state_memory {
> +		#address-cells =3D <1>;
> +		#size-cells =3D <1>;
> +		compatible =3D "barebox,state";
> +		magic =3D <0xab67421f>;
> +		backend-type =3D "raw";
> +		backend =3D <&backend_state_nand>;
> +		backend-storage-type =3D "circular";
> +		backend-stridesize =3D <32>;
> +
> +		variable@0 {
> +			reg =3D <0x0 0x1>;
> +			type =3D "uint8";
> +			default =3D <0x1>;
> +		};
> +	};
> +};
> +
> +&nand_controller {
> +	compatible =3D "marvell,armada370-nand", "marvell,pxa3xx-nand";
> +	status =3D "okay";
> +
> +	nand-rb =3D <0>;
> +	marvell,nand-keep-config;
> +	nand-on-flash-bbt;
> +
> +	nand-ecc-strength =3D <4>;
> +	nand-ecc-step-size =3D <512>;

Please drop all the properties that are already in the upstram dts.

Sascha

--
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |