From nobody Sun Nov 24 23:45:18 2024 Received: from smtpcmd0756.aruba.it (smtpcmd0756.aruba.it [62.149.156.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A72E01D1519 for ; Fri, 8 Nov 2024 07:38:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.149.156.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051519; cv=none; b=PeBfkImsbzS6keaKBY+AZfSSWF8K6KA2RoCKOQh70J5/OaMooTQxnOY9qNIjzYm9RPw7U6kkVP4CvkHTotJKxwaIZX3/68TC/z1JwKI9FoAqdjw7UEQLENRbYMKlQaByxol6hN6hVzCD5JVmaF6NlJVb4qM2mJ7menFYtTo19uo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051519; c=relaxed/simple; bh=BO5RyyymyYL2eadbR7ThNSbzhn4cNX0P7maH2NUBcgg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n6sDPOnsBmWmcpBLBFu/lQD4pXc/oGaIe63Gfuun4e9MDT5q9ZCKgzjGnctq7HkrZfNyeTbM2K+BZHbpgen7C2YtstSbP/5arxOsA9W0juseN2/M4jt3iO9dA8GwnjA2i8BHocTql+/FGm+RHYDg7D6mgWHZxJHz1XnJIT6xCKA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com; spf=pass smtp.mailfrom=enneenne.com; dkim=temperror (0-bit key) header.d=aruba.it header.i=@aruba.it header.b=WWiTN5xS; arc=none smtp.client-ip=62.149.156.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enneenne.com Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=aruba.it header.i=@aruba.it header.b="WWiTN5xS" Received: from polimar.everex.local ([79.0.204.227]) by Aruba Outgoing Smtp with ESMTPSA id 9JSetHUHi6epj9JShtjpds; Fri, 08 Nov 2024 08:31:20 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1731051080; bh=BO5RyyymyYL2eadbR7ThNSbzhn4cNX0P7maH2NUBcgg=; h=From:To:Subject:Date:MIME-Version; b=WWiTN5xSo2BT7OB5ajfd/N21WcO8yCQYV8N8qnYOPM2SRinDKUYF2ZXNOJnO9Va96 P22blveqv8N949r4OhvDnNschEYpMK/zBVfdhomy/efvFfUaQcK3+v883ffsJ6pRL5 nIGPlK0JTfGch6N9rzvf0XztnS4fu3KsqrNQpuxNVmnzmfecmgPeR2VMG1iXGBc3S6 rIc4f6KcLC8h9SVLihrsJcWh3VKRfTwYvMVGsrmLKilm5jCXlEgbBM76WyV4n1Aeoi SWM9YoL7Mq17/Hi5vh2GN6FpPouDwi68Ld4BB1iU+OZxI7xsucoJzM6leinvV5ytgz aqx4Zte5n4tAA== From: Rodolfo Giometti To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Greg KH , corbet@lwn.net, Hall Christopher S , Mohan Subramanian , tglx@linutronix.de, Andy Shevchenko , Dong Eddie , N Pandith , T R Thejesh Reddy , Zage David , Chinnadurai Srinivasan , Randy Dunlap , Bagas Sanjaya , Rodolfo Giometti Subject: [V3 1/4] drivers pps: add PPS generators support Date: Fri, 8 Nov 2024 08:31:12 +0100 Message-Id: <20241108073115.759039-2-giometti@enneenne.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241108073115.759039-1-giometti@enneenne.com> References: <20241108073115.759039-1-giometti@enneenne.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CMAE-Envelope: MS4xfByL/ulLdeMvtM5pRvsMn3uqQHLcEzSgHMHHx1ZPNoq3K1tx8qXTnz7zlvmaug499Umh7L+GGGTThclnIlsQpTGPAsNa6UpVcNKglabfe4ZN0rrvelRS FzdzP1a3dVjnjHE9OK+h8skrDWSgfXcWnZ0+L6W93YQxjd/U7+Dfa1rSw/nVMH3a40d0ggZ6NQmUx8V+N1MLnbu3RAnC5vqGeV2zTaW3KF11MQyJMa9tS+MD JAMNmyKE8ozZQir2yaZX/RIUVV6gX87jK+rfEyIyoWdnU+OJVBki2kUdXS/eBSZaMhldbrMCpMrpFQczF82G/bddamuWOtoTDnf5MEKdG8TmbBqyJ4I/WEs9 A/sq5zUqsrm5z/69yJBZXnnopJL6ItshSzDj9Ru4CT3kBj3rKvSjDaPmk36GGNqcf2ZjInB/Q9B9ndYRroZydtDHARCP4OT4d/SdGMkXJBxkkweePMoNOKJR ID9K14Bl55fOpXydhMp0mLvqEEgSXUp+2dF+1HDdlGthg7/7gAppExL6y2mFg6p6eo2e9NsEk2Kp6kxKuIfNqqTB7twt8y1yqRVRsETy+/OCTvOYtB50iCs0 QjgOrtCPpXqmDuYWa434ib4ZAiOvlxY7umQBn2OkJDw9TYE77IXsTYnHFa6pG7D9JuqL9U7c/l+Z8TlR2cgFcRCAsSBjb5jf+08kncvT4Zva2giQV10MCTu4 rniCDRebhQF354X1bscNHb78ZbexATptWl2ljhYrJx5D+pOSy/mSjPN6AxbRMgDETnnBtU73aB0= Content-Type: text/plain; charset="utf-8" Sometimes one needs to be able not only to catch PPS signals but to produce them also. For example, running a distributed simulation, which requires computers' clock to be synchronized very tightly. This patch adds PPS generators class in order to have a well-defined interface for these devices. Signed-off-by: Rodolfo Giometti --- .../userspace-api/ioctl/ioctl-number.rst | 1 + MAINTAINERS | 1 + drivers/pps/Makefile | 3 +- drivers/pps/generators/Kconfig | 13 +- drivers/pps/generators/Makefile | 3 + drivers/pps/generators/pps_gen.c | 344 ++++++++++++++++++ drivers/pps/generators/sysfs.c | 75 ++++ include/linux/pps_gen_kernel.h | 78 ++++ include/uapi/linux/pps_gen.h | 37 ++ 9 files changed, 553 insertions(+), 2 deletions(-) create mode 100644 drivers/pps/generators/pps_gen.c create mode 100644 drivers/pps/generators/sysfs.c create mode 100644 include/linux/pps_gen_kernel.h create mode 100644 include/uapi/linux/pps_gen.h diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documenta= tion/userspace-api/ioctl/ioctl-number.rst index e4be1378ba26..e4f7f798f091 100644 --- a/Documentation/userspace-api/ioctl/ioctl-number.rst +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst @@ -283,6 +283,7 @@ Code Seq# Include File = Comments 'p' 80-9F linux/ppdev.h user-= space parport 'p' A1-A5 linux/pps.h Linux= PPS +'p' B1-B3 linux/pps-gen.h Linux= PPS 'q' 00-1F linux/serio.h 'q' 80-FF linux/telephony.h Inter= net PhoneJACK, Internet LineJACK diff --git a/MAINTAINERS b/MAINTAINERS index 273a84483b74..d65e54e385b8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18487,6 +18487,7 @@ F: Documentation/devicetree/bindings/pps/pps-gpio.y= aml F: Documentation/driver-api/pps.rst F: drivers/pps/ F: include/linux/pps*.h +F: include/uapi/linux/pps-gen.h F: include/uapi/linux/pps.h =20 PRESSURE STALL INFORMATION (PSI) diff --git a/drivers/pps/Makefile b/drivers/pps/Makefile index ceaf65cc1f1d..0aea394d4e4d 100644 --- a/drivers/pps/Makefile +++ b/drivers/pps/Makefile @@ -6,6 +6,7 @@ pps_core-y :=3D pps.o kapi.o sysfs.o pps_core-$(CONFIG_NTP_PPS) +=3D kc.o obj-$(CONFIG_PPS) :=3D pps_core.o -obj-y +=3D clients/ generators/ +obj-y +=3D clients/ +obj-$(CONFIG_PPS_GENERATOR) +=3D generators/ =20 ccflags-$(CONFIG_PPS_DEBUG) :=3D -DDEBUG diff --git a/drivers/pps/generators/Kconfig b/drivers/pps/generators/Kconfig index d615e640fcad..b34e483eff21 100644 --- a/drivers/pps/generators/Kconfig +++ b/drivers/pps/generators/Kconfig @@ -3,7 +3,16 @@ # PPS generators configuration # =20 -comment "PPS generators support" +menuconfig PPS_GENERATOR + tristate "PPS generators support" + help + PPS generators are special hardware which are able to produce PPS + (Pulse Per Second) signals. + + To compile this driver as a module, choose M here: the module + will be called pps_gen_core. + +if PPS_GENERATOR =20 config PPS_GENERATOR_PARPORT tristate "Parallel port PPS signal generator" @@ -12,3 +21,5 @@ config PPS_GENERATOR_PARPORT If you say yes here you get support for a PPS signal generator which utilizes STROBE pin of a parallel port to send PPS signals. It uses parport abstraction layer and hrtimers to precisely control the signal. + +endif # PPS_GENERATOR diff --git a/drivers/pps/generators/Makefile b/drivers/pps/generators/Makef= ile index 2589fd0f2481..034a78edfa26 100644 --- a/drivers/pps/generators/Makefile +++ b/drivers/pps/generators/Makefile @@ -3,6 +3,9 @@ # Makefile for PPS generators. # =20 +pps_gen_core-y :=3D pps_gen.o sysfs.o +obj-$(CONFIG_PPS_GENERATOR) :=3D pps_gen_core.o + obj-$(CONFIG_PPS_GENERATOR_PARPORT) +=3D pps_gen_parport.o =20 ccflags-$(CONFIG_PPS_DEBUG) :=3D -DDEBUG diff --git a/drivers/pps/generators/pps_gen.c b/drivers/pps/generators/pps_= gen.c new file mode 100644 index 000000000000..ca592f1736f4 --- /dev/null +++ b/drivers/pps/generators/pps_gen.c @@ -0,0 +1,344 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * PPS generators core file + * + * Copyright (C) 2024 Rodolfo Giometti + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Local variables + */ + +static dev_t pps_gen_devt; +static struct class *pps_gen_class; + +static DEFINE_IDA(pps_gen_ida); + +/* + * Char device methods + */ + +static __poll_t pps_gen_cdev_poll(struct file *file, poll_table *wait) +{ + struct pps_gen_device *pps_gen =3D file->private_data; + + poll_wait(file, &pps_gen->queue, wait); + return EPOLLIN | EPOLLRDNORM; +} + +static int pps_gen_cdev_fasync(int fd, struct file *file, int on) +{ + struct pps_gen_device *pps_gen =3D file->private_data; + + return fasync_helper(fd, file, on, &pps_gen->async_queue); +} + +static long pps_gen_cdev_ioctl(struct file *file, + unsigned int cmd, unsigned long arg) +{ + struct pps_gen_device *pps_gen =3D file->private_data; + void __user *uarg =3D (void __user *) arg; + unsigned int __user *uiuarg =3D (unsigned int __user *) arg; + unsigned int status; + int ret; + + switch (cmd) { + case PPS_GEN_SETENABLE: + dev_dbg(pps_gen->dev, "PPS_GEN_SETENABLE\n"); + + ret =3D get_user(status, uiuarg); + if (ret) + return -EFAULT; + + ret =3D pps_gen->info.enable(pps_gen, status); + if (ret) + return ret; + pps_gen->enabled =3D status; + + break; + + case PPS_GEN_USESYSTEMCLOCK: + dev_dbg(pps_gen->dev, "PPS_GEN_USESYSTEMCLOCK\n"); + + ret =3D put_user(pps_gen->info.use_system_clock, uiuarg); + if (ret) + return -EFAULT; + + break; + + case PPS_GEN_FETCHEVENT: { + struct pps_gen_event info; + unsigned int ev =3D pps_gen->last_ev; + + dev_dbg(pps_gen->dev, "PPS_GEN_FETCHEVENT\n"); + + ret =3D wait_event_interruptible(pps_gen->queue, + ev !=3D pps_gen->last_ev); + if (ret =3D=3D -ERESTARTSYS) { + dev_dbg(pps_gen->dev, "pending signal caught\n"); + return -EINTR; + } + + spin_lock_irq(&pps_gen->lock); + info.sequence =3D pps_gen->sequence; + info.event =3D pps_gen->event; + spin_unlock_irq(&pps_gen->lock); + + ret =3D copy_to_user(uarg, &info, sizeof(struct pps_gen_event)); + if (ret) + return -EFAULT; + + break; + } + default: + return -ENOTTY; + } + + return 0; +} + +static int pps_gen_cdev_open(struct inode *inode, struct file *file) +{ + struct pps_gen_device *pps_gen =3D container_of(inode->i_cdev, + struct pps_gen_device, cdev); + + get_device(pps_gen->dev); + file->private_data =3D pps_gen; + return 0; +} + +static int pps_gen_cdev_release(struct inode *inode, struct file *file) +{ + struct pps_gen_device *pps_gen =3D file->private_data; + + put_device(pps_gen->dev); + return 0; +} + +/* + * Char device stuff + */ + +static const struct file_operations pps_gen_cdev_fops =3D { + .owner =3D THIS_MODULE, + .poll =3D pps_gen_cdev_poll, + .fasync =3D pps_gen_cdev_fasync, + .unlocked_ioctl =3D pps_gen_cdev_ioctl, + .open =3D pps_gen_cdev_open, + .release =3D pps_gen_cdev_release, +}; + +static void pps_gen_device_destruct(struct device *dev) +{ + struct pps_gen_device *pps_gen =3D dev_get_drvdata(dev); + + cdev_del(&pps_gen->cdev); + + pr_debug("deallocating pps-gen%d\n", pps_gen->id); + ida_free(&pps_gen_ida, pps_gen->id); + + kfree(dev); + kfree(pps_gen); +} + +static int pps_gen_register_cdev(struct pps_gen_device *pps_gen) +{ + int err; + dev_t devt; + + err =3D ida_alloc_max(&pps_gen_ida, PPS_GEN_MAX_SOURCES - 1, GFP_KERNEL); + if (err < 0) { + if (err =3D=3D -ENOSPC) { + pr_err("too many PPS sources in the system\n"); + err =3D -EBUSY; + } + return err; + } + pps_gen->id =3D err; + + devt =3D MKDEV(MAJOR(pps_gen_devt), pps_gen->id); + + cdev_init(&pps_gen->cdev, &pps_gen_cdev_fops); + pps_gen->cdev.owner =3D pps_gen->info.owner; + + err =3D cdev_add(&pps_gen->cdev, devt, 1); + if (err) { + pr_err("failed to add char device %d:%d\n", + MAJOR(pps_gen_devt), pps_gen->id); + goto free_ida; + } + pps_gen->dev =3D device_create(pps_gen_class, pps_gen->info.parent, devt, + pps_gen, "pps-gen%d", pps_gen->id); + if (IS_ERR(pps_gen->dev)) { + err =3D PTR_ERR(pps_gen->dev); + goto del_cdev; + } + pps_gen->dev->release =3D pps_gen_device_destruct; + dev_set_drvdata(pps_gen->dev, pps_gen); + + pr_debug("generator got cdev (%d:%d)\n", + MAJOR(pps_gen_devt), pps_gen->id); + + return 0; + +del_cdev: + cdev_del(&pps_gen->cdev); +free_ida: + ida_free(&pps_gen_ida, pps_gen->id); + return err; +} + +static void pps_gen_unregister_cdev(struct pps_gen_device *pps_gen) +{ + pr_debug("unregistering pps-gen%d\n", pps_gen->id); + device_destroy(pps_gen_class, pps_gen->dev->devt); +} + +/* + * Exported functions + */ + +/** + * pps_gen_register_source() - add a PPS generator in the system + * @info: the PPS generator info struct + * + * This function is used to register a new PPS generator in the system. + * When it returns successfully the new generator is up and running, and + * it can be managed by the userspace. + * + * Return: the PPS generator device in case of success, and ERR_PTR(errno) + * otherwise. + */ +struct pps_gen_device *pps_gen_register_source(struct pps_gen_source_info = *info) +{ + struct pps_gen_device *pps_gen; + int err; + + pps_gen =3D kzalloc(sizeof(struct pps_gen_device), GFP_KERNEL); + if (pps_gen =3D=3D NULL) { + err =3D -ENOMEM; + goto pps_gen_register_source_exit; + } + pps_gen->info =3D *info; + pps_gen->enabled =3D false; + + init_waitqueue_head(&pps_gen->queue); + spin_lock_init(&pps_gen->lock); + + /* Create the char device */ + err =3D pps_gen_register_cdev(pps_gen); + if (err < 0) { + pr_err(" unable to create char device\n"); + goto kfree_pps_gen; + } + + return pps_gen; + +kfree_pps_gen: + kfree(pps_gen); + +pps_gen_register_source_exit: + pr_err("unable to register generator\n"); + + return ERR_PTR(err); +} +EXPORT_SYMBOL(pps_gen_register_source); + +/** + * pps_gen_unregister_source() - remove a PPS generator from the system + * @pps_gen: the PPS generator device to be removed + * + * This function is used to deregister a PPS generator from the system. Wh= en + * called, it disables the generator so no pulses are generated anymore. + */ +void pps_gen_unregister_source(struct pps_gen_device *pps_gen) +{ + pps_gen_unregister_cdev(pps_gen); +} +EXPORT_SYMBOL(pps_gen_unregister_source); + +/* pps_gen_event - register a PPS generator event into the system + * @pps: the PPS generator device + * @event: the event type + * @data: userdef pointer + * + * This function is used by each PPS generator in order to register a new + * PPS event into the system (it's usually called inside an IRQ handler). + */ +void pps_gen_event(struct pps_gen_device *pps_gen, + unsigned int event, void *data) +{ + unsigned long flags; + + dev_dbg(pps_gen->dev, "PPS generator event %u\n", event); + + spin_lock_irqsave(&pps_gen->lock, flags); + + pps_gen->event =3D event; + pps_gen->sequence++; + + pps_gen->last_ev++; + wake_up_interruptible_all(&pps_gen->queue); + kill_fasync(&pps_gen->async_queue, SIGIO, POLL_IN); + + spin_unlock_irqrestore(&pps_gen->lock, flags); +} +EXPORT_SYMBOL(pps_gen_event); + +/* + * Module stuff + */ + +static void __exit pps_gen_exit(void) +{ + class_destroy(pps_gen_class); + unregister_chrdev_region(pps_gen_devt, PPS_GEN_MAX_SOURCES); +} + +static int __init pps_gen_init(void) +{ + int err; + + pps_gen_class =3D class_create("pps-gen"); + if (IS_ERR(pps_gen_class)) { + pr_err("failed to allocate class\n"); + return PTR_ERR(pps_gen_class); + } + pps_gen_class->dev_groups =3D pps_gen_groups; + + err =3D alloc_chrdev_region(&pps_gen_devt, 0, + PPS_GEN_MAX_SOURCES, "pps-gen"); + if (err < 0) { + pr_err("failed to allocate char device region\n"); + goto remove_class; + } + + return 0; + +remove_class: + class_destroy(pps_gen_class); + return err; +} + +subsys_initcall(pps_gen_init); +module_exit(pps_gen_exit); + +MODULE_AUTHOR("Rodolfo Giometti "); +MODULE_DESCRIPTION("LinuxPPS generators support"); +MODULE_LICENSE("GPL"); diff --git a/drivers/pps/generators/sysfs.c b/drivers/pps/generators/sysfs.c new file mode 100644 index 000000000000..faf8b1c6d202 --- /dev/null +++ b/drivers/pps/generators/sysfs.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * PPS generators sysfs support + * + * Copyright (C) 2024 Rodolfo Giometti + */ + +#include +#include +#include +#include + +/* + * Attribute functions + */ + +static ssize_t system_show(struct device *dev, struct device_attribute *at= tr, + char *buf) +{ + struct pps_gen_device *pps_gen =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", pps_gen->info.use_system_clock); +} +static DEVICE_ATTR_RO(system); + +static ssize_t time_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct pps_gen_device *pps_gen =3D dev_get_drvdata(dev); + struct timespec64 time; + int ret; + + ret =3D pps_gen->info.get_time(pps_gen, &time); + if (ret) + return ret; + + return sysfs_emit(buf, "%llu %09lu\n", time.tv_sec, time.tv_nsec); +} +static DEVICE_ATTR_RO(time); + +static ssize_t enable_store(struct device *dev, struct device_attribute *a= ttr, + const char *buf, size_t count) +{ + struct pps_gen_device *pps_gen =3D dev_get_drvdata(dev); + bool status; + int ret; + + ret =3D kstrtobool(buf, &status); + if (ret) + return ret; + + ret =3D pps_gen->info.enable(pps_gen, status); + if (ret) + return ret; + pps_gen->enabled =3D status; + + return count; +} +static DEVICE_ATTR_WO(enable); + +static struct attribute *pps_gen_attrs[] =3D { + &dev_attr_enable.attr, + &dev_attr_time.attr, + &dev_attr_system.attr, + NULL, +}; + +static const struct attribute_group pps_gen_group =3D { + .attrs =3D pps_gen_attrs, +}; + +const struct attribute_group *pps_gen_groups[] =3D { + &pps_gen_group, + NULL, +}; diff --git a/include/linux/pps_gen_kernel.h b/include/linux/pps_gen_kernel.h new file mode 100644 index 000000000000..022ea0ac4440 --- /dev/null +++ b/include/linux/pps_gen_kernel.h @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * PPS generator API kernel header + * + * Copyright (C) 2024 Rodolfo Giometti + */ + +#ifndef LINUX_PPS_GEN_KERNEL_H +#define LINUX_PPS_GEN_KERNEL_H + +#include +#include +#include + +/* + * Global defines + */ + +#define PPS_GEN_MAX_SOURCES 16 /* should be enough... */ + +struct pps_gen_device; + +/** + * struct pps_gen_source_info - the specific PPS generator info + * @use_system_clock: true, if the system clock is used to generate pulses + * @get_time: query the time stored into the generator clock + * @enable: enable/disable the PPS pulses generation + * + * This is the main generator struct where all needed information must be + * placed before calling the pps_gen_register_source(). + */ +struct pps_gen_source_info { + bool use_system_clock; + + int (*get_time)(struct pps_gen_device *pps_gen, + struct timespec64 *time); + int (*enable)(struct pps_gen_device *pps_gen, bool enable); + +/* private: internal use only */ + struct module *owner; + struct device *parent; /* for device_create */ +}; + +/* The main struct */ +struct pps_gen_device { + struct pps_gen_source_info info; /* PSS generator info */ + bool enabled; /* PSS generator status */ + + unsigned int event; + unsigned int sequence; + + unsigned int last_ev; /* last PPS event id */ + wait_queue_head_t queue; /* PPS event queue */ + + unsigned int id; /* PPS generator unique ID */ + struct cdev cdev; + struct device *dev; + struct fasync_struct *async_queue; /* fasync method */ + spinlock_t lock; +}; + +/* + * Global variables + */ + +extern const struct attribute_group *pps_gen_groups[]; + +/* + * Exported functions + */ + +extern struct pps_gen_device *pps_gen_register_source( + struct pps_gen_source_info *info); +extern void pps_gen_unregister_source(struct pps_gen_device *pps_gen); +extern void pps_gen_event(struct pps_gen_device *pps_gen, + unsigned int event, void *data); + +#endif /* LINUX_PPS_GEN_KERNEL_H */ diff --git a/include/uapi/linux/pps_gen.h b/include/uapi/linux/pps_gen.h new file mode 100644 index 000000000000..60a5d0fcfa68 --- /dev/null +++ b/include/uapi/linux/pps_gen.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* + * PPS generator API header + * + * Copyright (C) 2024 Rodolfo Giometti + */ + +#ifndef _PPS_GEN_H_ +#define _PPS_GEN_H_ + +#include +#include + +/** + * struct pps_gen_event - the PPS generator events + * @event: the event type + * @sequence: the event sequence number + * + * Userspace can get the last PPS generator event by using the + * ioctl(pps_gen, PPS_GEN_FETCHEVENT, ...) syscall. + * The sequence field can be used to save the last event ID, while in the + * event field is stored the last event type. Currently known event is: + * + * PPS_GEN_EVENT_MISSEDPULSE : last pulse was not generated + */ +struct pps_gen_event { + unsigned int event; + unsigned int sequence; +}; + +#define PPS_GEN_EVENT_MISSEDPULSE 1 + +#define PPS_GEN_SETENABLE _IOW('p', 0xb1, unsigned int *) +#define PPS_GEN_USESYSTEMCLOCK _IOR('p', 0xb2, unsigned int *) +#define PPS_GEN_FETCHEVENT _IOR('p', 0xb3, struct pps_gen_event *) + +#endif /* _PPS_GEN_H_ */ --=20 2.34.1 From nobody Sun Nov 24 23:45:18 2024 Received: from smtpcmd0756.aruba.it (smtpcmd0756.aruba.it [62.149.156.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C06361D1735 for ; Fri, 8 Nov 2024 07:38:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.149.156.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051520; cv=none; b=PdWxBmM4jRKEQHDwgkO77q/pnNZm92gZtNHUdueiRb68iZvoTMp2H8q4K0K5Lv8CHduEySFG9FOrKBH2eY8Eva3HWvK6x/x3dELe579BEMi6N+Qa4UC/LKe0u8Dv4YG68wTYGEtm8wQs2no6bsL5mbyaEpHDFQmsnRaGHir0Wqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051520; c=relaxed/simple; bh=pQYFTTHPv/l0SrEO6jpxHSYFgOBdIorOzOvP6SylBrw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ulS06KWra4Y4NGmGjFwmkY7VzGv/0Gmtt6mhDr+m9852VVVzq1bclK30lJIEfW5QV2QZmB3FWyrjciU8DEEvPnvzj1L+WGtv3b8NV7WaXBT1RgXNmWFpKz4LpDea24vMic0BSH3FpSiFS4/S1vEuk6wHrdwPEzeRweK6LAhUGBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com; spf=pass smtp.mailfrom=enneenne.com; dkim=temperror (0-bit key) header.d=aruba.it header.i=@aruba.it header.b=WaffGECr; arc=none smtp.client-ip=62.149.156.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enneenne.com Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=aruba.it header.i=@aruba.it header.b="WaffGECr" Received: from polimar.everex.local ([79.0.204.227]) by Aruba Outgoing Smtp with ESMTPSA id 9JSetHUHi6epj9JSitjpeG; Fri, 08 Nov 2024 08:31:20 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1731051080; bh=pQYFTTHPv/l0SrEO6jpxHSYFgOBdIorOzOvP6SylBrw=; h=From:To:Subject:Date:MIME-Version; b=WaffGECrfFtwt4TIBv+GqP51RJHcYWGCdF7PDARnRRZxEYj2hBosJOTbM9WDh8P1d PsBQB5f3Ck50XBmS3JIy5OxF4BhN7AtzZIxeymLuqzZSFziVkiDk5LKNN/rYNrjYHv XAsBpWwoL9At4hV/h4tnhA7TY98nnIDomCUlRT5PxekL2omiAzMeNiIpaXntrUYncC 9HKANOVMLHn8byfkxcB3UKqlnPBIipohXCRiDe/bLXxmKrMU6j6402tTUGnG2jpk1F WqjzyiIriySkRYdgdSZa7CNSH15T3tukPutxNBurZI2JSUDenf68tayAMrPzOuCW/R SyIcvWLCUW7VQ== From: Rodolfo Giometti To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Greg KH , corbet@lwn.net, Hall Christopher S , Mohan Subramanian , tglx@linutronix.de, Andy Shevchenko , Dong Eddie , N Pandith , T R Thejesh Reddy , Zage David , Chinnadurai Srinivasan , Randy Dunlap , Bagas Sanjaya , Rodolfo Giometti Subject: [V3 2/4] drivers pps/generators: add dummy PPS generator Date: Fri, 8 Nov 2024 08:31:13 +0100 Message-Id: <20241108073115.759039-3-giometti@enneenne.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241108073115.759039-1-giometti@enneenne.com> References: <20241108073115.759039-1-giometti@enneenne.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CMAE-Envelope: MS4xfByL/ulLdeMvtM5pRvsMn3uqQHLcEzSgHMHHx1ZPNoq3K1tx8qXTnz7zlvmaug499Umh7L+GGGTThclnIlsQpTGPAsNa6UpVcNKglabfe4ZN0rrvelRS FzdzP1a3dVjnjHE9OK+h8skrDWSgfXcWnZ0+L6W93YQxjd/U7+Dfa1rSw/nVMH3a40d0ggZ6NQmUx8V+N1MLnbu3RAnC5vqGeV2zTaW3KF11MQyJMa9tS+MD JAMNmyKE8ozZQir2yaZX/RIUVV6gX87jK+rfEyIyoWdnU+OJVBki2kUdXS/eBSZaMhldbrMCpMrpFQczF82G/bddamuWOtoTDnf5MEKdG8TmbBqyJ4I/WEs9 A/sq5zUqsrm5z/69yJBZXnnopJL6ItshSzDj9Ru4CT3kBj3rKvSjDaPmk36GGNqcf2ZjInB/Q9B9ndYRroZydtDHARCP4OT4d/SdGMkXJBxkkweePMoNOKJR ID9K14Bl55fOpXydhMp0mLvqEEgSXUp+2dF+1HDdlGthg7/7gAppExL6y2mFg6p6eo2e9NsEk2Kp6kxKuIfNqqTB7twt8y1yqRVRsETy+/OCTvOYtB50iCs0 QjgOrtCPpXqmDuYWa434ib4ZAiOvlxY7umQBn2OkJDw9TYE77IXsTYnHFa6pG7D9JuqL9U7c/l+Z8TlR2cgFcRCAsSBjb5jf+08kncvT4Zva2giQV10MCTu4 rniCDRebhQF354X1bscNHb78ZbexATptWl2ljhYrJx5D+pOSy/mSjPN6AxbRMgDETnnBtU73aB0= Content-Type: text/plain; charset="utf-8" This dummy PPS generator can be used for debugging and documentation purposes. Signed-off-by: Rodolfo Giometti --- drivers/pps/generators/Kconfig | 9 +++ drivers/pps/generators/Makefile | 1 + drivers/pps/generators/pps_gen-dummy.c | 96 ++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 drivers/pps/generators/pps_gen-dummy.c diff --git a/drivers/pps/generators/Kconfig b/drivers/pps/generators/Kconfig index b34e483eff21..cd94bf3bfaf2 100644 --- a/drivers/pps/generators/Kconfig +++ b/drivers/pps/generators/Kconfig @@ -14,6 +14,15 @@ menuconfig PPS_GENERATOR =20 if PPS_GENERATOR =20 +config PPS_GENERATOR_DUMMY + tristate "Dummy PPS generator (Testing generator, use for debug)" + help + If you say yes here you get support for a PPS debugging generator + (which generates no PPS signal at all). + + This driver can also be built as a module. If so, the module + will be called pps_gen-dummy. + config PPS_GENERATOR_PARPORT tristate "Parallel port PPS signal generator" depends on PARPORT && BROKEN diff --git a/drivers/pps/generators/Makefile b/drivers/pps/generators/Makef= ile index 034a78edfa26..dc1aa5a4688b 100644 --- a/drivers/pps/generators/Makefile +++ b/drivers/pps/generators/Makefile @@ -6,6 +6,7 @@ pps_gen_core-y :=3D pps_gen.o sysfs.o obj-$(CONFIG_PPS_GENERATOR) :=3D pps_gen_core.o =20 +obj-$(CONFIG_PPS_GENERATOR_DUMMY) +=3D pps_gen-dummy.o obj-$(CONFIG_PPS_GENERATOR_PARPORT) +=3D pps_gen_parport.o =20 ccflags-$(CONFIG_PPS_DEBUG) :=3D -DDEBUG diff --git a/drivers/pps/generators/pps_gen-dummy.c b/drivers/pps/generator= s/pps_gen-dummy.c new file mode 100644 index 000000000000..b284c200cbe5 --- /dev/null +++ b/drivers/pps/generators/pps_gen-dummy.c @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * PPS dummy generator + * + * Copyright (C) 2024 Rodolfo Giometti + */ + +#include +#include +#include +#include +#include +#include +#include + +static struct pps_gen_device *pps_gen; +static struct timer_list ktimer; + +static unsigned int get_random_delay(void) +{ + unsigned int delay =3D get_random_u8() & 0x0f; + + return (delay + 1) * HZ; +} + +/* + * The kernel timer + */ + +static void pps_gen_ktimer_event(struct timer_list *unused) +{ + pps_gen_event(pps_gen, PPS_GEN_EVENT_MISSEDPULSE, NULL); +} + +/* + * PPS Generator methods + */ + +static int pps_gen_dummy_get_time(struct pps_gen_device *pps_gen, + struct timespec64 *time) +{ + struct system_time_snapshot snap; + + ktime_get_snapshot(&snap); + *time =3D ktime_to_timespec64(snap.real); + + return 0; +} + +static int pps_gen_dummy_enable(struct pps_gen_device *pps_gen, bool enabl= e) +{ + if (enable) + mod_timer(&ktimer, jiffies + get_random_delay()); + else + del_timer_sync(&ktimer); + + return 0; +} + +/* + * The PPS info struct + */ + +static struct pps_gen_source_info pps_gen_dummy_info =3D { + .use_system_clock =3D true, + .get_time =3D pps_gen_dummy_get_time, + .enable =3D pps_gen_dummy_enable, +}; + +/* + * Module staff + */ + +static void __exit pps_gen_dummy_exit(void) +{ + del_timer_sync(&ktimer); + pps_gen_unregister_source(pps_gen); +} + +static int __init pps_gen_dummy_init(void) +{ + pps_gen =3D pps_gen_register_source(&pps_gen_dummy_info); + if (IS_ERR(pps_gen)) + return PTR_ERR(pps_gen); + + timer_setup(&ktimer, pps_gen_ktimer_event, 0); + + return 0; +} + +module_init(pps_gen_dummy_init); +module_exit(pps_gen_dummy_exit); + +MODULE_AUTHOR("Rodolfo Giometti "); +MODULE_DESCRIPTION("LinuxPPS dummy generator"); +MODULE_LICENSE("GPL"); --=20 2.34.1 From nobody Sun Nov 24 23:45:18 2024 Received: from smtpcmd0756.aruba.it (smtpcmd0756.aruba.it [62.149.156.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAB871D12E9 for ; Fri, 8 Nov 2024 07:38:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.149.156.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051520; cv=none; b=LvMiNlWZTpqxwq4f6Vp9GeYao1ahYj5rrEAV1w9I2+aU1+H0wda3Ij8vTWPPjUV1k3tim2lqokeq7fgTymJSXf5nUczkA9ioyKmJeabJ86sl57nLCRe46M3AG77L2b9URJCGWTFWWkPEy27/vx2tr4wWtCD688WpKLZkpG3zwWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051520; c=relaxed/simple; bh=L9tCvOiQSlxC+XUZd0dK9si0gZo88vvaD5/hqTT0opY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mgWcwbc+ecZzw/Hjdcbj0cIRoEw3A6bbXiK8uu+ljCMocPiDPkvhURaQIDOScz7ApRmv3Iq2dZC9Pl4B4ZGeOsjt/vUEKpzQZNjdXj3D1QFfL6uCVFAqY2od2YfdmBerVYRFqrOuadBB59GwG3lXRhL0+5WK45H5E0Rfa0A9+Es= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com; spf=pass smtp.mailfrom=enneenne.com; dkim=temperror (0-bit key) header.d=aruba.it header.i=@aruba.it header.b=l+5hL0Mr; arc=none smtp.client-ip=62.149.156.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enneenne.com Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=aruba.it header.i=@aruba.it header.b="l+5hL0Mr" Received: from polimar.everex.local ([79.0.204.227]) by Aruba Outgoing Smtp with ESMTPSA id 9JSetHUHi6epj9JSitjpei; Fri, 08 Nov 2024 08:31:21 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1731051081; bh=L9tCvOiQSlxC+XUZd0dK9si0gZo88vvaD5/hqTT0opY=; h=From:To:Subject:Date:MIME-Version; b=l+5hL0Mrw0lf3lHegqhO9bBd5DVfpN/CNfHCZLcPO/3kKd5SrXh1C/uW7VFlNQkjj iQuo8kYVL4KiLWPolnvRUyCBpSXWa8ywYMHolqq/USDiQE65bd+Z3P5HOlxFz8U66S upYUdU9K1zpDtcTn/SQAg7crxaCGapW8f+e08hbC6LaDB+B0WpMHJVApreCRfrhBr2 Xcdfbn91k5vwb0LJZ2cvEpk87RDCXc2wVFj4nGAkbAtI6e2ophwXV12ZmSMCckbCW5 OyAcRVvRdNpKa7I9eOAbRM9AuO1L0bE4g7gRIlsSuidnEcslPWbk9YNO72txDaglE6 d1IBRsE572UTA== From: Rodolfo Giometti To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Greg KH , corbet@lwn.net, Hall Christopher S , Mohan Subramanian , tglx@linutronix.de, Andy Shevchenko , Dong Eddie , N Pandith , T R Thejesh Reddy , Zage David , Chinnadurai Srinivasan , Randy Dunlap , Bagas Sanjaya , Rodolfo Giometti Subject: [V3 3/4] Documentation pps.rst: add PPS generators documentation Date: Fri, 8 Nov 2024 08:31:14 +0100 Message-Id: <20241108073115.759039-4-giometti@enneenne.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241108073115.759039-1-giometti@enneenne.com> References: <20241108073115.759039-1-giometti@enneenne.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CMAE-Envelope: MS4xfFrLF5IO2JyylQ0Fj+GPE4d0lB8LXZ8yMFYX5v2O27ifTUnAf2mwRuveBqQ5W1NYmjC+qYuBtlL53IHzwpx/8F1hpiyZX3mw5cjRUW7PMW2pv+OVTVBv HcYorQoyVJfJrAaDs2O9ZJFmyefILZE/HbVWQGQjWXFkzT/1nsgGNoUqAvy5BlIr+VWDzKqvMqbg+wAHVFTNZ7s0SfHP6s/8Sg7TGHtZdwc0Z26I75oHH4kQ dRWLI90v00oPy9h5UW/Ddd6TMbCqQBBSO5g0n7sW1NriiyWvTGYEbCqkTOEl+AtrBcwoyF0Gv4F5+y7htsjHazFJk+U/WREX9EIh87mMLHEQy1MGxcM9N2Qv 3T6yXP5TQ1StoJLtKKFSdDCkcnoJEvYEBJ8rSA/QjAPN92Zner6hvgJT2I4zOzNgkoMm8/IMpaFQ7dyJ9+qQKaizhXZ3p0HykR0Qc+w/VEiYM4OEfgvTx0lA 6ipZEwUF79DSapY9Aelt+abnNfQr+AxWH6hL7BrDRRXi8oNsopCZtIU7Y7yt96nISk7G0qy6CZPy93HOeidDiFdrwEH8Jx0FiYQhpz1gMQ/D/nx6WzYQIaiP BGTNzkmXLB3J9krSppNuTeCyqc0OHaZk9XyjWHZHSg/HfE/bnbb8mde8n9MIlqrIeyiP+iOdoD7jLToH7XvvV8F9nxfrJmKvBwoLCStcMoD4K/ptBDljPdZP XQNKUgYkM/qnRSCNZO3yTHr1+nV4DJZnGzB5u2CrOFBvn6MbEL5Y0bUkNGIGG7lp467DKF9qq5Y= Content-Type: text/plain; charset="utf-8" This patch adds some examples about how to register a new PPS generator in the system, and how to manage it. Signed-off-by: Rodolfo Giometti Reviewed-by: Bagas Sanjaya --- Documentation/driver-api/pps.rst | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Documentation/driver-api/pps.rst b/Documentation/driver-api/pp= s.rst index 78dded03e5d8..71ad04c82d6c 100644 --- a/Documentation/driver-api/pps.rst +++ b/Documentation/driver-api/pps.rst @@ -202,6 +202,46 @@ Sometimes one needs to be able not only to catch PPS s= ignals but to produce them also. For example, running a distributed simulation, which requires computers' clock to be synchronized very tightly. =20 +To do so the class pps-gen has been added. PPS generators can be +registered in the kernel by defining a struct pps_gen_source_info as +follows:: + + static struct pps_gen_source_info pps_gen_dummy_info =3D { + .name =3D "dummy", + .use_system_clock =3D true, + .get_time =3D pps_gen_dummy_get_time, + .enable =3D pps_gen_dummy_enable, + }; + +Where the use_system_clock states if the generator uses the system +clock to generate its pulses, or they are from a peripheral device +clock. Method get_time() is used to query the time stored into the +generator clock, while the method enable() is used to enable or +disable the PPS pulse generation. + +Then calling the function pps_gen_register_source() in your +initialization routine as follows creates a new generator in the +system:: + + pps_gen =3D pps_gen_register_source(&pps_gen_dummy_info); + +Generators SYSFS support +------------------------ + +If the SYSFS filesystem is enabled in the kernel it provides a new class:: + + $ ls /sys/class/pps-gen/ + pps-gen0/ pps-gen1/ pps-gen2/ + +Every directory is the ID of a PPS generator defined in the system and +inside of it you find several files:: + + $ ls -F /sys/class/pps-gen/pps-gen0/ + dev enable name power/ subsystem@ system time uevent + +To enable the PPS signal generation you can use the command below:: + + $ echo 1 > /sys/class/pps-gen/pps-gen0/enable =20 Parallel port generator ------------------------ --=20 2.34.1 From nobody Sun Nov 24 23:45:18 2024 Received: from smtpcmd0756.aruba.it (smtpcmd0756.aruba.it [62.149.156.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDF6B1D173D for ; Fri, 8 Nov 2024 07:38:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.149.156.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051520; cv=none; b=uHoSmCkNeU9zmLcM5U1jSaE+60kUR3ZFxQPG0Pb1rslsB0DUYaqdsd+oxI/K4jZH1junyGIDtN7oV0ako4px5oTpGL+TpNyKG/8yULGrScuVWqxYiRO/1v0ZdMmgurAQOok6RlNc9QIxN+BqlyZbduKT/YrL5mzwWIQtSDask6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731051520; c=relaxed/simple; bh=clU5E4Cj40RGlQga2eSAucvDuowSdrOWRq2hMukgfLw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=avj4Saku4xeCvywLcnHKM7Y0KkIjKJA4Td7Vui4dgVmCgrY8hDUbbSHUzjPJ0xSaTHpRlpANTbO8IPHChrSxkedb11BSAYYyioBaoOzkXNU5bNSsd3R6zRJ3gMnamNsi58yMt8Q/+/4WaHXYdHog/DZVvZGGS8P72WzJeCOl7us= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com; spf=pass smtp.mailfrom=enneenne.com; dkim=temperror (0-bit key) header.d=aruba.it header.i=@aruba.it header.b=UHn7PUe4; arc=none smtp.client-ip=62.149.156.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=enneenne.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=enneenne.com Authentication-Results: smtp.subspace.kernel.org; dkim=temperror (0-bit key) header.d=aruba.it header.i=@aruba.it header.b="UHn7PUe4" Received: from polimar.everex.local ([79.0.204.227]) by Aruba Outgoing Smtp with ESMTPSA id 9JSetHUHi6epj9JSjtjpf3; Fri, 08 Nov 2024 08:31:21 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1731051081; bh=clU5E4Cj40RGlQga2eSAucvDuowSdrOWRq2hMukgfLw=; h=From:To:Subject:Date:MIME-Version; b=UHn7PUe4By/gWDGfPSs8kGOX5/clDhkogoyB0Bi2L9C8fzpERg0v/34kJnnjIkq9C wTYDDmwQa3jAdhXAnHMJKBCJoxC/EzYjCezX2gA0ArytZgh6VUF19icRGyfMpp4j7/ SwEyCZFmGfxxKm2wYRh1CCBUPqu4h1wjVa0ilQ/V1SHNJuk7YDvBzppAgWtvGM4vHX oh6mqX0yZJG+acZ9Ir2X8SpaUCnU2H1Eet6PcVJE5b3+b5iHXVO/O3WD31uCAkJG67 NyuG+qZl9T+8PtWC/PuY4XWh1JpMCPZ0aOxPo6R71LkhewDw7AVXiPTPGo58zv52fQ hbFDDzX6348+g== From: Rodolfo Giometti To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Greg KH , corbet@lwn.net, Hall Christopher S , Mohan Subramanian , tglx@linutronix.de, Andy Shevchenko , Dong Eddie , N Pandith , T R Thejesh Reddy , Zage David , Chinnadurai Srinivasan , Randy Dunlap , Bagas Sanjaya , Rodolfo Giometti Subject: [V3 4/4] Documentation ABI: add PPS generators documentation Date: Fri, 8 Nov 2024 08:31:15 +0100 Message-Id: <20241108073115.759039-5-giometti@enneenne.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241108073115.759039-1-giometti@enneenne.com> References: <20241108073115.759039-1-giometti@enneenne.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CMAE-Envelope: MS4xfFrLF5IO2JyylQ0Fj+GPE4d0lB8LXZ8yMFYX5v2O27ifTUnAf2mwRuveBqQ5W1NYmjC+qYuBtlL53IHzwpx/8F1hpiyZX3mw5cjRUW7PMW2pv+OVTVBv HcYorQoyVJfJrAaDs2O9ZJFmyefILZE/HbVWQGQjWXFkzT/1nsgGNoUqAvy5BlIr+VWDzKqvMqbg+wAHVFTNZ7s0SfHP6s/8Sg7TGHtZdwc0Z26I75oHH4kQ dRWLI90v00oPy9h5UW/Ddd6TMbCqQBBSO5g0n7sW1NriiyWvTGYEbCqkTOEl+AtrBcwoyF0Gv4F5+y7htsjHazFJk+U/WREX9EIh87mMLHEQy1MGxcM9N2Qv 3T6yXP5TQ1StoJLtKKFSdDCkcnoJEvYEBJ8rSA/QjAPN92Zner6hvgJT2I4zOzNgkoMm8/IMpaFQ7dyJ9+qQKaizhXZ3p0HykR0Qc+w/VEiYM4OEfgvTx0lA 6ipZEwUF79DSapY9Aelt+abnNfQr+AxWH6hL7BrDRRXi8oNsopCZtIU7Y7yt96nISk7G0qy6CZPy93HOeidDiFdrwEH8Jx0FiYQhpz1gMQ/D/nx6WzYQIaiP BGTNzkmXLB3J9krSppNuTeCyqc0OHaZk9XyjWHZHSg/HfE/bnbb8mde8n9MIlqrIeyiP+iOdoD7jLToH7XvvV8F9nxfrJmKvBwoLCStcMoD4K/ptBDljPdZP XQNKUgYkM/qnRSCNZO3yTHr1+nV4DJZnGzB5u2CrOFBvn6MbEL5Y0bUkNGIGG7lp467DKF9qq5Y= Content-Type: text/plain; charset="utf-8" This patch adds the documentation for the ABI between the Linux kernel and userspace regarding the PPS generators. Signed-off-by: Rodolfo Giometti --- Documentation/ABI/testing/sysfs-pps-gen | 43 +++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 44 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-pps-gen diff --git a/Documentation/ABI/testing/sysfs-pps-gen b/Documentation/ABI/te= sting/sysfs-pps-gen new file mode 100644 index 000000000000..2519207b88fd --- /dev/null +++ b/Documentation/ABI/testing/sysfs-pps-gen @@ -0,0 +1,43 @@ +What: /sys/class/pps-gen/ +Date: February 2025 +KernelVersion: 6.13 +Contact: Rodolfo Giometti +Description: + The /sys/class/pps-gen/ directory contains files and + directories that provide a unified interface to the PPS + generators. + +What: /sys/class/pps-gen/pps-genX/ +Date: February 2025 +KernelVersion: 6.13 +Contact: Rodolfo Giometti +Description: + The /sys/class/pps-gen/pps-genX/ directory is related to X-th + PPS generator in the system. Each directory contain files to + manage and control its PPS generator. + +What: /sys/class/pps-gen/pps-genX/enable +Date: February 2025 +KernelVersion: 6.13 +Contact: Rodolfo Giometti +Description: + This write-only file enables or disables generation of the + PPS signal. + +What: /sys/class/pps-gen/pps-genX/system +Date: February 2025 +KernelVersion: 6.13 +Contact: Rodolfo Giometti +Description: + This read-only file returns "1" if the generator takes the + timing from the system clock, while it returns "0" if not + (i.e. from a peripheral device clock). + +What: /sys/class/pps-gen/pps-genX/time +Date: February 2025 +KernelVersion: 6.13 +Contact: Rodolfo Giometti +Description: + This read-only file contains the current time stored into the + generator clock as two integers representing the current time + seconds and nanoseconds. diff --git a/MAINTAINERS b/MAINTAINERS index d65e54e385b8..236eba6a429e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18483,6 +18483,7 @@ L: linuxpps@ml.enneenne.com (subscribers-only) S: Maintained W: http://wiki.enneenne.com/index.php/LinuxPPS_support F: Documentation/ABI/testing/sysfs-pps +F: Documentation/ABI/testing/sysfs-pps-gen F: Documentation/devicetree/bindings/pps/pps-gpio.yaml F: Documentation/driver-api/pps.rst F: drivers/pps/ --=20 2.34.1