[U-Boot] [RFC PATCH] scsi: ceva: Convert driver to use UCLASS_AHCI instead of SCSI

Michal Simek michal.simek at xilinx.com
Fri Apr 6 12:18:33 UTC 2018


In v2018 the patch
"dm: ahci: Correct uclass private data"
(sha1: bfc1c6b4838501d10aa48c0e92eaf70976f4b2dd)
was causing an issue for ceva_sata.
But this issue is not in v2018.05-rc1 but still converting to
UCLASS_AHCI would make more sense.

Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---

 drivers/ata/sata_ceva.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/drivers/ata/sata_ceva.c b/drivers/ata/sata_ceva.c
index bae26898bad2..2a9f8041e3ef 100644
--- a/drivers/ata/sata_ceva.c
+++ b/drivers/ata/sata_ceva.c
@@ -73,6 +73,10 @@
 #define DRV_NAME	"ahci-ceva"
 #define CEVA_FLAG_BROKEN_GEN2	1
 
+struct ceva_sata_priv {
+	ulong base;
+};
+
 static int ceva_init_sata(ulong mmio)
 {
 	ulong tmp;
@@ -111,18 +115,20 @@ static int ceva_init_sata(ulong mmio)
 	return 0;
 }
 
-static int sata_ceva_probe(struct udevice *dev)
+static int sata_ceva_bind(struct udevice *dev)
 {
-	int ret;
-	struct scsi_platdata *plat = dev_get_uclass_platdata(dev);
+	struct udevice *scsi_dev;
+
+	return ahci_bind_scsi(dev, &scsi_dev);
+}
 
-	ceva_init_sata(plat->base);
+static int sata_ceva_probe(struct udevice *dev)
+{
+	struct ceva_sata_priv *priv = dev_get_priv(dev);
 
-	ret = ahci_init_one_dm(dev);
-	if (ret)
-		return ret;
+	ceva_init_sata(priv->base);
 
-	return ahci_start_ports_dm(dev);
+	return ahci_probe_scsi(dev, priv->base);
 }
 
 static const struct udevice_id sata_ceva_ids[] = {
@@ -132,24 +138,22 @@ static const struct udevice_id sata_ceva_ids[] = {
 
 static int sata_ceva_ofdata_to_platdata(struct udevice *dev)
 {
-	struct scsi_platdata *plat = dev_get_uclass_platdata(dev);
+	struct ceva_sata_priv *priv = dev_get_priv(dev);
 
-	plat->base = devfdt_get_addr(dev);
-	if (plat->base == FDT_ADDR_T_NONE)
+	priv->base = devfdt_get_addr(dev);
+	if (priv->base == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
-	/* Hardcode number for ceva sata controller */
-	plat->max_lun = 1; /* Actually two but untested */
-	plat->max_id = 2;
-
 	return 0;
 }
 
 U_BOOT_DRIVER(ceva_host_blk) = {
 	.name = "ceva_sata",
-	.id = UCLASS_SCSI,
+	.id = UCLASS_AHCI,
 	.of_match = sata_ceva_ids,
+	.bind = sata_ceva_bind,
 	.ops = &scsi_ops,
+	.priv_auto_alloc_size = sizeof(struct ceva_sata_priv),
 	.probe = sata_ceva_probe,
 	.ofdata_to_platdata = sata_ceva_ofdata_to_platdata,
 };
-- 
1.9.1



More information about the U-Boot mailing list