Discussion:
GPIO pullups not working
Elwood Downey
2021-05-04 18:24:41 UTC
Permalink
Hello all;

Using RELEASE-13 on Raspberry Pi 4 I can not seem to engage GPIO input
pullups. Doing so should cause an input not connected to anything to read
high but it always reads low. Connecting the pin to 3.3V does read hi so I
know the pin is working correctly as an input, just that the pullup is not
connecting.

I configure the pin as follows:

freebsdpi# gpioctl -c 21 PU IN
freebsdpi# gpioctl -l | grep 21
pin 21: 0 pin 21<IN,PU>
freebsdpi# sysctl dev.gpio.0.pin.21.function
dev.gpio.0.pin.21.function: input

# test with pin disconnected
freebsdpi# gpioctl 21
0

Now connecting to 3.3V:
freebsdpi# gpioctl 21
1

Installing a microSD with Raspbian Buster in the same Pi, I can repeat the
above using their tools and the pullup works as expected, so I know the
hardware is fine.

Any help appreciated, advTHANKSance

Elwood Downey
Tucson AZ
Elwood Downey
2021-05-06 04:04:10 UTC
Permalink
A little followup to my own post....

I have done some bare metal programming on the broadcom devices in the past
so I thought I'd try to find the relevant freebsd driver. The closest one I
could find in /usr/src is for the bcm2835.

This chip was used on the Pi3. The Pi4 uses the bcm2711 which, in their
infinite wisdom, uses a different register set and protocol for controlling
the gpio pullups. Code for the 2835 executing on a 2711 is harmless but
does nothing, in agreement with my observations.

Then I found bcm2835_gpio.c which I must say is beautifully written. I'm
tempted to tweak a few lines in bcm_gpio_set_pud() but I'd have to figure
out how to rebuild the kernel which I will leave for another day.

Not a big deal, until the 2711 is supported I'll just use an external
pullup.

All the best,
Post by Elwood Downey
Hello all;
Using RELEASE-13 on Raspberry Pi 4 I can not seem to engage GPIO input
pullups. Doing so should cause an input not connected to anything to read
high but it always reads low. Connecting the pin to 3.3V does read hi so I
know the pin is working correctly as an input, just that the pullup is not
connecting.
freebsdpi# gpioctl -c 21 PU IN
freebsdpi# gpioctl -l | grep 21
pin 21: 0 pin 21<IN,PU>
freebsdpi# sysctl dev.gpio.0.pin.21.function
dev.gpio.0.pin.21.function: input
# test with pin disconnected
freebsdpi# gpioctl 21
0
freebsdpi# gpioctl 21
1
Installing a microSD with Raspbian Buster in the same Pi, I can repeat the
above using their tools and the pullup works as expected, so I know the
hardware is fine.
Any help appreciated, advTHANKSance
Elwood Downey
Tucson AZ
Mark Millard via freebsd-arm
2021-05-15 21:43:45 UTC
Permalink
Post by Elwood Downey
A little followup to my own post....
I have done some bare metal programming on the broadcom devices in the past
so I thought I'd try to find the relevant freebsd driver. The closest one I
could find in /usr/src is for the bcm2835.
This chip was used on the Pi3. The Pi4 uses the bcm2711 which, in their
infinite wisdom, uses a different register set and protocol for controlling
the gpio pullups. Code for the 2835 executing on a 2711 is harmless but
does nothing, in agreement with my observations.
Does this mean that main's 2551d928501f 2021-02-17 commit
of:

diff --git a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
index 61513df9c008..70b69eb154e8 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
@@ -157,6 +157,7 @@ enum bcm_gpio_pud {
static struct ofw_compat_data compat_data[] = {
{"broadcom,bcm2835-gpio", 1},
{"brcm,bcm2835-gpio", 1},
+ {"brcm,bcm2711-gpio", 1},
{NULL, 0}
};

was inappropriate?
Post by Elwood Downey
Then I found bcm2835_gpio.c which I must say is beautifully written. I'm
tempted to tweak a few lines in bcm_gpio_set_pud() but I'd have to figure
out how to rebuild the kernel which I will leave for another day.
Not a big deal, until the 2711 is supported I'll just use an external
pullup.
All the best,
Post by Elwood Downey
Hello all;
Using RELEASE-13 on Raspberry Pi 4 I can not seem to engage GPIO input
pullups. Doing so should cause an input not connected to anything to read
high but it always reads low. Connecting the pin to 3.3V does read hi so I
know the pin is working correctly as an input, just that the pullup is not
connecting.
freebsdpi# gpioctl -c 21 PU IN
freebsdpi# gpioctl -l | grep 21
pin 21: 0 pin 21<IN,PU>
freebsdpi# sysctl dev.gpio.0.pin.21.function
dev.gpio.0.pin.21.function: input
# test with pin disconnected
freebsdpi# gpioctl 21
0
freebsdpi# gpioctl 21
1
Installing a microSD with Raspbian Buster in the same Pi, I can repeat the
above using their tools and the pullup works as expected, so I know the
hardware is fine.
===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
Elwood Downey
2021-05-15 22:07:35 UTC
Permalink
Post by Mark Millard via freebsd-arm
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
index 61513df9c008..70b69eb154e8 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
@@ -157,6 +157,7 @@ enum bcm_gpio_pud {
static struct ofw_compat_data compat_data[] = {
{"broadcom,bcm2835-gpio", 1},
{"brcm,bcm2835-gpio", 1},
+ {"brcm,bcm2711-gpio", 1},
{NULL, 0}
};
was inappropriate?
Assuming that code made it into 13.0-RELEASE then I would say yes because
that release does not correctly control pullups for the 2711.

Loading...