From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 30 Sep 2022 18:22:17 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oeImH-001ZFA-91 for lore@lore.pengutronix.de; Fri, 30 Sep 2022 18:22:17 +0200 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1oeImD-0006Jr-Cs; Fri, 30 Sep 2022 18:22:13 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oeIm2-0006EU-Ac; Fri, 30 Sep 2022 18:22:02 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1oeIm2-003pqB-DA; Fri, 30 Sep 2022 18:22:00 +0200 Received: from afa by dude04.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1oeIm0-003SHF-0H; Fri, 30 Sep 2022 18:22:00 +0200 From: Ahmad Fatoum To: distrokit@pengutronix.de Date: Fri, 30 Sep 2022 18:21:51 +0200 Message-Id: <20220930162159.814389-3-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220930162159.814389-1-a.fatoum@pengutronix.de> References: <20220930162159.814389-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [DistroKit] [PATCH 02/10] v7a: barebox: switch to new broken-cd device parameter X-BeenThere: distrokit@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: DistroKit Mailinglist List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ahmad Fatoum Sender: "DistroKit" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: distrokit-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false 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 --- .../nv/dev.mmc0.broken_cd | 1 + .../platform-v7a/barebox-am335x-mlo.config | 1 - configs/platform-v7a/barebox-am335x.config | 1 - .../platform-v7a/barebox-am335x.config.diff | 2 +- configs/platform-v7a/barebox-at91.config | 1 - configs/platform-v7a/barebox-at91.config.diff | 2 +- .../nv/dev.mmc0.broken_cd | 1 + configs/platform-v7a/barebox-mx6.config | 1 - configs/platform-v7a/barebox-mx6.config.diff | 2 +- .../nv/dev.mci0.broken_cd | 1 + configs/platform-v7a/barebox-rpi2.config | 1 - configs/platform-v7a/barebox-rpi2.config.diff | 2 +- .../nv/dev.mmc0.broken_cd | 1 + configs/platform-v7a/barebox-stm32mp.config | 1 - .../platform-v7a/barebox-stm32mp.config.diff | 2 +- configs/platform-v7a/barebox-vexpress.config | 1 - .../platform-v7a/barebox-vexpress.config.diff | 2 +- configs/platform-v7a/barebox.config | 1 - ...new-MCI_BROKEN_CD-option-for-testing.patch | 109 ------------------ ...-upon-broken-cd-device-tree-property.patch | 60 ++++++++++ ...-core-add-broken_cd-device-parameter.patch | 46 ++++++++ ...broken-cd-information-into-kernel-DT.patch | 67 +++++++++++ .../patches/barebox-2022.09.0/series | 4 +- 23 files changed, 186 insertions(+), 124 deletions(-) create mode 100644 configs/platform-v7a/barebox-am335x-defaultenv/nv/dev.mmc0.broken_cd create mode 100644 configs/platform-v7a/barebox-mx6-defaultenv/nv/dev.mmc0.broken_cd create mode 100644 configs/platform-v7a/barebox-rpi2-defaultenv/nv/dev.mci0.broken_cd create mode 100644 configs/platform-v7a/barebox-stm32mp-defaultenv/nv/dev.mmc0.broken_cd delete mode 100644 configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-add-new-MCI_BROKEN_CD-option-for-testing.patch create mode 100644 configs/platform-v7a/patches/barebox-2022.09.0/0001-mci-core-act-upon-broken-cd-device-tree-property.patch create mode 100644 configs/platform-v7a/patches/barebox-2022.09.0/0002-mci-core-add-broken_cd-device-parameter.patch create mode 100644 configs/platform-v7a/patches/barebox-2022.09.0/0003-mci-core-fixup-broken-cd-information-into-kernel-DT.patch 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 000000000000..d00491fd7e5b --- /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 c7ef80c234e9..c296fefaa7a1 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 1969802c48a5..313046927a07 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 a5c5f077657e..601fe8baac2a 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 91bf127c7407..dccd26bbb5c0 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 b023e5764795..d3a00045e5aa 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 000000000000..d00491fd7e5b --- /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 e36de6fc267b..7906fafddfd8 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 78ab3238b22b..e492d590ea33 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 000000000000..d00491fd7e5b --- /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 ccfede161d32..46fb13b44830 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 847e6794157e..2ae317bac58f 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 000000000000..d00491fd7e5b --- /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 1d9a68c264de..9403afffaa2f 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 e426bb0d6a8e..2879df7917f3 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 10de783c9a4b..6f553187199b 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 fa80377b86fe..1b66b9c5ad16 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 d56b74ccc941..a7fea5731263 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 3224e99941bc..000000000000 --- 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 -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 ---- - 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 000000000000..7360637bdbfc --- /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 +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 +--- + 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 000000000000..b14c1602747d --- /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 +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 +--- + 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 000000000000..8f2c7767d0d9 --- /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 +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 +--- + 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 073642265726..26c8a02e7caa 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 -- 2.30.2