drivers: flash: silabs: Add low power write support

Add low-power-write property to MSC device tree node, set
MSC_WRITECTRL_LPWRITE if enabled.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
This commit is contained in:
Aksel Skauge Mellbye 2025-02-18 18:07:31 +01:00 committed by Carles Cufí
parent 4970e2a196
commit dba1c4bbbe
4 changed files with 33 additions and 0 deletions

View File

@ -32,6 +32,7 @@ struct flash_silabs_data {
struct flash_silabs_config {
struct flash_parameters flash_parameters;
struct flash_pages_layout page_layout;
bool lpwrite;
};
static bool flash_silabs_read_range_is_valid(off_t offset, uint32_t size)
@ -191,9 +192,14 @@ static int flash_silabs_get_size(const struct device *dev, uint64_t *size)
static int flash_silabs_init(const struct device *dev)
{
struct flash_silabs_data *const dev_data = dev->data;
const struct flash_silabs_config *config = dev->config;
MSC_Init();
if (config->lpwrite) {
MSC->WRITECTRL_SET = MSC_WRITECTRL_LPWRITE;
}
/* Lock the MSC module. */
flash_silabs_write_protection(true);
@ -236,6 +242,7 @@ static const struct flash_silabs_config flash_silabs_config_0 = {
DT_PROP(SOC_NV_FLASH_NODE, erase_block_size),
.pages_size = DT_PROP(SOC_NV_FLASH_NODE, erase_block_size),
},
.lpwrite = DT_INST_PROP(0, low_power_write),
};
/* clang-format on */

View File

@ -6,3 +6,9 @@ description: Silicon Labs Series 2 flash controller
compatible: "silabs,series2-flash-controller"
include: flash-controller.yaml
properties:
low-power-write:
type: boolean
description: |
Reduce current consumption during write, doubling write time

View File

@ -0,0 +1,13 @@
/*
* Copyright (c) 2025 Silicon Laboratories Inc.
* SPDX-License-Identifier: Apache-2.0
*/
&dma0 {
status = "okay";
};
&msc {
dmas = <&dma0 DMA_REQSEL_MSCWDATA>;
low-power-write;
};

View File

@ -99,3 +99,10 @@ tests:
- xg24_rb4187c
extra_configs:
- CONFIG_DMA=y
drivers.flash.common.silabs.dma.lpwrite:
platform_allow:
- xg24_rb4187c
extra_configs:
- CONFIG_DMA=y
extra_args:
- DTC_OVERLAY_FILE=boards/xg24_rb4187c_lpwrite.overlay