Skip to content

Add support ospi driver for Renesas RA8 devices #80799

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

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
19 changes: 19 additions & 0 deletions boards/renesas/ek_ra8d1/ek_ra8d1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,23 @@
psels = <RA_PSEL(RA_PSEL_ACMPHS_VCOUT, 2, 8)>;
};
};

ospi0_default: ospi0_default {
group1 {
/* sclk dqs sio0-7 */
psels = <RA_PSEL(RA_PSEL_OSPI, 8, 8)>, <RA_PSEL(RA_PSEL_OSPI, 8, 1)>,
<RA_PSEL(RA_PSEL_OSPI, 1, 0)>, <RA_PSEL(RA_PSEL_OSPI, 8, 3)>,
<RA_PSEL(RA_PSEL_OSPI, 1, 3)>, <RA_PSEL(RA_PSEL_OSPI, 1, 1)>,
<RA_PSEL(RA_PSEL_OSPI, 1, 2)>, <RA_PSEL(RA_PSEL_OSPI, 8, 0)>,
<RA_PSEL(RA_PSEL_OSPI, 8, 2)>, <RA_PSEL(RA_PSEL_OSPI, 8, 4)>;
drive-strength = "highspeed-high";
};

group2 {
/* cs1 rst ecsint1 */
psels = <RA_PSEL(RA_PSEL_OSPI, 1, 4)>, <RA_PSEL(RA_PSEL_OSPI, 1, 6)>,
<RA_PSEL(RA_PSEL_OSPI, 1, 5)>;
drive-strength = "high";
};
};
};
65 changes: 65 additions & 0 deletions boards/renesas/ek_ra8d1/ek_ra8d1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
/dts-v1/;

#include <renesas/ra/ra8/r7fa8d1bhecbd.dtsi>
#include <zephyr/dt-bindings/flash_controller/xspi.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/memory-attr/memory-attr-arm.h>
Expand Down Expand Up @@ -114,6 +115,19 @@
};
};

&pll2 {
status = "okay";
clocks = <&xtal>;
div = <2>;
mul = <80 0>;

pll2p {
status = "okay";
freq = <DT_FREQ_M(400)>;
div = <2>;
};
};

&sciclk {
clocks = <&pllp>;
div = <4>;
Expand All @@ -132,6 +146,12 @@
status = "okay";
};

&octaspiclk {
clocks = <&pll2p>;
div = <2>;
status = "okay";
};

&uclk {
clocks = <&pllq>;
div = <5>;
Expand Down Expand Up @@ -342,3 +362,48 @@ pmod_sd_shield: &sdhc1 {};
status = "okay";
};
};

&ospi0 {
pinctrl-0 = <&ospi0_default>;
pinctrl-names = "default";
status = "okay";

s28hl512t: ospi-nor-flash@90000000 {
compatible = "renesas,ra-ospi-b-nor";
protocol-mode = <XSPI_OCTO_MODE>;
data-rate = <XSPI_DTR_TRANSFER>;
ospi-max-frequency = <DT_FREQ_M(200)>;
reg = <0x90000000 DT_SIZE_M(64)>;
write-block-size = <1>;
status = "okay";

pages_layout: pages_layout {

pages_layout_4k: pages_layout_4k {
pages-count = <32>;
pages-size = <DT_SIZE_K(4)>;
};

pages_layout_128k: pages_layout_128k {
pages-count = <1>;
pages-size = <DT_SIZE_K(128)>;
};

pages_layout_256k: pages_layout_256k {
pages-count = <255>;
pages-size = <DT_SIZE_K(256)>;
};
};

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

partition@0 {
label = "nor";
reg = <0x00000000 DT_SIZE_M(64)>;
};
};
};
};
19 changes: 19 additions & 0 deletions boards/renesas/ek_ra8m1/ek_ra8m1-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,23 @@
psels = <RA_PSEL(RA_PSEL_ACMPHS_VCOUT, 2, 8)>;
};
};

ospi0_default: ospi0_default {
group1 {
/* sclk dqs sio0-7 */
psels = <RA_PSEL(RA_PSEL_OSPI, 8, 8)>, <RA_PSEL(RA_PSEL_OSPI, 8, 1)>,
<RA_PSEL(RA_PSEL_OSPI, 1, 0)>, <RA_PSEL(RA_PSEL_OSPI, 8, 3)>,
<RA_PSEL(RA_PSEL_OSPI, 1, 3)>, <RA_PSEL(RA_PSEL_OSPI, 1, 1)>,
<RA_PSEL(RA_PSEL_OSPI, 1, 2)>, <RA_PSEL(RA_PSEL_OSPI, 8, 0)>,
<RA_PSEL(RA_PSEL_OSPI, 8, 2)>, <RA_PSEL(RA_PSEL_OSPI, 8, 4)>;
drive-strength = "highspeed-high";
};

group2 {
/* cs1 rst ecsint1 */
psels = <RA_PSEL(RA_PSEL_OSPI, 1, 4)>, <RA_PSEL(RA_PSEL_OSPI, 1, 6)>,
<RA_PSEL(RA_PSEL_OSPI, 1, 5)>;
drive-strength = "high";
};
};
};
64 changes: 64 additions & 0 deletions boards/renesas/ek_ra8m1/ek_ra8m1.dts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <renesas/ra/ra8/r7fa8m1ahecbd.dtsi>
#include <dt-bindings/gpio/gpio.h>
#include <zephyr/dt-bindings/flash_controller/xspi.h>
#include <zephyr/dt-bindings/adc/adc.h>
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include "ek_ra8m1-pinctrl.dtsi"
Expand Down Expand Up @@ -151,6 +152,18 @@
};
};

