Skip to content
Permalink
Browse files

flash_gecko: add support for page layout

This commit adds support for FLASH_PAGE_LAYOUT Kconfig option in the
flash_gecko driver.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
  • Loading branch information...
mnkp authored and galak committed Apr 2, 2019
1 parent 0efc039 commit df33e5e861e32f1b428dacfc3e09bd70d5b87289
@@ -8,6 +8,7 @@ config SOC_FLASH_GECKO
bool "Silicon Labs Gecko flash driver"
depends on SOC_FAMILY_EXX32
select FLASH_HAS_DRIVER_ENABLED
select FLASH_HAS_PAGE_LAYOUT
select SOC_GECKO_MSC
help
Enable Silicon Labs Gecko series internal flash driver.
@@ -159,6 +159,22 @@ static int erase_flash_block(off_t offset, size_t size)
return ret;
}

#if CONFIG_FLASH_PAGE_LAYOUT
static const struct flash_pages_layout flash_gecko_0_pages_layout = {
.pages_count = (CONFIG_FLASH_SIZE * 1024) /
DT_SOC_NV_FLASH_0_ERASE_BLOCK_SIZE,
.pages_size = DT_SOC_NV_FLASH_0_ERASE_BLOCK_SIZE,
};

void flash_gecko_page_layout(struct device *dev,
const struct flash_pages_layout **layout,
size_t *layout_size)
{
*layout = &flash_gecko_0_pages_layout;
*layout_size = 1;
}
#endif /* CONFIG_FLASH_PAGE_LAYOUT */

static int flash_gecko_init(struct device *dev)
{
struct flash_gecko_data *const dev_data = DEV_DATA(dev);
@@ -180,6 +196,9 @@ static const struct flash_driver_api flash_gecko_driver_api = {
.write = flash_gecko_write,
.erase = flash_gecko_erase,
.write_protection = flash_gecko_write_protection,
#ifdef CONFIG_FLASH_PAGE_LAYOUT
.page_layout = flash_gecko_page_layout,
#endif
.write_block_size = DT_SOC_NV_FLASH_0_WRITE_BLOCK_SIZE,
};

@@ -35,6 +35,7 @@
compatible = "soc-nv-flash";
label = "FLASH_0";
write-block-size = <4>;
erase-block-size = <1024>;
};
};

@@ -39,6 +39,7 @@
compatible = "soc-nv-flash";
label = "FLASH_0";
write-block-size = <4>;
erase-block-size = <2048>;
};
};

@@ -35,6 +35,7 @@
compatible = "soc-nv-flash";
label = "FLASH_0";
write-block-size = <4>;
erase-block-size = <2048>;
};
};

@@ -35,6 +35,7 @@
compatible = "soc-nv-flash";
label = "FLASH_0";
write-block-size = <4>;
erase-block-size = <2048>;
};
};

@@ -35,6 +35,7 @@
compatible = "soc-nv-flash";
label = "FLASH_0";
write-block-size = <4>;
erase-block-size = <2048>;
};
};

0 comments on commit df33e5e

Please sign in to comment.
You can’t perform that action at this time.