Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support Flash QSPI on S32Z270 #78073

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion boards/nxp/mr_canhubk3/mr_canhubk3.dts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 NXP
* Copyright 2023-2024 NXP
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -344,6 +344,8 @@
readoc = "1-4-4";
writeoc = "1-4-4";
has-32k-erase;
max-program-buffer-size = <256>;
write-block-size = <1>;
status = "okay";

partitions {
Expand Down
8 changes: 8 additions & 0 deletions boards/nxp/s32z2xxdc2/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ The boards support the following hardware features:
+-----------+------------+-------------------------------------+
| DSPI | on-chip | spi |
+-----------+------------+-------------------------------------+
| QSPI | on-chip | flash |
+-----------+------------+-------------------------------------+

Other hardware features are not currently supported by the port.

Expand Down Expand Up @@ -170,6 +172,12 @@ EDMA
The EDMA modules feature four EDMA3 instances: Instance 0 with 32 channels,
and instances 1, 4, and 5, each with 16 channels.

External Flash
==============

The on-board S26HS512T 512M-bit HyperFlash memory is connected to the QSPI controller
port A1. This board configuration selects it as the default flash controller.

Programming and Debugging
*************************

Expand Down
67 changes: 67 additions & 0 deletions boards/nxp/s32z2xxdc2/s32z2xxdc2_s32z270.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include "s32z2xxdc2_s32z270_pinctrl.dtsi"
#include <zephyr/dt-bindings/qspi/nxp-s32-qspi.h>

&swt0 {
status = "okay";
Expand Down Expand Up @@ -58,3 +59,69 @@
&sar_adc1 {
vref-mv = <1800>;
};

&qspi0 {
pinctrl-0 = <&qspi0_default>;
pinctrl-names = "default";
data-rate = "DDR";
column-space = <3>;
word-addressable;
hold-time-2x;
a-dll-freq-enable;
a-dll-ref-counter = <2>;
a-dll-resolution = <2>;
a-dll-coarse-delay = <2>;
a-dll-fine-delay = <2>;
a-dll-mode = "AUTO UPDATE";
a-rx-clock-source = "EXTERNAL DQS";
ahb-buffers-masters = <0 1 2 3>;
ahb-buffers-sizes = <256 256 256 256>;
ahb-buffers-all-masters;
status = "okay";

sfp_mdad {
compatible = "nxp,s32-qspi-sfp-mdad";

mdad_0: mdad_0 {
domain-id = <0>;
secure-attribute = <NXP_S32_QSPI_SECURE>;
};
};

sfp_frad {
compatible = "nxp,s32-qspi-sfp-frad";
#address-cells = <1>;
#size-cells = <1>;

frad_0: frad@0 {
reg = <0x0 DT_SIZE_M(512)>;
master-domain-acp-policy = <NXP_S32_QSPI_SECURE>;
};
};

s26hs512t: s26hs512t@0 {
manuargue marked this conversation as resolved.
Show resolved Hide resolved
compatible = "nxp,s32-qspi-hyperflash";
reg = <0>;
jedec-id = [00 34 00 7b 00 1a 00 0f 00 90];
device-id-word-addr = <0x800>;
size = <DT_SIZE_M(512)>;
write-block-size = <2>;
read-latency-cycles = <16>;
max-program-buffer-size = <256>;
vcc-mv = <1800>;
drive-strength-ohm = <27>;
ppw-sectors-addr-mapping = "LOW";
status = "okay";

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

storage_partition: partition@0 {
label = "storage";
reg = <0x0 0x10000>;
};
};
};
};
21 changes: 21 additions & 0 deletions boards/nxp/s32z2xxdc2/s32z2xxdc2_s32z270_pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,25 @@
drive-open-drain;
};
};

