Skip to contentSkip to conversation

mmc: sdhci-pci: Add DMI quirk for missing CD GPIO on Vexia Edu Atla 10 tablet

PATCH Superseded Hans de Goede 2 participants 3 messages Nov 6, 2024 – Nov 7, 2024

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci-pci: Add DMI quirk for missing CD GPIO on Vexia Edu Atla 10 tablet

The Vexia Edu Atla 10 tablet distributed to schools in the Spanish Andalucía region has no ACPI fwnode associated with the SDHCI controller for its microsd-slot and thus has no ACPI GPIO resource info.

This causes the following error to be logged and the slot to not work:

[   10.572113] sdhci-pci 0000:00:12.0: failed to setup card detect gpio

Add a DMI quirk table for providing gpiod_lookup_tables with manually provided CD GPIO info and use this DMI table to provide the CD GPIO info on this tablet. This fixes the microsd-slot not working.

---
 drivers/mmc/host/sdhci-pci-core.c | 39 +++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
drivers/mmc/host/sdhci-pci-core.c +39 -0
index ed45ed0bdafd..eb9fb4ccd31b 100644
@@ -11,6 +11,7 @@
 #include <linux/bitfield.h>
 #include <linux/string.h>
 #include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/highmem.h>
 #include <linux/module.h>
 #include <linux/pci.h>
@@ -21,6 +22,7 @@
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/gpio.h>
+#include <linux/gpio/machine.h>
 #include <linux/pm_runtime.h>
 #include <linux/pm_qos.h>
 #include <linux/debugfs.h>
@@ -2054,6 +2056,29 @@ static const struct dev_pm_ops sdhci_pci_pm_ops = {
  *                                                                           *
 \*****************************************************************************/
 
+/* DMI quirks for devices with missing or broken CD GPIO info */
+static struct gpiod_lookup_table vexia_edu_atla10_cd_gpios = {
+	.dev_id = "0000:00:12.0",
+	.table = {
+		GPIO_LOOKUP("INT33FC:00", 38, "cd", GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
+
+const struct dmi_system_id sdhci_pci_dmi_cd_gpio_overrides[] = {
+	{
+		/* Vexia Edu Atla 10 tablet 9V version */
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
+			DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
+			/* Above strings are too generic, also match on BIOS date */
+			DMI_MATCH(DMI_BIOS_DATE, "08/25/2014"),
+		},
+		.driver_data = (void *)&vexia_edu_atla10_cd_gpios,
+	},
+	{ }
+};
+
 static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 	struct pci_dev *pdev, struct sdhci_pci_chip *chip, int first_bar,
 	int slotno)
@@ -2129,8 +2154,22 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot(
 		device_init_wakeup(&pdev->dev, true);
 
 	if (slot->cd_idx >= 0) {
+		struct gpiod_lookup_table *cd_gpio_lookup_table = NULL;
+		const struct dmi_system_id *dmi_id;
+
+		dmi_id = dmi_first_match(sdhci_pci_dmi_cd_gpio_overrides);
+		if (dmi_id)
+			cd_gpio_lookup_table = dmi_id->driver_data;
+
+		if (cd_gpio_lookup_table)
+			gpiod_add_lookup_table(cd_gpio_lookup_table);
+
 		ret = mmc_gpiod_request_cd(host->mmc, "cd", slot->cd_idx,
 					   slot->cd_override_level, 0);
+
+		if (cd_gpio_lookup_table)
+			gpiod_remove_lookup_table(cd_gpio_lookup_table);
+
 		if (ret && ret != -EPROBE_DEFER)
 			ret = mmc_gpiod_request_cd(host->mmc, NULL,
 						   slot->cd_idx,
Signature · 1 line
2.47.0
#1 lore raw
kernel test robot noticed the following build warnings:

Hi Hans,

kernel test robot noticed the following build warnings:

[auto build test WARNING on ulf-hansson-mmc-mirror/next] [also build test WARNING on linus/master v6.12-rc6 next-20241106] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Hans-de-Goede/mmc-sdhci-pci-Add-DMI-quirk-for-missing-CD-GPIO-on-Vexia-Edu-Atla-10-tablet/20241107-060048
base:   https://git.linaro.org/people/ulf.hansson/mmc-mirror.git next
patch link:    https://lore.kernel.org/r/20241106215927.40482-1-hdegoede%40redhat.com
patch subject: [PATCH] mmc: sdhci-pci: Add DMI quirk for missing CD GPIO on Vexia Edu Atla 10 tablet
config: i386-randconfig-061-20241107 (https://download.01.org/0day-ci/archive/20241107/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241107/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> drivers/mmc/host/sdhci-pci-core.c:2068:28: sparse: sparse: symbol 'sdhci_pci_dmi_cd_gpio_overrides' was not declared. Should it be static?

vim +/sdhci_pci_dmi_cd_gpio_overrides +2068 drivers/mmc/host/sdhci-pci-core.c

2067

> 2068	const struct dmi_system_id sdhci_pci_dmi_cd_gpio_overrides[] = {

2069 {
2070 /* Vexia Edu Atla 10 tablet 9V version */
2071 .matches = {
2072 DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
2073 DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
2074 /* Above strings are too generic, also match on BIOS date */
2075 DMI_MATCH(DMI_BIOS_DATE, "08/25/2014"),
2076 },
2077 .driver_data = (void *)&vexia_edu_atla10_cd_gpios,
2078 },
2079 { }
2080 };
2081

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw

Hi,

Quoted 18 lines · kernel test robot

Hi Hans,

kernel test robot noticed the following build warnings:

[auto build test WARNING on ulf-hansson-mmc-mirror/next] [also build test WARNING on linus/master v6.12-rc6 next-20241106] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Hans-de-Goede/mmc-sdhci-pci-Add-DMI-quirk-for-missing-CD-GPIO-on-Vexia-Edu-Atla-10-tablet/20241107-060048
base:   https://git.linaro.org/people/ulf.hansson/mmc-mirror.git next
patch link:    https://lore.kernel.org/r/20241106215927.40482-1-hdegoede%40redhat.com
patch subject: [PATCH] mmc: sdhci-pci: Add DMI quirk for missing CD GPIO on Vexia Edu Atla 10 tablet
config: i386-randconfig-061-20241107 (https://download.01.org/0day-ci/archive/20241107/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241107/[email protected]/reproduce)
Quoted 7 lines

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/mmc/host/sdhci-pci-core.c:2068:28: sparse: sparse: symbol 'sdhci_pci_dmi_cd_gpio_overrides' was not declared. Should it be static?

Yes it should I'll send a v2 of the patch fixing this.

Regards,

Hans