nrf5340 - Multi QSPI Flash chip models.

I'm working on nRF5340 custom platform (NCS 2.6.1, Zephyr 3.5.99).
I use MCUBoot immutable bootloader and external QSPI NOR Flash for slot-1 partition during DFU.

This is my working dts overlay configuration for flash model EN25QH64

/ {
	aliases {
		spi-flash0 = &en25qh64;
	};

	chosen {
		nordic,pm-ext-flash = &en25qh64;
	};
};

&qspi {
	en25qh64: en25qh64@0 {
		compatible = "nordic,qspi-nor";
		reg = <0>;
		sck-frequency = <8000000>;
		jedec-id = [1c 70 17];
		sfdp-bfp = [e5 20 fb ff 00 ff ff 03 44 eb 08 6b 08 3b 04 bb 04];
		size = <67108864>;
		has-dpd;
		t-enter-dpd = <10000>;
		t-exit-dpd = <35000>;
		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;
			data_partition: partition@0 {
				label = "data";
				reg = <0x000000000 0x000100000>;
			};
			en25qh64_slot1_partition: partition@100000 {
				label = "image-1";
				reg = <0x000100000 0x0001ac000>;
			};
		};  
	};
};

On the board I can replace the chip model with MX25R6435F. In this case the working overlay is

/ {
	aliases {
		spi-flash0 = &mx25r64;
	};

	chosen {
		nordic,pm-ext-flash = &mx25r64;
	};
};

&qspi {
    mx25r64: mx25r6435f@0 {
		compatible = "nordic,qspi-nor";
		reg = <0>;
		sck-frequency = <8000000>;
		jedec-id = [c2 28 17];
        sfdp-bfp = [
            e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
            ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
            10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
            30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
        ];
		size = <67108864>;
		has-dpd;
		t-enter-dpd = <10000>;
		t-exit-dpd = <35000>;
		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;
			data_partition: partition@0 {
				label = "data";
				reg = <0x000000000 0x000100000>;
			};
			slot1_partition: partition@100000 {
				label = "image-1";
				reg = <0x000100000 0x0001ac000>;
			};
		};  
	};
};

The question is, can I define a unified configuration for both the EN25QH64A and MX25R6435F flash devices in the devicetree overlay ?
At runtime, the firmware should be able to detect which flash is present (for example, by reading the JEDEC ID) and use the appropriate device.

Thank you.

Related