diff --git a/boards/alientek/pandora_stm32l475/pandora_stm32l475.dts b/boards/alientek/pandora_stm32l475/pandora_stm32l475.dts index a8025833d941..b0f43f21b675 100644 --- a/boards/alientek/pandora_stm32l475/pandora_stm32l475.dts +++ b/boards/alientek/pandora_stm32l475/pandora_stm32l475.dts @@ -82,6 +82,7 @@ reg = <0>; size = ; /* 128 Mbits */ qspi-max-frequency = <80000000>; + cs-high-time = <4>; /* >= 50 ns */ jedec-id = [ef 40 18]; spi-bus-width = <4>; writeoc = "PP_1_1_4"; diff --git a/boards/arduino/giga_r1/arduino_giga_r1_stm32h747xx_m7.dts b/boards/arduino/giga_r1/arduino_giga_r1_stm32h747xx_m7.dts index 4feba7fb1f37..78dc27882c13 100644 --- a/boards/arduino/giga_r1/arduino_giga_r1_stm32h747xx_m7.dts +++ b/boards/arduino/giga_r1/arduino_giga_r1_stm32h747xx_m7.dts @@ -178,6 +178,7 @@ reg = <0>; size = ; /* 128 Mbits */ qspi-max-frequency = <72000000>; + cs-high-time = <4>; /* >= 50 ns */ status = "okay"; partitions { diff --git a/boards/arduino/nicla_vision/arduino_nicla_vision_stm32h747xx_m7.dts b/boards/arduino/nicla_vision/arduino_nicla_vision_stm32h747xx_m7.dts index 0cc4ef217a18..bf2e4dce029a 100644 --- a/boards/arduino/nicla_vision/arduino_nicla_vision_stm32h747xx_m7.dts +++ b/boards/arduino/nicla_vision/arduino_nicla_vision_stm32h747xx_m7.dts @@ -170,6 +170,7 @@ zephyr_i2c: &i2c1 { reg = <0>; size = ; /* 128 Mbits */ qspi-max-frequency = <72000000>; + cs-high-time = <4>; /* >= 50 ns */ status = "okay"; partitions { diff --git a/boards/arduino/portenta_h7/arduino_portenta_h7-common.dtsi b/boards/arduino/portenta_h7/arduino_portenta_h7-common.dtsi index b95a2e679999..2887776f93b7 100644 --- a/boards/arduino/portenta_h7/arduino_portenta_h7-common.dtsi +++ b/boards/arduino/portenta_h7/arduino_portenta_h7-common.dtsi @@ -184,6 +184,7 @@ zephyr_i2c: &i2c1 { reg = <0>; size = ; /* 128 Mbits */ qspi-max-frequency = < 40000000 >; + cs-high-time = <2>; /* >= 30 ns */ sfdp-bfp = [ e5 20 f1 ff ff ff ff 07 44 eb 08 6b 08 3b 04 bb fe ff ff ff ff ff 00 ff ff ff 44 eb 0c 20 0f 52 10 d8 00 ff 82 41 bd 00 81 e5 7b c6 44 03 67 38 diff --git a/boards/fanke/fk743m5_xih6/fk743m5_xih6.dts b/boards/fanke/fk743m5_xih6/fk743m5_xih6.dts index 798418d379f2..799c8f01a112 100644 --- a/boards/fanke/fk743m5_xih6/fk743m5_xih6.dts +++ b/boards/fanke/fk743m5_xih6/fk743m5_xih6.dts @@ -101,6 +101,7 @@ reg = <0>; size = ; /* 64 Mbits */ qspi-max-frequency = <40000000>; + cs-high-time = <2>; /* >= 50 ns */ status = "okay"; spi-bus-width = <4>; writeoc = "PP_1_1_4"; diff --git a/boards/fanke/fk750m1_vbt6/fk750m1_vbt6.dts b/boards/fanke/fk750m1_vbt6/fk750m1_vbt6.dts index c3c1b6418bfa..6b2269d963f0 100644 --- a/boards/fanke/fk750m1_vbt6/fk750m1_vbt6.dts +++ b/boards/fanke/fk750m1_vbt6/fk750m1_vbt6.dts @@ -123,6 +123,7 @@ reg = <0>; size = ; /* 64 Mbits */ qspi-max-frequency = <40000000>; + cs-high-time = <2>; /* >= 50 ns */ status = "okay"; spi-bus-width = <4>; writeoc = "PP_1_1_4"; diff --git a/boards/st/disco_l475_iot1/disco_l475_iot1.dts b/boards/st/disco_l475_iot1/disco_l475_iot1.dts index 6b30f7139654..dc1ce05dbace 100644 --- a/boards/st/disco_l475_iot1/disco_l475_iot1.dts +++ b/boards/st/disco_l475_iot1/disco_l475_iot1.dts @@ -330,6 +330,7 @@ zephyr_udc0: &usbotg_fs { reg = <0>; size = ; /* 64 Mbits */ qspi-max-frequency = <50000000>; + cs-high-time = <2>; /* >= 30 ns */ status = "okay"; partitions { diff --git a/boards/st/stm32f412g_disco/stm32f412g_disco.dts b/boards/st/stm32f412g_disco/stm32f412g_disco.dts index 35f48d21b3c3..3f83c2fee3d1 100644 --- a/boards/st/stm32f412g_disco/stm32f412g_disco.dts +++ b/boards/st/stm32f412g_disco/stm32f412g_disco.dts @@ -161,6 +161,7 @@ reg = <0>; size = ; /* 128 Mbits */ qspi-max-frequency = <72000000>; + cs-high-time = <4>; /* >= 50 ns */ status = "okay"; }; }; diff --git a/boards/st/stm32f723e_disco/stm32f723e_disco.dts b/boards/st/stm32f723e_disco/stm32f723e_disco.dts index 134ec57806e7..624c7b101ea5 100644 --- a/boards/st/stm32f723e_disco/stm32f723e_disco.dts +++ b/boards/st/stm32f723e_disco/stm32f723e_disco.dts @@ -132,6 +132,7 @@ reg = <0>; size = ; /* 512 Mbits */ qspi-max-frequency = <8000000>; + cs-high-time = <3>; /* >= 30 ns */ status = "okay"; spi-bus-width = <4>; writeoc = "PP_1_4_4"; diff --git a/boards/st/stm32f746g_disco/stm32f746g_disco.dts b/boards/st/stm32f746g_disco/stm32f746g_disco.dts index 3cde07f09c26..66f7f642e13c 100644 --- a/boards/st/stm32f746g_disco/stm32f746g_disco.dts +++ b/boards/st/stm32f746g_disco/stm32f746g_disco.dts @@ -215,6 +215,7 @@ zephyr_udc0: &usbotg_fs { reg = <0>; size = ; /* 128 Mbits */ qspi-max-frequency = <72000000>; + cs-high-time = <4>; /* >= 50 ns */ status = "okay"; partitions { diff --git a/boards/st/stm32f7508_dk/stm32f7508_dk.dts b/boards/st/stm32f7508_dk/stm32f7508_dk.dts index 91cccf4521fa..d0884a18248c 100644 --- a/boards/st/stm32f7508_dk/stm32f7508_dk.dts +++ b/boards/st/stm32f7508_dk/stm32f7508_dk.dts @@ -202,6 +202,7 @@ zephyr_udc0: &usbotg_fs { reg = <0>; size = ; /* 128 Mbits */ qspi-max-frequency = <72000000>; + cs-high-time = <4>; /* >= 50 ns */ status = "okay"; partitions { diff --git a/boards/st/stm32f769i_disco/stm32f769i_disco.dts b/boards/st/stm32f769i_disco/stm32f769i_disco.dts index 822b8ebf900b..0aa96890bc70 100644 --- a/boards/st/stm32f769i_disco/stm32f769i_disco.dts +++ b/boards/st/stm32f769i_disco/stm32f769i_disco.dts @@ -200,6 +200,7 @@ arduino_serial: &usart6 {}; reg = <0>; size = ; /* 512 Mbits */ qspi-max-frequency = ; + cs-high-time = <2>; /* >= 30 ns */ status = "okay"; partitions { diff --git a/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts b/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts index c7c49da4f4eb..74aa4ca06753 100644 --- a/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts +++ b/boards/st/stm32h745i_disco/stm32h745i_disco_stm32h745xx_m7.dts @@ -185,6 +185,7 @@ reg = <0>; size = ; /* 512 Mbits */ qspi-max-frequency = <72000000>; + cs-high-time = <4>; /* >= 50 ns */ spi-bus-width = <4>; reset-cmd; status = "okay"; diff --git a/boards/st/stm32h747i_disco/stm32h747i_disco_stm32h747xx_m7.dts b/boards/st/stm32h747i_disco/stm32h747i_disco_stm32h747xx_m7.dts index 4ec0856b92e0..9582738a373f 100644 --- a/boards/st/stm32h747i_disco/stm32h747i_disco_stm32h747xx_m7.dts +++ b/boards/st/stm32h747i_disco/stm32h747i_disco_stm32h747xx_m7.dts @@ -258,6 +258,7 @@ zephyr_udc0: &usbotg_hs { reg = <0>; size = ; /* 512 Mbits */ qspi-max-frequency = <72000000>; + cs-high-time = <4>; /* >= 50 ns */ spi-bus-width = <4>; reset-cmd; status = "okay"; diff --git a/boards/st/stm32h750b_dk/stm32h750b_dk.dts b/boards/st/stm32h750b_dk/stm32h750b_dk.dts index e664a0a663e3..a29b0d4e6f13 100644 --- a/boards/st/stm32h750b_dk/stm32h750b_dk.dts +++ b/boards/st/stm32h750b_dk/stm32h750b_dk.dts @@ -192,6 +192,7 @@ reg = <0>; size = ; /* 512 Mbits */ qspi-max-frequency = <72000000>; + cs-high-time = <4>; /* >= 50 ns */ spi-bus-width = <4>; reset-cmd; status = "okay"; diff --git a/boards/st/stm32h757i_eval/stm32h757i_eval_stm32h757xx_m7.dts b/boards/st/stm32h757i_eval/stm32h757i_eval_stm32h757xx_m7.dts index e2d6fddfe6ca..4d96d2c87cb8 100644 --- a/boards/st/stm32h757i_eval/stm32h757i_eval_stm32h757xx_m7.dts +++ b/boards/st/stm32h757i_eval/stm32h757i_eval_stm32h757xx_m7.dts @@ -273,6 +273,7 @@ zephyr_udc0: &usbotg_hs { reg = <0>; size = ; /* 512 Mbits */ qspi-max-frequency = <72000000>; + cs-high-time = <4>; /* >= 50 ns */ spi-bus-width = <4>; reset-cmd; status = "okay"; diff --git a/boards/st/stm32l496g_disco/stm32l496g_disco.dts b/boards/st/stm32l496g_disco/stm32l496g_disco.dts index a888fec55987..ed7b419390a4 100644 --- a/boards/st/stm32l496g_disco/stm32l496g_disco.dts +++ b/boards/st/stm32l496g_disco/stm32l496g_disco.dts @@ -211,6 +211,7 @@ zephyr_udc0: &usbotg_fs { reg = <0>; size = ; /* 64 Mbits */ qspi-max-frequency = <8000000>; + cs-high-time = <3>; /* >= 30 ns */ status = "okay"; spi-bus-width = <4>; writeoc = "PP_1_4_4"; diff --git a/boards/vcc-gnd/yd_stm32h750vb/yd_stm32h750vb.dts b/boards/vcc-gnd/yd_stm32h750vb/yd_stm32h750vb.dts index 2e9430008185..6d39ef748cc9 100644 --- a/boards/vcc-gnd/yd_stm32h750vb/yd_stm32h750vb.dts +++ b/boards/vcc-gnd/yd_stm32h750vb/yd_stm32h750vb.dts @@ -119,6 +119,7 @@ reg = <0>; size = ; /* 128 Mbits */ qspi-max-frequency = <80000000>; + cs-high-time = <4>; /* >= 50 ns */ spi-bus-width = <4>; status = "okay"; diff --git a/boards/weact/mini_stm32h743/mini_stm32h743.dts b/boards/weact/mini_stm32h743/mini_stm32h743.dts index 7df87472d073..b946a522d74b 100644 --- a/boards/weact/mini_stm32h743/mini_stm32h743.dts +++ b/boards/weact/mini_stm32h743/mini_stm32h743.dts @@ -171,6 +171,7 @@ zephyr_udc0: &usbotg_fs { reg = <0>; size = ; /* 64 Mbits */ qspi-max-frequency = <40000000>; + cs-high-time = <2>; /* >= 50 ns */ status = "okay"; spi-bus-width = <4>; writeoc = "PP_1_1_4"; diff --git a/drivers/flash/flash_stm32_qspi.c b/drivers/flash/flash_stm32_qspi.c index 5ce9f0835929..2c7ee4b6548f 100644 --- a/drivers/flash/flash_stm32_qspi.c +++ b/drivers/flash/flash_stm32_qspi.c @@ -102,6 +102,7 @@ struct flash_stm32_qspi_config { irq_config_func_t irq_config; size_t flash_size; uint32_t max_frequency; + uint8_t cs_high_time; const struct pinctrl_dev_config *pcfg; #if STM32_QSPI_RESET_GPIO const struct gpio_dt_spec reset; @@ -1510,6 +1511,8 @@ static int flash_stm32_qspi_init(const struct device *dev) dev_data->hqspi.Init.ClockPrescaler = prescaler; /* Give a bit position from 0 to 31 to the HAL init minus 1 for the DCR1 reg */ dev_data->hqspi.Init.FlashSize = find_lsb_set(dev_cfg->flash_size) - 2; + dev_data->hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; + dev_data->hqspi.Init.ChipSelectHighTime = dev_cfg->cs_high_time - 1; #if DT_PROP(DT_NODELABEL(quadspi), dual_flash) && defined(QUADSPI_CR_DFM) /* * When the DTS has , it means Dual Flash Mode @@ -1517,8 +1520,6 @@ static int flash_stm32_qspi_init(const struct device *dev) * else the magic nb is wrong (0x46465353) * That means that the Dual Flash config is set after the SFDP sequence */ - dev_data->hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; - dev_data->hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_3_CYCLE; dev_data->hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE; /* Set Dual Flash Mode only on MemoryMapped */ dev_data->hqspi.Init.FlashID = QSPI_FLASH_ID_1; @@ -1705,6 +1706,7 @@ static const struct flash_stm32_qspi_config flash_stm32_qspi_cfg = { .irq_config = flash_stm32_qspi_irq_config_func, .flash_size = (DT_INST_PROP(0, size) / 8) << STM32_QSPI_DOUBLE_FLASH, .max_frequency = DT_INST_PROP(0, qspi_max_frequency), + .cs_high_time = DT_INST_PROP(0, cs_high_time), .pcfg = PINCTRL_DT_DEV_CONFIG_GET(STM32_QSPI_NODE), #if STM32_QSPI_RESET_GPIO .reset = GPIO_DT_SPEC_INST_GET(0, reset_gpios), diff --git a/dts/bindings/flash_controller/st,stm32-qspi-nor.yaml b/dts/bindings/flash_controller/st,stm32-qspi-nor.yaml index 1680610356b6..5d4e2ef562e0 100644 --- a/dts/bindings/flash_controller/st,stm32-qspi-nor.yaml +++ b/dts/bindings/flash_controller/st,stm32-qspi-nor.yaml @@ -80,3 +80,10 @@ properties: type: int default: 8 description: The number of dummy-cycles required when reading jedec id + + cs-high-time: + type: int + default: 4 + description: | + Minimum number of QSPI clock cycles the chip select signal must remain + high between commands issued to the flash memory. diff --git a/samples/subsys/fs/littlefs/boards/nucleo_h743zi.overlay b/samples/subsys/fs/littlefs/boards/nucleo_h743zi.overlay index 67fb25ae7ce7..95dd5d394032 100644 --- a/samples/subsys/fs/littlefs/boards/nucleo_h743zi.overlay +++ b/samples/subsys/fs/littlefs/boards/nucleo_h743zi.overlay @@ -47,6 +47,7 @@ reg = <0>; size = ; /* 256 Mbits */ qspi-max-frequency = <50000000>; + cs-high-time = <3>; /* >= 30 ns */ reset-gpios = <&gpiod 3 GPIO_ACTIVE_LOW>; reset-gpios-duration = <1>; spi-bus-width = <4>;