lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240122030238.29437-2-raag.jadav@intel.com>
Date: Mon, 22 Jan 2024 08:32:36 +0530
From: Raag Jadav <raag.jadav@...el.com>
To: u.kleine-koenig@...gutronix.de,
	jarkko.nikula@...ux.intel.com,
	mika.westerberg@...ux.intel.com,
	andriy.shevchenko@...ux.intel.com,
	lakshmi.sowjanya.d@...el.com
Cc: linux-pwm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Raag Jadav <raag.jadav@...el.com>
Subject: [PATCH v1 1/3] pwm: dwc: Add 16 channel support for Intel Elkhart Lake

Intel Elkhart Lake PSE includes two instances of PWM as a single PCI
function with 8 channels each. Add support for the remaining channels.

Signed-off-by: Raag Jadav <raag.jadav@...el.com>
Tested-by: Lakshmi Sowjanya D <lakshmi.sowjanya.d@...el.com>
---
 drivers/pwm/pwm-dwc.c | 51 +++++++++++++++++++++++++++++++++++--------
 drivers/pwm/pwm-dwc.h |  5 +++++
 2 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/drivers/pwm/pwm-dwc.c b/drivers/pwm/pwm-dwc.c
index 4929354f8cd9..fd64313cb38d 100644
--- a/drivers/pwm/pwm-dwc.c
+++ b/drivers/pwm/pwm-dwc.c
@@ -25,16 +25,48 @@
 
 #include "pwm-dwc.h"
 
+/* Elkhart Lake */
+static const struct dwc_pwm_info ehl_pwm_info = {
+	.nr = 2,
+	.size = 0x1000,
+};
+
+static int dwc_pwm_init(struct device *dev, const struct dwc_pwm_info *info, void __iomem *base)
+{
+	/* Default values for single instance devices */
+	unsigned int nr = 1, size = 0;
+	int i, ret;
+
+	/* Fill up values from driver_data, if any */
+	if (info) {
+		nr = info->nr;
+		size = info->size;
+	}
+
+	for (i = 0; i < nr; i++) {
+		struct dwc_pwm *dwc;
+
+		dwc = dwc_pwm_alloc(dev);
+		if (!dwc)
+			return -ENOMEM;
+
+		dwc->base = base + (i * size);
+
+		ret = devm_pwmchip_add(dev, &dwc->chip);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
+}
+
 static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
 {
+	const struct dwc_pwm_info *info;
 	struct device *dev = &pci->dev;
-	struct dwc_pwm *dwc;
+	void __iomem *base;
 	int ret;
 
-	dwc = dwc_pwm_alloc(dev);
-	if (!dwc)
-		return -ENOMEM;
-
 	ret = pcim_enable_device(pci);
 	if (ret) {
 		dev_err(dev, "Failed to enable device (%pe)\n", ERR_PTR(ret));
@@ -49,13 +81,14 @@ static int dwc_pwm_probe(struct pci_dev *pci, const struct pci_device_id *id)
 		return ret;
 	}
 
-	dwc->base = pcim_iomap_table(pci)[0];
-	if (!dwc->base) {
+	base = pcim_iomap_table(pci)[0];
+	if (!base) {
 		dev_err(dev, "Base address missing\n");
 		return -ENOMEM;
 	}
 
-	ret = devm_pwmchip_add(dev, &dwc->chip);
+	info = (const struct dwc_pwm_info *)id->driver_data;
+	ret = dwc_pwm_init(dev, info, base);
 	if (ret)
 		return ret;
 
@@ -109,7 +142,7 @@ static int dwc_pwm_resume(struct device *dev)
 static DEFINE_SIMPLE_DEV_PM_OPS(dwc_pwm_pm_ops, dwc_pwm_suspend, dwc_pwm_resume);
 
 static const struct pci_device_id dwc_pwm_id_table[] = {
-	{ PCI_VDEVICE(INTEL, 0x4bb7) }, /* Elkhart Lake */
+	{ PCI_VDEVICE(INTEL, 0x4bb7), (kernel_ulong_t)&ehl_pwm_info },
 	{  }	/* Terminating Entry */
 };
 MODULE_DEVICE_TABLE(pci, dwc_pwm_id_table);
diff --git a/drivers/pwm/pwm-dwc.h b/drivers/pwm/pwm-dwc.h
index 64795247c54c..c9bbfc77b568 100644
--- a/drivers/pwm/pwm-dwc.h
+++ b/drivers/pwm/pwm-dwc.h
@@ -33,6 +33,11 @@ MODULE_IMPORT_NS(dwc_pwm);
 #define DWC_TIM_CTRL_INT_MASK	BIT(2)
 #define DWC_TIM_CTRL_PWM	BIT(3)
 
+struct dwc_pwm_info {
+	unsigned int nr;
+	unsigned int size;
+};
+
 struct dwc_pwm_ctx {
 	u32 cnt;
 	u32 cnt2;
-- 
2.35.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