summaryrefslogtreecommitdiff
path: root/baseboard/volteer/baseboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'baseboard/volteer/baseboard.c')
-rw-r--r--baseboard/volteer/baseboard.c361
1 files changed, 0 insertions, 361 deletions
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c
deleted file mode 100644
index 4565822977..0000000000
--- a/baseboard/volteer/baseboard.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/* Copyright 2019 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 family-specific configuration */
-#include "adc_chip.h"
-#include "charge_manager.h"
-#include "charge_state.h"
-#include "driver/bc12/pi3usb9201.h"
-#include "driver/ppc/sn5s330.h"
-#include "driver/tcpm/tusb422.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "keyboard_scan.h"
-#include "pwm.h"
-#include "pwm_chip.h"
-#include "usbc_ppc.h"
-#include "usb_mux.h"
-#include "usb_pd.h"
-#include "usb_pd_tcpm.h"
-#include "util.h"
-
-#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_CHIPSET, format, ## args)
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ## args)
-
-/******************************************************************************/
-/* ADC configuration */
-const struct adc_t adc_channels[] = {
- [ADC_TEMP_SENSOR_1_CHARGER] = {
- .name = "TEMP_CHARGER",
- .input_ch = NPCX_ADC_CH0,
- .factor_mul = ADC_MAX_VOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- },
- [ADC_TEMP_SENSOR_2_PP3300_REGULATOR] = {
- .name = "TEMP_PP3300_REGULATOR",
- .input_ch = NPCX_ADC_CH1,
- .factor_mul = ADC_MAX_VOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- },
- [ADC_TEMP_SENSOR_3_DDR_SOC] = {
- .name = "TEMP_DDR_SOC",
- .input_ch = NPCX_ADC_CH8,
- .factor_mul = ADC_MAX_VOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- },
- [ADC_TEMP_SENSOR_4_FAN] = {
- .name = "TEMP_FAN",
- .input_ch = NPCX_ADC_CH3,
- .factor_mul = ADC_MAX_VOLT,
- .factor_div = ADC_READ_MAX + 1,
- .shift = 0,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
-
-/******************************************************************************/
-/* 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,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT);
-
-/******************************************************************************/
-/* Wake up pins */
-const enum gpio_signal hibernate_wake_pins[] = {
- GPIO_LID_OPEN,
- GPIO_ACOK_OD,
- GPIO_POWER_BUTTON_L,
- GPIO_EC_RST_ODL,
-};
-const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
-
-/******************************************************************************/
-/* Keyboard scan setting */
-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, 0xf5, 0xff,
- 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */
- },
-};
-
-/******************************************************************************/
-/* I2C port map configuration */
-const struct i2c_port_t i2c_ports[] = {
- {
- .name = "sensor",
- .port = I2C_PORT_SENSOR,
- .kbps = 400,
- .scl = GPIO_EC_I2C0_SENSOR_SCL,
- .sda = GPIO_EC_I2C0_SENSOR_SDA,
- },
- {
- .name = "usb_c0",
- .port = I2C_PORT_USB_C0,
- /* TODO: design supports 1 MHz, set to 100 KHz for bringup */
- .kbps = 100,
- .scl = GPIO_EC_I2C1_USB_C0_SCL,
- .sda = GPIO_EC_I2C1_USB_C0_SDA,
- },
- {
- .name = "usb_c1",
- .port = I2C_PORT_USB_C1,
- /* TODO: design supports 1 MHz, set to 100 KHz for bringup */
- .kbps = 100,
- .scl = GPIO_EC_I2C2_USB_C1_SCL,
- .sda = GPIO_EC_I2C2_USB_C1_SDA,
- },
- {
- .name = "usb_1_mix",
- .port = I2C_PORT_USB_1_MIX,
- .kbps = 100,
- .scl = GPIO_EC_I2C3_USB_1_MIX_SCL,
- .sda = GPIO_EC_I2C3_USB_1_MIX_SDA,
- },
- {
- .name = "power",
- .port = I2C_PORT_POWER,
- .kbps = 100,
- .scl = GPIO_EC_I2C5_POWER_SCL,
- .sda = GPIO_EC_I2C5_POWER_SDA,
- },
- {
- .name = "eeprom",
- .port = I2C_PORT_EEPROM,
- .kbps = 400,
- .scl = GPIO_EC_I2C7_EEPROM_SCL,
- .sda = GPIO_EC_I2C7_EEPROM_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 = 100,
- },
- [PWM_CH_LED2_GREEN] = {
- .channel = 0,
- .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP,
- .freq = 100,
- },
- [PWM_CH_LED3_RED] = {
- .channel = 1,
- .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP,
- .freq = 100,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-
-
-
-
-
-/******************************************************************************/
-/* USBC TCPC configuration */
-const 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,
- .usb23 = USBC_PORT_0_USB2_NUM | (USBC_PORT_0_USB3_NUM << 4),
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT);
-BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT);
-
-/******************************************************************************/
-/* USBC PPC configuration */
-struct ppc_config_t ppc_chips[] = {
- [USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
- .drv = &sn5s330_drv
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT);
-unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-
-/******************************************************************************/
-/* USBC mux configuration - Tiger Lake includes internal mux */
-struct usb_mux usb_muxes[] = {
- [USBC_PORT_C0] = {
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
-
-
-static void baseboard_tcpc_init(void)
-{
- /* Enable PPC interrupts. */
- gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_ODL);
-
- /* Enable TCPC interrupts. */
- gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL);
-}
-DECLARE_HOOK(HOOK_INIT, baseboard_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
-
-/******************************************************************************/
-/* PPC support routines */
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_PPC_INT_ODL:
- sn5s330_interrupt(USBC_PORT_C0);
- break;
-
- default:
- break;
- }
-}
-
-/******************************************************************************/
-/* TCPC support routines */
-void board_reset_pd_mcu(void)
-{
- /* No reset available for TCPC on port 0 */
-}
-
-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;
-
- return status;
-}
-
-void tcpc_alert_event(enum gpio_signal signal)
-{
- /* TODO: b/140572591 - check correct operation for Volteer */
-
- int port = -1;
-
- switch (signal) {
- case GPIO_USB_C0_TCPC_INT_ODL:
- port = 0;
- break;
- default:
- return;
- }
-
- schedule_deferred_pd_interrupt(port);
-}
-
-int board_set_active_charge_port(int port)
-{
- /* TODO: b/140561826 - check correct operation for Volteer */
-
- int is_valid_port = (port >= 0 &&
- port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
-
- if (port == CHARGE_PORT_NONE) {
- CPRINTSUSB("Disabling all charger ports");
-
- /* Disable all ports. */
- for (i = 0; i < ppc_cnt; i++) {
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (ppc_vbus_sink_enable(i, 0))
- CPRINTSUSB("Disabling C%d as sink failed.", i);
- }
-
- return EC_SUCCESS;
- } else if (!is_valid_port) {
- return EC_ERROR_INVAL;
- }
-
-
- /* Check if the port is sourcing VBUS. */
- if (ppc_is_sourcing_vbus(port)) {
- CPRINTFUSB("Skip enable C%d", port);
- return EC_ERROR_INVAL;
- }
-
- CPRINTSUSB("New charge port: C%d", port);
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < ppc_cnt; i++) {
- if (i == port)
- continue;
-
- if (ppc_vbus_sink_enable(i, 0))
- CPRINTSUSB("C%d: sink path disable failed.", i);
- }
-
- /* Enable requested charge port. */
- if (ppc_vbus_sink_enable(port, 1)) {
- CPRINTSUSB("C%d: sink path enable failed.", port);
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(MAX(charge_ma,
- CONFIG_CHARGER_INPUT_CURRENT),
- charge_mv);
-}
-
-void board_overcurrent_event(int port, int is_overcurrented)
-{
- /* TODO: b/140561826 - check correct operation for Volteer */
-}
-
-/*
- * Enable fan for 100% speed when AP is powered on.
- * TODO: b/ remove this once PWM control is working.
- */
-static void board_chipset_startup(void)
-{
- gpio_set_level_verbose(CC_SYSTEM, GPIO_EN_PP5000_FAN, 1);
-}
-DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT);
-
-static void board_chipset_shutdown(void)
-{
- gpio_set_level_verbose(CC_SYSTEM, GPIO_EN_PP5000_FAN, 0);
-}
-DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
-