summaryrefslogtreecommitdiff
path: root/board/halvor/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/halvor/board.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14438.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/halvor/board.c')
-rw-r--r--board/halvor/board.c528
1 files changed, 0 insertions, 528 deletions
diff --git a/board/halvor/board.c b/board/halvor/board.c
deleted file mode 100644
index 53828b5318..0000000000
--- a/board/halvor/board.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/* Copyright 2020 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.
- */
-
-/* Volteer board-specific configuration */
-#include "accelgyro.h"
-#include "assert.h"
-#include "button.h"
-#include "common.h"
-#include "cbi_ec_fw_config.h"
-#include "driver/accel_bma2x2.h"
-#include "driver/als_tcs3400.h"
-#include "driver/bc12/pi3usb9201.h"
-#include "driver/ppc/syv682x.h"
-#include "driver/retimer/bb_retimer_public.h"
-#include "driver/sync.h"
-#include "driver/tcpm/tcpci.h"
-#include "driver/tcpm/tusb422.h"
-#include "extpower.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "keyboard_scan.h"
-#include "lid_switch.h"
-#include "power.h"
-#include "power_button.h"
-#include "pwm.h"
-#include "pwm_chip.h"
-#include "switch.h"
-#include "system.h"
-#include "task.h"
-#include "tablet_mode.h"
-#include "uart.h"
-#include "usb_pd_tbt.h"
-#include "usbc_ppc.h"
-#include "usb_pd.h"
-#include "usb_pd_tcpm.h"
-#include "usb_mux.h"
-#include "util.h"
-
-#include "gpio_list.h" /* Must come after other header files. */
-
-/* Keyboard scan setting */
-__override struct keyboard_scan_config keyscan_config = {
- /* Increase from 50 us, because KSO_02 passes through the H1. */
- .output_settle_us = 80,
- /* Other values should be the same as the default configuration. */
- .debounce_down_us = 9 * MSEC,
- .debounce_up_us = 30 * MSEC,
- .scan_period_us = 3 * MSEC,
- .min_post_scan_delay_us = 1000,
- .poll_timeout_us = 100 * MSEC,
- .actual_key_mask = {
- 0x14, 0xff, 0xff, 0xff, 0xff, 0xf4, 0xff,
- 0xa0, 0xff, 0xfe, 0x41, 0xfa, 0xc0, 0x02,
- 0x08, /* full set */
- },
-};
-
-/******************************************************************************/
-static const struct ec_response_keybd_config halvor_kb = {
- .num_top_row_keys = 10,
- .action_keys = {
- TK_BACK, /* T1 */
- TK_REFRESH, /* T2 */
- TK_FULLSCREEN, /* T3 */
- TK_OVERVIEW, /* T4 */
- TK_BRIGHTNESS_DOWN, /* T5 */
- TK_BRIGHTNESS_UP, /* T6 */
- TK_PLAY_PAUSE, /* T7 */
- TK_VOL_MUTE, /* T8 */
- TK_VOL_DOWN, /* T9 */
- TK_VOL_UP, /* T10 */
- },
- .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
-};
-
-__override const struct ec_response_keybd_config
-*board_vivaldi_keybd_config(void)
-{
- return &halvor_kb;
-}
-
-/*
- * FW_CONFIG defaults for Halvor if the CBI data is not initialized.
- */
-union volteer_cbi_fw_config fw_config_defaults = {
- /* Set all FW_CONFIG fields default to 0 */
- .raw_value = 0,
-};
-
-static void board_init(void)
-{
- /* Illuminate motherboard and daughter board LEDs equally to start. */
- pwm_enable(PWM_CH_LED4_SIDESEL, 1);
- pwm_set_duty(PWM_CH_LED4_SIDESEL, 50);
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-
-__override enum tbt_compat_cable_speed board_get_max_tbt_speed(int port)
-{
- /* Routing length exceeds 205mm prior to connection to re-timer */
- if (port == USBC_PORT_C1)
- return TBT_SS_U32_GEN1_GEN2;
-
- /*
- * Thunderbolt-compatible mode not supported
- *
- * TODO (b/153995632): All the USB-C ports need to support same speed.
- * Need to fix once USB-C feature set is known for Halvor.
- */
- return TBT_SS_RES_0;
-}
-
-__override bool board_is_tbt_usb4_port(int port)
-{
- /*
- * On the volteer reference board 1 only port 1 supports TBT & USB4
- *
- * TODO (b/153995632): All the USB-C ports need to support same
- * features. Need to fix once USB-C feature set is known for Halvor.
- */
- return port == USBC_PORT_C1;
-}
-
-/******************************************************************************/
-/* I2C port map configuration */
-const struct i2c_port_t i2c_ports[] = {
- {
- .name = "sensor",
- .port = I2C_PORT_SENSOR,
- .kbps = 400,
- .scl = GPIO_EC_I2C_0_SCL,
- .sda = GPIO_EC_I2C_0_SDA,
- },
- {
- .name = "usb_c0",
- .port = I2C_PORT_USB_C0,
- .kbps = 1000,
- .scl = GPIO_EC_I2C_1_SCL,
- .sda = GPIO_EC_I2C_1_SDA,
- },
- {
- .name = "usb_c1",
- .port = I2C_PORT_USB_C1,
- .kbps = 1000,
- .scl = GPIO_EC_I2C_2_SCL,
- .sda = GPIO_EC_I2C_2_SDA,
- },
- {
- .name = "usb_bb_retimer",
- .port = I2C_PORT_USB_BB_RETIMER,
- .kbps = 100,
- .scl = GPIO_EC_I2C_3_SCL,
- .sda = GPIO_EC_I2C_3_SDA,
- },
- {
- .name = "usb_c2",
- .port = I2C_PORT_USB_C2,
- .kbps = 1000,
- .scl = GPIO_EC_I2C_4_SCL,
- .sda = GPIO_EC_I2C_4_SDA,
- },
- {
- .name = "power",
- .port = I2C_PORT_POWER,
- .kbps = 100,
- .scl = GPIO_EC_I2C_5_SCL,
- .sda = GPIO_EC_I2C_5_SDA,
- },
- {
- .name = "eeprom",
- .port = I2C_PORT_EEPROM,
- .kbps = 400,
- .scl = GPIO_EC_I2C_7_SCL,
- .sda = GPIO_EC_I2C_7_SDA,
- },
-};
-const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-
-/* PWM configuration */
-const struct pwm_t pwm_channels[] = {
- [PWM_CH_LED1_BLUE] = {
- .channel = 2,
- .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP,
- .freq = 2400,
- },
- [PWM_CH_LED2_GREEN] = {
- .channel = 0,
- .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP,
- .freq = 2400,
- },
- [PWM_CH_LED3_RED] = {
- .channel = 1,
- .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP,
- .freq = 2400,
- },
- [PWM_CH_LED4_SIDESEL] = {
- .channel = 7,
- .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP,
- /* Run at a higher frequency than the color PWM signals to avoid
- * timing-based color shifts.
- */
- .freq = 4800,
- },
- [PWM_CH_FAN] = {
- .channel = 5,
- .flags = PWM_CONFIG_OPEN_DRAIN,
- .freq = 25000
- },
- [PWM_CH_KBLIGHT] = {
- .channel = 3,
- .flags = 0,
- /*
- * Set PWM frequency to multiple of 50 Hz and 60 Hz to prevent
- * flicker. Higher frequencies consume similar average power to
- * lower PWM frequencies, but higher frequencies record a much
- * lower maximum power.
- */
- .freq = 2400,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-
-/******************************************************************************/
-/* EC thermal management configuration */
-
-/*
- * Tiger Lake specifies 100 C as maximum TDP temperature. THRMTRIP# occurs at
- * 130 C. However, sensor is located next to DDR, so we need to use the lower
- * DDR temperature limit (85 C)
- */
-const static struct ec_thermal_config thermal_cpu = {
- .temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(70),
- [EC_TEMP_THRESH_HALT] = C_TO_K(80),
- },
- .temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(65),
- },
- .temp_fan_off = C_TO_K(35),
- .temp_fan_max = C_TO_K(50),
-};
-
-/*
- * Inductor limits - used for both charger and PP3300 regulator
- *
- * Need to use the lower of the charger IC, PP3300 regulator, and the inductors
- *
- * Charger max recommended temperature 100C, max absolute temperature 125C
- * PP3300 regulator: operating range -40 C to 145 C
- *
- * Inductors: limit of 125c
- * PCB: limit is 80c
- */
-const static struct ec_thermal_config thermal_inductor = {
- .temp_host = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(75),
- [EC_TEMP_THRESH_HALT] = C_TO_K(80),
- },
- .temp_host_release = {
- [EC_TEMP_THRESH_HIGH] = C_TO_K(65),
- },
- .temp_fan_off = C_TO_K(40),
- .temp_fan_max = C_TO_K(55),
-};
-
-
-struct ec_thermal_config thermal_params[] = {
- [TEMP_SENSOR_1_CHARGER] = thermal_inductor,
- [TEMP_SENSOR_2_PP3300_REGULATOR] = thermal_inductor,
- [TEMP_SENSOR_3_DDR_SOC] = thermal_cpu,
- [TEMP_SENSOR_4_FAN] = thermal_cpu,
-};
-BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
-
-/******************************************************************************/
-void halvor_tcpc_alert_event(enum gpio_signal signal)
-{
- int port = -1;
-
- switch (signal) {
- case GPIO_USB_C0_TCPC_INT_ODL:
- port = USBC_PORT_C0;
- break;
- case GPIO_USB_C1_TCPC_INT_ODL:
- port = USBC_PORT_C1;
- break;
- case GPIO_USB_C2_TCPC_INT_ODL:
- port = USBC_PORT_C2;
- break;
- default:
- return;
- }
-
- ASSERT(port != -1);
- schedule_deferred_pd_interrupt(port);
-}
-
-void halvor_ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_PPC_INT_ODL:
- syv682x_interrupt(USBC_PORT_C0);
- break;
- case GPIO_USB_C1_PPC_INT_ODL:
- syv682x_interrupt(USBC_PORT_C1);
- break;
- case GPIO_USB_C2_PPC_INT_ODL:
- syv682x_interrupt(USBC_PORT_C2);
- break;
- default:
- break;
- }
-}
-
-void halvor_bc12_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_BC12_INT_ODL:
- task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12);
- break;
- case GPIO_USB_C1_BC12_INT_ODL:
- task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12);
- break;
- case GPIO_USB_C2_BC12_INT_ODL:
- task_set_event(TASK_ID_USB_CHG_P2, USB_CHG_EVENT_BC12);
- break;
-
- default:
- break;
- }
-}
-
-void board_reset_pd_mcu(void)
-{
- /* TODO (b/153705222): Need to implement three USB-C function */
-}
-
-__override void board_cbi_init(void)
-{
- /* TODO (b/153705222): Check FW_CONFIG for USB DB options */
-}
-
-/******************************************************************************/
-/* USBC PPC configuration */
-struct ppc_config_t ppc_chips[] = {
- [USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = SYV682X_ADDR0_FLAGS,
- .drv = &syv682x_drv,
- },
- [USBC_PORT_C1] = {
- .i2c_port = I2C_PORT_USB_C1,
- .i2c_addr_flags = SYV682X_ADDR0_FLAGS,
- .drv = &syv682x_drv,
- },
- [USBC_PORT_C2] = {
- .i2c_port = I2C_PORT_USB_C2,
- .i2c_addr_flags = SYV682X_ADDR0_FLAGS,
- .drv = &syv682x_drv,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT);
-unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-
-/******************************************************************************/
-/* BC1.2 charger detect configuration */
-const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
- [USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
- [USBC_PORT_C1] = {
- .i2c_port = I2C_PORT_USB_C1,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
- [USBC_PORT_C2] = {
- .i2c_port = I2C_PORT_USB_C2,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT);
-
-/******************************************************************************/
-/* USBC TCPC configuration */
-struct tcpc_config_t tcpc_config[] = {
- [USBC_PORT_C0] = {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C0,
- .addr_flags = TUSB422_I2C_ADDR_FLAGS,
- },
- .drv = &tusb422_tcpm_drv,
- },
- [USBC_PORT_C1] = {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C1,
- .addr_flags = TUSB422_I2C_ADDR_FLAGS,
- },
- .drv = &tusb422_tcpm_drv,
- },
- [USBC_PORT_C2] = {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C2,
- .addr_flags = TUSB422_I2C_ADDR_FLAGS,
- },
- .drv = &tusb422_tcpm_drv,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT);
-BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT);
-
-/******************************************************************************/
-/* USBC mux configuration - Tiger Lake includes internal mux */
-struct usb_mux usbc0_tcss_usb_mux = {
- .usb_port = USBC_PORT_C0,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
-};
-struct usb_mux usbc1_tcss_usb_mux = {
- .usb_port = USBC_PORT_C1,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
-};
-struct usb_mux usbc2_tcss_usb_mux = {
- .usb_port = USBC_PORT_C2,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
-};
-
-struct usb_mux usb_muxes[] = {
- [USBC_PORT_C0] = {
- .usb_port = USBC_PORT_C0,
- .next_mux = &usbc0_tcss_usb_mux,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_1_MIX,
- .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR,
- },
- [USBC_PORT_C1] = {
- .usb_port = USBC_PORT_C1,
- .next_mux = &usbc1_tcss_usb_mux,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_1_MIX,
- .i2c_addr_flags = USBC_PORT_C1_BB_RETIMER_I2C_ADDR,
- },
- [USBC_PORT_C2] = {
- .usb_port = USBC_PORT_C2,
- .next_mux = &usbc2_tcss_usb_mux,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_1_MIX,
- .i2c_addr_flags = USBC_PORT_C2_BB_RETIMER_I2C_ADDR,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
-
-struct bb_usb_control bb_controls[] = {
- [USBC_PORT_C0] = {
- .usb_ls_en_gpio = GPIO_USB_C0_LS_EN,
- .retimer_rst_gpio = GPIO_USB_C0_RT_RST_ODL,
- },
- [USBC_PORT_C1] = {
- .usb_ls_en_gpio = GPIO_USB_C1_LS_EN,
- .retimer_rst_gpio = GPIO_USB_C1_RT_RST_ODL,
- },
- [USBC_PORT_C2] = {
- .usb_ls_en_gpio = GPIO_USB_C2_LS_EN,
- .retimer_rst_gpio = GPIO_USB_C2_RT_RST_ODL,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(bb_controls) == USBC_PORT_COUNT);
-
-static void board_usb_chip_init(void)
-{
- /* Don't reset TCPCs after initial reset */
- if (!system_jumped_late())
- board_reset_pd_mcu();
-
- /* Enable PPC interrupts. */
- gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_ODL);
- gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL);
- gpio_enable_interrupt(GPIO_USB_C2_PPC_INT_ODL);
-
- /* Enable TCPC interrupts. */
- gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL);
- gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL);
- gpio_enable_interrupt(GPIO_USB_C2_TCPC_INT_ODL);
-
- /* Enable BC1.2 interrupts. */
- gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL);
- gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_ODL);
- gpio_enable_interrupt(GPIO_USB_C2_BC12_INT_ODL);
-}
-DECLARE_HOOK(HOOK_INIT, board_usb_chip_init, HOOK_PRIO_INIT_CHIPSET);
-
-/******************************************************************************/
-/* TCPC support routines */
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
-
- /*
- * Check which port has the ALERT line set
- */
- if (!gpio_get_level(GPIO_USB_C0_TCPC_INT_ODL))
- status |= PD_STATUS_TCPC_ALERT_0;
- if (!gpio_get_level(GPIO_USB_C1_TCPC_INT_ODL))
- status |= PD_STATUS_TCPC_ALERT_1;
- if (!gpio_get_level(GPIO_USB_C2_TCPC_INT_ODL))
- status |= PD_STATUS_TCPC_ALERT_2;
-
- return status;
-}
-
-int ppc_get_alert_status(int port)
-{
- if (port == USBC_PORT_C0)
- return gpio_get_level(GPIO_USB_C0_PPC_INT_ODL) == 0;
- else if (port == USBC_PORT_C1)
- return gpio_get_level(GPIO_USB_C1_PPC_INT_ODL) == 0;
- else
- return gpio_get_level(GPIO_USB_C2_PPC_INT_ODL) == 0;
-}