mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	"Maciej W. Rozycki" <macro@orcam.me.uk>,
	linux-kernel@vger.kernel.org
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Maxim Levitsky" <maximlevitsky@gmail.com>,
	"Ulf Hansson" <ulfh@kernel.org>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	linux-mmc@vger.kernel.org
Subject: [RFC PATCH 10/11] PCI: Move Ricoh RL5C476 MMC quirk to setup-cardbus.c
Date: Mon,  9 Nov 2026 23:07:10 +0200	[thread overview]
Message-ID: <20261109210714.3862-11-ilpo.jarvinen@linux.intel.com> (raw)
In-Reply-To: <20261109210714.3862-1-ilpo.jarvinen@linux.intel.com>

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@linux.intel.com>
---

Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Ulf Hansson <ulfh@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: linux-mmc@vger.kernel.org

 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


  parent reply	other threads:[~2026-11-09 21:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 21:07 [PATCH 00/11] PCI/CardBus: Disable properly when CARDBUS=n & fix some issues along the way Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 01/11] PCI: Free device name when pci_setup_device() fails Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 02/11] PCI: Use Header Type in __pci_bridge_assign_resources() Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 03/11] PCI: Use Header Type to detect CardBus bridges in pci_resource_alignment() Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 04/11] PCI: Fix off-by-one in CardBus resource names Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 05/11] PCI: Move pci_read_bases() wrapper with BUILD_BUG_ON() to pci.h Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 06/11] mmc: sdricoh_cs: Depend on CARDBUS Ilpo Järvinen
2026-11-09 21:07 ` [RFC PATCH 07/11] pcmcia: yenta_socket: Always select CARDBUS Ilpo Järvinen
2026-11-09 21:07 ` [RFC PATCH 08/11] PCI: Move CardBus device setup to setup-cardbus.c Ilpo Järvinen
2026-11-09 21:07 ` [PATCH 09/11] PCI: Move CardBus legacy mode quirk " Ilpo Järvinen
2026-11-09 21:07 ` Ilpo Järvinen [this message]
2026-11-09 21:07 ` [PATCH 11/11] PCI: Move CardBus resource names " Ilpo Järvinen

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=20261109210714.3862-11-ilpo.jarvinen@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=macro@orcam.me.uk \
    --cc=maximlevitsky@gmail.com \
    --cc=ulfh@kernel.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

all inboxes | Powered by JetHome®