diff options
author | Philip Chen <philipchen@google.com> | 2017-07-14 19:20:42 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-07-26 20:04:00 -0700 |
commit | 32d27e84310f2923576b961d5d7395ae54a6574c (patch) | |
tree | dca3e82a0a82c6c6ac96562f213f9684ba51cff6 /board/scarlet | |
parent | 74d1a312e7aecab4ffc118e2aa33596169a6269d (diff) | |
download | chrome-ec-32d27e84310f2923576b961d5d7395ae54a6574c.tar.gz |
scarlet: Migrate to stm32 chip
This will officially kill the support for rev0 boards.
The major changes include:
1) Massive GPIO rename/reallocation
2) New power sequencing
3) Reconfigure peripherals (e.g. I2C, SPI, ADC)
4) Drop usb_charger_task
5) Remove lid switch
6) Display BL not driven by PWM
7) Move bmp280 from I2C to SPI
8) Remove SPI flash
9) Some placeholders for follow-up changes.
BUG=b:62640322, b:62269890
BRANCH=none
TEST=build scarlet
Change-Id: Idc0a854a0935089295b67da106ba1b35359f146d
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/572684
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: David Schneider <dnschneid@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'board/scarlet')
-rw-r--r-- | board/scarlet/battery.c | 9 | ||||
-rw-r--r-- | board/scarlet/board.c | 75 | ||||
-rw-r--r-- | board/scarlet/board.h | 102 | ||||
-rw-r--r-- | board/scarlet/build.mk | 9 | ||||
-rw-r--r-- | board/scarlet/ec.tasklist | 1 | ||||
-rw-r--r-- | board/scarlet/gpio.inc | 175 | ||||
-rw-r--r-- | board/scarlet/usb_pd_policy.c | 20 |
7 files changed, 125 insertions, 266 deletions
diff --git a/board/scarlet/battery.c b/board/scarlet/battery.c index 557e9213ed..48e1f59c4c 100644 --- a/board/scarlet/battery.c +++ b/board/scarlet/battery.c @@ -34,6 +34,15 @@ const struct battery_info *battery_get_info(void) return &info; } +/* + * Just a placeholder. + * TODO(philipchen): Implement this function in MAX17055 driver. + */ +enum battery_present battery_is_present(void) +{ + return BP_YES; +} + int board_cut_off_battery(void) { int rv; diff --git a/board/scarlet/board.c b/board/scarlet/board.c index 0c2a64d424..81dc55bd56 100644 --- a/board/scarlet/board.c +++ b/board/scarlet/board.c @@ -24,13 +24,11 @@ #include "hooks.h" #include "host_command.h" #include "i2c.h" -#include "lid_switch.h" #include "power.h" #include "power_button.h" #include "pwm.h" #include "pwm_chip.h" #include "registers.h" -#include "shi_chip.h" #include "spi.h" #include "switch.h" #include "system.h" @@ -73,44 +71,24 @@ static void warm_reset_request_interrupt(enum gpio_signal signal) /******************************************************************************/ /* ADC channels. Must be in the exactly same order as in enum adc_channel. */ const struct adc_t adc_channels[] = { - [ADC_BOARD_ID] = { - "BOARD_ID", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX+1, 0 }, - [ADC_PP900_AP] = { - "PP900_AP", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX+1, 0 }, - [ADC_PP1200_LPDDR] = { - "PP1200_LPDDR", NPCX_ADC_CH2, ADC_MAX_VOLT, ADC_READ_MAX+1, 0 }, - [ADC_PPVAR_CLOGIC] = { - "PPVAR_CLOGIC", - NPCX_ADC_CH3, ADC_MAX_VOLT, ADC_READ_MAX+1, 0 }, - [ADC_PPVAR_LOGIC] = { - "PPVAR_LOGIC", NPCX_ADC_CH4, ADC_MAX_VOLT, ADC_READ_MAX+1, 0 }, + [ADC_BOARD_ID] = {"BOARD_ID", 16, 4096, 0, STM32_AIN(10)}, }; 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[] = { - /* ArcticSand part on Gru requires >= 2.6KHz */ - [PWM_CH_DISPLIGHT] = { 2, 0, 2600 }, -}; -BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); - -/******************************************************************************/ /* I2C ports */ const struct i2c_port_t i2c_ports[] = { - {"tcpc0", NPCX_I2C_PORT0_0, 1000, GPIO_I2C0_SCL0, GPIO_I2C0_SDA0}, - {"sensors", NPCX_I2C_PORT1, 400, GPIO_I2C1_SCL, GPIO_I2C1_SDA}, - {"charger", NPCX_I2C_PORT2, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA}, - {"battery", NPCX_I2C_PORT3, 100, GPIO_I2C3_SCL, GPIO_I2C3_SDA}, + {"charger", I2C_PORT_CHARGER, 400, GPIO_I2C0_SCL, GPIO_I2C0_SDA}, + {"tcpc0", I2C_PORT_TCPC0, 1000, GPIO_I2C1_SCL, GPIO_I2C1_SDA}, }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /* power signal list. Must match order of enum power_signal. */ const struct power_signal_info power_signal_list[] = { - {GPIO_PP5000_PG, 1, "PP5000_PWR_GOOD"}, - {GPIO_TPS65261_PG, 1, "SYS_PWR_GOOD"}, - {GPIO_AP_CORE_PG, 1, "AP_PWR_GOOD"}, - {GPIO_AP_EC_S3_S0_L, 0, "SUSPEND_DEASSERTED"}, + {GPIO_PP1250_S3_PG, 1, "PP1250_S3_PWR_GOOD"}, + {GPIO_PP900_S0_PG, 1, "PP900_S0_PWR_GOOD"}, + {GPIO_AP_CORE_PG, 1, "AP_PWR_GOOD"}, + {GPIO_AP_EC_S3_S0_L, 0, "SUSPEND_DEASSERTED"}, }; BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); @@ -141,14 +119,15 @@ BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); /******************************************************************************/ /* SPI devices */ const struct spi_device_t spi_devices[] = { - { CONFIG_SPI_ACCEL_PORT, 1, GPIO_SPI_SENSOR_CS_L } + { CONFIG_SPI_ACCEL_PORT, 1, GPIO_SPI_ACCEL_CS_L }, + { CONFIG_SPI_ACCEL_PORT, 1, GPIO_SPI_BARO_CS_L }, }; const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); /******************************************************************************/ /* Wake-up pins for hibernate */ const enum gpio_signal hibernate_wake_pins[] = { - GPIO_POWER_BUTTON_L, GPIO_CHARGER_INT_L, GPIO_LID_OPEN + GPIO_POWER_BUTTON_L, GPIO_CHARGER_INT_L }; const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); @@ -308,15 +287,12 @@ static void board_init(void) /* Enable TCPC alert interrupts */ gpio_enable_interrupt(GPIO_USB_C0_PD_INT_L); - /* Enable charger interrupt for BC1.2 detection on attach / detach */ - gpio_enable_interrupt(GPIO_CHARGER_INT_L); - /* Enable reboot / shutdown control inputs from AP */ gpio_enable_interrupt(GPIO_WARM_RESET_REQ); gpio_enable_interrupt(GPIO_AP_OVERTEMP); /* Enable interrupts from BMI160 sensor. */ - gpio_enable_interrupt(GPIO_BASE_SIXAXIS_INT_L); + gpio_enable_interrupt(GPIO_ACCEL_INT_L); /* Sensor Init */ if (system_jumped_to_this_image() && chipset_in_state(CHIPSET_STATE_ON)) @@ -401,7 +377,6 @@ int board_get_version(void) msleep(10); mv = adc_read_channel(ADC_BOARD_ID); - /* TODO(crosbug.com/p/54971): Fix failure on first ADC conversion. */ if (mv == ADC_READ_ERROR) mv = adc_read_channel(ADC_BOARD_ID); @@ -519,8 +494,8 @@ struct motion_sensor_t motion_sensors[] = { .location = MOTIONSENSE_LOC_LID, .drv = &bmp280_drv, .drv_data = &bmp280_drv_data, - .port = I2C_PORT_BARO, - .addr = BMP280_I2C_ADDRESS1, + .port = CONFIG_SPI_ACCEL_PORT, + .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), .default_range = 1 << 18, /* 1bit = 4 Pa, 16bit ~= 2600 hPa */ .config = { /* AP: by default shutdown all sensors */ @@ -549,30 +524,6 @@ struct motion_sensor_t motion_sensors[] = { const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); #endif /* defined(HAS_TASK_MOTIONSENSE) */ -#define PWM_DISPLIGHT_SYSJUMP_TAG 0x5044 /* "PD" */ -#define PWM_HOOK_VERSION 1 - -static void pwm_displight_restore_state(void) -{ - const int *prev; - int version, size; - - prev = (const int *)system_get_jump_tag(PWM_DISPLIGHT_SYSJUMP_TAG, - &version, &size); - if (prev && version == PWM_HOOK_VERSION && size == sizeof(*prev)) - pwm_set_raw_duty(PWM_CH_DISPLIGHT, *prev); -} -DECLARE_HOOK(HOOK_INIT, pwm_displight_restore_state, HOOK_PRIO_INIT_PWM + 1); - -static void pwm_displight_preserve_state(void) -{ - int pwm_displight_duty = pwm_get_raw_duty(PWM_CH_DISPLIGHT); - - system_add_jump_tag(PWM_DISPLIGHT_SYSJUMP_TAG, PWM_HOOK_VERSION, - sizeof(pwm_displight_duty), &pwm_displight_duty); -} -DECLARE_HOOK(HOOK_SYSJUMP, pwm_displight_preserve_state, HOOK_PRIO_DEFAULT); - int board_allow_i2c_passthru(int port) { return (port == I2C_PORT_VIRTUAL_BATTERY); diff --git a/board/scarlet/board.h b/board/scarlet/board.h index 1fa29d97b9..733a1e24a7 100644 --- a/board/scarlet/board.h +++ b/board/scarlet/board.h @@ -3,18 +3,16 @@ * found in the LICENSE file. */ -/* Configuration for Nuvoton M4 EB */ +/* Configuration for Scarlet */ #ifndef __CROS_EC_BOARD_H #define __CROS_EC_BOARD_H /* Optional modules */ #define CONFIG_ADC +#undef CONFIG_ADC_WATCHDOG #define CONFIG_CHIPSET_RK3399 #define CONFIG_CMD_ACCELS -#define CONFIG_CMD_RTC -#define CONFIG_HOSTCMD_RTC -#define CONFIG_HOSTCMD_SPS #define CONFIG_I2C #define CONFIG_I2C_MASTER #define CONFIG_I2C_VIRTUAL_BATTERY @@ -22,44 +20,35 @@ #define CONFIG_LED_COMMON #define CONFIG_LOW_POWER_IDLE #define CONFIG_POWER_COMMON -#define CONFIG_PWM -#define CONFIG_PWM_DISPLIGHT #define CONFIG_SPI #define CONFIG_SPI_MASTER -#define CONFIG_SPI_FLASH_GD25LQ40 -#define CONFIG_SPI_FLASH_REGS +#define CONFIG_STM_HWTIMER32 +#define CONFIG_SWITCH +#define CONFIG_WATCHDOG_HELP #define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands for testing */ -/* - * We are code space-constrained on scarlet, so take 10K that is normally used - * as data RAM (was 30K, now 22K) and use it for code RAM (was 96K, now 104K) - */ -#define RAM_SHIFT_SIZE (8 * 1024) -#undef CONFIG_RO_SIZE -#define CONFIG_RO_SIZE (NPCX_PROGRAM_MEMORY_SIZE + RAM_SHIFT_SIZE) -#undef CONFIG_RAM_BASE -#define CONFIG_RAM_BASE (0x200C0000 + RAM_SHIFT_SIZE) -#undef CONFIG_RAM_SIZE -#define CONFIG_RAM_SIZE (0x00008000 - 0x800 - RAM_SHIFT_SIZE) +#undef CONFIG_UART_CONSOLE +#define CONFIG_UART_CONSOLE 1 + /* Region sizes are no longer a power of 2 so we can't enable MPU */ #undef CONFIG_MPU /* Enable a different power-on sequence than the one on gru */ #undef CONFIG_CHIPSET_POWER_SEQ_VERSION -#define CONFIG_CHIPSET_POWER_SEQ_VERSION 1 +#define CONFIG_CHIPSET_POWER_SEQ_VERSION 2 /* Optional features */ #define CONFIG_BOARD_VERSION #define CONFIG_BOARD_SPECIFIC_VERSION #define CONFIG_BUTTON_COUNT 2 #define CONFIG_BUTTON_RECOVERY -#define CONFIG_FLASH_SIZE 0x00080000 /* 512KB spi flash */ #define CONFIG_HOST_COMMAND_STATUS /* By default, set hcdebug to off */ #undef CONFIG_HOSTCMD_DEBUG_MODE #define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF -#define CONFIG_LTO +#undef CONFIG_LID_SWITCH +#undef CONFIG_LTO #define CONFIG_POWER_BUTTON #define CONFIG_POWER_BUTTON_IGNORE_LID #define CONFIG_POWER_TRACK_HOST_SLEEP_STATE @@ -75,7 +64,6 @@ #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000 #define CONFIG_CHARGER_PROFILE_OVERRIDE -#define CONFIG_USB_CHARGER #define CONFIG_USB_MUX_VIRTUAL /* Increase tx buffer size, as we'd like to stream EC log to AP. */ @@ -87,9 +75,6 @@ #define CONFIG_ACCEL_INTERRUPTS #define CONFIG_ACCELGYRO_BMI160_INT_EVENT TASK_EVENT_CUSTOM(4) #define CONFIG_BARO_BMP280 -/* Temp Sensors */ -#define CONFIG_TEMP_SENSOR -#define CONFIG_TEMP_SENSOR_TMP432 /* To be able to indicate the device is in tablet mode. */ #define CONFIG_TABLET_MODE_SWITCH @@ -124,7 +109,7 @@ #define CONFIG_USB_PD_COMM_LOCKED #define CONFIG_BATTERY_CUT_OFF -#define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_L +#define CONFIG_BATTERY_PRESENT_CUSTOM #define CONFIG_BATTERY_RETRY_NACK #define CONFIG_BATTERY_REVIVE_DISCONNECT #define CONFIG_BATTERY_SMART @@ -141,19 +126,12 @@ /* Optional features for test commands */ #define CONFIG_CMD_CHARGER_PSYS -/* Set PSYS gain for 50W max measurement */ -#define BD99955_PSYS_GAIN_SELECT \ - BD99955_CMD_PMON_IOUT_CTRL_SET_PMON_GAIN_SET_08UAW - -#define CONFIG_UART_HOST 0 +/* Timer selection */ +#define TIM_CLOCK32 2 +#define TIM_WATCHDOG 7 -/* 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*/ -#define NPCX_TACH_SEL2 0 /* 0:GPIO40/A4 1:GPIO93/D3 as TACH */ -/* Enable SHI PU on transition to S0. Disable the PU otherwise for leakage. */ -#define NPCX_SHI_CS_PU -#define NPCX_SHI_BYPASS_OVER_256B +/* 48 MHz SYSCLK clock frequency */ +#define CPU_CLOCK 48000000 /* Optional for testing */ #undef CONFIG_PECI @@ -170,30 +148,22 @@ #undef CONFIG_CMD_TIMERINFO #undef CONFIG_CONSOLE_CMDHELP #undef CONFIG_CONSOLE_HISTORY -/* - * Remove task profiling to improve SHI interrupt latency. - * TODO(crosbug.com/p/55710): Re-define once interrupt latency is within - * tolerance. - */ -#undef CONFIG_TASK_PROFILING -#define I2C_PORT_TCPC0 NPCX_I2C_PORT0_0 -#define I2C_PORT_BARO NPCX_I2C_PORT1 -#define I2C_PORT_CHARGER NPCX_I2C_PORT2 -#define I2C_PORT_THERMAL NPCX_I2C_PORT2 -#define I2C_PORT_BATTERY NPCX_I2C_PORT3 +#define CONFIG_TASK_PROFILING + +#define I2C_PORT_CHARGER 0 +#define I2C_PORT_BATTERY 0 #define I2C_PORT_VIRTUAL_BATTERY I2C_PORT_BATTERY +#define I2C_PORT_TCPC0 1 /* Enable Accel over SPI */ -#define CONFIG_SPI_ACCEL_PORT 0 /* SPI master port (SPIP) form BMI160 */ +#define CONFIG_SPI_ACCEL_PORT 0 /* The first SPI master port (SPI2) */ #define CONFIG_KEYBOARD_PROTOCOL_MKBP #define CONFIG_MKBP_EVENT /* Define the MKBP events which are allowed to wakeup AP in S3. */ #define CONFIG_MKBP_WAKEUP_MASK \ - (EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) |\ - EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) |\ - EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED) |\ + (EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED) |\ EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC)) #ifndef __ASSEMBLER__ @@ -201,10 +171,6 @@ enum adc_channel { /* Real ADC channels begin here */ ADC_BOARD_ID = 0, - ADC_PP900_AP, - ADC_PP1200_LPDDR, - ADC_PPVAR_CLOGIC, - ADC_PPVAR_LOGIC, ADC_CH_COUNT }; @@ -214,26 +180,10 @@ enum button { BUTTON_COUNT }; -#ifdef CONFIG_TEMP_SENSOR_TMP432 -enum temp_sensor_id { - /* TMP432 local and remote sensors */ - TEMP_SENSOR_I2C_TMP432_LOCAL, - TEMP_SENSOR_I2C_TMP432_REMOTE1, - TEMP_SENSOR_I2C_TMP432_REMOTE2, - TEMP_SENSOR_COUNT -}; -#endif - -enum pwm_channel { - PWM_CH_DISPLIGHT, - /* Number of PWM channels */ - PWM_CH_COUNT -}; - /* power signal definitions */ enum power_signal { - PP5000_PWR_GOOD = 0, - SYS_PWR_GOOD, + PP1250_S3_PWR_GOOD = 0, + PP900_S0_PWR_GOOD, AP_PWR_GOOD, SUSPEND_DEASSERTED, diff --git a/board/scarlet/build.mk b/board/scarlet/build.mk index 2991539c4d..f2966fea6a 100644 --- a/board/scarlet/build.mk +++ b/board/scarlet/build.mk @@ -5,9 +5,10 @@ # # Board specific files build # - -# the IC is Nuvoton M-Series EC (npcx5m5g, npcx5m6g) -CHIP:=npcx -CHIP_VARIANT:=npcx5m5g +# +# STmicro STM32F098VC +CHIP:=stm32 +CHIP_FAMILY:=stm32f0 +CHIP_VARIANT:=stm32f09x board-y=battery.o board.o usb_pd_policy.o led.o diff --git a/board/scarlet/ec.tasklist b/board/scarlet/ec.tasklist index 03fe726b90..d2e4584fb3 100644 --- a/board/scarlet/ec.tasklist +++ b/board/scarlet/ec.tasklist @@ -18,7 +18,6 @@ */ #define CONFIG_TASK_LIST \ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG, usb_charger_task, NULL, TASK_STACK_SIZE) \ TASK_ALWAYS(CHARGER, charger_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \ diff --git a/board/scarlet/gpio.inc b/board/scarlet/gpio.inc index e9b78c3f97..0b28a6764a 100644 --- a/board/scarlet/gpio.inc +++ b/board/scarlet/gpio.inc @@ -10,135 +10,90 @@ * Note: Those with interrupt handlers must be declared first. */ - -GPIO_INT(WP_L, PIN(9, 3), GPIO_INT_BOTH, switch_interrupt) -GPIO_INT(SHI_CS_L, PIN(5, 3), GPIO_INT_FALLING | GPIO_PULL_DOWN, - shi_cs_event) -GPIO_INT(USB_C0_PD_INT_L, PIN(6, 0), GPIO_INT_FALLING | GPIO_PULL_UP, +GPIO_INT(SPI1_NSS, PIN(A, 15), GPIO_INT_BOTH, + spi_event) +GPIO_INT(USB_C0_PD_INT_L, PIN(C, 13), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event) -GPIO_INT(VOLUME_UP_L, PIN(8, 2), GPIO_INT_BOTH | GPIO_PULL_UP, +GPIO_INT(VOLUME_UP_L, PIN(D, 10), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) -GPIO_INT(VOLUME_DOWN_L, PIN(8, 3), GPIO_INT_BOTH | GPIO_PULL_UP, +GPIO_INT(VOLUME_DOWN_L, PIN(E, 11), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) -GPIO_INT(POWER_BUTTON_L, PIN(0, 4), GPIO_INT_BOTH | GPIO_PULL_UP, +GPIO_INT(POWER_BUTTON_L, PIN(A, 0), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt) -GPIO_INT(LID_OPEN, PIN(9, 7), GPIO_INT_BOTH | GPIO_SEL_1P8V, - lid_interrupt) - -GPIO_INT(PP5000_PG, PIN(7, 1), GPIO_INT_BOTH | GPIO_PULL_UP, +GPIO_INT(PP1250_S3_PG, PIN(D, 8), GPIO_INT_BOTH | GPIO_PULL_UP, power_signal_interrupt) -GPIO_INT(TPS65261_PG, PIN(7, 5), GPIO_INT_BOTH | GPIO_PULL_UP, +GPIO_INT(PP900_S0_PG, PIN(D, 9), GPIO_INT_BOTH | GPIO_PULL_UP, power_signal_interrupt) -/* TODO: Remove PD in S3 for power savings */ -GPIO_INT(AP_EC_S3_S0_L, PIN(C, 1), GPIO_INT_BOTH | GPIO_PULL_DOWN, +GPIO_INT(AP_EC_S3_S0_L, PIN(C, 7), GPIO_INT_BOTH | GPIO_PULL_DOWN, power_signal_interrupt) -GPIO_INT(AP_CORE_PG, PIN(6, 7), GPIO_INT_BOTH | GPIO_PULL_UP, +GPIO_INT(AP_CORE_PG, PIN(D, 7), GPIO_INT_BOTH | GPIO_PULL_UP, power_signal_interrupt) -GPIO_INT(WARM_RESET_REQ, PIN(7, 3), GPIO_INT_RISING | GPIO_PULL_DOWN, +GPIO_INT(WARM_RESET_REQ, PIN(E, 1), GPIO_INT_RISING | GPIO_PULL_DOWN, warm_reset_request_interrupt) -GPIO_INT(AP_OVERTEMP, PIN(7, 4), GPIO_INT_RISING | GPIO_PULL_DOWN, +GPIO_INT(AP_OVERTEMP, PIN(E, 4), GPIO_INT_RISING | GPIO_PULL_DOWN, overtemp_interrupt) -GPIO_INT(CHARGER_INT_L, PIN(3, 3), GPIO_INT_FALLING | GPIO_PULL_UP, - bd9995x_vbus_interrupt) -GPIO_INT(BASE_SIXAXIS_INT_L,PIN(4, 0), GPIO_INT_FALLING | GPIO_SEL_1P8V, +GPIO_INT(ACCEL_INT_L, PIN(D, 14), GPIO_INT_FALLING | GPIO_SEL_1P8V, bmi160_interrupt) -/* VR EN */ -GPIO(AP_CORE_EN, PIN(7, 2), GPIO_OUT_LOW) -GPIO(LPDDR_PWR_EN, PIN(8, 6), GPIO_OUT_LOW) -GPIO(PPVAR_CLOGIC_EN, PIN(C, 5), GPIO_OUT_LOW) -GPIO(PPVAR_LOGIC_EN, PIN(8, 5), GPIO_OUT_LOW) - -GPIO(PP900_AP_EN, PIN(B, 7), GPIO_OUT_LOW) -GPIO(PP900_DDRPLL_EN, PIN(C, 0), GPIO_OUT_LOW) -GPIO(PP900_USB_EN, PIN(A, 5), GPIO_OUT_LOW) -GPIO(PP900_PCIE_EN, PIN(0, 0), GPIO_OUT_LOW) - -/* NC */ -GPIO(GPIO81_NC, PIN(8, 1), GPIO_INPUT | GPIO_PULL_UP) +/* Voltage rails control pins */ +GPIO(PP1800_S0_EN, PIN(D, 11), GPIO_OUT_LOW) +GPIO(AP_CORE_EN, PIN(C, 1), GPIO_OUT_LOW) +GPIO(PP3300_S0_EN, PIN(E, 12), GPIO_OUT_LOW) +GPIO(PP1800_USB_EN, PIN(C, 4), GPIO_OUT_LOW) +GPIO(PP900_S0_EN, PIN(E, 8), GPIO_OUT_LOW) +GPIO(PP1250_S3_EN, PIN(D, 13), GPIO_OUT_LOW) +GPIO(PP1800_S3_EN, PIN(C, 3), GPIO_OUT_LOW) +GPIO(PP3300_S3_EN, PIN(E, 2), GPIO_OUT_LOW) +GPIO(PP900_S3_EN, PIN(E, 10), GPIO_OUT_LOW) -GPIO(PP1800_SENSOR_EN_L, PIN(A, 7), GPIO_OUT_HIGH) -GPIO(PP1800_USB_EN_L, PIN(A, 6), GPIO_OUT_HIGH) -GPIO(PP1800_LID_EN_L, PIN(B, 0), GPIO_OUT_HIGH) -GPIO(PP1800_PMU_EN_L, PIN(5, 1), GPIO_OUT_HIGH) -GPIO(PP1800_AP_AVDD_EN_L, PIN(5, 2), GPIO_OUT_HIGH) -GPIO(PP1800_S0_EN_L, PIN(5, 0), GPIO_OUT_HIGH) -GPIO(PP1800_SIXAXIS_EN_L, PIN(5, 6), GPIO_OUT_HIGH) - -GPIO(PP3300_TRACKPAD_EN_L, PIN(3, 2), GPIO_OUT_HIGH) -GPIO(PP3300_USB_EN_L, PIN(3, 7), GPIO_OUT_HIGH) - -GPIO(PP5000_EN, PIN(C, 6), GPIO_OUT_LOW) +GPIO(PP3300_REDUCE_EFF_L, PIN(D, 12), GPIO_ODR_HIGH) /* * I2C pins should be configured as inputs until I2C module is * initialized. This will avoid driving the lines unintentionally. */ -GPIO(I2C0_SCL0, PIN(B, 5), GPIO_ODR_HIGH | GPIO_SEL_1P8V) -GPIO(I2C0_SDA0, PIN(B, 4), GPIO_ODR_HIGH | GPIO_SEL_1P8V) -GPIO(I2C1_SCL, PIN(9, 0), GPIO_ODR_HIGH | GPIO_SEL_1P8V) -GPIO(I2C1_SDA, PIN(8, 7), GPIO_ODR_HIGH | GPIO_SEL_1P8V) -GPIO(I2C2_SCL, PIN(9, 2), GPIO_ODR_HIGH) -GPIO(I2C2_SDA, PIN(9, 1), GPIO_ODR_HIGH) -GPIO(I2C3_SCL, PIN(D, 1), GPIO_ODR_HIGH) -GPIO(I2C3_SDA, PIN(D, 0), GPIO_ODR_HIGH) - -/* Attached to push-pull interrupt pin of accel, but unused */ -GPIO(LID_ACCEL_INT_L, PIN(C, 7), GPIO_INPUT) +GPIO(I2C0_SCL, PIN(B, 8), GPIO_INPUT) +GPIO(I2C0_SDA, PIN(B, 9), GPIO_INPUT) +GPIO(I2C1_SCL, PIN(B, 13), GPIO_INPUT) +GPIO(I2C1_SDA, PIN(B, 14), GPIO_INPUT) -GPIO(USB_C0_5V_EN, PIN(D, 3), GPIO_OUT_LOW | GPIO_PULL_UP) +/* Analog pins */ +GPIO(BOARD_ID, PIN(C, 0), GPIO_ANALOG) -GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUT_LOW) -GPIO(SYS_RST_L, PIN(6, 1), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) -GPIO(EC_INT_L, PIN(5, 7), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) -GPIO(EC_BOARD_ID_EN_L, PIN(3, 5), GPIO_OUT_HIGH) - -GPIO(USB_DP_HPD, PIN(6, 6), GPIO_OUT_LOW) -GPIO(CHARGER_RESET_L, PIN(0, 1), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) -GPIO(TPM_ALLOW_RST, PIN(0, 2), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) -GPIO(EC_BATT_PRES_L, PIN(3, 4), GPIO_INPUT) -GPIO(LID_360_L, PIN(3, 6), GPIO_INPUT | GPIO_SEL_1P8V) -GPIO(CCD_MODE_ODL, PIN(6, 3), GPIO_INPUT | GPIO_PULL_UP) -GPIO(PP3300_S0_EN_L, PIN(7, 0), GPIO_OUT_HIGH) -GPIO(SPI_SENSOR_CS_L, PIN(9, 4), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) - -GPIO(USB_C0_DISCHARGE, PIN(0, 3), GPIO_OUT_LOW) -GPIO(USB_C1_DISCHARGE, PIN(B, 1), GPIO_OUT_LOW) - -GPIO(GPIOB6_NC, PIN(B, 6), GPIO_INPUT | GPIO_PULL_UP) +/* SPI sensors */ +GPIO(SPI_BARO_CS_L, PIN(B, 12), GPIO_OUT_LOW) +GPIO(SPI_ACCEL_CS_L, PIN(D, 0), GPIO_OUT_LOW) /* Scarlet LEDs */ -GPIO(BAT_LED_GREEN, PIN(C, 3), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) -GPIO(BAT_LED_RED, PIN(8, 0), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) - -/* - * SPI host interface - enable PDs by default. These will be made functional - * by the SHI driver when the AP powers up, and restored back to GPIO when - * the AP powers down. - */ -GPIO(SHI_SDI, PIN(4, 6), GPIO_INPUT | GPIO_PULL_DOWN) -GPIO(SHI_SDO, PIN(4, 7), GPIO_INPUT | GPIO_PULL_DOWN) -GPIO(SHI_SCLK, PIN(5, 5), GPIO_INPUT | GPIO_PULL_DOWN) - -/* SPIP_MOSI/SPIP_SCLK GPIOA3/A1 */ -ALTERNATE(PIN_MASK(A, 0x0A), 1, MODULE_SPI, 0) -/* SPIP_MISO GPIO95 */ -ALTERNATE(PIN_MASK(9, 0x20), 1, MODULE_SPI, 0) -/* I2C0SDA1/I2C0SCL1 GPIOB2/B3 */ -ALTERNATE(PIN_MASK(B, 0x0C), 1, MODULE_I2C, 0) -/* I2C0SDA0/I2C0SCL0 GPIOB4/B5 */ -ALTERNATE(PIN_MASK(B, 0x30), 1, MODULE_I2C, 0) -/* I2C1SDA GPIO87 */ -ALTERNATE(PIN_MASK(8, 0x80), 1, MODULE_I2C, 0) -/* I2C1SCL/I2C2SDA/I2C2SCL GPIO90/91/92 */ -ALTERNATE(PIN_MASK(9, 0x07), 1, MODULE_I2C, 0) -/* I2C3SDA/I2C3SCL GPIOD0/D1 */ -ALTERNATE(PIN_MASK(D, 0x03), 1, MODULE_I2C, 0) -/* PWM2 / BLPWM */ -ALTERNATE(PIN_MASK(C, 0x10), 1, MODULE_PWM, 0) -/* CR_SIN/SOUT GPIO64/65 */ -ALTERNATE(PIN_MASK(6, 0x30), 1, MODULE_UART, GPIO_PULL_UP) -/* ADC0-4 */ -ALTERNATE(PIN_MASK(4, 0x3e), 1, MODULE_ADC, 0) -/* External 32KHz input clock - GPIOE7 */ -ALTERNATE(PIN_MASK(E, 0x80), 1, MODULE_CLOCK, 0) +GPIO(BAT_LED_GREEN, PIN(E, 9), GPIO_ODR_HIGH) +GPIO(BAT_LED_RED, PIN(E, 13), GPIO_ODR_HIGH) + +/* Other input pins */ +GPIO(WP_L, PIN(E, 5), GPIO_INPUT) +/* TODO(philipchen): Add an interrupt handler once CCD is fully developed. */ +GPIO(CCD_MODE_ODL, PIN(C, 5), GPIO_INPUT | GPIO_PULL_UP) +/* TODO(b:63772957): Add an interrupt handler for charger rt946x */ +GPIO(CHARGER_INT_L, PIN(E, 6), GPIO_INPUT | GPIO_PULL_UP) +/* TODO(b:63773130): Add an interrupt handler for battery gauge max17055 */ +GPIO(BATTERY_INT_L, PIN(A, 12), GPIO_INPUT | GPIO_PULL_UP) + +/* Other output pins */ +GPIO(ENTERING_RW, PIN(C, 6), GPIO_ODR_HIGH) +GPIO(SYS_RST_L, PIN(C, 8), GPIO_ODR_HIGH) +GPIO(EC_INT_L, PIN(E, 3), GPIO_ODR_HIGH) +GPIO(EC_BOARD_ID_EN_L, PIN(F, 1), GPIO_ODR_HIGH) +GPIO(USB_C0_DISCHARGE, PIN(A, 11), GPIO_OUT_LOW) +GPIO(PCA9468_EN, PIN(E, 15), GPIO_OUT_LOW) + +/* USART1: PA9/PA10 */ +ALTERNATE(PIN_MASK(A, 0x0600), 1, MODULE_UART, 0) +/* I2C MASTER: PB8/9 */ +ALTERNATE(PIN_MASK(B, 0x0300), 1, MODULE_I2C, 0) +/* I2C MASTER: PB13/14 */ +ALTERNATE(PIN_MASK(B, 0x6000), 5, MODULE_I2C, 0) +/* SPI SLAVE: PB3/4/5 */ +ALTERNATE(PIN_MASK(B, 0x0038), 5, MODULE_SPI, 0) +/* SPI SLAVE CS: PA15 */ +ALTERNATE(PIN_MASK(A, 0x8000), 5, MODULE_SPI, 0) +/* SPI MASTER: PD1/3/4 */ +ALTERNATE(PIN_MASK(D, 0x001a), 1, MODULE_SPI_MASTER, 0) diff --git a/board/scarlet/usb_pd_policy.c b/board/scarlet/usb_pd_policy.c index e1261ef39b..8e7cfda0ee 100644 --- a/board/scarlet/usb_pd_policy.c +++ b/board/scarlet/usb_pd_policy.c @@ -62,20 +62,10 @@ int board_vbus_source_enabled(int port) static void board_vbus_update_source_current(int port) { - /* There is only one usb type-c port on Scarlet. */ - enum gpio_signal gpio = GPIO_USB_C0_5V_EN; - int flags = (vbus_rp == TYPEC_RP_1A5 && vbus_en) ? - (GPIO_INPUT | GPIO_PULL_UP) : (GPIO_OUTPUT | GPIO_PULL_UP); - /* - * Driving USB_Cx_5V_EN high, actually put a 16.5k resistance - * (2x 33k in parallel) on the NX5P3290 load switch ILIM pin, - * setting a minimum OCP current of 3186 mA. - * Putting an internal pull-up on USB_Cx_5V_EN, effectively put a 33k - * resistor on ILIM, setting a minimum OCP current of 1505 mA. + * TODO(philipchen): Remove this function and fix wherever + * this function is called after RT946x driver is hooked up. */ - gpio_set_level(gpio, vbus_en); - gpio_set_flags(gpio, flags); } int pd_set_power_supply_ready(int port) @@ -171,7 +161,11 @@ int pd_check_data_swap(int port, int data_role) int pd_check_vconn_swap(int port) { - return gpio_get_level(GPIO_PP5000_EN); + /* + * VCONN is provided directly by the battery (PPVAR_SYS) + * but use the same rules as power swap. + */ + return pd_get_dual_role() == PD_DRP_TOGGLE_ON ? 1 : 0; } void pd_execute_data_swap(int port, int data_role) |