diff options
author | David Hendricks <dhendrix@chromium.org> | 2016-04-08 13:55:58 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-05-20 17:08:34 -0700 |
commit | b14f89cfdbf403af08f27472ac2d3ba355c85490 (patch) | |
tree | db48c77ddd285907224a7946b934da3a43845bbd /board/reef | |
parent | 5219d2f86b151ca942673e88ad58d2bbacae1c46 (diff) | |
download | chrome-ec-b14f89cfdbf403af08f27472ac2d3ba355c85490.tar.gz |
reef: Initial commit
This adds the basic framework for Reef including full GPIO listing,
board config file, and rudimentary functionality. It has not been
fully tested and still has several TODOs/FIXMEs. For now we just need
something that will build and can be incrementally improved.
BUG=chrome-os-partner:53035
BRANCH=none
TEST=EC and AP both boot, seems reasonably stable for now
Change-Id: I4934ad00917e251dd1d7eb759207a92c45a36136
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/339292
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'board/reef')
l--------- | board/reef/Makefile | 1 | ||||
-rw-r--r-- | board/reef/battery.c | 232 | ||||
-rw-r--r-- | board/reef/board.c | 745 | ||||
-rw-r--r-- | board/reef/board.h | 217 | ||||
-rw-r--r-- | board/reef/build.mk | 14 | ||||
-rw-r--r-- | board/reef/ec.tasklist | 37 | ||||
-rw-r--r-- | board/reef/gpio.inc | 152 | ||||
-rw-r--r-- | board/reef/usb_pd_policy.c | 348 |
8 files changed, 1746 insertions, 0 deletions
diff --git a/board/reef/Makefile b/board/reef/Makefile new file mode 120000 index 0000000000..94aaae2c4d --- /dev/null +++ b/board/reef/Makefile @@ -0,0 +1 @@ +../../Makefile
\ No newline at end of file diff --git a/board/reef/battery.c b/board/reef/battery.c new file mode 100644 index 0000000000..2b86f7f012 --- /dev/null +++ b/board/reef/battery.c @@ -0,0 +1,232 @@ +/* Copyright 2016 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 = { + /* FIXME(dhendrix): where do these values come from? */ + .voltage_max = 8700, /* mV */ + .voltage_normal = 7600, + .voltage_min = 6100, + .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(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0, + I2C_XFER_SINGLE); + rv |= i2c_xfer(I2C_PORT_BATTERY, BATTERY_ADDR, 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", + NULL); + +#endif /* CONFIG_CHARGER_PROFILE_OVERRIDE */ diff --git a/board/reef/board.c b/board/reef/board.c new file mode 100644 index 0000000000..3a6ca25559 --- /dev/null +++ b/board/reef/board.c @@ -0,0 +1,745 @@ +/* Copyright 2016 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. + */ + +/* Reef board-specific configuration */ + +#include "adc.h" +#include "adc_chip.h" +#include "als.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_bmi160.h" +#include "driver/charger/bd99955.h" +#include "driver/tcpm/anx74xx.h" +#include "driver/tcpm/tcpci.h" +#include "extpower.h" +#include "gpio.h" +#include "hooks.h" +#include "host_command.h" +#include "i2c.h" +#include "keyboard_scan.h" +#include "lid_switch.h" +#include "math_util.h" +#include "motion_sense.h" +#include "motion_lid.h" +#include "power.h" +#include "power_button.h" +#include "pwm.h" +#include "pwm_chip.h" +#include "spi.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" + +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) + +#define IN_ALL_SYS_PG POWER_SIGNAL_MASK(X86_ALL_SYS_PG) +#define IN_PGOOD_PP3300 POWER_SIGNAL_MASK(X86_PGOOD_PP3300) +#define IN_PGOOD_PP5000 POWER_SIGNAL_MASK(X86_PGOOD_PP5000) + +static void tcpc_alert_event(enum gpio_signal signal) +{ + if (!gpio_get_level(GPIO_USB_PD_RST_ODL)) + return; + +#ifdef HAS_TASK_PDCMD + /* Exchange status with TCPCs */ + host_command_pd_send_status(PD_CHARGE_NO_CHANGE); +#endif +} + + +/* Exchange status with PD MCU. */ +static void pd_mcu_interrupt(enum gpio_signal signal) +{ +#ifdef HAS_TASK_PDCMD + /* Exchange status with PD MCU to determine interrupt cause */ + host_command_pd_send_status(0); +#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. + * Use DECLARE_DEFERRED to generate enable_input_devices_data. + */ +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" + +/* power signal list. Must match order of enum power_signal. */ +const struct power_signal_info power_signal_list[] = { + {GPIO_RSMRST_L_PGOOD, 1, "RSMRST_L"}, + {GPIO_PCH_SLP_S0_L, 1, "PMU_SLP_S0_N"}, + {GPIO_PCH_SLP_S3_L, 1, "SLP_S3_DEASSERTED"}, + {GPIO_PCH_SLP_S4_L, 1, "SLP_S4_DEASSERTED"}, + {GPIO_SUSPWRNACK, 1, "SUSPWRNACK_DEASSERTED"}, + + {GPIO_ALL_SYS_PGOOD, 1, "ALL_SYS_PGOOD"}, + {GPIO_PP3300_PG, 1, "PP3300_PG"}, + {GPIO_PP5000_PG, 1, "PP5000_PG"}, +}; +BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); + +/* ADC channels */ +const struct adc_t adc_channels[] = { + [ADC_BOARD_ID] = {"BOARD_ID", NPCX_ADC_CH2, 1, 1, 0}, +}; +BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); + +/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */ +const struct pwm_t pwm_channels[] = { + [PWM_CH_LED_GREEN] = { 2, PWM_CONFIG_DSLEEP, 100 }, + [PWM_CH_LED_RED] = { 3, PWM_CONFIG_DSLEEP, 100 }, +}; +BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); + +const struct i2c_port_t i2c_ports[] = { + {"tcpc0", NPCX_I2C_PORT0_0, 400, + GPIO_EC_I2C_USB_C0_PD_SCL, GPIO_EC_I2C_USB_C0_PD_SDA}, + {"tcpc1", NPCX_I2C_PORT0_1, 400, + GPIO_EC_I2C_USB_C1_PD_SCL, GPIO_EC_I2C_USB_C1_PD_SDA}, + {"gyro", I2C_PORT_GYRO, 400, + GPIO_EC_I2C_GYRO_SCL, GPIO_EC_I2C_GYRO_SDA}, + {"sensors", NPCX_I2C_PORT2, 400, + GPIO_EC_I2C_SENSOR_SCL, GPIO_EC_I2C_SENSOR_SDA}, + {"batt", NPCX_I2C_PORT3, 100, + GPIO_EC_I2C_POWER_SCL, GPIO_EC_I2C_POWER_SDA}, +}; +const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); + +const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { + {NPCX_I2C_PORT0_0, 0x50, &anx74xx_tcpm_drv}, + {NPCX_I2C_PORT0_1, 0x16, &tcpci_tcpm_drv}, +}; + +uint16_t tcpc_get_alert_status(void) +{ + uint16_t status = 0; + + if (gpio_get_level(GPIO_USB_C0_PD_INT)) + status |= PD_STATUS_TCPC_ALERT_0; + if (!gpio_get_level(GPIO_USB_C1_PD_INT_ODL)) + status |= PD_STATUS_TCPC_ALERT_1; + + return status; +} + +const enum gpio_signal hibernate_wake_pins[] = { + GPIO_LID_OPEN, + GPIO_POWER_BUTTON_L, +}; + +const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); + +struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { + { + .port_addr = 0, /* don't care / unused */ + .driver = &anx74xx_tcpm_usb_mux_driver, + }, + { + .port_addr = 1, + .driver = &tcpci_tcpm_usb_mux_driver, + } +}; + +/* called from anx74xx_set_power_mode() */ +void board_set_tcpc_power_mode(int port, int mode) +{ + gpio_set_level(GPIO_EN_USB_TCPC_PWR, mode); + msleep(1); + + /* FIXME(dhendrix): This is also connected to the PS8751 which + * we might not want to reset just because something happened + * on the ANX3429. */ + gpio_set_level(GPIO_USB_PD_RST_ODL, mode); + msleep(10); +} + +/** + * Reset PD MCU + */ +void board_reset_pd_mcu(void) +{ + gpio_set_level(GPIO_USB_PD_RST_ODL, 0); + msleep(1); + gpio_set_level(GPIO_EN_USB_TCPC_PWR, 0); + msleep(10); + + gpio_set_level(GPIO_EN_USB_TCPC_PWR, 1); + msleep(1); + gpio_set_level(GPIO_USB_PD_RST_ODL, 1); + /* + * ANX7688 needed 50ms to release RESET_N, but the ANX7428 datasheet + * does not indicate such a long delay is necessary. Leave it in due + * to paranoia. + */ + msleep(50); +} + +int board_get_battery_temp(int idx, int *temp_ptr) +{ + /* FIXME(dhendrix): Read THERM_VAL from BD99956 and convert + Celsius to Kelvin */ + *temp_ptr = 0; + return 0; + +} + +int board_get_charger_temp(int idx, int *temp_ptr) +{ + int raw_val = adc_read_channel(NPCX_ADC_CH0); + + if (raw_val < 0) + return -1; + + /* FIXME(dhendrix): Add data points and calculate using CL:344781 */ + *temp_ptr = 0; + return 0; +} + +int board_get_ambient_temp(int idx, int *temp_ptr) +{ + int raw_val = adc_read_channel(NPCX_ADC_CH1); + + if (raw_val < 0) + return -1; + + /* FIXME(dhendrix): Add data points and calculate using CL:344781 */ + *temp_ptr = 0; + return 0; +} + + +const struct temp_sensor_t temp_sensors[] = { + /* FIXME(dhendrix): tweak action_delay_sec */ + {"Battery", TEMP_SENSOR_TYPE_BATTERY, board_get_battery_temp, 0, 1}, + {"Ambient", TEMP_SENSOR_TYPE_BOARD, board_get_ambient_temp, 0, 5}, + {"Charger", TEMP_SENSOR_TYPE_BOARD, board_get_charger_temp, 0, 1}, +}; +BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); + +/* + * Thermal limits for each temp sensor. All temps are in degrees K. Must be in + * same order as enum temp_sensor_id. To always ignore any temp, use 0. + */ +struct ec_thermal_config thermal_params[] = { + /* {Twarn, Thigh, Thalt}, fan_off, fan_max */ + /* FIXME(dhendrix): Implement this... */ + {{0, 0, 0}, 0, 0}, /* Battery */ + {{0, 0, 0}, 0, 0}, /* Ambient */ + {{0, 0, 0}, 0, 0}, /* Charger */ +}; +BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); + +/* ALS instances. Must be in same order as enum als_id. */ +struct als_t als[] = { + /* FIXME(dhendrix): verify attenuation_factor */ + {"TI", opt3001_init, opt3001_read_lux, 5}, +}; +BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT); + +const struct button_config buttons[CONFIG_BUTTON_COUNT] = { + {"Volume Down", KEYBOARD_BUTTON_VOLUME_DOWN, GPIO_EC_VOLDN_BTN_L, + 30 * MSEC, 0}, + {"Volume Up", KEYBOARD_BUTTON_VOLUME_UP, GPIO_EC_VOLUP_BTN_L, + 30 * MSEC, 0}, +}; + +/* Called by APL power state machine when transitioning from G3 to S5 */ +static void chipset_pre_init(void) +{ +#if 0 + /* No need to re-init PMIC since settings are sticky across sysjump */ + /* TODO(dhendrix): Handle sysjump case appropriately */ + if (system_jumped_to_this_image()) + return; +#endif + + /* Enable PP5000 before PP3300 due to NFC: chrome-os-partner:50807 */ + gpio_set_level(GPIO_EN_PP5000, 1); + udelay(6); /* Double the PG low to high delay for power supply. */ + + /* Enable 3.3V rail */ + gpio_set_level(GPIO_EN_PP3300, 1); + udelay(1500); /* Double the PG low to high delay for converter. */ + + /* Make sure TCPCs are on and taken out of reset */ + board_reset_pd_mcu(); + + /* FIXME: for debugging */ + cprintf(CC_HOOK, "PP3300_PG: %d", gpio_get_level(GPIO_PP3300_PG)); + cprintf(CC_HOOK, "PP5000_PG: %d", gpio_get_level(GPIO_PP5000_PG)); + + /* (Re-)Enable I2C */ + gpio_config_module(MODULE_I2C, 1); +#if 0 + /* Enable PD interrupts */ + gpio_enable_interrupt(GPIO_USB_C0_PD_INT); + gpio_enable_interrupt(GPIO_USB_C1_PD_INT_ODL); + + /* Enable charger interrupts */ + gpio_enable_interrupt(GPIO_PD_MCU_INT); +#endif +} +DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, chipset_pre_init, HOOK_PRIO_DEFAULT); + +/* Initialize board. */ +static void board_init(void) +{ + /* FIXME: Handle tablet mode */ + /* gpio_enable_interrupt(GPIO_TABLET_MODE_L); */ +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); + +/** + * 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) +{ + enum bd99955_charge_port bd99955_port; + + /* charge port is a physical port */ + int is_real_port = (charge_port >= 0 && + charge_port < CONFIG_USB_PD_PORT_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; + } + + CPRINTS("New chg p%d", charge_port); + + switch (charge_port) { + case 0: + bd99955_port = BD99955_CHARGE_PORT_VBUS; + break; + case 1: + bd99955_port = BD99955_CHARGE_PORT_VCC; + break; + case CHARGE_PORT_NONE: + bd99955_port = BD99955_CHARGE_PORT_NONE; + break; + default: + panic("Invalid charge port\n"); + break; + } + + return bd99955_select_input_port(bd99955_port); +} + +/** + * Set the charge limit based upon desired maximum. + * + * @param charge_ma Desired charge limit (mA). + */ +void board_set_charge_limit(int charge_ma) +{ + charge_set_input_current_limit(MAX(charge_ma, + CONFIG_CHARGER_INPUT_CURRENT)); +} + +int extpower_is_present(void) +{ + return bd99955_extpower_is_present(); +} + +int usb_charger_port_is_sourcing_vbus(int port) +{ + return gpio_get_level(port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN); +} + +/* Enable or disable input devices, based upon chipset state and tablet mode */ +static void enable_input_devices(void) +{ + int kb_enable = 1; + + /* Disable KB if chipset is off */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + kb_enable = 0; + + keyboard_scan_enable(kb_enable, KB_SCAN_DISABLE_LID_ANGLE); +} + +/* Called on AP S5 -> S3 transition */ +static void board_chipset_startup(void) +{ + static int need_to_enable_sleep_interrupt = 1; + + /* + * SLP_Sn signals may be glitchy before V5A and PMIC are both on + * so wait until we're exiting S5 to enable SLP_Sn interrupts. + * See chrome-os-partner:51323 for details. + */ + if (need_to_enable_sleep_interrupt) { + gpio_enable_interrupt(GPIO_PCH_SLP_S4_L); + gpio_enable_interrupt(GPIO_PCH_SLP_S3_L); + gpio_enable_interrupt(GPIO_PCH_SLP_S0_L); + need_to_enable_sleep_interrupt = 0; + } + + /* Enable USB-A port. */ + gpio_set_level(GPIO_EN_USB_A_5V, 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) +{ + /* Disable USB-A port. */ + gpio_set_level(GPIO_EN_USB_A_5V, 1); + + hook_call_deferred(&enable_input_devices_data, 0); + /* FIXME(dhendrix): Drive USB_PD_RST_ODL low to prevent + leakage? (see comment in schematic) */ +} +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); + +/* FIXME(dhendrix): Add CHIPSET_RESUME and CHIPSET_SUSPEND + hooks to enable/disable sensors? */ + +/* + * FIXME(dhendrix): Weak symbol hack until we can get a better solution for + * both Amenia and Reef. + */ +void chipset_do_shutdown(void) +{ + cprintf(CC_CHIPSET, "Doing custom shutdown for Reef\n"); + + /* Disable I2C module */ + gpio_config_module(MODULE_I2C, 0); + + gpio_set_level(GPIO_EN_USB_TCPC_PWR, 0); + /* Disable V5A which de-assert PMIC_EN and causes PMIC to shutdown. */ + gpio_set_level(GPIO_V5A_EN, 0); + gpio_set_level(GPIO_EN_PP3300, 0); + gpio_set_level(GPIO_EN_PP5000, 0); +} + +void board_set_gpio_hibernate_state(void) +{ + int i; + const uint32_t hibernate_pins[][2] = { +#if 0 + /* Turn off LEDs in hibernate */ + {GPIO_BAT_LED_BLUE, GPIO_INPUT | GPIO_PULL_UP}, + {GPIO_BAT_LED_AMBER, GPIO_INPUT | GPIO_PULL_UP}, + /* + * Set PD wake low so that it toggles high to generate a wake + * event once we leave hibernate. + */ + {GPIO_USB_PD_WAKE, GPIO_OUTPUT | GPIO_LOW}, +#endif + /* + * In hibernate, this pin connected to GND. Set it to output + * low to eliminate the current caused by internal pull-up. + */ + /* FIXME(dhendrix): What do to with PROCHOT? */ + /* {GPIO_PLATFORM_EC_PROCHOT, GPIO_OUTPUT | GPIO_LOW}, */ + + /* + * BD99956 handles charge input automatically. We'll disable + * charge output in hibernate. Charger will assert ACOK_OD + * when VBUS or VCC are plugged in. + */ + {GPIO_USB_C0_5V_EN, GPIO_INPUT | GPIO_PULL_DOWN}, + {GPIO_USB_C1_5V_EN, GPIO_INPUT | GPIO_PULL_DOWN}, + }; + + /* Change GPIOs' state in hibernate for better power consumption */ + for (i = 0; i < ARRAY_SIZE(hibernate_pins); ++i) + gpio_set_flags(hibernate_pins[i][0], hibernate_pins[i][1]); + + gpio_config_module(MODULE_KEYBOARD_SCAN, 0); + + /* + * Calling gpio_config_module sets disabled alternate function pins to + * GPIO_INPUT. But to prevent keypresses causing leakage currents + * while hibernating we want to enable GPIO_PULL_UP as well. + */ + gpio_set_flags_by_mask(0x2, 0x03, GPIO_INPUT | GPIO_PULL_UP); + gpio_set_flags_by_mask(0x1, 0xFF, GPIO_INPUT | GPIO_PULL_UP); + gpio_set_flags_by_mask(0x0, 0xE0, GPIO_INPUT | GPIO_PULL_UP); +} + +/* Motion sensors */ +/* Mutexes */ +static struct mutex g_lid_mutex; +static struct mutex g_base_mutex; + +/* Matrix to rotate accelrator into standard reference frame */ +const matrix_3x3_t base_standard_ref = { + { 0, FLOAT_TO_FP(1), 0}, + { FLOAT_TO_FP(-1), 0, 0}, + { 0, 0, FLOAT_TO_FP(1)} +}; + +/* KX022 private data */ +struct kionix_accel_data g_kx022_data = { + .variant = KX022, +}; + +/* FIXME(dhendrix): Copied from Amenia, probably need to tweak for Reef */ +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. + */ + [LID_ACCEL] = { + .name = "Lid Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_LID, + .drv = &bmi160_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_ACCEL, + .addr = BMI160_ADDR0, + .rot_standard_ref = NULL, /* Identity matrix. */ + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default use EC settings */ + [SENSOR_CONFIG_AP] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0 + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0 + }, + }, + }, + + [LID_GYRO] = { + .name = "Lid Gyro", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_GYRO, + .location = MOTIONSENSE_LOC_LID, + .drv = &bmi160_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_GYRO, + .addr = BMI160_ADDR0, + .default_range = 1000, /* dps */ + .rot_standard_ref = NULL, /* Identity Matrix. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC does not need in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 0, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, + + [LID_MAG] = { + .name = "Lid Mag", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_BMI160, + .type = MOTIONSENSE_TYPE_MAG, + .location = MOTIONSENSE_LOC_LID, + .drv = &bmi160_drv, + .mutex = &g_lid_mutex, + .drv_data = &g_bmi160_data, + .port = I2C_PORT_ACCEL, + .addr = BMI160_ADDR0, + .default_range = 1 << 11, /* 16LSB / uT, fixed */ + .rot_standard_ref = NULL, /* Identity Matrix. */ + .config = { + /* AP: by default shutdown all sensors */ + [SENSOR_CONFIG_AP] = { + .odr = 0, + .ec_rate = 0, + }, + /* EC does not need in S0 */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 0, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + /* Sensor off in S3/S5 */ + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, + + [BASE_ACCEL] = { + .name = "Base Accel", + .active_mask = SENSOR_ACTIVE_S0, + .chip = MOTIONSENSE_CHIP_KXCJ9, + .type = MOTIONSENSE_TYPE_ACCEL, + .location = MOTIONSENSE_LOC_BASE, + .drv = &kionix_accel_drv, + .mutex = &g_base_mutex, + .drv_data = &g_kx022_data, + .port = I2C_PORT_ACCEL, + .addr = KXCJ9_ADDR1, + .rot_standard_ref = &base_standard_ref, /* Identity matrix. */ + .default_range = 2, /* g, enough for laptop. */ + .config = { + /* AP: by default use EC settings */ + [SENSOR_CONFIG_AP] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* EC use accel for angle detection */ + [SENSOR_CONFIG_EC_S0] = { + .odr = 10000 | ROUND_UP_FLAG, + .ec_rate = 100 * MSEC, + }, + /* unused */ + [SENSOR_CONFIG_EC_S3] = { + .odr = 0, + .ec_rate = 0, + }, + [SENSOR_CONFIG_EC_S5] = { + .odr = 0, + .ec_rate = 0, + }, + }, + }, +}; +const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); + +void board_hibernate(void) +{ + CPRINTS("Enter Pseudo G3"); + + /* + * Clean up the UART buffer and prevent any unwanted garbage characters + * before power off and also ensure above debug message is printed. + */ + cflush(); + + /* FIXME(dhendrix): What to do here? EC is always on so we need to + * turn off whatever can be turned off. */ +} + +enum reef_board_version { + BOARD_VERSION_UNKNOWN = -1, + BOARD_VERSION_1, + BOARD_VERSION_2, + BOARD_VERSION_3, + BOARD_VERSION_4, + BOARD_VERSION_5, + BOARD_VERSION_6, + BOARD_VERSION_7, + BOARD_VERSION_8, + BOARD_VERSION_COUNT, +}; + +struct { + enum reef_board_version version; + int thresh_mv; +} const reef_board_versions[] = { + { BOARD_VERSION_1, 330 }, /* 5.11 Kohm */ + { BOARD_VERSION_2, 670 }, /* 11.8 Kohm */ + { BOARD_VERSION_3, 1010 }, /* 20.5 Kohm */ + { BOARD_VERSION_4, 1390 }, /* 32.4 Kohm */ + { BOARD_VERSION_5, 1690 }, /* 48.7 Kohm */ + { BOARD_VERSION_6, 2020 }, /* 73.2 Kohm */ + { BOARD_VERSION_7, 2350 }, /* 115 Kohm */ + { BOARD_VERSION_8, 2800 }, /* 261 Kohm */ +}; +BUILD_ASSERT(ARRAY_SIZE(reef_board_versions) == BOARD_VERSION_COUNT); + +int board_get_version(void) +{ + static int version = BOARD_VERSION_UNKNOWN; + int mv, i; + + if (version != BOARD_VERSION_UNKNOWN) + return version; + + /* FIXME(dhendrix): enable ADC */ + gpio_set_flags(GPIO_EC_BRD_ID_EN_ODL, GPIO_ODR_HIGH); + gpio_set_level(GPIO_EC_BRD_ID_EN_ODL, 0); + /* Wait to allow cap charge */ + msleep(1); + mv = adc_read_channel(ADC_BOARD_ID); + /* FIXME(dhendrix): disable ADC */ + gpio_set_level(GPIO_EC_BRD_ID_EN_ODL, 1); + gpio_set_flags(GPIO_EC_BRD_ID_EN_ODL, GPIO_INPUT); + + if (mv == ADC_READ_ERROR) { + version = BOARD_VERSION_UNKNOWN; + return version; + } + + for (i = 0; i < BOARD_VERSION_COUNT; i++) { + if (mv < reef_board_versions[i].thresh_mv) { + version = reef_board_versions[i].version; + break; + } + } + + return version; +} diff --git a/board/reef/board.h b/board/reef/board.h new file mode 100644 index 0000000000..bda2786cd3 --- /dev/null +++ b/board/reef/board.h @@ -0,0 +1,217 @@ +/* Copyright 2016 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. + */ + +/* Reef board configuration */ + +#ifndef __CROS_EC_BOARD_H +#define __CROS_EC_BOARD_H + +/* + * Allow dangerous commands. + * TODO: Remove this config before production. + */ +#define CONFIG_SYSTEM_UNLOCKED + +/* Battery */ +#define CONFIG_BATTERY_CUT_OFF +#define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_L +#define CONFIG_BATTERY_SMART + +/* Charger */ +#define CONFIG_CHARGE_MANAGER +#define CONFIG_CHARGER +#define CONFIG_CHARGER_V2 +#define CONFIG_CHARGER_BD99955 +#define CONFIG_CHARGER_DISCHARGE_ON_AC +#define CONFIG_CHARGER_INPUT_CURRENT 512 +#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1 +#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000 +#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 + +/* USB PD config */ +#define CONFIG_USB_PD_ALT_MODE +#define CONFIG_USB_PD_ALT_MODE_DFP +#define CONFIG_USB_PD_CUSTOM_VDM +#define CONFIG_USB_PD_DUAL_ROLE +#define CONFIG_USB_PD_LOGGING +#define CONFIG_USB_PD_LOG_SIZE 512 +#define CONFIG_USB_PD_PORT_COUNT 2 +#define CONFIG_USB_PD_TCPM_VBUS +#define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */ +#define CONFIG_USB_PD_TCPM_TCPCI +#define CONFIG_USB_PD_TCPM_ANX74XX +#define CONFIG_USB_PD_TRY_SRC +#define CONFIG_USB_POWER_DELIVERY + +#define CONFIG_USBC_SS_MUX +#define CONFIG_USBC_SS_MUX_DFP_ONLY +#define CONFIG_USBC_VCONN +#define CONFIG_USBC_VCONN_SWAP + +/* SoC / PCH */ +#define CONFIG_LPC +#define CONFIG_CHIPSET_APOLLOLAKE +#undef CONFIG_PECI +#define CONFIG_POWER_BUTTON +#define CONFIG_POWER_BUTTON_X86 +#define CONFIG_POWER_COMMON + +/* EC */ +#define CONFIG_ADC +#define CONFIG_BOARD_VERSION +#define CONFIG_BOARD_SPECIFIC_VERSION +#define CONFIG_BUTTON_COUNT 2 +#define CONFIG_FPU +#define CONFIG_I2C +#define CONFIG_I2C_MASTER +#define CONFIG_KEYBOARD_PROTOCOL_8042 +#define CONFIG_KEYBOARD_COL2_INVERTED +/* #define CONFIG_LED_COMMON */ +/* #define CONFIG_LID_ANGLE */ /* FIXME(dhendrix): maybe? */ +/* #define CONFIG_LID_ANGLE_SENSOR_BASE 0 */ /* FIXME(dhendrix): maybe? */ +/* #define CONFIG_LID_ANGLE_SENSOR_LID 2 */ /* FIXME(dhendrix): maybe? */ +#define CONFIG_LID_SWITCH +/* #define CONFIG_LOW_POWER_IDLE */ +#define CONFIG_LTO +#define CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD 30 +#define CONFIG_PWM +/* #define CONFIG_TEMP_SENSOR */ +#define CONFIG_UART_HOST 0 +#define CONFIG_VBOOT_HASH + +#define CONFIG_FLASH_SIZE 524288 +#define CONFIG_SPI_FLASH_W25Q40 /* FIXME: Should be GD25LQ40? */ + +/* + * 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 */ + +/* Optional feature - used by nuvoton */ +#define NPCX_UART_MODULE2 1 /* 0:GPIO10/11 1:GPIO64/65 as UART */ +#define NPCX_JTAG_MODULE2 0 /* 0:GPIO21/17/16/20 1:GPIOD5/E2/D4/E5 as JTAG*/ +/* FIXME(dhendrix): these pins are just normal GPIOs on Reef. Do we need + * to change some other setting to put them in GPIO mode? */ +#define NPCX_TACH_SEL2 0 /* 0:GPIO40/A4 1:GPIO93/D3 as TACH */ + +/* LED signals */ +#define GPIO_BAT_LED_RED GPIO_CHARGE_LED_1 +#define GPIO_BAT_LED_GREEN GPIO_CHARGE_LED_2 + +/* I2C ports */ +#define I2C_PORT_GYRO NPCX_I2C_PORT1 +#define I2C_PORT_ALS NPCX_I2C_PORT2 +#define I2C_PORT_ACCEL NPCX_I2C_PORT2 +#define I2C_PORT_BATTERY NPCX_I2C_PORT3 +#define I2C_PORT_CHARGER NPCX_I2C_PORT3 +#define I2C_PORT_PD_MCU NPCX_I2C_PORT3 + +#define CONFIG_ACCELGYRO_BMI160 +#define CONFIG_ACCEL_KX022 +/* FIXME: Need to add BMP280 barometer */ + +#define CONFIG_ALS +#define CONFIG_ALS_OPT3001 + +#define BMM150_I2C_ADDRESS BMM150_ADDR0 /* 8-bit address */ +#define CONFIG_MAG_BMI160_BMM150 +#define BMM150_I2C_ADDRESS BMM150_ADDR0 +#define CONFIG_MAG_CALIBRATE + +/* Ambient Light Sensor address */ +#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1 + +#undef DEFERRABLE_MAX_COUNT +#define DEFERRABLE_MAX_COUNT 15 + +#ifndef __ASSEMBLER__ + +#include "gpio_signal.h" +#include "registers.h" + +/* ADC signal */ +enum adc_channel { + ADC_VBUS = -1, /* FIXME(dhendrix) */ + ADC_BOARD_ID = 2, + ADC_CH_COUNT +}; + +enum pwm_channel { + PWM_CH_LED_GREEN = 0, + PWM_CH_LED_RED, + /* Number of PWM channels */ + PWM_CH_COUNT +}; + +enum power_signal { + X86_RSMRST_N = 0, + X86_SLP_S0_N, + X86_SLP_S3_N, + X86_SLP_S4_N, + X86_SUSPWRDNACK, + + X86_ALL_SYS_PG, /* PMIC_EC_PWROK_OD */ + X86_PGOOD_PP3300, /* GPIO_PP3300_PG */ + X86_PGOOD_PP5000, /* GPIO_PP5000_PG */ + + /* Number of X86 signals */ + POWER_SIGNAL_COUNT +}; + +enum temp_sensor_id { + TEMP_SENSOR_BATTERY = 0, + TEMP_SENSOR_AMBIENT, + TEMP_SENSOR_CHARGER, + TEMP_SENSOR_COUNT +}; + +/* Light sensors */ +enum als_id { + ALS_OPT3001 = 0, + + ALS_COUNT +}; + +/* Motion sensors */ +enum sensor_id { + LID_ACCEL = 0, + LID_GYRO, + LID_MAG, + BASE_ACCEL, +}; + +/* start as a sink in case we have no other power supply/battery */ +#define PD_DEFAULT_STATE PD_STATE_SNK_DISCONNECTED + +/* TODO: determine the following board specific type-C power constants */ +/* FIXME(dhendrix): verify all of the below PD_* numbers */ +/* + * 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 PD_VCONN_SWAP_DELAY 5000 /* us */ + +/* 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 +#define PD_MAX_VOLTAGE_MV 20000 + +/* Reset PD MCU */ +void board_reset_pd_mcu(void); + +int board_get_version(void); + +void board_set_tcpc_power_mode(int port, int mode); + +#endif /* !__ASSEMBLER__ */ + +#endif /* __CROS_EC_BOARD_H */ diff --git a/board/reef/build.mk b/board/reef/build.mk new file mode 100644 index 0000000000..d7db8dd66d --- /dev/null +++ b/board/reef/build.mk @@ -0,0 +1,14 @@ +# -*- 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 +# + +CHIP:=npcx +CHIP_VARIANT:=npcx5m6g + +board-y=board.o +board-$(CONFIG_BATTERY_SMART)+=battery.o +board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o diff --git a/board/reef/ec.tasklist b/board/reef/ec.tasklist new file mode 100644 index 0000000000..a07c0f66af --- /dev/null +++ b/board/reef/ec.tasklist @@ -0,0 +1,37 @@ +/* Copyright 2016 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. + */ + +/* + * List of enabled tasks in the priority order + * + * The first one has the lowest priority. + * + * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and + * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries, + * where : + * 'n' in the name of the task + * 'r' in the main routine of the task + * 'd' in an opaque parameter passed to the routine at startup + * 's' is the stack size in bytes; must be a multiple of 8 + * + * For USB PD tasks, IDs must be in consecutive order and correspond to + * the port which they are for. See TASK_ID_TO_PD_PORT() macro. + */ + +#define CONFIG_TASK_LIST \ + TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(ALS, als_task, NULL, TASK_STACK_SIZE) \ + TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_NOTEST(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \ + TASK_NOTEST(PDCMD, pd_command_task, NULL, TASK_STACK_SIZE) \ + TASK_ALWAYS(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \ + TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \ + TASK_ALWAYS(POWERBTN, power_button_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) + diff --git a/board/reef/gpio.inc b/board/reef/gpio.inc new file mode 100644 index 0000000000..265ff8c25b --- /dev/null +++ b/board/reef/gpio.inc @@ -0,0 +1,152 @@ +/* -*- mode:c -*- + * + * Copyright 2016 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(PD_MCU_INT, PIN(3, 3), GPIO_INT_LOW, pd_mcu_interrupt) /* CHARGER_EC_INT_ODL from BD99955 */ +GPIO_INT(USB_C0_PD_INT, PIN(3, 7), GPIO_INT_RISING | GPIO_SEL_1P8V, tcpc_alert_event) /* from Analogix TCPC */ +GPIO_INT(USB_C1_PD_INT_ODL, PIN(D, 2), GPIO_INT_FALLING, tcpc_alert_event) /* from Parade TCPC */ + +GPIO_INT(PCH_SLP_S4_L, PIN(8, 6), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S4_L */ +GPIO_INT(PCH_SLP_S3_L, PIN(7, 3), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S3_L */ +GPIO_INT(PCH_SLP_S0_L, PIN(7, 5), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S0_L */ +GPIO_INT(SUSPWRNACK, PIN(7, 2), GPIO_INT_BOTH, power_signal_interrupt) +GPIO_INT(RSMRST_L_PGOOD, PIN(6, 0), GPIO_INT_BOTH, power_signal_interrupt) /* PMIC_EC_RSMRST_ODL */ +GPIO_INT(ALL_SYS_PGOOD, PIN(5, 0), GPIO_INT_BOTH, power_signal_interrupt) /* PMIC_EC_PWROK_OD */ + +/* FIXME(dhendrix): What to do with ACOK_OD? */ +//GPIO_INT(AC_PRESENT, PIN(C, 1), GPIO_INT_BOTH | GPIO_INPUT, extpower_interrupt) /* ACOK_OD from BD99955 */ +/* TODO: We might remove external pull-up for POWER_BUTTON_L in EVT */ +GPIO_INT(POWER_BUTTON_L, PIN(0, 4), GPIO_INT_BOTH, power_button_interrupt) /* MECH_PWR_BTN_ODL */ +GPIO_INT(LID_OPEN, PIN(6, 7), GPIO_INT_BOTH, lid_interrupt) +GPIO_INT(EC_VOLDN_BTN_L, PIN(8, 3), GPIO_INT_LOW | GPIO_PULL_UP, button_interrupt) +GPIO_INT(EC_VOLUP_BTN_L, PIN(8, 2), GPIO_INT_LOW | GPIO_PULL_UP, button_interrupt) + +GPIO_INT(WP_L, PIN(4, 0), GPIO_INT_BOTH | GPIO_SEL_1P8V, switch_interrupt) /* EC_WP_ODL */ + +/* FIXME(dhendrix): Implement interrupt handlers for lid, tablet mode, etc. */ +//GPIO_INT(BASE_SIXAXIS_INT_L, PIN(9, 3), GPIO_INT_LOW | GPIO_SEL_1P8V, gyro_interrupt) +GPIO(BASE_SIXAXIS_INT_L, PIN(9, 3), GPIO_INPUT | GPIO_SEL_1P8V) +//GPIO_INT(LID_ACCEL_INT_L, PIN(C, 7), GPIO_INT_LOW | GPIO_SEL_1P8V, lid_interrupt) +GPIO(LID_ACCEL_INT_L, PIN(C, 7), GPIO_INPUT | GPIO_SEL_1P8V) +//GPIO_INT(TABLET_MODE, PIN(3, 6), GPIO_INT_BOTH | GPIO_PULL_HIGH, tablet_mode_interrupt) + +/* KB interrupt from EC to PCH */ +ALTERNATE(PIN_MASK(5, 0x08), 0, MODULE_LPC, GPIO_INT_HIGH | GPIO_ODR_HIGH) /* FIXME(dhendrix): LPC_SERIRQ, INT_HIGH? */ +/* Use EC_PCH_KB_INT_ODL if SERIRQ doesn't work*/ +/* GPIO(EC_PCH_KB_INT_ODL, PIN(B, 0), GPIO_OPEN_DRAIN) */ + +/* I2C GPIOs will be set to alt. function later */ +GPIO(EC_I2C_GYRO_SDA, PIN(D, 0), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(EC_I2C_GYRO_SCL, PIN(D, 1), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(EC_I2C_SENSOR_SDA, PIN(9, 1), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(EC_I2C_SENSOR_SCL, PIN(A, 0), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(EC_I2C_USB_C0_PD_SDA, PIN(B, 4), GPIO_INPUT) +GPIO(EC_I2C_USB_C0_PD_SCL, PIN(B, 5), GPIO_INPUT) +GPIO(EC_I2C_USB_C1_PD_SDA, PIN(B, 2), GPIO_INPUT) +GPIO(EC_I2C_USB_C1_PD_SCL, PIN(B, 3), GPIO_INPUT) +GPIO(EC_I2C_POWER_SDA, PIN(8, 7), GPIO_INPUT) +GPIO(EC_I2C_POWER_SCL, PIN(9, 0), GPIO_INPUT) + +GPIO(EC_SMI_ODL, PIN(A, 6), GPIO_ODR_HIGH | GPIO_SEL_1P8V) +GPIO(EC_SCI_ODL, PIN(A, 7), GPIO_ODR_HIGH | GPIO_SEL_1P8V) + +/* + * BRD_ID1 is a an ADC pin which will be used to measure multiple values. + * Assert EC_BRD_ID_EN_ODL and then read BRD_ID1. + */ +ALTERNATE(PIN_MASK(4, 0x08), 1, MODULE_ADC, 0) +GPIO(EC_BRD_ID_EN_ODL, PIN(3, 5), GPIO_INPUT) + +GPIO(CCD_MODE_ODL, PIN(6, 3), GPIO_INPUT) +GPIO(EC_HAVEN_RESET_ODL, PIN(0, 2), GPIO_ODR_HIGH) +GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUTPUT) /* EC_ENTERING_RW */ + +/* + * FIXME(dhendrix): Should this be an interrupt? It's a normal input on elm. + * ANX72xx programming guide section 6 suggests it should interrupt on both + * high and low edges and we should use it to set PWR_EN and RESET_N pins. + */ +GPIO(USB_C0_CABLE_DET, PIN(C, 5), GPIO_INPUT) + +GPIO(PCH_RSMRST_L, PIN(7, 0), GPIO_OUT_LOW) +GPIO(EC_BATT_PRES_L, PIN(3, 4), GPIO_INPUT) +GPIO(V5A_EN, PIN(8, 5), GPIO_OUT_LOW) /* PMIC_EN */ +GPIO(EN_PP3300, PIN(C, 2), GPIO_OUT_LOW) +GPIO(PP3300_PG, PIN(6, 2), GPIO_INPUT) +GPIO(EN_PP5000, PIN(C, 6), GPIO_OUT_LOW) +GPIO(PP5000_PG, PIN(7, 1), GPIO_INPUT) +GPIO(EN_P3300_TRACKPAD_ODL, PIN(3, 2), GPIO_ODR_HIGH) +GPIO(PCH_SYS_PWROK, PIN(E, 7), GPIO_OUTPUT) /* EC_PCH_PWROK_OD */ +GPIO(ENABLE_BACKLIGHT, PIN(9, 7), GPIO_ODR_HIGH | GPIO_SEL_1P8V) /* EC_BL_EN_OD */ + +GPIO(WIRELESS_GPIO_WLAN_POWER, PIN(6, 6), GPIO_ODR_HIGH) /* EN_PP3300_WLAN_ODL */ + +GPIO(CPU_PROCHOT, PIN(7, 4), GPIO_INPUT | GPIO_SEL_1P8V) /* PCH_PROCHOT_ODL */ +GPIO(EC_PCH_PROCHOT_OVERRIDE_ODL,PIN(A, 3), GPIO_ODR_HIGH | GPIO_SEL_1P8V) + +GPIO(PCH_PWRBTN_L, PIN(0, 1), GPIO_ODR_HIGH) /* EC_PCH_PWR_BTN_ODL */ +GPIO(PCH_WAKE_L, PIN(8, 1), GPIO_ODR_HIGH) /* EC_PCH_WAKE_ODL */ +GPIO(USB_C0_HPD_1P8_ODL, PIN(9, 4), GPIO_ODR_HIGH) +GPIO(USB_C1_HPD_1P8_ODL, PIN(A, 5), GPIO_ODR_HIGH) + +GPIO(USB2_OTG_ID, PIN(A, 1), GPIO_OUTPUT) /* FIXME: what should this init to? */ +GPIO(USB2_OTG_VBUSSENSE, PIN(9, 5), GPIO_OUTPUT) + +/* EC_PCH_RTCRST is a sledgehammer for resetting SoC state and should rarely + * be used. Set as input for now, we'll set it as an output when we want to use + * it. Has external pull-down resistor. */ +GPIO(EC_PCH_RTCRST, PIN(B, 7), GPIO_INPUT) +GPIO(PCH_RCIN_L, PIN(6, 1), GPIO_ODR_HIGH) /* SYS_RST_ODL */ + +/* FIXME: What, if anything, to do about EC_RST_ODL on VCC1_RST#? */ + +GPIO(CHARGER_RST_ODL, PIN(C, 0), GPIO_ODR_HIGH) +GPIO(USB_A_CHARGE_EN_L, PIN(4, 2), GPIO_OUT_HIGH) +GPIO(EN_USB_TCPC_PWR, PIN(C, 3), GPIO_OUT_LOW) +GPIO(USB_PD_RST_ODL, PIN(0, 3), GPIO_ODR_HIGH) +GPIO(EN_USB_A_5V, PIN(4, 1), GPIO_OUT_LOW) +GPIO(USB_C0_5V_EN, PIN(D, 3), GPIO_OUT_LOW) /* EN_USB_CN_5V_OUT, Enable C0 */ +GPIO(USB_C1_5V_EN, PIN(B, 1), GPIO_OUT_LOW) /* EN_USB_C1_5V_OUT, Enable C1 */ + +/* Clear for non-HDI breakout, must be pulled high */ +GPIO(NC1, PIN(8, 4), GPIO_INPUT | GPIO_PULL_UP | GPIO_SEL_1P8V) +GPIO(NC2, PIN(8, 4), GPIO_INPUT | GPIO_PULL_UP | GPIO_SEL_1P8V) + +/* + * Alternate function pins + */ +/* Keyboard pins */ +#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP) +#define GPIO_KB_OUTPUT (GPIO_ODR_HIGH) +#define GPIO_KB_OUTPUT_COL2 (GPIO_OUT_LOW) +ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_INPUT) +ALTERNATE(PIN_MASK(2, 0xfc), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_INPUT) +ALTERNATE(PIN_MASK(2, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_OUTPUT) +ALTERNATE(PIN_MASK(0, 0xe0), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_OUTPUT) +ALTERNATE(PIN_MASK(1, 0x7f), 0, MODULE_KEYBOARD_SCAN, GPIO_KB_OUTPUT) +GPIO(KBD_KSO2, PIN(1, 7), GPIO_KB_OUTPUT_COL2) + +ALTERNATE(PIN(4, 4), 6, MODULE_ADC, 0) /* TEMP_SENSOR_AMB (FIXME: alt function 6?) */ +ALTERNATE(PIN(4, 5), 6, MODULE_ADC, 0) /* TEMP_SENSOR_CHARGER (FIXME: alt function?) */ + +ALTERNATE(PIN_MASK(D, 0x03), 1, MODULE_I2C, 0) /* GPIOD1-D0 for EC_I2C_GYRO_SDA/SCL */ +ALTERNATE(PIN_MASK(9, 0x06), 1, MODULE_I2C, 0) /* GPIO92-91 for EC_I2C_SENSOR_SDA/SCL */ +ALTERNATE(PIN_MASK(B, 0x30), 1, MODULE_I2C, 0) /* GPIOB5-B4 for EC_I2C_USB_C0_PD_SDA/SCL */ +ALTERNATE(PIN_MASK(B, 0x0C), 1, MODULE_I2C, 0) /* GPOPB3-B2 for EC_I2C_USB_C1_PD_SDA/SCL */ +ALTERNATE(PIN_MASK(8, 0x80), 1, MODULE_I2C, 0) /* GPIO87 for EC_I2C_POWER_SDA */ +ALTERNATE(PIN_MASK(9, 0x01), 1, MODULE_I2C, 0) /* GPIO90 for EC_I2C_POWER_SCL */ + +ALTERNATE(PIN_MASK(4, 0xc0), 1, MODULE_LPC, 0) +ALTERNATE(PIN_MASK(5, 0x7e), 1, MODULE_LPC, 0) + +ALTERNATE(PIN(8, 0), 4, MODULE_PWM, 0) /* RED_LED (PWM3) */ +GPIO(GPIO_GREEN_LED, PIN(C, 4), GPIO_INPUT) + +/* FIXME: Make UART RX an interrupt? */ +ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* UART from EC to Servo */ diff --git a/board/reef/usb_pd_policy.c b/board/reef/usb_pd_policy.c new file mode 100644 index 0000000000..8af728b936 --- /dev/null +++ b/board/reef/usb_pd_policy.c @@ -0,0 +1,348 @@ +/* Copyright 2016 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 "extpower.h" +#include "charge_manager.h" +#include "common.h" +#include "console.h" +#include "driver/charger/bd99955.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) + +#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP |\ + PDO_FIXED_COMM_CAP) + +/* TODO: fill in correct source and sink capabilities */ +const uint32_t pd_src_pdo[] = { + PDO_FIXED(5000, 1500, PDO_FIXED_FLAGS), +}; +const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); + +const uint32_t pd_snk_pdo[] = { + PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), + PDO_BATT(4750, 21000, 15000), + PDO_VAR(4750, 21000, 3000), +}; +const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); + +int pd_is_valid_input_voltage(int mv) +{ + return 1; +} + +void pd_transition_voltage(int idx) +{ + /* No-operation: we are always 5V */ +} + +int pd_set_power_supply_ready(int port) +{ + /* Ensure we're not charging from this port */ + if (charge_manager_get_active_charge_port() == port) + bd99955_select_input_port(BD99955_CHARGE_PORT_NONE); + + /* 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); +} + +void pd_set_input_current_limit(int port, uint32_t max_ma, + uint32_t supply_voltage) +{ +#ifdef CONFIG_CHARGE_MANAGER + struct charge_port_info charge; + + charge.current = max_ma; + charge.voltage = supply_voltage; + charge_manager_update_charge(CHARGE_SUPPLIER_PD, port, &charge); +#endif + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +void typec_set_input_current_limit(int port, uint32_t max_ma, + uint32_t supply_voltage) +{ +#ifdef CONFIG_CHARGE_MANAGER + struct charge_port_info charge; + + charge.current = max_ma; + charge.voltage = supply_voltage; + charge_manager_update_charge(CHARGE_SUPPLIER_TYPEC, port, &charge); +#endif + + /* notify host of power info change */ + pd_send_host_event(PD_EVENT_POWER_CHANGE); +} + +int pd_snk_is_vbus_provided(int port) +{ + return extpower_is_present(); +} + +int pd_board_checks(void) +{ + return EC_SUCCESS; +} + +int pd_check_power_swap(int port) +{ + /* + * Allow power swap as long as we are acting as a dual role device, + * otherwise assume our role is fixed (not in S0 or console command + * to fix our role). + */ + return pd_get_dual_role() == PD_DRP_TOGGLE_ON ? 1 : 0; +} + +int pd_check_data_swap(int port, int data_role) +{ + /* Allow data swap if we are a UFP, otherwise don't allow */ + return (data_role == PD_ROLE_UFP) ? 1 : 0; +} + +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_V5A_EN); +} + +void pd_execute_data_swap(int port, int data_role) +{ + /* Do nothing */ +} + +void pd_check_pr_role(int port, int pr_role, int flags) +{ + /* + * If partner is dual-role power and dualrole toggling is on, consider + * if a power swap is necessary. + */ + if ((flags & PD_FLAGS_PARTNER_DR_POWER) && + pd_get_dual_role() == PD_DRP_TOGGLE_ON) { + /* + * If we are a sink and partner is not externally powered, then + * swap to become a source. If we are source and partner is + * externally powered, swap to become a sink. + */ + int partner_extpower = flags & PD_FLAGS_PARTNER_EXTPOWER; + + if ((!partner_extpower && pr_role == PD_ROLE_SINK) || + (partner_extpower && pr_role == PD_ROLE_SOURCE)) + pd_request_power_swap(port); + } +} + +void pd_check_dr_role(int port, int dr_role, int flags) +{ + /* If UFP, try to switch to DFP */ + if ((flags & PD_FLAGS_PARTNER_DR_DATA) && dr_role == PD_ROLE_UFP) + pd_request_data_swap(port); +} +/* ----------------- Vendor Defined Messages ------------------ */ +const struct svdm_response svdm_rsp = { + .identity = NULL, + .svids = NULL, + .modes = NULL, +}; + +int pd_custom_vdm(int port, int cnt, uint32_t *payload, + uint32_t **rpayload) +{ + int cmd = PD_VDO_CMD(payload[0]); + uint16_t dev_id = 0; + int is_rw; + + /* make sure we have some payload */ + if (cnt == 0) + return 0; + + switch (cmd) { + case VDO_CMD_VERSION: + /* guarantee last byte of payload is null character */ + *(payload + cnt - 1) = 0; + CPRINTF("version: %s\n", (char *)(payload+1)); + break; + case VDO_CMD_READ_INFO: + case VDO_CMD_SEND_INFO: + /* copy hash */ + if (cnt == 7) { + dev_id = VDO_INFO_HW_DEV_ID(payload[6]); + is_rw = VDO_INFO_IS_RW(payload[6]); + + CPRINTF("DevId:%d.%d SW:%d RW:%d\n", + HW_DEV_ID_MAJ(dev_id), + HW_DEV_ID_MIN(dev_id), + VDO_INFO_SW_DBG_VER(payload[6]), + is_rw); + } else if (cnt == 6) { + /* really old devices don't have last byte */ + pd_dev_store_rw_hash(port, dev_id, payload + 1, + SYSTEM_IMAGE_UNKNOWN); + } + break; + case VDO_CMD_CURRENT: + CPRINTF("Current: %dmA\n", payload[1]); + break; + case VDO_CMD_FLIP: + usb_mux_flip(port); + break; +#ifdef CONFIG_USB_PD_LOGGING + case VDO_CMD_GET_LOG: + pd_log_recv_vdm(port, cnt, payload); + break; +#endif /* CONFIG_USB_PD_LOGGING */ + } + + return 0; +} + +#ifdef CONFIG_USB_PD_ALT_MODE_DFP +static int dp_flags[CONFIG_USB_PD_PORT_COUNT]; + +static void svdm_safe_dp_mode(int port) +{ + /* make DP interface safe until configure */ + dp_flags[port] = 0; + /* board_set_usb_mux(port, TYPEC_MUX_NONE, pd_get_polarity(port)); */ +} + +static int svdm_enter_dp_mode(int port, uint32_t mode_caps) +{ + /* Only enter mode if device is DFP_D capable */ + if (mode_caps & MODE_DP_SNK) { + svdm_safe_dp_mode(port); + return 0; + } + + return -1; +} + +static int svdm_dp_status(int port, uint32_t *payload) +{ + int opos = pd_alt_mode(port, USB_SID_DISPLAYPORT); + + payload[0] = VDO(USB_SID_DISPLAYPORT, 1, + CMD_DP_STATUS | VDO_OPOS(opos)); + payload[1] = VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */ + 0, /* HPD level ... not applicable */ + 0, /* exit DP? ... no */ + 0, /* usb mode? ... no */ + 0, /* multi-function ... no */ + (!!(dp_flags[port] & DP_FLAGS_DP_ON)), + 0, /* power low? ... no */ + (!!(dp_flags[port] & DP_FLAGS_DP_ON))); + return 2; +}; + +static int svdm_dp_config(int port, uint32_t *payload) +{ + int opos = pd_alt_mode(port, USB_SID_DISPLAYPORT); + /* board_set_usb_mux(port, TYPEC_MUX_DP, pd_get_polarity(port)); */ + payload[0] = VDO(USB_SID_DISPLAYPORT, 1, + CMD_DP_CONFIG | VDO_OPOS(opos)); + payload[1] = VDO_DP_CFG(MODE_DP_PIN_E, /* pin mode */ + 1, /* DPv1.3 signaling */ + 2); /* UFP connected */ + return 2; +}; + +static void svdm_dp_post_config(int port) +{ + dp_flags[port] |= DP_FLAGS_DP_ON; + if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING)) + return; +} + +static int svdm_dp_attention(int port, uint32_t *payload) +{ + /* ack */ + return 1; +} + +static void svdm_exit_dp_mode(int port) +{ + svdm_safe_dp_mode(port); + /* gpio_set_level(PORT_TO_HPD(port), 0); */ +} + +static int svdm_enter_gfu_mode(int port, uint32_t mode_caps) +{ + /* Always enter GFU mode */ + return 0; +} + +static void svdm_exit_gfu_mode(int port) +{ +} + +static int svdm_gfu_status(int port, uint32_t *payload) +{ + /* + * This is called after enter mode is successful, send unstructured + * VDM to read info. + */ + pd_send_vdm(port, USB_VID_GOOGLE, VDO_CMD_READ_INFO, NULL, 0); + return 0; +} + +static int svdm_gfu_config(int port, uint32_t *payload) +{ + return 0; +} + +static int svdm_gfu_attention(int port, uint32_t *payload) +{ + return 0; +} + +const struct svdm_amode_fx supported_modes[] = { + { + .svid = USB_SID_DISPLAYPORT, + .enter = &svdm_enter_dp_mode, + .status = &svdm_dp_status, + .config = &svdm_dp_config, + .post_config = &svdm_dp_post_config, + .attention = &svdm_dp_attention, + .exit = &svdm_exit_dp_mode, + }, + { + .svid = USB_VID_GOOGLE, + .enter = &svdm_enter_gfu_mode, + .status = &svdm_gfu_status, + .config = &svdm_gfu_config, + .attention = &svdm_gfu_attention, + .exit = &svdm_exit_gfu_mode, + } +}; +const int supported_modes_cnt = ARRAY_SIZE(supported_modes); +#endif /* CONFIG_USB_PD_ALT_MODE_DFP */ |