diff options
author | Simon Glass <sjg@chromium.org> | 2016-05-01 11:36:26 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-05-17 09:54:43 -0600 |
commit | f5a14af9c42be077404dbbeaebbb629f7ddcbed6 (patch) | |
tree | 2c3020ac68217a70f3fff29bda077aba85f86923 | |
parent | e8c0a2509c6ec62a5c58a39c338cc1127bc83e1a (diff) |
dm: sata: Add support for driver-model block devices
Add driver-model block-device support to the SATA implementation. This is
just a dummy implementation for now, since the SATA low-level API uses
numbered devices and that doesn't fit with driver model.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | common/sata.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/common/sata.c b/common/sata.c index 1d52fcb2dcb..88f08c95eca 100644 --- a/common/sata.c +++ b/common/sata.c @@ -11,6 +11,7 @@ */ #include <common.h> +#include <dm.h> #include <sata.h> struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE]; @@ -22,6 +23,19 @@ struct blk_desc *sata_get_dev(int dev) } #endif +#ifdef CONFIG_BLK +static unsigned long sata_bread(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, void *dst) +{ + return -ENOSYS; +} + +static unsigned long sata_bwrite(struct udevice *dev, lbaint_t start, + lbaint_t blkcnt, const void *buffer) +{ + return -ENOSYS; +} +#else static unsigned long sata_bread(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, void *dst) { @@ -33,6 +47,7 @@ static unsigned long sata_bwrite(struct blk_desc *block_dev, lbaint_t start, { return sata_write(block_dev->devnum, start, blkcnt, buffer); } +#endif int __sata_initialize(void) { @@ -48,9 +63,10 @@ int __sata_initialize(void) sata_dev_desc[i].lba = 0; sata_dev_desc[i].blksz = 512; sata_dev_desc[i].log2blksz = LOG2(sata_dev_desc[i].blksz); +#ifndef CONFIG_BLK sata_dev_desc[i].block_read = sata_bread; sata_dev_desc[i].block_write = sata_bwrite; - +#endif rc = init_sata(i); if (!rc) { rc = scan_sata(i); @@ -78,9 +94,22 @@ __weak int __sata_stop(void) } int sata_stop(void) __attribute__((weak, alias("__sata_stop"))); +#ifdef CONFIG_BLK +static const struct blk_ops sata_blk_ops = { + .read = sata_bread, + .write = sata_bwrite, +}; + +U_BOOT_DRIVER(sata_blk) = { + .name = "sata_blk", + .id = UCLASS_BLK, + .ops = &sata_blk_ops, +}; +#else U_BOOT_LEGACY_BLK(sata) = { .if_typename = "sata", .if_type = IF_TYPE_SATA, .max_devs = CONFIG_SYS_SATA_MAX_DEVICE, .desc = sata_dev_desc, }; +#endif |