Skip to content

Added support to reserve/enable a GPIO pin to be used from pps-gpio module #717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2014

Conversation

tjko
Copy link

@tjko tjko commented Oct 30, 2014

This change enables use of existing pps-gpio module with Raspberry Pi. This change should be "no-op", as it is disabled by default. It adds two kernel cmdline options:

bcm2708.pps_gpio_enable
bcm2708.pps_gpio_pin

When user wants to use pps-gpio module they need to add "bcm2708.pps_gpio_enable=1" into cmdline.txt, this will enable PPS on GPIO 18. If any other GPIO pin is desired it can be selected using the second option...

After system is booted with this option, pps-gpio module can simply be loaded and it will find the designated GPIO pin as a PPS source:

[   61.691271] pps_core: LinuxPPS API ver. 1 registered
[   61.691305] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
[   61.700274] pps pps0: new PPS source pps-gpio.-1
[   61.700357] pps pps0: Registered IRQ 188 as PPS source

This change is based on the patch by Hauke Lampe: https://github.com/lampeh/rpi-misc/blob/master/linux-pps/linux-rpi-pps-gpio-bcm2708.diff

@popcornmix
Copy link
Collaborator

I think GPIO18 is a bad choice for a B+ board (it collides with I2S used by audio cards).

Can you remove pps_gpio_enable, initialise pps_gpio_pin to -1, and use bcm2708.pps_gpio_pin= as the way of enabling this (for any non-negative pin number).

@tjko
Copy link
Author

tjko commented Oct 31, 2014

That's a good idea, no really need for two kernel options.

Can I also include change to enable PPS modules in bcmrpi_defconfig? PPS modules add only about 52KB to /lib/modules

@tjko
Copy link
Author

tjko commented Oct 31, 2014

Patch has now been cleaned up, and uses just single new kernel/module option:
bcm2708.pps_gpio_pin=n

It shouldn't really change anything until user manually enables desired GPIO pin to be used as PPS source with pps-gpio kernel module.

I added info message when this option is used (nothing is printed if option is not specified), so its easier for users to confirm that the option they passed actually took effect (and that the option is supported in kernel that they use):

...
[    0.029535] bcm2708: GPIO 18 setup as pps-gpio device
...
[   26.587907] pps_core: LinuxPPS API ver. 1 registered
[   26.587937] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <[email protected]>
[   26.605937] pps pps0: new PPS source pps-gpio.18
[   26.606019] pps pps0: Registered IRQ 188 as PPS source
...

Also the device ID in the device tree gets populated with the GPIO pin number, making it bit clearer which /dev/ppsX device maps to which PPS source...

@kukabu
Copy link

kukabu commented Oct 31, 2014

It would be good!
CONFIG_PPS=m
CONFIG_PPS_CLIENT_LDISC=m
CONFIG_PPS_CLIENT_GPIO=m

@popcornmix
Copy link
Collaborator

Can you squash first two commits (git rebase -i HEAD~3 and following instructions, then git push -f).

…odule (LinuxPPS).

Enable PPS modules in default config for RPi.
@tjko
Copy link
Author

tjko commented Nov 1, 2014

Everything is now in as single commit. This should make using GPS as PPS source with Raspberry Pi rather easy, when it comes to kernel...

popcornmix added a commit that referenced this pull request Nov 1, 2014
Added support to reserve/enable a GPIO pin to be used from pps-gpio module
@popcornmix popcornmix merged commit 519c51e into raspberrypi:rpi-3.12.y Nov 1, 2014
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Nov 1, 2014
…s-gpio module

See: raspberrypi/linux#717

firmware: arm_loader: Add lock to rotated frame updates to avoid an unsafe update from mailbox channel
See: #327

firmware: hdmi: Fix for attached flag in hdmi status when booting with cable disconnected
See: #326
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this pull request Nov 1, 2014
…s-gpio module

See: raspberrypi/linux#717

firmware: arm_loader: Add lock to rotated frame updates to avoid an unsafe update from mailbox channel
See: raspberrypi/firmware#327

firmware: hdmi: Fix for attached flag in hdmi status when booting with cable disconnected
See: raspberrypi/firmware#326
@jera-sea
Copy link

jera-sea commented Dec 2, 2014

I am getting a timeout when using ppstest on /dev/pps0
the debug messages say "time format unspecified".
It is a copy of the latest raspbian image with the kernel recompiled and pps gpio added as modules.

@tjko
Copy link
Author

tjko commented Dec 2, 2014

It seems gpsd / ntpd can sometimes auto-load pps_ldisc module (that can
be used for PPS source on COM port using some of the signal lines ;
CTS etc...), this won't work on serial ports that don't implement
those lines like ttyAMA0 on RPi...
So on RPi you could see things like:

[   26.246266] pps_ldisc: PPS line discipline registered
[   26.248015] pps pps0: new PPS source ttyAMA0
[   26.248292] pps pps0: source "/dev/ttyAMA0" added

If that happens then likely pps_gpio was loaded after pps_ldisc
module, and created "pps1" (/dev/pps1") and you would need to use that
for PPS, instead...

If thats not it, then you may want to check that kernel got the command line parameter (bcm2708.pps_gpio_pin) specifying which GPIO pin to use:

[    0.029902] bcm2708: GPIO 18 setup as pps-gpio device

If you don't see message similar to one above, then loading pps_gpio wont work.
But if message similar to the one above shows up, then you should see pps_gpio generate messages like this:

[   78.339732] pps pps0: new PPS source pps-gpio.18
[   78.339813] pps pps0: Registered IRQ 188 as PPS source

Note which ppsX device was assigned, since it might not always be "pps0"...

(above assumes that you set pin 18 using command line option to
kernel: bcm2708.pps_gpio_pin=18)

Btw, have you checked the instructions at: http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html#easy

@jera-sea
Copy link

jera-sea commented Dec 3, 2014

Oh god...
Sorry for wasting your time.

the ribbon cable was dodgy.

facepalm

neuschaefer pushed a commit to neuschaefer/raspi-binary-firmware that referenced this pull request Feb 27, 2017
…s-gpio module

See: raspberrypi/linux#717

firmware: arm_loader: Add lock to rotated frame updates to avoid an unsafe update from mailbox channel
See: raspberrypi#327

firmware: hdmi: Fix for attached flag in hdmi status when booting with cable disconnected
See: raspberrypi#326
pfpacket pushed a commit to pfpacket/linux-rpi-rust that referenced this pull request Apr 7, 2023
rust: add a simple Rust mutex implementation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants