#include <zephyr/dt-bindings/memory-attr/memory-attr.h>

&pinctrl {
	sqspi_default: sqspi_default {
		group1 {
			psels = <NRF_PSEL(SDP_MSPI_SCK, 2, 1)>,
				<NRF_PSEL(SDP_MSPI_CS0, 2, 5)>,
				<NRF_PSEL(SDP_MSPI_DQ0, 2, 2)>;
			nordic,drive-mode = <NRF_DRIVE_E0E1>;
		};
		group2 {
			psels = <NRF_PSEL(SDP_MSPI_DQ1, 2, 4)>,
				<NRF_PSEL(SDP_MSPI_DQ2, 2, 3)>,
				<NRF_PSEL(SDP_MSPI_DQ3, 2, 0)>;
			nordic,drive-mode = <NRF_DRIVE_E0E1>;
			bias-pull-up;
		};
	};

	sqspi_sleep: sqspi_sleep {
		group1 {
			low-power-enable;
			psels = <NRF_PSEL(SDP_MSPI_SCK, 2, 1)>,
				<NRF_PSEL(SDP_MSPI_CS0, 2, 5)>,
				<NRF_PSEL(SDP_MSPI_DQ0, 2, 2)>,
				<NRF_PSEL(SDP_MSPI_DQ1, 2, 4)>,
				<NRF_PSEL(SDP_MSPI_DQ2, 2, 3)>,
				<NRF_PSEL(SDP_MSPI_DQ3, 2, 0)>;
		};
	};
};

&cpuflpr_vpr {
	pinctrl-0 = <&sqspi_default>;
	pinctrl-1 = <&sqspi_sleep>;
	pinctrl-names = "default", "sleep";
	interrupts = <76 NRF_DEFAULT_IRQ_PRIORITY>;
	status = "okay";
};

/ {
	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		softperipheral_ram: memory@2003c000 {
			compatible = "zephyr,memory-region";
			reg = <0x2003c000 0x4000>;
			ranges = <0 0x2003c000 0x4000>;
			#address-cells = <1>;
			#size-cells = <1>;
			#memory-region-cells = <0>;
			zephyr,memory-region = "SOFTPERIPHERAL_RAM";
			zephyr,memory-attr = <DT_MEM_DMA>;

			sqspi: sqspi@3b40 {
				compatible = "nordic,nrf-sqspi";
				#address-cells = <1>;
				#size-cells = <0>;
				reg = <0x3b40 0x200>;
				status = "okay";
				zephyr,pm-device-runtime-auto;
				memory-regions = <&softperipheral_ram>;
			};
		};
	};
};

/delete-node/ &mx25r64;

&sqspi {
	mx25r64: mx25r6435f@0 {
		compatible = "mxicy,mx25r", "jedec,mspi-nor";
		status = "okay";
		reg = <0>;
		jedec-id = [c2 28 17];
		quad-enable-requirements = "S1B6";
		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>;
		t-reset-pulse = <10000>;
		t-reset-recovery = <35000>;
		mspi-max-frequency = <DT_FREQ_M(8)>;
		mspi-io-mode = "MSPI_IO_MODE_QUAD_1_4_4";
		mspi-data-rate = "MSPI_DATA_RATE_SINGLE";
		mspi-hardware-ce-num = <1>;
		mspi-cpp-mode = "MSPI_CPP_MODE_0";
		mspi-endian = "MSPI_BIG_ENDIAN";
		mspi-ce-polarity = "MSPI_CE_ACTIVE_LOW";
	};
};

&mx25r64 {
	status = "okay";
};
