diff options
author | Scott Collyer <scollyer@google.com> | 2018-07-03 17:14:25 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-07-31 16:37:20 -0700 |
commit | fa96abba710e10638d783e1c753c3dc523b0226c (patch) | |
tree | a77d354210d79baafa60ea3f336242258c596a8b /board/dragonegg | |
parent | 10aa31c7bf2a6a9637a6c2a286df992b8510a4ba (diff) | |
download | chrome-ec-fa96abba710e10638d783e1c753c3dc523b0226c.tar.gz |
DragonEgg: Add support for Type C port 0, charging, and battery
BRANCH=none
BUG=b:111281797
TEST=make buildall
Change-Id: I2f4342f2c9ddfb4a6b2debbf94c1b0589227b58c
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1135928
Commit-Ready: Jett Rink <jettrink@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'board/dragonegg')
-rw-r--r-- | board/dragonegg/battery.c | 65 | ||||
-rw-r--r-- | board/dragonegg/board.c | 18 | ||||
-rw-r--r-- | board/dragonegg/board.h | 9 | ||||
-rw-r--r-- | board/dragonegg/build.mk | 1 | ||||
-rw-r--r-- | board/dragonegg/ec.tasklist | 3 | ||||
-rw-r--r-- | board/dragonegg/gpio.inc | 6 |
6 files changed, 102 insertions, 0 deletions
diff --git a/board/dragonegg/battery.c b/board/dragonegg/battery.c new file mode 100644 index 0000000000..ae583a0d40 --- /dev/null +++ b/board/dragonegg/battery.c @@ -0,0 +1,65 @@ +/* Copyright 2018 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery pack vendor provided charging profile + */ + +#include "battery_fuel_gauge.h" +#include "common.h" +#include "util.h" + +/* + * Battery info for all DragonEgg battery types. Note that the fields + * start_charging_min/max and charging_min/max are not used for the charger. + * The effective temperature limits are given by discharging_min/max_c. + * + * Fuel Gauge (FG) parameters which are used for determining if the battery + * is connected, the appropriate ship mode (battery cutoff) command, and the + * charge/discharge FETs status. + * + * Ship mode (battery cutoff) requires 2 writes to the appropriate smart battery + * register. For some batteries, the charge/discharge FET bits are set when + * charging/discharging is active, in other types, these bits set mean that + * charging/discharging is disabled. Therefore, in addition to the mask for + * these bits, a disconnect value must be specified. Note that for TI fuel + * gauge, the charge/discharge FET status is found in Operation Status (0x54), + * but a read of Manufacturer Access (0x00) will return the lower 16 bits of + * Operation status which contains the FET status bits. + * + * The assumption for battery types supported is that the charge/discharge FET + * status can be read with a sb_read() command and therefore, only the register + * address, mask, and disconnect value need to be provided. + */ +const struct board_batt_params board_battery_info[] = { + /* Panasonic AP1505L Battery Information */ + [BATTERY_0RD] = { + .fuel_gauge = { + .manuf_name = "SMP-COS5940", + .ship_mode = { + .reg_addr = 0x0, + .reg_data = { 0x10, 0x10 }, + }, + .fet = { + .reg_addr = 0x0, + .reg_mask = 0x2000, + .disconnect_val = 0x2000, + } + }, + .batt_info = { + .voltage_max = 8800, + .voltage_normal = 7700, /* mV */ + .voltage_min = 6000, /* mV */ + .precharge_current = 256, /* mA */ + .start_charging_min_c = 0, + .start_charging_max_c = 60, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 60, + }, + }, +}; +BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); + +const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_0RD; diff --git a/board/dragonegg/board.c b/board/dragonegg/board.c index 32d8c5da61..aa95e30478 100644 --- a/board/dragonegg/board.c +++ b/board/dragonegg/board.c @@ -6,8 +6,11 @@ /* DragonEgg board-specific configuration */ #include "common.h" +#include "console.h" +#include "driver/ppc/sn5s330.h" #include "extpower.h" #include "gpio.h" +#include "hooks.h" #include "intc.h" #include "lid_switch.h" #include "power.h" @@ -18,6 +21,12 @@ #include "uart.h" #include "util.h" +static void ppc_interrupt(enum gpio_signal signal) +{ + if (signal == GPIO_USB_C0_TCPPC_INT_L) + sn5s330_interrupt(0); +} + #include "gpio_list.h" /* Must come after other header files. */ /******************************************************************************/ @@ -26,3 +35,12 @@ const struct spi_device_t spi_devices[] = { }; const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); + +void board_overcurrent_event(int port) +{ + if (port == 0) { + /* TODO(b/111281797): When does this get set high again? */ + gpio_set_level(GPIO_USB_OC_ODL, 0); + cprints(CC_USBPD, "p%d: overcurrent!", port); + } +} diff --git a/board/dragonegg/board.h b/board/dragonegg/board.h index e5cc9b8ee0..9db2239b46 100644 --- a/board/dragonegg/board.h +++ b/board/dragonegg/board.h @@ -50,6 +50,15 @@ enum pwm_channel { PWM_CH_COUNT }; +/* List of possible batteries */ +enum battery_type { + BATTERY_0RD, + BATTERY_TYPE_COUNT, +}; + +int board_get_battery_soc(void); +void board_pd_vconn_ctrl(int port, int cc_pin, int enabled); + #endif /* !__ASSEMBLER__ */ #endif /* __CROS_EC_BOARD_H */ diff --git a/board/dragonegg/build.mk b/board/dragonegg/build.mk index 19b1ee2086..09726d3c63 100644 --- a/board/dragonegg/build.mk +++ b/board/dragonegg/build.mk @@ -12,3 +12,4 @@ CHIP_VARIANT:=it8320dx BASEBOARD:=dragonegg board-y=board.o +board-$(CONFIG_BATTERY_SMART)+=battery.o diff --git a/board/dragonegg/ec.tasklist b/board/dragonegg/ec.tasklist index 2ab483bd73..b6092a60a2 100644 --- a/board/dragonegg/ec.tasklist +++ b/board/dragonegg/ec.tasklist @@ -22,9 +22,12 @@ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \ + TASK_NOTEST(PDCMD, pd_command_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \ TASK_ALWAYS(POWERBTN, power_button_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(PD_C0, pd_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/board/dragonegg/gpio.inc b/board/dragonegg/gpio.inc index 28da3bd87e..2af749e406 100644 --- a/board/dragonegg/gpio.inc +++ b/board/dragonegg/gpio.inc @@ -28,6 +28,9 @@ GPIO_INT(SLP_SUS_L, PIN(G, 2), GPIO_INT_BOTH, power_signal_interrupt) GPIO_INT(PG_EC_RSMRST_ODL,PIN(E, 1), GPIO_INT_BOTH, power_signal_interrupt) GPIO_INT(PG_EC_DSW_PWROK, PIN(D, 6), GPIO_INT_BOTH, power_signal_interrupt) +/* USB-C interrupts */ +GPIO_INT(USB_C0_TCPPC_INT_L, PIN(B, 2), GPIO_INT_FALLING, ppc_interrupt) + /* Misc. interrupts */ /* TODO (b:110880394) Uncomment this when support for buttons is added */ /* GPIO_INT(VOL_DOWN_ODL, PIN(I, 6), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) */ @@ -58,6 +61,9 @@ GPIO(EC_PCH_RSMRST_L, PIN(H, 0), GPIO_OUT_HIGH) GPIO(EC_PROCHOT_ODL, PIN(D, 0), GPIO_ODR_HIGH) GPIO(PP5000_PG_OD, PIN(F, 0), GPIO_INPUT) +/* USB and USBC Signals */ +GPIO(USB_OC_ODL, PIN(J, 6), GPIO_ODR_HIGH) + /* I2C pins - Alternate function below configures I2C module on these pins */ GPIO(I2C0_SCL, PIN(B, 3), GPIO_INPUT) /* EC_PROG_SCL */ GPIO(I2C0_SDA, PIN(B, 4), GPIO_INPUT) /* EC_PROG_SDA */ |