Gaggery Tsai has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: [WIP] Add a voltage parameter for getting info from USB PD ......................................................................
[WIP] Add a voltage parameter for getting info from USB PD
This patch adds a voltage parameter in google_chromeec_get_usb_pd_power_info. For some application, we need the voltage information.
BUG=b:151972149 TEST=emerge-puff coreboot; emerge-fizz coreboot
Change-Id: I11efe6f45f2f929fcb2763d192268e677d7426cb Signed-off-by: Gaggery Tsai gaggery.tsai@intel.com --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h M src/mainboard/google/fizz/mainboard.c M src/mainboard/google/hatch/variants/puff/mainboard.c 4 files changed, 7 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/39849/1
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 8f1f864..78f808c 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1128,7 +1128,7 @@
/* Get charger power info in Watts. Also returns type of charger */ int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type, - uint32_t *max_watts) + uint32_t *max_watts, uint16_t *mini_volts) { struct ec_params_usb_pd_power_info params = { .port = PD_POWER_CHARGING_PORT, @@ -1154,7 +1154,7 @@ *type = resp.type; m = resp.meas; *max_watts = (m.current_max * m.voltage_max) / 1000000; - + *mini_volts = m.voltage_max; return 0; }
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index 60afb50..9b46ad9 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -109,7 +109,7 @@ * @return non-zero for error, otherwise 0. */ int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type, - uint32_t *max_watts); + uint32_t *max_watts, uint16_t *mini_volts);
/* * Set max current and voltage of a dedicated charger. diff --git a/src/mainboard/google/fizz/mainboard.c b/src/mainboard/google/fizz/mainboard.c index 6bb298b..7464b9f 100644 --- a/src/mainboard/google/fizz/mainboard.c +++ b/src/mainboard/google/fizz/mainboard.c @@ -115,8 +115,9 @@ { enum usb_chg_type type; u32 watts; + u16 mini_volts; u32 pl2, psyspl2; - int rv = google_chromeec_get_usb_pd_power_info(&type, &watts); + int rv = google_chromeec_get_usb_pd_power_info(&type, &watts, &mini_volts); uint8_t sku = board_sku_id(); const uint32_t u42_mask = (1 << FIZZ_SKU_ID_I7_U42) | (1 << FIZZ_SKU_ID_I5_U42) | diff --git a/src/mainboard/google/hatch/variants/puff/mainboard.c b/src/mainboard/google/hatch/variants/puff/mainboard.c index 7dcd8c7..f00f47f 100644 --- a/src/mainboard/google/hatch/variants/puff/mainboard.c +++ b/src/mainboard/google/hatch/variants/puff/mainboard.c @@ -101,8 +101,9 @@ { enum usb_chg_type type; u32 watts; + u16 mini_volts; u32 psyspl2 = PUFF_PSYSPL2; // default barrel jack value for U22 - int rv = google_chromeec_get_usb_pd_power_info(&type, &watts); + int rv = google_chromeec_get_usb_pd_power_info(&type, &watts, &mini_volts);
/* use SoC default value for PsysPL3 and PL4 unless we're on USB-PD*/ conf->tdp_psyspl3 = 0;
Harry Pan has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: [WIP] Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 1: Code-Review+1
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: [WIP] Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 1:
(5 comments)
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG@7 PS1, Line 7: [WIP] Add a voltage parameter for getting info from USB PD Please add a prefix.
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG@10 PS1, Line 10: For some application Please list one as an example.
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG@10 PS1, Line 10: application applications
https://review.coreboot.org/c/coreboot/+/39849/1/src/ec/google/chromeec/ec.c File src/ec/google/chromeec/ec.c:
https://review.coreboot.org/c/coreboot/+/39849/1/src/ec/google/chromeec/ec.c... PS1, Line 1157: *mini_volts = m.voltage_max; Why not use `voltage_max` as variable name?
https://review.coreboot.org/c/coreboot/+/39849/1/src/mainboard/google/fizz/m... File src/mainboard/google/fizz/mainboard.c:
https://review.coreboot.org/c/coreboot/+/39849/1/src/mainboard/google/fizz/m... PS1, Line 118: mini_volts What is *mini*? Minimum? I know of *min* and *max* as common abbreviations.
Gaggery Tsai has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: [WIP] Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39849/1/src/ec/google/chromeec/ec.c File src/ec/google/chromeec/ec.c:
https://review.coreboot.org/c/coreboot/+/39849/1/src/ec/google/chromeec/ec.c... PS1, Line 1157: *mini_volts = m.voltage_max;
Why not use `voltage_max` as variable name?
oh.. it's milli volts ==> mV. I think the comment already put the units, I can modify it to voltage_max.
Gaggery Tsai has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: [WIP] Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39849/1/src/mainboard/google/fizz/m... File src/mainboard/google/fizz/mainboard.c:
https://review.coreboot.org/c/coreboot/+/39849/1/src/mainboard/google/fizz/m... PS1, Line 118: mini_volts
What is *mini*? Minimum? I know of *min* and *max* as common abbreviations.
sorry, it's milliVolts, will modify it.
Gaggery Tsai has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: [WIP] Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 1:
(3 comments)
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG@7 PS1, Line 7: [WIP] Add a voltage parameter for getting info from USB PD
Please add a prefix.
The changes across API definition and mainboards. What's the suggested prefix?
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG@10 PS1, Line 10: For some application
Please list one as an example.
Ack
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG@10 PS1, Line 10: application
applications
Ack
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: [WIP] Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG@7 PS1, Line 7: [WIP] Add a voltage parameter for getting info from USB PD
The changes across API definition and mainboards. […]
google/chromeec: …
Hello build bot (Jenkins), Jamie Chen, Harry Pan,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39849
to look at the new patch set (#2).
Change subject: Add a voltage parameter for getting info from USB PD ......................................................................
Add a voltage parameter for getting info from USB PD
This patch adds a voltage parameter in google_chromeec_get_usb_pd_power_info. For some applications, we need the voltage information to calculate correct system power power eg PsysPmax.
BUG=b:151972149 TEST=emerge-puff coreboot; emerge-fizz coreboot
Change-Id: I11efe6f45f2f929fcb2763d192268e677d7426cb Signed-off-by: Gaggery Tsai gaggery.tsai@intel.com --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h M src/mainboard/google/fizz/mainboard.c M src/mainboard/google/hatch/variants/puff/mainboard.c 4 files changed, 8 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/39849/2
Hello build bot (Jenkins), Jamie Chen, Harry Pan,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39849
to look at the new patch set (#3).
Change subject: google/chromeec: Add a voltage parameter for getting info from USB PD ......................................................................
google/chromeec: Add a voltage parameter for getting info from USB PD
This patch adds a voltage parameter in google_chromeec_get_usb_pd_power_info. For some applications, we need the voltage information to calculate correct system power power eg PsysPmax.
BUG=b:151972149 TEST=emerge-puff coreboot; emerge-fizz coreboot
Change-Id: I11efe6f45f2f929fcb2763d192268e677d7426cb Signed-off-by: Gaggery Tsai gaggery.tsai@intel.com --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h M src/mainboard/google/fizz/mainboard.c M src/mainboard/google/hatch/variants/puff/mainboard.c 4 files changed, 8 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/39849/3
Jamie Chen has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: google/chromeec: Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 3: Code-Review+1
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: google/chromeec: Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 3: Code-Review+1
(1 comment)
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c File src/ec/google/chromeec/ec.c:
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c... PS3, Line 1131: t *max_watts, uint16_t *voltage_max maybe this function should have returned I and V instead and do the multiplication at the call site for power in watts? I think that would be a more well considered change if you went in that direction.
Gaggery Tsai has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: google/chromeec: Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c File src/ec/google/chromeec/ec.c:
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c... PS3, Line 1131: t *max_watts, uint16_t *voltage_max
maybe this function should have returned I and V instead and do the multiplication at the call site […]
How about return all three data (power, voltage and current)? Otherwise, I have to find a fizz to ensure the V*I equals to the power returned from EC.
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: google/chromeec: Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c File src/ec/google/chromeec/ec.c:
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c... PS3, Line 1131: t *max_watts, uint16_t *voltage_max
How about return all three data (power, voltage and current)? Otherwise, I have to find a fizz to en […]
What's the purpose of returning I and V separately? Do the PL calculations depend on the voltage or do they depend on power? It seems disingenuous to return I, V, and P, if you weren't certain that I*V=P. Otherwise, what do the different values really mean?
Gaggery Tsai has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: google/chromeec: Add a voltage parameter for getting info from USB PD ......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c File src/ec/google/chromeec/ec.c:
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c... PS3, Line 1131: t *max_watts, uint16_t *voltage_max
What's the purpose of returning I and V separately? Do the PL calculations depend on the voltage or […]
For Puff design, it needs Voltage information to calculate correct Psys. I think we can return I/V as Edward suggested.
Hello Shelley Chen, build bot (Jenkins), Furquan Shaikh, Jamie Chen, Kangheui Won, Harry Pan, Tim Wawrzynczak, Edward O'Callaghan, Dossym Nurmukhanov, Gaggery Tsai,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39849
to look at the new patch set (#4).
Change subject: google/chromeec: Revise parameters of EC USB PD API call ......................................................................
google/chromeec: Revise parameters of EC USB PD API call
This patch adds voltage and cuurent parameters in google_chromeec_get_usb_pd_power_info and remove power parameter. Caller could use the voltage and current information to calculate charger power rating. The reason for this change is, some applications need the voltage information to calculate correct system power eg PsysPmax.
BUG=b:151972149 TEST=emerge-puff coreboot; emerge-fizz coreboot
Change-Id: I11efe6f45f2f929fcb2763d192268e677d7426cb Signed-off-by: Gaggery Tsai gaggery.tsai@intel.com --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h M src/mainboard/google/fizz/mainboard.c M src/mainboard/google/hatch/variants/puff/mainboard.c 4 files changed, 13 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/39849/4
Edward O'Callaghan has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: google/chromeec: Revise parameters of EC USB PD API call ......................................................................
Patch Set 4: Code-Review+2
(1 comment)
https://review.coreboot.org/c/coreboot/+/39849/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39849/4//COMMIT_MSG@9 PS4, Line 9: cuurent current
Hello Shelley Chen, build bot (Jenkins), Furquan Shaikh, Jamie Chen, Kangheui Won, Harry Pan, Tim Wawrzynczak, Edward O'Callaghan, Gaggery Tsai, Dossym Nurmukhanov,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39849
to look at the new patch set (#5).
Change subject: google/chromeec: Revise parameters of EC USB PD API call ......................................................................
google/chromeec: Revise parameters of EC USB PD API call
This patch adds voltage and curent parameters in google_chromeec_get_usb_pd_power_info and remove power parameter. Caller could use the voltage and current information to calculate charger power rating. The reason for this change is, some applications need the voltage information to calculate correct system power eg PsysPmax.
BUG=b:151972149 TEST=emerge-puff coreboot; emerge-fizz coreboot
Change-Id: I11efe6f45f2f929fcb2763d192268e677d7426cb Signed-off-by: Gaggery Tsai gaggery.tsai@intel.com --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h M src/mainboard/google/fizz/mainboard.c M src/mainboard/google/hatch/variants/puff/mainboard.c 4 files changed, 13 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/49/39849/5
Gaggery Tsai has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: google/chromeec: Revise parameters of EC USB PD API call ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/coreboot/+/39849/4//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39849/4//COMMIT_MSG@9 PS4, Line 9: cuurent
current
Ack
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: google/chromeec: Revise parameters of EC USB PD API call ......................................................................
Patch Set 5:
(2 comments)
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/39849/1//COMMIT_MSG@7 PS1, Line 7: [WIP] Add a voltage parameter for getting info from USB PD
google/chromeec: …
Done
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c File src/ec/google/chromeec/ec.c:
https://review.coreboot.org/c/coreboot/+/39849/3/src/ec/google/chromeec/ec.c... PS3, Line 1131: t *max_watts, uint16_t *voltage_max
For Puff design, it needs Voltage information to calculate correct Psys. […]
Done
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/39849 )
Change subject: google/chromeec: Revise parameters of EC USB PD API call ......................................................................
google/chromeec: Revise parameters of EC USB PD API call
This patch adds voltage and curent parameters in google_chromeec_get_usb_pd_power_info and remove power parameter. Caller could use the voltage and current information to calculate charger power rating. The reason for this change is, some applications need the voltage information to calculate correct system power eg PsysPmax.
BUG=b:151972149 TEST=emerge-puff coreboot; emerge-fizz coreboot
Change-Id: I11efe6f45f2f929fcb2763d192268e677d7426cb Signed-off-by: Gaggery Tsai gaggery.tsai@intel.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/39849 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Edward O'Callaghan quasisec@chromium.org --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h M src/mainboard/google/fizz/mainboard.c M src/mainboard/google/hatch/variants/puff/mainboard.c 4 files changed, 13 insertions(+), 8 deletions(-)
Approvals: build bot (Jenkins): Verified Edward O'Callaghan: Looks good to me, approved
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 17e110c..73baec6 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1120,9 +1120,9 @@ return google_chromeec_command(&cmd); }
-/* Get charger power info in Watts. Also returns type of charger */ +/* Get charger voltage and current. Also returns type of charger */ int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type, - uint32_t *max_watts) + uint16_t *current_max, uint16_t *voltage_max) { struct ec_params_usb_pd_power_info params = { .port = PD_POWER_CHARGING_PORT, @@ -1147,8 +1147,8 @@ /* values are given in milliAmps and milliVolts */ *type = resp.type; m = resp.meas; - *max_watts = (m.current_max * m.voltage_max) / 1000000; - + *voltage_max = m.voltage_max; + *current_max = m.current_max; return 0; }
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index 13e3bd9..64d7e52 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -102,11 +102,12 @@ * Retrieve the charger type and max wattage. * * @param type charger type - * @param max_watts charger max wattage + * @param current_max charger max current + * @param voltage_max charger max voltage * @return non-zero for error, otherwise 0. */ int google_chromeec_get_usb_pd_power_info(enum usb_chg_type *type, - uint32_t *max_watts); + uint16_t *current_max, uint16_t *voltage_max);
/* * Set max current and voltage of a dedicated charger. diff --git a/src/mainboard/google/fizz/mainboard.c b/src/mainboard/google/fizz/mainboard.c index daf9da4..9f35411 100644 --- a/src/mainboard/google/fizz/mainboard.c +++ b/src/mainboard/google/fizz/mainboard.c @@ -104,8 +104,9 @@ { enum usb_chg_type type; u32 watts; + u16 volts_mv, current_ma; u32 pl2, psyspl2; - int rv = google_chromeec_get_usb_pd_power_info(&type, &watts); + int rv = google_chromeec_get_usb_pd_power_info(&type, ¤t_ma, &volts_mv); uint8_t sku = board_sku_id(); const uint32_t u42_mask = (1 << FIZZ_SKU_ID_I7_U42) | (1 << FIZZ_SKU_ID_I5_U42) | @@ -126,6 +127,7 @@ psyspl2 = FIZZ_PSYSPL2_U42; } else { /* Detected TypeC. Base on max value of adapter */ + watts = ((u32)volts_mv * current_ma) / 1000000; psyspl2 = watts; conf->tdp_psyspl3 = SET_PSYSPL2(psyspl2); /* set max possible time window */ diff --git a/src/mainboard/google/hatch/variants/puff/mainboard.c b/src/mainboard/google/hatch/variants/puff/mainboard.c index e8098b9..3f74c96 100644 --- a/src/mainboard/google/hatch/variants/puff/mainboard.c +++ b/src/mainboard/google/hatch/variants/puff/mainboard.c @@ -90,8 +90,9 @@ { enum usb_chg_type type; u32 watts; + u16 volts_mv, current_ma; u32 psyspl2 = PUFF_PSYSPL2; // default barrel jack value for U22 - int rv = google_chromeec_get_usb_pd_power_info(&type, &watts); + int rv = google_chromeec_get_usb_pd_power_info(&type, ¤t_ma, &volts_mv);
/* use SoC default value for PsysPL3 and PL4 unless we're on USB-PD*/ conf->tdp_psyspl3 = 0; @@ -99,6 +100,7 @@
if (rv == 0 && type == USB_CHG_TYPE_PD) { /* Detected USB-PD. Base on max value of adapter */ + watts = ((u32)current_ma * volts_mv) / 1000000; psyspl2 = watts; conf->tdp_psyspl3 = SET_PSYSPL2(psyspl2); /* set max possible time window */