drivers: flash: mcux: Fix DT_DRV_COMPAT setting
For a flash driver DT_DRV_COMPAT should be the compatible for the flash controller and not the soc-nv-flash. Change to driver to use the flash controllers compatible and get the soc-nv-flash properties as a child of that controller. The soc_flash_mcux supports several possible compatible so handle that as part of how we set DT_DRV_COMPAT. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This commit is contained in:
parent
3fa974cab0
commit
a61d2a281c
1 changed files with 19 additions and 6 deletions
|
@ -4,8 +4,6 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT soc_nv_flash
|
||||
|
||||
#include <kernel.h>
|
||||
#include <device.h>
|
||||
#include <string.h>
|
||||
|
@ -22,6 +20,20 @@
|
|||
#include "fsl_flash.h"
|
||||
#endif
|
||||
|
||||
#if DT_HAS_NODE(DT_INST(0, nxp_kinetis_ftfa))
|
||||
#define DT_DRV_COMPAT nxp_kinetis_ftfa
|
||||
#elif DT_HAS_NODE(DT_INST(0, nxp_kinetis_ftfe))
|
||||
#define DT_DRV_COMPAT nxp_kinetis_ftfe
|
||||
#elif DT_HAS_NODE(DT_INST(0, nxp_kinetis_ftfl))
|
||||
#define DT_DRV_COMPAT nxp_kinetis_ftfl
|
||||
#elif DT_HAS_NODE(DT_INST(0, nxp_lpc_iap))
|
||||
#define DT_DRV_COMPAT nxp_lpc_iap
|
||||
#else
|
||||
#error No matching compatible for soc_flash_mcux.c
|
||||
#endif
|
||||
|
||||
#define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash)
|
||||
|
||||
struct flash_priv {
|
||||
flash_config_t config;
|
||||
/*
|
||||
|
@ -119,8 +131,9 @@ static int flash_mcux_write_protection(struct device *dev, bool enable)
|
|||
|
||||
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
|
||||
static const struct flash_pages_layout dev_layout = {
|
||||
.pages_count = KB(CONFIG_FLASH_SIZE) / DT_INST_PROP(0, erase_block_size),
|
||||
.pages_size = DT_INST_PROP(0, erase_block_size),
|
||||
.pages_count = DT_REG_SIZE(SOC_NV_FLASH_NODE) /
|
||||
DT_PROP(SOC_NV_FLASH_NODE, erase_block_size),
|
||||
.pages_size = DT_PROP(SOC_NV_FLASH_NODE, erase_block_size),
|
||||
};
|
||||
|
||||
static void flash_mcux_pages_layout(struct device *dev,
|
||||
|
@ -142,8 +155,8 @@ static const struct flash_driver_api flash_mcux_api = {
|
|||
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
|
||||
.page_layout = flash_mcux_pages_layout,
|
||||
#endif
|
||||
#if DT_INST_NODE_HAS_PROP(0, write_block_size)
|
||||
.write_block_size = DT_INST_PROP(0, write_block_size),
|
||||
#if DT_NODE_HAS_PROP(SOC_NV_FLASH_NODE, write_block_size)
|
||||
.write_block_size = DT_PROP(SOC_NV_FLASH_NODE, write_block_size),
|
||||
#else
|
||||
.write_block_size = FSL_FEATURE_FLASH_PFLASH_BLOCK_WRITE_UNIT_SIZE,
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue