diff options
-rw-r--r-- | src/mainboard/google/brya/variants/kinox/ramstage.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/mainboard/google/brya/variants/kinox/ramstage.c b/src/mainboard/google/brya/variants/kinox/ramstage.c index 36f250e7b4..6df88c28df 100644 --- a/src/mainboard/google/brya/variants/kinox/ramstage.c +++ b/src/mainboard/google/brya/variants/kinox/ramstage.c @@ -79,50 +79,50 @@ const struct psys_config psys_config = { .bj_volts_mv = 20000 }; -static void change_power_limits(const struct cpu_power_limits *limits, size_t num_entries) -{ - variant_update_psys_power_limits(limits, sys_limits, num_entries, &psys_config); - variant_update_power_limits(limits, num_entries); -} - -static void update_power_limits(void) +static const struct cpu_power_limits *get_power_limit(size_t *total_entries) { enum usb_chg_type type; uint16_t volts_mv, current_ma, watts; - size_t total_entries; int rv = google_chromeec_get_usb_pd_power_info(&type, ¤t_ma, &volts_mv); - if (rv == 0) { - watts = ((uint32_t)current_ma * volts_mv) / 1000000; - printk(BIOS_INFO, "PL124: type: (%u) Current_ma: (%u) Volts_mv: (%u) Watts: (%u)\n", - type, current_ma, volts_mv, watts); - if (type == USB_CHG_TYPE_PROPRIETARY) { - if (watts == CHARGER_170W) { - printk(BIOS_INFO, "PL124: Performance.\n"); - total_entries = ARRAY_SIZE(perf_limits); - change_power_limits(perf_limits, total_entries); - } else { - printk(BIOS_INFO, "PL124: Baseline.\n"); - total_entries = ARRAY_SIZE(baseline_limits); - change_power_limits(baseline_limits, total_entries); - } + if (rv) { + printk(BIOS_INFO, "EC cmd failure: PL124: Baseline.\n"); + *total_entries = ARRAY_SIZE(baseline_limits); + return baseline_limits; + } + + watts = ((uint32_t)current_ma * volts_mv) / 1000000; + if (type == USB_CHG_TYPE_PROPRIETARY) { + if (watts == CHARGER_170W) { + printk(BIOS_INFO, "PL124: Performance.\n"); + *total_entries = ARRAY_SIZE(perf_limits); + return perf_limits; } else { - if (watts >= CHARGER_90W) { - printk(BIOS_INFO, "PL124: Performance.\n"); - total_entries = ARRAY_SIZE(perf_limits); - change_power_limits(perf_limits, total_entries); - } else { - printk(BIOS_INFO, "PL124: Baseline.\n"); - total_entries = ARRAY_SIZE(baseline_limits); - change_power_limits(baseline_limits, total_entries); - } + printk(BIOS_INFO, "PL124: Baseline.\n"); + *total_entries = ARRAY_SIZE(baseline_limits); + return baseline_limits; } } else { - printk(BIOS_INFO, "EC cmd failure: PL124: Baseline.\n"); - total_entries = ARRAY_SIZE(baseline_limits); - change_power_limits(baseline_limits, total_entries); + if (watts >= CHARGER_90W) { + printk(BIOS_INFO, "PL124: Performance.\n"); + *total_entries = ARRAY_SIZE(perf_limits); + return perf_limits; + } else { + printk(BIOS_INFO, "PL124: Baseline.\n"); + *total_entries = ARRAY_SIZE(baseline_limits); + return baseline_limits; + } } } +static void update_power_limits(void) +{ + size_t entries; + const struct cpu_power_limits *power_limit; + power_limit = get_power_limit(&entries); + variant_update_psys_power_limits(power_limit, sys_limits, entries, &psys_config); + variant_update_power_limits(power_limit, entries); +} + void variant_devtree_update(void) { update_power_limits(); |