From: Simon Glass Date: Sun, 1 May 2016 17:36:26 +0000 (-0600) Subject: dm: sata: Add support for driver-model block devices X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=f5a14af9c42be077404dbbeaebbb629f7ddcbed6;p=u-boot.git 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 --- diff --git a/common/sata.c b/common/sata.c index 1d52fcb2dc..88f08c95ec 100644 --- a/common/sata.c +++ b/common/sata.c @@ -11,6 +11,7 @@ */ #include +#include #include 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