/* * Raspberry Pi GPIO support */ #include "u.h" #include "../port/lib.h" #include "../port/error.h" #include "mem.h" #include "dat.h" #include "fns.h" #include "io.h" #define GPIOREGS (VIRTIO+0x200000) /* GPIO regs */ enum { Fsel0 = 0x00>>2, FuncMask= 0x7, Set0 = 0x1c>>2, Clr0 = 0x28>>2, Lev0 = 0x34>>2, PUD = 0x94>>2, Off = 0x0, Pulldown= 0x1, Pullup = 0x2, PUDclk0 = 0x98>>2, PUDclk1 = 0x9c>>2, }; 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<