allwinner gpio bank offset

Titus Manea <[email protected]>
Newsgroups gmane.os.freebsd.devel.arm
Message-ID <[email protected]>
The Allwinner pincontroller register layout used to allow for at least
11 banks per controller, any more banks would reside at a second
controller instance.
When the per-bank register map size was increased with the D1, it turned
out that the last bank (port K) of those maximum 11 banks actually would
not fit anymore in the 512 bytes reserved for the pincontroller registers.
On new SoCs Allwinner thus moved the last bank beyond the existing
registers, at offset 0x500.

So far SoCs never used more than 9 banks per controller, but the new
Allwinner A523 actually uses all 11 banks. Since that SoC also uses the
extended layout, its PortK needs to be programmed at offset 0x500.

Factor out the bank offset calculation into a new function, and handle
the case for the last bank separately. Since none of the older SoCs ever
used PortK, we can ignore this case, and just always use offset 0x500
for the last bank.
source
https://patchew.org/linux/[email protected]/[email protected]/
so
we need to change the AW_GPIO_GP_BASE macro

#define AW_BASE_1(_sc, _bank, _o)       ((_sc)->conf->bank_size * (_bank) + (_o))

#define BANK_K                          ('K' - 'A')
#define IS_BANK_K(_sc, _bank)           (AW_BASE_1(_sc, _bank, 0) > 0x200)
#define AW_GPIO_GP_BASE(_sc, _bank)     (IS_BANK_K(_sc, _bank) ? \
                                           AW_BASE_1((_sc), ((_bank) - BANK_K), 0x500) : \
                                           AW_BASE_1((_sc), (_bank), 0))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.