Skip to contentSkip to conversation

Add TSC function supports and MFD driver for TGPIO

PATCH In review Zqiang 4 participants 7 messages May 17, 2022 – May 19, 2022

Subsystems (2)
lore
Share & tools
lore

Zqiang

author
#0 lore raw

cover Add TSC function supports and MFD driver for TGPIO

The following modifications are mainly to add TSC function for TGPIO and add intel-ehl-gpio driver divides and initializes the PSE TGPIO resources.

Christopher Hall (1):
x86/tsc: Add TSC support functions to support ART driven Time-Aware
GPIO

D, Lakshmi Sowjanya (1):
ptp: tgpio: PSE TGPIO crosststamp, counttstamp

Raymond Tan (1):
mfd: intel-ehl-gpio: Introduce MFD framework to PSE GPIO/TGPIO

 arch/x86/include/asm/tsc.h   |   8 ++
 arch/x86/kernel/tsc.c        | 168 +++++++++++++++++++++++-
 drivers/mfd/Kconfig          |  12 ++
 drivers/mfd/Makefile         |   1 +
 drivers/mfd/intel-ehl-gpio.c | 248 +++++++++++++++++++++++++++++++++++
 5 files changed, 435 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mfd/intel-ehl-gpio.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/3 x86/tsc: Add TSC support functions to support ART driven Time-Aware GPIO

From: Christopher Hall <[email protected]>

The PMC Time-Aware GPIO (TGPIO) logic is driven by ART. Several support functions are required to translate ART to/from nanoseconds units which is required by the PHC clock interface. A function is also added to get the current value of ART/TSC using get_cycles() (RDTSC). This avoids multiple MMIO reads required to retrieve ART.

Note that rather than ART nanoseconds, TSC nanoseconds are used. These are related by TSC = ART * CPUID[15H].EBX/CPUID[15H].EAX + K. The value of K is the distinction between between the ART and TSC nanoseconds.

The advantage of using TSC nanoseconds to represent the device clock because it can easily be calculated in user-space using only CPUID[15H]. The value of ART in general can't be since K isn't necessarily known to the application.

---
 arch/x86/include/asm/tsc.h |   6 ++
 arch/x86/kernel/tsc.c      | 116 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 120 insertions(+), 2 deletions(-)
arch/x86/include/asm/tsc.h +6 -0
index 01a300a9700b..721caa09a14d 100644
@@ -30,6 +30,12 @@ static inline cycles_t get_cycles(void)
 
 extern struct system_counterval_t convert_art_to_tsc(u64 art);
 extern struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns);
+extern struct timespec64 get_tsc_ns_now(struct system_counterval_t
+					*system_counter);
+extern u64 convert_tsc_ns_to_art(struct timespec64 *tsc_ns);
+extern u64 convert_tsc_ns_to_art_duration(struct timespec64 *tsc_ns);
+extern struct timespec64 convert_art_to_tsc_ns(u64 art);
+extern struct timespec64 convert_art_to_tsc_ns_duration(u64 art);
 
 extern void tsc_early_init(void);
 extern void tsc_init(void);
arch/x86/kernel/tsc.c +114 -2

134 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 2/3 ptp: tgpio: PSE TGPIO crosststamp, counttstamp

In reply to Zqiang

From: "D, Lakshmi Sowjanya" <[email protected]>

Driver gets the art time from get_art() function for PSE TGPIO crosststamp. Counttstamp implementation for PSE TGPIO.

---
 arch/x86/include/asm/tsc.h |  2 ++
 arch/x86/kernel/tsc.c      | 52 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
arch/x86/include/asm/tsc.h +2 -0
index 721caa09a14d..a480a76b47c3 100644
@@ -32,6 +32,8 @@ extern struct system_counterval_t convert_art_to_tsc(u64 art);
 extern struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns);
 extern struct timespec64 get_tsc_ns_now(struct system_counterval_t
 					*system_counter);
+extern int convert_tsc_to_art(const struct system_counterval_t *tsc, u64 *art);
+extern u64 read_art(void);
 extern u64 convert_tsc_ns_to_art(struct timespec64 *tsc_ns);
 extern u64 convert_tsc_ns_to_art_duration(struct timespec64 *tsc_ns);
 extern struct timespec64 convert_art_to_tsc_ns(u64 art);
arch/x86/kernel/tsc.c +52 -0

58 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#3 lore raw

PATCH 3/3 mfd: intel-ehl-gpio: Introduce MFD framework to PSE GPIO/TGPIO

In reply to Zqiang

From: Raymond Tan <[email protected]>

In Elkhart Lake, the PSE GPIO and TGPIO shares the PCI device, albeit being accessed at different MMIO BAR offset. Thus, to properly register device drivers and enable support of both functionalities, we choose Linux MFD framework.

1) intel-ehl-gpio - probe base on the PCI device, and split the resources
2) ptp-intel-tgpio-plat - platform driver which will register support of PSE TGPIO (20 pins max per device)

Note: BIOS configuration is required to properly assign the pin-mux.
Note: PSE TGPIO driver is based on Balbi Felipe's original driver.
Note: PSE GPIO driver is based on Pandith N's original driver.

---
 drivers/mfd/Kconfig          |  12 ++
 drivers/mfd/Makefile         |   1 +
 drivers/mfd/intel-ehl-gpio.c | 248 +++++++++++++++++++++++++++++++++++
 3 files changed, 261 insertions(+)
 create mode 100644 drivers/mfd/intel-ehl-gpio.c
