Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Deciphering GPIO on Raspberry Pi B+



On Sun, Apr 15, 2018 at 01:18:29PM -0700, Jason Thorpe wrote:
> > 
> > You look at the PDF and find that GPIO2-27 are available, GPIO0-1 is
> > reserved for the HAT EEPROM, but could be used too if it doesn't look
> > like an EEPROM.
> 
> But that doesn?t really answer my question, because there?s really no indication as to how *NetBSD* has configured the GPIO at start-up time.

It hasn't.


> For example, which of the GPIO pins have alternate functions enabled (and, if so, which one)?

None of GPIO0-27 have been configured, all default to input and no
alternate function as initialized by the firmware. Other pins have
been initialized by the firmware to whatever the firmware needs,
only part of that is documented.


> And how does that change depending on what drivers are present in the kernel at start-up time?  For example, ?vcaudio? uses a couple if GPIO pins, but are those pins put into that alternate function when the ?vcaudio? driver is attached, or when the device is opened for use?  There?s also the question of the on-board LEDs ? which GPIO pins are consumed by those?

vcaudio doesn't use any of the GPIO pins. It does use the PWM engine,
but has no control over it as it just talks to the firmware.

The current firmware uses the PWM channels, associated clocks and
DMA channels when you ask it to play analog audio (instead of HDMI
audio), and it never releases either. There isn't even a protocol
to arbitrate access. They have added the config.txt setting
'force_pwm_open', when set to 0, the firmware will release the
hardware when not playing, at the cost of some extra 'click' noise.
I think you can also force the firmware to use HDMI audio.

LEDs vary a lot by RPI model, from being hardwired to being controlled
by a GPIO extender chip that is connected to one of the I2C busses.


> Obviously, the only ones I really need to care about are the ones actually brought out to the 40-pin header, but knowing which ones of those I can actually use based on how NetBSD has configured the system and the proper way to refer to them (?gpio0 + BCM pin number? or ?gpio1 + BCM pin number - 32?) would be useful information.

You can use all as GPIO (modulo usage of GPIO0/1 for the HAT EEPROM).

How you can use alternate functions depends. But basically:

-> there are tty drivers for both UARTS
-> there is vcaudio (using PWM).




> (This bifurcation of the GPIO pin space is annoying because it?s going to potentially make some intended-to-be-portable-to-other-GPIO-having-hardware code more complicated for the NetBSD case.)

Fortunately all pins from the 40pin connector are on the first GPIO.



> > The other question is what alternate functions are available and
> > how the other 26 GPIOs are used:
> > 
> > -> https://elinux.org/RPi_BCM2835_GPIOs <https://elinux.org/RPi_BCM2835_GPIOs>
> 
> Well, this is certainly a handy reference.  Someone with access to do so should link to it on the NetBSD RPI wiki page.

All developers can access the wiki page :)


Greetings,
-- 
                                Michael van Elst
Internet: mlelstv%serpens.de@localhost
                                "A potential Snark may lurk in every tree."


Home | Main Index | Thread Index | Old Index