TGPIO: Introduce tgpio driver and testcase
cover TGPIO: Introduce tgpio driver and testcase
General-Purpose I/O (GPIO) is a digital signal pin on an electronic device without a specified purpose. A GPIO pin can work as output (by switching to the high or low state) or as input (by reading whether a pin is in the high or low state).
The control of GPIOs on a system with Linux* or other OS may be less precise and produce more jitter compared to a bare-metal solution because of the OS scheduler.
Certain Intel processors(Intel Atom x6000E or 11th generation Intel Core processors) have a hardware feature called Time-Aware GPIO (TGPIO). These processors have one or more TGPIO pins, which you can control using timestamps. You can program a specific timestamp to toggle a TGPIO pin, or capture the current timestamp when a pin is toggled. This is done by hardware, so the OS or other software do not affect the precision.
In this patchset, we add tgpio driver and tgpiotest smokey testcase.
TGPIO RTDM driver:
The TGPIO interface is represented as a RT PTP device(/dev/rtdm/pmc-tgpio and pse-tgpio). It is controlled using ioctl() syscalls and provides the following features:
1. Getting TGPIO capabilities: number of pins, number of channels.
2. Generating signals with a given period, which starts at a specific timestamp.
3. Reading the timestamp when the input pin’s state changes.
4. Cross-timestamping the TGPIO clock with the system clock.
TGPIO smokey testcase:
The tgpiotest smokey testcase demonstrate how to start working with Time-Aware GPIO (TGPIO):
The info sample (tgpio_info) is a self-contained example program demonstrating how to get a report of available TGPIO capabilities for a specified device.
for example:
./tgpiotest --run=3 --verbose=4 --main-prio=90 device=/dev/rtdm/pmc-tgpio (or pse-tgpio)
The basic oneshot output sample (tgpio_oneshot_output) is a self-contained example program demonstrating a TGPIO single-shot output scenario. The sample demonstrates how to trigger a TGPIO pin at the specific timestamp. In this sample, this timestamp is specified as an offset from the Base time.
for example:
./tgpiotest --run=0 --verbose=4 --main-prio=90 device=/dev/rtdm/pmc-tgpio (or pse-tgpio) pin=1 channel=1 start=10000000(ns)
The basic periodic output sample (tgpio_periodic_output) is a self-contained example program demonstrating how to set a TGPIO pin to periodic output mode. The sample generates a signal based on the specified period (1 second, for example). The sample generates a voltage change on the output pin at the specific timestamp.
for example:
./tgpiotest --run=1 --verbose=4 --main-prio=90 device=/dev/rtdm/pmc-tgpio (or pse-tgpio) pin=1 channel=1 period=10000000(ns)
The basic input sample (tgpio_input) is a self-contained example program that prints a timestamp when an edge is detected, indicating a change in the TGPIO input pin state.
for example:
./tgpiotest --run=1 --verbose=4 --main-prio=90 device=/dev/rtdm/pse-tgpio (or pmc-tgpio) pin=17 channel=17 mode=1
BIOS configuration:
To enable PMC Time-Aware GPIO, configure the following BIOS options:
Intel Advanced Menu > PCH IO Configuration > Enabled Timed GPIO0 [Enable] Intel Advanced Menu > PCH IO Configuration > Enabled Timed GPIO1 [Enable]
To enable pins to be controlled as PSE-TGPIO from OS for Intel Atom x6000E Series Processors, configure the following BIOS options:
Intel Advanced Menu > PCH IO Configuration > Security Configuration > Force unlock on all GPIO pads > [Enabled]
Intel Advanced Menu > PCH IO Configuration > SerialIo Configuration > SPI2 Controller > [Disabled]
Intel Advanced Menu > PCH IO Configuration > PSE configuration > SPI0 > [Host owned with pin muxed]
Intel Advanced Menu > PCH IO Configuration > PSE configuration > Eclite > [Disabled]
Intel Advanced Menu > PCH IO Configuration > PSE configuration > GPIO/TGPIO 0 > [Host owned with pin muxed]
Intel Advanced Menu > PCH IO Configuration > PSE configuration > GPIO/TGPIO 0 MUX SELECTION > MID
Intel Advanced Menu > PCH IO Configuration > PSE configuration > GPIO/TGPIO 0 Pin Selection > Check pins 28 and 27
Intel Advanced Menu > PCH IO Configuration > PinCntrl Driver GPIO scheme > [Enabled]
(Note: PSE-TGPIO only support for Atom x6000E)
Zqiang (4):
driver/ptp: introduce real-time PTP driver support ptp/pmc-tgpio: introduce PMC Time-Aware GPIO driver for Intel
Processors
ptp/pse-tgpio: introduce PSE Time-Aware GPIO driver for Intel
Processors
testsuite/tgpiotest: introduce TGPIO smokey testcase
configure.ac | 1 + include/rtdm/rt_ptp_clock.h | 24 + include/rtdm/uapi/rt_ptp_clock.h | 258 ++++++++++ include/rtdm/uapi/rtdm.h | 1 + include/smokey/smokey.h | 10 + kernel/drivers/Kconfig | 2 +- kernel/drivers/Makefile | 2 +- kernel/drivers/ptp/Kconfig | 44 ++ kernel/drivers/ptp/Makefile | 8 + kernel/drivers/ptp/pmc-tgpio.c | 827 +++++++++++++++++++++++++++++++ kernel/drivers/ptp/pse-tgpio.c | 568 +++++++++++++++++++++ kernel/drivers/ptp/ptp.c | 537 ++++++++++++++++++++ kernel/drivers/ptp/ptp.h | 106 ++++ lib/smokey/helpers.c | 19 + testsuite/Makefile.am | 2 + testsuite/tgpiotest/Makefile.am | 19 + testsuite/tgpiotest/tgpiotest.c | 591 ++++++++++++++++++++++ 17 files changed, 3017 insertions(+), 2 deletions(-) create mode 100644 include/rtdm/rt_ptp_clock.h create mode 100644 include/rtdm/uapi/rt_ptp_clock.h create mode 100644 kernel/drivers/ptp/Kconfig create mode 100644 kernel/drivers/ptp/Makefile create mode 100644 kernel/drivers/ptp/pmc-tgpio.c create mode 100644 kernel/drivers/ptp/pse-tgpio.c create mode 100644 kernel/drivers/ptp/ptp.c create mode 100644 kernel/drivers/ptp/ptp.h create mode 100644 testsuite/tgpiotest/Makefile.am create mode 100644 testsuite/tgpiotest/tgpiotest.c
Signature · 1 line
2.25.1
PATCH 1/4 driver/ptp: introduce real-time PTP driver support
This patch add an infrastructure for TGPIO hardware, it offer a registration method to generate rtdm type of tgpio device.
--- include/rtdm/uapi/rt_ptp_clock.h | 258 +++++++++++++++ include/rtdm/uapi/rtdm.h | 1 + kernel/drivers/Kconfig | 2 +- kernel/drivers/Makefile | 2 +- kernel/drivers/ptp/Kconfig | 9 + kernel/drivers/ptp/Makefile | 2 + kernel/drivers/ptp/ptp.c | 537 +++++++++++++++++++++++++++++++ kernel/drivers/ptp/ptp.h | 106 ++++++ 8 files changed, 915 insertions(+), 2 deletions(-) create mode 100644 include/rtdm/uapi/rt_ptp_clock.h create mode 100644 kernel/drivers/ptp/Kconfig create mode 100644 kernel/drivers/ptp/Makefile create mode 100644 kernel/drivers/ptp/ptp.c create mode 100644 kernel/drivers/ptp/ptp.h
include/rtdm/uapi/rt_ptp_clock.h new file +258 -0
@@ -0,0 +1,258 @@ +/** +* @note Copyright (C) 2022 Zqiang <[email protected]> +* +* This RTDM PTP device profile header is based on: +* include/uapi/linux/ptp_clock.h PTP 1588 clock support for Linux +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License as +* published by the Free Software Foundation; either version 2 of the +* License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#ifndef _RTDM_UAPI_PTP_CLOCK_H_ +#define _RTDM_UAPI_PTP_CLOCK_H_ + +#include <linux/ioctl.h> +#include <linux/types.h> + +/* +* Bits of the rt_ptp_extts_request.flags field: +*/ +#define RT_PTP_ENABLE_FEATURE (1<<0) +#define RT_PTP_RISING_EDGE (1<<1) +#define RT_PTP_FALLING_EDGE (1<<2) +#define RT_PTP_STRICT_FLAGS (1<<3) +#define RT_PTP_EVENT_COUNTER_MODE (1<<4) +#define RT_PTP_EXTTS_EDGES (RT_PTP_RISING_EDGE | RT_PTP_FALLING_EDGE) + +/* +* Bits of the rt_ptp_pin_desc.flags field: +*/ +#define RT_PTP_PINDESC_EVTCNTVALID (1<<0) +#define RT_PTP_PINDESC_INPUTPOLL (1<<1) + +/* +* flag fields valid for the new RT_PTP_EXTTS_REQUEST2 ioctl. +*/ +#define RT_PTP_EXTTS_VALID_FLAGS (RT_PTP_ENABLE_FEATURE | \ + RT_PTP_RISING_EDGE | \ + RT_PTP_FALLING_EDGE | \ + RT_PTP_STRICT_FLAGS) + +/* +* flag fields valid for the original RT_PTP_EXTTS_REQUEST ioctl. +* DO NOT ADD NEW FLAGS HERE. +*/ +#define RT_PTP_EXTTS_V1_VALID_FLAGS (RT_PTP_ENABLE_FEATURE | \ + RT_PTP_RISING_EDGE | \ + RT_PTP_FALLING_EDGE | \ + RT_PTP_EVENT_COUNTER_MODE) + +/* +* Bits of the rt_ptp_perout_request.flags field: +*/ +#define RT_PTP_PEROUT_ONE_SHOT (1<<0) +#define RT_PTP_PEROUT_DUTY_CYCLE (1<<1) +#define RT_PTP_PEROUT_PHASE (1<<2) +#define RT_PTP_PEROUT_FREQ_ADJ (1<<3) + +/* +* flag fields valid for the new RT_PTP_PEROUT_REQUEST2 ioctl. +*/ +#define RT_PTP_PEROUT_VALID_FLAGS (RT_PTP_PEROUT_ONE_SHOT | \ + RT_PTP_PEROUT_DUTY_CYCLE | \ + RT_PTP_PEROUT_PHASE | \ + RT_PTP_PEROUT_FREQ_ADJ) + +/* +* No flags are valid for the original RT_PTP_PEROUT_REQUEST ioctl +*/ +#define RT_PTP_PEROUT_V1_VALID_FLAGS (0) + +/* +* struct rt_ptp_clock_time - represents a time value +* +* The sign of the seconds field applies to the whole value. The +* nanoseconds field is always unsigned. The reserved field is +* included for sub-nanosecond resolution, should the demand for +* this ever appear. +* +*/ +struct rt_ptp_clock_time { +__s64 sec;/* seconds */ +__u32 nsec;/* nanoseconds */ +__u32 reserved; +}; + +struct rt_ptp_clock_caps { +int max_adj;/* Maximum frequency adjustment in parts per billon. */ +int n_alarm;/* Number of programmable alarms. */ +int n_ext_ts;/* Number of external time stamp channels. */ +int n_per_out;/* Number of programmable periodic signals. */ +int pps;/* Whether the clock supports a PPS callback. */ +int n_pins;/* Number of input/output pins. */ +/* Whether the clock supports precise system-device cross timestamps */ +int cross_timestamping; +/* Whether the clock supports adjust phase */ +int adjust_phase; +int rsv[12 ];/* Reserved for future use. */ +}; + +struct rt_ptp_extts_request { +unsigned int index;/* Which channel to configure. */ +unsigned int flags;/* Bit field for PTP_xxx flags. */ +unsigned int rsv[2 ];/* Reserved for future use. */ +}; + +struct rt_ptp_perout_request { +union { +/* +* Absolute start time. +* Valid only if (flags & PTP_PEROUT_PHASE) is unset. +*/ +struct rt_ptp_clock_time start; +/* +* Phase offset. The signal should start toggling at an +* unspecified integer multiple of the period, plus this value. +* The start time should be "as soon as possible". +* Valid only if (flags & PTP_PEROUT_PHASE) is set. +*/ +struct rt_ptp_clock_time phase; + }; +struct rt_ptp_clock_time period;/* Desired period, zero means disable. */ +unsigned int index;/* Which channel to configure. */ +unsigned int flags; +union { +/* +* The "on" time of the signal. +* Must be lower than the period. +* Valid only if (flags & PTP_PEROUT_DUTY_CYCLE) is set. +*/ +struct rt_ptp_clock_time on; +/* Reserved for future use. */ +unsigned int rsv[4 ]; + }; +}; + +struct rt_ptp_event_count_tstamp { +struct rt_ptp_clock_time device_time; +unsigned long long event_count; +unsigned int index; +unsigned int flags; +unsigned int rsv[4 ];/* Reserved for future use. */ +}; + +#define RT_PTP_MAX_SAMPLES 25/* Maximum allowed offset measurement samples. */ + +struct rt_ptp_sys_offset { +unsigned int n_samples;/* Desired number of measurements. */ +unsigned int rsv[3 ];/* Reserved for future use. */ +/* +* Array of interleaved system/phc time stamps. The kernel +* will provide 2*n_samples + 1 time stamps, with the last +* one as a system time stamp. +*/ +struct rt_ptp_clock_time ts[2 *RT_PTP_MAX_SAMPLES +1 ]; +}; + +struct rt_ptp_sys_offset_extended { +unsigned int n_samples;/* Desired number of measurements. */ +unsigned int rsv[3 ];/* Reserved for future use. */ +/* +* Array of [system, phc, system] time stamps. The kernel will provide +* 3*n_samples time stamps. +*/ +struct rt_ptp_clock_time ts[RT_PTP_MAX_SAMPLES ][3 ]; +}; + +struct rt_ptp_sys_offset_precise { +struct rt_ptp_clock_time device; +struct rt_ptp_clock_time sys_realtime; +struct rt_ptp_clock_time sys_monoraw; +unsigned int rsv[4 ];/* Reserved for future use. */ +}; + +enum rt_ptp_pin_function { +RT_PTP_PF_NONE , +RT_PTP_PF_EXTTS , +RT_PTP_PF_PEROUT , +RT_PTP_PF_PHYSYNC , +}; + +struct rt_ptp_pin_desc { +/* +* Hardware specific human readable pin name. This field is +* set by the kernel during the PTP_PIN_GETFUNC ioctl and is +* ignored for the PTP_PIN_SETFUNC ioctl. +*/ +char name[64 ]; +/* +* Pin index in the range of zero to ptp_clock_caps.n_pins - 1. +*/ +unsigned int index; +/* +* Which of the PTP_PF_xxx functions to use on this pin. +*/ +unsigned int func; +/* +* The specific channel to use for this function. +* This corresponds to the 'index' field of the +* PTP_EXTTS_REQUEST and PTP_PEROUT_REQUEST ioctls. +*/ +unsigned int chan; +/* +* Per pin capability flag +*/ +unsigned int flags; +/* +* Reserved for future use. +*/ +unsigned int rsv[5 ]; +}; + +#define RT_PTP_CLK_MAGIC RTDM_CLASS_PTP + +#define RT_PTP_CLOCK_GETCAPS _IOR(RT_PTP_CLK_MAGIC, 1, struct rt_ptp_clock_caps) +#define RT_PTP_EXTTS_REQUEST _IOW(RT_PTP_CLK_MAGIC, 2, struct rt_ptp_extts_request) +#define RT_PTP_PEROUT_REQUEST _IOW(RT_PTP_CLK_MAGIC, 3, struct rt_ptp_perout_request) +#define RT_PTP_ENABLE_PPS _IOW(RT_PTP_CLK_MAGIC, 4, int) +#define RT_PTP_SYS_OFFSET _IOW(RT_PTP_CLK_MAGIC, 5, struct rt_ptp_sys_offset) +#define RT_PTP_PIN_GETFUNC _IOWR(RT_PTP_CLK_MAGIC, 6, struct rt_ptp_pin_desc) +#define RT_PTP_PIN_SETFUNC _IOW(RT_PTP_CLK_MAGIC, 7, struct rt_ptp_pin_desc) +#define RT_PTP_SYS_OFFSET_PRECISE \ + _IOWR(RT_PTP_CLK_MAGIC, 8, struct rt_ptp_sys_offset_precise) +#define RT_PTP_SYS_OFFSET_EXTENDED \ + _IOWR(RT_PTP_CLK_MAGIC, 9, struct rt_ptp_sys_offset_extended) + +#define RT_PTP_CLOCK_GETCAPS2 _IOR(RT_PTP_CLK_MAGIC, 10, struct rt_ptp_clock_caps) +#define RT_PTP_EXTTS_REQUEST2 _IOW(RT_PTP_CLK_MAGIC, 11, struct rt_ptp_extts_request) +#define RT_PTP_PEROUT_REQUEST2 _IOW(RT_PTP_CLK_MAGIC, 12, struct rt_ptp_perout_request) +#define RT_PTP_ENABLE_PPS2 _IOW(RT_PTP_CLK_MAGIC, 13, int) +#define RT_PTP_SYS_OFFSET2 _IOW(RT_PTP_CLK_MAGIC, 14, struct rt_ptp_sys_offset) +#define RT_PTP_PIN_GETFUNC2 _IOWR(RT_PTP_CLK_MAGIC, 15, struct rt_ptp_pin_desc) +#define RT_PTP_PIN_SETFUNC2 _IOW(RT_PTP_CLK_MAGIC, 16, struct rt_ptp_pin_desc) +#define RT_PTP_SYS_OFFSET_PRECISE2 \ + _IOWR(RT_PTP_CLK_MAGIC, 17, struct rt_ptp_sys_offset_precise) +#define RT_PTP_SYS_OFFSET_EXTENDED2 \ + _IOWR(RT_PTP_CLK_MAGIC, 18, struct rt_ptp_sys_offset_extended) +#define RT_PTP_EVENT_COUNT_TSTAMP2 \ + _IOWR(RT_PTP_CLK_MAGIC, 19, struct rt_ptp_event_count_tstamp) + +struct rt_ptp_extts_event { +struct rt_ptp_clock_time t;/* Time event occured. */ +unsigned int index;/* Which channel produced the event. */ +unsigned int flags;/* Reserved for future use. */ +unsigned int rsv[2 ];/* Reserved for future use. */ +}; + +#endif
include/rtdm/uapi/rtdm.h +1 -0
@@ -82,6 +82,7 @@ typedef int64_t nanosecs_rel_t;#define RTDM_CLASS_GPIO 11#define RTDM_CLASS_SPI 12#define RTDM_CLASS_PWM 13 +#define RTDM_CLASS_PTP 14#define RTDM_CLASS_MISC 223#define RTDM_CLASS_EXPERIMENTAL 224
kernel/drivers/Kconfig +1 -1
@@ -31,5 +31,5 @@ source "drivers/xenomai/udd/Kconfig" source "drivers/xenomai/gpio/Kconfig" source "drivers/xenomai/gpiopwm/Kconfig" source "drivers/xenomai/spi/Kconfig" - +source "drivers/xenomai/ptp/Kconfig" endmenu
kernel/drivers/Makefile +1 -1
@@ -1 +1 @@ -obj-$(CONFIG_XENOMAI) += autotune/ serial/ testing/ can/ net/ analogy/ ipc/ udd/ gpio/ gpiopwm/ spi/ +obj-$(CONFIG_XENOMAI) += autotune/ serial/ testing/ can/ net/ analogy/ ipc/ udd/ gpio/ gpiopwm/ spi/ ptp/
kernel/drivers/ptp/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +menu "PTP drivers" + +config XENO_DRIVERS_PTP + tristate "PTP clock support" + default y + help + This driver adds support for PTP clocks as RT devices. + +endmenu
kernel/drivers/ptp/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_XENO_DRIVERS_PTP) += xeno_ptp.o +xeno_ptp-y := ptp.o
kernel/drivers/ptp/ptp.c new file +537 -0
537 lines not on this page · raw message
kernel/drivers/ptp/ptp.h new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 2/4 ptp/pmc-tgpio: introduce PMC Time-Aware GPIO driver for Intel Processors
In reply to ZqiangAdd support for PMC Time-Aware GPIO (TGPIO) hardware that is present on upcoming Intel platforms. The hardware logic is driven by the ART clock. The current hardware has two GPIO pins. Input interrupts are not implemented in hardware.
--- kernel/drivers/ptp/Kconfig | 11 + kernel/drivers/ptp/Makefile | 3 + kernel/drivers/ptp/pmc-tgpio.c | 827 +++++++++++++++++++++++++++++++++ 3 files changed, 841 insertions(+) create mode 100644 kernel/drivers/ptp/pmc-tgpio.c
kernel/drivers/ptp/Kconfig +11 -0
@@ -6,4 +6,15 @@ config XENO_DRIVERS_PTP help This driver adds support for PTP clocks as RT devices. +config XENO_DRIVERS_PTP_PMC_TGPIO + tristate "Intel PMC Timed GPIO" + depends on XENO_DRIVERS_PTP + default n + help + This driver adds support for Intel PMC Timed-Aware GPIO (TGPIO) + note: BIOS configuration is required to properly assign the pin. + To enable PMC Time-Aware GPIO, configure the following BIOS options: + Intel Advanced Menu > PCH IO Configuration > Enabled Timed GPIO0 [Enable] + Intel Advanced Menu > PCH IO Configuration > Enabled Timed GPIO1 [Enable] + endmenu
kernel/drivers/ptp/Makefile +3 -0
@@ -1,2 +1,5 @@ obj-$(CONFIG_XENO_DRIVERS_PTP) += xeno_ptp.o xeno_ptp-y := ptp.o + +obj-$(CONFIG_XENO_DRIVERS_PTP_PMC_TGPIO) += xeno_pmc-tgpio.o +xeno_pmc-tgpio-y := pmc-tgpio.o
kernel/drivers/ptp/pmc-tgpio.c new file +827 -0
827 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 3/4 ptp/pse-tgpio: introduce PSE Time-Aware GPIO driver for Intel Processors
In reply to ZqiangThe 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, it depends on intel-ehl-gpio driver (CONFIG_MFD_INTEL_EHL_PSE_GPIO need to enable)to initialize hardware resources.
note: this driver only supports Intel Atom x6000 series processors.
--- kernel/drivers/ptp/Kconfig | 24 ++ kernel/drivers/ptp/Makefile | 3 + kernel/drivers/ptp/pse-tgpio.c | 568 +++++++++++++++++++++++++++++++++ 3 files changed, 595 insertions(+) create mode 100644 kernel/drivers/ptp/pse-tgpio.c
kernel/drivers/ptp/Kconfig +24 -0
@@ -17,4 +17,28 @@ config XENO_DRIVERS_PTP_PMC_TGPIO Intel Advanced Menu > PCH IO Configuration > Enabled Timed GPIO0 [Enable] Intel Advanced Menu > PCH IO Configuration > Enabled Timed GPIO1 [Enable] +config XENO_DRIVERS_PTP_PSE_TGPIO + tristate "Intel PSE Timed GPIO" + depends on XENO_DRIVERS_PTP + default n + help + This driver adds support for Intel PSE Timed-Aware GPIO (TGPIO) + note: BIOS configuration is required to properly assign the pin, + PSE TGPIO only for Intel Atom x6000 Series Processor. + To enable PSE Time-Aware GPIO, configure the following BIOS options: + Intel Advanced Menu > PCH IO Configuration > PSE configuration > Eclite + > Disable + Intel Advanced Menu > PCH IO Configuration > Security Configuration > + Force unlock on all GPIO pads > [Enabled] + Intel Advanced Menu > PCH IO Configuration > SerialIo Configuration > + SPI2 Controller > [Disabled] + Intel Advanced Menu > PCH IO Configuration > PSE configuration > SPI0 > + [Host owned with pin muxed] + Intel Advanced Menu > PCH IO Configuration > PSE configuration > + GPIO/TGPIO 0 > [Host owned with pin muxed] + Intel Advanced Menu > PCH IO Configuration > PSE configuration > + GPIO/TGPIO 0 MUX SELECTION > MID + Intel Advanced Menu > PCH IO Configuration > PSE configuration > + GPIO/TGPIO 0 Pin Selection > Check pins 28 and 27 + endmenu
kernel/drivers/ptp/Makefile +3 -0
@@ -3,3 +3,6 @@ xeno_ptp-y := ptp.o obj-$(CONFIG_XENO_DRIVERS_PTP_PMC_TGPIO) += xeno_pmc-tgpio.o xeno_pmc-tgpio-y := pmc-tgpio.o + +obj-$(CONFIG_XENO_DRIVERS_PTP_PSE_TGPIO) += xeno_pse-tgpio.o +xeno_pse-tgpio-y := pse-tgpio.o
kernel/drivers/ptp/pse-tgpio.c new file +568 -0
568 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 4/4 testsuite/tgpiotest: introduce TGPIO smokey testcase
In reply to ZqiangThe TGPIO testcase includes the following contents:
1. tgpio_info: get a report of available TGPIO capabilities for a specified device.
2. tgpio_oneshot_output: demonstrating a TGPIO single-shot output scenario. the sample demonstrates how to trigger a TGPIO pin at the specific timestamp. in this sample, this timestamp is specified as an offset from the Base time
3. tgpio_periodic_output: demonstrating how to set a TGPIO pin to periodic output mode the sample generates a signal based on the specified period (1 second, for example). the sample generates a voltage change on the output pin at the specific timestamp.
4. tgpio_input: prints a timestamp when an edge is detected, indicating a change in the TGPIO input pin state.
--- configure.ac | 1 + include/rtdm/rt_ptp_clock.h | 24 ++ include/smokey/smokey.h | 10 + lib/smokey/helpers.c | 19 + testsuite/Makefile.am | 2 + testsuite/tgpiotest/Makefile.am | 19 + testsuite/tgpiotest/tgpiotest.c | 591 ++++++++++++++++++++++++++++++++ 7 files changed, 666 insertions(+) create mode 100644 include/rtdm/rt_ptp_clock.h create mode 100644 testsuite/tgpiotest/Makefile.am create mode 100644 testsuite/tgpiotest/tgpiotest.c
configure.ac +1 -0
@@ -971,6 +971,7 @@ AC_CONFIG_FILES([ \ testsuite/switchtest/Makefile \ testsuite/gpiotest/Makefile \ testsuite/gpiobench/Makefile \ + testsuite/tgpiotest/Makefile \ testsuite/spitest/Makefile \ testsuite/smokey/Makefile \ testsuite/smokey/arith/Makefile \
include/rtdm/rt_ptp_clock.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (C) 2022 Zqiang <[email protected]> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. + +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +*/ +#ifndef _RTDM_PTP_H +#define _RTDM_PTP_H + +#include <rtdm/rtdm.h> +#include <rtdm/uapi/rt_ptp_clock.h> + +#endif
include/smokey/smokey.h +10 -0
@@ -31,6 +31,12 @@#define do_fork vfork#endif +#define SMOKEY_ULONG (__name) { \ + .name = # __name, \ + .parser = smokey_ulong, \ + .matched = 0, \ + } +#define SMOKEY_INT (__name) { \ .name = # __name, \ .parser = smokey_int, \
@@ -65,6 +71,7 @@ struct smokey_arg { struct smokey_arg *arg);union {int n_val; +unsigned long long ln_val;char *s_val;size_t l_val; } u;
@@ -112,6 +119,7 @@ struct smokey_test {#define SMOKEY_ARG_BOOL (__plugin, __arg) (!!SMOKEY_ARG_INT(__plugin, __arg))#define SMOKEY_ARG_STRING (__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.s_val)#define SMOKEY_ARG_SIZE (__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.l_val) +#define SMOKEY_ARG_ULONG (__plugin, __arg) (SMOKEY_ARG(__plugin, __arg)->u.ln_val)#define smokey_arg_isset (__t, __name) (smokey_lookup_arg(__t, __name)->matched)#define smokey_arg_int (__t, __name) (smokey_lookup_arg(__t, __name)->u.n_val)
@@ -221,6 +229,8 @@ void smokey_register_plugin(struct smokey_test *t);int smokey_int (const char *s,struct smokey_arg *arg); +int smokey_ulong (const char *s,struct smokey_arg *arg); +int smokey_bool (const char *s,struct smokey_arg *arg);int smokey_string (const char *s,struct smokey_arg *arg);
lib/smokey/helpers.c +19 -0
@@ -47,6 +47,25 @@ int smokey_int(const char *s, struct smokey_arg *arg)return ret; } +int smokey_ulong (const char *s,struct smokey_arg *arg) +{ +char *name, *p; +int ret; + + ret =sscanf (s,"%m[_a-z]=%m[^\n]" , &name, &p); +if (ret !=2 || !(isdigit (*p) || *p =='-' )) +return 0 ; + + ret = !strcmp (name, arg->name); +if (ret) + arg->u.ln_val =strtoull (p,NULL ,10 ); + +free (p); +free (name); + +return ret; +} +int smokey_bool (const char *s,struct smokey_arg *arg) {int ret;
testsuite/Makefile.am +2 -0
@@ -7,6 +7,7 @@ SUBDIRS += \ gpiotest \ spitest \ switchtest \ + tgpiotest \ xeno-test endif
@@ -18,4 +19,5 @@ DIST_SUBDIRS = \ smokey \ spitest \ switchtest \ + tgpiotest \ xeno-test
testsuite/tgpiotest/Makefile.am new file +19 -0
@@ -0,0 +1,19 @@ +testdir = @XENO_TEST_DIR@ + +CCLD = $(top_srcdir)/scripts/wrap-link.sh $(CC) + +test_PROGRAMS = tgpiotest + +tgpiotest_SOURCES = tgpiotest.c + +tgpiotest_CPPFLAGS = \ + $(XENO_USER_CFLAGS) \ + -I$(top_srcdir)/include + +tgpiotest_LDFLAGS = @XENO_AUTOINIT_LDFLAGS@ $(XENO_POSIX_WRAPPERS) + +tgpiotest_LDADD = \ + ../../lib/smokey/libsmokey@[email protected] \ + @XENO_CORE_LDADD@ \ + @XENO_USER_LDADD@ \ + -lpthread -lrt
testsuite/tgpiotest/tgpiotest.c new file +591 -0
591 lines not on this page · raw message
Signature · 1 line
2.25.1