summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-09-14 18:12:22 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-09-25 18:35:26 -0700
commit13fb9ac539b9e85fd418b25da36e80a9be4aa292 (patch)
tree1b6ea3542e93c834bafff06ccba5e3711e9cfcb0
parent406302ffb09ecd0fa300b8faafea8e5cdcc1db07 (diff)
downloadchrome-ec-13fb9ac539b9e85fd418b25da36e80a9be4aa292.tar.gz
Fizz: Limit input current
Fizz has an over current control system. There are two FETs connected to two registers: PR257 & PR258. They control the max input current as follows: PR257, PR258 For 4.62A (90W BJ adapter), on, off For 3.33A (65W BJ adapter), off, on For 3.00A (Type-C adapter), off, off BJ adapters are distinguished by reading GPIO71. This patch also removes ISL9238 driver and ramping code. The charger chip has been removed from the board since proto2. BUG=b:65013352 BRANCH=none TEST=Boot Fizz Proto3 on BJ and Type-C. Change-Id: I32c2467f4ab23adf3f9313a03914d74d64a722df Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/668119 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--board/fizz/board.c68
-rw-r--r--board/fizz/board.h13
-rw-r--r--board/fizz/gpio.inc4
-rw-r--r--board/fizz/usb_pd_policy.c5
4 files changed, 36 insertions, 54 deletions
diff --git a/board/fizz/board.c b/board/fizz/board.c
index b57a0fa58f..6ce83044d2 100644
--- a/board/fizz/board.c
+++ b/board/fizz/board.c
@@ -379,52 +379,34 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
void board_set_charge_limit(int port, int supplier, int charge_ma,
int max_ma, int charge_mv)
{
- charger_set_input_current(charge_ma);
-}
-
-/**
- * Return whether ramping is allowed for given supplier
- */
-int board_is_ramp_allowed(int supplier)
-{
- /* Don't allow ramping in RO when write protected */
- if (!system_is_in_rw() && system_is_locked())
- return 0;
- else
- return (supplier == CHARGE_SUPPLIER_BC12_DCP ||
- supplier == CHARGE_SUPPLIER_BC12_SDP ||
- supplier == CHARGE_SUPPLIER_BC12_CDP ||
- supplier == CHARGE_SUPPLIER_OTHER);
-}
-
-/**
- * Return the maximum allowed input current
- */
-int board_get_ramp_current_limit(int supplier, int sup_curr)
-{
- switch (supplier) {
- case CHARGE_SUPPLIER_BC12_DCP:
- return 2000;
- case CHARGE_SUPPLIER_BC12_SDP:
- return 1000;
- case CHARGE_SUPPLIER_BC12_CDP:
- case CHARGE_SUPPLIER_PROPRIETARY:
- return sup_curr;
- default:
- return 500;
+ /*
+ * We have two FETs connected to two registers: PR257 & PR258.
+ * These control thresholds of the over current monitoring system.
+ *
+ * PR257, PR258
+ * For 4.62A (90W BJ adapter), on, off
+ * For 3.33A (65W BJ adapter), off, on
+ * For 3.00A (Type-C adapter), off, off
+ *
+ * The over current monitoring system doesn't support less than 3A
+ * (e.g. 2.25A, 2.00A). These current most likely won't be enough to
+ * power the system. However, if they're needed, EC can monitor
+ * PMON_PSYS and trigger H_PROCHOT by itself.
+ */
+ if (charge_ma >= 4620) {
+ gpio_set_level(GPIO_U42_P, 1);
+ gpio_set_level(GPIO_U22_C, 0);
+ } else if (charge_ma >= 3330) {
+ gpio_set_level(GPIO_U42_P, 0);
+ gpio_set_level(GPIO_U22_C, 1);
+ } else if (charge_ma >= 3000) {
+ gpio_set_level(GPIO_U42_P, 0);
+ gpio_set_level(GPIO_U22_C, 0);
+ } else {
+ CPRINTS("Current %dmA not supported", charge_mv);
}
}
-/**
- * Return if board is consuming full amount of input current
- */
-int board_is_consuming_full_charge(void)
-{
- int chg_perc = charge_get_percent();
-
- return chg_perc > 2 && chg_perc < 95;
-}
-
const struct button_config buttons[CONFIG_BUTTON_COUNT] = {
[BUTTON_RECOVERY] = {
.name = "Recovery",
diff --git a/board/fizz/board.h b/board/fizz/board.h
index f988fae2dc..c82d333ccb 100644
--- a/board/fizz/board.h
+++ b/board/fizz/board.h
@@ -62,19 +62,14 @@
/* Charger */
#define CONFIG_CHARGE_MANAGER
-#define CONFIG_CHARGE_RAMP_HW /* This, or just RAMP? */
+
+/* TODO(dnojiri): Set this right */
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 20000
-#define CONFIG_CHARGER_ISL9238
-#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_PSYS
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
-#define CONFIG_CMD_CHARGER_ADC_AMON_BMON
#define CONFIG_CMD_PD_CONTROL
#define CONFIG_EXTPOWER_GPIO
-#undef CONFIG_EXTPOWER_DEBOUNCE_MS
-#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
+#undef CONFIG_EXTPOWER_DEBOUNCE_MS
+#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
#define CONFIG_POWER_BUTTON
#define CONFIG_POWER_BUTTON_X86
#define CONFIG_POWER_BUTTON_INIT_IDLE
diff --git a/board/fizz/gpio.inc b/board/fizz/gpio.inc
index da1fbcab25..6ba6e25523 100644
--- a/board/fizz/gpio.inc
+++ b/board/fizz/gpio.inc
@@ -36,11 +36,13 @@ GPIO(PCH_PWRBTN_L, PIN(7, 4), GPIO_ODR_HIGH) /* Power Button to SOC */
GPIO(EC_PLATFORM_RST, PIN(A, 6), GPIO_OUT_LOW) /* EC Reset to LDO_EN */
GPIO(SYS_RESET_L, PIN(6, 1), GPIO_ODR_HIGH) /* Cold Reset to SOC */
GPIO(PMIC_SLP_SUS_L, PIN(8, 5), GPIO_OUT_LOW) /* SLP_SUS# to PMIC */
-GPIO(BATTERY_PRESENT_L, PIN(3, 4), GPIO_INPUT | GPIO_PULL_UP) /* Battery Present */
GPIO(CCD_MODE_ODL, PIN(6, 3), GPIO_INPUT) /* Case Closed Debug Mode */
GPIO(EC_HAVEN_RESET_ODL, PIN(0, 2), GPIO_ODR_HIGH) /* H1 Reset */
GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUTPUT) /* EC Entering RW */
GPIO(PMIC_INT_L, PIN(6, 0), GPIO_INPUT) /* PMIC interrupt */
+GPIO(U42_P, PIN(3, 3), GPIO_OUTPUT | GPIO_PULL_DOWN)
+GPIO(U22_C, PIN(3, 4), GPIO_OUTPUT | GPIO_PULL_DOWN)
+GPIO(POWER_RATE, PIN(7, 1), GPIO_INPUT) /* High: i3/5/7. Low: Celeron */
/* Fizz specific pins */
GPIO(LAN_PWR_EN, PIN(8, 3), GPIO_OUT_HIGH) /* Ethernet power enabled */
diff --git a/board/fizz/usb_pd_policy.c b/board/fizz/usb_pd_policy.c
index c64652ec8e..0213c22867 100644
--- a/board/fizz/usb_pd_policy.c
+++ b/board/fizz/usb_pd_policy.c
@@ -287,7 +287,10 @@ static void board_charge_manager_init(void)
break;
case CHARGE_PORT_BARRELJACK:
cpi.voltage = input_voltage;
- cpi.current = 3330; /* TODO(dnojiri): Set right value */
+ if (gpio_get_level(GPIO_POWER_RATE))
+ cpi.current = 4620;
+ else
+ cpi.current = 3330;
charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED, 1,
&cpi);
break;