From: Raag Jadav <raag.jadav@intel.com>
To: lee@kernel.org, giometti@enneenne.com,
gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com,
raymond.tan@intel.com
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Raag Jadav <raag.jadav@intel.com>
Subject: [PATCH v2 4/5] pps: generators: tio: move to match_data() model
Date: Mon, 3 Mar 2025 10:17:44 +0530 [thread overview]
Message-ID: <20250303044745.268964-5-raag.jadav@intel.com> (raw)
In-Reply-To: <20250303044745.268964-1-raag.jadav@intel.com>
Use device_get_match_data() which allows configuring platform
specific data like number of pins and MMIO registers for TIO.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pps/generators/pps_gen_tio.c | 33 ++++++++++++++++++++--------
drivers/pps/generators/pps_gen_tio.h | 19 +++++++++++++---
2 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/drivers/pps/generators/pps_gen_tio.c b/drivers/pps/generators/pps_gen_tio.c
index 7f2aab1219af..6e3a4b198259 100644
--- a/drivers/pps/generators/pps_gen_tio.c
+++ b/drivers/pps/generators/pps_gen_tio.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pps_gen_kernel.h>
+#include <linux/property.h>
#include <linux/timekeeping.h>
#include <linux/types.h>
@@ -28,7 +29,7 @@ static inline u32 pps_tio_read(u32 offset, struct pps_tio *tio)
static inline void pps_ctl_write(u32 value, struct pps_tio *tio)
{
- writel(value, tio->base + TIOCTL);
+ writel(value, tio->base + tio->regs.ctl);
}
/*
@@ -37,7 +38,7 @@ static inline void pps_ctl_write(u32 value, struct pps_tio *tio)
*/
static inline void pps_compv_write(u64 value, struct pps_tio *tio)
{
- hi_lo_writeq(value, tio->base + TIOCOMPV);
+ hi_lo_writeq(value, tio->base + tio->regs.compv);
}
static inline ktime_t first_event(struct pps_tio *tio)
@@ -49,7 +50,7 @@ static u32 pps_tio_disable(struct pps_tio *tio)
{
u32 ctrl;
- ctrl = pps_tio_read(TIOCTL, tio);
+ ctrl = pps_tio_read(tio->regs.ctl, tio);
pps_compv_write(0, tio);
ctrl &= ~TIOCTL_EN;
@@ -63,7 +64,7 @@ static void pps_tio_enable(struct pps_tio *tio)
{
u32 ctrl;
- ctrl = pps_tio_read(TIOCTL, tio);
+ ctrl = pps_tio_read(tio->regs.ctl, tio);
ctrl |= TIOCTL_EN;
pps_ctl_write(ctrl, tio);
tio->pps_gen->enabled = true;
@@ -112,7 +113,7 @@ static enum hrtimer_restart hrtimer_callback(struct hrtimer *timer)
* Check if any event is missed.
* If an event is missed, TIO will be disabled.
*/
- event_count = pps_tio_read(TIOEC, tio);
+ event_count = pps_tio_read(tio->regs.ec, tio);
if (tio->prev_count && tio->prev_count == event_count)
goto err;
tio->prev_count = event_count;
@@ -172,6 +173,7 @@ static int pps_tio_get_time(struct pps_gen_device *pps_gen,
static int pps_gen_tio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
+ const struct pps_tio_data *data;
struct pps_tio *tio;
if (!(cpu_feature_enabled(X86_FEATURE_TSC_KNOWN_FREQ) &&
@@ -184,6 +186,11 @@ static int pps_gen_tio_probe(struct platform_device *pdev)
if (!tio)
return -ENOMEM;
+ data = device_get_match_data(dev);
+ if (!data)
+ return -ENODEV;
+
+ tio->regs = data->regs;
tio->gen_info.use_system_clock = true;
tio->gen_info.enable = pps_tio_gen_enable;
tio->gen_info.get_time = pps_tio_get_time;
@@ -216,11 +223,19 @@ static void pps_gen_tio_remove(struct platform_device *pdev)
pps_gen_unregister_source(tio->pps_gen);
}
+static const struct pps_tio_data pmc_data = {
+ .regs = {
+ .ctl = TIOCTL_PMC,
+ .compv = TIOCOMPV_PMC,
+ .ec = TIOEC_PMC,
+ },
+};
+
static const struct acpi_device_id intel_pmc_tio_acpi_match[] = {
- { "INTC1021" },
- { "INTC1022" },
- { "INTC1023" },
- { "INTC1024" },
+ { "INTC1021", (kernel_ulong_t)&pmc_data },
+ { "INTC1022", (kernel_ulong_t)&pmc_data },
+ { "INTC1023", (kernel_ulong_t)&pmc_data },
+ { "INTC1024", (kernel_ulong_t)&pmc_data },
{}
};
MODULE_DEVICE_TABLE(acpi, intel_pmc_tio_acpi_match);
diff --git a/drivers/pps/generators/pps_gen_tio.h b/drivers/pps/generators/pps_gen_tio.h
index 5033d5efdf92..4329b6dbd598 100644
--- a/drivers/pps/generators/pps_gen_tio.h
+++ b/drivers/pps/generators/pps_gen_tio.h
@@ -18,9 +18,10 @@
struct device;
-#define TIOCTL 0x00
-#define TIOCOMPV 0x10
-#define TIOEC 0x30
+/* PMC Registers */
+#define TIOCTL_PMC 0x00
+#define TIOCOMPV_PMC 0x10
+#define TIOEC_PMC 0x30
/* Control Register */
#define TIOCTL_EN BIT(0)
@@ -36,9 +37,21 @@ struct device;
#define MAGIC_CONST (NSEC_PER_SEC - SAFE_TIME_NS)
#define ART_HW_DELAY_CYCLES 2
+struct pps_tio_regs {
+ u32 ctl;
+ u32 compv;
+ u32 ec;
+};
+
+struct pps_tio_data {
+ struct pps_tio_regs regs;
+ u32 num_pins;
+};
+
struct pps_tio {
struct pps_gen_source_info gen_info;
struct pps_gen_device *pps_gen;
+ struct pps_tio_regs regs;
struct hrtimer timer;
void __iomem *base;
u32 prev_count;
--
2.34.1
next prev parent reply other threads:[~2025-03-03 4:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 4:47 [PATCH v2 0/5] Introduce Intel Elkhart Lake PSE TIO Raag Jadav
2025-03-03 4:47 ` [PATCH v2 1/5] mfd: intel_ehl_pse_gpio: Introduce Intel Elkhart Lake PSE GPIO and TIO Raag Jadav
2025-03-03 8:24 ` Andy Shevchenko
2025-03-03 11:39 ` Raag Jadav
2025-03-03 11:45 ` Andy Shevchenko
2025-03-03 12:14 ` Raag Jadav
2025-03-03 12:22 ` Andy Shevchenko
2025-03-03 12:47 ` Raag Jadav
2025-03-03 13:20 ` Andy Shevchenko
2025-03-04 5:25 ` Raag Jadav
2025-03-04 11:33 ` Andy Shevchenko
2025-03-03 4:47 ` [PATCH v2 2/5] gpio: elkhartlake: depend on MFD_INTEL_EHL_PSE_GPIO Raag Jadav
2025-03-03 8:21 ` Andy Shevchenko
2025-03-03 11:38 ` Raag Jadav
2025-03-03 11:44 ` Andy Shevchenko
2025-03-03 12:13 ` Raag Jadav
2025-03-03 12:21 ` Andy Shevchenko
2025-03-03 12:46 ` Raag Jadav
2025-03-03 13:19 ` Andy Shevchenko
2025-03-03 14:01 ` Raag Jadav
2025-03-03 14:20 ` Andy Shevchenko
2025-03-04 5:22 ` Raag Jadav
2025-03-04 11:31 ` Andy Shevchenko
2025-03-04 14:24 ` Andy Shevchenko
2025-03-03 4:47 ` [PATCH v2 3/5] pps: generators: tio: split pps_gen_tio.h Raag Jadav
2025-03-03 4:47 ` Raag Jadav [this message]
2025-03-03 4:47 ` [PATCH v2 5/5] pps: generators: tio: Introduce Intel Elkhart Lake PSE TIO Raag Jadav
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=20250303044745.268964-5-raag.jadav@intel.com \
--to=raag.jadav@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=giometti@enneenne.com \
--cc=gregkh@linuxfoundation.org \
--cc=lee@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=raymond.tan@intel.com \
/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