From 8630bd35a636a463bcf7211aaa0f014600013463 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 27 Jul 2019 20:00:53 +0200 Subject: [PATCH] bcm, bcm64: add BCM2711 support for gpiopull(), fix gpiomeminit(), cleanup according to the following linux change, BCM2711 uses a different method for changing pullup/down mode: https://github.com/raspberrypi/linux/commit/abcfd092860760087b87acbdda0963fe7906839c#diff-cf078559c38543ac72c5db99323e236d gpiomeminit() was broken, using virtual address for the gpio physseg instead of the physical one. cleanup the code, avoid repetition by declaring static u32int *regs variable. make local variable names consistent. --- sys/src/9/bcm/gpio.c | 82 +++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/sys/src/9/bcm/gpio.c b/sys/src/9/bcm/gpio.c index b970e96f6..fbb66343b 100644 --- a/sys/src/9/bcm/gpio.c +++ b/sys/src/9/bcm/gpio.c @@ -30,36 +30,50 @@ enum { Off = 0x0, Pulldown= 0x1, Pullup = 0x2, + PudMask = 0x3, + PUDclk0 = 0x98>>2, PUDclk1 = 0x9c>>2, + + /* BCM2711 only */ + PUPPDN0 = 0xe4>>2, + PUPPDN1 = 0xe8>>2, + PUPPDN2 = 0xec>>2, + PUPPDN3 = 0xf0>>2, }; +static u32int *regs = (u32int*)GPIOREGS; + void gpiosel(uint pin, int func) { - u32int *gp, *fsel; - int off; - - gp = (u32int*)GPIOREGS; - fsel = &gp[Fsel0 + pin/10]; - off = (pin % 10) * 3; - *fsel = (*fsel & ~(FuncMask<