qspi0_default: qspi0_default {
group1 {
pinmux = <PI4_QSPI_0_DATA_A_O0>, <PH14_QSPI_0_DATA_A_O1>,
<PI8_QSPI_0_DATA_A_O2>, <PI1_QSPI_0_DATA_A_O3>,
<PI5_QSPI_0_DATA_A_O4>, <PH15_QSPI_0_DATA_A_O5>,
<PI7_QSPI_0_DATA_A_O6>, <PI0_QSPI_0_DATA_A_O7>,
<PI6_QSPI_0_DQS_A_O>;
output-enable;
input-enable;
};
group2 {
pinmux = <PH13_QSPI_0_CS_A0>, <PI9_QSPI_0_CS_A1>,
<PI2_QSPI_0_CK_A_B>, <PI3_QSPI_0_CK_A>;
output-enable;
};
group3 {
pinmux = <PH12_QSPI_0_INTA_B>;
input-enable;
};
};
};
1 change: 1 addition & 0 deletions boards/nxp/s32z2xxdc2/s32z2xxdc2_s32z270_rtu0.dts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
zephyr,sram = &dram0;
zephyr,flash = &cram0;
zephyr,canbus = &canxl0;
zephyr,flash-controller = &s26hs512t;
};

aliases {
Expand Down
1 change: 1 addition & 0 deletions boards/nxp/s32z2xxdc2/s32z2xxdc2_s32z270_rtu1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
zephyr,sram = &dram1;
zephyr,flash = &cram1;
zephyr,canbus = &flexcan0;
zephyr,flash-controller = &s26hs512t;
};

aliases {
Expand Down
9 changes: 5 additions & 4 deletions drivers/flash/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ zephyr_library_include_directories_ifdef(
)

zephyr_library_sources_ifdef(CONFIG_FLASH_NXP_S32_QSPI_NOR flash_nxp_s32_qspi_nor.c)
zephyr_library_include_directories_ifdef(
CONFIG_FLASH_NXP_S32_QSPI_NOR
${ZEPHYR_BASE}/drivers/memc
)
zephyr_library_sources_ifdef(CONFIG_FLASH_NXP_S32_QSPI_HYPERFLASH flash_nxp_s32_qspi_hyperflash.c)
if(CONFIG_FLASH_NXP_S32_QSPI_NOR OR CONFIG_FLASH_NXP_S32_QSPI_HYPERFLASH)
zephyr_library_sources(flash_nxp_s32_qspi.c)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers/memc)
endif()

if(CONFIG_RA_FLASH_HP)
zephyr_library_sources(flash_hp_ra.c)
Expand Down
21 changes: 17 additions & 4 deletions drivers/flash/Kconfig.nxp_s32
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 NXP
# Copyright 2023-2024 NXP
# SPDX-License-Identifier: Apache-2.0

config FLASH_NXP_S32_QSPI_NOR
Expand All @@ -14,10 +14,23 @@ config FLASH_NXP_S32_QSPI_NOR
Enable the Flash driver for a NOR Serial Flash Memory device connected
to an NXP S32 QSPI bus.

if FLASH_NXP_S32_QSPI_NOR
config FLASH_NXP_S32_QSPI_HYPERFLASH
bool "NXP S32 QSPI HYPERFLASH driver"
default y
depends on DT_HAS_NXP_S32_QSPI_HYPERFLASH_ENABLED
select MEMC
select FLASH_HAS_PAGE_LAYOUT
select FLASH_HAS_DRIVER_ENABLED
select FLASH_HAS_EXPLICIT_ERASE
help
Enable the Flash driver for a HyperFlash Memory device connected
to an NXP S32 QSPI bus.

if FLASH_NXP_S32_QSPI_NOR || FLASH_NXP_S32_QSPI_HYPERFLASH

config FLASH_NXP_S32_QSPI_NOR_SFDP_RUNTIME
config FLASH_NXP_S32_QSPI_SFDP_RUNTIME
bool "Read flash parameters at runtime"
depends on FLASH_NXP_S32_QSPI_NOR
help
Read flash device characteristics from the device at runtime.
This option should provide functionality for all supported
Expand Down Expand Up @@ -52,4 +65,4 @@ config FLASH_NXP_S32_QSPI_LAYOUT_PAGE_SIZE
flash memory. Other options may include the 32K-byte erase size (32768),
the block size (65536), or any non-zero multiple of the sector size.

endif # FLASH_NXP_S32_QSPI_NOR
endif # FLASH_NXP_S32_QSPI_NOR || FLASH_NXP_S32_QSPI_HYPERFLASH
Loading
Loading