[RFC PATCH 10/11] PCI: Move Ricoh RL5C476 MMC quirk to setup-cardbus.c
From: Ilpo Järvinen
Date: Mon Nov 09 2026 - 16:14:26 EST
ricoh_mmc_fixup_rl5c476() disables the proprietary MMC controller of the
Ricoh RL5C476 through Function 0 of the chip, which is a CardBus bridge.
When CONFIG_CARDBUS is not set, CardBus bridges are ignored and, as
Function 0 is then missing, pci_scan_slot() does not enumerate the other
Functions of the chip either. The quirk has nothing to do in that case.
Move the quirk to setup-cardbus.c so it is only built with CARDBUS.
CARDBUS defaults to y when CONFIG_PCCARD is enabled, so existing configs
for systems with these chips should mostly keep the quirk.
CONFIG_MMC_RICOH_MMC is an option of the SDHCI PCI card reader driver
(CONFIG_MMC_SDHCI_PCI), which drives the SD controller of both the
RL5C476 and the R5C832 family. On the R5C832 family, the MMC controller
is disabled through the FireWire Function, which does not need CardBus.
Thus, do not make MMC_RICOH_MMC depend on CARDBUS.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
---
Cc: Maxim Levitsky <maximlevitsky@xxxxxxxxx>
Cc: Ulf Hansson <ulfh@xxxxxxxxxx>
Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: linux-mmc@xxxxxxxxxxxxxxx
drivers/pci/quirks.c | 32 -----------------------------
drivers/pci/setup-cardbus.c | 41 +++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 32 deletions(-)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 78f6df5d4d19..85b4c39617a6 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3320,38 +3320,6 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HINT, 0x0020, quirk_hotplug_bridge);
* #1, and this will confuse the PCI core.
*/
#ifdef CONFIG_MMC_RICOH_MMC
-static void ricoh_mmc_fixup_rl5c476(struct pci_dev *dev)
-{
- u8 write_enable;
- u8 write_target;
- u8 disable;
-
- /*
- * Disable via CardBus interface
- *
- * This must be done via function #0
- */
- if (PCI_FUNC(dev->devfn))
- return;
-
- pci_read_config_byte(dev, 0xB7, &disable);
- if (disable & 0x02)
- return;
-
- pci_read_config_byte(dev, 0x8E, &write_enable);
- pci_write_config_byte(dev, 0x8E, 0xAA);
- pci_read_config_byte(dev, 0x8D, &write_target);
- pci_write_config_byte(dev, 0x8D, 0xB7);
- pci_write_config_byte(dev, 0xB7, disable | 0x02);
- pci_write_config_byte(dev, 0x8E, write_enable);
- pci_write_config_byte(dev, 0x8D, write_target);
-
- pci_notice(dev, "proprietary Ricoh MMC controller disabled (via CardBus function)\n");
- pci_notice(dev, "MMC cards are now supported by standard SDHCI controller\n");
-}
-DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476);
-DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476);
-
static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev)
{
u8 write_enable;
diff --git a/drivers/pci/setup-cardbus.c b/drivers/pci/setup-cardbus.c
index ef35393aca1b..33aca7b28354 100644
--- a/drivers/pci/setup-cardbus.c
+++ b/drivers/pci/setup-cardbus.c
@@ -330,4 +330,45 @@ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
PCI_CLASS_BRIDGE_CARDBUS, 8, quirk_cardbus_legacy);
DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(PCI_ANY_ID, PCI_ANY_ID,
PCI_CLASS_BRIDGE_CARDBUS, 8, quirk_cardbus_legacy);
+
+#ifdef CONFIG_MMC_RICOH_MMC
+/*
+ * Disable the proprietary Ricoh MMC controller on chips whose function 0
+ * is a CardBus bridge. See ricoh_mmc_fixup_r5c832() in quirks.c for
+ * details.
+ */
+static void ricoh_mmc_fixup_rl5c476(struct pci_dev *dev)
+{
+ u8 write_enable;
+ u8 write_target;
+ u8 disable;
+
+ /*
+ * Disable via CardBus interface
+ *
+ * This must be done via function #0
+ */
+ if (PCI_FUNC(dev->devfn))
+ return;
+
+ pci_read_config_byte(dev, 0xB7, &disable);
+ if (disable & 0x02)
+ return;
+
+ pci_read_config_byte(dev, 0x8E, &write_enable);
+ pci_write_config_byte(dev, 0x8E, 0xAA);
+ pci_read_config_byte(dev, 0x8D, &write_target);
+ pci_write_config_byte(dev, 0x8D, 0xB7);
+ pci_write_config_byte(dev, 0xB7, disable | 0x02);
+ pci_write_config_byte(dev, 0x8E, write_enable);
+ pci_write_config_byte(dev, 0x8D, write_target);
+
+ pci_notice(dev, "proprietary Ricoh MMC controller disabled (via CardBus function)\n");
+ pci_notice(dev, "MMC cards are now supported by standard SDHCI controller\n");
+}
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476,
+ ricoh_mmc_fixup_rl5c476);
+DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476,
+ ricoh_mmc_fixup_rl5c476);
+#endif /* CONFIG_MMC_RICOH_MMC */
#endif /* CONFIG_PCI_QUIRKS */
--
2.47.3