summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Bénard <eric@eukrea.com>2013-02-10 17:22:49 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-02-11 20:58:35 +0100
commitf850d96eb56e567f1d6d67d712bfb743302cf928 (patch)
treea1c5506a118e3bc1794403780c51b9024e972959
parent43e99fa0076301b6ac379c5d5278f894c0565a85 (diff)
downloadbarebox-f850d96eb56e567f1d6d67d712bfb743302cf928.tar.gz
barebox-f850d96eb56e567f1d6d67d712bfb743302cf928.tar.xz
mx23-evk: fix MCI support
- this patch fix MCI support and enable using the SDCard to store the environment. - it is fully copied from imx23-olinuxino.c - tested on i.MX23 EVK RevB1 Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/boards/freescale-mx23-evk/mx23-evk.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/arch/arm/boards/freescale-mx23-evk/mx23-evk.c b/arch/arm/boards/freescale-mx23-evk/mx23-evk.c
index 0c5fa4b51..043b62be2 100644
--- a/arch/arm/boards/freescale-mx23-evk/mx23-evk.c
+++ b/arch/arm/boards/freescale-mx23-evk/mx23-evk.c
@@ -26,8 +26,9 @@
#include <mach/mci.h>
static struct mxs_mci_platform_data mci_pdata = {
- .caps = MMC_MODE_4BIT,
+ .caps = MMC_MODE_4BIT | MMC_MODE_HS | MMC_MODE_HS_52MHz,
.voltages = MMC_VDD_32_33 | MMC_VDD_33_34, /* fixed to 3.3 V */
+ .f_min = 400000,
};
static const uint32_t pad_setup[] = {
@@ -49,9 +50,48 @@ static int mx23_evk_mem_init(void)
}
mem_initcall(mx23_evk_mem_init);
+/**
+ * Try to register an environment storage on the attached MCI card
+ * @return 0 on success
+ *
+ * We rely on the existence of a usable SD card, already attached to
+ * our system, to get something like a persistent memory for our environment.
+ * If this SD card is also the boot media, we can use the second partition
+ * for our environment purpose (if present!).
+ */
+static int register_persistant_environment(void)
+{
+ struct cdev *cdev;
+
+ /*
+ * The imx23-olinuxino only has one MCI card socket.
+ * So, we expect its name as "disk0".
+ */
+ cdev = cdev_by_name("disk0");
+ if (cdev == NULL) {
+ pr_err("No MCI card preset\n");
+ return -ENODEV;
+ }
+
+
+
+ /* MCI card is present, also a useable partition on it? */
+ cdev = cdev_by_name("disk0.1");
+ if (cdev == NULL) {
+ pr_err("No second partition available\n");
+ pr_info("Please create at least a second partition with"
+ " 256 kiB...512 kiB in size (your choice)\n");
+ return -ENODEV;
+ }
+
+ /* use the full partition as our persistent environment storage */
+ return devfs_add_partition("disk0.1", 0, cdev->size,
+ DEVFS_PARTITION_FIXED, "env0");
+}
+
static int mx23_evk_devices_init(void)
{
- int i;
+ int i, rc;
/* initizalize gpios */
for (i = 0; i < ARRAY_SIZE(pad_setup); i++)
@@ -62,8 +102,14 @@ static int mx23_evk_devices_init(void)
imx_set_ioclk(480000000); /* enable IOCLK to run at the PLL frequency */
imx_set_sspclk(0, 100000000, 1);
- add_generic_device("mxs_mci", 0, NULL, IMX_SSP1_BASE, 0,
- IORESOURCE_MEM, &mci_pdata);
+
+ add_generic_device("mxs_mci", DEVICE_ID_DYNAMIC, NULL, IMX_SSP1_BASE,
+ 0x8000, IORESOURCE_MEM, &mci_pdata);
+
+ rc = register_persistant_environment();
+ if (rc != 0)
+ printf("Cannot create the 'env0' persistant "
+ "environment storage (%d)\n", rc);
return 0;
}