summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-07-29 11:35:15 -0600
committerJaehoon Chung <jh80.chung@samsung.com>2017-08-17 16:44:17 +0900
commitb8341f1c39df8708ee783038d8abb2b50dd83fac (patch)
treef640f5e5024d4e995c948e7655e9d649b3c42788
parent7e0712b26ee877ca46cc7ba9978c52a9c3f40dc4 (diff)
dm: sata: Update the AHCI uclass to support operations
At present the AHCI uclass is just a shell and we still use the global functions to access SATA. Fix this by adding operations to the uclass. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/ata/sata.c37
-rw-r--r--include/ahci.h54
2 files changed, 91 insertions, 0 deletions
diff --git a/drivers/ata/sata.c b/drivers/ata/sata.c
index 42ff5c7755..b3ebc05ead 100644
--- a/drivers/ata/sata.c
+++ b/drivers/ata/sata.c
@@ -11,17 +11,52 @@
*/
#include <common.h>
+#include <ahci.h>
#include <dm.h>
#include <sata.h>
+#ifndef CONFIG_AHCI
struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
+#endif
+
+int sata_reset(struct udevice *dev)
+{
+ struct ahci_ops *ops = ahci_get_ops(dev);
+
+ if (!ops->reset)
+ return -ENOSYS;
+
+ return ops->reset(dev);
+}
+
+int sata_dm_port_status(struct udevice *dev, int port)
+{
+ struct ahci_ops *ops = ahci_get_ops(dev);
+
+ if (!ops->port_status)
+ return -ENOSYS;
+ return ops->port_status(dev, port);
+}
+
+int sata_scan(struct udevice *dev)
+{
+ struct ahci_ops *ops = ahci_get_ops(dev);
+
+ if (!ops->scan)
+ return -ENOSYS;
+
+ return ops->scan(dev);
+}
+
+#ifndef CONFIG_AHCI
#ifdef CONFIG_PARTITIONS
struct blk_desc *sata_get_dev(int dev)
{
return (dev < CONFIG_SYS_SATA_MAX_DEVICE) ? &sata_dev_desc[dev] : NULL;
}
#endif
+#endif
#ifdef CONFIG_BLK
static unsigned long sata_bread(struct udevice *dev, lbaint_t start,
@@ -49,6 +84,7 @@ static unsigned long sata_bwrite(struct blk_desc *block_dev, lbaint_t start,
}
#endif
+#ifndef CONFIG_AHCI
int __sata_initialize(void)
{
int rc, ret = -1;
@@ -95,6 +131,7 @@ __weak int __sata_stop(void)
return err;
}
int sata_stop(void) __attribute__((weak, alias("__sata_stop")));
+#endif
#ifdef CONFIG_BLK
static const struct blk_ops sata_blk_ops = {
diff --git a/include/ahci.h b/include/ahci.h
index 29f4ba1d13..33171b7ffd 100644
--- a/include/ahci.h
+++ b/include/ahci.h
@@ -176,6 +176,60 @@ struct ahci_uc_priv {
u32 link_port_map; /*linkup port map*/
};
+struct ahci_ops {
+ /**
+ * reset() - reset the controller
+ *
+ * @dev: Controller to reset
+ * @return 0 if OK, -ve on error
+ */
+ int (*reset)(struct udevice *dev);
+
+ /**
+ * port_status() - get the status of a SATA port
+ *
+ * @dev: Controller to reset
+ * @port: Port number to check (0 for first)
+ * @return 0 if detected, -ENXIO if nothing on port, other -ve on error
+ */
+ int (*port_status)(struct udevice *dev, int port);
+
+ /**
+ * scan() - scan SATA ports
+ *
+ * @dev: Controller to scan
+ * @return 0 if OK, -ve on error
+ */
+ int (*scan)(struct udevice *dev);
+};
+
+#define ahci_get_ops(dev) ((struct ahci_ops *)(dev)->driver->ops)
+
+/**
+ * sata_reset() - reset the controller
+ *
+ * @dev: Controller to reset
+ * @return 0 if OK, -ve on error
+ */
+int sata_reset(struct udevice *dev);
+
+/**
+ * sata_port_status() - get the status of a SATA port
+ *
+ * @dev: Controller to reset
+ * @port: Port number to check (0 for first)
+ * @return 0 if detected, -ENXIO if nothin on port, other -ve on error
+ */
+int sata_dm_port_status(struct udevice *dev, int port);
+
+/**
+ * sata_scan() - scan SATA ports
+ *
+ * @dev: Controller to scan
+ * @return 0 if OK, -ve on error
+ */
+int sata_scan(struct udevice *dev);
+
int ahci_init(void __iomem *base);
int ahci_reset(void __iomem *base);