From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 1/2] mci: parse upstream boot/gp partition binding
Date: Thu, 5 Dec 2024 09:55:29 +0100 [thread overview]
Message-ID: <20241205085530.3897385-1-s.hauer@pengutronix.de> (raw)
Linux recently added support for device tree partition binding for
SD/eMMC devices. Linux supports partitioning the main area as well as
the boot and gp areas. This adds support for the same binding to
barebox.
barebox already had support for partitioning the eMMC boot partitions,
unfortunately with different node names. Try the upstream binding first
and fall back to the barebox binding if upstream compatible nodes are
not found.
Note that not only the node names for the boot partitions differ in
both bindings, but also the numbering. "boot0-partitions" in the
barebox binding matches "partitions-boot1" in the upstream binding.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
.../devicetree/bindings/mtd/partition.rst | 3 +
drivers/mci/mci-core.c | 62 ++++++++++++-------
2 files changed, 43 insertions(+), 22 deletions(-)
diff --git a/Documentation/devicetree/bindings/mtd/partition.rst b/Documentation/devicetree/bindings/mtd/partition.rst
index 0ba117dffc..fb228c63a3 100644
--- a/Documentation/devicetree/bindings/mtd/partition.rst
+++ b/Documentation/devicetree/bindings/mtd/partition.rst
@@ -23,6 +23,9 @@ the partition table node is named appropriately:
* ``boot0-partitions`` : boot0 partition
* ``boot1-partitions`` : boot1 partition
+``boot0-partitions`` and ``boot1-partitions`` are deprecated. Use ``partitions-boot1``
+and ``partitions-boot2`` instead which is supported under Linux as well.
+
Examples:
.. code-block:: none
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 48a3df9ec9..eb723a2711 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2582,11 +2582,49 @@ static const char *mci_boot_names[] = {
"user",
};
+static struct device_node *mci_get_partition_node(struct device_node *hwnode,
+ unsigned int type,
+ unsigned int index)
+{
+ struct device_node *np;
+ char partnodename[sizeof("bootx-partitions")];
+
+ if (index > 8)
+ return NULL;
+
+ switch (type) {
+ case MMC_BLK_DATA_AREA_BOOT:
+ sprintf(partnodename, "partitions-boot%u", index + 1);
+ break;
+ case MMC_BLK_DATA_AREA_MAIN:
+ return hwnode;
+ case MMC_BLK_DATA_AREA_GP:
+ sprintf(partnodename, "partitions-gp%u", index + 1);
+ break;
+ default:
+ return NULL;
+ }
+
+ np = of_get_child_by_name(hwnode, partnodename);
+ if (np)
+ return np;
+
+ if (type != MMC_BLK_DATA_AREA_BOOT)
+ return NULL;
+
+ /*
+ * barebox historically understands "bootx-partitions" with x starting
+ * at zero.
+ */
+ sprintf(partnodename, "boot%u-partitions", index);
+
+ return of_get_child_by_name(hwnode, partnodename);
+}
+
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;
@@ -2605,27 +2643,7 @@ static int mci_register_partition(struct mci_part *part)
}
dev_info(&mci->dev, "registered %s\n", part->blk.cdev.name);
- np = host->hw_dev->of_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->of_node,
- partnodename);
- break;
- case MMC_BLK_DATA_AREA_MAIN:
- break;
- case MMC_BLK_DATA_AREA_GP:
- break;
- default:
- return 0;
- }
-
+ np = mci_get_partition_node(host->hw_dev->of_node, part->area_type, part->idx);
if (np) {
of_parse_partitions(&part->blk.cdev, np);
--
2.39.5
next reply other threads:[~2024-12-05 8:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-05 8:55 Sascha Hauer [this message]
2024-12-05 8:55 ` [PATCH 2/2] ARM: dts: Use upstream eMMC boot " Sascha Hauer
2024-12-06 9:43 ` [PATCH 1/2] mci: parse upstream boot/gp " 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=20241205085530.3897385-1-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