Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/34545 )
Change subject: mediatek/mt8183: Init SPM driver ......................................................................
Patch Set 12:
(1 comment)
https://review.coreboot.org/c/coreboot/+/34545/12/src/mainboard/google/kukui... File src/mainboard/google/kukui/mainboard.c:
https://review.coreboot.org/c/coreboot/+/34545/12/src/mainboard/google/kukui... PS12, Line 59: spm_init(get_dram_type());
I just talk with MTK dram driver owner, how about if we move get_dram_type function to emi. […]
The point is that 'params' is not accessible in ramstage (or at least you shouldn't access it, for efficiency reasons). It doesn't matter which .c file you put the code in.
From looking at CB:34433 it seems like you're not actually using the dram_type thing anywhere else (i.e. not for the actual DDR init)? In that case, I see how it might be hard to interpret it back out of EMI hardware register state.
So I think you have two options: either move the thing that needs dram_type into romstage (so you only load the params from flash once and do everything you need to do with them in that stage), or you have to store the dram_type outside of the other params. For example, you could have a second lookup table in sdram_configs.c like this:
static const char *const sdram_configs[] = { [1] = "sdram-lpddr4x-H9HCNNNCPMALHR-4GB", [2] = ... };
static const enum dram_type sdram_types[] = { [1] = DRAM_TYPE_DISCRETE, [2] = ... };