On Wed, May 21, 2025 at 03:45:03PM +0900, Alexandre Courbot wrote: > Some registers (notably scratch registers) don't have a definitive > purpose, but need to be interpreted differently depending on context. > > Expand the register!() macro to support a syntax indicating that a > register type should be at the same offset as another one, but under a > different name, and with different fields and documentation. > > Signed-off-by: Alexandre Courbot <acour...@nvidia.com> > --- > drivers/gpu/nova-core/regs/macros.rs | 40 > ++++++++++++++++++++++++++++++++++-- > 1 file changed, 38 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/nova-core/regs/macros.rs > b/drivers/gpu/nova-core/regs/macros.rs > index > 7cd013f3c90bbd8ca437d4072cae8f11d7946fcd..64dda1d4d93d3c7022ef02b6f6fb81b58e90dd44 > 100644 > --- a/drivers/gpu/nova-core/regs/macros.rs > +++ b/drivers/gpu/nova-core/regs/macros.rs > @@ -71,6 +71,20 @@ > /// pr_info!("CPU CTL: {:#x}", cpuctl); > /// cpuctl.set_start(true).write(&bar, CPU_BASE); > /// ``` > +/// > +/// It is also possible to create a alias register by using the `=> PARENT` > syntax. This is useful > +/// for cases where a register's interpretation depends on the context: > +/// > +/// ```no_run > +/// register!(SCRATCH_0 @ 0x0000100, "Scratch register 0" { > +/// 31:0 value as u32, "Raw value"; > +/// > +/// register!(SCRATCH_0_BOOT_STATUS => SCRATCH_0, "Boot status of the > firmware" {
NIT: I'd put the arrow the other way around, i.e. SCRATCH_0_BOOT_STATUS is derived from SCRATCH_0, not the other way around.