aboutsummaryrefslogtreecommitdiff
path: root/board/compulab
diff options
context:
space:
mode:
authorSimon Glass2017-07-29 11:35:25 -0600
committerJaehoon Chung2017-08-17 16:44:17 +0900
commit8d331e38e056542399f8453141b42eb725edae37 (patch)
treed7d6d8d8889e39481fc5c53c88e13bf863b4ecba /board/compulab
parent653282b5672c6a9b50cb045510e95f44e20ab8a7 (diff)
dm: imx: cm_fx6: Support driver model for SATA
Add support for using driver model for SATA with the cm_fx6 board. The old code remains for now to permit testing. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'board/compulab')
-rw-r--r--board/compulab/cm_fx6/cm_fx6.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index c59884a8c31..ecefe394f1a 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -9,7 +9,9 @@
*/
#include <common.h>
+#include <ahci.h>
#include <dm.h>
+#include <dwc_ahsata.h>
#include <fsl_esdhc.h>
#include <miiphy.h>
#include <mtd_node.h>
@@ -29,6 +31,7 @@
#include <asm/io.h>
#include <asm/gpio.h>
#include <dm/platform_data/serial_mxc.h>
+#include <dm/device-internal.h>
#include <jffs2/load_kernel.h>
#include "common.h"
#include "../common/eeprom.h"
@@ -206,6 +209,8 @@ static int cm_fx6_setup_issd(void)
}
#define CM_FX6_SATA_INIT_RETRIES 10
+
+# if !CONFIG_IS_ENABLED(AHCI)
int sata_initialize(void)
{
int err, i;
@@ -246,6 +251,7 @@ int sata_stop(void)
return 0;
}
+# endif
#else
static int cm_fx6_setup_issd(void) { return 0; }
#endif
@@ -757,3 +763,66 @@ U_BOOT_DEVICE(cm_fx6_serial) = {
.name = "serial_mxc",
.platdata = &cm_fx6_mxc_serial_plat,
};
+
+#if CONFIG_IS_ENABLED(AHCI)
+static int sata_imx_probe(struct udevice *dev)
+{
+ int i, err;
+
+ /* Make sure this gpio has logical 0 value */
+ gpio_direction_output(CM_FX6_SATA_PWLOSS_INT, 0);
+ udelay(100);
+ cm_fx6_sata_power(1);
+
+ for (i = 0; i < CM_FX6_SATA_INIT_RETRIES; i++) {
+ err = setup_sata();
+ if (err) {
+ printf("SATA setup failed: %d\n", err);
+ return err;
+ }
+
+ udelay(100);
+
+ err = dwc_ahsata_probe(dev);
+ if (!err)
+ break;
+
+ /* There is no device on the SATA port */
+ if (sata_dm_port_status(0, 0) == 0)
+ break;
+
+ /* There's a device, but link not established. Retry */
+ device_remove(dev, DM_REMOVE_NORMAL);
+ }
+
+ return 0;
+}
+
+static int sata_imx_remove(struct udevice *dev)
+{
+ cm_fx6_sata_power(0);
+ mdelay(250);
+
+ return 0;
+}
+
+struct ahci_ops sata_imx_ops = {
+ .port_status = dwc_ahsata_port_status,
+ .reset = dwc_ahsata_bus_reset,
+ .scan = dwc_ahsata_scan,
+};
+
+static const struct udevice_id sata_imx_ids[] = {
+ { .compatible = "fsl,imx6q-ahci" },
+ { }
+};
+
+U_BOOT_DRIVER(sata_imx) = {
+ .name = "dwc_ahci",
+ .id = UCLASS_AHCI,
+ .of_match = sata_imx_ids,
+ .ops = &sata_imx_ops,
+ .probe = sata_imx_probe,
+ .remove = sata_imx_remove, /* reset bus to stop it */
+};
+#endif /* AHCI */