From owner-freebsd-stable@freebsd.org Fri Mar 4 18:00:17 2016 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 691D09DAA8C for ; Fri, 4 Mar 2016 18:00:17 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from pmta2.delivery6.ore.mailhop.org (pmta2.delivery6.ore.mailhop.org [54.200.129.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 50AC4C95 for ; Fri, 4 Mar 2016 18:00:17 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 2c83b635-e233-11e5-8de6-958346fd02ba X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.34.117.227 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.34.117.227]) by outbound2.ore.mailhop.org (Halon Mail Gateway) with ESMTPSA; Fri, 4 Mar 2016 18:01:52 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.14.9) with ESMTP id u24I08Fj004054; Fri, 4 Mar 2016 11:00:08 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1457114408.13785.150.camel@freebsd.org> Subject: Re: PPS input on a generic GPIO pin on Raspberry Pi. From: Ian Lepore To: Karl Denninger , freebsd-stable@freebsd.org Date: Fri, 04 Mar 2016 11:00:08 -0700 In-Reply-To: <56D9BDB6.6040903@denninger.net> References: <8C90C80B-AC5F-4B12-8E84-84193B8C55C4@pean.org> <56D9BDB6.6040903@denninger.net> Content-Type: text/plain; charset="iso-8859-13" X-Mailer: Evolution 3.16.5 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Mar 2016 18:00:17 -0000 On Fri, 2016-03-04 at 10:54 -0600, Karl Denninger wrote: > On 3/3/2016 12:57, Peter Ankerstål wrote: > > Hi! > > > > I have sort of exactly the same question as Erik: > > http://lists.freebsd.org/pipermail/freebsd-questions/2014-July/2590 > > 55.html > > > > I have bought a https://learn.adafruit.com/adafruit-ultimate-gps an > > d want to use the PPS output to discipline my clock. > > > > But the only source of information on how PPS works in FreeBSD I > > could find is this: > > https://docs.freebsd.org/doc/8.0-RELEASE/usr/share/doc/ntp/pps.html > > and it clearly states the two ways to provide a PPS signal. "The > > PPS signal can be connected in either of two ways: via the data > > carrier detector (DCD) pin of a serial port or via the acknowledge > > (ACK) pin of a parallel port¡ > > > > Since the Pi doesnÿt have any DCD pin i would like to use a generic > > GPIO for this. There is a linux kernel module for this: http://lxr. > > free-electrons.com/source/drivers/pps/clients/pps-gpio.c?v=3.6 > GPIO is supported on the Pi, I'm using it on 11-Current on my home > control software to drive relays on my pool hardware (e.g. valves, > heater, VFD motor drive, etc) and it is working very well. I don't > believe tapping into that at the kernel level to expose a pps signal > (e.g. on /dev/pps or something of the like) would be very difficult > at > all, since the low-level driver capability is already present. > > If I get some free time I'll dig around a bit and see if I can cobble > something up. It's of some interest to me as well since I have a GPS > clock here that currently talks to a serial port on an Intel-based > machine and being able to move that to a $35 "appliance" for NTP > using > the Adafruit setup looks sort of attractive given that the Pi plus > the > module would be under $100 all-in. > Don't "cobble something up" just yet... there is "a right way" to fix this, which is a generic gpio-pps driver. The problem is that it requires support from the new INTRNG, and the rpi hasn't been converted to that yet. I'm checking around to see if someone has done the conversion for rpi and it just hasn't been reveiwed/committed yet; if not, I guess I'll try to do it myself. Writing the actual gpio-pps driver will be pretty quick and easy once we have the intrng support, I think it'll take me a couple hours. Also, FYI, another option with PPS is to use a usb-serial adapter and feed the PPS in on the CTS or DCD pin. I tested that on rpi a few months ago and it worked fine. There's surpisingly little jitter even when the usb bus is heavily loaded with other traffic such as disk or network IO. -- Ian