|
|
|
@ -9,6 +9,8 @@ |
|
|
|
|
#include <spi.h> |
|
|
|
|
#include <spi_flash.h> |
|
|
|
|
|
|
|
|
|
static size_t spi_flash_get_jedec_id(struct flash_dev *dev, char *jedec_id, |
|
|
|
|
size_t len); |
|
|
|
|
static size_t spi_flash_get_size(struct flash_dev *dev); |
|
|
|
|
static size_t spi_flash_read(struct flash_dev *dev, uint32_t addr, void *data, |
|
|
|
|
size_t len); |
|
|
|
@ -21,6 +23,7 @@ static struct flash_ops spi_flash_ops = { |
|
|
|
|
.release = spi_flash_release, |
|
|
|
|
.get_size = spi_flash_get_size, |
|
|
|
|
.get_capacity = spi_flash_get_size, |
|
|
|
|
.get_jedec_id = spi_flash_get_jedec_id, |
|
|
|
|
.read = spi_flash_read, |
|
|
|
|
.write = spi_flash_write, |
|
|
|
|
.copy = default_flash_copy, |
|
|
|
@ -167,6 +170,7 @@ static int spi_flash_erase(struct flash_dev *dev, uint32_t addr) |
|
|
|
|
|
|
|
|
|
struct flash_dev *flash_probe(void) |
|
|
|
|
{ |
|
|
|
|
char jedec_id[3] = { 0, 0, 0 }; |
|
|
|
|
struct flash_dev *dev; |
|
|
|
|
|
|
|
|
|
if (!(dev = malloc(sizeof *dev))) |
|
|
|
@ -178,6 +182,9 @@ struct flash_dev *flash_probe(void) |
|
|
|
|
dev->ops = &spi_flash_ops; |
|
|
|
|
dev->log2_block_size = ilog2(4 * KIB); |
|
|
|
|
|
|
|
|
|
if (!spi_flash_get_jedec_id(dev, jedec_id, 3) || !jedec_id[0]) |
|
|
|
|
goto err_free_dev; |
|
|
|
|
|
|
|
|
|
return dev; |
|
|
|
|
|
|
|
|
|
err_free_dev: |
|
|
|
|