&pll2 {
status = "okay";
clocks = <&xtal>;
div = <2>;
mul = <80 0>;

pll2p {
status = "okay";
freq = <DT_FREQ_M(400)>;
div = <2>;
};
};

&sciclk {
clocks = <&pllp>;
Expand All @@ -170,6 +183,12 @@
status = "okay";
};

&octaspiclk {
clocks = <&pll2p>;
div = <2>;
status = "okay";
};

&ioport0 {
status = "okay";
};
Expand Down Expand Up @@ -401,3 +420,48 @@ pmod_sd_shield: &sdhc0 {};
status = "okay";
};
};

&ospi0 {
pinctrl-0 = <&ospi0_default>;
pinctrl-names = "default";
status = "okay";

s28hl512t: ospi-nor-flash@90000000 {
compatible = "renesas,ra-ospi-b-nor";
protocol-mode = <XSPI_OCTO_MODE>;
data-rate = <XSPI_DTR_TRANSFER>;
ospi-max-frequency = <DT_FREQ_M(200)>;
reg = <0x90000000 DT_SIZE_M(64)>;
write-block-size = <1>;
status = "okay";

pages_layout: pages_layout {

pages_layout_4k: pages_layout_4k {
pages-count = <32>;
pages-size = <DT_SIZE_K(4)>;
};

pages_layout_128k: pages_layout_128k {
pages-count = <1>;
pages-size = <DT_SIZE_K(128)>;
};

pages_layout_256k: pages_layout_256k {
pages-count = <255>;
pages-size = <DT_SIZE_K(256)>;
};
};

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

partition@0 {
label = "nor";
reg = <0x00000000 DT_SIZE_M(64)>;
};
};
};
};
1 change: 1 addition & 0 deletions drivers/flash/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ zephyr_library_sources_ifdef(CONFIG_FLASH_MSPI_EMUL_DEVICE flash_mspi_emul_devic
zephyr_library_sources_ifdef(CONFIG_FLASH_MSPI_NOR flash_mspi_nor.c)
zephyr_library_sources_ifdef(CONFIG_FLASH_NPCX_FIU_NOR flash_npcx_fiu_nor.c)
zephyr_library_sources_ifdef(CONFIG_FLASH_NPCX_FIU_QSPI flash_npcx_fiu_qspi.c)
zephyr_library_sources_ifdef(CONFIG_FLASH_RENESAS_RA_OSPI_B flash_renesas_ra_ospi_b.c)
zephyr_library_sources_ifdef(CONFIG_FLASH_RPI_PICO flash_rpi_pico.c)
zephyr_library_sources_ifdef(CONFIG_FLASH_STM32_OSPI flash_stm32_ospi.c)
zephyr_library_sources_ifdef(CONFIG_FLASH_STM32_QSPI flash_stm32_qspi.c)
Expand Down
1 change: 1 addition & 0 deletions drivers/flash/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ source "drivers/flash/Kconfig.numaker"
source "drivers/flash/Kconfig.numaker_rmc"
source "drivers/flash/Kconfig.nxp_s32"
source "drivers/flash/Kconfig.renesas_ra"
source "drivers/flash/Kconfig.renesas_ra_ospi"
source "drivers/flash/Kconfig.rpi_pico"
source "drivers/flash/Kconfig.rv32m1"
source "drivers/flash/Kconfig.sam"
Expand Down
18 changes: 18 additions & 0 deletions drivers/flash/Kconfig.renesas_ra_ospi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Renesas RA Family

# Copyright (c) 2024-2025 Renesas Electronics Corporation
# SPDX-License-Identifier: Apache-2.0

config FLASH_RENESAS_RA_OSPI_B
bool "Renesas RA Octal-SPI driver"
default y
depends on DT_HAS_RENESAS_RA_OSPI_B_NOR_ENABLED
select FLASH_HAS_DRIVER_ENABLED
select FLASH_HAS_PAGE_LAYOUT
select FLASH_HAS_EXPLICIT_ERASE
select USE_RA_FSP_OSPI_B_NOR_FLASH
select FLASH_JESD216
select FLASH_HAS_EX_OP
select PINCTRL
help
Enable Octal-SPI Nor flash driver for RA series
Loading