drivers/mfd/Kconfig +12 -0
index b8847ae04d93..c36b35100ead 100644
@@ -2168,5 +2168,17 @@ config MFD_INTEL_M10_BMC
 	  additional drivers must be enabled in order to use the functionality
 	  of the device.
 
+config MFD_INTEL_EHL_PSE_GPIO
+	tristate "Intel Elkhart Lake PSE GPIO MFD"
+	depends on PCI
+	depends on X86
+	select MFD_CORE
+	help
+	  This MFD provides support for GPIO and TGPIO that exist only
+	  in a signle PCI device.
+
+	  IT splits the 2 IO devices to their
+	  respective drivers.
+
 endmenu
 endif
drivers/mfd/Makefile +1 -0
index 1780019d2474..5f7912391237 100644
@@ -267,3 +267,4 @@ obj-$(CONFIG_MFD_KHADAS_MCU) 	+= khadas-mcu.o
 obj-$(CONFIG_SGI_MFD_IOC3)	+= ioc3.o
 obj-$(CONFIG_MFD_SIMPLE_MFD_I2C)	+= simple-mfd-i2c.o
 obj-$(CONFIG_MFD_INTEL_M10_BMC)   += intel-m10-bmc.o
+obj-$(CONFIG_MFD_INTEL_EHL_PSE_GPIO)    += intel-ehl-gpio.o
drivers/mfd/intel-ehl-gpio.c new file +248 -0

248 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw
In reply to Zqiang
Quoted 8 lines · Zqiang via Xenomai

The following modifications are mainly to add TSC function for TGPIO and add intel-ehl-gpio driver divides and initializes the PSE TGPIO resources.

Christopher Hall (1):
x86/tsc: Add TSC support functions to support ART driven Time-Aware
GPIO

Quoted 5 lines

D, Lakshmi Sowjanya (1):
ptp: tgpio: PSE TGPIO crosststamp, counttstamp

Raymond Tan (1):
mfd: intel-ehl-gpio: Introduce MFD framework to PSE GPIO/TGPIO

I haven't looked at the details yet and I missed the Community meeting today where this topic might have been discussed.

I'm asking myself if the dovetail tree is the right tree to take those patches. Have these patches already been sent to upstream / Linux? If so, we should fetch them within the next rebase cycle, right?

If not: I feel we shouldn't apply them here and follow the "upstream first" approach.

Best regards,
Florian

Quoted 9 lines
 arch/x86/include/asm/tsc.h   |   8 ++
 arch/x86/kernel/tsc.c        | 168 +++++++++++++++++++++++-
 drivers/mfd/Kconfig          |  12 ++
 drivers/mfd/Makefile         |   1 +
 drivers/mfd/intel-ehl-gpio.c | 248 +++++++++++++++++++++++++++++++++++
 5 files changed, 435 insertions(+), 2 deletions(-)
 create mode 100644 drivers/mfd/intel-ehl-gpio.c
#5 lore raw
Quoted 18 lines · Florian (T CED SES-DE)
Quoted 8 lines · Zqiang via Xenomai

The following modifications are mainly to add TSC function for TGPIO and add intel-ehl-gpio driver divides and initializes the PSE TGPIO resources.

Christopher Hall (1):
x86/tsc: Add TSC support functions to support ART driven Time-Aware
GPIO

Quoted 5 lines

D, Lakshmi Sowjanya (1):
ptp: tgpio: PSE TGPIO crosststamp, counttstamp

Raymond Tan (1):
mfd: intel-ehl-gpio: Introduce MFD framework to PSE GPIO/TGPIO

I haven't looked at the details yet and I missed the Community meeting today where this topic might have been discussed.

Quoted 6 lines

I'm asking myself if the dovetail tree is the right tree to take those patches. Have these patches already been sent to upstream / Linux? If so, we should fetch them within the next rebase cycle, right?

If not: I feel we shouldn't apply them here and follow the "upstream first" approach.

Yup, those should be confirmed upstream first. I'm not seeing them in Linus' tree yet, or anything related. I thought EHL upstreaming was completed by now?

Once they are confirmed, backporting accepted patches to certain stable trees is much safer than having to change APIs again once that feature hits upstream later.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#6 lore raw
In reply to Bezdeka, Florian
Quoted 18 lines · Florian
Quoted 8 lines · Zqiang via Xenomai

The following modifications are mainly to add TSC function for TGPIO and add intel-ehl-gpio driver divides and initializes the PSE TGPIO resources.

Christopher Hall (1):
x86/tsc: Add TSC support functions to support ART driven Time-Aware
GPIO

Quoted 5 lines

D, Lakshmi Sowjanya (1):
ptp: tgpio: PSE TGPIO crosststamp, counttstamp

Raymond Tan (1):
mfd: intel-ehl-gpio: Introduce MFD framework to PSE GPIO/TGPIO

I haven't looked at the details yet and I missed the Community meeting today where this topic might have been discussed.

Quoted 7 lines

I'm asking myself if the dovetail tree is the right tree to take those patches. Have these patches already been sent to upstream / Linux? If so, we should fetch them within the next rebase cycle, right?

If not: I feel we shouldn't apply them here and follow the "upstream first" approach.

Agreed.

Signature · 1 line
Philippe.