Subject: Re: Help needed: supporting new device with unique register bitfields

From: Jakub Kicinski <[email-masked]>
Date: Mon, 24 Apr 2023 12:53:57 -0700

On Sun, 23 Apr 2023 16:19:11 +0800 Feiyang Chen wrote:
> We are hoping to add support for a new device which shares almost
> identical logic with dwmac1000 (dwmac_lib.c, dwmac1000_core.c, and
> dwmac1000_dma.c), but with significant differences in the register
> bitfields (dwmac_dma.h and dwmac1000.h).
> 
> We are seeking guidance on the best approach to support this new
> device. Any advice on how to proceed would be greatly appreciated.
> 
> Thank you for your time and expertise.

There's no recipe on how to support devices with different register
layout :(  You'll need to find the right balance of (1) indirect calls,
(2) if conditions and (3) static description data that's right for you.

Static description data (e.g. putting register addresses in a struct
and using the members of that struct rather than #defines) is probably
the best but the least flexible.

Adding the stmmac maintainers.