[PATCH v2 1/2] mfd: intel-lpss: Switch to generalized quirk table

Aleksandrs Vinarskis posted 2 patches 1 year, 12 months ago
There is a newer version of this series
[PATCH v2 1/2] mfd: intel-lpss: Switch to generalized quirk table
Posted by Aleksandrs Vinarskis 1 year, 12 months ago
Introduce generic quirk table, and port existing walkaround for select
Microsoft devices to it. This is a preparation for
QUIRK_CLOCK_DIVIDER_UNITY.

Signed-off-by: Aleksandrs Vinarskis <alex.vinarskis@gmail.com>
---
V1 -> V2: Removed unnecessary intermidiate data structure 

 drivers/mfd/intel-lpss-pci.c | 22 +++++++++++++---------
 drivers/mfd/intel-lpss.c     |  2 +-
 drivers/mfd/intel-lpss.h     |  9 ++++++++-
 3 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-pci.c
index 4621d3950b8f..f8454d802677 100644
--- a/drivers/mfd/intel-lpss-pci.c
+++ b/drivers/mfd/intel-lpss-pci.c
@@ -23,13 +23,15 @@
 
 #include "intel-lpss.h"
 
-/* Some DSDTs have an unused GEXP ACPI device conflicting with I2C4 resources */
-static const struct pci_device_id ignore_resource_conflicts_ids[] = {
-	/* Microsoft Surface Go (version 1) I2C4 */
-	{ PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x9d64, 0x152d, 0x1182), },
-	/* Microsoft Surface Go 2 I2C4 */
-	{ PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x9d64, 0x152d, 0x1237), },
-	{ }
+static const struct pci_device_id quirk_ids[] = {
+	{	/* Microsoft Surface Go (version 1) I2C4 */
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x9d64, 0x152d, 0x1182),
+		.driver_data = QUIRK_IGNORE_RESOURCE_CONFLICTS,
+	}, {	/* Microsoft Surface Go 2 I2C4 */
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x9d64, 0x152d, 0x1237),
+		.driver_data = QUIRK_IGNORE_RESOURCE_CONFLICTS,
+	},
+	{}
 };
 
 static int intel_lpss_pci_probe(struct pci_dev *pdev,
@@ -37,6 +39,7 @@ static int intel_lpss_pci_probe(struct pci_dev *pdev,
 {
 	const struct intel_lpss_platform_info *data = (void *)id->driver_data;
 	struct intel_lpss_platform_info *info;
+	const struct pci_device_id *quirk_pci_info;
 	int ret;
 
 	ret = pcim_enable_device(pdev);
@@ -55,8 +58,9 @@ static int intel_lpss_pci_probe(struct pci_dev *pdev,
 	info->mem = pci_resource_n(pdev, 0);
 	info->irq = pci_irq_vector(pdev, 0);
 
-	if (pci_match_id(ignore_resource_conflicts_ids, pdev))
-		info->ignore_resource_conflicts = true;
+	quirk_pci_info = pci_match_id(quirk_ids, pdev);
+	if (quirk_pci_info)
+		info->quirks = quirk_pci_info->driver_data;
 
 	pdev->d3cold_delay = 0;
 
diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
index eff423f7dd28..aafa0da5f8db 100644
--- a/drivers/mfd/intel-lpss.c
+++ b/drivers/mfd/intel-lpss.c
@@ -412,7 +412,7 @@ int intel_lpss_probe(struct device *dev,
 		return ret;
 
 	lpss->cell->swnode = info->swnode;
-	lpss->cell->ignore_resource_conflicts = info->ignore_resource_conflicts;
+	lpss->cell->ignore_resource_conflicts = info->quirks & QUIRK_IGNORE_RESOURCE_CONFLICTS;
 
 	intel_lpss_init_dev(lpss);
 
diff --git a/drivers/mfd/intel-lpss.h b/drivers/mfd/intel-lpss.h
index c1d72b117ed5..8a1ffd4f3546 100644
--- a/drivers/mfd/intel-lpss.h
+++ b/drivers/mfd/intel-lpss.h
@@ -11,16 +11,23 @@
 #ifndef __MFD_INTEL_LPSS_H
 #define __MFD_INTEL_LPSS_H
 
+#include <linux/bits.h>
 #include <linux/pm.h>
 
+/*
+ * Some DSDTs have an unused GEXP ACPI device conflicting with I2C4 resources
+ * Set to ignore resource conflicts with ACPI declared SystemMemory regions
+ */
+#define QUIRK_IGNORE_RESOURCE_CONFLICTS BIT(0)
+
 struct device;
 struct resource;
 struct software_node;
 
 struct intel_lpss_platform_info {
 	struct resource *mem;
-	bool ignore_resource_conflicts;
 	int irq;
+	unsigned int quirks;
 	unsigned long clk_rate;
 	const char *clk_con_id;
 	const struct software_node *swnode;
-- 
2.40.1
Re: [PATCH v2 1/2] mfd: intel-lpss: Switch to generalized quirk table
Posted by Andy Shevchenko 1 year, 12 months ago
On Wed, Dec 20, 2023 at 09:56:20PM +0100, Aleksandrs Vinarskis wrote:
> Introduce generic quirk table, and port existing walkaround for select
> Microsoft devices to it. This is a preparation for
> QUIRK_CLOCK_DIVIDER_UNITY.

Thank you for the update!
Some nit-picks below, after addressing them feel free to add
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

...

> -	{ }

> +	{}

No need to change here.

Also I'm not sure about "}, {" style. Lee as the maintainer can clarify
on this.

...

>  	const struct intel_lpss_platform_info *data = (void *)id->driver_data;
>  	struct intel_lpss_platform_info *info;
> +	const struct pci_device_id *quirk_pci_info;
>  	int ret;

I would preserve reversed xmas tree order:

	const struct intel_lpss_platform_info *data = (void *)id->driver_data;
	const struct pci_device_id *quirk_pci_info;
	struct intel_lpss_platform_info *info;
	int ret;

...

> +	quirk_pci_info = pci_match_id(quirk_ids, pdev);
> +	if (quirk_pci_info)
> +		info->quirks = quirk_pci_info->driver_data;

Can you confirm that there is no compiler warning if you compile for 32-bit?

...

> +/*
> + * Some DSDTs have an unused GEXP ACPI device conflicting with I2C4 resources
> + * Set to ignore resource conflicts with ACPI declared SystemMemory regions

Please, mind the periods at the ends of sentences.

> + */

...

> +	unsigned int quirks;

Depending on the above (32-bit compilation) this might be converted to
unsigned long.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v2 1/2] mfd: intel-lpss: Switch to generalized quirk table
Posted by Andy Shevchenko 1 year, 12 months ago
On Thu, Dec 21, 2023 at 02:41:28PM +0200, Andy Shevchenko wrote:
> On Wed, Dec 20, 2023 at 09:56:20PM +0100, Aleksandrs Vinarskis wrote:

...

> Also I'm not sure about "}, {" style. Lee as the maintainer can clarify
> on this.

JFYI:

$ git grep '^[[:space:]]\+}, {$' -- drivers/mfd/ | wc
250     750    8008

$ git grep '^[[:space:]]\+},$' -- drivers/mfd/ | wc
1898    3796   55230

-- 
With Best Regards,
Andy Shevchenko