summaryrefslogtreecommitdiffstats
path: root/drivers/mci
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-04-08 10:17:15 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-04-08 10:17:15 +0200
commitc239b65fc2bc779343d7b8f0afd1c4cac1dd0beb (patch)
tree0f4cd6fb5cf7fae9f67d5eb7a95f24ecead54e35 /drivers/mci
parent62e4a326f060853bb2ef0bb03c11f1b5bab2cdb9 (diff)
parent26b2a029e97369efbe1520fc3a7f2412ccb1baeb (diff)
downloadbarebox-c239b65fc2bc779343d7b8f0afd1c4cac1dd0beb.tar.gz
barebox-c239b65fc2bc779343d7b8f0afd1c4cac1dd0beb.tar.xz
Merge branch 'for-next/layerscape'
Diffstat (limited to 'drivers/mci')
-rw-r--r--drivers/mci/imx-esdhc-pbl.c60
-rw-r--r--drivers/mci/imx-esdhc.c3
2 files changed, 61 insertions, 2 deletions
diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c
index 8a03c5fcf4..f7f8c3348d 100644
--- a/drivers/mci/imx-esdhc-pbl.c
+++ b/drivers/mci/imx-esdhc-pbl.c
@@ -15,11 +15,12 @@
#include <io.h>
#include <mci.h>
#include <linux/sizes.h>
+#include <asm-generic/sections.h>
+#include <mach/xload.h>
#ifdef CONFIG_ARCH_IMX
#include <mach/atf.h>
#include <mach/imx6-regs.h>
#include <mach/imx8mq-regs.h>
-#include <mach/xload.h>
#include <mach/imx-header.h>
#endif
#include "sdhci.h"
@@ -406,3 +407,60 @@ int imx8_esdhc_start_image(int instance)
MX8MQ_ATF_BL33_BASE_ADDR, SZ_32K);
}
#endif
+
+#ifdef CONFIG_ARCH_LS1046
+
+/*
+ * The image on the SD card starts at 0x1000. We reserved 128KiB for the PBL,
+ * so the 2nd stage image starts here:
+ */
+#define LS1046A_SD_IMAGE_OFFSET (SZ_4K + SZ_128K)
+
+/**
+ * ls1046a_esdhc_start_image - Load and start a 2nd stage from the ESDHC controller
+ *
+ * This loads and starts a 2nd stage barebox from an SD card and starts it. We
+ * assume the image has been generated with scripts/pblimage.c which puts the
+ * second stage to an offset of 128KiB in the image.
+ *
+ * Return: If successful, this function does not return. A negative error
+ * code is returned when this function fails.
+ */
+int ls1046a_esdhc_start_image(unsigned long r0, unsigned long r1, unsigned long r2)
+{
+ int ret;
+ uint32_t val;
+ struct esdhc esdhc = {
+ .regs = IOMEM(0x01560000),
+ .is_be = true,
+ };
+ unsigned long sdram = 0x80000000;
+ void (*barebox)(unsigned long, unsigned long, unsigned long) =
+ (void *)(sdram + LS1046A_SD_IMAGE_OFFSET);
+
+ /*
+ * The ROM leaves us here with a clock frequency of around 400kHz. Speed
+ * this up a bit. FIXME: The resulting frequency has not yet been verified
+ * to work on all cards.
+ */
+ val = esdhc_read32(&esdhc, SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET);
+ val &= ~0x0000fff0;
+ val |= (2 << 8) | (6 << 4);
+ esdhc_write32(&esdhc, SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET, val);
+
+ esdhc_write32(&esdhc, ESDHC_DMA_SYSCTL, ESDHC_SYSCTL_DMA_SNOOP);
+
+ ret = esdhc_read_blocks(&esdhc, (void *)sdram,
+ ALIGN(barebox_image_size + LS1046A_SD_IMAGE_OFFSET, 512));
+ if (ret) {
+ pr_err("%s: reading blocks failed with: %d\n", __func__, ret);
+ return ret;
+ }
+
+ printf("Starting barebox\n");
+
+ barebox(r0, r1, r2);
+
+ return -EINVAL;
+}
+#endif
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index 2fa0974742..f71ca539ed 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -741,7 +741,8 @@ static struct esdhc_soc_data usdhc_imx6sx_data = {
};
static struct esdhc_soc_data esdhc_ls_data = {
- .flags = ESDHC_FLAG_MULTIBLK_NO_INT | ESDHC_FLAG_BIGENDIAN,
+ .flags = ESDHC_FLAG_MULTIBLK_NO_INT | ESDHC_FLAG_BIGENDIAN |
+ ESDHC_FLAG_CACHE_SNOOPING,
};
static __maybe_unused struct of_device_id fsl_esdhc_compatible[] = {