summaryrefslogtreecommitdiff
path: root/arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2025-01-24 22:49:40 +0000
committerTom Rini <trini@konsulko.com>2025-04-28 12:45:44 -0600
commit90b74b3f51a9637c6fa226d0fdf162b6e94a3ecb (patch)
treef6e001ac87bb7fa9e288623ca86c988467d25835 /arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c
parent5721a3c47ae153285ceddec4d0fe5d8b36a688d4 (diff)
sunxi: clock: H6: drop usage of struct sunxi_prcm_reg
U-Boot drivers often revert to using C structures for modelling hardware register frames. This creates some problems: - A "struct" is a C language construct to group several variables together. The details of the layout of this struct are partly subject to the compiler's discretion (padding and alignment). - The "packed" attribute would force a certain layout, but we are not using it. - The actual source of information from the data sheet is the register offset. Here we create an artificial struct, carefully tuning the layout (with a lot of reserved members) to match that offset. To help with correctness, we put the desired information as a *comment*, though this is purely for the human reader, and has no effect on the generated layout. This sounds all very backwards. - Using a struct suggests we can assign a pointer and then access the register content via the members. But this is not the case, instead every MMIO register access must go through specific accessor functions, to meet the ordering and access size guarantees the hardware requires. - We share those structs in code shared across multiple SoC families, though most SoCs define their own version of the struct. Members must match in their name, across every SoC, otherwise compilation will fail. We work around this with even more #ifdefs in the shared code. - Some SoCs have an *almost* identical layout, but differ in a few registers. This requires hard to maintain #ifdef's in the struct definition. - Some of the register frames are huge: the H6 CCU device defines 127 registers. We use 15 of them. Still the whole frame would need to be described, which is very tedious, but for no reason. - Adding a new SoC often forces people to decide whether to share an existing struct, or to create a new copy. For some cases (say like 80% similarity) this works out badly either way. The Linux kernel heavily frowns upon those register structs, and instead uses a much simpler solution: #define REG_NAME <offset> This easily maps to the actual information from the data sheet, and can much simpler be shared across multiple SoCs, as it allows to have all SoC versions visible, so we can use C "if" statements instead of #ifdef's. Also it requires to just define the registers we need, and we can use alternative locations for some registers much more easily. Drop the usage of "struct sunxi_prcm_reg" in the H6 SPL clock code, by defining the respective register names and their offsets, then adding them to the base pointer. We cannot drop the struct definition quite yet, as it's also used in other drivers, still. Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Diffstat (limited to 'arch/arm/mach-stm32mp/cmd_stm32prog/cmd_stm32prog.c')
0 files changed, 0 insertions, 0 deletions