summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-09-30 18:21:51 +0200
committerRobert Schwebel <r.schwebel@pengutronix.de>2022-09-30 18:53:56 +0200
commitefd49c8f6cae16c64adb7019fed8c151c5c6e823 (patch)
tree321bf966ff678227a7c18e122b8297396a1e6b05
parentccfabc730f929221c374ff40f27c3fc0bea6ab39 (diff)
downloadDistroKit-efd49c8f6cae16c64adb7019fed8c151c5c6e823.tar.gz
DistroKit-efd49c8f6cae16c64adb7019fed8c151c5c6e823.tar.xz
v7a: barebox: switch to new broken-cd device parameter
The original patch didn't go upstream, because semantics were a bit odd, a Kconfig option changing behavior, but only for devices barebox probes. This imports v3 of the series into DistroKit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.pengutronix.de/20220930162159.814389-3-a.fatoum@pengutronix.de Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
-rw-r--r--configs/platform-v7a/barebox-am335x-defaultenv/nv/dev.mmc0.broken_cd1
-rw-r--r--configs/platform-v7a/barebox-am335x-mlo.config1
-rw-r--r--configs/platform-v7a/barebox-am335x.config1
-rw-r--r--configs/platform-v7a/barebox-am335x.config.diff2
-rw-r--r--configs/platform-v7a/barebox-at91.config1
-rw-r--r--configs/platform-v7a/barebox-at91.config.diff2
-rw-r--r--configs/platform-v7a/barebox-mx6-defaultenv/nv/dev.mmc0.broken_cd1
-rw-r--r--configs/platform-v7a/barebox-mx6.config1
-rw-r--r--configs/platform-v7a/barebox-mx6.config.diff2
-rw-r--r--configs/platform-v7a/barebox-rpi2-defaultenv/nv/dev.mci0.broken_cd1
-rw-r--r--configs/platform-v7a/barebox-rpi2.config1
-rw-r--r--configs/platform-v7a/barebox-rpi2.config.diff2
-rw-r--r--configs/platform-v7a/barebox-stm32mp-defaultenv/nv/dev.mmc0.broken_cd1
-rw-r--r--configs/platform-v7a/barebox-stm32mp.config1
-rw-r--r--configs/platform-v7a/barebox-stm32mp.config.diff2
-rw-r--r--configs/platform-v7a/barebox-vexpress.config1
-rw-r--r--configs/platform-v7a/barebox-vexpress.config.diff2
-rw-r--r--configs/platform-v7a/barebox.config1
-rw-r--r--configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch109
-rw-r--r--configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-core-act-upon-broken-cd-device-tree-property.patch60
-rw-r--r--configs/platform-v7a/patches/barebox-2022.09.0/0002-mci-core-add-broken_cd-device-parameter.patch46
-rw-r--r--configs/platform-v7a/patches/barebox-2022.09.0/0003-mci-core-fixup-broken-cd-information-into-kernel-DT.patch67
-rw-r--r--configs/platform-v7a/patches/barebox-2022.09.0/series4
23 files changed, 186 insertions, 124 deletions
diff --git a/configs/platform-v7a/barebox-am335x-defaultenv/nv/dev.mmc0.broken_cd b/configs/platform-v7a/barebox-am335x-defaultenv/nv/dev.mmc0.broken_cd
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/configs/platform-v7a/barebox-am335x-defaultenv/nv/dev.mmc0.broken_cd
@@ -0,0 +1 @@
+1
diff --git a/configs/platform-v7a/barebox-am335x-mlo.config b/configs/platform-v7a/barebox-am335x-mlo.config
index c7ef80c..c296fef 100644
--- a/configs/platform-v7a/barebox-am335x-mlo.config
+++ b/configs/platform-v7a/barebox-am335x-mlo.config
@@ -297,7 +297,6 @@ CONFIG_MCI=y
# CONFIG_MCI_WRITE is not set
# CONFIG_MCI_MMC_BOOT_PARTITIONS is not set
# CONFIG_MCI_MMC_GPP_PARTITIONS is not set
-# CONFIG_MCI_BROKEN_CD is not set
#
# --- MCI host drivers ---
diff --git a/configs/platform-v7a/barebox-am335x.config b/configs/platform-v7a/barebox-am335x.config
index 1969802..3130469 100644
--- a/configs/platform-v7a/barebox-am335x.config
+++ b/configs/platform-v7a/barebox-am335x.config
@@ -651,7 +651,6 @@ CONFIG_MCI_INFO=y
CONFIG_MCI_WRITE=y
# CONFIG_MCI_MMC_BOOT_PARTITIONS is not set
# CONFIG_MCI_MMC_GPP_PARTITIONS is not set
-CONFIG_MCI_BROKEN_CD=y
#
# --- MCI host drivers ---
diff --git a/configs/platform-v7a/barebox-am335x.config.diff b/configs/platform-v7a/barebox-am335x.config.diff
index a5c5f07..601fe8b 100644
--- a/configs/platform-v7a/barebox-am335x.config.diff
+++ b/configs/platform-v7a/barebox-am335x.config.diff
@@ -1,4 +1,4 @@
-c9dc2932604e238cf0e8d81e538c2819
+db5930a2812171dea02ac82d359831b3
# CONFIG_32BIT is undefined
# CONFIG_64BIT is undefined
# CONFIG_AM33XX_NET_BOOT is not set
diff --git a/configs/platform-v7a/barebox-at91.config b/configs/platform-v7a/barebox-at91.config
index 91bf127..dccd26b 100644
--- a/configs/platform-v7a/barebox-at91.config
+++ b/configs/platform-v7a/barebox-at91.config
@@ -608,7 +608,6 @@ CONFIG_MCI_INFO=y
CONFIG_MCI_WRITE=y
CONFIG_MCI_MMC_BOOT_PARTITIONS=y
# CONFIG_MCI_MMC_GPP_PARTITIONS is not set
-CONFIG_MCI_BROKEN_CD=y
#
# --- MCI host drivers ---
diff --git a/configs/platform-v7a/barebox-at91.config.diff b/configs/platform-v7a/barebox-at91.config.diff
index b023e57..d3a0004 100644
--- a/configs/platform-v7a/barebox-at91.config.diff
+++ b/configs/platform-v7a/barebox-at91.config.diff
@@ -1,4 +1,4 @@
-c9dc2932604e238cf0e8d81e538c2819
+db5930a2812171dea02ac82d359831b3
# CONFIG_32BIT is undefined
# CONFIG_64BIT is undefined
CONFIG_ARCH_AT91=y
diff --git a/configs/platform-v7a/barebox-mx6-defaultenv/nv/dev.mmc0.broken_cd b/configs/platform-v7a/barebox-mx6-defaultenv/nv/dev.mmc0.broken_cd
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/configs/platform-v7a/barebox-mx6-defaultenv/nv/dev.mmc0.broken_cd
@@ -0,0 +1 @@
+1
diff --git a/configs/platform-v7a/barebox-mx6.config b/configs/platform-v7a/barebox-mx6.config
index e36de6f..7906faf 100644
--- a/configs/platform-v7a/barebox-mx6.config
+++ b/configs/platform-v7a/barebox-mx6.config
@@ -764,7 +764,6 @@ CONFIG_MCI_INFO=y
CONFIG_MCI_WRITE=y
CONFIG_MCI_MMC_BOOT_PARTITIONS=y
# CONFIG_MCI_MMC_GPP_PARTITIONS is not set
-CONFIG_MCI_BROKEN_CD=y
#
# --- MCI host drivers ---
diff --git a/configs/platform-v7a/barebox-mx6.config.diff b/configs/platform-v7a/barebox-mx6.config.diff
index 78ab323..e492d59 100644
--- a/configs/platform-v7a/barebox-mx6.config.diff
+++ b/configs/platform-v7a/barebox-mx6.config.diff
@@ -1,4 +1,4 @@
-c9dc2932604e238cf0e8d81e538c2819
+db5930a2812171dea02ac82d359831b3
# CONFIG_32BIT is undefined
# CONFIG_64BIT is undefined
# CONFIG_ARCH_BCM283X is not set
diff --git a/configs/platform-v7a/barebox-rpi2-defaultenv/nv/dev.mci0.broken_cd b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/dev.mci0.broken_cd
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/configs/platform-v7a/barebox-rpi2-defaultenv/nv/dev.mci0.broken_cd
@@ -0,0 +1 @@
+1
diff --git a/configs/platform-v7a/barebox-rpi2.config b/configs/platform-v7a/barebox-rpi2.config
index ccfede1..46fb13b 100644
--- a/configs/platform-v7a/barebox-rpi2.config
+++ b/configs/platform-v7a/barebox-rpi2.config
@@ -613,7 +613,6 @@ CONFIG_MCI_INFO=y
CONFIG_MCI_WRITE=y
CONFIG_MCI_MMC_BOOT_PARTITIONS=y
# CONFIG_MCI_MMC_GPP_PARTITIONS is not set
-CONFIG_MCI_BROKEN_CD=y
#
# --- MCI host drivers ---
diff --git a/configs/platform-v7a/barebox-rpi2.config.diff b/configs/platform-v7a/barebox-rpi2.config.diff
index 847e679..2ae317b 100644
--- a/configs/platform-v7a/barebox-rpi2.config.diff
+++ b/configs/platform-v7a/barebox-rpi2.config.diff
@@ -1,4 +1,4 @@
-c9dc2932604e238cf0e8d81e538c2819
+db5930a2812171dea02ac82d359831b3
CONFIG_ARM_ASM_UNIFIED=y
# CONFIG_CMD_NVMEM is not set
# CONFIG_CMD_USBGADGET is undefined
diff --git a/configs/platform-v7a/barebox-stm32mp-defaultenv/nv/dev.mmc0.broken_cd b/configs/platform-v7a/barebox-stm32mp-defaultenv/nv/dev.mmc0.broken_cd
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/configs/platform-v7a/barebox-stm32mp-defaultenv/nv/dev.mmc0.broken_cd
@@ -0,0 +1 @@
+1
diff --git a/configs/platform-v7a/barebox-stm32mp.config b/configs/platform-v7a/barebox-stm32mp.config
index 1d9a68c..9403aff 100644
--- a/configs/platform-v7a/barebox-stm32mp.config
+++ b/configs/platform-v7a/barebox-stm32mp.config
@@ -593,7 +593,6 @@ CONFIG_MCI_INFO=y
CONFIG_MCI_WRITE=y
CONFIG_MCI_MMC_BOOT_PARTITIONS=y
# CONFIG_MCI_MMC_GPP_PARTITIONS is not set
-CONFIG_MCI_BROKEN_CD=y
#
# --- MCI host drivers ---
diff --git a/configs/platform-v7a/barebox-stm32mp.config.diff b/configs/platform-v7a/barebox-stm32mp.config.diff
index e426bb0..2879df7 100644
--- a/configs/platform-v7a/barebox-stm32mp.config.diff
+++ b/configs/platform-v7a/barebox-stm32mp.config.diff
@@ -1,4 +1,4 @@
-c9dc2932604e238cf0e8d81e538c2819
+db5930a2812171dea02ac82d359831b3
# CONFIG_32BIT is undefined
# CONFIG_64BIT is undefined
# CONFIG_ARCH_BCM283X is not set
diff --git a/configs/platform-v7a/barebox-vexpress.config b/configs/platform-v7a/barebox-vexpress.config
index 10de783..6f55318 100644
--- a/configs/platform-v7a/barebox-vexpress.config
+++ b/configs/platform-v7a/barebox-vexpress.config
@@ -607,7 +607,6 @@ CONFIG_MCI_INFO=y
CONFIG_MCI_WRITE=y
# CONFIG_MCI_MMC_BOOT_PARTITIONS is not set
# CONFIG_MCI_MMC_GPP_PARTITIONS is not set
-CONFIG_MCI_BROKEN_CD=y
#
# --- MCI host drivers ---
diff --git a/configs/platform-v7a/barebox-vexpress.config.diff b/configs/platform-v7a/barebox-vexpress.config.diff
index fa80377..1b66b9c 100644
--- a/configs/platform-v7a/barebox-vexpress.config.diff
+++ b/configs/platform-v7a/barebox-vexpress.config.diff
@@ -1,4 +1,4 @@
-c9dc2932604e238cf0e8d81e538c2819
+db5930a2812171dea02ac82d359831b3
# CONFIG_32BIT is undefined
# CONFIG_64BIT is undefined
CONFIG_AMBA_SP804=y
diff --git a/configs/platform-v7a/barebox.config b/configs/platform-v7a/barebox.config
index d56b74c..a7fea57 100644
--- a/configs/platform-v7a/barebox.config
+++ b/configs/platform-v7a/barebox.config
@@ -630,7 +630,6 @@ CONFIG_MCI_INFO=y
CONFIG_MCI_WRITE=y
# CONFIG_MCI_MMC_BOOT_PARTITIONS is not set
# CONFIG_MCI_MMC_GPP_PARTITIONS is not set
-CONFIG_MCI_BROKEN_CD=y
#
# --- MCI host drivers ---
diff --git a/configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch b/configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch
deleted file mode 100644
index 3224e99..0000000
--- a/configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch
+++ /dev/null
@@ -1,109 +0,0 @@
-From f9fa5cf2ba5842a355aa827ac8847ed62eee65d0 Mon Sep 17 00:00:00 2001
-From: Ahmad Fatoum <a.fatoum@pengutronix.de>
-Date: Mon, 25 Jul 2022 13:58:56 +0200
-Subject: [PATCH] mci: add new MCI_BROKEN_CD option for testing
-
-In remote labs co-located with other hardware, we've observed card
-detect levers of different boards to sporadically fail to detect
-the card, e.g. because the cable on the usbsdmux was yanked around
-by accident. When this happens, barebox usually boots up normally as
-the card detect is ignored and then Linux waits indefinitely for
-the card-detect to turn active. Add a new config option that can be
-enabled to avoid these issues altogether.
-
-Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
----
- drivers/mci/Kconfig | 15 +++++++++++++++
- drivers/mci/mci-core.c | 36 ++++++++++++++++++++++++++++++++----
- 2 files changed, 47 insertions(+), 4 deletions(-)
-
-diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
-index 21d53c0c3f0b..651e59259790 100644
---- a/drivers/mci/Kconfig
-+++ b/drivers/mci/Kconfig
-@@ -56,6 +56,21 @@ config MCI_MMC_GPP_PARTITIONS
- Note: by default, 'MMC' devices have no 'general purpose partitions',
- it requires a special one-time configuration step to enable them.
-
-+config MCI_BROKEN_CD
-+ bool "ignore card-detect pin on boot and in OS"
-+ help
-+ Say 'y' here to have barebox unconditionally ignore the
-+ card-detect pin for its own operation and manipulate the
-+ kernel DT, so all detected MCI cards are polled instead
-+ of expecting the card detect lever to behave correctly.
-+ If you need more fine grained control use of_property
-+ in an init script:
-+
-+ of_property -fd mmc0 cd-gpios
-+ of_property -fs mmc0 broken-cd
-+
-+ If unsure, say 'n' here.
-+
- comment "--- MCI host drivers ---"
-
- config MCI_DW
-diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
-index b8f71e15986e..c6ed6e3d8b79 100644
---- a/drivers/mci/mci-core.c
-+++ b/drivers/mci/mci-core.c
-@@ -1739,6 +1739,27 @@ static int mci_register_partition(struct mci_part *part)
- return 0;
- }
-
-+static int of_broken_cd_fixup(struct device_node *root, void *ctx)
-+{
-+ struct device_d *hw_dev = ctx;
-+ struct device_node *np;
-+ char *name;
-+
-+ name = of_get_reproducible_name(hw_dev->device_node);
-+ np = of_find_node_by_reproducible_name(root, name);
-+ free(name);
-+ if (!np) {
-+ dev_warn(hw_dev, "Cannot find nodepath %s, cannot fixup\n",
-+ hw_dev->device_node->full_name);
-+ return -EINVAL;
-+ }
-+
-+ of_property_write_bool(np, "cd-gpios", false);
-+ of_property_write_bool(np, "broken-cd", true);
-+
-+ return 0;
-+}
-+
- /**
- * Probe an MCI card at the given host interface
- * @param mci MCI device instance
-@@ -1750,10 +1771,13 @@ static int mci_card_probe(struct mci *mci)
- int i, rc, disknum, ret;
- bool has_bootpart = false;
-
-- if (host->card_present && !host->card_present(host) &&
-- !host->non_removable) {
-- dev_err(&mci->dev, "no card inserted\n");
-- return -ENODEV;
-+ if (host->card_present && !host->card_present(host) && !host->non_removable) {
-+ if (!IS_ENABLED(CONFIG_MCI_BROKEN_CD)) {
-+ dev_err(&mci->dev, "no card inserted\n");
-+ return -ENODEV;
-+ }
-+
-+ dev_info(&mci->dev, "no card inserted (ignoring)\n");
- }
-
- ret = regulator_enable(host->supply);
-@@ -1839,6 +1863,10 @@ static int mci_card_probe(struct mci *mci)
- &mci->boot_ack_enable, mci);
- }
-
-+ if (IS_ENABLED(CONFIG_MCI_BROKEN_CD) && !host->no_sd &&
-+ dev_of_node(host->hw_dev))
-+ of_register_fixup(of_broken_cd_fixup, host->hw_dev);
-+
- dev_dbg(&mci->dev, "SD Card successfully added\n");
-
- on_error:
---
-2.30.2
-
diff --git a/configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-core-act-upon-broken-cd-device-tree-property.patch b/configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-core-act-upon-broken-cd-device-tree-property.patch
new file mode 100644
index 0000000..7360637
--- /dev/null
+++ b/configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-core-act-upon-broken-cd-device-tree-property.patch
@@ -0,0 +1,60 @@
+From 1d41bcf91e00a2e590497c266d5171232f30428c Mon Sep 17 00:00:00 2001
+From: Ahmad Fatoum <a.fatoum@pengutronix.de>
+Date: Tue, 6 Sep 2022 20:10:14 +0200
+Subject: [PATCH 1/3] mci: core: act upon broken-cd device tree property
+
+We didn't care much for broken-cd so far, still we have some drivers
+implementing the card_present callback, which we should ignore when
+card-detect is marked broken.
+
+Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
+---
+ drivers/mci/mci-core.c | 12 ++++++++----
+ include/mci.h | 1 +
+ 2 files changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
+index b8f71e15986e..5b1aa8dbed87 100644
+--- a/drivers/mci/mci-core.c
++++ b/drivers/mci/mci-core.c
+@@ -1750,10 +1750,13 @@ static int mci_card_probe(struct mci *mci)
+ int i, rc, disknum, ret;
+ bool has_bootpart = false;
+
+- if (host->card_present && !host->card_present(host) &&
+- !host->non_removable) {
+- dev_err(&mci->dev, "no card inserted\n");
+- return -ENODEV;
++ if (host->card_present && !host->card_present(host) && !host->non_removable) {
++ if (!host->broken_cd) {
++ dev_err(&mci->dev, "no card inserted\n");
++ return -ENODEV;
++ }
++
++ dev_info(&mci->dev, "no card inserted (ignoring)\n");
+ }
+
+ ret = regulator_enable(host->supply);
+@@ -2033,6 +2036,7 @@ void mci_of_parse_node(struct mci_host *host,
+ }
+ }
+
++ host->broken_cd = of_property_read_bool(np, "broken-cd");
+ host->non_removable = of_property_read_bool(np, "non-removable");
+ host->no_sd = of_property_read_bool(np, "no-sd");
+ host->disable_wp = of_property_read_bool(np, "disable-wp");
+diff --git a/include/mci.h b/include/mci.h
+index 2098b4fbf084..d949310fac30 100644
+--- a/include/mci.h
++++ b/include/mci.h
+@@ -404,6 +404,7 @@ struct mci_host {
+ unsigned max_req_size;
+ unsigned dsr_val; /**< optional dsr value */
+ int use_dsr; /**< optional dsr usage flag */
++ int broken_cd; /**< card detect is broken */
+ bool non_removable; /**< device is non removable */
+ bool no_sd; /**< do not send SD commands during initialization */
+ bool disable_wp; /**< ignore write-protect detection logic */
+--
+2.30.2
+
diff --git a/configs/platform-v7a/patches/barebox-2022.09.0/0002-mci-core-add-broken_cd-device-parameter.patch b/configs/platform-v7a/patches/barebox-2022.09.0/0002-mci-core-add-broken_cd-device-parameter.patch
new file mode 100644
index 0000000..b14c160
--- /dev/null
+++ b/configs/platform-v7a/patches/barebox-2022.09.0/0002-mci-core-add-broken_cd-device-parameter.patch
@@ -0,0 +1,46 @@
+From 8d66a16dfd6b5c7e0d39e90954af32667e480074 Mon Sep 17 00:00:00 2001
+From: Ahmad Fatoum <a.fatoum@pengutronix.de>
+Date: Tue, 6 Sep 2022 20:10:37 +0200
+Subject: [PATCH 2/3] mci: core: add broken_cd device parameter
+
+Sometimes a broken card-detect is not a general issue affecting all
+boards, but only a given board. Allow setting broken_cd for such boards
+via a device parameter.
+
+Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
+---
+ drivers/mci/mci-core.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
+index 5b1aa8dbed87..5101ac1d8298 100644
+--- a/drivers/mci/mci-core.c
++++ b/drivers/mci/mci-core.c
+@@ -1919,7 +1919,7 @@ int mci_register(struct mci_host *host)
+ {
+ struct mci *mci;
+ struct device_d *hw_dev;
+- struct param_d *param_probe;
++ struct param_d *param_probe, *param_broken_cd;
+ int ret;
+
+ mci = xzalloc(sizeof(*mci));
+@@ -1963,6 +1963,15 @@ int mci_register(struct mci_host *host)
+ goto err_unregister;
+ }
+
++ param_broken_cd = dev_add_param_bool(&mci->dev, "broken_cd",
++ NULL, NULL, &host->broken_cd, mci);
++
++ if (IS_ERR(param_broken_cd) && PTR_ERR(param_broken_cd) != -ENOSYS) {
++ ret = PTR_ERR(param_broken_cd);
++ dev_dbg(&mci->dev, "Failed to add 'broken_cd' parameter to the MCI device\n");
++ goto err_unregister;
++ }
++
+ if (IS_ENABLED(CONFIG_MCI_INFO))
+ mci->dev.info = mci_info;
+
+--
+2.30.2
+
diff --git a/configs/platform-v7a/patches/barebox-2022.09.0/0003-mci-core-fixup-broken-cd-information-into-kernel-DT.patch b/configs/platform-v7a/patches/barebox-2022.09.0/0003-mci-core-fixup-broken-cd-information-into-kernel-DT.patch
new file mode 100644
index 0000000..8f2c776
--- /dev/null
+++ b/configs/platform-v7a/patches/barebox-2022.09.0/0003-mci-core-fixup-broken-cd-information-into-kernel-DT.patch
@@ -0,0 +1,67 @@
+From 16931f8ef3bc2a5ecce5ae77c33e2b5611ac8d98 Mon Sep 17 00:00:00 2001
+From: Ahmad Fatoum <a.fatoum@pengutronix.de>
+Date: Mon, 25 Jul 2022 13:58:56 +0200
+Subject: [PATCH 3/3] mci: core: fixup broken-cd information into kernel DT
+
+In remote labs co-located with other hardware, we've observed card
+detect levers of different boards to sporadically fail to detect
+the card, e.g. because the cable on the usbsdmux was yanked around
+by accident. When this happens, barebox usually boots up normally as
+the card detect is ignored and then Linux waits indefinitely for
+the card-detect to turn active. We already maintain a broken_cd flag
+for each card. Use this to fixup the kernel DT appropriately.
+
+Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
+---
+ drivers/mci/mci-core.c | 28 ++++++++++++++++++++++++++++
+ 1 file changed, 28 insertions(+)
+
+diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
+index 5101ac1d8298..92dbdaf469fd 100644
+--- a/drivers/mci/mci-core.c
++++ b/drivers/mci/mci-core.c
+@@ -1739,6 +1739,31 @@ static int mci_register_partition(struct mci_part *part)
+ return 0;
+ }
+
++static int of_broken_cd_fixup(struct device_node *root, void *ctx)
++{
++ struct mci_host *host = ctx;
++ struct device_d *hw_dev = host->hw_dev;
++ struct device_node *np;
++ char *name;
++
++ if (!host->broken_cd)
++ return 0;
++
++ name = of_get_reproducible_name(hw_dev->device_node);
++ np = of_find_node_by_reproducible_name(root, name);
++ free(name);
++ if (!np) {
++ dev_warn(hw_dev, "Cannot find nodepath %s, cannot fixup\n",
++ hw_dev->device_node->full_name);
++ return -EINVAL;
++ }
++
++ of_property_write_bool(np, "cd-gpios", false);
++ of_property_write_bool(np, "broken-cd", true);
++
++ return 0;
++}
++
+ /**
+ * Probe an MCI card at the given host interface
+ * @param mci MCI device instance
+@@ -1979,6 +2004,9 @@ int mci_register(struct mci_host *host)
+ if (IS_ENABLED(CONFIG_MCI_STARTUP))
+ mci_card_probe(mci);
+
++ if (!host->no_sd && dev_of_node(host->hw_dev))
++ of_register_fixup(of_broken_cd_fixup, host);
++
+ list_add_tail(&mci->list, &mci_list);
+
+ return 0;
+--
+2.30.2
+
diff --git a/configs/platform-v7a/patches/barebox-2022.09.0/series b/configs/platform-v7a/patches/barebox-2022.09.0/series
index 0736422..26c8a02 100644
--- a/configs/platform-v7a/patches/barebox-2022.09.0/series
+++ b/configs/platform-v7a/patches/barebox-2022.09.0/series
@@ -1 +1,3 @@
-0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch
+0001-mci-core-act-upon-broken-cd-device-tree-property.patch
+0002-mci-core-add-broken_cd-device-parameter.patch
+0003-mci-core-fixup-broken-cd-information-into-kernel-DT.patch