]> www.infradead.org Git - users/dwmw2/linux.git/commit
net: sparx5: add indirection layer to register macros
authorDaniel Machon <daniel.machon@microchip.com>
Fri, 4 Oct 2024 13:19:28 +0000 (15:19 +0200)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 8 Oct 2024 10:07:00 +0000 (12:07 +0200)
commit5ba3f8460393aab8debdc961a8364527252c2b1e
tree90c8667db6213cb1a931fbf7dd8f3d4aab7d9d94
parent1d00c08048529b36e4d039aee8d60f8258797ed7
net: sparx5: add indirection layer to register macros

The register macros are used to read and write to the switch registers.
The registers are largely the same on Sparx5 and lan969x, however in some
cases they differ. The differences can be one or more of the following:
target size, register address, register count, group address, group
count, group size, field position, field size.

In order to handle these differences, we introduce a new indirection
layer, that defines and maps them to corresponding values, based on the
platform. As the register macro arguments can now be non-constants, we
also add non-constant variants of FIELD_GET and FIELD_PREP.

Since the indirection layer contributes to longer macros, we have
changed the formatting of them slightly, to adhere to a 80 character
limit, and added a comment if a macro is platform-specific.

With these additions, we can reuse all the existing macros for
lan969x.

Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/microchip/sparx5/Makefile
drivers/net/ethernet/microchip/sparx5/sparx5_main.c
drivers/net/ethernet/microchip/sparx5/sparx5_main.h
drivers/net/ethernet/microchip/sparx5/sparx5_main_regs.h
drivers/net/ethernet/microchip/sparx5/sparx5_regs.c [new file with mode: 0644]
drivers/net/ethernet/microchip/sparx5/sparx5_regs.h [new file with mode: 0644]