sunxi: H616: dram: split struct dram_para
authorAndre Przywara <andre.przywara@arm.com>
Wed, 7 Jun 2023 00:07:43 +0000 (01:07 +0100)
committerAndre Przywara <andre.przywara@arm.com>
Thu, 20 Jul 2023 23:29:42 +0000 (00:29 +0100)
commit78aa00c38e86ea06e625c9c7e0365fc87353d5a5
tree08d03e6274b23f059abb096cd2192a06f1a32ce3
parent457e2cd665bd0e17f6fe0be936525f7d3dd8efb5
sunxi: H616: dram: split struct dram_para

Currently there is one DRAM parameter struct for the Allwinner H616 DRAM
"driver". It contains many fields that are compile time constants
(set by Kconfig variables), though there are also some fields that are
probed and changed over the runtime of the DRAM initialisation.

Because of this mixture, the compiler cannot properly optimise the code
for size, as it does not consider constant propagation in its full
potential.

Help the compiler out by splitting that structure into two: one that only
contains values known at compile time, and another one where the values
will actually change. The former can then be declared "const", which will
let the compiler fold its values directly into the code using it.

We also add "const" tags for some new "struct dram_config" pointers, to
further increase code optimisation.
To help the compiler optimise the code further, the definition of the
now "const struct dram_para" has to happen at a file-global level, so
move that part out of sunxi_dram_init().

That results in quite some code savings (almost 2KB), and helps to keep
the code small with the LPDDR3 support added later.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
arch/arm/include/asm/arch-sunxi/dram_sun50i_h616.h
arch/arm/mach-sunxi/dram_sun50i_h616.c