drivers/soc/litex: support 32-bit subregisters, 64-bit CPUs
authorGabriel Somlo <gsomlo@gmail.com>
Tue, 12 Jan 2021 17:31:43 +0000 (12:31 -0500)
committerStafford Horne <shorne@gmail.com>
Thu, 14 Jan 2021 00:52:54 +0000 (09:52 +0900)
commit51f109228308a87c7f2583360e54acfc567203da
tree73c8877c7fad7313714d41fa99e71931aecbe2ab
parentffa4ebc48971abffed722b75887ac1d8c9256b41
drivers/soc/litex: support 32-bit subregisters, 64-bit CPUs

Upstream LiteX now defaults to using 32-bit CSR subregisters
(see https://github.com/enjoy-digital/litex/commit/a2b71fde).

This patch expands on commit 22447a99c97e ("drivers/soc/litex: add
LiteX SoC Controller driver"), adding support for handling both 8-
and 32-bit LiteX CSR (MMIO) subregisters, as determined by the
LITEX_SUBREG_SIZE Kconfig option.

NOTE that while LITEX_SUBREG_SIZE could theoretically be a device
tree property, defining it as a compile-time constant allows for
much better optimization of the resulting code. This is further
supported by the low expected usefulness of deploying the same
kernel across LiteX SoCs built with different CSR-Bus data widths.

Finally, the litex_[read|write][8|16|32|64]() accessors are
redefined in terms of litex_[get|set]_reg(), which, after compiler
optimization, will result in code as efficient as hardcoded shifts,
but with the added benefit of automatically matching the appropriate
LITEX_SUBREG_SIZE.

NOTE that litex_[get|set]_reg() nominally operate on 64-bit data,
but that will also be optimized by the compiler in situations where
narrower data is used from a call site.

Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
Signed-off-by: Stafford Horne <shorne@gmail.com>
drivers/soc/litex/Kconfig
drivers/soc/litex/litex_soc_ctrl.c
include/linux/litex.h