diff --git a/board/adi/ev-sc598-som/nand.cfg b/board/adi/ev-sc598-som/nand.cfg new file mode 100644 index 0000000..ad5f65a --- /dev/null +++ b/board/adi/ev-sc598-som/nand.cfg @@ -0,0 +1,40 @@ +# Micron 8Gb (1GB) SPI NAND flash +# Model: MT29F8G01ADAFD12-AAT:F +# Datasheet: https://www.micron.com/content/dam/micron/global/secure/products/data-sheet/nand-flash/70-series/m70a-4-8gb-nand-spi-auto.pdf +# Label: U4 +flash nand-1G { + pebsize = 256K + numpebs = 4096 + minimum-io-unit-size = 4096 + sub-page-size = 4096 + vid-header-offset = 4096 +} + +image nand.img { + flash {} + flashtype = "nand-1G" + + partition u-boot-spl { + image = "u-boot-spl.ldr" + size = 256K + } + + partition u-boot { + image = "u-boot.ldr" + size = 768K + } + + partition dtb { + image = "sc598-som-nand.dtb" + size = 256K + } + + partition kernel { + image = "Image" + size = 32M + } + + partition rootfs { + image = "rootfs.ubi" + } +} diff --git a/board/adi/ev-sc598-som/patches/linux/dts/adi/sc598-som-nand.dts b/board/adi/ev-sc598-som/patches/linux/dts/adi/sc598-som-nand.dts new file mode 100644 index 0000000..117b9dd --- /dev/null +++ b/board/adi/ev-sc598-som/patches/linux/dts/adi/sc598-som-nand.dts @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2026 Analog Devices Incorporated + */ + +/dts-v1/; + +#include "sc598-som-revE.dtsi" + +/ { + model = "ADI SC598-SOM with NAND"; + compatible = "adi,sc598-som-nand", "adi,sc59x-64"; +}; + +/* + * Clock configuration for faster SPI NAND performance. + * + * Default SPI clock sources (sclk0_0, oclk_0) are both 62.5 MHz, limiting + * SPI speed. Reconfigure oclk_0 to 250 MHz instead of using sclk0_0 + * because sclk0_0 is shared by UARTs, I2C, timers, watchdog, and Ethernet. + * + * CGU0_ODIV: 1000 MHz / 4 = 250 MHz (was / 16 = 62.5 MHz) + * SPI_SEL: Use oclk_0 as SPI parent + * EMMC_SEL: Switch eMMC to dclk_0_half (eMMC defaults to oclk_0, which + * would break it at 250 MHz - "Internal clock never stabilised") + * + * time nanddump /dev/mtd4 -l 1048576 -f /dev/null + * ~21 MHz (original): 0.24s (~4.4 MB/s) + * 62.5 MHz: 0.20s (~5.2 MB/s) + * 83.3 MHz: 0.19s (~5.5 MB/s) + * 125 MHz: probe failed (ID reads 0xffffffff) + */ +&clk { + assigned-clocks = <&clk ADSP_SC598_CLK_CGU0_ODIV>, <&clk ADSP_SC598_CLK_SPI_SEL>, <&clk ADSP_SC598_CLK_EMMC_SEL>; + assigned-clock-rates = <250000000>, <0>, <0>; + assigned-clock-parents = <0>, <&clk ADSP_SC598_CLK_CGU0_OCLK>, <&clk ADSP_SC598_CLK_DCLK0_HALF>; +}; + +&mmc0 { + status = "disabled"; +}; + +&spi2 { + /delete-node/ is25lp01g@0; + + som_flash: spi-nand@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "micron,mt29f1g01abafd", "spi-nand"; + reg = <0>; + spi-max-frequency = <83000000>; + spi-rx-bus-width = <4>; + spi-tx-bus-width = <4>; + nand-ecc-mode = "on-die"; + nand-ecc-strength = <1>; + nand-ecc-step-size = <512>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot-spl"; + reg = <0x0 0x40000>; + }; + + partition@40000 { + label = "u-boot"; + reg = <0x40000 0xC0000>; + }; + + partition@100000 { + label = "dtb"; + reg = <0x100000 0x40000>; + }; + + partition@140000 { + label = "kernel"; + reg = <0x140000 0x2000000>; + }; + + partition@2140000 { + label = "rootfs"; + reg = <0x2140000 0x3DEC0000>; + }; + }; + }; +}; diff --git a/board/adi/ev-sc598-som/patches/linux/nand.fragment b/board/adi/ev-sc598-som/patches/linux/nand.fragment new file mode 100644 index 0000000..613e448 --- /dev/null +++ b/board/adi/ev-sc598-som/patches/linux/nand.fragment @@ -0,0 +1,2 @@ +CONFIG_MTD_SPI_NAND=y +CONFIG_MTD_UBI=y diff --git a/board/adi/ev-sc598-som/patches/uboot/dts/sc598-som-nand.dts b/board/adi/ev-sc598-som/patches/uboot/dts/sc598-som-nand.dts new file mode 100644 index 0000000..3d85b99 --- /dev/null +++ b/board/adi/ev-sc598-som/patches/uboot/dts/sc598-som-nand.dts @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2026 Analog Devices Incorporated + */ + +/dts-v1/; + +#include "sc598-som-revE.dtsi" + +/ { + model = "ADI SC598-SOM with NAND"; + compatible = "adi,sc598-som-nand", "adi,sc59x-64"; +}; + +&spi2 { + /delete-node/ is25lp01g@1; + + som_flash: spi-nand@1 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "spi-nand"; + reg = <1>; + spi-max-frequency = <25000000>; + spi-rx-bus-width = <4>; + spi-tx-bus-width = <4>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot-spl"; + reg = <0x0 0x40000>; + }; + + partition@40000 { + label = "u-boot"; + reg = <0x40000 0xC0000>; + }; + + partition@100000 { + label = "dtb"; + reg = <0x100000 0x40000>; + }; + + partition@140000 { + label = "kernel"; + reg = <0x140000 0x2000000>; + }; + + partition@2140000 { + label = "rootfs"; + reg = <0x2140000 0x3DEC0000>; + }; + }; + }; +}; diff --git a/board/adi/ev-sc598-som/patches/uboot/nand.fragment b/board/adi/ev-sc598-som/patches/uboot/nand.fragment new file mode 100644 index 0000000..552a5e3 --- /dev/null +++ b/board/adi/ev-sc598-som/patches/uboot/nand.fragment @@ -0,0 +1,4 @@ +CONFIG_DEFAULT_DEVICE_TREE="sc598-som-nand" +CONFIG_DM_MTD=y +CONFIG_MTD_SPI_NAND=y +CONFIG_SUPPORT_RAW_INITRD=y diff --git a/configs/adi_sc598_nand.fragment b/configs/adi_sc598_nand.fragment new file mode 100644 index 0000000..4ad778f --- /dev/null +++ b/configs/adi_sc598_nand.fragment @@ -0,0 +1,9 @@ +BR2_LINUX_KERNEL_INTREE_DTS_NAME="adi/sc598-som-nand" +BR2_LINUX_KERNEL_CUSTOM_DTS_DIR="$(BR2_EXTERNAL)/board/adi/ev-sc598-som/patches/linux/dts/" +BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL)/board/adi/ev-sc598-som/patches/linux/nand.fragment" +BR2_TARGET_UBOOT_CUSTOM_DTS_PATH="$(BR2_EXTERNAL)/board/adi/ev-sc598-som/patches/uboot/dts/sc598-som-nand.dts" +BR2_TARGET_UBOOT_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL)/board/adi/ev-sc598-som/patches/uboot/nand.fragment" +BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS="-c $(BR2_EXTERNAL)/board/adi/ev-sc598-som/nand.cfg" +# BR2_TARGET_ROOTFS_EXT2 is not set +BR2_TARGET_ROOTFS_CPIO=y +BR2_TARGET_ROOTFS_CPIO_GZIP=y