core: spi: flash: implement flash_get_jedec_id()

tags/0.1.0
S.J.R. van Schaik 7 years ago
parent 238ea35524
commit 81430df971
  1. 2
      include/flash.h
  2. 8
      source/core/flash.c
  3. 3
      source/platform/spi_flash.c

@ -7,6 +7,7 @@ struct flash_dev;
struct flash_ops {
void (* release)(struct flash_dev *dev);
size_t (* get_jedec_id)(struct flash_dev *dev, char *jedec_id, size_t len);
size_t (* get_size)(struct flash_dev *dev);
size_t (* get_capacity)(struct flash_dev *dev);
size_t (* read)(struct flash_dev *dev, uint32_t addr, void *data, size_t len);
@ -31,6 +32,7 @@ size_t default_flash_copy(struct flash_dev *dev, uint32_t dst, uint32_t src,
struct flash_dev *flash_probe(void);
void flash_release(struct flash_dev *dev);
size_t flash_get_jedec_id(struct flash_dev *dev, char *jedec_id, size_t len);
size_t flash_get_size(struct flash_dev *dev);
size_t flash_get_capacity(struct flash_dev *dev);
size_t flash_read(struct flash_dev *dev, uint32_t addr, void *data, size_t len);

@ -72,6 +72,14 @@ void flash_release(struct flash_dev *dev)
dev->ops->release(dev);
}
size_t flash_get_jedec_id(struct flash_dev *dev, char *jedec_id, size_t len)
{
if (!dev || !dev->ops->get_jedec_id)
return 0;
return dev->ops->get_jedec_id(dev, jedec_id, len);
}
size_t flash_get_size(struct flash_dev *dev)
{
if (!dev)

@ -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,

Loading…
Cancel
Save