diff options
Diffstat (limited to 'board/oak')
-rw-r--r-- | board/oak/battery.c | 72 | ||||
-rw-r--r-- | board/oak/board.c | 732 | ||||
-rw-r--r-- | board/oak/board.h | 263 | ||||
-rw-r--r-- | board/oak/board_revs.h | 26 | ||||
-rw-r--r-- | board/oak/build.mk | 14 | ||||
-rw-r--r-- | board/oak/ec.tasklist | 46 | ||||
-rw-r--r-- | board/oak/gpio.inc | 214 | ||||
-rw-r--r-- | board/oak/led.c | 266 | ||||
-rw-r--r-- | board/oak/usb_pd_policy.c | 106 | ||||
-rw-r--r-- | board/oak/vif_override.xml | 3 |
10 files changed, 0 insertions, 1742 deletions
diff --git a/board/oak/battery.c b/board/oak/battery.c deleted file mode 100644 index fffd2f7763..0000000000 --- a/board/oak/battery.c +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright 2015 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.h" -#include "battery_smart.h" -#include "i2c.h" -#include "util.h" - -/* Shutdown mode parameter to write to manufacturer access register */ -#define PARAM_CUT_OFF_LOW 0x10 -#define PARAM_CUT_OFF_HIGH 0x00 - -static const struct battery_info info = { -#if (BOARD_REV >= OAK_REV3) - .voltage_max = 13050, - .voltage_normal = 11400, - /* - * TODO(crosbug.com/p/44428): - * In order to compatible with 2S battery, set min voltage as 6V rather - * than 9V. Should set voltage_min to 9V, when 2S battery - * phased out. - */ - .voltage_min = 6000, -#else /* BOARD_REV < OAK_REV3 */ - .voltage_max = 8700, - .voltage_normal = 7600, - .voltage_min = 6000, -#endif - /* Pre-charge values. */ - .precharge_current = 256, /* mA */ - - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 45, - .discharging_min_c = 0, - .discharging_max_c = 60, -}; - -const struct battery_info *battery_get_info(void) -{ - return &info; -} - -static int cutoff(void) -{ - int rv; - uint8_t buf[3]; - - /* Ship mode command must be sent twice to take effect */ - buf[0] = SB_MANUFACTURER_ACCESS & 0xff; - buf[1] = PARAM_CUT_OFF_LOW; - buf[2] = PARAM_CUT_OFF_HIGH; - - i2c_lock(I2C_PORT_BATTERY, 1); - rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, - buf, 3, NULL, 0, I2C_XFER_SINGLE); - rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, - buf, 3, NULL, 0, I2C_XFER_SINGLE); - i2c_lock(I2C_PORT_BATTERY, 0); - - return rv; -} - -int board_cut_off_battery(void) -{ - return cutoff(); -} diff --git a/board/oak/board.c b/board/oak/board.c deleted file mode 100644 index e8eba6d45b..0000000000 --- a/board/oak/board.c +++ /dev/null @@ -1,732 +0,0 @@ -/* Copyright 2015 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. - */ - -/* Oak board configuration */ - -#include "adc.h" -#include "als.h" -#include "atomic.h" -#include "battery.h" -#include "charge_manager.h" -#include "charge_state.h" -#include "charger.h" -#include "chipset.h" -#include "common.h" -#include "console.h" -#include "driver/accel_kionix.h" -#include "driver/accel_kx022.h" -#include "driver/accelgyro_bmi_common.h" -#include "driver/als_opt3001.h" -#include "driver/charger/isl923x.h" -#include "driver/tcpm/tcpci.h" -#include "driver/temp_sensor/tmp432.h" -#include "driver/usb_mux/pi3usb3x532.h" -#include "extpower.h" -#include "gpio.h" -#include "hooks.h" -#include "host_command.h" -#include "i2c.h" -#include "keyboard_raw.h" -#include "keyboard_scan.h" -#include "lid_switch.h" -#include "math_util.h" -#include "motion_lid.h" -#include "motion_sense.h" -#include "pi3usb9281.h" -#include "power.h" -#include "power_button.h" -#include "registers.h" -#include "spi.h" -#include "switch.h" -#include "system.h" -#include "task.h" -#include "temp_sensor.h" -#include "temp_sensor_chip.h" -#include "thermal.h" -#include "timer.h" -#include "usb_charge.h" -#include "usb_mux.h" -#include "usb_pd.h" -#include "usb_pd_tcpm.h" -#include "util.h" - -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) - -/* Dispaly port hardware can connect to port 0, 1 or neither. */ -#define PD_PORT_NONE -1 - -void pd_mcu_interrupt(enum gpio_signal signal) -{ - /* Exchange status with PD MCU to determine interrupt cause */ - host_command_pd_send_status(0); -} - -#if BOARD_REV >= OAK_REV4 -void usb_evt(enum gpio_signal signal) -{ - task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_INTR); - task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_INTR); -} -#endif /* BOARD_REV >= OAK_REV4 */ - -#include "gpio_list.h" - -/* power signal list. Must match order of enum power_signal. */ -const struct power_signal_info power_signal_list[] = { - {GPIO_SOC_POWER_GOOD, POWER_SIGNAL_ACTIVE_HIGH, "POWER_GOOD"}, - {GPIO_SUSPEND_L, POWER_SIGNAL_ACTIVE_LOW, "SUSPEND#_ASSERTED"}, -}; -BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); - -/* ADC channels */ -const struct adc_t adc_channels[] = { - /* - * PSYS_MONITOR(PA2): ADC_IN2, 1.44 uA/W on 6.05k Ohm - * output in mW - */ - [ADC_PSYS] = {"PSYS", 379415, 4096, 0, STM32_AIN(2)}, - /* AMON_BMON(PC0): ADC_IN10, output in uV */ - [ADC_AMON_BMON] = {"AMON_BMON", 183333, 4096, 0, STM32_AIN(10)}, - /* VDC_BOOSTIN_SENSE(PC1): ADC_IN11, output in mV */ - [ADC_VBUS] = {"VBUS", 33000, 4096, 0, STM32_AIN(11)}, -}; -BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); - -/* I2C ports */ -const struct i2c_port_t i2c_ports[] = { - {"battery", I2C_PORT_BATTERY, 100, GPIO_I2C0_SCL, GPIO_I2C0_SDA}, - {"pd", I2C_PORT_PD_MCU, 1000, GPIO_I2C1_SCL, GPIO_I2C1_SDA} -}; - -const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); - -#ifdef CONFIG_ACCELGYRO_BMI160 -/* SPI devices */ -const struct spi_device_t spi_devices[] = { - { CONFIG_SPI_ACCEL_PORT, 1, GPIO_SPI2_NSS } -}; -const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); -#endif - -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_TCPC, - .addr_flags = CONFIG_TCPC_I2C_BASE_ADDR_FLAGS, - }, - .drv = &tcpci_tcpm_drv, - }, - { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_TCPC, - .addr_flags = CONFIG_TCPC_I2C_BASE_ADDR_FLAGS + 1, - }, - .drv = &tcpci_tcpm_drv, - }, -}; - -struct mutex pericom_mux_lock; -struct pi3usb9281_config pi3usb9281_chips[] = { - { - .i2c_port = I2C_PORT_PERICOM, - .mux_gpio = GPIO_USB_C_BC12_SEL, - .mux_gpio_level = 0, - .mux_lock = &pericom_mux_lock, - }, - { - .i2c_port = I2C_PORT_PERICOM, - .mux_gpio = GPIO_USB_C_BC12_SEL, - .mux_gpio_level = 1, - .mux_lock = &pericom_mux_lock, - }, -}; -BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) == - CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT); - -#if BOARD_REV == OAK_REV1 -const struct charger_config_t chg_chips[] = { - { - .i2c_port = I2C_PORT_CHARGER, - .i2c_addr_flags = I2C_ADDR_CHARGER_FLAGS, - .drv = &bq2477x_drv, - }, -}; -#else -const struct charger_config_t chg_chips[] = { - { - .i2c_port = I2C_PORT_CHARGER, - .i2c_addr_flags = ISL923X_ADDR_FLAGS, - .drv = &isl923x_drv, - }, -}; -#endif /* OAK_REV1 */ - -/* - * Temperature sensors data; must be in same order as enum temp_sensor_id. - * Sensor index and name must match those present in coreboot: - * src/mainboard/google/${board}/acpi/dptf.asl - */ -const struct temp_sensor_t temp_sensors[] = { - {"TMP432_Internal", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val, - TMP432_IDX_LOCAL}, - {"TMP432_Sensor_1", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val, - TMP432_IDX_REMOTE1}, - {"TMP432_Sensor_2", TEMP_SENSOR_TYPE_BOARD, tmp432_get_val, - TMP432_IDX_REMOTE2}, - {"Battery", TEMP_SENSOR_TYPE_BATTERY, charge_get_battery_temp, - 0}, -}; -BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); - -#ifdef HAS_TASK_ALS -/* ALS instances. Must be in same order as enum als_id. */ -struct als_t als[] = { - {"TI", opt3001_init, opt3001_read_lux, 5}, -}; -BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT); -#endif - -const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .usb_port = 0, - .i2c_port = I2C_PORT_USB_MUX, - .i2c_addr_flags = PI3USB3X532_I2C_ADDR0, - .driver = &pi3usb3x532_usb_mux_driver, - }, - { - .usb_port = 1, - .i2c_port = I2C_PORT_USB_MUX, -#if (BOARD_REV <= OAK_REV4) - .i2c_addr_flags = PI3USB3X532_I2C_ADDR1, - .driver = &pi3usb3x532_usb_mux_driver, -#else - .i2c_addr_flags = 0x10, - .driver = &ps8740_usb_mux_driver, -#endif - }, -}; - -/** - * Store the current DP hardware route. - */ -static int dp_hw_port = PD_PORT_NONE; -static struct mutex dp_hw_lock; - -/** - * Reset PD MCU - */ -void board_reset_pd_mcu(void) -{ - gpio_set_level(GPIO_USB_PD_RST_L, 0); - usleep(100); - gpio_set_level(GPIO_USB_PD_RST_L, 1); -} - -/** - * There is a level shift for AC_OK & LID_OPEN signal between AP & EC, - * disable it (drive high) when AP is off, otherwise enable it (drive low). - */ -static void board_extpower_buffer_to_soc(void) -{ - /* Drive high when AP is off (G3), else drive low */ - gpio_set_level(GPIO_LEVEL_SHIFT_EN_L, - chipset_in_state(CHIPSET_STATE_HARD_OFF) ? 1 : 0); -} - -/* Initialize board. */ -static void board_init(void) -{ - /* - * Assert wake GPIO to PD MCU to wake it from hibernate. - * This cannot be done from board_pre_init() (or from any function - * called before system_pre_init()), otherwise a spurious wake will - * occur -- see stm32 check_reset_cause() WORKAROUND comment. - */ - gpio_set_level(GPIO_USB_PD_VBUS_WAKE, 1); - - /* Enable Level shift of AC_OK & LID_OPEN signals */ - board_extpower_buffer_to_soc(); - /* Enable rev1 testing GPIOs */ - gpio_set_level(GPIO_SYSTEM_POWER_H, 1); - /* Enable PD MCU interrupt */ - gpio_enable_interrupt(GPIO_PD_MCU_INT); - -#if BOARD_REV >= OAK_REV4 - /* Enable BC 1.2 interrupt */ - gpio_enable_interrupt(GPIO_USB_BC12_INT); -#endif /* BOARD_REV >= OAK_REV4 */ - -#if BOARD_REV >= OAK_REV3 - /* Update VBUS supplier */ - usb_charger_vbus_change(0, !gpio_get_level(GPIO_USB_C0_VBUS_WAKE_L)); - usb_charger_vbus_change(1, !gpio_get_level(GPIO_USB_C1_VBUS_WAKE_L)); -#else - usb_charger_vbus_change(0, 0); - usb_charger_vbus_change(1, 0); -#endif - -#ifdef CONFIG_ACCELGYRO_BMI160 - /* SPI sensors: put back the GPIO in its expected state */ - gpio_set_level(GPIO_SPI2_NSS, 1); - - /* Remap SPI2 to DMA channels 6 and 7 (0011) */ - STM32_DMA_CSELR(STM32_DMAC_CH6) |= (3 << 20) | (3 << 24); - - /* Enable SPI for BMI160 */ - gpio_config_module(MODULE_SPI_CONTROLLER, 1); - - /* Set all four SPI pins to high speed */ - /* pins D0/D1/D3/D4 */ - STM32_GPIO_OSPEEDR(GPIO_D) |= 0x000003cf; - - /* Enable clocks to SPI2 module */ - STM32_RCC_APB1ENR |= STM32_RCC_PB1_SPI2; - - /* Reset SPI2 */ - STM32_RCC_APB1RSTR |= STM32_RCC_PB1_SPI2; - STM32_RCC_APB1RSTR &= ~STM32_RCC_PB1_SPI2; - - spi_enable(&spi_devices[0], 1); - CPRINTS("Board using SPI sensors"); -#endif -} -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); - -/** - * Set active charge port -- only one port can active at a time. - * - * @param charge_port Charge port to enable. - * - * Return EC_SUCCESS if charge port is accepted and made active. - * EC_ERROR_* otherwise. - */ -int board_set_active_charge_port(int charge_port) -{ - /* charge port is a physical port */ - int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); - /* check if we are source VBUS on the port */ - int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : - GPIO_USB_C1_5V_EN); - - if (is_real_port && source) { - CPRINTF("Skip enable p%d", charge_port); - return EC_ERROR_INVAL; - } - - CPRINTF("New chg p%d", charge_port); - - if (charge_port == CHARGE_PORT_NONE) { - /* Disable both ports */ - gpio_set_level(GPIO_USB_C0_CHARGE_L, 1); - gpio_set_level(GPIO_USB_C1_CHARGE_L, 1); - } else { - /* Make sure non-charging port is disabled */ - gpio_set_level(charge_port ? GPIO_USB_C0_CHARGE_L : - GPIO_USB_C1_CHARGE_L, 1); - /* Enable charging port */ - gpio_set_level(charge_port ? GPIO_USB_C1_CHARGE_L : - GPIO_USB_C0_CHARGE_L, 0); - } - - return EC_SUCCESS; -} - -/** - * Set the charge limit based upon desired maximum. - * - * @param port Port number. - * @param supplier Charge supplier type. - * @param charge_ma Desired charge limit (mA). - * @param charge_mv Negotiated charge voltage (mV). - */ -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); - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -/* - * timestamp of the next possible toggle to ensure the 2-ms spacing - * between IRQ_HPD. - */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_MAX_COUNT]; - -static void board_typec_set_dp_hpd(int port, int level) -{ -#if BOARD_REV >= OAK_REV5 - if (1 == dp_hw_port) - gpio_set_level(GPIO_C1_DP_HPD, level); -#endif - - gpio_set_level(GPIO_USB_DP_HPD, level); -} - -/** - * Turn on DP hardware on type-C port. - */ -void board_typec_dp_on(int port) -{ - mutex_lock(&dp_hw_lock); - - if (dp_hw_port != !port) { - /* Get control of DP hardware */ - dp_hw_port = port; -#if BOARD_REV == OAK_REV2 || BOARD_REV >= OAK_REV5 - /* Rev2 or Rev5 later board has DP switch */ - gpio_set_level(GPIO_DP_SWITCH_CTL, port); -#endif - if (!gpio_get_level(GPIO_USB_DP_HPD)) { - board_typec_set_dp_hpd(port, 1); - } else { - uint64_t now = get_time().val; - /* wait for the minimum spacing between IRQ_HPD */ - if (now < hpd_deadline[port]) - usleep(hpd_deadline[port] - now); - - board_typec_set_dp_hpd(port, 0); - usleep(HPD_DSTREAM_DEBOUNCE_IRQ); - board_typec_set_dp_hpd(port, 1); - } - } - /* enforce 2-ms delay between HPD pulses */ - hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - - mutex_unlock(&dp_hw_lock); -} - -/** - * Turn off a PD port's DP output. - */ -void board_typec_dp_off(int port, int *dp_flags) -{ - mutex_lock(&dp_hw_lock); - - if (dp_hw_port == !port) { - mutex_unlock(&dp_hw_lock); - return; - } - - dp_hw_port = PD_PORT_NONE; - board_typec_set_dp_hpd(port, 0); - - mutex_unlock(&dp_hw_lock); - - /* Enable the other port if its dp flag is on */ - if (dp_flags[!port] & DP_FLAGS_DP_ON) - board_typec_dp_on(!port); -} - -/** - * Set DP hotplug detect level. - */ -void board_typec_dp_set(int port, int level) -{ - mutex_lock(&dp_hw_lock); - - if (dp_hw_port == PD_PORT_NONE) { - dp_hw_port = port; -#if BOARD_REV == OAK_REV2 || BOARD_REV >= OAK_REV5 - /* Rev2 or Rev5 later board has DP switch */ - gpio_set_level(GPIO_DP_SWITCH_CTL, port); -#endif - } - - if (dp_hw_port == port) - board_typec_set_dp_hpd(port, level); - - mutex_unlock(&dp_hw_lock); -} - -#if BOARD_REV < OAK_REV3 -#ifndef CONFIG_AP_WARM_RESET_INTERRUPT -/* Using this hook if system doesn't have enough external line. */ -static void check_ap_reset_second(void) -{ - /* Check the warm reset signal from servo board */ - static int warm_reset, last; - - warm_reset = !gpio_get_level(GPIO_AP_RESET_L); - - if (last == warm_reset) - return; - - if (warm_reset) - chipset_reset(); /* Warm reset AP */ - - last = warm_reset; -} -DECLARE_HOOK(HOOK_SECOND, check_ap_reset_second, HOOK_PRIO_DEFAULT); -#endif -#endif - -/** - * Set AP reset. - * - * PMIC_WARM_RESET_H (PB3) is connected to PMIC RESET before rev < 3. - * AP_RESET_L (PC3, CPU_WARM_RESET_L) is connected to PMIC SYSRSTB - * after rev >= 3. - */ -void board_set_ap_reset(int asserted) -{ - if (system_get_board_version() < 3) { - /* Signal is active-high */ - CPRINTS("pmic warm reset(%d)", asserted); - gpio_set_level(GPIO_PMIC_WARM_RESET_H, asserted); - } else { - /* Signal is active-low */ - CPRINTS("ap warm reset(%d)", asserted); - gpio_set_level(GPIO_AP_RESET_L, !asserted); - } -} - -#if BOARD_REV < OAK_REV4 -/** - * Check VBUS state and trigger USB BC1.2 charger. - */ -void vbus_task(void *u) -{ - struct { - uint8_t interrupt; - uint8_t device_type; - uint8_t charger_status; - uint8_t vbus; - } bc12[CONFIG_USB_PD_PORT_MAX_COUNT]; - uint8_t port, vbus, reg, wake; - - while (1) { - for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++) { -#if BOARD_REV == OAK_REV3 - vbus = !gpio_get_level(port ? GPIO_USB_C1_VBUS_WAKE_L : - GPIO_USB_C0_VBUS_WAKE_L); -#else - vbus = tcpm_check_vbus_level(port, VBUS_PRESENT); -#endif - /* check if VBUS changed */ - if (((bc12[port].vbus >> port) & 1) == vbus) - continue; - /* wait 1.2 seconds and check BC 1.2 status */ - msleep(1200); - - if (vbus) - bc12[port].vbus |= 1 << port; - else - bc12[port].vbus &= ~BIT(port); - - wake = 0; - reg = pi3usb9281_get_interrupts(port); - if (reg != bc12[port].interrupt) { - bc12[port].interrupt = reg; - wake++; - } - - reg = pi3usb9281_get_device_type(port); - if (reg != bc12[port].device_type) { - bc12[port].device_type = reg; - wake++; - } - - reg = pi3usb9281_get_charger_status(port); - if (reg != bc12[port].charger_status) { - bc12[port].charger_status = reg; - wake++; - } - - if (wake) - task_set_event(port ? TASK_ID_USB_CHG_P1 : - TASK_ID_USB_CHG_P0, - USB_CHG_EVENT_BC12); - } - task_wait_event(-1); - } -} -#else -void vbus_task(void *u) -{ - while (1) - task_wait_event(-1); -} -#endif /* BOARD_REV < OAK_REV4 */ - -#ifdef CONFIG_TEMP_SENSOR_TMP432 -static void tmp432_set_power_deferred(void) -{ - /* Shut tmp432 down if not in S0 && no external power */ - if (!extpower_is_present() && !chipset_in_state(CHIPSET_STATE_ON)) { - if (EC_SUCCESS != tmp432_set_power(TMP432_POWER_OFF)) - CPRINTS("ERROR: Can't shutdown TMP432."); - return; - } - - /* else, turn it on. */ - if (EC_SUCCESS != tmp432_set_power(TMP432_POWER_ON)) - CPRINTS("ERROR: Can't turn on TMP432."); -} -DECLARE_DEFERRED(tmp432_set_power_deferred); -#endif - -/** - * Hook of AC change. turn on/off tmp432 depends on AP & AC status. - */ -static void board_extpower(void) -{ - board_extpower_buffer_to_soc(); -#ifdef CONFIG_TEMP_SENSOR_TMP432 - hook_call_deferred(&tmp432_set_power_deferred_data, 0); -#endif -} -DECLARE_HOOK(HOOK_AC_CHANGE, board_extpower, HOOK_PRIO_DEFAULT); - -/* Called on AP S5 -> S3 transition, and before HOOK_CHIPSET_STARTUP */ -static void board_chipset_pre_init(void) -{ - /* Enable level shift of AC_OK when power on */ - board_extpower_buffer_to_soc(); -#if BOARD_REV >= OAK_REV5 - /* Enable DP muxer */ - gpio_set_level(GPIO_DP_MUX_EN_L , 0); - gpio_set_level(GPIO_PARADE_MUX_EN, 1); -#endif -} -DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT); - -/* Called on AP S3 -> S5 transition */ -static void board_chipset_shutdown(void) -{ - /* Disable level shift to SoC when shutting down */ - gpio_set_level(GPIO_LEVEL_SHIFT_EN_L, 1); -#if BOARD_REV >= OAK_REV5 - /* Disable DP muxer */ - gpio_set_level(GPIO_DP_MUX_EN_L , 1); - gpio_set_level(GPIO_PARADE_MUX_EN, 0); -#endif -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); - - -/* Called on AP S3 -> S0 transition */ -static void board_chipset_resume(void) -{ -#ifdef CONFIG_TEMP_SENSOR_TMP432 - hook_call_deferred(&tmp432_set_power_deferred_data, 0); -#endif -} -DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT); - -/* Called on AP S0 -> S3 transition */ -static void board_chipset_suspend(void) -{ -#ifdef CONFIG_TEMP_SENSOR_TMP432 - hook_call_deferred(&tmp432_set_power_deferred_data, 0); -#endif -} -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); - -#ifdef HAS_TASK_MOTIONSENSE -/* Motion sensors */ -/* Mutexes */ -#ifdef CONFIG_ACCEL_KX022 -static struct mutex g_lid_mutex; -#endif -#ifdef CONFIG_ACCELGYRO_BMI160 -static struct mutex g_base_mutex; - -/* Matrix to rotate accelrator into standard reference frame */ -const mat33_fp_t base_standard_ref = { - { FLOAT_TO_FP(-1), 0, 0}, - { 0, FLOAT_TO_FP(-1), 0}, - { 0, 0, FLOAT_TO_FP(1)} -}; -#endif - -static struct kionix_accel_data g_kx022_data; -static struct bmi_drv_data_t g_bmi160_data; - -struct motion_sensor_t motion_sensors[] = { -#ifdef CONFIG_ACCELGYRO_BMI160 - /* - * Note: bmi160: supports accelerometer and gyro sensor - * Requirement: accelerometer sensor must init before gyro sensor - * DO NOT change the order of the following table. - */ - [BASE_ACCEL] = { - .name = "Base Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = I2C_PORT_ACCEL, - .i2c_spi_addr_flags = ACCEL_MK_SPI_ADDR_FLAGS(0), - .rot_standard_ref = &base_standard_ref, - .default_range = 4, /* g, to meet CDD 7.3.1/C-1-4 reqs */ - .min_frequency = BMI_ACCEL_MIN_FREQ, - .max_frequency = BMI_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, - }, - - [BASE_GYRO] = { - .name = "Base Gyro", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_BMI160, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_BASE, - .drv = &bmi160_drv, - .mutex = &g_base_mutex, - .drv_data = &g_bmi160_data, - .port = I2C_PORT_ACCEL, - .i2c_spi_addr_flags = ACCEL_MK_SPI_ADDR_FLAGS(0), - .default_range = 1000, /* dps */ - .rot_standard_ref = &base_standard_ref, - .min_frequency = BMI_GYRO_MIN_FREQ, - .max_frequency = BMI_GYRO_MAX_FREQ, - }, -#endif -#ifdef CONFIG_ACCEL_KX022 - [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_KX022, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &kionix_accel_drv, - .mutex = &g_lid_mutex, - .drv_data = &g_kx022_data, - .port = I2C_PORT_ACCEL, - .i2c_spi_addr_flags = KX022_ADDR1_FLAGS, - .rot_standard_ref = NULL, /* Identity matrix. */ - .default_range = 2, /* g, to support lid angle calculation. */ - .min_frequency = KX022_ACCEL_MIN_FREQ, - .max_frequency = KX022_ACCEL_MAX_FREQ, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 100 * MSEC, - }, - }, - }, -#endif -}; -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); - -__override void lid_angle_peripheral_enable(int enable) -{ - keyboard_scan_enable(enable, KB_SCAN_DISABLE_LID_ANGLE); -} -#endif /* defined(HAS_TASK_MOTIONSENSE) */ diff --git a/board/oak/board.h b/board/oak/board.h deleted file mode 100644 index e82907a508..0000000000 --- a/board/oak/board.h +++ /dev/null @@ -1,263 +0,0 @@ -/* Copyright 2015 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. - */ - -/* oak board configuration */ - -#ifndef __CROS_EC_BOARD_H -#define __CROS_EC_BOARD_H - -/* board revision */ -#include "board_revs.h" - -/* Free up some flash space */ -#define CONFIG_DEBUG_ASSERT_BRIEF -#define CONFIG_USB_PD_DEBUG_LEVEL 0 - -#define CONFIG_LTO - -#if BOARD_REV >= OAK_REV5 -#define CONFIG_ACCELGYRO_BMI160 -#define CONFIG_ACCEL_KX022 -#define CONFIG_CMD_ACCELS -#define CONFIG_CMD_ACCEL_INFO -#endif - -#define CONFIG_ADC -#undef CONFIG_ADC_WATCHDOG - -#if BOARD_REV >= OAK_REV5 -/* Add for Ambient Light Sensor */ -#define CONFIG_ALS_OPT3001 -#define CONFIG_CMD_ALS -#endif - -/* Add for AC adaptor, charger, battery */ -#define CONFIG_BATTERY_CUT_OFF -#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L -#define CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD -#define CONFIG_BATTERY_SMART -#define CONFIG_CHARGE_MANAGER -#define CONFIG_CHARGER - -#define CONFIG_CHARGER_INPUT_CURRENT 512 - -#if BOARD_REV == OAK_REV1 -#define CONFIG_CHARGER_BQ24773 -#define CONFIG_CHARGER_MAX_INPUT_CURRENT 2150 -#define CONFIG_CHARGER_SENSE_RESISTOR 10 -#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10 -#else -#define CONFIG_CHARGE_RAMP_HW -#define CONFIG_CHARGER_ISL9237 -#define CONFIG_CHARGER_MAX_INPUT_CURRENT 2250 -#define CONFIG_CHARGER_SENSE_RESISTOR 10 -#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 -#endif /* BOARD_REV */ - -#define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHIPSET_MT817X -#define CONFIG_CMD_TYPEC -#define CONFIG_EXTPOWER_GPIO -#define CONFIG_FORCE_CONSOLE_RESUME - -/* - * EC_WAKE: PA0 - WKUP1 - * POWER_BUTTON_L: PB5 - WKUP6 - */ -#define CONFIG_HIBERNATE -#if BOARD_REV <= OAK_REV4 -#define CONFIG_HIBERNATE_WAKEUP_PINS (STM32_PWR_CSR_EWUP6) -#else -#define CONFIG_HIBERNATE_WAKEUP_PINS (STM32_PWR_CSR_EWUP1) -#define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL -#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL -#define CONFIG_LID_ANGLE_UPDATE -#endif /* BOARD_REV */ -#define CONFIG_HOST_COMMAND_STATUS -#define CONFIG_HOSTCMD_PD -#define CONFIG_HOSTCMD_PD_PANIC -#define CONFIG_I2C -#define CONFIG_I2C_CONTROLLER -#define CONFIG_KEYBOARD_COL2_INVERTED -#define CONFIG_KEYBOARD_PROTOCOL_MKBP -#define CONFIG_LED_COMMON -#define CONFIG_LID_SWITCH -#define CONFIG_LOW_POWER_IDLE -#define CONFIG_MKBP_EVENT -#define CONFIG_MKBP_USE_GPIO -#define CONFIG_POWER_BUTTON -#define CONFIG_POWER_COMMON -#define CONFIG_USB_CHARGER -#define CONFIG_USBC_SS_MUX -#define CONFIG_USBC_SS_MUX_DFP_ONLY -#define CONFIG_USBC_VCONN -#define CONFIG_USBC_VCONN_SWAP -#define CONFIG_USB_POWER_DELIVERY -#define CONFIG_USB_PD_TCPMV1 -#define CONFIG_USB_PD_ALT_MODE -#define CONFIG_USB_PD_ALT_MODE_DFP -#define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_PORT_MAX_COUNT 2 -#define CONFIG_USB_PD_TCPM_TCPCI -#define CONFIG_USB_PD_TRY_SRC -#define CONFIG_USB_PD_VBUS_DETECT_TCPC -#define CONFIG_SPI -#define CONFIG_SPI_CONTROLLER -#define CONFIG_STM_HWTIMER32 -#define CONFIG_VBOOT_HASH -#undef CONFIG_WATCHDOG_HELP -#define CONFIG_SWITCH -#define CONFIG_BOARD_VERSION_GPIO -#undef CONFIG_UART_CONSOLE -#define CONFIG_UART_CONSOLE 1 -#define CONFIG_TEMP_SENSOR -#define CONFIG_TEMP_SENSOR_TMP432 -#define CONFIG_DPTF - -/* UART DMA */ -#undef CONFIG_UART_TX_DMA -#undef CONFIG_UART_RX_DMA - -/* - * Allow dangerous commands. - * TODO: Remove this config before production. - */ -#define CONFIG_SYSTEM_UNLOCKED - -/* Optional features */ -#define CONFIG_CMD_HOSTCMD -#undef CONFIG_CMD_MFALLOW - -/* Drivers */ -/* USB Mux */ -#define CONFIG_USB_MUX_PI3USB30532 -#if BOARD_REV >= OAK_REV5 -#define CONFIG_USB_MUX_PS8740 -#endif -/* BC 1.2 charger */ -#define CONFIG_BC12_DETECT_PI3USB9281 -#define CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT 2 - -#ifndef __ASSEMBLER__ - -/* 48 MHz SYSCLK clock frequency */ -#define CPU_CLOCK 48000000 - -/* Keyboard output port list */ -#define KB_OUT_PORT_LIST GPIO_A, GPIO_B, GPIO_C, GPIO_D - -/* 2 I2C master ports, connect to battery, charger, pd and USB switches */ -#define I2C_PORT_MASTER 0 -#define I2C_PORT_ACCEL 0 -#define I2C_PORT_ALS 0 -#define I2C_PORT_BATTERY 0 -#define I2C_PORT_CHARGER 0 -#define I2C_PORT_PERICOM 0 -#define I2C_PORT_THERMAL 0 -#define I2C_PORT_PD_MCU 1 -#define I2C_PORT_USB_MUX 1 -#define I2C_PORT_TCPC 1 - -/* Enable Accel over SPI */ -#define CONFIG_SPI_ACCEL_PORT 0 /* First SPI master port (SPI2) */ - -/* Ambient Light Sensor address */ -#define OPT3001_I2C_ADDR_FLAGS OPT3001_I2C_ADDR1_FLAGS - -/* Timer selection */ -#define TIM_CLOCK32 2 -#define TIM_WATCHDOG 4 - -/* Define the host events which are allowed to wakeup AP in S3. */ -#define CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK \ - (EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) |\ - EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) |\ - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED) |\ - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_RECOVERY) |\ - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEYBOARD_FASTBOOT)) - -#include "gpio_signal.h" - -enum power_signal { - MTK_POWER_GOOD = 0, - MTK_SUSPEND_ASSERTED, - /* Number of power signals */ - POWER_SIGNAL_COUNT -}; - -enum pwm_channel { - PWM_CH_POWER_LED = 0, - /* Number of PWM channels */ - PWM_CH_COUNT -}; - -enum adc_channel { - ADC_PSYS = 0, /* PC1: STM32_AIN(2) */ - ADC_AMON_BMON, /* PC0: STM32_AIN(10) */ - ADC_VBUS, /* PA2: STM32_AIN(11) */ - ADC_CH_COUNT -}; - -enum temp_sensor_id { - /* TMP432 local and remote sensors */ - TEMP_SENSOR_I2C_TMP432_LOCAL, - TEMP_SENSOR_I2C_TMP432_REMOTE1, - TEMP_SENSOR_I2C_TMP432_REMOTE2, - - /* Battery temperature sensor */ - TEMP_SENSOR_BATTERY, - - TEMP_SENSOR_COUNT -}; - -enum sensor_id { -#ifdef CONFIG_ACCELGYRO_BMI160 - BASE_ACCEL, - BASE_GYRO, -#endif -#ifdef CONFIG_ACCEL_KX022 - LID_ACCEL, -#endif - SENSOR_COUNT, -}; - -/* Light sensors */ -enum als_id { - ALS_OPT3001 = 0, - - ALS_COUNT -}; - -/* TODO: determine the following board specific type-C power constants */ -/* - * delay to turn on the power supply max is ~16ms. - * delay to turn off the power supply max is about ~180ms. - */ -#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ -#define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */ - -/* delay to turn on/off vconn */ - -/* Define typical operating power and max power */ -#define PD_OPERATING_POWER_MW 15000 -#define PD_MAX_POWER_MW 60000 -#define PD_MAX_CURRENT_MA CONFIG_CHARGER_MAX_INPUT_CURRENT -#define PD_MAX_VOLTAGE_MV 20000 - -/* Reset PD MCU */ -void board_reset_pd_mcu(void); -/* Set AP reset pin according to parameter */ -void board_set_ap_reset(int asserted); - -/* Control type-C DP route and hotplug detect signal */ -void board_typec_dp_on(int port); -void board_typec_dp_off(int port, int *dp_flags); -void board_typec_dp_set(int port, int level); - -#endif /* !__ASSEMBLER__ */ - -#endif /* __CROS_EC_BOARD_H */ diff --git a/board/oak/board_revs.h b/board/oak/board_revs.h deleted file mode 100644 index 34fc4bfc88..0000000000 --- a/board/oak/board_revs.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2015 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. - */ - -#ifndef __CROS_EC_BOARD_REVS_H -#define __CROS_EC_BOARD_REVS_H - -#define OAK_REV0 0 -#define OAK_REV1 1 -#define OAK_REV2 2 -#define OAK_REV3 3 -#define OAK_REV4 4 -#define OAK_REV5 5 -#define OAK_REV_LAST OAK_REV5 -#define OAK_REV_DEFAULT OAK_REV5 - -#if !defined(BOARD_REV) -#define BOARD_REV OAK_REV_DEFAULT -#endif - -#if BOARD_REV < OAK_REV1 || BOARD_REV > OAK_REV_LAST -#error "Board revision out of range" -#endif - -#endif /* __CROS_EC_BOARD_REVS_H */ diff --git a/board/oak/build.mk b/board/oak/build.mk deleted file mode 100644 index dc21970df0..0000000000 --- a/board/oak/build.mk +++ /dev/null @@ -1,14 +0,0 @@ -#-*- makefile -*- -# Copyright 2015 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. -# -# Board specific files build - -# STmicro STM32F091VC -CHIP := stm32 -CHIP_FAMILY := stm32f0 -CHIP_VARIANT:= stm32f09x - -board-y = board.o battery.o led.o -board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o diff --git a/board/oak/ec.tasklist b/board/oak/ec.tasklist deleted file mode 100644 index 2af7da77eb..0000000000 --- a/board/oak/ec.tasklist +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2015 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. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#include "board_revs.h" - - -#if BOARD_REV >= OAK_REV5 - -#define CONFIG_TASK_LIST \ - TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(VBUS, vbus_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P0, usb_charger_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P1, usb_charger_task, NULL, 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(PDCMD, pd_command_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(ALS, als_task, NULL, TASK_STACK_SIZE) \ - TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C0, pd_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C1, pd_task, NULL, LARGER_TASK_STACK_SIZE) - -#else /* BOARD_REV >= OAK_REV5 */ - -#define CONFIG_TASK_LIST \ - TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(VBUS, vbus_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P0, usb_charger_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P1, usb_charger_task, NULL, 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(PDCMD, pd_command_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C0, pd_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_C1, pd_task, NULL, LARGER_TASK_STACK_SIZE) - -#endif /* BOARD_REV >= OAK_REV5 */ diff --git a/board/oak/gpio.inc b/board/oak/gpio.inc deleted file mode 100644 index 3789f3ec35..0000000000 --- a/board/oak/gpio.inc +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- mode:c -*- - * - * Copyright 2015 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. - */ - -/* Declare symbolic names for all the GPIOs that we care about. - * Note: Those with interrupt handlers must be declared first. */ - -GPIO_INT(AC_PRESENT, PIN(C, 6), GPIO_INT_BOTH, extpower_interrupt) -GPIO_INT(POWER_BUTTON_L, PIN(B, 5), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt) -GPIO_INT(LID_OPEN, PIN(C, 13), GPIO_INT_BOTH, lid_interrupt) /* LID switch detection */ -#if BOARD_REV <= OAK_REV3 -GPIO_INT(SUSPEND_L, PIN(C, 7), GPIO_INT_BOTH | GPIO_PULL_DOWN, power_signal_interrupt) /* AP suspend/resume state */ -#else -GPIO_INT(SUSPEND_L, PIN(C, 7), GPIO_INT_BOTH, power_signal_interrupt) /* AP suspend/resume state */ -#endif -GPIO_INT(PD_MCU_INT, PIN(E, 0), GPIO_INT_FALLING, pd_mcu_interrupt) /* Signal from PD MCU, external pull-up */ -GPIO_INT(SPI1_NSS, PIN(A, 4), GPIO_INT_BOTH | GPIO_PULL_UP, spi_event) /* SPI Chip Select */ - -/* Keyboard inputs */ -#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH) -#define GPIO_KB_OUTPUT GPIO_ODR_HIGH - -GPIO_INT(KB_IN00, PIN(C, 8), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) -GPIO_INT(KB_IN01, PIN(C, 9), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) -GPIO_INT(KB_IN02, PIN(C, 10), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) -GPIO_INT(KB_IN03, PIN(C, 11), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) -GPIO_INT(KB_IN04, PIN(C, 12), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) -GPIO_INT(KB_IN05, PIN(C, 14), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) -GPIO_INT(KB_IN06, PIN(C, 15), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) -GPIO_INT(KB_IN07, PIN(D, 2), GPIO_KB_INPUT, keyboard_raw_gpio_interrupt) - -/* Board specific interrupt and input */ -#if BOARD_REV <= OAK_REV1 -GPIO_INT(SOC_POWER_GOOD, PIN(A, 3), GPIO_INT_BOTH | GPIO_PULL_DOWN, power_signal_interrupt) -GPIO(EC_INT_L, PIN(B, 9), GPIO_OUT_HIGH) -#elif BOARD_REV == OAK_REV2 -GPIO_INT(SOC_POWER_GOOD, PIN(A, 3), GPIO_INT_BOTH | GPIO_PULL_DOWN, power_signal_interrupt) -GPIO(EC_INT_L, PIN(B, 9), GPIO_OUT_HIGH) -GPIO(USB_VBUS_WAKE_L, PIN(E, 1), GPIO_INPUT) -#elif BOARD_REV == OAK_REV3 -GPIO_INT(SOC_POWER_GOOD, PIN(A, 3), GPIO_INT_BOTH | GPIO_PULL_DOWN, power_signal_interrupt) -GPIO(EC_INT_L, PIN(B, 9), GPIO_OUT_HIGH) -GPIO(USB_C0_VBUS_WAKE_L, PIN(E, 1), GPIO_INPUT) -GPIO(USB_C1_VBUS_WAKE_L, PIN(F, 2), GPIO_INPUT) -#elif BOARD_REV >= OAK_REV4 -GPIO_INT(SOC_POWER_GOOD, PIN(A, 3), GPIO_INT_BOTH , power_signal_interrupt) -GPIO_INT(USB_BC12_INT, PIN(E, 1), GPIO_INT_FALLING, usb_evt) -GPIO(USB_C0_VBUS_WAKE_L, PIN(D, 12), GPIO_INPUT) -GPIO(USB_C1_VBUS_WAKE_L, PIN(F, 2), GPIO_INPUT) -GPIO(EC_INT_L, PIN(B, 9), GPIO_ODR_HIGH) -#endif - -/* Inputs without interrupt handlers */ -GPIO(5V_POWER_GOOD, PIN(A, 1), GPIO_INPUT) -GPIO(EC_WAKE, PIN(A, 0), GPIO_INPUT|GPIO_PULL_DOWN) -GPIO(WP_L, PIN(B, 4), GPIO_INPUT) /* Write protect input */ -GPIO(BAT_PRESENT_L, PIN(E, 3), GPIO_INPUT|GPIO_PULL_UP) - -/* Board version */ -GPIO(BOARD_VERSION1, PIN(E, 10), GPIO_INPUT) /* Board ID 0 */ -GPIO(BOARD_VERSION2, PIN(E, 9), GPIO_INPUT) /* Board ID 1 */ -GPIO(BOARD_VERSION3, PIN(E, 12), GPIO_INPUT) /* Board ID 2 */ -GPIO(BOARD_VERSION4, PIN(E, 11), GPIO_INPUT) /* Board ID 3 */ - -/* Outputs */ -#if BOARD_REV < OAK_REV5 -GPIO(BAT_LED0, PIN(B, 11), GPIO_OUT_LOW) /* LED_GREEN */ -GPIO(BAT_LED1, PIN(A, 11), GPIO_OUT_LOW) /* LED_ORANGE or LED_RED(>rev3)*/ -#else -GPIO(BAT_LED0, PIN(A, 11), GPIO_OUT_LOW) /* LED_GREEN */ -GPIO(BAT_LED1, PIN(B, 11), GPIO_OUT_LOW) /* LED_ORANGE or LED_RED(>rev3)*/ -#endif - -#if (BOARD_REV == OAK_REV3) || (BOARD_REV == OAK_REV4) -GPIO(PWR_LED0, PIN(F, 10), GPIO_OUT_LOW) /* LED_GREEN */ -GPIO(PWR_LED1, PIN(F, 9), GPIO_OUT_LOW) /* LED_ORANGE */ -#else -UNIMPLEMENTED(PWR_LED0) -UNIMPLEMENTED(PWR_LED1) -#endif -GPIO(EC_BL_OVERRIDE, PIN(F, 1), GPIO_OUT_LOW) -GPIO(ENTERING_RW, PIN(F, 0), GPIO_OUT_LOW) - - -#if BOARD_REV == OAK_REV1 -GPIO(AP_RESET_L, PIN(C, 3), GPIO_INPUT|GPIO_PULL_UP) /* AP reset signal from servo board */ -GPIO(USB_C_BC12_SEL, PIN(A, 14), GPIO_OUT_LOW) -GPIO(KB_OUT00, PIN(B, 0), GPIO_KB_OUTPUT) -GPIO(KB_OUT01, PIN(B, 8), GPIO_KB_OUTPUT) -GPIO(KB_OUT02, PIN(B, 12), GPIO_OUT_LOW) /* KSO2 is inverted */ -GPIO(KB_OUT03, PIN(B, 2), GPIO_KB_OUTPUT) -GPIO(KB_OUT04, PIN(A, 8), GPIO_KB_OUTPUT) -GPIO(KB_OUT05, PIN(D, 4), GPIO_KB_OUTPUT) -GPIO(KB_OUT06, PIN(D, 0), GPIO_KB_OUTPUT) -GPIO(KB_OUT07, PIN(D, 1), GPIO_KB_OUTPUT) -GPIO(KB_OUT08, PIN(C, 2), GPIO_KB_OUTPUT) -GPIO(KB_OUT09, PIN(B, 1), GPIO_KB_OUTPUT) -GPIO(KB_OUT10, PIN(C, 5), GPIO_KB_OUTPUT) -GPIO(KB_OUT11, PIN(C, 4), GPIO_KB_OUTPUT) -GPIO(KB_OUT12, PIN(A, 13), GPIO_KB_OUTPUT) -UNIMPLEMENTED(DP_SWITCH_CTL) - -#elif BOARD_REV == OAK_REV2 -GPIO(AP_RESET_L, PIN(C, 3), GPIO_INPUT|GPIO_PULL_UP) /* AP reset signal from servo board */ -GPIO(USB_C_BC12_SEL, PIN(D, 7), GPIO_OUT_LOW) -GPIO(KB_OUT00, PIN(B, 0), GPIO_KB_OUTPUT) -GPIO(KB_OUT01, PIN(B, 8), GPIO_KB_OUTPUT) -GPIO(KB_OUT02, PIN(B, 12), GPIO_OUT_LOW) /* KSO2 is inverted */ -GPIO(KB_OUT03, PIN(B, 2), GPIO_KB_OUTPUT) -GPIO(KB_OUT04, PIN(A, 8), GPIO_KB_OUTPUT) -GPIO(KB_OUT05, PIN(D, 4), GPIO_KB_OUTPUT) -GPIO(KB_OUT06, PIN(D, 0), GPIO_KB_OUTPUT) -GPIO(KB_OUT07, PIN(D, 1), GPIO_KB_OUTPUT) -GPIO(KB_OUT08, PIN(C, 2), GPIO_KB_OUTPUT) -GPIO(KB_OUT09, PIN(B, 1), GPIO_KB_OUTPUT) -GPIO(KB_OUT10, PIN(C, 5), GPIO_KB_OUTPUT) -GPIO(KB_OUT11, PIN(C, 4), GPIO_KB_OUTPUT) -GPIO(KB_OUT12, PIN(D, 5), GPIO_KB_OUTPUT) -GPIO(DP_MUX_EN_L, PIN(E, 6), GPIO_OUT_LOW) -GPIO(DP_SWITCH_CTL, PIN(E, 5), GPIO_OUT_LOW) - -#elif BOARD_REV <= OAK_REV4 /* BOARD_REV 3 or 4 */ -GPIO(AP_RESET_L, PIN(C, 3), GPIO_ODR_HIGH) /* Connect to the PMU_SYSRSTB */ -GPIO(USB_C_BC12_SEL, PIN(D, 7), GPIO_OUT_LOW) -GPIO(KB_OUT00, PIN(B, 0), GPIO_KB_OUTPUT) -GPIO(KB_OUT01, PIN(B, 8), GPIO_KB_OUTPUT) -GPIO(KB_OUT02, PIN(B, 12), GPIO_OUT_LOW) /* KSO2 is inverted */ -GPIO(KB_OUT03, PIN(D, 0), GPIO_KB_OUTPUT) -GPIO(KB_OUT04, PIN(A, 8), GPIO_KB_OUTPUT) -GPIO(KB_OUT05, PIN(D, 4), GPIO_KB_OUTPUT) -GPIO(KB_OUT06, PIN(B, 2), GPIO_KB_OUTPUT) -GPIO(KB_OUT07, PIN(D, 1), GPIO_KB_OUTPUT) -GPIO(KB_OUT08, PIN(D, 5), GPIO_KB_OUTPUT) -GPIO(KB_OUT09, PIN(B, 1), GPIO_KB_OUTPUT) -GPIO(KB_OUT10, PIN(C, 5), GPIO_KB_OUTPUT) -GPIO(KB_OUT11, PIN(C, 4), GPIO_KB_OUTPUT) -GPIO(KB_OUT12, PIN(C, 2), GPIO_KB_OUTPUT) -UNIMPLEMENTED(DP_SWITCH_CTL) - -#else /* >= OAK_REV5 */ -GPIO(AP_RESET_L, PIN(C, 3), GPIO_ODR_HIGH) /* Connect to the PMU_SYSRSTB */ -GPIO(USB_C_BC12_SEL, PIN(D, 7), GPIO_OUT_LOW) -GPIO(KB_OUT00, PIN(B, 0), GPIO_KB_OUTPUT) -GPIO(KB_OUT01, PIN(B, 8), GPIO_KB_OUTPUT) -GPIO(KB_OUT02, PIN(B, 12), GPIO_OUT_LOW) /* KSO2 is inverted */ -GPIO(KB_OUT03, PIN(B, 2), GPIO_KB_OUTPUT) -GPIO(KB_OUT04, PIN(A, 8), GPIO_KB_OUTPUT) -GPIO(KB_OUT05, PIN(D, 14), GPIO_KB_OUTPUT) -GPIO(KB_OUT06, PIN(D, 13), GPIO_KB_OUTPUT) -GPIO(KB_OUT07, PIN(D, 15), GPIO_KB_OUTPUT) -GPIO(KB_OUT08, PIN(C, 2), GPIO_KB_OUTPUT) -GPIO(KB_OUT09, PIN(B, 1), GPIO_KB_OUTPUT) -GPIO(KB_OUT10, PIN(C, 5), GPIO_KB_OUTPUT) -GPIO(KB_OUT11, PIN(C, 4), GPIO_KB_OUTPUT) -GPIO(KB_OUT12, PIN(D, 5), GPIO_KB_OUTPUT) -GPIO(C1_DP_HPD, PIN(E,15), GPIO_OUT_LOW) /* inform PS8740 to exit from idle mode. */ -GPIO(DP_SWITCH_CTL, PIN(E, 5), GPIO_OUT_LOW) -GPIO(EN_OTG_USB_A_PWR, PIN(E, 4), GPIO_OUT_HIGH) -GPIO(OTG_USB_A_ILIM_SEL,PIN(E, 2), GPIO_OUT_HIGH) -GPIO(EC_IDDIG, PIN(E,13), GPIO_OUT_LOW) -GPIO(DP_MUX_EN_L, PIN(E, 6), GPIO_OUT_LOW) -GPIO(PARADE_MUX_EN, PIN(E, 7), GPIO_OUT_HIGH) -#endif /* BOARD_REV */ - -GPIO(SYSTEM_POWER_H, PIN(B, 10), GPIO_OUT_LOW) -GPIO(PMIC_PWRON_H, PIN(A, 12), GPIO_OUT_LOW) -GPIO(PMIC_WARM_RESET_H, PIN(B, 3), GPIO_OUT_LOW) -#if BOARD_REV <= OAK_REV4 -GPIO(LEVEL_SHIFT_EN_L, PIN(D, 3), GPIO_OUT_LOW) /* LID/AC level shift */ -GPIO(USB_C0_DEVMODE_L, PIN(E, 4), GPIO_OUT_HIGH) /* set HSD2 (host mode) path as default */ -GPIO(USB_C1_DEVMODE, PIN(E, 2), GPIO_OUT_LOW) /* set HSD1 (host mode) path as default */ -#else /* >= OAK_REV5 */ -GPIO(LEVEL_SHIFT_EN_L, PIN(F, 10), GPIO_OUT_LOW) /* LID/AC level shift */ -/* SPI MASTER. For SPI sensor */ -GPIO(SPI2_NSS, PIN(D, 0), GPIO_OUT_LOW) - -#endif -GPIO(USB_PD_RST_L, PIN(A, 15), GPIO_OUT_HIGH) /* PD reset */ -GPIO(USB_C0_5V_EN, PIN(D, 8), GPIO_OUT_LOW) /* USBC port 0 5V */ -GPIO(USB_C0_CHARGE_L, PIN(D, 9), GPIO_OUT_LOW) /* USBC port 0 charge */ -GPIO(USB_C1_5V_EN, PIN(D, 10), GPIO_OUT_LOW) /* USBC port 1 5V */ -GPIO(USB_C1_CHARGE_L, PIN(D, 11), GPIO_OUT_LOW) /* USBC port 1 charge */ -GPIO(USB_PD_VBUS_WAKE, PIN(B, 15), GPIO_OUT_LOW) /* PD MCU wake */ -GPIO(USB_DP_HPD, PIN(F, 3), GPIO_OUT_LOW) - -#if (BOARD_REV < OAK_REV5) -GPIO(TYPEC0_MUX_EN_L, PIN(E, 13), GPIO_OUT_LOW) -GPIO(TYPEC1_MUX_EN_L, PIN(E, 14), GPIO_OUT_LOW) -#endif - -/* Analog pins */ -GPIO(VDC_BOOSTIN_SENSE, PIN(C, 1), GPIO_ANALOG) /* ADC_IN11 */ -GPIO(PSYS_MONITOR, PIN(A, 2), GPIO_ANALOG) /* ADC_IN2 */ -GPIO(AMON_BMON, PIN(C, 0), GPIO_ANALOG) /* ADC_IN10 */ - -/* - * I2C pins should be configured as inputs until I2C module is - * initialized. This will avoid driving the lines unintentionally. - */ -GPIO(I2C0_SCL, PIN(B, 6), GPIO_INPUT) /* EC I2C */ -GPIO(I2C0_SDA, PIN(B, 7), GPIO_INPUT) -GPIO(I2C1_SCL, PIN(B, 13), GPIO_INPUT) /* PD I2C */ -GPIO(I2C1_SDA, PIN(B, 14), GPIO_INPUT) - -ALTERNATE(PIN_MASK(A, 0x0600), 1, MODULE_UART, 0) /* USART1: PA9/PA10 */ -ALTERNATE(PIN_MASK(B, 0x00c0), 1, MODULE_I2C, 0) /* I2C MASTER:PB6/7 */ -ALTERNATE(PIN_MASK(B, 0x6000), 5, MODULE_I2C, 0) /* I2C MASTER:PB13/14 */ -ALTERNATE(PIN_MASK(A, 0x00f0), 0, MODULE_SPI, 0) /* SPI SLAVE:PA4/5/6/7 */ -#if BOARD_REV >= OAK_REV5 -ALTERNATE(PIN_MASK(D, 0x001A), 1, MODULE_SPI_CONTROLLER, 0) /* SPI MASTER:PD1/3/4 */ -#endif diff --git a/board/oak/led.c b/board/oak/led.c deleted file mode 100644 index 877f115a12..0000000000 --- a/board/oak/led.c +++ /dev/null @@ -1,266 +0,0 @@ -/* Copyright 2015 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 LED and Power LED control for Oak Board. - */ - -#include "battery.h" -#include "charge_state.h" -#include "chipset.h" -#include "gpio.h" -#include "hooks.h" -#include "led_common.h" -#include "util.h" -#include "system.h" - -const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_BATTERY_LED -}; - -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -enum led_color { - BAT_LED_GREEN = 0, - BAT_LED_ORANGE, - BAT_LED_RED, - BAT_LED_AMBER, - PWR_LED_GREEN, - PWR_LED_ORANGE, - LED_COLOR_COUNT /* Number of colors, not a color itself */ -}; - -static int bat_led_set(enum led_color color, int on) -{ - /* Before Rev5, it's active low; After that, it's active high */ - if (system_get_board_version() < OAK_REV5) - on = !on; - - switch (color) { - case BAT_LED_GREEN: - gpio_set_level(GPIO_BAT_LED0, on); /* BAT_LED_GREEN */ - break; - case BAT_LED_ORANGE: - /* for rev2 or before */ - gpio_set_level(GPIO_BAT_LED1, on); /* BAT_LED_ORANGE */ - break; - case BAT_LED_RED: - /* for rev3 or later */ - gpio_set_level(GPIO_BAT_LED1, on); /* BAT_LED_RED */ - break; - case BAT_LED_AMBER: - /* for rev3 or later */ - gpio_set_level(GPIO_BAT_LED0, on); /* BAT_LED_AMBER */ - gpio_set_level(GPIO_BAT_LED1, on); - break; - case PWR_LED_GREEN: - gpio_set_level(GPIO_PWR_LED0, on); /* PWR_LED_GREEN */ - break; - case PWR_LED_ORANGE: - gpio_set_level(GPIO_PWR_LED1, on); /* PWR_LED_ORANGE */ - break; - default: - return EC_ERROR_UNKNOWN; - } - return EC_SUCCESS; -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - /* Ignoring led_id as both leds support the same colors */ - brightness_range[EC_LED_COLOR_RED] = 1; - brightness_range[EC_LED_COLOR_GREEN] = 1; - brightness_range[EC_LED_COLOR_YELLOW] = 1; -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - if (EC_LED_ID_BATTERY_LED == led_id) { - if (brightness[EC_LED_COLOR_GREEN] != 0) { - bat_led_set(BAT_LED_GREEN, 1); - bat_led_set(BAT_LED_ORANGE, 0); - } else if (brightness[EC_LED_COLOR_YELLOW] != 0) { - bat_led_set(BAT_LED_GREEN, 1); - bat_led_set(BAT_LED_ORANGE, 1); - } else if (brightness[EC_LED_COLOR_RED] != 0) { - bat_led_set(BAT_LED_GREEN, 0); - bat_led_set(BAT_LED_RED, 1); - } else { - bat_led_set(BAT_LED_GREEN, 0); - bat_led_set(BAT_LED_ORANGE, 0); - } - return EC_SUCCESS; - } else if (EC_LED_ID_POWER_LED == led_id) { - if (brightness[EC_LED_COLOR_GREEN] != 0) { - bat_led_set(PWR_LED_GREEN, 1); - bat_led_set(PWR_LED_ORANGE, 0); - } else if (brightness[EC_LED_COLOR_YELLOW] != 0) { - bat_led_set(PWR_LED_GREEN, 1); - bat_led_set(PWR_LED_ORANGE, 1); - } else { - bat_led_set(PWR_LED_GREEN, 0); - bat_led_set(PWR_LED_ORANGE, 0); - } - return EC_SUCCESS; - } else { - return EC_ERROR_UNKNOWN; - } -} - -static void oak_led_set_power(int board_version) -{ - static int power_second; - - power_second++; - - switch(board_version) { - case OAK_REV3: - case OAK_REV4: - /* - * For Rev3 and Rev4 revision. - * PWR LED behavior: - * Power on: Green ON - * Suspend: Orange in breeze mode ( 1 sec on/ 3 sec off) - * Power off: OFF - */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) { - bat_led_set(PWR_LED_GREEN, 0); - bat_led_set(PWR_LED_ORANGE, 0); - } else if (chipset_in_state(CHIPSET_STATE_ON)) { - bat_led_set(PWR_LED_GREEN, 1); - bat_led_set(PWR_LED_ORANGE, 0); - } else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) { - bat_led_set(PWR_LED_GREEN, 0); - bat_led_set(PWR_LED_ORANGE, - (power_second & 3) ? 0 : 1); - } - break; - default: - break; - } -} - -static void oak_led_set_battery(int board_version) -{ - static int battery_second; - - battery_second++; - - switch(board_version) { - case OAK_REV3: - case OAK_REV4: - /* - * For Rev3 and Rev4 revision: - * BAT LED behavior: - * - Fully charged / idle: Green ON - * - Charging: Amber ON (BAT_LED_RED && BAT_LED_GREEN) - * - Battery discharging capacity<10%, red blink - * - Battery error: Red ON - */ - switch (charge_get_state()) { - case PWR_STATE_CHARGE: - bat_led_set(BAT_LED_AMBER, 1); - break; - case PWR_STATE_CHARGE_NEAR_FULL: - bat_led_set(BAT_LED_GREEN, 1); - bat_led_set(BAT_LED_RED, 0); - break; - case PWR_STATE_DISCHARGE: - bat_led_set(BAT_LED_GREEN, 0); - if (charge_get_percent() < 3) - bat_led_set(BAT_LED_RED, - (battery_second & 1) ? 0 : 1); - else if (charge_get_percent() < 10) - bat_led_set(BAT_LED_RED, - (battery_second & 3) ? 0 : 1); - else - bat_led_set(BAT_LED_RED, 0); - break; - case PWR_STATE_ERROR: - bat_led_set(BAT_LED_RED, 1); - break; - case PWR_STATE_IDLE: /* Ext. power connected in IDLE. */ - bat_led_set(BAT_LED_GREEN, 1); - bat_led_set(BAT_LED_RED, 0); - break; - default: - /* Other states don't alter LED behavior */ - break; - } - break; /* End of case OAK_REV3 & OAK_REV4 */ - default: - /* - * Put power control here since we are using the "battery" LED. - * This allows LED autocontrol to be turned off by cmd during factory test. - * - * PWR LED behavior: - * Power on: Green - * Suspend: Green in breeze mode ( 1 sec on/ 3 sec off) - * Power off: OFF - */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - bat_led_set(BAT_LED_GREEN, 0); - else if (chipset_in_state(CHIPSET_STATE_ON)) - bat_led_set(BAT_LED_GREEN, 1); - else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) { - int cycle_time = 4; - /* Oak rev5 with GlaDOS ID has a extremely power - * comsuming LED. Increase LED blink cycle time to reduce - * S3 power comsuption. */ - if (board_version >= OAK_REV5) - cycle_time = 10; - bat_led_set(BAT_LED_GREEN, - (battery_second % cycle_time) ? 0 : 1); - } - - /* BAT LED behavior: - * Fully charged / idle: Off - * Under charging: Orange - * Bat. low (10%): Orange in breeze mode (1s on, 3s off) - * Bat. critical low (less than 3%) or abnormal battery - * situation: Orange in blinking mode (1s on, 1s off) - * Using battery or not connected to AC power: OFF - */ - switch (charge_get_state()) { - case PWR_STATE_CHARGE: - bat_led_set(BAT_LED_ORANGE, 1); - break; - case PWR_STATE_CHARGE_NEAR_FULL: - bat_led_set(BAT_LED_ORANGE, 1); - break; - case PWR_STATE_DISCHARGE: - if (charge_get_percent() < 3) - bat_led_set(BAT_LED_ORANGE, - (battery_second & 1) ? 0 : 1); - else if (charge_get_percent() < 10) - bat_led_set(BAT_LED_ORANGE, - (battery_second & 3) ? 0 : 1); - else - bat_led_set(BAT_LED_ORANGE, 0); - break; - case PWR_STATE_ERROR: - bat_led_set(BAT_LED_ORANGE, - (battery_second & 1) ? 0 : 1); - break; - case PWR_STATE_IDLE: /* Ext. power connected in IDLE. */ - bat_led_set(BAT_LED_ORANGE, 0); - break; - default: - /* Other states don't alter LED behavior */ - break; - } - break; /* End of default */ - } -} - -/** - * Called by hook task every 1 sec - */ -static void led_second(void) -{ - if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) - oak_led_set_power(system_get_board_version()); - if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) - oak_led_set_battery(system_get_board_version()); -} -DECLARE_HOOK(HOOK_SECOND, led_second, HOOK_PRIO_DEFAULT); diff --git a/board/oak/usb_pd_policy.c b/board/oak/usb_pd_policy.c deleted file mode 100644 index a4e62ebe88..0000000000 --- a/board/oak/usb_pd_policy.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright 2015 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. - */ - -#include "atomic.h" -#include "charge_manager.h" -#include "common.h" -#include "console.h" -#include "gpio.h" -#include "hooks.h" -#include "host_command.h" -#include "registers.h" -#include "system.h" -#include "task.h" -#include "timer.h" -#include "util.h" -#include "usb_mux.h" -#include "usb_pd.h" - -#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) -#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) - -int pd_set_power_supply_ready(int port) -{ - /* Disable charging */ - gpio_set_level(port ? GPIO_USB_C1_CHARGE_L : - GPIO_USB_C0_CHARGE_L, 1); - /* Provide VBUS */ - gpio_set_level(port ? GPIO_USB_C1_5V_EN : - GPIO_USB_C0_5V_EN, 1); - - /* notify host of power info change */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; /* we are ready */ -} - -void pd_power_supply_reset(int port) -{ - /* Disable VBUS */ - gpio_set_level(port ? GPIO_USB_C1_5V_EN : - GPIO_USB_C0_5V_EN, 0); - - /* notify host of power info change */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -__override int pd_board_checks(void) -{ -#if BOARD_REV <= OAK_REV3 - /* wake up VBUS task to check vbus change */ - task_wake(TASK_ID_VBUS); -#endif - return EC_SUCCESS; -} - -int pd_check_vconn_swap(int port) -{ - /* in G3, do not allow vconn swap since 5V power source is off */ - return gpio_get_level(GPIO_5V_POWER_GOOD); -} - -/* ----------------- Vendor Defined Messages ------------------ */ -#ifdef CONFIG_USB_PD_ALT_MODE_DFP -__override void svdm_dp_post_config(int port) -{ - dp_flags[port] |= DP_FLAGS_DP_ON; - if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING)) - return; - board_typec_dp_set(port, 1); -} - -__override int svdm_dp_attention(int port, uint32_t *payload) -{ - int cur_lvl; - int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); - int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); - - dp_status[port] = payload[1]; - cur_lvl = gpio_get_level(GPIO_USB_DP_HPD); - - /* Its initial DP status message prior to config */ - if (!(dp_flags[port] & DP_FLAGS_DP_ON)) { - if (lvl) - dp_flags[port] |= DP_FLAGS_HPD_HI_PENDING; - return 1; - } - - if (irq & cur_lvl) { - board_typec_dp_on(port); - } else if (irq & !cur_lvl) { - CPRINTF("ERR:HPD:IRQ&LOW\n"); - return 0; /* nak */ - } else { - board_typec_dp_set(port, lvl); - } - /* ack */ - return 1; -} - -__override void svdm_exit_dp_mode(int port) -{ - board_typec_dp_off(port, dp_flags); -} -#endif /* CONFIG_USB_PD_ALT_MODE_DFP */ diff --git a/board/oak/vif_override.xml b/board/oak/vif_override.xml deleted file mode 100644 index 32736caf64..0000000000 --- a/board/oak/vif_override.xml +++ /dev/null @@ -1,3 +0,0 @@ -<!-- Add VIF field overrides here. See genvif.c and the Vendor Info File - Definition from the USB-IF. ---> |