[PATCH v1 2/2] mfd: intel-lpss: Introduce QUIRK_CLOCK_DIVIDER_UNITY for XPS 9530

Aleksandrs Vinarskis posted 2 patches 1 year, 12 months ago
There is a newer version of this series
[PATCH v1 2/2] mfd: intel-lpss: Introduce QUIRK_CLOCK_DIVIDER_UNITY for XPS 9530
Posted by Aleksandrs Vinarskis 1 year, 12 months ago
Some devices (eg. Dell XPS 9530, 2023) due to a firmware bug have a
misconfigured clock divider, which should've been 1:1. This introduces
quirk which conditionally re-configures the clock divider to 1:1.

Signed-off-by: Aleksandrs Vinarskis <alex.vinarskis@gmail.com>
---
 drivers/mfd/intel-lpss-pci.c | 8 ++++++++
 drivers/mfd/intel-lpss.c     | 7 +++++++
 drivers/mfd/intel-lpss.h     | 1 +
 3 files changed, 16 insertions(+)

diff --git a/drivers/mfd/intel-lpss-pci.c b/drivers/mfd/intel-lpss-pci.c
index cf8006e094f7..2e3b91418415 100644
--- a/drivers/mfd/intel-lpss-pci.c
+++ b/drivers/mfd/intel-lpss-pci.c
@@ -28,6 +28,11 @@ static const struct intel_lpss_platform_info quirk_ignore_resource_conflicts = {
 	.quirks = QUIRK_IGNORE_RESOURCE_CONFLICTS,
 };
 
+/* Some devices have misconfigured clock divider, which should've been 1:1 */
+static const struct intel_lpss_platform_info quirk_skip_clock_divider = {
+	.quirks = QUIRK_CLOCK_DIVIDER_UNITY,
+};
+
 static const struct pci_device_id quirk_ids[] = {
 	{	/* Microsoft Surface Go (version 1) I2C4 */
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x9d64, 0x152d, 0x1182),
@@ -35,6 +40,9 @@ static const struct pci_device_id quirk_ids[] = {
 	}, {	/* Microsoft Surface Go 2 I2C4 */
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x9d64, 0x152d, 0x1237),
 		.driver_data = (kernel_ulong_t)&quirk_ignore_resource_conflicts,
+	}, {	/* Dell XPS 9530 (2023) */
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x51fb, 0x1028, 0x0beb),
+		.driver_data = (kernel_ulong_t)&quirk_skip_clock_divider,
 	},
 	{}
 };
diff --git a/drivers/mfd/intel-lpss.c b/drivers/mfd/intel-lpss.c
index aafa0da5f8db..2a9018112dfc 100644
--- a/drivers/mfd/intel-lpss.c
+++ b/drivers/mfd/intel-lpss.c
@@ -300,6 +300,7 @@ static int intel_lpss_register_clock_divider(struct intel_lpss *lpss,
 {
 	char name[32];
 	struct clk *tmp = *clk;
+	int ret;
 
 	snprintf(name, sizeof(name), "%s-enable", devname);
 	tmp = clk_register_gate(NULL, name, __clk_get_name(tmp), 0,
@@ -316,6 +317,12 @@ static int intel_lpss_register_clock_divider(struct intel_lpss *lpss,
 		return PTR_ERR(tmp);
 	*clk = tmp;
 
+	if (lpss->info->quirks & QUIRK_CLOCK_DIVIDER_UNITY) {
+		ret = clk_set_rate(tmp, lpss->info->clk_rate);
+		if (ret)
+			return ret;
+	}
+
 	snprintf(name, sizeof(name), "%s-update", devname);
 	tmp = clk_register_gate(NULL, name, __clk_get_name(tmp),
 				CLK_SET_RATE_PARENT, lpss->priv, 31, 0, NULL);
diff --git a/drivers/mfd/intel-lpss.h b/drivers/mfd/intel-lpss.h
index 3e9d96c372a8..f27834b74cb6 100644
--- a/drivers/mfd/intel-lpss.h
+++ b/drivers/mfd/intel-lpss.h
@@ -14,6 +14,7 @@
 #include <linux/pm.h>
 
 #define QUIRK_IGNORE_RESOURCE_CONFLICTS BIT(0)
+#define QUIRK_CLOCK_DIVIDER_UNITY		BIT(1)
 
 struct device;
 struct resource;
-- 
2.40.1
Re: [PATCH v1 2/2] mfd: intel-lpss: Introduce QUIRK_CLOCK_DIVIDER_UNITY for XPS 9530
Posted by Andy Shevchenko 1 year, 12 months ago
On Wed, Dec 20, 2023 at 08:31:48AM +0100, Aleksandrs Vinarskis wrote:
> Some devices (eg. Dell XPS 9530, 2023) due to a firmware bug have a
> misconfigured clock divider, which should've been 1:1. This introduces
> quirk which conditionally re-configures the clock divider to 1:1.

(Btw, do you use --histogram when preparing patches? Use it in v2.)

...

> +	}, {	/* Dell XPS 9530 (2023) */
> +		PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x51fb, 0x1028, 0x0beb),
> +		.driver_data = (kernel_ulong_t)&quirk_skip_clock_divider,
>  	},

Should be

	}, {	/* Dell XPS 9530 (2023) */
		PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x51fb, 0x1028, 0x0beb),
		.driver_data = QUIRK_CLOCK_DIVIDER_UNITY,
	},

...

>  #define QUIRK_IGNORE_RESOURCE_CONFLICTS BIT(0)
> +#define QUIRK_CLOCK_DIVIDER_UNITY		BIT(1)

Each quirk should be documented, see, for example,
https://elixir.bootlin.com/linux/latest/source/include/linux/gpio/consumer.h#L593

-- 
With Best Regards,
Andy Shevchenko