summaryrefslogtreecommitdiff
path: root/board/cappy2/board.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /board/cappy2/board.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-voshyr-14637.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'board/cappy2/board.c')
-rw-r--r--board/cappy2/board.c363
1 files changed, 0 insertions, 363 deletions
diff --git a/board/cappy2/board.c b/board/cappy2/board.c
deleted file mode 100644
index ba0c4f04e9..0000000000
--- a/board/cappy2/board.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/* Copyright 2021 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.
- */
-
-/* cappy2 board-specific configuration */
-
-
-#include "adc_chip.h"
-#include "button.h"
-#include "cbi_fw_config.h"
-#include "charge_manager.h"
-#include "charge_state_v2.h"
-#include "charger.h"
-#include "driver/bc12/pi3usb9201.h"
-#include "driver/charger/isl923x.h"
-#include "driver/tcpm/raa489000.h"
-#include "driver/temp_sensor/thermistor.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "keyboard_raw.h"
-#include "keyboard_scan.h"
-#include "lid_switch.h"
-#include "math_util.h"
-#include "power.h"
-#include "power_button.h"
-#include "pwm.h"
-#include "pwm_chip.h"
-#include "switch.h"
-#include "system.h"
-#include "tablet_mode.h"
-#include "task.h"
-#include "tcpm/tcpci.h"
-#include "temp_sensor.h"
-#include "uart.h"
-#include "usb_charge.h"
-#include "usb_mux.h"
-#include "usb_mux/ps8743_public.h"
-#include "usb_pd.h"
-#include "usb_pd_tcpm.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-
-#define INT_RECHECK_US 5000
-
-/* 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)
-{
- /*
- * The interrupt line is shared between the TCPC and BC 1.2 detection
- * chip. Therefore we'll need to check both ICs.
- */
- schedule_deferred_pd_interrupt(0);
- task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12);
-}
-
-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);
-}
-
-/* Keyboard scan setting */
-
-#include "gpio_list.h"
-
-/* ADC channels */
-const struct adc_t adc_channels[] = {
- [ADC_TEMP_SENSOR_1] = {
- .name = "TEMP_SENSOR1",
- .input_ch = NPCX_ADC_CH0,
- .factor_mul = ADC_MAX_VOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- },
- [ADC_TEMP_SENSOR_2] = {
- .name = "TEMP_SENSOR2",
- .input_ch = NPCX_ADC_CH1,
- .factor_mul = ADC_MAX_VOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- },
- [ADC_SUB_ANALOG] = {
- .name = "SUB_ANALOG",
- .input_ch = NPCX_ADC_CH2,
- .factor_mul = ADC_MAX_VOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- },
- [ADC_TEMP_SENSOR_3] = {
- .name = "TEMP_SENSOR3",
- .input_ch = NPCX_ADC_CH6,
- .factor_mul = ADC_MAX_VOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- },
- [ADC_VSNS_PP3300_A] = {
- .name = "PP3300_A_PGOOD",
- .input_ch = NPCX_ADC_CH9,
- .factor_mul = ADC_MAX_VOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-
-void board_hibernate(void)
-{
- /*
- * Both charger ICs need to be put into their "low power mode" before
- * entering the Z-state.
- */
- raa489000_hibernate(0, true);
-}
-
-void board_reset_pd_mcu(void)
-{
- /*
- * TODO(b:147316511): Here we could issue a digital reset to the IC,
- * unsure if we actually want to do that or not yet.
- */
-}
-
-__override void board_power_5v_enable(int enable)
-{
- /*
- * Port 0 simply has a GPIO to turn on the 5V regulator, however, 5V is
- * generated locally on the sub board and we need to set the comparator
- * polarity on the sub board charger IC.
- */
- gpio_set_level(GPIO_EN_PP5000, !!enable);
- gpio_set_level(GPIO_EN_USB_A0_VBUS, !!enable);
-
-}
-
-int board_is_sourcing_vbus(int port)
-{
- int regval;
-
- tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
- return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS);
-
-}
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 &&
- port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
- int old_port;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- old_port = charge_manager_get_active_charge_port();
-
- CPRINTS("New chg p%d", port);
-
- /* Disable all ports. */
- if (port == CHARGE_PORT_NONE) {
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
- tcpc_write(i, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_LOW);
-
- return EC_SUCCESS;
- }
-
- /* Check if port is sourcing VBUS. */
- if (board_is_sourcing_vbus(port)) {
- CPRINTS("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- if (i == port)
- continue;
-
- if (tcpc_write(i, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_LOW))
- CPRINTS("p%d: sink path disable failed.", i);
- }
-
- /*
- * Stop the charger IC from switching while changing ports. Otherwise,
- * we can overcurrent the adapter we're switching to. (crbug.com/926056)
- */
- if (old_port != CHARGE_PORT_NONE)
- charger_discharge_on_ac(1);
-
- /* Enable requested charge port. */
- if (tcpc_write(port, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_HIGH)) {
- CPRINTS("p%d: sink path enable failed.", port);
- charger_discharge_on_ac(0);
- return EC_ERROR_UNKNOWN;
- }
-
- /* Allow the charger IC to begin/continue switching. */
- charger_discharge_on_ac(0);
-
- return EC_SUCCESS;
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
-__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- if (port < 0 || port > board_get_usb_pd_port_count())
- return;
-
- raa489000_set_output_current(port, rp);
-}
-
-int pd_snk_is_vbus_provided(int port)
-{
- return pd_check_vbus_level(port, VBUS_PRESENT);
-}
-
-const struct charger_config_t chg_chips[] = {
- {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = ISL923X_ADDR_FLAGS,
- .drv = &isl923x_drv,
- },
-};
-
-/* BC 1.2 chip*/
-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,
- },
-};
-
-const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C0,
- .addr_flags = RAA489000_TCPC0_I2C_FLAGS,
- },
- .flags = TCPC_FLAGS_TCPCI_REV2_0,
- .drv = &raa489000_tcpm_drv,
- },
-};
-
-const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .usb_port = 0,
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = PS8743_I2C_ADDR0_FLAG,
- .driver = &ps8743_usb_mux_driver,
- },
-};
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
- int regval;
-
- /*
- * The interrupt line is shared between the TCPC and BC1.2 detector IC.
- * Therefore, go out and actually read the alert registers to report the
- * alert status.
- */
- if (!gpio_get_level(GPIO_USB_C0_INT_ODL)) {
- if (!tcpc_read16(0, TCPC_REG_ALERT, &regval)) {
- if (regval)
- status |= PD_STATUS_TCPC_ALERT_0;
- }
- }
-
- return status;
-}
-
-void board_init(void)
-{
- int on;
-
- gpio_enable_interrupt(GPIO_USB_C0_INT_ODL);
-
- /*
- * If interrupt lines are already low, schedule them to be processed
- * after inits are completed.
- */
- if (!gpio_get_level(GPIO_USB_C0_INT_ODL))
- hook_call_deferred(&check_c0_line_data, 0);
-
- gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL);
-
- /* Turn on 5V if the system is on, otherwise turn it off. */
- on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND |
- CHIPSET_STATE_SOFT_OFF);
- board_power_5v_enable(on);
-
- /* modify AC DC prochot value */
- isl923x_set_ac_prochot(CHARGER_SOLO, 4096);
- isl923x_set_dc_prochot(CHARGER_SOLO, 6000);
-
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-
-/* 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},
- [TEMP_SENSOR_3] = {.name = "Cpu",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_51k1_47k_4050b,
- .idx = ADC_TEMP_SENSOR_3},
-};
-BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);