LinuxPPS (pre)patch
Subsystems (5)
Rodolfo Giometti
maintainerHello,
here my last patch of LinuxPPS.
Main differences from old versions is that now (finally) each PPS source is a dedicated char device!
This thanks to an agreement with NTP people who suggested to me how to interpret RFC 2783 in such a way even a dedicated char device is now RFC complain.
Please, take a look at the code and report all suggestions and/or needed modifications for kernel inclusion so I can provide a final patch.
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems [email protected] UNIX programming phone: +39 349 2432127
Rodolfo Giometti
maintainerOops: [RFC] LinuxPPS (pre)patch
Quoted 3 lines · Rodolfo Giometti
Hello,
here my last patch of LinuxPPS.
Sorry... attached. :)
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems [email protected] UNIX programming phone: +39 349 2432127
Documentation/pps/Makefile new file +27 -0
@@ -0,0 +1,27 @@ +TARGETS = ppstest ppsctl + +CFLAGS += -Wall -O2 -D_GNU_SOURCE +CFLAGS += -I . +CFLAGS += -ggdb + +# -- Actions section ---------------------------------------------------------- + +.PHONY : all depend dep + +all : .depend $(TARGETS) + +.depend depend dep : + $(CC) $(CFLAGS) -M $(TARGETS:=.c) > .depend + +ifeq (.depend,$(wildcard .depend)) +include .depend +endif + + +# -- Clean section ------------------------------------------------------------ + +.PHONY : clean + +clean : + rm -f *.o *~ core .depend + rm -f ${TARGETS}
Documentation/pps/pps.txt new file +170 -0
170 lines not on this page · raw message
Documentation/pps/ppsctl.c new file +62 -0
62 lines not on this page · raw message
Documentation/pps/ppsfind new file +17 -0
@@ -0,0 +1,17 @@ +#!/bin/sh + +SYS="/sys/class/pps/" + +if [ $# -lt 1 ] ; then + echo "usage: ppsfind <name>" >&2 + exit 1 +fi + +for d in $(ls $SYS) ; do + if grep $1 $SYS/$d/name >& /dev/null || \ + grep $1 $SYS/$d/path >& /dev/null ; then + echo "$d: name=$(cat $SYS/$d/name) path=$(cat $SYS/$d/path)" + fi +done + +exit 0
Documentation/pps/ppstest.c new file +151 -0
151 lines not on this page · raw message
Documentation/pps/timepps.h new file +193 -0
193 lines not on this page · raw message
MAINTAINERS +7 -0
@@ -3011,6 +3011,13 @@ P: James Chapman M: [email protected] S: Maintained +PPS SUPPORT +P: Rodolfo Giometti +M: [email protected] +W: http://wiki.enneenne.com/index.php/LinuxPPS_support +L: [email protected] +S: Maintained + PREEMPTIBLE KERNEL P: Robert Love M: [email protected]
drivers/Kconfig +2 -0
@@ -52,6 +52,8 @@ source "drivers/i2c/Kconfig" source "drivers/spi/Kconfig" +source "drivers/pps/Kconfig" + source "drivers/w1/Kconfig" source "drivers/power/Kconfig"
drivers/Makefile +1 -0
@@ -63,6 +63,7 @@ obj-$(CONFIG_INPUT) += input/ obj-$(CONFIG_I2O) += message/ obj-$(CONFIG_RTC_LIB) += rtc/ obj-y += i2c/ +obj-$(CONFIG_PPS) += pps/ obj-$(CONFIG_W1) += w1/ obj-$(CONFIG_POWER_SUPPLY) += power/ obj-$(CONFIG_HWMON) += hwmon/
drivers/char/lp.c +61 -0
79 lines not on this page · raw message
drivers/pps/Kconfig new file +34 -0
@@ -0,0 +1,34 @@ +# +# PPS support configuration +# + +menu "PPS support" + +config PPS + tristate "PPS support" + depends on EXPERIMENTAL + ---help--- + PPS (Pulse Per Second) is a special pulse provided by some GPS + antennae. Userland can use it to get an high time reference. + + Some antennae's PPS signals are connected with the CD (Carrier + Detect) pin of the serial line they use to communicate with the + host. In this case use the SERIAL_LINE client support. + + Some antennae's PPS signals are connected with some special host + inputs so you have to enable the corresponding client support. + + To compile this driver as a module, choose M here: the module + will be called pps_core.ko. + +config PPS_DEBUG + bool "PPS debugging messages" + depends on PPS + help + Say Y here if you want the PPS support to produce a bunch of debug + messages to the system log. Select this if you are having a + problem with PPS support and want to see more of what is going on. + +source drivers/pps/clients/Kconfig + +endmenu
drivers/pps/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# +# Makefile for the PPS core. +# + +pps_core-objs += pps.o kapi.o sysfs.o +obj-$(CONFIG_PPS) += pps_core.o +obj-y += clients/ + +ifeq ($(CONFIG_PPS_DEBUG),y) +EXTRA_CFLAGS += -DDEBUG +endif
drivers/pps/clients/Kconfig new file +38 -0
@@ -0,0 +1,38 @@ +# +# PPS clients configuration +# + +if PPS + +comment "PPS clients support" + +config PPS_CLIENT_KTIMER + tristate "Kernel timer client (Testing client, use for debug)" + help + If you say yes here you get support for a PPS debugging client + which uses a kernel timer to generate the PPS signal. + + This driver can also be built as a module. If so, the module + will be called ktimer.ko. + +comment "UART serial support (forced off)" + depends on ! (SERIAL_CORE != n && !(PPS = m && SERIAL_CORE = y)) + +config PPS_CLIENT_UART + bool "UART serial support" + depends on SERIAL_CORE != n && !(PPS = m && SERIAL_CORE = y) + help + If you say yes here you get support for a PPS source connected + with the CD (Carrier Detect) pin of your serial port. + +comment "Parallel printer support (forced off)" + depends on !( PRINTER != n && !(PPS = m && PRINTER = y)) + +config PPS_CLIENT_LP + bool "Parallel printer support" + depends on PRINTER != n && !(PPS = m && PRINTER = y) + help + If you say yes here you get support for a PPS source connected + with the interrupt pin of your parallel port. + +endif
drivers/pps/clients/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# +# Makefile for PPS clients. +# + +obj-$(CONFIG_PPS_CLIENT_KTIMER) += ktimer.o + +ifeq ($(CONFIG_PPS_DEBUG),y) +EXTRA_CFLAGS += -DDEBUG +endif
drivers/pps/clients/ktimer.c new file +114 -0
114 lines not on this page · raw message
drivers/pps/kapi.c new file +271 -0
271 lines not on this page · raw message
drivers/pps/pps.c new file +332 -0
332 lines not on this page · raw message
drivers/pps/sysfs.c new file +124 -0
124 lines not on this page · raw message
drivers/serial/8250.c +2 -0
@@ -2118,6 +2118,8 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios, up->ier |=UART_IER_MSI ;if (up->capabilities &UART_CAP_UUE ) up->ier |=UART_IER_UUE |UART_IER_RTOIE ; +if (up->port.flags &UPF_HARDPPS_CD ) + up->ier |=UART_IER_MSI ;/* enable interrupts */ serial_out (up,UART_IER , up->ier);
drivers/serial/serial_core.c +70 -1
105 lines not on this page · raw message
include/linux/Kbuild +1 -0
@@ -295,6 +295,7 @@ unifdef-y += pmu.h unifdef-y += poll.h unifdef-y += ppp_defs.h unifdef-y += ppp-comp.h +unifdef-y += pps.h unifdef-y += ptrace.h unifdef-y += qnx4_fs.h unifdef-y += quota.h
include/linux/parport.h +12 -0
@@ -100,6 +100,7 @@ typedef enum {#include <linux/proc_fs.h> #include <linux/spinlock.h> #include <linux/wait.h> +#include <linux/pps.h> #include <asm/system.h> #include <asm/ptrace.h> #include <asm/semaphore.h>
@@ -327,6 +328,11 @@ struct parport {struct list_head full_list;struct parport *slaves[3 ]; + +#ifdef CONFIG_PPS_CLIENT_LP +struct pps_source_info pps_info; +int pps_source;/* PPS source ID */ +#endif };#define DEFAULT_SPIN_TIME 500/* us */
@@ -517,6 +523,12 @@ extern int parport_daisy_select (struct parport *port, int daisy, int mode);/* Lowlevel drivers _can_ call this support function to handle irqs. */ static __inline__void parport_generic_irq (int irq,struct parport *port) { +#ifdef CONFIG_PPS_CLIENT_LP +pps_event (port->pps_source,PPS_CAPTUREASSERT , port); +dev_dbg (port->dev,"PPS assert at %lu on source #%d\n" , + jiffies, port->pps_source); +#endif +parport_ieee1284_interrupt (irq, port);read_lock (&port->cad_lock);if (port->cad && port->cad->irq_func)
include/linux/pps.h new file +196 -0
196 lines not on this page · raw message
include/linux/serial_core.h +24 -6
@@ -157,6 +157,7 @@#include <linux/tty.h> #include <linux/mutex.h> #include <linux/sysrq.h> +#include <linux/pps.h> struct uart_port ;struct uart_info ;
@@ -236,6 +237,9 @@ struct uart_port {unsigned char regshift;/* reg offset shift */ unsigned char iotype;/* io access style */ unsigned char unused1; +#ifdef CONFIG_PPS_CLIENT_UART +int pps_source;/* PPS source ID */ +#endif #define UPIO_PORT (0)#define UPIO_HUB6 (1)
@@ -280,7 +284,8 @@ struct uart_port {#define UPF_IOREMAP ((__force upf_t) (1 << 31))#define UPF_CHANGE_MASK ((__force upf_t) (0x17fff)) -#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY)) +#define UPF_USR_MASK ((__force upf_t) (UPF_SPD_MASK|UPF_LOW_LATENCY\ + |UPF_HARDPPS_CD))unsigned int mctrl;/* current modem ctrl settings */ unsigned int timeout;/* character-based timeout */
@@ -312,6 +317,10 @@ struct uart_state {struct uart_info *info;struct uart_port *port; +#ifdef CONFIG_PPS_CLIENT_UART +struct pps_source_info pps_info; +#endif +struct mutex mutex; };
@@ -476,13 +485,22 @@ uart_handle_dcd_change(struct uart_port *port, unsigned int status) {struct uart_info *info = port->info; - port->icount.dcd++; - -#ifdef CONFIG_HARD_PPS -if ((port->flags &UPF_HARDPPS_CD ) && status) -hardpps (); +#ifdef CONFIG_PPS_CLIENT_UART +if (port->flags &UPF_HARDPPS_CD ) { +if (status) { +pps_event (port->pps_source,PPS_CAPTUREASSERT , port); +dev_dbg (port->dev,"PPS assert at %lu on source #%d\n" , + jiffies, port->pps_source); + }else { +pps_event (port->pps_source,PPS_CAPTURECLEAR , port); +dev_dbg (port->dev,"PPS clear at %lu on source #%d\n" , + jiffies, port->pps_source); + } + }#endif + port->icount.dcd++; +if (info->flags &UIF_CHECK_CD ) {if (status)wake_up_interruptible (&info->open_wait);
Re: Oops: [RFC] LinuxPPS (pre)patch
Quoted 17 lines · Rodolfo Giometti
include/linux/pps.h new file +17
-0+/* The main struct */ +struct pps_device { +struct pps_source_info info;/* PSS source info */ + +struct pps_kparams params;/* PPS's current params */ + +__u32 assert_sequence;/* PPS' assert event seq # */ +__u32 clear_sequence;/* PPS' clear event seq # */ +struct pps_ktime assert_tu; +struct pps_ktime clear_tu; +int current_mode;/* PPS mode at event time */ + +int go;/* PPS event is arrived? */ +wait_queue_head_t queue;/* PPS event queue */ + +unsigned int id;/* PPS source unique ID */ +struct cdev cdev;
include/linux/pps.h line 178
Quoted 10 lines
include/linux/pps.h new file +10
-0+struct device *dev; +int devno; +struct fasync_struct *async_queue;/* fasync method */ +spinlock_t lock; + +atomic_t usage;/* usage count */ +wait_queue_head_t usage_queue; + +struct class_device class_dev; +};
Please use a 'struct class' instead of a 'struct class_device'. We have almost rid the kernel of all usages of 'struct class_device' and want to remove that structure entirely soon. I'm aiming for 2.6.25 and it's looking good.
So please don't add new instances of it, you can do all the same things with a 'struct device' and it should be a very trivial change.
thanks,
greg k-h
Rodolfo Giometti
maintainerRe: Oops: [RFC] LinuxPPS (pre)patch
Quoted 2 lines · Greg KH
Please use a 'struct class' instead of a 'struct
class_device'. We have
Ok, fixed. I'll repost my patch ASAP.
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems [email protected] UNIX programming phone: +39 349 2432127