Author: hselasky Date: Sat Mar 7 18:25:58 2015 New Revision: 279729 URL: https://svnweb.freebsd.org/changeset/base/279729
Log: Add PPS support to USB serial drivers. Bump kernel version to reflect structure change. PR: 196897 MFC after: 1 week Modified: head/sys/dev/usb/serial/usb_serial.c head/sys/dev/usb/serial/usb_serial.h head/sys/sys/param.h Modified: head/sys/dev/usb/serial/usb_serial.c ============================================================================== --- head/sys/dev/usb/serial/usb_serial.c Sat Mar 7 18:23:32 2015 (r279728) +++ head/sys/dev/usb/serial/usb_serial.c Sat Mar 7 18:25:58 2015 (r279729) @@ -96,6 +96,11 @@ __FBSDID("$FreeBSD$"); static SYSCTL_NODE(_hw_usb, OID_AUTO, ucom, CTLFLAG_RW, 0, "USB ucom"); +static int ucom_pps_mode; + +SYSCTL_INT(_hw_usb_ucom, OID_AUTO, pps_mode, CTLFLAG_RWTUN, + &ucom_pps_mode, 0, "pulse capturing mode - 0/1/2 - disabled/CTS/DCD"); + #ifdef USB_DEBUG static int ucom_debug = 0; @@ -409,6 +414,10 @@ ucom_attach_tty(struct ucom_super_softc sc->sc_tty = tp; + sc->sc_pps.ppscap = PPS_CAPTUREBOTH; + sc->sc_pps.mtx = sc->sc_mtx; + pps_init(&sc->sc_pps); + DPRINTF("ttycreate: %s\n", buf); /* Check if this device should be a console */ @@ -858,6 +867,8 @@ ucom_ioctl(struct tty *tp, u_long cmd, c } else { error = ENOIOCTL; } + if (error == ENOIOCTL) + error = pps_ioctl(cmd, data, &sc->sc_pps); break; } return (error); @@ -1061,7 +1072,7 @@ ucom_cfg_status_change(struct usb_proc_m struct tty *tp; uint8_t new_msr; uint8_t new_lsr; - uint8_t onoff; + uint8_t msr_delta; uint8_t lsr_delta; tp = sc->sc_tty; @@ -1085,15 +1096,37 @@ ucom_cfg_status_change(struct usb_proc_m /* TTY device closed */ return; } - onoff = ((sc->sc_msr ^ new_msr) & SER_DCD); + msr_delta = (sc->sc_msr ^ new_msr); lsr_delta = (sc->sc_lsr ^ new_lsr); sc->sc_msr = new_msr; sc->sc_lsr = new_lsr; - if (onoff) { + /* time pulse counting support */ + switch(ucom_pps_mode) { + case 1: + if ((sc->sc_pps.ppscap & PPS_CAPTUREBOTH) && + (msr_delta & SER_CTS)) { + pps_capture(&sc->sc_pps); + pps_event(&sc->sc_pps, (sc->sc_msr & SER_CTS) ? + PPS_CAPTUREASSERT : PPS_CAPTURECLEAR); + } + break; + case 2: + if ((sc->sc_pps.ppscap & PPS_CAPTUREBOTH) && + (msr_delta & SER_DCD)) { + pps_capture(&sc->sc_pps); + pps_event(&sc->sc_pps, (sc->sc_msr & SER_DCD) ? + PPS_CAPTUREASSERT : PPS_CAPTURECLEAR); + } + break; + default: + break; + } + + if (msr_delta & SER_DCD) { - onoff = (sc->sc_msr & SER_DCD) ? 1 : 0; + int onoff = (sc->sc_msr & SER_DCD) ? 1 : 0; DPRINTF("DCD changed to %d\n", onoff); Modified: head/sys/dev/usb/serial/usb_serial.h ============================================================================== --- head/sys/dev/usb/serial/usb_serial.h Sat Mar 7 18:23:32 2015 (r279728) +++ head/sys/dev/usb/serial/usb_serial.h Sat Mar 7 18:25:58 2015 (r279729) @@ -64,6 +64,7 @@ #include <sys/serial.h> #include <sys/fcntl.h> #include <sys/sysctl.h> +#include <sys/timepps.h> /* Module interface related macros */ #define UCOM_MODVER 1 @@ -155,6 +156,8 @@ struct ucom_softc { struct ucom_cfg_task sc_line_state_task[2]; struct ucom_cfg_task sc_status_task[2]; struct ucom_param_task sc_param_task[2]; + /* pulse capturing support, PPS */ + struct pps_state sc_pps; /* Used to set "UCOM_FLAG_GP_DATA" flag: */ struct usb_proc_msg *sc_last_start_xfer; const struct ucom_callback *sc_callback; Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Sat Mar 7 18:23:32 2015 (r279728) +++ head/sys/sys/param.h Sat Mar 7 18:25:58 2015 (r279729) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100063 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100064 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"