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

STM32N6: add XSPI PSRAM support #85564

Merged
merged 4 commits into from
Mar 24, 2025

Conversation

gautierg-st
Copy link
Contributor

Add XSPI PSRAM support for STM32N6. Enable XSPI PSRAM on STM32N6570-DK.

@gautierg-st
Copy link
Contributor Author

Test results of tests/drivers/memc/ram/:

*** Booting Zephyr OS build v4.0.0-4949-gda9e0a1c29ca ***
Running TESTSUITE test_ram
===================================================================
START - test_psram
 PASS - test_psram in 0.001 seconds
===================================================================
START - test_ram0
 SKIP - test_ram0 in 0.001 seconds
===================================================================
START - test_sdram1
 SKIP - test_sdram1 in 0.001 seconds
===================================================================
START - test_sdram2
 SKIP - test_sdram2 in 0.001 seconds
===================================================================
START - test_sram1
 SKIP - test_sram1 in 0.001 seconds
===================================================================
START - test_sram2
 SKIP - test_sram2 in 0.001 seconds
===================================================================
TESTSUITE test_ram succeeded

------ TESTSUITE SUMMARY START ------

SUITE PASS - 100.00% [test_ram]: pass = 1, fail = 0, skip = 5, total = 6 duration = 0.006 seconds
 - PASS - [test_ram.test_psram] duration = 0.001 seconds
 - SKIP - [test_ram.test_ram0] duration = 0.001 seconds
 - SKIP - [test_ram.test_sdram1] duration = 0.001 seconds
 - SKIP - [test_ram.test_sdram2] duration = 0.001 seconds
 - SKIP - [test_ram.test_sram1] duration = 0.001 seconds
 - SKIP - [test_ram.test_sram2] duration = 0.001 seconds

------ TESTSUITE SUMMARY END ------

===================================================================
PROJECT EXECUTION SUCCESSFUL

kartben
kartben previously approved these changes Feb 12, 2025
@gautierg-st
Copy link
Contributor Author

Rebased to fix conflicts

@gautierg-st gautierg-st assigned FRASTM and unassigned erwango Feb 14, 2025
cmd.DataMode = HAL_XSPI_DATA_8_LINES;
cmd.DataLength = 2;
cmd.DataDTRMode = HAL_XSPI_DATA_DTR_ENABLE;
cmd.DummyCycles = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done by the cmd = {0};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

cmd.OperationType = HAL_XSPI_OPTYPE_READ_CFG;
cmd.Instruction = READ_CMD;
cmd.DummyCycles = DUMMY_CLK_CYCLES_READ;
cmd.DQSMode = HAL_XSPI_DQS_ENABLE;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already done at line 297

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

}

mem_mapped_cfg.TimeOutActivation = HAL_XSPI_TIMEOUT_COUNTER_ENABLE;
mem_mapped_cfg.TimeoutPeriodClock = 0x34;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is a 'magic' value coming from the stm32Cube

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, should I add a comment to say that?

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

erwango
erwango previously approved these changes Mar 14, 2025
Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

@erwango erwango requested review from FRASTM and kartben March 19, 2025 15:41
return 0;
}

uint32_t ap_memory_read_reg(XSPI_HandleTypeDef *hxspi, uint32_t address, uint8_t *value,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint32_t ap_memory_read_reg(XSPI_HandleTypeDef *hxspi, uint32_t address, uint8_t *value,
static uint32_t ap_memory_read_reg(XSPI_HandleTypeDef *hxspi, uint32_t address, uint8_t *value,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@gautierg-st gautierg-st force-pushed the n6_add_xspi_psram branch 2 times, most recently from 115b417 to 435df8c Compare March 20, 2025 10:45
Add bindings for STM32 XSPI PSRAM

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
@erwango erwango requested review from kartben and erwango March 20, 2025 13:10
erwango
erwango previously approved these changes Mar 20, 2025
kartben
kartben previously approved these changes Mar 20, 2025
static int ap_memory_write_reg(XSPI_HandleTypeDef *hxspi, uint32_t address, uint8_t *value)
{
XSPI_RegularCmdTypeDef cmd = {0};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if cmd is {0], you probably save some init below assigning cmd.xx to a value which is also 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed lines that were already set at 0 but kept them in comment, I think they are still useful for a better understanding of the commands.

cfg.nCSOverride = HAL_XSPI_CSSEL_OVR_NCS1;
cfg.IOPort = HAL_XSPIM_IOPORT_1;

if (HAL_XSPIM_Config(&hxspi, &cfg, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (HAL_XSPIM_Config(&hxspi, &cfg, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
if (HAL_XSPIM_Config(&hxspi, &cfg, HAL_XSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
LOG_ERR("XSPIMgr Init failed");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Add a driver for STM32 XSPI PSRAM in memory mapped mode.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Add XSPI1 node for STM32N6

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Enables XSPI PSRAM on the STM32N6570-DK board.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
@gautierg-st gautierg-st dismissed stale reviews from kartben and erwango via e8d3d06 March 21, 2025 07:46
@erwango erwango assigned erwango and unassigned FRASTM Mar 24, 2025
@kartben kartben merged commit 3b8e472 into zephyrproject-rtos:main Mar 24, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants