minerva: Fallback gracefully when old lib present

This commit is contained in:
shchmue 2019-12-09 12:51:11 -07:00
parent 12a076ca82
commit d6794070c4
2 changed files with 11 additions and 5 deletions

View file

@ -28,7 +28,7 @@
extern volatile nyx_storage_t *nyx_str; extern volatile nyx_storage_t *nyx_str;
void minerva_init() u32 minerva_init()
{ {
u32 curr_ram_idx = 0; u32 curr_ram_idx = 0;
@ -37,13 +37,17 @@ void minerva_init()
// Set table to nyx storage. // Set table to nyx storage.
mtc_cfg->mtc_table = (emc_table_t *)&nyx_str->mtc_table; mtc_cfg->mtc_table = (emc_table_t *)&nyx_str->mtc_table;
mtc_cfg->init_done = MTC_NEW_MAGIC;
mtc_cfg->sdram_id = (fuse_read_odm(4) >> 3) & 0x1F; mtc_cfg->sdram_id = (fuse_read_odm(4) >> 3) & 0x1F;
mtc_cfg->init_done = MTC_NEW_MAGIC; // Initialize mtc table.
u32 ep_addr = ianos_loader(false, "bootloader/sys/libsys_minerva.bso", DRAM_LIB, (void *)mtc_cfg); u32 ep_addr = ianos_loader(false, "bootloader/sys/libsys_minerva.bso", DRAM_LIB, (void *)mtc_cfg);
minerva_cfg = (void *)ep_addr;
// Ensure that Minerva is new.
if (mtc_cfg->init_done == MTC_INIT_MAGIC)
minerva_cfg = (void *)ep_addr;
if (!minerva_cfg) if (!minerva_cfg)
return; return 1;
// Get current frequency // Get current frequency
for (curr_ram_idx = 0; curr_ram_idx < 10; curr_ram_idx++) for (curr_ram_idx = 0; curr_ram_idx < 10; curr_ram_idx++)
@ -69,6 +73,8 @@ void minerva_init()
// Switch to max. // Switch to max.
mtc_cfg->rate_to = 1600000; mtc_cfg->rate_to = 1600000;
minerva_cfg(mtc_cfg, NULL); minerva_cfg(mtc_cfg, NULL);
return 0;
} }
void minerva_change_freq(minerva_freq_t freq) void minerva_change_freq(minerva_freq_t freq)

View file

@ -58,7 +58,7 @@ typedef enum
} minerva_freq_t; } minerva_freq_t;
void (*minerva_cfg)(mtc_config_t *mtc_cfg, void *); void (*minerva_cfg)(mtc_config_t *mtc_cfg, void *);
void minerva_init(); u32 minerva_init();
void minerva_change_freq(minerva_freq_t freq); void minerva_change_freq(minerva_freq_t freq);
void minerva_periodic_training(); void minerva_periodic_training();