mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Eric Bénard" <eric@eukrea.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] mx23-evk: fix MCI support
Date: Sun, 10 Feb 2013 17:22:49 +0100	[thread overview]
Message-ID: <1360513371-16470-1-git-send-email-eric@eukrea.com> (raw)

- 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>
---
 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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2013-02-10 16:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-10 16:22 Eric Bénard [this message]
2013-02-10 16:22 ` [PATCH 2/3] mx23-evk: add USB gadget support Eric Bénard
2013-02-10 16:22 ` [PATCH 3/3] mx23-evk: update defconfig Eric Bénard
2013-02-11  9:31 ` [PATCH 1/3] mx23-evk: fix MCI support Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360513371-16470-1-git-send-email-eric@eukrea.com \
    --to=eric@eukrea.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox