* [PATCH 1/2] mci: parse upstream boot/gp partition binding
@ 2024-12-05 8:55 Sascha Hauer
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
0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-12-05 8:55 UTC (permalink / raw)
To: Barebox List
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] ARM: dts: Use upstream eMMC boot partition binding
2024-12-05 8:55 [PATCH 1/2] mci: parse upstream boot/gp partition binding Sascha Hauer
@ 2024-12-05 8:55 ` Sascha Hauer
2024-12-06 9:43 ` [PATCH 1/2] mci: parse upstream boot/gp " Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-12-05 8:55 UTC (permalink / raw)
To: Barebox List
barebox supports partitioning the eMMC boot partitions via device tree.
Linux recently gained that functionality as well, but with different
node names. Update the node names to the Linux binding.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/dts/imx50-kindle-common.dtsi | 2 +-
arch/arm/dts/imx7d-phyboard-zeta.dts | 2 +-
arch/arm/dts/imx7s-warp.dts | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/dts/imx50-kindle-common.dtsi b/arch/arm/dts/imx50-kindle-common.dtsi
index 92933e6912..c286dcb2e9 100644
--- a/arch/arm/dts/imx50-kindle-common.dtsi
+++ b/arch/arm/dts/imx50-kindle-common.dtsi
@@ -153,7 +153,7 @@ diags_kernel: diags_kernel@e41000 {
};
};
- boot0-partitions {
+ partitions-boot1 {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/dts/imx7d-phyboard-zeta.dts b/arch/arm/dts/imx7d-phyboard-zeta.dts
index a34f12f616..211c72604e 100644
--- a/arch/arm/dts/imx7d-phyboard-zeta.dts
+++ b/arch/arm/dts/imx7d-phyboard-zeta.dts
@@ -37,7 +37,7 @@ &fec1 {
&usdhc3 {
status = "okay";
- boot0-partitions {
+ partitions-boot1 {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/dts/imx7s-warp.dts b/arch/arm/dts/imx7s-warp.dts
index 3cae11b6a2..d84b9ed434 100644
--- a/arch/arm/dts/imx7s-warp.dts
+++ b/arch/arm/dts/imx7s-warp.dts
@@ -21,7 +21,7 @@ environment {
};
&usdhc3 {
- boot0-partitions {
+ partitions-boot1 {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
--
2.39.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] mci: parse upstream boot/gp partition binding
2024-12-05 8:55 [PATCH 1/2] mci: parse upstream boot/gp partition binding Sascha Hauer
2024-12-05 8:55 ` [PATCH 2/2] ARM: dts: Use upstream eMMC boot " Sascha Hauer
@ 2024-12-06 9:43 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-12-06 9:43 UTC (permalink / raw)
To: Barebox List, Sascha Hauer
On Thu, 05 Dec 2024 09:55:29 +0100, Sascha Hauer wrote:
> 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.
>
> [...]
Applied, thanks!
[1/2] mci: parse upstream boot/gp partition binding
https://git.pengutronix.de/cgit/barebox/commit/?id=15cc1fa00cda (link may not be stable)
[2/2] ARM: dts: Use upstream eMMC boot partition binding
https://git.pengutronix.de/cgit/barebox/commit/?id=bba5fd59b0a0 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-06 9:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-05 8:55 [PATCH 1/2] mci: parse upstream boot/gp partition binding Sascha Hauer
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox