- 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 <[email protected]>
---
 arch/arm/boards/freescale-mx23-evk/mx23-evk.c | 54 +++++++++++++++++++++++++--
 1 file 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 0c5fa4b..043b62b 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;
 }
-- 
1.7.11.7


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to