summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDtrain Hsu <dtrain_hsu@compal.corp-partner.google.com>2022-06-20 14:38:43 +0800
committerFelix Held <felix-coreboot@felixheld.de>2022-06-22 18:09:56 +0000
commit121ff627689834c4d0517ae151eb355ad548d285 (patch)
tree082270e4188fbf932e5bd1927c3706cb53c4580c /src
parent6b0d0851645cf369e2fd08a2d11ffc441df7f7aa (diff)
mb/google/brya/var/kinox: Refactoring update_power_limits function
Based on 'commit 0b917bde36a7 ("mb/google/brya/var/kinox: Set power limit based on charger type")' to refactoring update_power_limits function for kinox. BUG=b:231911918 TEST=Build and boot to Chrome OS Signed-off-by: Dtrain Hsu <dtrain_hsu@compal.corp-partner.google.com> Change-Id: I1fcb593090f95bf23808e577dd11b8a836f47494 Reviewed-on: https://review.coreboot.org/c/coreboot/+/65242 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Subrata Banik <subratabanik@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/mainboard/google/brya/variants/kinox/ramstage.c68
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, &current_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();