Shelley Chen has uploaded this change for review. ( https://review.coreboot.org/21772
Change subject: google/fizz: Set PL2 value based on sku id/charge max power ......................................................................
google/fizz: Set PL2 value based on sku id/charge max power
Set PL2 based on either 90% of usb c charger's max power or sku id if using a barrel jack.
BUG=b:37473486 BRANCH=None TEST=output debug info for different skus and make sure PL2 set correctly.
Change-Id: I487fce4a5d0825a26488e71dee02400dbebbffb3 Signed-off-by: Shelley Chen shchen@chromium.org --- M src/mainboard/google/fizz/mainboard.c 1 file changed, 20 insertions(+), 12 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/72/21772/1
diff --git a/src/mainboard/google/fizz/mainboard.c b/src/mainboard/google/fizz/mainboard.c index 76fb2b8..1ced07e 100644 --- a/src/mainboard/google/fizz/mainboard.c +++ b/src/mainboard/google/fizz/mainboard.c @@ -18,7 +18,9 @@ #include <chip.h> #include <device/device.h> #include <ec/ec.h> -#include <intelblocks/mp_init.h> +#include <ec/google/chromeec/ec.h> +#include <gpio.h> +#include <soc/gpio.h> #include <soc/pci_devs.h> #include <soc/nhlt.h> #include <vendorcode/google/chromeos/chromeos.h> @@ -29,23 +31,29 @@ /* * mainboard_get_pl2 * - * @return value Pl2 should be set to based on cpu id + * @return value Pl2 should be set to * - * TODO: This is purely based on cpu id, which only works for the - * current build because we have a different cpu id per sku. However, - * on the next build, we'll have distinct board ids per sku. We'll - * need to modify that at this point. + * Check if charger is USB C. If so, set to 90% of the max value. + * Otherwise, set PL2 based on sku id. */ static u32 mainboard_get_pl2(void) { - struct cpuid_result cpuidr; + u32 watts = 0.9 * google_chromeec_get_usb_pd_power_info(); + int sku_id;
- cpuidr = cpuid(1); - if (cpuidr.eax == CPUID_KABYLAKE_Y0) { - /* i7 needs higher pl2 */ - return 44; + if (watts == 0) { + /* using the barrel jack, get PL2 based on sku id */ + watts = 29; + sku_id = gpio_get(GPP_C15) << 3 | + gpio_get(GPP_C14) << 2 | + gpio_get(GPP_C13) << 1 | + gpio_get(GPP_C12); + if (sku_id == 0x4) { + /* u42 i7 needs higher pl2. Everything else is 29 */ + watts = 44; + } } - return 29; + return watts; }
static void mainboard_init(device_t dev)