Everything posted by maruel
Context: I implemented a GPIO driver in Golang for A64 running armbian using memory mapped registers leveraging /dev/mem. Will test on H3 as soon as I receive my board. The main improvement over sunxi-pio is that I implemented edge based triggering leveraging sysfs gpio, since interrupts are not accessible in user mode yet polling sucks. I realized the /dev/gpiomem concept (at least as implemented by Raspbian) is not applicable on (some) Allwinner processors (at least on A64 and H3) because they require 2 separate sections to be memory mapped to access all the pins. GPIO belonging to group PB to PH use the registers located at 0x01C20800 and group PL uses registers located at 0x01F02C00. So I'll forget on this gpiomem idea for now. And since Pine64 has PL pins on its PI2 header, it's really important to be able to access this group. That's annoying as this requires me to run my app as root for the foreseeable future, which is really a downer. --- <random rant> Allwinner CPUs has only a subset of pins supporting edge based triggering: in groups PB, PG, PH and PL, unlike bcm283x which supports it on all pins. On the other hand, you can query the current pull resistor on any pin on Allwinner, unlike bcm283x which is a black box. You can't have it all...
That's my point; /dev/gpiomem was created to give only access to a few Kb of non translated memory without compromising on security. I'd rather have my GPIO using apps not run as root and/or be able to poke into the kernel's memory as a user.
tkaiser, udev rules files can be easily added by a user as root. So it's not a big deal if it is not done in the image, it can be fixed afterward. On the other hand, /dev/gpiomem has real benefit to run gpio apps fast (read the pin directly from the CPU register), without using gpio sysfs, without requiring root. This is a pure "Raspbianism" but I think it's a good feature to be looked into. This requires writing a kernel driver something like https://github.com/raspberrypi/linux/blob/rpi-4.4.y/drivers/char/broadcom/bcm2835-gpiomem.cbut for other processors. That's harder to do for a end user than adding udev rules. Allwinner A64: As per http://files.pine64.org/doc/datasheet/pine64/Allwinner_A64_User_Manual_V1.0.pdf page 73~75 and page 81, base address 0x01C20000 for a few Kb could be mapped the same way. http://dl.linux-sunxi.org/H3/Allwinner_H3_Datasheet_V1.0.pdfpage 90 implies that Allwinner H3 uses a similar memory mapping so it could probably be shared at least for these two processors. Amlogic S905: I did a quick peek at datasheet at http://dn.odroid.com/S905/DataSheet/S905_Public_Datasheet_V1.1.4.pdfpage 45 and 80, tells 0xc8834000 being the interesting base address. I didn't look for other processors. I have no linux kernel dev experience though so it may take a while for me to create a functional one, albeit copy pasting the raspbian's one (yay GPL I guess?). Does this sound like a "good" idea?