mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 13/23] mci: Allow to partition eMMC boot partitions
Date: Mon, 16 Jan 2017 11:50:58 +0100	[thread overview]
Message-ID: <20170116105108.13617-14-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20170116105108.13617-1-s.hauer@pengutronix.de>

So far the eMMC boot partitions cannot be partitioned from the
device tree. Since they are often 4MiB in size they are big enough
to hold a barebox image and the environment. Add partition parsing
to the boot partitions to allow this usecase.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c | 78 +++++++++++++++++++++++++++++++++++---------------
 include/mci.h          |  1 +
 2 files changed, 56 insertions(+), 23 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 4e176f7b3..055a5e2b0 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -436,6 +436,7 @@ static void mci_part_add(struct mci *mci, uint64_t size,
 	part->blk.num_blocks = mci_calc_blk_cnt(size, part->blk.blockbits);
 	part->area_type = area_type;
 	part->part_cfg = part_cfg;
+	part->idx = idx;
 
 	if (area_type == MMC_BLK_DATA_AREA_MAIN)
 		part->blk.cdev.device_node = mci->host->hw_dev->device_node;
@@ -1573,6 +1574,59 @@ static const char *mci_boot_names[] = {
 	"user",
 };
 
+static int mci_register_partition(struct mci_part *part)
+{
+	struct mci *mci = part->mci;
+	struct mci_host *host = mci->host;
+	const char *partnodename = NULL;
+	struct device_node *np;
+	int rc;
+
+	/*
+	 * An MMC/SD card acts like an ordinary disk.
+	 * So, re-use the disk driver to gain access to this media
+	 */
+	part->blk.dev = &mci->dev;
+	part->blk.ops = &mci_ops;
+
+	rc = blockdevice_register(&part->blk);
+	if (rc != 0) {
+		dev_err(&mci->dev, "Failed to register MCI/SD blockdevice\n");
+		return rc;
+	}
+	dev_info(&mci->dev, "registered %s\n", part->blk.cdev.name);
+
+	np = host->hw_dev->device_node;
+
+	/* create partitions on demand */
+	switch (part->area_type) {
+	case MMC_BLK_DATA_AREA_BOOT:
+		if (part->idx == 0)
+			partnodename = "boot0-partitions";
+		else
+			partnodename = "boot1-partitions";
+
+		np = of_get_child_by_name(host->hw_dev->device_node,
+					  partnodename);
+		break;
+	case MMC_BLK_DATA_AREA_MAIN:
+		break;
+	default:
+		return 0;
+	}
+
+	rc = parse_partition_table(&part->blk);
+	if (rc != 0) {
+		dev_warn(&mci->dev, "No partition table found\n");
+		rc = 0; /* it's not a failure */
+	}
+
+	if (np)
+		of_parse_partitions(&part->blk.cdev, np);
+
+	return 0;
+}
+
 /**
  * Probe an MCI card at the given host interface
  * @param mci MCI device instance
@@ -1647,29 +1701,7 @@ static int mci_card_probe(struct mci *mci)
 	for (i = 0; i < mci->nr_parts; i++) {
 		struct mci_part *part = &mci->part[i];
 
-		/*
-		 * An MMC/SD card acts like an ordinary disk.
-		 * So, re-use the disk driver to gain access to this media
-		 */
-		part->blk.dev = &mci->dev;
-		part->blk.ops = &mci_ops;
-
-		rc = blockdevice_register(&part->blk);
-		if (rc != 0) {
-			dev_err(&mci->dev, "Failed to register MCI/SD blockdevice\n");
-			goto on_error;
-		}
-		dev_info(&mci->dev, "registered %s\n", part->blk.cdev.name);
-
-		/* create partitions on demand */
-		if (part->area_type == MMC_BLK_DATA_AREA_MAIN) {
-			rc = parse_partition_table(&part->blk);
-			if (rc != 0) {
-				dev_warn(&mci->dev, "No partition table found\n");
-				rc = 0; /* it's not a failure */
-			}
-			of_parse_partitions(&part->blk.cdev, host->hw_dev->device_node);
-		}
+		rc = mci_register_partition(part);
 
 		if (IS_ENABLED(CONFIG_MCI_MMC_BOOT_PARTITIONS) &&
 				part->area_type == MMC_BLK_DATA_AREA_BOOT &&
diff --git a/include/mci.h b/include/mci.h
index 0370547b0..cc4712cfa 100644
--- a/include/mci.h
+++ b/include/mci.h
@@ -433,6 +433,7 @@ struct mci_part {
 	uint64_t		size;		/* partition size (in bytes) */
 	unsigned int		part_cfg;	/* partition type */
 	char			*name;
+	int			idx;
 	unsigned int		area_type;
 #define MMC_BLK_DATA_AREA_MAIN	(1<<0)
 #define MMC_BLK_DATA_AREA_BOOT	(1<<1)
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2017-01-16 10:51 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 10:50 i.MX7 support Sascha Hauer
2017-01-16 10:50 ` [PATCH 01/23] imx-usb-loader: let constant data be const Sascha Hauer
2017-01-16 10:50 ` [PATCH 02/23] imx-usb-loader: this table is used internally only, so keep it static Sascha Hauer
2017-01-16 11:29   ` Juergen Borleis
2017-01-16 10:50 ` [PATCH 03/23] imx-usb-loader: add i.MX7S support Sascha Hauer
2017-01-16 10:50 ` [PATCH 04/23] ARM: Makefile: format fix Sascha Hauer
2017-01-16 10:50 ` [PATCH 05/23] i2c: i.MX: Enable clock Sascha Hauer
2017-01-16 10:50 ` [PATCH 06/23] mci: imx-esdhc: " Sascha Hauer
2017-01-16 10:50 ` [PATCH 07/23] serial: i.MX: " Sascha Hauer
2017-01-16 10:50 ` [PATCH 08/23] usb: imx: Make usb-misc multi instance safe Sascha Hauer
2017-01-16 10:50 ` [PATCH 09/23] usb: imx: Add usbmisc support for i.MX7 Sascha Hauer
2017-01-16 10:50 ` [PATCH 10/23] usb: imx: Add clock support Sascha Hauer
2017-01-16 10:50 ` [PATCH 11/23] phy: usb-nop-xceiv: " Sascha Hauer
2017-01-16 10:50 ` [PATCH 12/23] of: partitions: force "partitions" subnode Sascha Hauer
2017-01-16 10:50 ` Sascha Hauer [this message]
2017-01-16 10:50 ` [PATCH 14/23] mci: imx-esdhci: remove wrong write protection test Sascha Hauer
2017-01-16 10:51 ` [PATCH 15/23] ARM: i.MX: Add i.MX7 base architecture support Sascha Hauer
2017-01-16 10:51 ` [PATCH 16/23] clk: i.MX: pllv3: Add support for the i.MX7 enet pll Sascha Hauer
2017-01-16 10:51 ` [PATCH 17/23] clk: imx: Add clk-cpu support Sascha Hauer
2017-01-16 10:51 ` [PATCH 18/23] clk: i.MX: Add clock support for i.MX7 Sascha Hauer
2017-01-16 10:51 ` [PATCH 19/23] clk: i.MX7: Add missing USB clocks Sascha Hauer
2017-01-16 10:51 ` [PATCH 20/23] ARM: i.MX: gpt: Add i.MX7 support Sascha Hauer
2017-01-16 11:35   ` Juergen Borleis
2017-01-16 10:51 ` [PATCH 21/23] pinmmux: i.MX: add pin mux support for i.MX7 Sascha Hauer
2017-01-16 10:51 ` [PATCH 22/23] serial: i.MX: add i.MX7 support Sascha Hauer
2017-01-16 10:51 ` [PATCH 23/23] ARM: i.MX: Add WaRP7 board support Sascha Hauer
2017-01-16 10:58 ` i.MX7 support Fabio Estevam
2017-01-16 12:58   ` Sascha Hauer
2017-01-17 12:07     ` Fabio Estevam
2017-01-18  7:07       ` Sascha Hauer
2017-01-18  9:36         ` Fabio Estevam
2017-01-19  9:14           ` Sascha Hauer
2017-01-19 11:54             ` Fabio Estevam
2017-01-19 12:38               ` Sascha Hauer
2017-01-19 17:32                 ` Fabio Estevam
2017-01-16 11:02 ` Belisko Marek
2017-01-16 11:38   ` Robert Schwebel
2017-01-16 11:51     ` Belisko Marek

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=20170116105108.13617-14-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --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