diff --git a/main.c b/main.c index a8702110773fb5659e1948d3d245c7ed164c1d8b..fe1c1efa3fb12a6192d00df3276dc5b0b3994135 100644 --- a/main.c +++ b/main.c @@ -89,7 +89,7 @@ static hiomap_configuration_data_t hiomap_config; // Background service tasks static uint8_t host_background_service_task_active = 0; static uint8_t host_console_service_task_active = 0; -static int configured_cpu_count = 0; +static int configured_cpu_count = 1; // POST codes uint8_t post_code_high = 0; @@ -103,6 +103,7 @@ typedef struct { int8_t index; uint8_t *i2c_master; + uint32_t i2c_frequency; uint8_t vdd_regulator_addr; uint8_t vdn_regulator_addr; uint8_t vdd_smbus_addr; @@ -112,6 +113,7 @@ static const cpu_info_t g_cpu_info[] = { { .index = 0, .i2c_master = (uint8_t *)I2CMASTER1_BASE, + .i2c_frequency = 100000, .vdd_regulator_addr = 0x70, .vdn_regulator_addr = 0x73, .vdd_smbus_addr = 0x28, @@ -122,6 +124,7 @@ static const cpu_info_t g_cpu_info[] = { { .index = 1, .i2c_master = (uint8_t *)I2CMASTER2_BASE, + .i2c_frequency = 100000, .vdd_regulator_addr = 0x70, .vdn_regulator_addr = 0x73, .vdd_smbus_addr = 0x28, @@ -1419,13 +1422,12 @@ static int apply_avsbus_workarounds(const cpu_info_t *cpu_info, int cpu_count) { printf("Applying AVSBus workarounds...\n"); - while (--cpu_count) + for (int i = 0; i < cpu_count; i++) { - if (apply_avsbus_workarounds_cpu(&cpu_info[0])) + if (apply_avsbus_workarounds_cpu(&cpu_info[i])) { return -1; } - cpu_info++; } printf("\tAVSBus workaround application complete!\n"); @@ -1471,13 +1473,12 @@ static int enable_avsbus_pmbus(const cpu_info_t *cpu_info, int cpu_count) { printf("Enabling AVSbus PMBUS functionality...\n"); - while (--cpu_count) + for (int i = 0; i < cpu_count; i++) { - if (enable_avsbus_pmbus_cpu(&cpu_info[0])) + if (enable_avsbus_pmbus_cpu(&cpu_info[i])) { return -1; } - cpu_info++; } printf("\tAVSBus PMBUS functionality enabled!\n"); @@ -1523,14 +1524,13 @@ static int disable_avsbus_pmbus(const cpu_info_t *cpu_info, int cpu_count) int status = 0; printf("Disabling AVSbus PMBUS functionality...\n"); - while (--cpu_count) + for (int i = 0; i < cpu_count; i++) { // Attempt to turn of power on all CPUs, even if one isn't responding. - if (disable_avsbus_pmbus_cpu(&cpu_info[0])) + if (disable_avsbus_pmbus_cpu(&cpu_info[i])) { status = -1; } - cpu_info++; } printf("\tAVSBus PMBUS functionality disabled!\n"); @@ -2428,10 +2428,10 @@ int main(void) display_character(0x30, 0); // STATUS CODE: 0 - initialize_i2c_master((uint8_t *)I2CMASTER1_BASE, 100000); -#ifdef I2CMASTER2_BASE - initialize_i2c_master((uint8_t *)I2CMASTER2_BASE, 100000); -#endif + for (int i = 0; i < MAX_CPUS_SUPPORTED; i++) + { + initialize_i2c_master(g_cpu_info[i].i2c_master, g_cpu_info[i].i2c_frequency); + } // initialize_i2c_master((uint8_t*)I2CMASTER3_BASE, 100000); initialize_i2c_master((uint8_t *)I2CMASTER4_BASE, 100000);