From abe50cc92991389e2508de8ea721bee36cd5fb17 Mon Sep 17 00:00:00 2001 From: Yonatan Schachter Date: Tue, 3 Jan 2023 11:11:46 +0200 Subject: [PATCH] rpi_pico: Fix DTC warnings concerning the flash The addresses of the flash and flash controller of the RP2040 SoC were mixed up. There was no clear distinction between the flash and the flash controller, which was unclear but also caused a DTC warning. This commit makes the distinction clearer: The SSI peripheral at 0x18000000 is the flash controller, and the flash itself starts at 0x10000000. The flash driver and rpi_pico.dts were fixed accordingly. Signed-off-by: Yonatan Schachter --- boards/arm/rpi_pico/rpi_pico.dts | 2 +- drivers/flash/flash_rpi_pico.c | 7 ++++--- dts/arm/rpi_pico/rp2040.dtsi | 7 +++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/boards/arm/rpi_pico/rpi_pico.dts b/boards/arm/rpi_pico/rpi_pico.dts index 20fc1b09f2..9ed80c96cf 100644 --- a/boards/arm/rpi_pico/rpi_pico.dts +++ b/boards/arm/rpi_pico/rpi_pico.dts @@ -18,7 +18,7 @@ chosen { zephyr,sram = &sram0; zephyr,flash = &flash0; - zephyr,flash-controller = &flash_controller; + zephyr,flash-controller = &ssi; zephyr,console = &uart0; zephyr,shell-uart = &uart0; zephyr,code-partition = &code_partition; diff --git a/drivers/flash/flash_rpi_pico.c b/drivers/flash/flash_rpi_pico.c index d9228a6041..6c7959c45c 100644 --- a/drivers/flash/flash_rpi_pico.c +++ b/drivers/flash/flash_rpi_pico.c @@ -27,10 +27,11 @@ LOG_MODULE_REGISTER(flash_rpi_pico, CONFIG_FLASH_LOG_LEVEL); #define DT_DRV_COMPAT raspberrypi_pico_flash_controller #define PAGE_SIZE 256 -#define SECTOR_SIZE DT_PROP(DT_CHILD(DT_NODELABEL(flash_controller), flash_0), erase_block_size) +#define SECTOR_SIZE DT_PROP(DT_CHOSEN(zephyr_flash), erase_block_size) #define ERASE_VALUE 0xff #define FLASH_SIZE KB(CONFIG_FLASH_SIZE) -#define FLASH_BASE DT_REG_ADDR(DT_NODELABEL(flash_controller)) +#define FLASH_BASE CONFIG_FLASH_BASE_ADDRESS +#define SSI_BASE_ADDRESS DT_REG_ADDR(DT_CHOSEN(zephyr_flash_controller)) static const struct flash_parameters flash_rpi_parameters = { .write_block_size = 1, @@ -56,7 +57,7 @@ enum outover { OUTOVER_HIGH }; -static ssi_hw_t *const ssi = (ssi_hw_t *)XIP_SSI_BASE; +static ssi_hw_t *const ssi = (ssi_hw_t *)SSI_BASE_ADDRESS; static uint32_t boot2_copyout[BOOT2_SIZE_WORDS]; static bool boot2_copyout_valid; diff --git a/dts/arm/rpi_pico/rp2040.dtsi b/dts/arm/rpi_pico/rp2040.dtsi index 9742e2e615..7a74dba448 100644 --- a/dts/arm/rpi_pico/rp2040.dtsi +++ b/dts/arm/rpi_pico/rp2040.dtsi @@ -33,15 +33,14 @@ reg = <0x20000000 DT_SIZE_K(264)>; }; - flash_controller: flash-controller@10000000 { + ssi: flash-controller@18000000 { compatible = "raspberrypi,pico-flash-controller"; - reg = <0x10000000 DT_SIZE_K(4)>; - interrupts = <15 0>; + reg = <0x18000000 0xfc>; #address-cells = <1>; #size-cells = <1>; - flash0: flash@0 { + flash0: flash@10000000 { compatible = "soc-nv-flash"; write-block-size = <1>; erase-block-size = ;