Skip to content

Commit 9a162e0

Browse files
de-nordickartben
authored andcommitted
drivers/flash/flexspi_nor: Add flash_get_size API call
The commit adds implementation of flash_get_size. Signed-off-by: Dominik Ermel <[email protected]>
1 parent 6a06c10 commit 9a162e0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/flash/flash_mcux_flexspi_nor.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct flash_flexspi_nor_data {
7575
flexspi_device_config_t config;
7676
flexspi_port_t port;
7777
bool legacy_poll;
78+
uint64_t size;
7879
struct flash_pages_layout layout;
7980
struct flash_parameters flash_parameters;
8081
};
@@ -456,6 +457,15 @@ static const struct flash_parameters *flash_flexspi_nor_get_parameters(
456457
return &data->flash_parameters;
457458
}
458459

460+
static int flash_flexspi_nor_get_size(const struct device *dev, uint64_t *size)
461+
{
462+
struct flash_flexspi_nor_data *data = dev->data;
463+
464+
*size = (uint64_t)data->size;
465+
466+
return 0;
467+
}
468+
459469
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
460470
static void flash_flexspi_nor_pages_layout(const struct device *dev,
461471
const struct flash_pages_layout **layout, size_t *layout_size)
@@ -1259,6 +1269,7 @@ static const struct flash_driver_api flash_flexspi_nor_api = {
12591269
.write = flash_flexspi_nor_write,
12601270
.read = flash_flexspi_nor_read,
12611271
.get_parameters = flash_flexspi_nor_get_parameters,
1272+
.get_size = flash_flexspi_nor_get_size,
12621273
#if defined(CONFIG_FLASH_PAGE_LAYOUT)
12631274
.page_layout = flash_flexspi_nor_pages_layout,
12641275
#endif
@@ -1309,6 +1320,7 @@ static const struct flash_driver_api flash_flexspi_nor_api = {
13091320
flash_flexspi_nor_data_##n = { \
13101321
.config = FLASH_FLEXSPI_DEVICE_CONFIG(n), \
13111322
.port = DT_INST_REG_ADDR(n), \
1323+
.size = DT_INST_PROP(n, size) / 8, \
13121324
.layout = { \
13131325
.pages_count = DT_INST_PROP(n, size) / 8 \
13141326
/ SPI_NOR_SECTOR_SIZE, \

0 commit comments

Comments
 (0)