summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam Flaherty <liamflaherty@chromium.org>2022-11-24 13:13:32 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-11-28 00:02:09 +0000
commita6dfae38361b8b63727c2ff0d3e3f17215cd773c (patch)
tree326650583372758d43beca31fe71d695ec9f8c3d
parente10c75edd1c17eb70f7faf9add22cb7f50e2eee2 (diff)
downloadchrome-ec-a6dfae38361b8b63727c2ff0d3e3f17215cd773c.tar.gz
dibbi: Update board specific power implementation
Removed battery and battery charging support, as dibbi does not have either of these. Added support for dual barrel-jack/USB-C power supplies and update USB PD policies accordingly. Added support for USB-C0 output load-switch. Made changes in dedede baseboard to allow alternate implementation of extpower_is_present with the absence of a charger chip. BUG=b:257377326 BRANCH=dedede TEST=make -j BOARD=dibbi Signed-off-by: Liam Flaherty <liamflaherty@chromium.org> Change-Id: I81d01a88caf174eb038685bf098686e8a310a9b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4054386 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Sam McNally <sammc@chromium.org> Reviewed-by: Adam Mills <adamjmills@google.com> Tested-by: Adam Mills <adamjmills@google.com>
-rw-r--r--baseboard/dedede/baseboard.c2
-rw-r--r--board/dibbi/battery.c331
-rw-r--r--board/dibbi/board.c429
-rw-r--r--board/dibbi/board.h105
-rw-r--r--board/dibbi/build.mk1
-rw-r--r--board/dibbi/ec.tasklist11
-rw-r--r--board/dibbi/gpio.inc27
-rw-r--r--board/dibbi/led.c54
-rw-r--r--board/dibbi/usb_pd_policy.c55
9 files changed, 338 insertions, 677 deletions
diff --git a/baseboard/dedede/baseboard.c b/baseboard/dedede/baseboard.c
index cd55f37588..22034a09bd 100644
--- a/baseboard/dedede/baseboard.c
+++ b/baseboard/dedede/baseboard.c
@@ -294,6 +294,7 @@ int board_is_i2c_port_powered(int port)
return chipset_in_state(CHIPSET_STATE_ANY_OFF) ? 0 : 1;
}
+#if defined(CONFIG_CHARGER_RAA489000) || defined(CONFIG_CHARGER_SM5803)
__overridable int extpower_is_present(void)
{
int port;
@@ -314,6 +315,7 @@ __overridable int extpower_is_present(void)
return 0;
}
+#endif
__override uint32_t board_override_feature_flags0(uint32_t flags0)
{
diff --git a/board/dibbi/battery.c b/board/dibbi/battery.c
deleted file mode 100644
index 99f458a4aa..0000000000
--- a/board/dibbi/battery.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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 "charge_state.h"
-#include "common.h"
-
-/*
- * Battery info for all waddledee 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[] = {
- /* LGC AC15A8J Battery Information */
- [BATTERY_LGC15] = {
- .fuel_gauge = {
- .manuf_name = "LGC",
- .device_name = "AC15A8J",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .mfgacc_support = 1,
- .reg_addr = 0x0,
- .reg_mask = 0x0002,
- .disconnect_val = 0x0,
- }
- },
- .batt_info = {
- .voltage_max = 13200,
- .voltage_normal = 11520, /* mV */
- .voltage_min = 9000, /* mV */
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* Panasonic AP1505L Battery Information */
- [BATTERY_PANASONIC_AP15O5L] = {
- .fuel_gauge = {
- .manuf_name = "PANASONIC",
- .device_name = "AP15O5L",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .reg_addr = 0x0,
- .reg_mask = 0x4000,
- .disconnect_val = 0x0,
- }
- },
- .batt_info = {
- .voltage_max = 13200,
- .voltage_normal = 11550, /* mV */
- .voltage_min = 9000, /* mV */
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* SANYO AC15A3J Battery Information */
- [BATTERY_SANYO] = {
- .fuel_gauge = {
- .manuf_name = "SANYO",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .reg_addr = 0x0,
- .reg_mask = 0x4000,
- .disconnect_val = 0x0,
- }
- },
- .batt_info = {
- .voltage_max = TARGET_WITH_MARGIN(13200, 5),
- .voltage_normal = 11550, /* mV */
- .voltage_min = 9000, /* mV */
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* Sony Ap13J4K Battery Information */
- [BATTERY_SONY] = {
- .fuel_gauge = {
- .manuf_name = "SONYCorp",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .reg_addr = 0x0,
- .reg_mask = 0x8000,
- .disconnect_val = 0x8000,
- .cfet_mask = 0x4000,
- .cfet_off_val = 0x4000,
- }
- },
- .batt_info = {
- .voltage_max = TARGET_WITH_MARGIN(13200, 5),
- .voltage_normal = 11400, /* mV */
- .voltage_min = 9000, /* mV */
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* Simplo AP13J7K Battery Information */
- [BATTERY_SMP_AP13J7K] = {
- .fuel_gauge = {
- .manuf_name = "SIMPLO",
- .device_name = "AP13J7K",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .mfgacc_support = 1,
- .reg_addr = 0x0,
- .reg_mask = 0x0002,
- .disconnect_val = 0x0000,
- }
- },
- .batt_info = {
- .voltage_max = 13050,
- .voltage_normal = 11400, /* mV */
- .voltage_min = 9000, /* mV */
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = 0,
- .discharging_max_c = 60,
- },
- },
-
- /* Panasonic AC15A3J Battery Information */
- [BATTERY_PANASONIC_AC15A3J] = {
- .fuel_gauge = {
- .manuf_name = "PANASONIC",
- .device_name = "AC15A3J",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .reg_addr = 0x0,
- .reg_mask = 0x4000,
- .disconnect_val = 0x0,
- }
- },
- .batt_info = {
- .voltage_max = 13200,
- .voltage_normal = 11550, /* mV */
- .voltage_min = 9000, /* mV */
- .precharge_current = 256, /* mA */
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = -20,
- .discharging_max_c = 75,
- },
- },
-
- /* LGC AP18C8K Battery Information */
- [BATTERY_LGC_AP18C8K] = {
- .fuel_gauge = {
- .manuf_name = "LGC KT0030G020",
- .device_name = "AP18C8K",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .reg_addr = 0x43,
- .reg_mask = 0x0001,
- .disconnect_val = 0x0,
- },
- },
- .batt_info = {
- .voltage_max = 13050,
- .voltage_normal = 11250,
- .voltage_min = 9000,
- .precharge_current = 256,
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = -20,
- .discharging_max_c = 75,
- },
- },
-
- /* Murata AP18C4K Battery Information */
- [BATTERY_MURATA_AP18C4K] = {
- .fuel_gauge = {
- .manuf_name = "Murata KT00304012",
- .device_name = "AP18C4K",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .reg_addr = 0x0,
- .reg_mask = 0x2000,
- .disconnect_val = 0x2000,
- },
- },
- .batt_info = {
- .voltage_max = 13200,
- .voltage_normal = 11400,
- .voltage_min = 9000,
- .precharge_current = 256,
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = -20,
- .discharging_max_c = 75,
- },
- },
-
- /* LGC AP19A8K Battery Information */
- [BATTERY_LGC_AP19A8K] = {
- .fuel_gauge = {
- .manuf_name = "LGC KTxxxxGxxx",
- .device_name = "AP19A8K",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .reg_addr = 0x43,
- .reg_mask = 0x0001,
- .disconnect_val = 0x0,
- .cfet_mask = 0x0002,
- .cfet_off_val = 0x0,
- },
- },
- .batt_info = {
- .voltage_max = 13200,
- .voltage_normal = 11550,
- .voltage_min = 9000,
- .precharge_current = 256,
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = -20,
- .discharging_max_c = 75,
- },
- },
-
- /* LGC KT0030G023 Battery Information */
- [BATTERY_LGC_G023] = {
- .fuel_gauge = {
- .manuf_name = "LGC KT0030G023",
- .device_name = "AP19A8K",
- .ship_mode = {
- .reg_addr = 0x3A,
- .reg_data = { 0xC574, 0xC574 },
- },
- .fet = {
- .reg_addr = 0x43,
- .reg_mask = 0x0001,
- .disconnect_val = 0x0,
- },
- },
- .batt_info = {
- .voltage_max = 13200,
- .voltage_normal = 11550,
- .voltage_min = 9000,
- .precharge_current = 256,
- .start_charging_min_c = 0,
- .start_charging_max_c = 50,
- .charging_min_c = 0,
- .charging_max_c = 60,
- .discharging_min_c = -20,
- .discharging_max_c = 75,
- },
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
-
-const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_PANASONIC_AC15A3J;
diff --git a/board/dibbi/board.c b/board/dibbi/board.c
index cba8bc64a4..9b3207859a 100644
--- a/board/dibbi/board.c
+++ b/board/dibbi/board.c
@@ -3,17 +3,13 @@
* found in the LICENSE file.
*/
-/* Waddledee board-specific configuration */
+/* Dibbi board-specific configuration */
#include "adc_chip.h"
#include "button.h"
#include "charge_manager.h"
#include "charge_state_v2.h"
#include "charger.h"
-#include "driver/accel_kionix.h"
-#include "driver/accelgyro_lsm6dsm.h"
-#include "driver/bc12/pi3usb9201.h"
-#include "driver/charger/sm5803.h"
#include "driver/temp_sensor/thermistor.h"
#include "driver/tcpm/it83xx_pd.h"
#include "driver/usb_mux/it5205.h"
@@ -38,53 +34,6 @@
#define CPRINTUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define INT_RECHECK_US 5000
-
-/* TODO(b/257377326) remove SM5803 references */
-
-/* C0 interrupt line shared by BC 1.2 and charger */
-static void check_c0_line(void);
-DECLARE_DEFERRED(check_c0_line);
-
-static void notify_c0_chips(void)
-{
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
- sm5803_interrupt(0);
-}
-
-static void check_c0_line(void)
-{
- /*
- * If line is still being held low, see if there's more to process from
- * one of the chips
- */
- if (!gpio_get_level(GPIO_USB_C0_INT_ODL)) {
- notify_c0_chips();
- hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
- }
-}
-
-static void usb_c0_interrupt(enum gpio_signal s)
-{
- /* Cancel any previous calls to check the interrupt line */
- hook_call_deferred(&check_c0_line_data, -1);
-
- /* Notify all chips using this line that an interrupt came in */
- notify_c0_chips();
-
- /* Check the line again in 5ms */
- hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
-}
-
-static void c0_ccsbu_ovp_interrupt(enum gpio_signal s)
-{
- cprints(CC_USBPD, "C0: CC OVP, SBU OVP, or thermal event");
- pd_handle_cc_overvoltage(0);
-}
-
-/* Must come after other header files and interrupt handler declarations */
-#include "gpio_list.h"
-
/* ADC channels */
const struct adc_t adc_channels[] = {
[ADC_VSNS_PP3300_A] = { .name = "PP3300_A_PGOOD",
@@ -102,33 +51,19 @@ const struct adc_t adc_channels[] = {
.factor_div = ADC_READ_MAX + 1,
.shift = 0,
.channel = CHIP_ADC_CH3 },
- [ADC_SUB_ANALOG] = { .name = "SUB_ANALOG",
- .factor_mul = ADC_MAX_MVOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- .channel = CHIP_ADC_CH13 },
+ [ADC_PPVAR_PWR_IN_IMON] = { .name = "ADC_PPVAR_PWR_IN_IMON",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH15 },
+ [ADC_SNS_PPVAR_PWR_IN] = { .name = "ADC_SNS_PPVAR_PWR_IN",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH16 },
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-/* BC 1.2 chips */
-const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
- {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- .flags = PI3USB9201_ALWAYS_POWERED,
- },
-};
-
-/* Charger chips */
-const struct charger_config_t chg_chips[] = {
- [CHARGER_SOLO] = {
- /* TODO(b/257377326) change - SM5803 not in use */
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = SM5803_ADDR_CHARGER_FLAGS,
- .drv = &sm5803_drv,
- },
-};
-
/* TCPCs */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
@@ -150,31 +85,62 @@ const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-void board_init(void)
-{
- int on;
+/* USB-A ports */
+const int usb_port_enable[USB_PORT_COUNT] = {
+ GPIO_EN_USB_A0_VBUS,
+ GPIO_EN_USB_A1_VBUS,
+ GPIO_EN_USB_A2_VBUS,
+};
+
+/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
+const struct pwm_t pwm_channels[] = {
+ [PWM_CH_LED_RED] = {
+ .channel = 1,
+ .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
+ .freq_hz = 2400,
+ },
+
+ [PWM_CH_LED_GREEN] = {
+ .channel = 2,
+ .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
+ .freq_hz = 2400,
+ },
- if (system_get_board_version() <= 0) {
- /* TODO(b/257377326) possibly update/delete */
- pd_set_max_voltage(5000);
+ [PWM_CH_LED_BLUE] = {
+ .channel = 3,
+ .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
+ .freq_hz = 2400,
}
- gpio_enable_interrupt(GPIO_USB_C0_INT_ODL);
+};
+BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
- /*
- * If interrupt lines are already low, schedule them to be processed
- * after inits are completed.
- */
- check_c0_line();
+/* Thermistors */
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_1] = { .name = "Memory",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_1 },
+ [TEMP_SENSOR_2] = { .name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_2 },
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
- gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL);
+static void c0_ccsbu_ovp_interrupt(enum gpio_signal s)
+{
+ cprints(CC_USBPD, "C0: CC OVP, SBU OVP, or thermal event");
+ pd_handle_cc_overvoltage(0);
+}
- /* Charger on the MB will be outputting PROCHOT_ODL and OD CHG_DET */
- sm5803_configure_gpio0(CHARGER_SOLO, GPIO0_MODE_PROCHOT, 1);
- sm5803_configure_chg_det_od(CHARGER_SOLO, 1);
+void board_init(void)
+{
+ int on;
- /* Charger on the sub-board will be a push-pull GPIO */
- sm5803_configure_gpio0(CHARGER_SOLO, GPIO0_MODE_OUTPUT, 0);
+ gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL);
+ gpio_enable_interrupt(GPIO_BJ_ADP_PRESENT_L);
+ gpio_enable_interrupt(GPIO_USBC_ADP_PRESENT_L);
/* Turn on 5V if the system is on, otherwise turn it off */
on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND |
@@ -183,27 +149,6 @@ void board_init(void)
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-static void board_resume(void)
-{
- sm5803_disable_low_power_mode(CHARGER_SOLO);
-}
-DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_resume, HOOK_PRIO_DEFAULT);
-
-static void board_suspend(void)
-{
- sm5803_enable_low_power_mode(CHARGER_SOLO);
-}
-DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_suspend, HOOK_PRIO_DEFAULT);
-
-void board_hibernate(void)
-{
- /*
- * Put all charger ICs present into low power mode before entering
- * z-state.
- */
- sm5803_hibernate(CHARGER_SOLO);
-}
-
void board_reset_pd_mcu(void)
{
/*
@@ -214,55 +159,27 @@ void board_reset_pd_mcu(void)
__override void board_power_5v_enable(int enable)
{
/*
- * Motherboard has a GPIO to turn on the 5V regulator, but the sub-board
- * sets it through the charger GPIO.
+ * Mainboard 5V regulator activated by GPIO.
+ * USB-A ports are activated by usb_port_power_dumb.
*/
gpio_set_level(GPIO_EN_PP5000, !!enable);
- gpio_set_level(GPIO_EN_USB_A0_VBUS, !!enable);
- if (sm5803_set_gpio0_level(1, !!enable))
- CPRINTUSB("Failed to %sable sub rails!", enable ? "en" : "dis");
}
-uint16_t tcpc_get_alert_status(void)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
+ int charge_mv)
{
- /*
- * TCPC 0 is embedded in the EC and processes interrupts in the chip
- * code (it83xx/intc.c)
- */
- return 0;
+ int insufficient_power =
+ (charge_ma * charge_mv) <
+ (CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON * 1000);
+ /* TODO(b/259467280) blink LED on error */
+ (void)insufficient_power;
}
-int board_set_active_charge_port(int port)
+int board_vbus_source_enabled(int port)
{
- /*
- * TODO(b/257377326) since this now enable/disable on one port, look
- * into updating this method
- */
- int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count());
-
- if (!is_valid_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- if (port == CHARGE_PORT_NONE) {
- CPRINTUSB("Disabling all charge ports");
-
- sm5803_vbus_sink_enable(CHARGER_SOLO, 0);
-
- return EC_SUCCESS;
- }
-
- CPRINTUSB("New chg p%d", port);
-
- /*
- * Ensure other port is turned off, then enable new charge port
- */
- if (port == 0) {
- sm5803_vbus_sink_enable(CHARGER_SOLO, 1);
- } else {
- sm5803_vbus_sink_enable(CHARGER_SOLO, 0);
- }
-
- return EC_SUCCESS;
+ if (port != CHARGE_PORT_TYPEC0)
+ return 0;
+ return gpio_get_level(GPIO_EN_USB_C0_VBUS);
}
/* Vconn control for integrated ITE TCPC */
@@ -280,54 +197,178 @@ void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
- int current;
+ int ilim3A;
if (port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT)
return;
- current = (rp == TYPEC_RP_3A0) ? 3000 : 1500;
+ /* Switch between 1.5A and 3A ILIM values */
+ ilim3A = (rp == TYPEC_RP_3A0);
+ gpio_set_level(GPIO_USB_C0_VBUS_ILIM, ilim3A);
+}
+
+/******************************************************************************/
+/*
+ * Since dibbi has no battery, it must source all of its power from either
+ * USB-C or the barrel jack (preferred). Fizz operates in continuous safe
+ * mode (charge_manager_leave_safe_mode() will never be called), which
+ * modifies port selection as follows:
+ *
+ * - Dual-role / dedicated capability of the port partner is ignored.
+ * - Charge ceiling on PD voltage transition is ignored.
+ * - CHARGE_PORT_NONE will never be selected.
+ */
+
+/* List of BJ adapters */
+enum bj_adapter {
+ BJ_NONE,
+ BJ_65W_19V,
+};
+
+/* Barrel-jack power adapter ratings. */
+static const struct charge_port_info bj_adapters[] = {
+ [BJ_NONE] = { .current = 0, .voltage = 0 },
+ [BJ_65W_19V] = { .current = 3420, .voltage = 19000 },
+};
+#define BJ_ADP_RATING_DEFAULT BJ_65W_19V /* BJ power ratings default */
+#define ADP_DEBOUNCE_MS 1000 /* Debounce time for BJ plug/unplug */
+
+/* Debounced connection state of the barrel jack */
+static int8_t bj_adp_connected = -1;
+static void adp_connect_deferred(void)
+{
+ const struct charge_port_info *pi;
+ int connected = !gpio_get_level(GPIO_BJ_ADP_PRESENT_L);
+
+ /* Debounce */
+ if (connected == bj_adp_connected)
+ return;
- charger_set_otg_current_voltage(port, current, 5000);
+ if (connected) {
+ pi = &bj_adapters[BJ_ADP_RATING_DEFAULT];
+ } else {
+ /* No barrel-jack, zero out this power supply */
+ pi = &bj_adapters[BJ_NONE];
+ }
+ /* This will result in a call to board_set_active_charge_port */
+ charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED,
+ DEDICATED_CHARGE_PORT, pi);
+ bj_adp_connected = connected;
}
+DECLARE_DEFERRED(adp_connect_deferred);
-/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
-const struct pwm_t pwm_channels[] = {
- [PWM_CH_KBLIGHT] = {
- .channel = 0,
- .flags = PWM_CONFIG_DSLEEP,
- .freq_hz = 10000,
- },
+/* IRQ for BJ plug/unplug. It shouldn't be called if BJ is the power source. */
+void adp_connect_interrupt(enum gpio_signal signal)
+{
+ hook_call_deferred(&adp_connect_deferred_data, ADP_DEBOUNCE_MS * MSEC);
+}
- [PWM_CH_LED_RED] = {
- .channel = 1,
- .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
- .freq_hz = 2400,
- },
+/* IRQ for USB-C plug/unplug. */
+void usbc_connect_interrupt(enum gpio_signal signal)
+{
+ task_wake(TASK_ID_PD_C0);
+}
- [PWM_CH_LED_GREEN] = {
- .channel = 2,
- .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
- .freq_hz = 2400,
- },
+int board_set_active_charge_port(int port)
+{
+ const int active_port = charge_manager_get_active_charge_port();
- [PWM_CH_LED_BLUE] = {
- .channel = 3,
- .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
- .freq_hz = 2400,
+ CPRINTUSB("Requested charge port change to %d", port);
+
+ if (port < 0 || CHARGE_PORT_COUNT <= port)
+ return EC_ERROR_INVAL;
+
+ if (port == active_port)
+ return EC_SUCCESS;
+
+ /* Don't sink from a source port */
+ if (board_vbus_source_enabled(port))
+ return EC_ERROR_INVAL;
+
+ if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
+ int bj_requested;
+
+ if (charge_manager_get_active_charge_port() != CHARGE_PORT_NONE)
+ /* Change is only permitted while the system is off */
+ return EC_ERROR_INVAL;
+
+ /*
+ * Current setting is no charge port but the AP is on, so the
+ * charge manager is out of sync (probably because we're
+ * reinitializing after sysjump). Reject requests that aren't
+ * in sync with our outputs.
+ */
+ bj_requested = port == CHARGE_PORT_BARRELJACK;
+ if (bj_adp_connected != bj_requested)
+ return EC_ERROR_INVAL;
}
-};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+ CPRINTUSB("New charger p%d", port);
+
+ switch (port) {
+ case CHARGE_PORT_TYPEC0:
+ gpio_set_level(GPIO_EN_PPVAR_USBC_ADP_L, 0);
+ gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 1);
+ gpio_enable_interrupt(GPIO_BJ_ADP_PRESENT_L);
+ break;
+ case CHARGE_PORT_BARRELJACK:
+ /* Make sure BJ adapter is sourcing power */
+ if (gpio_get_level(GPIO_BJ_ADP_PRESENT_L))
+ return EC_ERROR_INVAL;
+ gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 0);
+ gpio_set_level(GPIO_EN_PPVAR_USBC_ADP_L, 1);
+ gpio_disable_interrupt(GPIO_BJ_ADP_PRESENT_L);
+ break;
+ default:
+ return EC_ERROR_INVAL;
+ }
-/* Thermistors */
-const struct temp_sensor_t temp_sensors[] = {
- [TEMP_SENSOR_1] = { .name = "Memory",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_51k1_47k_4050b,
- .idx = ADC_TEMP_SENSOR_1 },
- [TEMP_SENSOR_2] = { .name = "Ambient",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_51k1_47k_4050b,
- .idx = ADC_TEMP_SENSOR_2 },
-};
-BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+ return EC_SUCCESS;
+}
+
+static void board_charge_manager_init(void)
+{
+ enum charge_port port;
+
+ /*
+ * Initialize all charge suppliers to 0. The charge manager waits until
+ * all ports have reported in before doing anything.
+ */
+ for (int i = 0; i < CHARGE_PORT_COUNT; i++) {
+ for (int j = 0; j < CHARGE_SUPPLIER_COUNT; j++)
+ charge_manager_update_charge(j, i, NULL);
+ }
+
+ port = gpio_get_level(GPIO_BJ_ADP_PRESENT_L) ? CHARGE_PORT_TYPEC0 :
+ CHARGE_PORT_BARRELJACK;
+ CPRINTUSB("Power source is p%d (%s)", port,
+ port == CHARGE_PORT_TYPEC0 ? "USB-C" : "BJ");
+
+ /* Initialize the power source supplier */
+ switch (port) {
+ case CHARGE_PORT_TYPEC0:
+ typec_set_input_current_limit(port, 3000, 5000);
+ break;
+ case CHARGE_PORT_BARRELJACK:
+ charge_manager_update_charge(
+ CHARGE_SUPPLIER_DEDICATED, DEDICATED_CHARGE_PORT,
+ &bj_adapters[BJ_ADP_RATING_DEFAULT]);
+ break;
+ }
+
+ /* Report charge state from the barrel jack. */
+ adp_connect_deferred();
+}
+DECLARE_HOOK(HOOK_INIT, board_charge_manager_init,
+ HOOK_PRIO_INIT_CHARGE_MANAGER + 1);
+
+__override int extpower_is_present(void)
+{
+ /*
+ * There's no battery, so running this method implies we have power.
+ */
+ return 1;
+}
+
+/* Must come after other header files and interrupt handler declarations */
+#include "gpio_list.h"
diff --git a/board/dibbi/board.h b/board/dibbi/board.h
index 166b9d6fbf..c59a540b5d 100644
--- a/board/dibbi/board.h
+++ b/board/dibbi/board.h
@@ -17,44 +17,67 @@
#define CONFIG_CMD_CHARGER_DUMP
-/* Battery */
-#define CONFIG_BATTERY_FUEL_GAUGE
-
-/* BC 1.2 */
-#define CONFIG_BC12_DETECT_PI3USB9201
-
-/* Charger */
-#define CONFIG_CHARGER_SM5803 /* C0: Charger */
+/* Power */
+#undef CONFIG_CHARGER
+#undef CONFIG_CHARGER_DISCHARGE_ON_AC
+#undef CONFIG_USB_PD_VBUS_MEASURE_CHARGER
+#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 16000
#define PD_MAX_VOLTAGE_MV 15000
-#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
-#define CONFIG_USB_PD_5V_CHARGER_CTRL
-#define CONFIG_CHARGER_OTG
+#define CONFIG_USB_PD_VBUS_DETECT_GPIO
+/* ADC sensors could measure VBUS on this board, but components are DNS */
+#define CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
-/* LED */
-#define CONFIG_LED_PWM
-#define CONFIG_LED_PWM_COUNT 1
+/* Override macro for C0 only */
+#define PORT_TO_HPD(port) (GPIO_USB_C0_DP_HPD)
-/* PWM */
-#define CONFIG_PWM
+/* Power: Dedicated barreljack charger port */
+#undef CONFIG_DEDICATED_CHARGE_PORT_COUNT
+#define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1
+#define DEDICATED_CHARGE_PORT 1
+
+/* USB Type-C */
+#undef CONFIG_USB_CHARGER
+#undef CONFIG_USB_MUX_PI3USB31532
/* TCPC */
#define CONFIG_USB_PD_PORT_MAX_COUNT 1
#define CONFIG_USB_PD_TCPM_ITE_ON_CHIP /* C0: ITE EC TCPC */
#define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT 1
-/* Power: Dedicated barreljack charger port */
-#undef CONFIG_DEDICATED_CHARGE_PORT_COUNT
-#define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1
-#define DEDICATED_CHARGE_PORT 1
+/* USB Mux and Retimer */
+#define CONFIG_USB_MUX_IT5205 /* C0: ITE Mux */
+#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* Required for ITE Mux */
+
+/* USB Type A Features */
+#define CONFIG_USB_PORT_POWER_DUMB
+#define USB_PORT_COUNT 3 /* Type A ports */
+
+/* No battery */
+#undef CONFIG_BATTERY_CUT_OFF
+#undef CONFIG_BATTERY_PRESENT_GPIO
+#undef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD
+#undef CONFIG_BATTERY_REVIVE_DISCONNECT
+#undef CONFIG_BATTERY_SMART
+
+/* LED */
+/* TODO(b/259467280) Determine what LED/PWM impl is needed*/
+/* #define CONFIG_LED_PWM */
+/* #define CONFIG_LED_PWM_COUNT 1 */
+
+/* PWM */
+#define CONFIG_PWM
/* Thermistors */
#define CONFIG_TEMP_SENSOR
#define CONFIG_THERMISTOR
#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B
-/* USB Mux and Retimer */
-#define CONFIG_USB_MUX_IT5205 /* C0: ITE Mux */
-#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* Required for ITE Mux */
+/* Buttons */
+#define CONFIG_DEDICATED_RECOVERY_BUTTON
+#define CONFIG_DEDICATED_RECOVERY_BUTTON_2
+#define CONFIG_POWER_BUTTON
+#define CONFIG_POWER_BUTTON_IGNORE_LID
+#define CONFIG_POWER_BUTTON_X86
/* No Keyboard */
#undef CONFIG_MKBP_EVENT
@@ -71,14 +94,8 @@
#undef CONFIG_BACKLIGHT_LID
#undef GPIO_ENABLE_BACKLIGHT
-/* Buttons */
-#define CONFIG_DEDICATED_RECOVERY_BUTTON
-#define CONFIG_DEDICATED_RECOVERY_BUTTON_2
-#define CONFIG_POWER_BUTTON
-#define CONFIG_POWER_BUTTON_IGNORE_LID
-#define CONFIG_POWER_BUTTON_X86
-
/* Unused features - Misc */
+#undef CONFIG_HIBERNATE
#undef CONFIG_VOLUME_BUTTONS
#undef CONFIG_LID_SWITCH
#undef CONFIG_TABLET_MODE
@@ -99,8 +116,12 @@
#include "gpio_signal.h"
#include "registers.h"
+enum charge_port {
+ CHARGE_PORT_TYPEC0,
+ CHARGE_PORT_BARRELJACK,
+};
+
enum pwm_channel {
- PWM_CH_KBLIGHT,
PWM_CH_LED_RED,
PWM_CH_LED_GREEN,
PWM_CH_LED_BLUE,
@@ -112,31 +133,13 @@ enum adc_channel {
ADC_VSNS_PP3300_A, /* ADC0 */
ADC_TEMP_SENSOR_1, /* ADC2 */
ADC_TEMP_SENSOR_2, /* ADC3 */
- ADC_SUB_ANALOG, /* ADC13 */
+ ADC_PPVAR_PWR_IN_IMON, /* ADC15 */
+ ADC_SNS_PPVAR_PWR_IN, /* ADC16 */
ADC_CH_COUNT
};
enum temp_sensor_id { TEMP_SENSOR_1, TEMP_SENSOR_2, TEMP_SENSOR_COUNT };
-/* List of possible batteries */
-enum battery_type {
- BATTERY_LGC15,
- BATTERY_PANASONIC_AP15O5L,
- BATTERY_SANYO,
- BATTERY_SONY,
- BATTERY_SMP_AP13J7K,
- BATTERY_PANASONIC_AC15A3J,
- BATTERY_LGC_AP18C8K,
- BATTERY_MURATA_AP18C4K,
- BATTERY_LGC_AP19A8K,
- BATTERY_LGC_G023,
- BATTERY_TYPE_COUNT,
-};
-
-/* Board specific handlers */
-/* TODO(b/257377326) Update this with power re-work */
-#define PORT_TO_HPD(port) (GPIO_USB_C0_DP_HPD)
-
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/dibbi/build.mk b/board/dibbi/build.mk
index e75f1c6725..07ea50c392 100644
--- a/board/dibbi/build.mk
+++ b/board/dibbi/build.mk
@@ -12,4 +12,3 @@ CHIP_VARIANT:=it8320dx
BASEBOARD:=dedede
board-y=board.o led.o usb_pd_policy.o
-board-$(CONFIG_BATTERY_SMART)+=battery.o
diff --git a/board/dibbi/ec.tasklist b/board/dibbi/ec.tasklist
index ed73e778fe..768c31112a 100644
--- a/board/dibbi/ec.tasklist
+++ b/board/dibbi/ec.tasklist
@@ -9,17 +9,8 @@
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, VENTI_TASK_STACK_SIZE) \
- TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, LARGER_TASK_STACK_SIZE) \
- TASK_ALWAYS(CHARGER, charger_task, NULL, TRENTA_TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(HOSTCMD, host_command_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(POWERBTN, power_button_task, NULL, ULTRA_TASK_STACK_SIZE) \
- TASK_ALWAYS(PD_C0, pd_task, NULL, ULTRA_TASK_STACK_SIZE)
-
-/*
- * TODO(b/257377326):
- * determine what tasks are required for PD power
- * determine whether there should be a PD_INT_C0 (waddledee only had
- * PD_INT_C1)
- */
+ TASK_ALWAYS(PD_C0, pd_task, NULL, ULTRA_TASK_STACK_SIZE)
diff --git a/board/dibbi/gpio.inc b/board/dibbi/gpio.inc
index 313eda46c9..a5c0c02a72 100644
--- a/board/dibbi/gpio.inc
+++ b/board/dibbi/gpio.inc
@@ -29,19 +29,16 @@ GPIO_INT(UART1_RX, PIN(B, 0), GPIO_INT_BOTH, uart_deepsleep_interrupt) /* UART_
#endif
/* USB-C interrupts */
-GPIO_INT(USB_C0_INT_ODL, PIN(K, 0), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c0_interrupt) /* BC12 and charger */
GPIO_INT(USB_C0_CCSBU_OVP_ODL, PIN(K, 6), GPIO_INT_FALLING | GPIO_PULL_UP, c0_ccsbu_ovp_interrupt) /* Fault protection */
/* Other interrupts */
-/* TODO(b/257377326) PIN(A, 7) changed from LID_360_L to BJ_ADP_PRESENT_L */
-/* TODO(b/257833880) PIN(I, 6) changed from VOLDN_BTN_ODL to USB_C0_VBUS_ILIM */
-/* TODO(b/257833880) PIN(I, 7) changed from VOLUP_BTN_ODL to EN_USB_C0_VBUS */
-/* TODO(b/257377326) PIN(J, 0) changed from BASE_SIXAXIS_INT_L to EN_PVAR_BJ_ADP_L */
GPIO_INT(EC_WP_OD, PIN(A, 6), GPIO_INT_BOTH, switch_interrupt)
/* Directly connected recovery button */
GPIO_INT(EC_RECOVERY_BTN_ODL, PIN(K, 7), GPIO_INT_BOTH, button_interrupt)
/* Recovery button input from H1 */
GPIO_INT(H1_EC_RECOVERY_BTN_ODL, PIN(K, 4), GPIO_INT_BOTH, button_interrupt)
+GPIO_INT(BJ_ADP_PRESENT_L, PIN(A, 7), GPIO_INT_BOTH | GPIO_PULL_UP, adp_connect_interrupt)
+GPIO_INT(USBC_ADP_PRESENT_L, PIN(K, 3), GPIO_INT_BOTH | GPIO_PULL_UP, usbc_connect_interrupt)
/* Power sequence GPIOs */
GPIO(EC_AP_RTCRST, PIN(K, 2), GPIO_OUT_LOW)
@@ -61,13 +58,20 @@ GPIO(EN_VCCIO_EXT, PIN(B, 2), GPIO_OUT_LOW)
GPIO(EC_PROCHOT_ODL, PIN(I, 1), GPIO_ODR_HIGH | GPIO_SEL_1P8V)
GPIO(EC_AP_VCCST_PWRGD_OD, PIN(E, 5), GPIO_ODR_LOW)
GPIO(ALL_SYS_PWRGD, PIN(B, 7), GPIO_OUT_LOW)
-GPIO(EN_SLP_Z, PIN(K, 3), GPIO_OUT_LOW)
+GPIO(EN_PPVAR_BJ_ADP_L, PIN(J, 0), GPIO_OUT_LOW)
+GPIO(EN_PPVAR_USBC_ADP_L, PIN(J, 1), GPIO_OUT_LOW)
+GPIO(EN_USB_C0_VBUS, PIN(I, 7), GPIO_OUT_LOW)
+GPIO(USB_C0_VBUS_ILIM, PIN(I, 6), GPIO_OUT_LOW)
/* Required for icelake chipset code, but implemented through other means for dedede */
UNIMPLEMENTED(AC_PRESENT)
UNIMPLEMENTED(PG_EC_DSW_PWROK)
UNIMPLEMENTED(PG_EC_ALL_SYS_PWRGD)
+/* Required for dedede baseboard but not used in dibbi */
+UNIMPLEMENTED(USB_C0_INT_ODL)
+UNIMPLEMENTED(EN_SLP_Z)
+
/* I2C pins - Alternate function below configures I2C module on these pins */
GPIO(EC_I2C_EEPROM_SCL, PIN(B, 3), GPIO_INPUT)
GPIO(EC_I2C_EEPROM_SDA, PIN(B, 4), GPIO_INPUT)
@@ -82,9 +86,9 @@ GPIO(EC_I2C_USB_C0_SDA, PIN(A, 5), GPIO_INPUT)
GPIO(EN_USB_C0_CC1_VCONN, PIN(H, 4), GPIO_OUT_LOW)
GPIO(EN_USB_C0_CC2_VCONN, PIN(H, 6), GPIO_OUT_LOW)
GPIO(EC_AP_USB_C0_HPD, PIN(L, 4), GPIO_OUT_LOW)
-GPIO(USB_C0_FRS, PIN(C, 4), GPIO_OUT_LOW)
-GPIO(HDMI_SEL_L, PIN(C, 6), GPIO_OUT_HIGH)
-GPIO(EN_USB_A0_VBUS, PIN(L, 6), GPIO_OUT_LOW) /* Board rev 1, NC board rev 0 */
+GPIO(EN_USB_A0_VBUS, PIN(L, 6), GPIO_OUT_LOW)
+GPIO(EN_USB_A1_VBUS, PIN(C, 6), GPIO_OUT_LOW)
+GPIO(EN_USB_A2_VBUS, PIN(C, 4), GPIO_OUT_LOW)
/* MKBP event synchronization */
/* TODO(b/257833880) Check whether this pin is needed */
@@ -100,7 +104,6 @@ GPIO(EC_SUB_IO_2_2, PIN(L, 2), GPIO_INPUT)
GPIO(EC_ENTERING_RW, PIN(G, 0), GPIO_OUT_LOW)
GPIO(CCD_MODE_ODL, PIN(H, 5), GPIO_ODR_HIGH)
GPIO(EC_BATTERY_PRES_ODL, PIN(I, 4), GPIO_INPUT)
-/* TODO(b/257377326) PIN(J, 1) changed from PEN_DET_ODL to EN_PPVAR_USBC_ADP_L */
GPIO(ECH1_PACKET_MODE, PIN(H, 1), GPIO_OUT_LOW)
@@ -115,6 +118,8 @@ GPIO(GPIOG7_NC, PIN(G, 7), GPIO_INPUT | GPIO_PULL_DOWN)
GPIO(GPIOJ4_NC, PIN(J, 4), GPIO_INPUT | GPIO_PULL_DOWN)
GPIO(GPIOJ5_NC, PIN(J, 5), GPIO_INPUT | GPIO_PULL_DOWN)
GPIO(GPIOJ6_NC, PIN(J, 6), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOK0_NC, PIN(K, 0), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOL0_NC, PIN(L, 0), GPIO_INPUT | GPIO_PULL_DOWN)
GPIO(GPIOM6_NC, PIN(M, 6), GPIO_INPUT | GPIO_PULL_DOWN)
/* TODO(b/257833880) add any new unused pins */
@@ -130,8 +135,8 @@ ALTERNATE(PIN_MASK(E, BIT(0) | BIT(7)), 0, MODULE_I2C, 0) /* I2C4 */
ALTERNATE(PIN_MASK(A, BIT(4) | BIT(5)), 0, MODULE_I2C, 0) /* I2C5 */
/* ADC */
-ALTERNATE(PIN_MASK(L, BIT(0)), 0, MODULE_ADC, 0) /* ADC13: EC_SUB_ANALOG */
ALTERNATE(PIN_MASK(I, BIT(0) | BIT(2) | BIT(3)), 0, MODULE_ADC, 0) /* ADC0: EC_VSNS_PP3300_A, ADC2: TEMP_SENSOR_1, ADC3: TEMP_SENSOR_2 */
+ALTERNATE(PIN_MASK(L, BIT(2) | BIT(3)), 0, MODULE_ADC, 0) /* ADC15: PPVAR_PWR_IN_IMON, ADC16: SNS_PPVAR_PWR_IN */
/* PWM */
ALTERNATE(PIN_MASK(A, BIT(1) | BIT(2) | BIT(3)), 0, MODULE_PWM, 0) /* LED_[R,G,B]_ODL */
diff --git a/board/dibbi/led.c b/board/dibbi/led.c
index 74d6419aea..44cfc0b457 100644
--- a/board/dibbi/led.c
+++ b/board/dibbi/led.c
@@ -3,45 +3,23 @@
* found in the LICENSE file.
*/
-/* Waddledee specific PWM LED settings. */
+/* Dibbi specific PWM LED settings. */
#include "common.h"
#include "ec_commands.h"
-#include "led_pwm.h"
#include "pwm.h"
#include "util.h"
+/* TODO(b/259467280) Implement LED logic */
+
const enum ec_led_id supported_led_ids[] = {
EC_LED_ID_POWER_LED,
};
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-/*
- * Board has one physical LED with red, green, and blue
- */
-struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
- /* Red, Green, Blue */
- [EC_LED_COLOR_RED] = { 100, 0, 0 },
- [EC_LED_COLOR_GREEN] = { 0, 100, 0 },
- [EC_LED_COLOR_BLUE] = { 0, 0, 100 },
- [EC_LED_COLOR_YELLOW] = { 50, 50, 0 },
- [EC_LED_COLOR_WHITE] = { 50, 50, 50 },
- [EC_LED_COLOR_AMBER] = { 70, 30, 0 },
-};
-
-/* One logical LED with red, green, and blue channels. */
-struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = {
- {
- .ch0 = PWM_CH_LED_RED,
- .ch1 = PWM_CH_LED_GREEN,
- .ch2 = PWM_CH_LED_BLUE,
- .enable = &pwm_enable,
- .set_duty = &pwm_set_duty,
- },
-};
-
void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
{
+ /* TODO(b/259467280) check this implementation */
memset(brightness_range, '\0',
sizeof(*brightness_range) * EC_LED_COLOR_COUNT);
brightness_range[EC_LED_COLOR_RED] = 100;
@@ -54,29 +32,7 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
{
- enum pwm_led_id pwm_id;
-
- /* Convert ec_led_id to pwm_led_id. */
- if (led_id == EC_LED_ID_POWER_LED)
- pwm_id = PWM_LED0;
- else
- return EC_ERROR_UNKNOWN;
-
- if (brightness[EC_LED_COLOR_RED])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_RED);
- else if (brightness[EC_LED_COLOR_GREEN])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_GREEN);
- else if (brightness[EC_LED_COLOR_BLUE])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_BLUE);
- else if (brightness[EC_LED_COLOR_YELLOW])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_YELLOW);
- else if (brightness[EC_LED_COLOR_WHITE])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_WHITE);
- else if (brightness[EC_LED_COLOR_AMBER])
- set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER);
- else
- /* Otherwise, the "color" is "off". */
- set_pwm_led_color(pwm_id, -1);
+ /* TODO(b/259467280) fix this implementation */
return EC_SUCCESS;
}
diff --git a/board/dibbi/usb_pd_policy.c b/board/dibbi/usb_pd_policy.c
index ad930e1862..9d573b9c61 100644
--- a/board/dibbi/usb_pd_policy.c
+++ b/board/dibbi/usb_pd_policy.c
@@ -3,40 +3,44 @@
* found in the LICENSE file.
*/
-#include "battery_smart.h" /* TODO(b/257377326) remove */
#include "charge_manager.h"
#include "charger.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
-#include "driver/charger/sm5803.h" /* TODO(b/257377326) remove */
#include "driver/tcpm/tcpci.h"
+#include "gpio.h"
#include "usb_pd.h"
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
+__override int pd_check_power_swap(int port)
+{
+ /* If type-c port is supplying power, we never swap PR (to source) */
+ if (port == charge_manager_get_active_charge_port())
+ return 0;
+ /*
+ * Allow power swap as long as we are acting as a dual role device,
+ * otherwise assume our role is fixed (not in S0 or console command
+ * to fix our role).
+ */
+ return (pd_get_dual_role(port) == PD_DRP_TOGGLE_ON ? 1 : 0);
+}
+
int pd_check_vconn_swap(int port)
{
/* Allow VCONN swaps if the AP is on */
- return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON);
+ return gpio_get_level(GPIO_EN_PP5000_U);
}
void pd_power_supply_reset(int port)
{
- int prev_en;
-
if (port < 0 || port >= board_get_usb_pd_port_count())
return;
- prev_en = charger_is_sourcing_otg_power(port);
-
- /* Disable Vbus */
- charger_enable_otg_power(port, 0);
-
- /* Discharge Vbus if previously enabled */
- if (prev_en)
- sm5803_set_vbus_disch(port, 1);
+ /* Disable VBUS source */
+ gpio_set_level(GPIO_EN_USB_C0_VBUS, 0);
/* Notify host of power info change. */
pd_send_host_event(PD_EVENT_POWER_CHANGE);
@@ -44,18 +48,11 @@ void pd_power_supply_reset(int port)
int pd_set_power_supply_ready(int port)
{
- enum ec_error_list rv;
-
- /* Disable sinking */
- rv = sm5803_vbus_sink_enable(port, 0);
- if (rv)
- return rv;
-
- /* Disable Vbus discharge */
- sm5803_set_vbus_disch(port, 0);
+ /* Disable charging */
+ gpio_set_level(GPIO_EN_PPVAR_USBC_ADP_L, 1);
- /* Provide Vbus */
- charger_enable_otg_power(port, 1);
+ /* Enable VBUS source */
+ gpio_set_level(GPIO_EN_USB_C0_VBUS, 1);
/* Notify host of power info change. */
pd_send_host_event(PD_EVENT_POWER_CHANGE);
@@ -63,12 +60,10 @@ int pd_set_power_supply_ready(int port)
return EC_SUCCESS;
}
-__override bool pd_check_vbus_level(int port, enum vbus_level level)
+__override int pd_snk_is_vbus_provided(int port)
{
- return sm5803_check_vbus_level(port, level);
-}
+ if (port != CHARGE_PORT_TYPEC0)
+ return 0;
-int pd_snk_is_vbus_provided(int port)
-{
- return sm5803_is_vbus_present(port);
+ return gpio_get_level(GPIO_USBC_ADP_PRESENT_L);
}