Hello Tim Chen,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/40828
to review the following change.
Change subject: mb/google/hatch/vr/puff: Add psys_pmax calculation
......................................................................
mb/google/hatch/vr/puff: Add psys_pmax calculation
This patch adds psys_pmax calculation. There are two types of power
sources. One is barrel jack and the other is USB TYPE-C. The voltage
level is fixed for a barrel jack while TYPE-C may vary depending
on power ratings. We need to get voltage information from
EC and calculate correct psys_pmax value. The psys_pmax needs to be
set before FSP-S since FSP-S will handle the setting passing to pcode,
so move the routine ahead to variant_ramstage_init.
BUG=b:151972149
TEST=emerge-puff coreboot chromeos-bootimage
check firmware log and ensure psys_pmax is passed to FSP
check the data from dump_intel_rapl_consumption in the OS and
ensure the power data is close to an external power meter.
Change-Id: Iff767d4b44a01e766258345545438a54a16d1af5
Signed-off-by: Tim Chen <tim-chen(a)quanta.corp-partner.google.com>
---
M src/mainboard/google/hatch/variants/duffy/mainboard.c
M src/mainboard/google/hatch/variants/kaisa/mainboard.c
2 files changed, 74 insertions(+), 36 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/28/40828/1
diff --git a/src/mainboard/google/hatch/variants/duffy/mainboard.c b/src/mainboard/google/hatch/variants/duffy/mainboard.c
index 3f74c96..ceeb0c5 100644
--- a/src/mainboard/google/hatch/variants/duffy/mainboard.c
+++ b/src/mainboard/google/hatch/variants/duffy/mainboard.c
@@ -31,23 +31,6 @@
stopwatch_duration_msecs(&sw));
}
-void variant_ramstage_init(void)
-{
- static const long display_timeout_ms = 3000;
-
- /* This is reconfigured back to whatever FSP-S expects by
- gpio_configure_pads. */
- gpio_input(GPIO_HDMI_HPD);
- gpio_input(GPIO_DP_HPD);
- if (display_init_required()
- && !gpio_get(GPIO_HDMI_HPD)
- && !gpio_get(GPIO_DP_HPD)) {
- /* This has to be done before FSP-S runs. */
- if (google_chromeec_wait_for_displayport(display_timeout_ms))
- wait_for_hpd(GPIO_DP_HPD, display_timeout_ms);
- }
-}
-
/*
* For type-C chargers, set PL2 to 90% of max power to account for
* cable loss and FET Rdson loss in the path from the source.
@@ -86,6 +69,24 @@
* | n (U22) | 29 | .9n | .9n | x(43) |
* +-------------+-----+---------+---------+-------+
*/
+
+/*
+ * Psys_pmax considerations
+ *
+ * Given the hardware design in puff, the serial shunt resistor is 0.01ohm.
+ * The full scale of hardware PSYS signal 0.8v maps to system current 9.6A
+ * instead of real system power. The equation is shown below:
+ * PSYS = 0.8v = (0.01ohm x Iinput) x 50 (INA213, gain 50V/V) x 15k/(15k + 75k)
+ * Hence, Iinput (Amps) = 9.6A
+ * Since there is no voltage information from PSYS, different voltage input
+ * would map to different Psys_pmax settings:
+ * For Type-C 15V, the Psys_pmax sholud be 15v x 9.6A = 144W
+ * For Type-C 20V, the Psys_pmax should be 20v x 9.6A = 192W
+ * For a barral jack, the Psys_pmax should be 19v x 9.6A = 182.4W
+ */
+#define PSYS_IMAX 9600
+#define BJ_VOLTS_MV 19000
+
static void mainboard_set_power_limits(config_t *conf)
{
enum usb_chg_type type;
@@ -108,15 +109,33 @@
/* set minimum duty cycle */
conf->tdp_psyspl3_dutycycle = PUFF_MIN_DUTYCYCLE;
conf->tdp_pl4 = SET_PSYSPL2(psyspl2);
+ } else {
+ /* Input type is barrel jack */
+ volts_mv = BJ_VOLTS_MV;
}
+ /* voltage unit is milliVolts and current is in milliAmps */
+ conf->psys_pmax = (u16)(((u32)PSYS_IMAX * volts_mv) / 1000000);
conf->tdp_pl2_override = PUFF_PL2;
/* set psyspl2 to 90% of max adapter power */
conf->tdp_psyspl2 = SET_PSYSPL2(psyspl2);
}
-void variant_mainboard_enable(struct device *dev)
+void variant_ramstage_init(void)
{
+ static const long display_timeout_ms = 3000;
config_t *conf = config_of_soc();
+
+ /* This is reconfigured back to whatever FSP-S expects by gpio_configure_pads. */
+ gpio_input(GPIO_HDMI_HPD);
+ gpio_input(GPIO_DP_HPD);
+ if (display_init_required()
+ && !gpio_get(GPIO_HDMI_HPD)
+ && !gpio_get(GPIO_DP_HPD)) {
+ /* This has to be done before FSP-S runs. */
+ if (google_chromeec_wait_for_displayport(display_timeout_ms))
+ wait_for_hpd(GPIO_DP_HPD, display_timeout_ms);
+ }
+ /* Psys_pmax needs to be setup before FSP-S */
mainboard_set_power_limits(conf);
}
diff --git a/src/mainboard/google/hatch/variants/kaisa/mainboard.c b/src/mainboard/google/hatch/variants/kaisa/mainboard.c
index 3f74c96..ceeb0c5 100644
--- a/src/mainboard/google/hatch/variants/kaisa/mainboard.c
+++ b/src/mainboard/google/hatch/variants/kaisa/mainboard.c
@@ -31,23 +31,6 @@
stopwatch_duration_msecs(&sw));
}
-void variant_ramstage_init(void)
-{
- static const long display_timeout_ms = 3000;
-
- /* This is reconfigured back to whatever FSP-S expects by
- gpio_configure_pads. */
- gpio_input(GPIO_HDMI_HPD);
- gpio_input(GPIO_DP_HPD);
- if (display_init_required()
- && !gpio_get(GPIO_HDMI_HPD)
- && !gpio_get(GPIO_DP_HPD)) {
- /* This has to be done before FSP-S runs. */
- if (google_chromeec_wait_for_displayport(display_timeout_ms))
- wait_for_hpd(GPIO_DP_HPD, display_timeout_ms);
- }
-}
-
/*
* For type-C chargers, set PL2 to 90% of max power to account for
* cable loss and FET Rdson loss in the path from the source.
@@ -86,6 +69,24 @@
* | n (U22) | 29 | .9n | .9n | x(43) |
* +-------------+-----+---------+---------+-------+
*/
+
+/*
+ * Psys_pmax considerations
+ *
+ * Given the hardware design in puff, the serial shunt resistor is 0.01ohm.
+ * The full scale of hardware PSYS signal 0.8v maps to system current 9.6A
+ * instead of real system power. The equation is shown below:
+ * PSYS = 0.8v = (0.01ohm x Iinput) x 50 (INA213, gain 50V/V) x 15k/(15k + 75k)
+ * Hence, Iinput (Amps) = 9.6A
+ * Since there is no voltage information from PSYS, different voltage input
+ * would map to different Psys_pmax settings:
+ * For Type-C 15V, the Psys_pmax sholud be 15v x 9.6A = 144W
+ * For Type-C 20V, the Psys_pmax should be 20v x 9.6A = 192W
+ * For a barral jack, the Psys_pmax should be 19v x 9.6A = 182.4W
+ */
+#define PSYS_IMAX 9600
+#define BJ_VOLTS_MV 19000
+
static void mainboard_set_power_limits(config_t *conf)
{
enum usb_chg_type type;
@@ -108,15 +109,33 @@
/* set minimum duty cycle */
conf->tdp_psyspl3_dutycycle = PUFF_MIN_DUTYCYCLE;
conf->tdp_pl4 = SET_PSYSPL2(psyspl2);
+ } else {
+ /* Input type is barrel jack */
+ volts_mv = BJ_VOLTS_MV;
}
+ /* voltage unit is milliVolts and current is in milliAmps */
+ conf->psys_pmax = (u16)(((u32)PSYS_IMAX * volts_mv) / 1000000);
conf->tdp_pl2_override = PUFF_PL2;
/* set psyspl2 to 90% of max adapter power */
conf->tdp_psyspl2 = SET_PSYSPL2(psyspl2);
}
-void variant_mainboard_enable(struct device *dev)
+void variant_ramstage_init(void)
{
+ static const long display_timeout_ms = 3000;
config_t *conf = config_of_soc();
+
+ /* This is reconfigured back to whatever FSP-S expects by gpio_configure_pads. */
+ gpio_input(GPIO_HDMI_HPD);
+ gpio_input(GPIO_DP_HPD);
+ if (display_init_required()
+ && !gpio_get(GPIO_HDMI_HPD)
+ && !gpio_get(GPIO_DP_HPD)) {
+ /* This has to be done before FSP-S runs. */
+ if (google_chromeec_wait_for_displayport(display_timeout_ms))
+ wait_for_hpd(GPIO_DP_HPD, display_timeout_ms);
+ }
+ /* Psys_pmax needs to be setup before FSP-S */
mainboard_set_power_limits(conf);
}
--
To view, visit https://review.coreboot.org/c/coreboot/+/40828
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Iff767d4b44a01e766258345545438a54a16d1af5
Gerrit-Change-Number: 40828
Gerrit-PatchSet: 1
Gerrit-Owner: Tim Chen <Tim-Chen(a)quantatw.com>
Gerrit-Reviewer: Tim Chen <tim-chen(a)quanta.corp-partner.google.com>
Gerrit-MessageType: newchange
Ian Feng has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/40774 )
Change subject: mb/google/dedede: Enable USB port for camera support
......................................................................
mb/google/dedede: Enable USB port for camera support
Support USB Chicony user facing camera.
BUG=b:155109736
BRANCH=None
TEST=Build and Boot waddledoo board and able to capture image
using user facing camera.
Signed-off-by: Ian Feng <ian_feng(a)compal.corp-partner.google.com>
Change-Id: I7580a58086977e239dca49c1def4f03583831662
---
M src/mainboard/google/dedede/variants/baseboard/devicetree.cb
1 file changed, 6 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/74/40774/1
diff --git a/src/mainboard/google/dedede/variants/baseboard/devicetree.cb b/src/mainboard/google/dedede/variants/baseboard/devicetree.cb
index cfe221f..c7cf5db 100644
--- a/src/mainboard/google/dedede/variants/baseboard/devicetree.cb
+++ b/src/mainboard/google/dedede/variants/baseboard/devicetree.cb
@@ -32,7 +32,7 @@
register "usb2_ports[2]" = "USB2_PORT_MID(OC_SKIP)" # Type-A Port A0
register "usb2_ports[3]" = "USB2_PORT_MID(OC_SKIP)" # Type-A Port A1
register "usb2_ports[4]" = "USB2_PORT_MID(OC_SKIP)" # Discrete Bluetooth
- register "usb2_ports[5]" = "USB2_PORT_EMPTY" # Not Used
+ register "usb2_ports[5]" = "USB2_PORT_MID(OC_SKIP)" # Camera
register "usb2_ports[6]" = "USB2_PORT_EMPTY" # Not Used
register "usb2_ports[7]" = "USB2_PORT_MID(OC_SKIP)" # Integrated Bluetooth
@@ -212,6 +212,11 @@
device usb 2.4 on end
end
chip drivers/usb/acpi
+ register "desc" = ""Camera""
+ register "type" = "UPC_TYPE_INTERNAL"
+ device usb 2.5 on end
+ end
+ chip drivers/usb/acpi
register "desc" = ""Integrated Bluetooth""
register "type" = "UPC_TYPE_INTERNAL"
register "reset_gpio" = "ACPI_GPIO_OUTPUT_ACTIVE_LOW(GPP_H19)"
--
To view, visit https://review.coreboot.org/c/coreboot/+/40774
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I7580a58086977e239dca49c1def4f03583831662
Gerrit-Change-Number: 40774
Gerrit-PatchSet: 1
Gerrit-Owner: Ian Feng <ian_feng(a)compal.corp-partner.google.com>
Gerrit-MessageType: newchange