diff options
Diffstat (limited to 'board/mchpevb1')
-rw-r--r-- | board/mchpevb1/battery.c | 230 | ||||
-rw-r--r-- | board/mchpevb1/board.c | 984 | ||||
-rw-r--r-- | board/mchpevb1/board.h | 487 | ||||
-rw-r--r-- | board/mchpevb1/build.mk | 19 | ||||
-rw-r--r-- | board/mchpevb1/ec.tasklist | 18 | ||||
-rw-r--r-- | board/mchpevb1/gpio.inc | 450 | ||||
-rw-r--r-- | board/mchpevb1/led.c | 174 | ||||
-rw-r--r-- | board/mchpevb1/lfw/vif_override.xml | 3 | ||||
-rw-r--r-- | board/mchpevb1/usb_pd_policy.c | 61 |
9 files changed, 0 insertions, 2426 deletions
diff --git a/board/mchpevb1/battery.c b/board/mchpevb1/battery.c deleted file mode 100644 index fcc09994bf..0000000000 --- a/board/mchpevb1/battery.c +++ /dev/null @@ -1,230 +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 "charge_state.h" -#include "console.h" -#include "ec_commands.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 - -/* Battery info for BQ40Z55 */ -static const struct battery_info info = { - .voltage_max = 8700, /* mV */ - .voltage_normal = 7600, - .voltage_min = 6000, - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 46, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, -}; - -const struct battery_info *battery_get_info(void) -{ - return &info; -} - -int board_cut_off_battery(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; -} - -#ifdef CONFIG_CHARGER_PROFILE_OVERRIDE - -static int fast_charging_allowed = 1; - -/* - * This can override the smart battery's charging profile. To make a change, - * modify one or more of requested_voltage, requested_current, or state. - * Leave everything else unchanged. - * - * Return the next poll period in usec, or zero to use the default (which is - * state dependent). - */ -int charger_profile_override(struct charge_state_data *curr) -{ - /* temp in 0.1 deg C */ - int temp_c = curr->batt.temperature - 2731; - /* keep track of last temperature range for hysteresis */ - static enum { - TEMP_RANGE_1, - TEMP_RANGE_2, - TEMP_RANGE_3, - TEMP_RANGE_4, - TEMP_RANGE_5, - } temp_range = TEMP_RANGE_3; - /* keep track of last voltage range for hysteresis */ - static enum { - VOLTAGE_RANGE_LOW, - VOLTAGE_RANGE_HIGH, - } voltage_range = VOLTAGE_RANGE_LOW; - - /* Current and previous battery voltage */ - int batt_voltage; - static int prev_batt_voltage; - - /* - * Determine temperature range. The five ranges are: - * < 10C - * 10-15C - * 15-23C - * 23-45C - * > 45C - * - * Add 0.2 degrees of hysteresis. - * If temp reading was bad, use last range. - */ - if (!(curr->batt.flags & BATT_FLAG_BAD_TEMPERATURE)) { - if (temp_c < 99) - temp_range = TEMP_RANGE_1; - else if (temp_c > 101 && temp_c < 149) - temp_range = TEMP_RANGE_2; - else if (temp_c > 151 && temp_c < 229) - temp_range = TEMP_RANGE_3; - else if (temp_c > 231 && temp_c < 449) - temp_range = TEMP_RANGE_4; - else if (temp_c > 451) - temp_range = TEMP_RANGE_5; - } - - /* - * If battery voltage reading is bad, use the last reading. Otherwise, - * determine voltage range with hysteresis. - */ - if (curr->batt.flags & BATT_FLAG_BAD_VOLTAGE) { - batt_voltage = prev_batt_voltage; - } else { - batt_voltage = prev_batt_voltage = curr->batt.voltage; - if (batt_voltage < 8200) - voltage_range = VOLTAGE_RANGE_LOW; - else if (batt_voltage > 8300) - voltage_range = VOLTAGE_RANGE_HIGH; - } - - /* - * If we are not charging or we aren't using fast charging profiles, - * then do not override desired current and voltage. - */ - if (curr->state != ST_CHARGE || !fast_charging_allowed) - return 0; - - /* - * Okay, impose our custom will: - * When battery is 0-10C: - * CC at 486mA @ 8.7V - * CV at 8.7V - * - * When battery is <15C: - * CC at 1458mA @ 8.7V - * CV at 8.7V - * - * When battery is <23C: - * CC at 3402mA until 8.3V @ 8.7V - * CC at 2430mA @ 8.7V - * CV at 8.7V - * - * When battery is <45C: - * CC at 4860mA until 8.3V @ 8.7V - * CC at 2430mA @ 8.7V - * CV at 8.7V until current drops to 450mA - * - * When battery is >45C: - * CC at 2430mA @ 8.3V - * CV at 8.3V (when battery is hot we don't go to fully charged) - */ - switch (temp_range) { - case TEMP_RANGE_1: - curr->requested_current = 486; - curr->requested_voltage = 8700; - break; - case TEMP_RANGE_2: - curr->requested_current = 1458; - curr->requested_voltage = 8700; - break; - case TEMP_RANGE_3: - curr->requested_voltage = 8700; - if (voltage_range == VOLTAGE_RANGE_HIGH) - curr->requested_current = 2430; - else - curr->requested_current = 3402; - break; - case TEMP_RANGE_4: - curr->requested_voltage = 8700; - if (voltage_range == VOLTAGE_RANGE_HIGH) - curr->requested_current = 2430; - else - curr->requested_current = 4860; - break; - case TEMP_RANGE_5: - curr->requested_current = 2430; - curr->requested_voltage = 8300; - break; - } - - return 0; -} - -/* Customs options controllable by host command. */ -#define PARAM_FASTCHARGE (CS_PARAM_CUSTOM_PROFILE_MIN + 0) - -enum ec_status charger_profile_override_get_param(uint32_t param, - uint32_t *value) -{ - if (param == PARAM_FASTCHARGE) { - *value = fast_charging_allowed; - return EC_RES_SUCCESS; - } - return EC_RES_INVALID_PARAM; -} - -enum ec_status charger_profile_override_set_param(uint32_t param, - uint32_t value) -{ - if (param == PARAM_FASTCHARGE) { - fast_charging_allowed = value; - return EC_RES_SUCCESS; - } - return EC_RES_INVALID_PARAM; -} - -static int command_fastcharge(int argc, char **argv) -{ - if (argc > 1 && !parse_bool(argv[1], &fast_charging_allowed)) - return EC_ERROR_PARAM1; - - ccprintf("fastcharge %s\n", fast_charging_allowed ? "on" : "off"); - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(fastcharge, command_fastcharge, - "[on|off]", - "Get or set fast charging profile"); - -#endif /* CONFIG_CHARGER_PROFILE_OVERRIDE */ diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c deleted file mode 100644 index 73cec110bb..0000000000 --- a/board/mchpevb1/board.c +++ /dev/null @@ -1,984 +0,0 @@ -/* Copyright 2017 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. - */ - -/* - * Microchip Evaluation Board(EVB) with - * MEC1701H 144-pin processor card. - * EVB connected to Intel SKL RVP3 configured - * for eSPI with Kabylake silicon. - */ - -#include "adc.h" -#include "als.h" -#include "bd99992gw.h" -#include "button.h" -#include "charge_manager.h" -#include "charge_state.h" -#include "charger.h" -#include "chipset.h" -#include "console.h" -#include "driver/als_opt3001.h" -#include "driver/accel_kionix.h" -#include "driver/accel_kx022.h" -#include "driver/accelgyro_bmi_common.h" -#include "driver/tcpm/tcpci.h" -#include "extpower.h" -#include "gpio_chip.h" -#include "gpio.h" -#include "hooks.h" -#include "host_command.h" -#include "i2c.h" -#include "espi.h" -#include "lpc_chip.h" -#include "keyboard_scan.h" -#include "lid_switch.h" -#include "math_util.h" -#include "motion_sense.h" -#include "motion_lid.h" -#include "pi3usb9281.h" -#include "power.h" -#include "power_button.h" -#include "spi.h" -#include "spi_chip.h" -#include "switch.h" -#include "system.h" -#include "task.h" -#include "temp_sensor.h" -#include "timer.h" -#include "uart.h" -#include "usb_charge.h" -#include "usb_mux.h" -#include "usb_pd.h" -#include "usb_pd_tcpm.h" -#include "util.h" -#include "espi.h" -#include "battery_smart.h" - -/* Console output macros */ -#define CPUTS(outstr) cputs(CC_LPC, outstr) -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) - - -/* NOTE: MEC17xx EVB + SKL RVP3 does not use BD99992 PMIC. - * RVP3 PMIC controlled by RVP3 logic. - */ -#define I2C_ADDR_BD99992_FLAGS 0x30 - -/* - * Maxim DS1624 I2C temperature sensor used for testing I2C. - * DS1624 contains one internal temperature sensor - * and EEPROM. It has no external temperature inputs. - */ -#define DS1624_I2C_ADDR_FLAGS (0x48 | I2C_FLAG_BIG_ENDIAN) -#define DS1624_IDX_LOCAL 0 -#define DS1624_READ_TEMP16 0xAA /* read 16-bit temperature */ -#define DS1624_ACCESS_CFG 0xAC /* read/write 8-bit config */ -#define DS1624_CMD_START 0xEE -#define DS1624_CMD_STOP 0x22 - -/* - * static global and routine to return smart battery - * temperature when we do not build with charger task. - */ -static int smart_batt_temp; -static int ds1624_temp; -static int sb_temp(int idx, int *temp_ptr); -static int ds1624_get_val(int idx, int *temp_ptr); -static void board_spi_enable(void); -static void board_spi_disable(void); - -#ifdef CONFIG_BOARD_PRE_INIT -/* - * Used to enable JTAG debug during development. - * NOTE: If ARM Serial Wire Viewer not used then SWV pin can be - * be disabled and used for another purpose. Change mode to - * MCHP_JTAG_MODE_SWD. - * For low power idle testing enable GPIO060 as function 2(48MHZ_OUT) - * to check PLL is turning off in heavy sleep. Note, do not put GPIO060 - * in gpio.inc - * GPIO060 is port 1 bit[16]. - */ -void board_config_pre_init(void) -{ - smart_batt_temp = 0; - ds1624_temp = 0; - -#ifdef CONFIG_CHIPSET_DEBUG - MCHP_EC_JTAG_EN = MCHP_JTAG_ENABLE + MCHP_JTAG_MODE_SWD_SWV; -#endif - -#if defined(CONFIG_LOW_POWER_IDLE) && defined(CONFIG_MCHP_48MHZ_OUT) - gpio_set_alternate_function(1, 0x10000, 2); -#endif -} -#endif /* #ifdef CONFIG_BOARD_PRE_INIT */ - - -/* - * Use EC to handle ALL_SYS_PWRGD signal. - * MEC17xx connected to SKL/KBL RVP3 reference board - * is required to monitor ALL_SYS_PWRGD and drive SYS_RESET_L - * after a 10 to 100 ms delay. - */ -#ifdef CONFIG_BOARD_EC_HANDLES_ALL_SYS_PWRGD - -static void board_all_sys_pwrgd(void) -{ - int allsys_in = gpio_get_level(GPIO_ALL_SYS_PWRGD); - int allsys_out = gpio_get_level(GPIO_SYS_RESET_L); - - if (allsys_in == allsys_out) - return; - - CPRINTS("ALL_SYS_PWRGD=%d SYS_RESET_L=%d", allsys_in, allsys_out); - - trace2(0, BRD, 0, "ALL_SYS_PWRGD=%d SYS_RESET_L=%d", - allsys_in, allsys_out); - - /* - * Wait at least 10 ms between power signals going high - */ - if (allsys_in) - msleep(100); - - if (!allsys_out) { - /* CPRINTS("Set SYS_RESET_L = %d", allsys_in); */ - trace1(0, BRD, 0, "Set SYS_RESET_L=%d", allsys_in); - gpio_set_level(GPIO_SYS_RESET_L, allsys_in); - /* Force fan on for kabylake RVP */ - gpio_set_level(GPIO_EC_FAN1_PWM, 1); - } -} -DECLARE_DEFERRED(board_all_sys_pwrgd); - -void all_sys_pwrgd_interrupt(enum gpio_signal signal) -{ - trace0(0, ISR, 0, "ALL_SYS_PWRGD Edge"); - hook_call_deferred(&board_all_sys_pwrgd_data, 0); -} -#endif /* #ifdef CONFIG_BOARD_HAS_ALL_SYS_PWRGD */ - - -#ifdef HAS_TASK_PDCMD -/* Exchange status with PD MCU. */ -static void pd_mcu_interrupt(enum gpio_signal signal) -{ - /* Exchange status with PD MCU to determine interrupt cause */ - host_command_pd_send_status(0); - -} -#endif - -#ifdef CONFIG_USB_POWER_DELIVERY -void vbus0_evt(enum gpio_signal signal) -{ - /* VBUS present GPIO is inverted */ - usb_charger_vbus_change(0, !gpio_get_level(signal)); - task_wake(TASK_ID_PD_C0); -} - -void vbus1_evt(enum gpio_signal signal) -{ - /* VBUS present GPIO is inverted */ - usb_charger_vbus_change(1, !gpio_get_level(signal)); - task_wake(TASK_ID_PD_C1); -} - -void usb0_evt(enum gpio_signal signal) -{ - task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12); -} - -void usb1_evt(enum gpio_signal signal) -{ - task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12); -} -#endif - -/* - * enable_input_devices() is called by the tablet_mode ISR, but changes the - * state of GPIOs, so its definition must reside after including gpio_list. - */ -static void enable_input_devices(void); -DECLARE_DEFERRED(enable_input_devices); - -void tablet_mode_interrupt(enum gpio_signal signal) -{ - hook_call_deferred(&enable_input_devices_data, 0); -} - -#include "gpio_list.h" - -/* ADC channels - * name, factor multiplier, factor divider, shift, channel - */ -const struct adc_t adc_channels[] = { - /* Vbus sensing. Converted to mV, full ADC is equivalent to 30V. */ - [ADC_VBUS] = {"VBUS", 30000, 1024, 0, 1}, - /* Adapter current output or battery discharging current */ - [ADC_AMON_BMON] = {"AMON_BMON", 25000, 3072, 0, 3}, - /* System current consumption */ - [ADC_PSYS] = {"PSYS", 1, 1, 0, 4}, - [ADC_CASE] = {"CASE", 1, 1, 0, 7}, -}; -BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); - -/* - * MCHP EVB connected to KBL RVP3 - */ -const struct i2c_port_t i2c_ports[] = { - {"sensors", MCHP_I2C_PORT4, 100, GPIO_SMB04_SCL, GPIO_SMB04_SDA}, - {"batt", MCHP_I2C_PORT5, 100, GPIO_SMB05_SCL, GPIO_SMB05_SDA}, -}; -const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); - -/* - * Map ports to controller. - * Ports may map to the same controller. - */ -const uint16_t i2c_port_to_ctrl[I2C_PORT_COUNT] = { - (MCHP_I2C_CTRL0 << 8) + MCHP_I2C_PORT4, - (MCHP_I2C_CTRL1 << 8) + MCHP_I2C_PORT5 -}; - -/* - * default to I2C0 because callers may not check - * return value if we returned an error code. - */ -int board_i2c_p2c(int port) -{ - int i; - - for (i = 0; i < I2C_PORT_COUNT; i++) - if ((i2c_port_to_ctrl[i] & 0xFF) == port) - return (int)(i2c_port_to_ctrl[i] >> 8); - - return -1; -} - -#ifdef CONFIG_USB_POWER_DELIVERY -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - {I2C_PORT_TCPC, - CONFIG_TCPC_I2C_BASE_ADDR_FLAGS, - &tcpci_tcpm_drv}, - - {I2C_PORT_TCPC, - CONFIG_TCPC_I2C_BASE_ADDR_FLAGS + 1, - &tcpci_tcpm_drv}, -}; -#endif - -/* SPI devices */ -const struct spi_device_t spi_devices[] = { - { QMSPI0_PORT, 4, GPIO_QMSPI_CS0}, -#if defined(CONFIG_SPI_ACCEL_PORT) - { GPSPI0_PORT, 2, GPIO_SPI0_CS0 }, -#endif -}; -const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); - -const enum gpio_signal hibernate_wake_pins[] = { - GPIO_AC_PRESENT, - GPIO_LID_OPEN, - GPIO_POWER_BUTTON_L, -}; -const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); - - -/* - * Deep sleep support, called by chip level. - */ -#if defined(CONFIG_LOW_POWER_IDLE) && defined(CONFIG_BOARD_DEEP_SLEEP) - -/* - * Perform any board level prepare for sleep actions. - * For example, disabling pin/pads to further reduce - * current during sleep. - */ -void board_prepare_for_deep_sleep(void) -{ -#if defined(CONFIG_GPIO_POWER_DOWN) && \ - defined(CONFIG_MCHP_DEEP_SLP_GPIO_PWR_DOWN) - gpio_power_down_module(MODULE_SPI_FLASH); - gpio_power_down_module(MODULE_SPI_CONTROLLER); - gpio_power_down_module(MODULE_I2C); - /* powering down keyscan is causing an issue with keyscan task - * probably due to spurious interrupts on keyscan pins. - * gpio_config_module(MODULE_KEYBOARD_SCAN, 0); - */ - -#ifndef CONFIG_POWER_S0IX - gpio_power_down_module(MODULE_LPC); -#endif -#endif -} - -/* - * Perform any board level resume from sleep actions. - * For example, re-enabling pins powered off in - * board_prepare_for_deep_sleep(). - */ -void board_resume_from_deep_sleep(void) -{ -#if defined(CONFIG_GPIO_POWER_DOWN) && \ - defined(CONFIG_MCHP_DEEP_SLP_GPIO_PWR_DOWN) -#ifndef CONFIG_POWER_S0IX - gpio_config_module(MODULE_LPC, 1); -#endif - /* gpio_config_module(MODULE_KEYBOARD_SCAN, 1); */ - gpio_config_module(MODULE_SPI_FLASH, 1); - gpio_config_module(MODULE_SPI_CONTROLLER, 1); - gpio_config_module(MODULE_I2C, 1); -#endif -} -#endif - -#ifdef CONFIG_USB_MUX_PI3USB30532 -struct pi3usb9281_config pi3usb9281_chips[] = { - { - .i2c_port = I2C_PORT_USB_CHARGER_1, - .mux_lock = NULL, - }, - { - .i2c_port = I2C_PORT_USB_CHARGER_2, - .mux_lock = NULL, - }, -}; -BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) == - CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT); - -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, - .i2c_addr_flags = 0x10, - .driver = &ps8740_usb_mux_driver, - } -}; -#endif - -/** - * Reset PD MCU - */ -void board_reset_pd_mcu(void) -{ - gpio_set_level(GPIO_PD_RST_L, 0); - usleep(100); - gpio_set_level(GPIO_PD_RST_L, 1); -} - -/* - * - */ -static int therm_get_val(int idx, int *temp_ptr) -{ - if (temp_ptr != NULL) { - *temp_ptr = adc_read_channel(idx); - return EC_SUCCESS; - } - - return EC_ERROR_PARAM2; -} - -#ifdef CONFIG_TEMP_SENSOR -#if 0 /* Chromebook design uses ADC in BD99992GW PMIC */ -const struct temp_sensor_t temp_sensors[] = { - {"Battery", TEMP_SENSOR_TYPE_BATTERY, charge_get_battery_temp, 0, 4}, - - /* These BD99992GW temp sensors are only readable in S0 */ - {"Ambient", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val, - BD99992GW_ADC_CHANNEL_SYSTHERM0, 4}, - {"Charger", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val, - BD99992GW_ADC_CHANNEL_SYSTHERM1, 4}, - {"DRAM", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val, - BD99992GW_ADC_CHANNEL_SYSTHERM2, 4}, - {"Wifi", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val, - BD99992GW_ADC_CHANNEL_SYSTHERM3, 4}, -}; -BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); -#else /* mec1701_evb test I2C and EC ADC */ -/* - * battery charge_get_battery_temp requires charger task running. - * OR can we call into driver/battery/smart.c - * int sb_read(int cmd, int *param) - * sb_read(SB_TEMPERATURE, &batt_new.temperature) - * Issue is functions in this table return a value from a memory array. - * There's a task or hook that is actually reading the temperature. - * We could implement a one second hook to call sb_read() and fill in - * a static global in this module. - */ -const struct temp_sensor_t temp_sensors[] = { - {"Battery", TEMP_SENSOR_TYPE_BATTERY, sb_temp, 0}, - {"Ambient", TEMP_SENSOR_TYPE_BOARD, ds1624_get_val, 0}, - {"Case", TEMP_SENSOR_TYPE_CASE, therm_get_val, (int)ADC_CASE}, -}; -BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); -#endif -#endif - -#ifdef CONFIG_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 button_config buttons[CONFIG_BUTTON_COUNT] = { - {"Volume Down", KEYBOARD_BUTTON_VOLUME_DOWN, GPIO_VOLUME_DOWN_L, - 30 * MSEC, 0}, - {"Volume Up", KEYBOARD_BUTTON_VOLUME_UP, GPIO_VOLUME_UP_L, - 30 * MSEC, 0}, -}; - -/* MCHP mec1701_evb connected to Intel SKL RVP3 with Kabylake - * processor we do not control the PMIC on SKL. - */ -static void board_pmic_init(void) -{ - int rv, cfg; - - /* No need to re-init PMIC since settings are sticky across sysjump */ - if (system_jumped_late()) - return; - -#if 0 /* BD99992GW PMIC on a real Chromebook */ - /* Set CSDECAYEN / VCCIO decays to 0V at assertion of SLP_S0# */ - i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x30, 0x4a); - - /* - * Set V100ACNT / V1.00A Control Register: - * Nominal output = 1.0V. - */ - i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x37, 0x1a); - - /* - * Set V085ACNT / V0.85A Control Register: - * Lower power mode = 0.7V. - * Nominal output = 1.0V. - */ - i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x38, 0x7a); - - /* VRMODECTRL - enable low-power mode for VCCIO and V0.85A */ - i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992, 0x3b, 0x18); -#else - CPRINTS("HOOK_INIT - called board_pmic_init"); - trace0(0, HOOK, 0, "HOOK_INIT - call board_pmic_init"); - - /* Config DS1624 temperature sensor for continuous conversion */ - cfg = 0x66; - rv = i2c_read8(I2C_PORT_THERMAL, DS1624_I2C_ADDR_FLAGS, - DS1624_ACCESS_CFG, &cfg); - trace2(0, BRD, 0, "Read DS1624 Config rv = %d cfg = 0x%02X", - rv, cfg); - - if ((rv == EC_SUCCESS) && (cfg & (1u << 0))) { - /* one-shot mode switch to continuous */ - rv = i2c_write8(I2C_PORT_THERMAL, DS1624_I2C_ADDR_FLAGS, - DS1624_ACCESS_CFG, 0); - trace1(0, BRD, 0, "Write DS1624 Config to 0, rv = %d", rv); - /* writes to config require 10ms until next I2C command */ - if (rv == EC_SUCCESS) - udelay(10000); - } - - /* Send start command */ - rv = i2c_write8(I2C_PORT_THERMAL, DS1624_I2C_ADDR_FLAGS, - DS1624_CMD_START, 1); - trace1(0, BRD, 0, "Send Start command to DS1624 rv = %d", rv); - - return; -#endif -} -DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_DEFAULT); - -/* Initialize board. */ -static void board_init(void) -{ - CPRINTS("MEC1701 HOOK_INIT - called board_init"); - trace0(0, HOOK, 0, "HOOK_INIT - call board_init"); - -#ifdef CONFIG_USB_POWER_DELIVERY - /* Enable PD MCU interrupt */ - gpio_enable_interrupt(GPIO_PD_MCU_INT); - /* Enable VBUS interrupt */ - gpio_enable_interrupt(GPIO_USB_C0_VBUS_WAKE_L); - gpio_enable_interrupt(GPIO_USB_C1_VBUS_WAKE_L); - - /* Enable pericom BC1.2 interrupts */ - gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_L); - gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L); -#endif - /* Enable tablet mode interrupt for input device enable */ - gpio_enable_interrupt(GPIO_TABLET_MODE_L); - - /* Provide AC status to the PCH */ - gpio_set_level(GPIO_PCH_ACOK, extpower_is_present()); - - if (system_jumped_late() && - chipset_in_state(CHIPSET_STATE_ON)) { - trace0(0, BRD, 0, "board_init: S0 call board_spi_enable"); - board_spi_enable(); - } - -} -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); - - -/** - * Buffer the AC present GPIO to the PCH. - */ -static void board_extpower(void) -{ - CPRINTS("MEC1701 HOOK_AC_CHANGE - called board_extpower"); - trace0(0, HOOK, 0, "HOOK_AC_CHANGET - call board_extpower"); - gpio_set_level(GPIO_PCH_ACOK, extpower_is_present()); -} -DECLARE_HOOK(HOOK_AC_CHANGE, board_extpower, HOOK_PRIO_DEFAULT); - -#ifdef CONFIG_CHARGER -/** - * Set active charge port -- only one port can be active at a time. - * - * @param charge_port Charge port to enable. - * - * Returns 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 realy physical port */ - int is_real_port = (charge_port >= 0 && - charge_port < CONFIG_USB_PD_PORT_MAX_COUNT); - /* check if we are source vbus on that port */ - int source = gpio_get_level(charge_port == 0 ? GPIO_USB_C0_5V_EN : - GPIO_USB_C1_5V_EN); - - if (is_real_port && source) { - CPRINTS("MEC1701 Skip enable p%d", charge_port); - trace1(0, BOARD, 0, "Skip enable charge port %d", - charge_port); - return EC_ERROR_INVAL; - } - - CPRINTS("MEC1701 New chg p%d", charge_port); - trace1(0, BOARD, 0, "New charge port %d", charge_port); - - if (charge_port == CHARGE_PORT_NONE) { - /* Disable both ports */ - gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, 1); - gpio_set_level(GPIO_USB_C1_CHARGE_EN_L, 1); - } else { - /* Make sure non-charging port is disabled */ - gpio_set_level(charge_port ? GPIO_USB_C0_CHARGE_EN_L : - GPIO_USB_C1_CHARGE_EN_L, 1); - /* Enable charging port */ - gpio_set_level(charge_port ? GPIO_USB_C1_CHARGE_EN_L : - GPIO_USB_C0_CHARGE_EN_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); -} -#else -/* - * TODO HACK providing functions from common/charge_state_v2.c - * which is not compiled in when no charger - */ -int charge_prevent_power_on(int power_button_pressed) -{ - return 0; -} - - -#endif - -/* - * Enable or disable input devices, - * based upon chipset state and tablet mode - */ -static void enable_input_devices(void) -{ - int kb_enable = 1; - int tp_enable = 1; - - /* Disable both TP and KB in tablet mode */ - if (!gpio_get_level(GPIO_TABLET_MODE_L)) - kb_enable = tp_enable = 0; - /* Disable TP if chipset is off */ - else if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - tp_enable = 0; - - keyboard_scan_enable(kb_enable, KB_SCAN_DISABLE_LID_ANGLE); - gpio_set_level(GPIO_ENABLE_TOUCHPAD, tp_enable); -} - -/* Called on AP S5 -> S3 transition */ -static void board_chipset_startup(void) -{ - CPRINTS("MEC1701 HOOK_CHIPSET_STARTUP - called board_chipset_startup"); - trace0(0, HOOK, 0, "HOOK_CHIPSET_STARTUP - board_chipset_startup"); - gpio_set_level(GPIO_USB1_ENABLE, 1); - gpio_set_level(GPIO_USB2_ENABLE, 1); - hook_call_deferred(&enable_input_devices_data, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, - board_chipset_startup, - HOOK_PRIO_DEFAULT); - -/* Called on AP S3 -> S5 transition */ -static void board_chipset_shutdown(void) -{ - CPRINTS("MEC1701 HOOK_CHIPSET_SHUTDOWN board_chipset_shutdown"); - trace0(0, HOOK, 0, - "HOOK_CHIPSET_SHUTDOWN board_chipset_shutdown"); - gpio_set_level(GPIO_USB1_ENABLE, 0); - gpio_set_level(GPIO_USB2_ENABLE, 0); - hook_call_deferred(&enable_input_devices_data, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, - board_chipset_shutdown, - HOOK_PRIO_DEFAULT); - -/* Called on AP S3 -> S0 transition */ -static void board_chipset_resume(void) -{ - CPRINTS("MEC1701_EVG HOOK_CHIPSET_RESUME"); - trace0(0, HOOK, 0, "HOOK_CHIPSET_RESUME - board_chipset_resume"); - gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1); -#if 0 /* TODO not implemented in gpio.inc */ - gpio_set_level(GPIO_PP1800_DX_AUDIO_EN, 1); - gpio_set_level(GPIO_PP1800_DX_SENSOR_EN, 1); -#endif - -} -DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, - MOTION_SENSE_HOOK_PRIO-1); - -/* Called on AP S0 -> S3 transition */ -static void board_chipset_suspend(void) -{ - CPRINTS("MEC1701 HOOK_CHIPSET_SUSPEND - called board_chipset_resume"); - trace0(0, HOOK, 0, "HOOK_CHIPSET_SUSPEND - board_chipset_suspend"); - gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0); -#if 0 /* TODO not implemented in gpio.inc */ - gpio_set_level(GPIO_PP1800_DX_AUDIO_EN, 0); - gpio_set_level(GPIO_PP1800_DX_SENSOR_EN, 0); -#endif -} -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, - board_chipset_suspend, - HOOK_PRIO_DEFAULT); - -void board_hibernate_late(void) -{ - /* put host chipset into reset */ - gpio_set_level(GPIO_SYS_RESET_L, 0); - - /* Turn off LEDs in hibernate */ - gpio_set_level(GPIO_CHARGE_LED_1, 0); - gpio_set_level(GPIO_CHARGE_LED_2, 0); - - /* - * Set PD wake low so that it toggles high to generate a wake - * event once we leave hibernate. - */ - gpio_set_level(GPIO_USB_PD_WAKE, 0); - -#ifdef CONFIG_USB_PD_PORT_MAX_COUNT - /* - * Leave USB-C charging enabled in hibernate, in order to - * allow wake-on-plug. 5V enable must be pulled low. - */ -#if CONFIG_USB_PD_PORT_MAX_COUNT > 0 - gpio_set_flags(GPIO_USB_C0_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT); - gpio_set_level(GPIO_USB_C0_CHARGE_EN_L, 0); -#endif -#if CONFIG_USB_PD_PORT_MAX_COUNT > 1 - gpio_set_flags(GPIO_USB_C1_5V_EN, GPIO_PULL_DOWN | GPIO_INPUT); - gpio_set_level(GPIO_USB_C1_CHARGE_EN_L, 0); -#endif -#endif /* CONFIG_USB_PD_PORT_MAX_COUNT */ -} - -/* Any glados boards post version 2 should have ROP_LDO_EN stuffed. */ -#define BOARD_MIN_ID_LOD_EN 2 -/* Make the pmic re-sequence the power rails under these conditions. */ -#define PMIC_RESET_FLAGS \ - (EC_RESET_FLAG_WATCHDOG | EC_RESET_FLAG_SOFT | EC_RESET_FLAG_HARD) -static void board_handle_reboot(void) -{ -#if 0 /* MEC17xx EVB + SKL-RVP3 does not use chromebook PMIC design */ - int flags; -#endif - CPRINTS("MEC HOOK_INIT - called board_handle_reboot"); - trace0(0, HOOK, 0, "HOOK_INIT - board_handle_reboot"); - - if (system_jumped_late()) - return; - - if (system_get_board_version() < BOARD_MIN_ID_LOD_EN) - return; - -#if 0 /* TODO MCHP KBL hack not PMIC system */ - /* Interrogate current reset flags from previous reboot. */ - flags = system_get_reset_flags(); - - if (!(flags & PMIC_RESET_FLAGS)) - return; - - /* Preserve AP off request. */ - if (flags & EC_RESET_FLAG_AP_OFF) - chip_save_reset_flags(EC_RESET_FLAG_AP_OFF); - - ccprintf("Restarting system with PMIC.\n"); - /* Flush console */ - cflush(); - - /* Bring down all rails but RTC rail (including EC power). */ - gpio_set_flags(GPIO_BATLOW_L_PMIC_LDO_EN, GPIO_OUT_HIGH); - while (1) - ; /* wait here */ -#else - return; -#endif -} -DECLARE_HOOK(HOOK_INIT, board_handle_reboot, HOOK_PRIO_FIRST); - - -static int sb_temp(int idx, int *temp_ptr) -{ - if (idx != 0) - return EC_ERROR_PARAM1; - - if (temp_ptr == NULL) - return EC_ERROR_PARAM2; - - *temp_ptr = smart_batt_temp; - - return EC_SUCCESS; -} - -static int ds1624_get_val(int idx, int *temp_ptr) -{ - if (idx != 0) - return EC_ERROR_PARAM1; - - if (temp_ptr == NULL) - return EC_ERROR_PARAM2; - - *temp_ptr = ds1624_temp; - - return EC_SUCCESS; -} - -/* call smart battery code to get its temperature - * output is in tenth degrees C - */ -static void sb_update(void) -{ - int rv __attribute__((unused)); - - rv = sb_read(SB_TEMPERATURE, &smart_batt_temp); - smart_batt_temp = smart_batt_temp / 10; - - trace12(0, BRD, 0, "sb_read temperature rv=%d temp=%d K", - rv, smart_batt_temp); -} - -/* - * Read temperature from Maxim DS1624 sensor. It only has internal sensor - * and is configured for continuous reading mode by default. - * DS1624 does not implement temperature limits or other features of - * sensors like the TMP411. - * Output format is 16-bit MSB first signed celcius temperature in units - * of 0.0625 degree Celsius. - * b[15]=sign bit - * b[14]=2^6, b[13]=2^5, ..., b[8]=2^0 - * b[7]=1/2, b[6]=1/4, b[5]=1/8, b[4]=1/16 - * b[3:0]=0000b - * - */ -static void ds1624_update(void) -{ - uint32_t d; - int temp; - int rv __attribute__((unused)); - - rv = i2c_read16(I2C_PORT_THERMAL, DS1624_I2C_ADDR_FLAGS, - DS1624_READ_TEMP16, &temp); - - d = (temp & 0x7FFF) >> 8; - if ((uint32_t)temp & BIT(7)) - d++; - - if ((uint32_t)temp & BIT(15)) - d |= (1u << 31); - - ds1624_temp = (int32_t)d; - - trace3(0, BRD, 0, "ds1624_update: rv=%d raw temp = 0x%04X tempC = %d", - rv, temp, ds1624_temp); -} - -/* Indicate scheduler is alive by blinking an LED. - * Test I2C by reading a smart battery and temperature sensor. - * Smart battery 16 bit temperature is in units of 1/10 degree C. - */ -static void board_one_sec(void) -{ - trace0(0, BRD, 0, "HOOK_SECOND"); - - if (gpio_get_level(GPIO_CHARGE_LED_2)) - gpio_set_level(GPIO_CHARGE_LED_2, 0); - else - gpio_set_level(GPIO_CHARGE_LED_2, 1); - - sb_update(); - ds1624_update(); -} -DECLARE_HOOK(HOOK_SECOND, board_one_sec, HOOK_PRIO_DEFAULT); - -/* Motion sensors */ - -static struct mutex g_base_mutex; -/* BMI160 private data */ -static struct bmi_drv_data_t g_bmi160_data; - -#ifdef CONFIG_ACCEL_KX022 -static struct mutex g_lid_mutex; -/* KX022 private data */ -static struct kionix_accel_data g_kx022_data; -#endif - -struct motion_sensor_t motion_sensors[] = { - /* - * 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 = CONFIG_SPI_ACCEL_PORT, - .i2c_spi_addr_flags = ACCEL_MK_SPI_ADDR_FLAGS( - CONFIG_SPI_ACCEL_PORT), - .rot_standard_ref = NULL, /* Identity matrix. */ - .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 = CONFIG_SPI_ACCEL_PORT, - .i2c_spi_addr_flags = ACCEL_MK_SPI_ADDR_FLAGS( - CONFIG_SPI_ACCEL_PORT), - .default_range = 1000, /* dps */ - .rot_standard_ref = NULL, /* Identity Matrix. */ - .min_frequency = BMI_GYRO_MIN_FREQ, - .max_frequency = BMI_GYRO_MAX_FREQ, - }, -#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, enough for laptop. */ - .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 /* #ifdef CONFIG_ACCEL_KX022 */ -}; -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); - -static void board_spi_enable(void) -{ - trace0(0, BRD, 0, "HOOK_CHIPSET_STARTUP - board_spi_enable"); - - spi_enable(&spi_devices[1], 1); - - /* Toggle SPI chip select to switch BMI160 from I2C mode - * to SPI mode - */ - gpio_set_level(GPIO_SPI0_CS0, 0); - udelay(10); - gpio_set_level(GPIO_SPI0_CS0, 1); -} -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_spi_enable, - MOTION_SENSE_HOOK_PRIO - 1); - -static void board_spi_disable(void) -{ - trace0(0, BRD, 0, "HOOK_CHIPSET_SHUTDOWN - board_spi_disable"); - spi_enable(&spi_devices[1], 0); -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_spi_disable, - MOTION_SENSE_HOOK_PRIO + 1); - -#ifdef MEC1701_EVB_TACH_TEST /* PWM/TACH test */ -void tach0_isr(void) -{ - MCHP_INT_DISABLE(MCHP_TACH_GIRQ) = MCHP_TACH_GIRQ_BIT(0); - MCHP_INT_SOURCE(MCHP_TACH_GIRQ) = MCHP_TACH_GIRQ_BIT(0); -} -DECLARE_IRQ(MCHP_IRQ_TACH_0, tach0_isr, 1); -#endif diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h deleted file mode 100644 index 98ab333b67..0000000000 --- a/board/mchpevb1/board.h +++ /dev/null @@ -1,487 +0,0 @@ -/* Copyright 2017 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. - */ - -/* - * Microchip Evaluation Board (EVB) with - * MEC1701H 144-pin processor card. - * EVB connected to Intel SKL RVP3 configured - * for eSPI with Kabylake silicon. - */ - -#ifndef __CROS_EC_BOARD_H -#define __CROS_EC_BOARD_H - -/* - * Initial board bringup and prevent power button task from - * generating event to exit G3 state. - * - * #define CONFIG_BRINGUP - */ - -/* - * Debug on EVB with CONFIG_CHIPSET_DEBUG - * Keep WDG disabled and JTAG enabled. - * CONFIG_BOARD_PRE_INIT enables JTAG early - */ -/* #define CONFIG_CHIPSET_DEBUG */ - -#ifdef CONFIG_CHIPSET_DEBUG -#ifndef CONFIG_BOARD_PRE_INIT -#define CONFIG_BOARD_PRE_INIT -#endif -#endif - -/* - * DEBUG: Add CRC32 in last 4 bytes of EC_RO/RW binaries - * in SPI. LFW will use DMA CRC32 HW to check data integrity. - * #define CONFIG_MCHP_LFW_DEBUG - */ - -/* - * EC UART console on UART 0 or 1 - */ -#define CONFIG_UART_CONSOLE 0 - -/* - * Override Boot-ROM JTAG mode - * 0x01 = 4-pin standard JTAG - * 0x03 = ARM 2-pin SWD + 1-pin SWV - * 0x05 = ARM 2-pin SWD no SWV - */ -#define CONFIG_MCHP_JTAG_MODE 0x03 - -/* - * Enable Trace FIFO Debug port - * When this is undefined all TRACEn() and tracen() - * macros are defined as blank. - * Uncomment this define to enable these messages. - * Only enable if GPIO's 0171 & 0171 are available therefore - * define this at the board level. - */ -/* #define CONFIG_MCHP_TFDP */ - -/* - * Enable MCHP specific GPIO EC UART commands - * for debug. - */ -/* #define CONFIG_MEC_GPIO_EC_CMDS */ - -/* - * Enable CPRINT in chip eSPI module - * and EC UART test command. - */ -/* #define CONFIG_MCHP_ESPI_DEBUG */ - -/* - * Enable board specific ISR on ALL_SYS_PWRGD signal. - * Requires for handling Kabylake/Skylake RVP3 board's - * ALL_SYS_PWRGD signal. - */ -#define CONFIG_BOARD_EC_HANDLES_ALL_SYS_PWRGD - -/* - * EVB eSPI test mode (no eSPI master connected) - */ -/* - * #define EVB_NO_ESPI_TEST_MODE - */ - - -/* - * DEBUG - * Disable ARM Cortex-M4 write buffer so - * exceptions become synchronous. - * - * #define CONFIG_DEBUG_DISABLE_WRITE_BUFFER - */ - -/* New eSPI configuration items */ - -/* - * Maximum clock frequence eSPI EC advertises - * Values in MHz are 20, 25, 33, 50, and 66 - */ -/* KBL + EVB fly-wire hook up only supports 20MHz */ -#define CONFIG_HOSTCMD_ESPI_EC_MAX_FREQ MCHP_ESPI_CAP1_MAX_FREQ_20M - -/* - * EC eSPI advertises IO lanes - * 0 = Single - * 1 = Single and Dual - * 2 = Single and Quad - * 3 = Single, Dual, and Quad - */ -/* KBL + EVB fly-wire hook up only support Single mode */ -#define CONFIG_HOSTCMD_ESPI_EC_MODE MCHP_ESPI_CAP1_SINGLE_MODE - -/* - * Bit map of eSPI channels EC advertises - * bit[0] = 1 Peripheral channel - * bit[1] = 1 Virtual Wire channel - * bit[2] = 1 OOB channel - * bit[3] = 1 Flash channel - */ -#define CONFIG_HOSTCMD_ESPI_EC_CHAN_BITMAP MCHP_ESPI_CAP0_ALL_CHAN_SUPP - -#define CONFIG_MCHP_ESPI_VW_SAVE_ON_SLEEP - -/* - * Allow dangerous commands. - * TODO(shawnn): Remove this config before production. - */ -#define CONFIG_SYSTEM_UNLOCKED - -/* Optional features */ -#define CONFIG_ACCELGYRO_BMI160 -/* #define CONFIG_ACCEL_KX022 */ -/* #define CONFIG_ALS */ -/* #define CONFIG_ALS_OPT3001 */ -#define CONFIG_BATTERY_CUT_OFF -#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L -#define CONFIG_BATTERY_SMART -#define CONFIG_BOARD_VERSION_GPIO -#define CONFIG_BUTTON_COUNT 2 -/* #define CONFIG_CHARGE_MANAGER */ -/* #define CONFIG_CHARGE_RAMP_SW */ - - -/* #define CONFIG_CHARGER */ - -/* #define CONFIG_CHARGER_DISCHARGE_ON_AC */ -/* #define CONFIG_CHARGER_ISL9237 */ -/* #define CONFIG_CHARGER_ILIM_PIN_DISABLED */ -/* #define CONFIG_CHARGER_INPUT_CURRENT 512 */ - -/* #define CONFIG_CHARGER_NARROW_VDC */ -/* #define CONFIG_CHARGER_PROFILE_OVERRIDE */ -/* #define CONFIG_CHARGER_SENSE_RESISTOR 10 */ -/* #define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 */ -/* #define CONFIG_CMD_CHARGER_ADC_AMON_BMON */ - -#define CONFIG_CHIPSET_SKYLAKE -#define CONFIG_CHIPSET_RESET_HOOK - -#define CONFIG_HOSTCMD_ESPI -#define CONFIG_HOSTCMD_ESPI_VW_SLP_S3 -#define CONFIG_HOSTCMD_ESPI_VW_SLP_S4 - -#define CONFIG_CLOCK_CRYSTAL -#define CONFIG_EXTPOWER_GPIO -/* #define CONFIG_HOSTCMD_PD */ -/* #define CONFIG_HOSTCMD_PD_PANIC */ -#define CONFIG_I2C -#define CONFIG_I2C_CONTROLLER -#define CONFIG_KEYBOARD_PROTOCOL_8042 -#define CONFIG_LED_COMMON - -#ifdef CONFIG_ACCEL_KX022 -#define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_LID LID_ACCEL -#define CONFIG_LID_ANGLE_SENSOR_BASE BASE_ACCEL -#endif /* CONFIG_ACCEL_KX022 */ - -#define CONFIG_LID_SWITCH -/* - * Enable MCHP Low Power Idle support - * and API to power down pins - * #define CONFIG_LOW_POWER_IDLE - */ - - -/* #define CONFIG_GPIO_POWER_DOWN */ - -/* - * Turn off pin modules during deep sleep. - * Requires CONFIG_GPIO_POWER_DOWN - */ -/* #define CONFIG_MCHP_DEEP_SLP_GPIO_PWR_DOWN */ - -/* - * DEBUG: Configure MEC17xx GPIO060 as 48MHZ_OUT to - * verify & debug clock is shutdown in heavy sleep. - */ -#define CONFIG_MCHP_48MHZ_OUT - -/* - * DEBUG: Save and print out PCR sleep enables, - * clock required, and interrupt aggregator result - * registers. - */ -#define CONFIG_MCHP_DEEP_SLP_DEBUG - -/* - * MCHP debug EC code turn off GCC link-time-optimization - * #define CONFIG_LTO - */ -#define CONFIG_POWER_BUTTON -#define CONFIG_POWER_BUTTON_X86 -#define CONFIG_POWER_COMMON -#define CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD 30 - -/* - * MEC1701H SCI is virtual wire on eSPI - *#define CONFIG_SCI_GPIO GPIO_PCH_SCI_L - */ - -#if 0 /* MCHP EVB + KBL/SKL RVP3 no USB charging hardware */ -#define CONFIG_USB_CHARGER -#define CONFIG_USB_MUX_PI3USB30532 -#define CONFIG_USB_MUX_PS8740 -#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_DP_HPD_GPIO -#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 -#endif -/* - * #define CONFIG_USB_PD_TCPC - * #define CONFIG_USB_PD_TCPM_STUB - */ -#if 0 -#define CONFIG_USB_PD_TRY_SRC -#define CONFIG_USB_PD_VBUS_DETECT_GPIO -#define CONFIG_BC12_DETECT_PI3USB9281 -#define CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT 2 -#define CONFIG_USBC_SS_MUX -#define CONFIG_USBC_SS_MUX_DFP_ONLY -#define CONFIG_USBC_VCONN -#define CONFIG_USBC_VCONN_SWAP -#endif - -#define CONFIG_VBOOT_HASH - -/* - * MEC1701H loads firmware using QMSPI controller - * CONFIG_SPI_FLASH_PORT is the index into - * spi_devices[] in board.c - */ -#define CONFIG_SPI_FLASH_PORT 0 -#define CONFIG_SPI_FLASH -/* - * Google uses smaller flashes on chromebook boards - * MCHP SPI test dongle for EVB uses 16MB W25Q128F - * Configure for smaller flash is OK for testing except - * for SPI flash lock bit. - */ - #define CONFIG_FLASH_SIZE_BYTES 524288 - #define CONFIG_SPI_FLASH_W25X40 -/* - * #define CONFIG_FLASH_SIZE_BYTES 0x1000000 - * #define CONFIG_SPI_FLASH_W25Q128 - */ - -/* - * Enable extra SPI flash and generic SPI - * commands via EC UART - */ -#define CONFIG_CMD_SPI_FLASH -#define CONFIG_CMD_SPI_XFER - -/* common software SHA256 required by vboot and rollback */ -#define CONFIG_SHA256 - -/* - * Enable MCHP SHA256 hardware accelerator module. - * API is same as software SHA256 but prefixed with "chip_" - * #define CONFIG_SHA256_HW - */ - -/* enable console command to test HW Hash engine - * #define CONFIG_CMD_SHA256_TEST - */ - -/* - * MEC17xx EVB + SKL/KBL RVP3 does not have - * BD99992GW PMIC with NCP15WB thermistor. - * We have connected a Maxim DS1624 I2C temperature - * sensor. The sensor board has a thermistor on it - * we connect to an EC ADC channel. - */ -#if 0 -#define CONFIG_TEMP_SENSOR -#define CONFIG_TEMP_SENSOR_BD99992GW -#define CONFIG_THERMISTOR_NCP15WB -#define CONFIG_DPTF -#else -#define CONFIG_TEMP_SENSOR -#define CONFIG_DPTF -#endif - -/* Enable GPSPI0 controller and port for - * SPI Accelerometer. - * bit[0] == 1 GPSPI0 - * bit[1] == 0 board does not use GPSPI1 - * Make sure to not include GPSPI in little-firmware(LFW) - */ -#ifndef LFW -#define CONFIG_MCHP_GPSPI 0x01 -#endif - -/* SPI Accelerometer - * CONFIG_SPI_FLASH_PORT is the index into - * spi_devices[] in board.c - */ -#define CONFIG_SPI_ACCEL_PORT 1 - -/* - * Enable EC UART commands to read/write - * motion sensor. - */ -#define CONFIG_CMD_ACCELS - -/* - * Enable 1 slot of secure temporary storage to support - * suspend/resume with read/write memory training. - */ -#define CONFIG_VSTORE -#define CONFIG_VSTORE_SLOT_COUNT 1 - -#define CONFIG_WATCHDOG_HELP - -#if 0 /* TODO - No wireless on EVB */ -#define CONFIG_WIRELESS -#define CONFIG_WIRELESS_SUSPEND \ - (EC_WIRELESS_SWITCH_WLAN | EC_WIRELESS_SWITCH_WLAN_POWER) - -/* Wireless signals */ -#define WIRELESS_GPIO_WLAN GPIO_WLAN_OFF_L -#define WIRELESS_GPIO_WLAN_POWER GPIO_PP3300_WLAN_EN -#endif - -/* LED signals */ -#define GPIO_BAT_LED_RED GPIO_CHARGE_LED_1 -#define GPIO_BAT_LED_GREEN GPIO_CHARGE_LED_2 - -/* I2C ports */ -#define I2C_CONTROLLER_COUNT 2 -#define I2C_PORT_COUNT 2 - - -/* - * Map I2C Ports to Controllers for this board. - * - * I2C Controller 0 ---- Port 0 -> PMIC, USB Charger 2 - * |-- Port 2 -> USB Charger 1, USB Mux - * - * I2C Controller 1 ---- Port 3 -> PD MCU, TCPC - * I2C Controller 2 ---- Port 4 -> ALS, Accel - * I2C Controller 3 ---- Port 5 -> Battery, Charger - * - * All other ports set to 0xff (not used) - */ - -#define I2C_PORT_PMIC MCHP_I2C_PORT10 -#define I2C_PORT_USB_CHARGER_1 MCHP_I2C_PORT2 -#define I2C_PORT_USB_MUX MCHP_I2C_PORT2 -#define I2C_PORT_USB_CHARGER_2 MCHP_I2C_PORT2 -#define I2C_PORT_PD_MCU MCHP_I2C_PORT3 -#define I2C_PORT_TCPC MCHP_I2C_PORT3 -#define I2C_PORT_ALS MCHP_I2C_PORT4 -#define I2C_PORT_ACCEL MCHP_I2C_PORT4 -#define I2C_PORT_BATTERY MCHP_I2C_PORT5 -#define I2C_PORT_CHARGER MCHP_I2C_PORT5 - -/* Thermal sensors read through PMIC ADC interface */ -#if 0 -#define I2C_PORT_THERMAL I2C_PORT_PMIC -#else -#define I2C_PORT_THERMAL MCHP_I2C_PORT4 -#endif - -/* Ambient Light Sensor address */ -#define OPT3001_I2C_ADDR_FLAGS OPT3001_I2C_ADDR1_FLAGS - -/* Modules we want to exclude */ -#undef CONFIG_CMD_HASH -#undef CONFIG_CMD_TEMP_SENSOR -#undef CONFIG_CMD_TIMERINFO -/* #undef CONFIG_CONSOLE_CMDHELP */ - -#ifndef __ASSEMBLER__ - -#include "gpio_signal.h" -#include "registers.h" - -/* ADC signal */ -enum adc_channel { - ADC_VBUS, - ADC_AMON_BMON, - ADC_PSYS, - ADC_CASE, - /* Number of ADC channels */ - ADC_CH_COUNT -}; - -enum temp_sensor_id { - TEMP_SENSOR_BATTERY, - - /* These temp sensors are only readable in S0 */ - TEMP_SENSOR_AMBIENT, - TEMP_SENSOR_CASE, -/* TEMP_SENSOR_CHARGER, */ -/* TEMP_SENSOR_DRAM, */ -/* TEMP_SENSOR_WIFI, */ - - TEMP_SENSOR_COUNT -}; - -enum sensor_id { - BASE_ACCEL, - BASE_GYRO, -#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 45000 -#define PD_MAX_CURRENT_MA 3000 - -/* Try to negotiate to 20V since i2c noise problems should be fixed. */ -#define PD_MAX_VOLTAGE_MV 20000 - -/* - * include TFDP macros from mchp chip level - */ -#include "tfdp_chip.h" - - -/* Map I2C port to controller */ -int board_i2c_p2c(int port); - -/* Reset PD MCU */ -void board_reset_pd_mcu(void); - -#ifdef CONFIG_LOW_POWER_IDLE -void board_prepare_for_deep_sleep(void); -void board_resume_from_deep_sleep(void); -#endif - -#endif /* !__ASSEMBLER__ */ - -#endif /* __CROS_EC_BOARD_H */ diff --git a/board/mchpevb1/build.mk b/board/mchpevb1/build.mk deleted file mode 100644 index 412b04d46b..0000000000 --- a/board/mchpevb1/build.mk +++ /dev/null @@ -1,19 +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 -# - -# the IC is Microchip MEC1701 -# external SPI is 512KB -# external clock is crystal -CHIP:=mchp -CHIP_FAMILY:=mec170x -CHIP_VARIANT:=mec1701 -CHIP_SPI_SIZE_KB:=512 - -board-y=board.o led.o -board-$(CONFIG_BATTERY_SMART)+=battery.o -board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o diff --git a/board/mchpevb1/ec.tasklist b/board/mchpevb1/ec.tasklist deleted file mode 100644 index 6fcd5faa98..0000000000 --- a/board/mchpevb1/ec.tasklist +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2017 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. - */ -#define CONFIG_TASK_LIST \ - TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ - TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(POWERBTN, power_button_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE) - diff --git a/board/mchpevb1/gpio.inc b/board/mchpevb1/gpio.inc deleted file mode 100644 index 8be1099fbd..0000000000 --- a/board/mchpevb1/gpio.inc +++ /dev/null @@ -1,450 +0,0 @@ -/* -*- mode:c -*- - * - * Copyright 2017 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. - */ - -/* - * mec1701h_evb board GPIO pins - * !!!!!!!!!!!!!!!!!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!!!!!!!!!!! - * MEC1701 and MEC1322 data sheets GPIO numbers are OCTAL. - * Original glados MEC1322 used these octal numbers as base 10. - * mec1701 and its boards will use OCTAL therefore make sure all - * numbers used below are written as C OCTAL with a leading 0. - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - */ -/* NOTE: We use JTAG on MEC1701H on EVB. - * GPIO_0145 is JTAG_TDI - * GPIO_0146 is JTAG_TDO - * GPIO_0147 is JTAG_CLK - * GPIO_0150 is JTAG_TMS - */ - -/* include common gpio.inc under chip/mchp/lfw/... */ -#include "chip/mchp/lfw/gpio.inc" - -#define GPIO_BOTH_EDGES_PU (GPIO_INT_BOTH | GPIO_PULL_UP) - -/* Only needed if CONFIG_HOSTCMD_ESPI is not set, using LPC interface to PCH */ -#ifndef CONFIG_HOSTCMD_ESPI -GPIO_INT(PCH_PLTRST_L, PIN(064), GPIO_BOTH_EDGES_PU, lpcrst_interrupt) -#endif - -/* MEC1701H GPIO_0015/PWM7 OK */ -GPIO_INT(LID_OPEN, PIN(015), GPIO_INT_BOTH | GPIO_PULL_UP, lid_interrupt) -/* MEC1701H GPIO_0014/PWM6/GPTP-IN6 OK */ -GPIO_INT(AC_PRESENT, PIN(014), GPIO_INT_BOTH, extpower_interrupt) - -/* MEC1701H GPIO_0036/RC_ID2 OK */ -/* Kabylake bringup move to gpio input */ -/* GPIO_INT(WP_L, PIN(036), GPIO_INT_BOTH, switch_interrupt) */ - -/* Buffered power button input from PMIC / ROP_EC_PWR_BTN_L_R */ -/* MEC1701H GPIO_0023/GPTP-IN1/MVP_VR_ON OK */ -GPIO_INT(POWER_BUTTON_L, PIN(023), GPIO_INT_BOTH, power_button_interrupt) - -/* RSMRST from PMIC */ -/* MEC1701H GPIO_0057/VCC_PWRGD OK */ -GPIO_INT(RSMRST_L_PGOOD, PIN(0126), GPIO_INT_BOTH, power_signal_interrupt) - -/* Remove. SLP_S3,S4 are eSPI virtual wires -GPIO_INT(PCH_SLP_S4_L, PIN(0200), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(PCH_SLP_S3_L, PIN(0206), GPIO_INT_BOTH, power_signal_interrupt) -*/ - -/* MEC1701H GPIO_0175/KSO17 OK */ -GPIO_INT(PCH_SLP_SUS_L, PIN(0175), GPIO_INT_BOTH, power_signal_interrupt) - -/* - * Handle ALL_SYS_PWRGD from SKL RVP3 board - */ -GPIO_INT(ALL_SYS_PWRGD, PIN(057), GPIO_INT_BOTH, all_sys_pwrgd_interrupt) - -/* Kabylake bring up move to ordinary GPIO input */ -/* MEC1701H GPIO_0034/RC_ID1/SPI0_CLK */ -/* - *GPIO_INT(VOLUME_UP_L, PIN(034), \ - *GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) - */ -/* MEC1701H GPIO_035/PWM8/CTOUT1 OK */ -/* - *GPIO_INT(VOLUME_DOWN_L, PIN(035), GPIO_INT_BOTH | GPIO_PULL_UP, \ - * button_interrupt) - */ - -/* MEC1701H GPIO_0161/VCI_IN2# OK */ -GPIO_INT(PMIC_INT_L, PIN(0161), GPIO_INT_FALLING, power_signal_interrupt) - - /* MEC1701H GPIO_0162/VCI_IN1# OK */ -/* GPIO_INT(PD_MCU_INT, PIN(0162), \ - GPIO_INT_FALLING | GPIO_PULL_UP, pd_mcu_interrupt) */ -/* MEC1701H GPIO_0242/ISPI_CLK OK */ -/* GPIO_INT(USB_C0_VBUS_WAKE_L,PIN(0242), GPIO_INT_BOTH, vbus0_evt) */ -/* MEC1701H GPIO_0243/ISPI_IO0 OK */ -/* GPIO_INT(USB_C1_VBUS_WAKE_L,PIN(0243), GPIO_INT_BOTH, vbus1_evt) */ -/* MEC1701H GPIO_0240/INT_IO3 OK */ -/* GPIO_INT(USB_C0_BC12_INT_L, PIN(0240), GPIO_INT_FALLING, usb0_evt) */ -/* MEC1701H GPIO_0241/ISPI_CS# OK */ -/* GPIO_INT(USB_C1_BC12_INT_L, PIN(0241), GPIO_INT_FALLING, usb1_evt) */ -/* MEC1701H GPIO_0100/nEC_SCI OK */ -GPIO_INT(TABLET_MODE_L, PIN(0100), GPIO_INT_BOTH | GPIO_PULL_UP, \ - tablet_mode_interrupt) -/* Delayed PWR_OK from PMIC */ -/* MEC1701H GPIO_0151/ICT4/KSO15 OK */ -GPIO_INT(PMIC_DPWROK, PIN(0151), GPIO_INT_BOTH, power_signal_interrupt) -/* UART input */ -/* MEC1701H GPIO_0105/UART0_RX OK */ -GPIO_INT(UART0_RX, PIN(0105), GPIO_INT_BOTH_DSLEEP | GPIO_PULL_UP, \ - uart_deepsleep_interrupt) - - -/* GPIO Pins not interrupt enabled */ - -/* Kabylake bring up move to ordinary GPIO input */ -GPIO(VOLUME_UP_L, PIN(034), GPIO_INPUT | GPIO_PULL_UP) -GPIO(VOLUME_DOWN_L, PIN(035), GPIO_INPUT | GPIO_PULL_UP) -GPIO(WP_L, PIN(036), GPIO_INPUT) -/* - * TODO GP-SPI0 for testing SPI accelerometer - * GPIO_0003 Func 2 = SPI0_CS#, func 1 = smbus00_sda - * GPIO_0034 Func 2 = SPI0_CLK - * GPIO_0004 Func 2 = SPI0_MOSI, func 1 = smbus00_scl - * GPIO_0036 Func 2 = SPI0_MISO - */ - - - -/* PCH and CPU pins */ - -/* Kabylake bringup using MECC board */ -/* - *GPIO(ALL_SYS_PWRGD, PIN(057), GPIO_INPUT) - */ - -/* - * This pulldown should be removed and SLP_S0 should be enabled as a power - * signal interrupt in future hardware followers. The signal is pulled up - * in the SoC when the primary rails are on and/or ramping. - * In order to not get interrupt storms there should be external logic - * which makes this a true binary signal into the EC. - */ -/* MEC1701H GPIO_0222 Func1 SER_IRQ OK */ -GPIO(PCH_SLP_S0_L, PIN(0222), GPIO_INPUT | GPIO_PULL_DOWN) -/* MEC170H GPIO_0043 Func1 SB-TSI_CLK OK */ -GPIO(PCH_PWRBTN_L, PIN(043), GPIO_OUTPUT) -/* - *CONFLICT with KSI3. SCI becomes eSPI Virtual Wire, remove - *GPIO(PCH_SCI_L, PIN(026), GPIO_ODR_HIGH) - */ -/* When asserted, ME does not lock security descriptor */ -/* MEC1701H GPIO_0022/GPTP-IN0 OK */ -GPIO(PCH_SEC_DISABLE_L, PIN(022), GPIO_OUT_HIGH) -/* MEC1701H GPIO_0016/GPTP-IN7/SHD_IO3 OK */ -GPIO(PCH_WAKE_L, PIN(016), GPIO_ODR_HIGH) -/* MEC1701H GPIO_0110/PS2_CLK2 OK */ -GPIO(PCH_ACOK, PIN(0110), GPIO_OUT_LOW) -/* MEC1701H GPIO_0012/SMB07_DATA OK */ -GPIO(PCH_RSMRST_L, PIN(012), GPIO_OUT_LOW) -/* - * !!! Don't use GPIO_0024 if testing on MEC51xx parts because - * it is connected in the package to nRESET_IN# and will reset - * the part when driven low. - * !!! - *GPIO(PCH_RTCRST, PIN(024), GPIO_OUT_LOW) - */ -GPIO(PCH_RTCRST, PIN(052), GPIO_OUT_LOW) - -/* - * MEC1322 Func1=nSMI, is code switching pin to Func1? - * Conflicts with KSO04 on MEC1701H - * eSPI replaces this signal with eSPI Virtual Wire. - * GPIO(PCH_SMI_L, PIN(044), GPIO_ODR_HIGH) - */ - -/* - * RCIN# line to PCH for 8042 emulation. Becomes VWire on eSPI - * GPIO(PCH_RCIN_L, PIN(0135), GPIO_ODR_HIGH) - */ - -/* MEC1701H GPIO_0111/PS2_DAT2 OK */ -GPIO(CPU_PROCHOT, PIN(0111), GPIO_OUT_LOW) - -/* MEC1701H GPIO_0025/TIN0/nEM_INT/UART_CLK OK - * Kabylake with MECC board change to GPIO_OUT_LOW - * GPIO(SYS_RESET_L, PIN(025), GPIO_ODR_HIGH) - */ -GPIO(SYS_RESET_L, PIN(025), GPIO_OUT_LOW) - -/* PMIC pins */ -/* GPIO_0033/RC_ID0 OK */ -GPIO(PMIC_SLP_SUS_L, PIN(033), GPIO_OUT_LOW) - -/* - * BATLOW_L and ROP_LDO_EN are stuffing options. Set as input to - * dynamically handle the stuffing option based on board id. - * As both signals have external pulls setting this pin as input - * won't harm anything. - */ -/* MEC1701H GPIO_0163/VCI_IN0# OK */ -GPIO(BATLOW_L_PMIC_LDO_EN, PIN(0163), GPIO_INPUT) - - -/* I2C pins - these will be reconfigured for alternate function below */ -/* MEC1701H */ -/* Using these pins as function 2 (GP-SPI0) - * GPIO(SMB00_SCL, PIN(004), GPIO_INPUT) - * GPIO(SMB00_SDA, PIN(003), GPIO_INPUT) - */ -GPIO(SMB02_SCL, PIN(0155), GPIO_INPUT) -GPIO(SMB02_SDA, PIN(0154), GPIO_INPUT) -GPIO(SMB03_SCL, PIN(010), GPIO_INPUT) -GPIO(SMB03_SDA, PIN(007), GPIO_INPUT) -GPIO(SMB04_SCL, PIN(0144), GPIO_INPUT) -GPIO(SMB04_SDA, PIN(0143), GPIO_INPUT) -GPIO(SMB05_SCL, PIN(0142), GPIO_INPUT) -GPIO(SMB05_SDA, PIN(0141), GPIO_INPUT) -GPIO(SMB10_SCL, PIN(0131), GPIO_INPUT) -GPIO(SMB10_SDA, PIN(0130), GPIO_INPUT) - -/* USB and USB-PD related pins */ -/* MEC1701H GPIO_0153/LED2 OK */ -GPIO(PD_RST_L, PIN(0153), GPIO_ODR_HIGH) -/* MEC1701H GPIO_0013/SMB07_CLK/TOUT2 OK */ -GPIO(USB2_OTG_ID, PIN(013), GPIO_ODR_LOW) -/* MEC1701H GPIO_0042/PECI_DAT/SB-TSI_DAT */ -GPIO(USB1_ENABLE, PIN(042), GPIO_OUT_LOW) -/* MEC1701H GPIO_0067/CLKRUN# OK */ -GPIO(USB2_ENABLE, PIN(067), GPIO_OUT_LOW) -/* MEC1701H GPIO_0101/BGP01 OK */ -GPIO(USB_C0_DP_HPD, PIN(0101), GPIO_OUT_LOW) -/* MEC1701H GPIO_0102/BGP02 OK */ -GPIO(USB_C1_DP_HPD, PIN(0102), GPIO_OUT_LOW) -/* MEC1701H GPIO_0202/ADC02 OK */ -GPIO(USB_PD_WAKE, PIN(0202), GPIO_OUT_HIGH) -/* MEC1701H GPIO_0140/SMB06_CLK OK */ -GPIO(USB2_OTG_VBUSSENSE, PIN(0140), GPIO_OUT_LOW) -/* MEC1701H GPIO_0205/ADC05 OK */ -GPIO(USB_C0_5V_EN, PIN(0205), GPIO_OUT_LOW) -/* MEC1701H GPIO_0205/ADC06 OK */ -GPIO(USB_C1_5V_EN, PIN(0206), GPIO_OUT_LOW) -/* MEC1701H GPIO_0165/32KHZ_IN/CTOUT0/TRACECLK OK */ -GPIO(USB_C0_CHARGE_EN_L, PIN(0165), GPIO_OUT_LOW) -/* MEC1701H GPIO_0152/GPTP-OUT/KSO16 OK */ -GPIO(USB_C1_CHARGE_EN_L, PIN(0152), GPIO_OUT_LOW) - -/* Fan PWM output and TACH input. PROCHOT input */ -/* MEC1701H GPIO_0050/FAN_TACH0 OK */ -GPIO(EC_FAN1_TTACH, PIN(050), GPIO_INPUT | GPIO_PULL_UP) -/* Fan PWM output - NC / testing only */ -/* MEC1701H GPIO_0053/PWM0 OK */ -GPIO(EC_FAN1_PWM, PIN(053), GPIO_OUT_LOW) -/* prochot input from devices */ -/* MEC1701H GPIO_0051/FAN_TACH1 OK */ -GPIO(PLATFORM_EC_PROCHOT, PIN(051), GPIO_INPUT | GPIO_PULL_UP) - - -/* Miscellaneous */ -/* KB BL PWM, only connected to TP */ -/* MEC1701H GPIO_0002/PWM5 OK */ -GPIO(PWM_KBLIGHT, PIN(02), GPIO_OUT_LOW) -/* MEC1701H GPIO_0041/SYS_SHDN# OK */ -GPIO(ENTERING_RW, PIN(041), GPIO_OUT_LOW) -/* MEC1701H GPIO_0115/PS2_DATA0A OK */ -GPIO(ENABLE_TOUCHPAD, PIN(0115), GPIO_OUT_LOW) -/* MEC1701H GPIO_0200/ADC00 OK */ -GPIO(BAT_PRESENT_L, PIN(0200), GPIO_INPUT) -/* MEC1701H GPIO_0164/VCI_OVRD_IN OK */ -GPIO(WLAN_OFF_L, PIN(0164), GPIO_OUT_LOW) - -/* From lid sensor */ -/* MEC1701H GPIO_0000/VCI_IN3# OK */ -GPIO(ENABLE_BACKLIGHT, PIN(00), GPIO_OUT_LOW) - -/* Interrupts from accelerometer / gyro -- not yet implemented */ -/* - * GPIO(ACCEL1_INT, PIN(0161), GPIO_INPUT) - * GPIO(ACCEL2_INT, PIN(0127), GPIO_INPUT) - * MEC1701H must move. GPIO_0147 is JTAG_CLK - * GPIO(ACCEL3_INT, PIN(0147), GPIO_INPUT) - * GPIO(ACCEL4_INT, PIN(0126), GPIO_INPUT) - */ - -/* MEC1701H GPIO_0011/nSMI OK */ -/* Move to board ver GPIO(PP1800_DX_SENSOR_EN, PIN(011), GPIO_OUT_LOW) */ - /* MEC1701H GPIO_0207/ADC07 OK */ -/* Move to board ver GPIO(PP3300_WLAN_EN, PIN(0207), GPIO_OUT_LOW)*/ -/* MEC1701H GPIO_0114/PS2_CLK0A/nEC_SCI OK */ -/* Move to board version - * GPIO(PP1800_DX_AUDIO_EN, PIN(0114), GPIO_OUT_LOW) - */ - - -/* Board Version */ -/* - * MEC1701H - * GPIO_0130/SMB10_DATA - * GPIO_0131/SMB10_CLK - * GPIO_0132/SMB06_DATA - */ -/* - * GPIO(BOARD_VERSION1, PIN(0130), GPIO_INPUT) - * GPIO(BOARD_VERSION2, PIN(0131), GPIO_INPUT) - * GPIO(BOARD_VERSION3, PIN(0132), GPIO_INPUT) - */ -GPIO(BOARD_VERSION1, PIN(0114), GPIO_INPUT) -GPIO(BOARD_VERSION2, PIN(0207), GPIO_INPUT) -GPIO(BOARD_VERSION3, PIN(0011), GPIO_INPUT) - -/* - * MEC1701H GP-SPI0 chip select is GPIO_0003 - * It is used as GPIO output. GPSPI chip level - * code drives chip select. - */ -GPIO(SPI0_CS0, PIN(03), GPIO_ODR_HIGH) - - -/* - * TODO(crosbug.com/p/40848): These LEDs should be under control of the - * mec1701 LED control unit. Remove these GPIO definitions once the LED - * control unit is functional. - */ -/* MEC1701H GPIO_0156/LED0 OK */ -GPIO(CHARGE_LED_1, PIN(0156), GPIO_OUT_LOW) -/* MEC1701H GPIO_0157/LED1 OK */ -GPIO(CHARGE_LED_2, PIN(0157), GPIO_OUT_LOW) - -/* - * MCHP TFDP - */ -GPIO(TFDP_CLOCK, PIN(0170), GPIO_INPUT) -GPIO(TFDP_DATA, PIN(0171), GPIO_INPUT) - -/* Alternate functions GPIO definitions */ - -/* KB pins */ -#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP) -#define GPIO_KB_OUTPUT (GPIO_ODR_HIGH) - -/* KB pins */ -/* - * MEC1704H (144 pin package) - * KSO00 = GPIO_0040 Func3 bank 1 bit 0 - * KSO01 = GPIO_0045 Func3 bank 1 bit 5 - * KSO02 = GPIO_0046 Func3 bank 1 bit 6 - * KSO03 = GPIO_0047 Func3 bank 1 bit 7 - * KSO04 = GPIO_0107 Func3 bank 2 bit 7 - * KSO05 = GPIO_0112 Func3 bank 2 bit 10 - * KSO06 = GPIO_0113 Func3 bank 2 bit 11 - * KSO07 = GPIO_0120 Func3 bank 2 bit 16 - * KSO08 = GPIO_0121 Func3 bank 2 bit 17 - * KSO09 = GPIO_0122 Func3 bank 2 bit 18 - * KSO10 = GPIO_0123 Func3 bank 2 bit 19 - * KSO11 = GPIO_0124 Func3 bank 2 bit 20 - * KSO12 = GPIO_0125 Func3 bank 2 bit 21 - * For 8x16 test keyboard add KSO13 - KSO15 - * KSO13 = GPIO_0126 Func3 bank 2 bit 22 - * KSO14 = GPIO_0132 Func3 bank 2 bit 26 - * KSO15 = GPIO_0151 Func3 bank 3 bit 9 - * - * KSI0 = GPIO_0017 Func3 bank 0 bit 15 - * KSI1 = GPIO_0020 Func3 bank 0 bit 16 - * KSI2 = GPIO_0021 Func3 bank 0 bit 17 - * KSI3 = GPIO_0026 Func3 bank 0 bit 22 - * KSI4 = GPIO_0027 Func3 bank 0 bit 23 - * KSI5 = GPIO_0030 Func3 bank 0 bit 24 - * KSI6 = GPIO_0031 Func3 bank 0 bit 25 - * KSI7 = GPIO_0032 Func3 bank 0 bit 26 - */ -/* KSI 0-7, Bank 0, Func3, bits 15-17, 22-26 */ -ALTERNATE(PIN_MASK(0, 0x07C38000), 3, MODULE_KEYBOARD_SCAN, GPIO_KB_INPUT) - -/* KSO 0-3 Bank 1, Func3, bits 0, 5-7 */ -ALTERNATE(PIN_MASK(1, 0xE1), 3, MODULE_KEYBOARD_SCAN, GPIO_KB_OUTPUT) -/* KSO 4-12, Bank 2, Func3, bits 7, 10-11, 16-21 */ -ALTERNATE(PIN_MASK(2, 0x003F0C80), 3, MODULE_KEYBOARD_SCAN, GPIO_KB_OUTPUT) - -/* Add KSO13-15 for 8x16 test matrix */ -/* KSO 13-14, Bank 2, Func3, bits 22, 26 */ -/*ALTERNATE(PIN_MASK(2, 0x04400000), 3, MODULE_KEYBOARD_SCAN, \ - * GPIO_KB_OUTPUT) - */ -/* KSO 15, Bank 3, Func3, bit 9 */ -/*ALTERNATE(PIN_MASK(3, 0x00000200), 3, MODULE_KEYBOARD_SCAN, \ - * GPIO_KB_OUTPUT) - */ - -/* eSPI pins */ -/* ESPI_RESET# - GPIO_0061 Function 2, Bank 1 bit[17] */ -ALTERNATE(PIN_MASK(1, 0x20000), 2, MODULE_LPC, 0) -/* ESPI_ALERT# - GPIO_0063 Function 2, Bank 1 bit[19] */ -ALTERNATE(PIN_MASK(1, 0x80000), 2, MODULE_LPC, 0) -/* ESPI_CS# - GPIO_0066 Function 2, Bank 1 bit[22] */ -ALTERNATE(PIN_MASK(1, 0x400000), 2, MODULE_LPC, 0) -/* ESPI_CLK - GPIO_0065 Function 2, Bank 1 bit[21] */ -ALTERNATE(PIN_MASK(1, 0x200000), 2, MODULE_LPC, 0) -/* ESPI_IO{0,1,2,3} - GPIO_0070-GPIO_0073 Function 2, Bank 1 bits[24:27] */ -ALTERNATE(PIN_MASK(1, 0xf000000), 2, MODULE_LPC, 0) - -/* LPC LRESET# GPIO_0064/LRESET# - * Function 1, Bank 1 bit[20] */ -ALTERNATE(PIN_MASK(1, 0x100000), 1, MODULE_LPC, GPIO_PULL_UP) - -/* - * MEC1701H GP-SPI0 Master - * SPI0_CS# = GPIO_0003 Func 0(GPIO) Bank 0, bit 3 - * SPI0_CLK = GPIO_0034 Func 2 Bank 0, bit 28 - * SPI0_MISO = GPIO_0036 Func 2 Bank 0, bit 30 - * SPI0_MOSI = GPIO_0004 Func 2 Bank 0, bit 4 - */ -ALTERNATE(PIN_MASK(0, 0x00000008), 0, MODULE_SPI_CONTROLLER, GPIO_ODR_HIGH) -ALTERNATE(PIN_MASK(0, 0x50000010), 2, MODULE_SPI_CONTROLLER, 0) - -/* I2C pins */ -/* Using SMB00 as function 2 GP-SPI0 - * SMB00_DAT - GPIO_0003 Func1, SMB00_CLK - GPIO_0004 Func1 - * SMB03_DAT - GPIO_0007 Func1, SMB03_CLK - GPIO_0010 Func1 - * Bank 0 bits[3:4,7:8] -*/ -/* ALTERNATE(PIN_MASK(0, 0x0198), 1, MODULE_I2C, GPIO_ODR_HIGH) */ -ALTERNATE(PIN_MASK(0, 0x0180), 1, MODULE_I2C, GPIO_ODR_HIGH) - -/* - * SMB05_DAT - GPIO_0141 Func1, SMB05_CLK - GPIO_0142 Func1 - * SMB04_DAT - GPIO_0143 Func1, SMB04_CLK - GPIO_0144 Func1 - * SMB02_DAT - GPIO_0154 Func1, SMB02_CLK - GPIO_0155 Func1 - * Bank 3 bits[1:4,12:13] -*/ -ALTERNATE(PIN_MASK(3, 0x301e), 1, MODULE_I2C, GPIO_ODR_HIGH) - -/* ADC pins */ -/* ADC01 - GPIO_0201 / PPVAR_BOOSTIN_SENSE. Func1 Bank 4 bit[1] - * ADC03 - GPIO_0203 / IADP_ACMON_BMON. Func1 Bank 4 bit[3] - * ADC04 - GPIO_0204 / PMON_PSYS. Func1 Bank 4 bit[4] - * ADC07 - GPIO_0207 / Thermistor call it ADC_CASE - */ -ALTERNATE(PIN_MASK(4, 0x009a), 1, MODULE_ADC, GPIO_ANALOG) - -/* LED0 - GPIO_0156 Func1 Bank 3 bit[14] - * LED1 - GPIO_0157 Func1 Bank 3 bit[15] - */ -ALTERNATE(PIN_MASK(3, 0xc000), 1, MODULE_POWER_LED, 0) - -/* - * nRESET_OUT functionality is PWROK signal from MEC1701H - * nRESET_OUT - GPIO121 Bank 2 bit[17] - * MEC1701H nRESET_OUT is GPIO_0106/PWROK func1 - * Bank 2 bit[6] - */ -/* - * Not using nRESET_OUT on Kabylake RVP3 plus MEC170x EVB - * ALTERNATE(PIN_MASK(2, 0x40), 1, MODULE_PMU, 0) - */ - -/* - * MCHP TFDP alternate function configuration - * GPIO 0170 = clock, 0171 = data both function 1 - * Port = 3 bits[24:25] - */ -ALTERNATE(PIN_MASK(3, 0x03000000), 1, MODULE_TFDP, 0) diff --git a/board/mchpevb1/led.c b/board/mchpevb1/led.c deleted file mode 100644 index 7b9f7646cb..0000000000 --- a/board/mchpevb1/led.c +++ /dev/null @@ -1,174 +0,0 @@ -/* Copyright 2017 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. - * - * Power and battery LED control for MEC1701 EVB. - */ - -#include "battery.h" -#include "charge_state.h" -#include "chipset.h" -#include "ec_commands.h" -#include "gpio.h" -#include "hooks.h" -#include "host_command.h" -#include "led_common.h" -#include "util.h" - -#define BAT_LED_ON 1 -#define BAT_LED_OFF 0 - -#define CRITICAL_LOW_BATTERY_PERCENTAGE 3 -#define LOW_BATTERY_PERCENTAGE 10 - -#define LED_TOTAL_4SECS_TICKS 4 -#define LED_TOTAL_2SECS_TICKS 2 -#define LED_ON_1SEC_TICKS 1 -#define LED_ON_2SECS_TICKS 2 - -/* - * NOTE: GPIO_BAT_LED_xxx defined in board.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 { - LED_OFF = 0, - LED_RED, - LED_AMBER, - LED_GREEN, - LED_COLOR_COUNT /* Number of colors, not a color itself */ -}; - -static int bat_led_set_color(enum led_color color) -{ - switch (color) { - case LED_OFF: - gpio_set_level(GPIO_BAT_LED_RED, BAT_LED_OFF); - gpio_set_level(GPIO_BAT_LED_GREEN, BAT_LED_OFF); - break; - case LED_RED: - gpio_set_level(GPIO_BAT_LED_RED, BAT_LED_ON); - gpio_set_level(GPIO_BAT_LED_GREEN, BAT_LED_OFF); - break; - case LED_AMBER: - gpio_set_level(GPIO_BAT_LED_RED, BAT_LED_ON); - gpio_set_level(GPIO_BAT_LED_GREEN, BAT_LED_ON); - break; - case LED_GREEN: - gpio_set_level(GPIO_BAT_LED_RED, BAT_LED_OFF); - gpio_set_level(GPIO_BAT_LED_GREEN, BAT_LED_ON); - break; - default: - return EC_ERROR_UNKNOWN; - } - return EC_SUCCESS; -} - -void led_get_brightness_range(enum ec_led_id led_id, - uint8_t *brightness_range) -{ - brightness_range[EC_LED_COLOR_RED] = 1; - brightness_range[EC_LED_COLOR_GREEN] = 1; -} - -static int board_led_set_color_battery(enum led_color color) -{ - return bat_led_set_color(color); -} - -static int board_led_set_color(enum ec_led_id led_id, enum led_color color) -{ - int rv; - - led_auto_control(led_id, 0); - switch (led_id) { - case EC_LED_ID_BATTERY_LED: - rv = board_led_set_color_battery(color); - break; - default: - return EC_ERROR_UNKNOWN; - } - return rv; -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - if (brightness[EC_LED_COLOR_RED] != 0 && - brightness[EC_LED_COLOR_GREEN] != 0) - board_led_set_color(led_id, LED_AMBER); - else if (brightness[EC_LED_COLOR_RED] != 0) - board_led_set_color(led_id, LED_RED); - else if (brightness[EC_LED_COLOR_GREEN] != 0) - board_led_set_color(led_id, LED_GREEN); - else - board_led_set_color(led_id, LED_OFF); - - return EC_SUCCESS; -} - -static void board_led_set_battery(void) -{ -#ifdef CONFIG_CHARGER - static int battery_ticks; - uint32_t chflags = charge_get_flags(); - - battery_ticks++; - - /* BAT LED behavior: - * Same as the chromeos spec - * Green/Amber for CHARGE_FLAG_FORCE_IDLE - */ - switch (charge_get_state()) { - case PWR_STATE_CHARGE: - board_led_set_color_battery(LED_AMBER); - break; - case PWR_STATE_DISCHARGE: - /* Less than 3%, blink one second every two second */ - if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) && - charge_get_percent() < CRITICAL_LOW_BATTERY_PERCENTAGE) - board_led_set_color_battery( - (battery_ticks % LED_TOTAL_2SECS_TICKS < - LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); - /* Less than 10%, blink one second every four seconds */ - else if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) && - charge_get_percent() < LOW_BATTERY_PERCENTAGE) - board_led_set_color_battery( - (battery_ticks % LED_TOTAL_4SECS_TICKS < - LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); - else - board_led_set_color_battery(LED_OFF); - break; - case PWR_STATE_ERROR: - board_led_set_color_battery( - (battery_ticks % LED_TOTAL_2SECS_TICKS < - LED_ON_1SEC_TICKS) ? LED_RED : LED_OFF); - break; - case PWR_STATE_CHARGE_NEAR_FULL: - board_led_set_color_battery(LED_GREEN); - break; - case PWR_STATE_IDLE: /* External power connected in IDLE */ - if (chflags & CHARGE_FLAG_FORCE_IDLE) - board_led_set_color_battery( - (battery_ticks % LED_TOTAL_4SECS_TICKS < - LED_ON_2SECS_TICKS) ? LED_GREEN : LED_AMBER); - else - board_led_set_color_battery(LED_GREEN); - break; - default: - /* Other states don't alter LED behavior */ - break; - } -#endif -} - - -static void led_second(void) -{ - if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) - board_led_set_battery(); -} -DECLARE_HOOK(HOOK_SECOND, led_second, HOOK_PRIO_DEFAULT); diff --git a/board/mchpevb1/lfw/vif_override.xml b/board/mchpevb1/lfw/vif_override.xml deleted file mode 100644 index 32736caf64..0000000000 --- a/board/mchpevb1/lfw/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. ---> diff --git a/board/mchpevb1/usb_pd_policy.c b/board/mchpevb1/usb_pd_policy.c deleted file mode 100644 index 690f8b8a3c..0000000000 --- a/board/mchpevb1/usb_pd_policy.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2017 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_EN_L : - GPIO_USB_C0_CHARGE_EN_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); -} - -int pd_snk_is_vbus_provided(int port) -{ - return !gpio_get_level(port ? GPIO_USB_C1_VBUS_WAKE_L : - GPIO_USB_C0_VBUS_WAKE_L); -} - -int pd_check_vconn_swap(int port) -{ - /* in G3, do not allow vconn swap since pp5000_A rail is off */ - return gpio_get_level(GPIO_PMIC_SLP_SUS_L); -} |