summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2017-11-03 16:46:23 -0600
committerchrome-bot <chrome-bot@chromium.org>2017-11-14 13:31:48 -0800
commit6d4674fd0520ae6f1210b1a8b1cc654119344795 (patch)
tree8e59a822e03285778d79ea5d6e94bc2aab1aaf04 /board
parent49b0f33e186ae5c65dd490ad0d304868608c9f1d (diff)
downloadchrome-ec-6d4674fd0520ae6f1210b1a8b1cc654119344795.tar.gz
grunt: Initial GPIO setup for grunt
Configure GPIOs to match grunt proto v1.1 schematic. Change EC chip to npcx7m6f. Minimal board.c/h, just enough to build. BUG=b:64935726 BRANCH=none TEST=make BOARD=grunt Change-Id: I1a1f581c7ee7b80808c0dde179bc3ee0d69f960e Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/754302 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/grunt/board.c604
-rw-r--r--board/grunt/board.h293
-rw-r--r--board/grunt/build.mk5
-rw-r--r--board/grunt/ec.tasklist13
-rw-r--r--board/grunt/gpio.inc212
5 files changed, 169 insertions, 958 deletions
diff --git a/board/grunt/board.c b/board/grunt/board.c
index 9a4b341ee7..a8755e08c2 100644
--- a/board/grunt/board.c
+++ b/board/grunt/board.c
@@ -5,611 +5,91 @@
/* Grunt board-specific configuration */
-#include "adc.h"
#include "adc_chip.h"
-#include "als.h"
#include "button.h"
#include "charge_manager.h"
-#include "charge_ramp.h"
#include "charge_state.h"
-#include "charger.h"
-#include "chipset.h"
+#include "charge_state_v2.h"
+#include "common.h"
#include "console.h"
-#include "driver/als_al3010.h"
-#include "driver/accel_kionix.h"
-#include "driver/charger/isl923x.h"
-#include "driver/tcpm/ps8xxx.h"
-#include "driver/tcpm/tcpci.h"
-#include "driver/tcpm/tcpm.h"
-#include "driver/temp_sensor/g78x.h"
-#include "pi3usb9281.h"
+#include "compile_time_macros.h"
+#include "ec_commands.h"
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
-#include "host_command.h"
#include "i2c.h"
#include "keyboard_scan.h"
-#include "lid_angle.h"
#include "lid_switch.h"
-#include "math_util.h"
-#include "motion_sense.h"
#include "power.h"
#include "power_button.h"
-#include "pwm.h"
-#include "fan.h"
-#include "fan_chip.h"
-#include "pwm_chip.h"
-#include "spi.h"
-#include "switch.h"
+#include "registers.h"
#include "system.h"
-#include "task.h"
-#include "temp_sensor.h"
-#include "timer.h"
-#include "uart.h"
-#include "usb_charge.h"
+#include "switch.h"
+#include "tcpci.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)
-
static void tcpc_alert_event(enum gpio_signal signal)
{
- if ((signal == GPIO_USB_C0_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C0_PD_RST_ODL))
- return;
-
- if ((signal == GPIO_USB_C1_PD_INT_ODL) &&
- !gpio_get_level(GPIO_USB_C1_PD_RST_ODL))
- return;
-
-#ifdef HAS_TASK_PDCMD
- /* Exchange status with TCPCs */
- host_command_pd_send_status(PD_CHARGE_NO_CHANGE);
-#endif
-}
-
-void usb0_evt(enum gpio_signal signal)
-{
- task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12, 0);
-}
-
-void usb1_evt(enum gpio_signal signal)
-{
- task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12, 0);
+ /* TODO(ecgh) */
}
#include "gpio_list.h"
-/* power signal list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {
- {GPIO_PCH_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
- {GPIO_PCH_SLP_S5_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S5_DEASSERTED"},
- {GPIO_SPOK, POWER_SIGNAL_ACTIVE_HIGH, "SPOK_DEASSERTED"},
- {GPIO_P095VALW_PG, POWER_SIGNAL_ACTIVE_HIGH, "0.95VALW_DEASSERTED"},
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
-/* Temperature sensors data */
-const struct temp_sensor_t temp_sensors[] = {
- {"G781_Internal", TEMP_SENSOR_TYPE_BOARD, g78x_get_val,
- G78X_TEMP_LOCAL, 4},
- {"G781_Sensor_1", TEMP_SENSOR_TYPE_BOARD, g78x_get_val,
- G78X_TEMP_REMOTE1, 4},
- {"Battery", TEMP_SENSOR_TYPE_BATTERY, charge_get_battery_temp,
- 0, 4},
-};
-BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
-
-/* ALS instances. Must be in same order as enum als_id. */
-struct als_t als[] = {
- {"ISL", al3010_init, al3010_read_lux, 5},
-};
-BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT);
-
-/* ADC channels */
-const struct adc_t adc_channels[] = {
- /* Vfs = Vref = 2.816V, 10-bit unsigned reading */
- [ADC_IMON1] = {
- "PD1", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0
- },
- [ADC_IMON2] = {
- "PD2", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0
- },
- [ADC_BOARD_ID] = {
- "BRD_ID", NPCX_ADC_CH2, ADC_MAX_VOLT, ADC_READ_MAX + 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_FAN] = { 0, 0, 25000 },
-};
-BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-
-/******************************************************************************/
-/* Physical fans. These are logically separate from pwm_channels. */
-const struct fan_t fans[] = {
- [FAN_CH_0] = {
- .flags = FAN_USE_RPM_MODE,
- .rpm_min = 1000,
- .rpm_start = 1000,
- .rpm_max = 4300,
- .ch = 0,/* Use MFT id to control fan */
- .pgood_gpio = -1,
- .enable_gpio = -1,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(fans) == FAN_CH_COUNT);
-
-/* MFT channels. These are logically separate from mft_channels. */
-const struct mft_t mft_channels[] = {
- [MFT_CH_0] = { NPCX_MFT_MODULE_1, TCKC_LFCLK, PWM_CH_FAN},
-};
-BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_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},
- {"thermal", I2C_PORT_THERMAL, 400,
- GPIO_EC_I2C_THERMAL_SCL, GPIO_EC_I2C_THERMAL_SDA},
- {"accelgyro", 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);
-
-struct pi3usb9281_config pi3usb9281_chips[] = {
- {
- .i2c_port = NPCX_I2C_PORT0_0,
- .mux_lock = NULL,
- },
- {
- .i2c_port = NPCX_I2C_PORT0_1,
- .mux_lock = NULL,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) ==
- CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT);
-
-const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- [0] = {
- .i2c_host_port = NPCX_I2C_PORT0_0,
- .i2c_slave_addr = 0x16,
- .drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
- },
- [1] = {
- .i2c_host_port = NPCX_I2C_PORT0_1,
- .i2c_slave_addr = 0x16,
- .drv = &ps8xxx_tcpm_drv,
- .pol = TCPC_ALERT_ACTIVE_LOW,
- },
-};
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
-
- if (!gpio_get_level(GPIO_USB_C0_PD_INT_ODL)) {
- if (gpio_get_level(GPIO_USB_C0_PD_RST_ODL))
- status |= PD_STATUS_TCPC_ALERT_0;
- }
-
- if (!gpio_get_level(GPIO_USB_C1_PD_INT_ODL)) {
- if (gpio_get_level(GPIO_USB_C1_PD_RST_ODL))
- status |= PD_STATUS_TCPC_ALERT_1;
- }
-
- return status;
-}
-
const enum gpio_signal hibernate_wake_pins[] = {
- GPIO_AC_PRESENT,
GPIO_LID_OPEN,
+ GPIO_AC_PRESENT,
GPIO_POWER_BUTTON_L,
};
+const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
-const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
-
-struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
- {
- .port_addr = 0,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+const struct adc_t adc_channels[] = {
+ [ADC_TEMP_SENSOR_CHARGER] = {
+ "CHARGER", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX+1, 0
+ },
+ [ADC_TEMP_SENSOR_SOC] = {
+ "SOC", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX+1, 0
},
- {
- .port_addr = 1,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
- }
};
-const int usb_port_enable[CONFIG_USB_PORT_POWER_SMART_PORT_COUNT] = {
- GPIO_USB1_ENABLE,
+/* Power signal list. Must match order of enum power_signal. */
+const struct power_signal_info power_signal_list[] = {
+ {GPIO_PCH_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"},
+ {GPIO_PCH_SLP_S5_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S5_DEASSERTED"},
+ {GPIO_VGATE, POWER_SIGNAL_ACTIVE_HIGH, "VGATE"},
+ {GPIO_SPOK, POWER_SIGNAL_ACTIVE_HIGH, "SPOK"},
};
+BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-/**
- * Reset PD MCU -- currently only called from handle_pending_reboot() in
- * common/power.c just before hard resetting the system. This logic is likely
- * not needed as the PP3300_A rail should be dropped on EC reset.
- */
-void board_reset_pd_mcu(void)
-{
- /* Assert reset to TCPC1 */
- gpio_set_level(GPIO_USB_C1_PD_RST_ODL, 0);
-
- /* Assert reset to TCPC0 */
- gpio_set_level(GPIO_USB_C0_PD_RST_ODL, 0);
-
- /* TCPC0 requires 10ms reset/power down assertion */
- msleep(10);
-
- /* Deassert reset to TCPC1 */
- gpio_set_level(GPIO_USB_C1_PD_RST_ODL, 1);
-
- /* Deassert reset to TCPC0 */
- gpio_set_level(GPIO_USB_C0_PD_RST_ODL, 1);
-}
-
-void board_tcpc_init(void)
-{
- int port;
-
- /* Only reset TCPC if not sysjump */
- if (!system_jumped_to_this_image())
- board_reset_pd_mcu();
-
- /* Enable TCPC0 interrupt */
- gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
-
- /* Enable TCPC1 interrupt */
- gpio_enable_interrupt(GPIO_USB_C1_PD_INT_ODL);
-
- /*
- * Initialize HPD to low; after sysjump SOC needs to see
- * HPD pulse to enable video path
- */
- for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) {
- const struct usb_mux *mux = &usb_muxes[port];
-
- mux->hpd_update(port, 0, 0);
- }
-}
-DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
-
-/* Called by power state machine when transitioning from G3 to S5 */
-static void chipset_pre_init(void)
-{
-
-}
-DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, chipset_pre_init, HOOK_PRIO_DEFAULT);
-
-/* Initialize board. */
-static void board_init(void)
-{
- /* Enable pericom BC1.2 interrupts */
- gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_L);
- gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L);
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_FIRST);
-
-/*
- * TODO(b/63514169)
- * There is no VBUS detect pin in proto phase, EC needs to
- * get VBUS information from BC1.2 chip. HW will add VBUS
- * detect pin in EVT phase and EC can get VBUS status from
- * GPIO.
- */
-int check_vbus_status(int port)
-{
- int reg;
-
- i2c_read8(pi3usb9281_chips[port].i2c_port,
- 0x4A, PI3USB9281_REG_VBUS, &reg);
-
- return ((reg & 0x02) >> 1);
-}
-
-void update_vbus_status(void)
-{
- uint8_t port, vbus;
-
- for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) {
- vbus = check_vbus_status(port);
- usb_charger_vbus_change(port, vbus);
- task_wake(port ? TASK_ID_PD_C1 : TASK_ID_PD_C0);
- }
-}
-
-/*
- * TODO(b/63514169)
- * Check VBUS status when AC changes to update the charge source information.
- * We will modify it to gpio interrupt control when HW adds vbus status pin
- * in EVT phase.
- */
-static void board_extpower(void)
-{
- update_vbus_status();
-}
-DECLARE_HOOK(HOOK_AC_CHANGE, board_extpower, HOOK_PRIO_DEFAULT);
-
-int pd_snk_is_vbus_provided(int port)
-{
- return check_vbus_status(port);
-}
-
-/**
- * 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)
-{
- switch (charge_port) {
- case 0:
- /* Don't charge from a source port */
- if (board_vbus_source_enabled(charge_port))
- return -1;
-
- gpio_set_level(GPIO_USB_C0_5V_EN, 0);
- gpio_set_level(GPIO_USB_C0_20V_EN, 1);
- break;
- case 1:
- /* Don't charge from a source port */
- if (board_vbus_source_enabled(charge_port))
- return -1;
-
- gpio_set_level(GPIO_USB_C1_5V_EN, 0);
- gpio_set_level(GPIO_USB_C1_20V_EN, 1);
- break;
- case CHARGE_PORT_NONE:
- gpio_set_level(GPIO_USB_C0_20V_EN, 0);
- gpio_set_level(GPIO_USB_C1_20V_EN, 0);
- break;
- default:
- panic("Invalid charge port\n");
- break;
- }
-
- CPRINTS("New chg p%d", charge_port);
-
- 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_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(MAX(charge_ma,
- CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
-/**
- * Return if VBUS is sagging too low
- */
-int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
-{
- return 0;
-}
-
-/* Called on AP S5 -> S3 transition */
-static void board_chipset_startup(void)
-{
- /* Enable USB-A port. */
- gpio_set_level(GPIO_USB1_ENABLE, 1);
-
- /* Enable Trackpad */
- gpio_set_level(GPIO_EN_TRACKPAD, 1);
-
- /* Enable Touchscreen */
- gpio_set_level(GPIO_EN_TOUCHSCREEN, 1);
-
- /* Enable Codec */
- gpio_set_level(GPIO_EN_ALC_CLK, 1);
-
- /*
- * TODO: Remove after thermal control table is provided
- */
- fan_set_duty(0, 75);
-}
-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_USB1_ENABLE, 0);
-
- /* Disable Trackpad */
- gpio_set_level(GPIO_EN_TRACKPAD, 0);
-
- /* Disable Touchscreen */
- gpio_set_level(GPIO_EN_TOUCHSCREEN, 0);
-
- /* Disable Codec */
- gpio_set_level(GPIO_EN_ALC_CLK, 0);
-}
-DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
-
-void chipset_do_shutdown(void)
-{
-
-}
-
-void board_hibernate_late(void)
-{
- int i;
- const uint32_t hibernate_pins[][2] = {
- /* Turn off LEDs in hibernate */
- {GPIO_BAT_LED_GREEN, GPIO_INPUT | GPIO_PULL_UP},
- {GPIO_BAT_LED_AMBER, GPIO_INPUT | GPIO_PULL_UP},
- {GPIO_PWR_LED_GREEN, GPIO_INPUT | GPIO_PULL_UP},
- {GPIO_LID_OPEN, GPIO_INT_RISING | GPIO_PULL_DOWN},
-
- {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, 0x7F, GPIO_INPUT | GPIO_PULL_UP);
- gpio_set_flags_by_mask(0x0, 0xE0, GPIO_INPUT | GPIO_PULL_UP);
- /* KBD_KSO2 needs to have a pull-down enabled instead of pull-up */
- gpio_set_flags_by_mask(0x1, 0x80, GPIO_INPUT | GPIO_PULL_DOWN);
-}
-
-/* Motion sensors */
-/* Mutexes */
-static struct mutex g_lid_mutex;
-struct kionix_accel_data g_kxcj9_data;
-
-struct motion_sensor_t motion_sensors[] = {
- [LID_ACCEL] = {
- .name = "Lid Accel",
- .active_mask = SENSOR_ACTIVE_S0_S3,
- .chip = MOTIONSENSE_CHIP_KXCJ9,
- .type = MOTIONSENSE_TYPE_ACCEL,
- .location = MOTIONSENSE_LOC_LID,
- .drv = &kionix_accel_drv,
- .mutex = &g_lid_mutex,
- .drv_data = &g_kxcj9_data,
- .port = I2C_PORT_LID_ACCEL,
- .addr = KXCJ9_ADDR1,
- .rot_standard_ref = NULL, /* Identity matrix. */
- .default_range = 2, /* g, enough for laptop. */
- .min_frequency = KXCJ9_ACCEL_MIN_FREQ,
- .max_frequency = KXCJ9_ACCEL_MAX_FREQ,
- .config = {
- /* AP: by default use EC settings */
- [SENSOR_CONFIG_AP] = {
- .odr = 0,
- .ec_rate = 0,
- },
- /* Setup for AP for rotation detection */
- [SENSOR_CONFIG_EC_S0] = {
- .odr = 10000 | ROUND_UP_FLAG,
- .ec_rate = 0,
- },
- [SENSOR_CONFIG_EC_S3] = {
- .odr = 0,
- .ec_rate = 0,
- },
- [SENSOR_CONFIG_EC_S5] = {
- .odr = 0,
- .ec_rate = 0,
- },
- },
- },
+/* I2C port map. */
+const struct i2c_port_t i2c_ports[] = {
+ {"power", I2C_PORT_POWER, 100, GPIO_I2C0_SCL, GPIO_I2C0_SDA},
+ {"tcpc0", I2C_PORT_TCPC0, 1000, GPIO_I2C1_SCL, GPIO_I2C1_SDA},
+ {"tcpc1", I2C_PORT_TCPC1, 1000, GPIO_I2C2_SCL, GPIO_I2C2_SDA},
+ {"thermal", I2C_PORT_THERMAL, 400, GPIO_I2C3_SCL, GPIO_I2C3_SDA},
+ {"sensor", I2C_PORT_SENSOR, 400, GPIO_I2C7_SCL, GPIO_I2C7_SDA},
};
-const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-
-void board_hibernate(void)
-{
- /*
- * To support hibernate called from console commands, ectool commands
- * and key sequence, shutdown the AP before hibernating.
- */
- chipset_do_shutdown();
-
- /* Added delay to allow AP to settle down */
- msleep(100);
-}
+const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-struct {
- enum board_version version;
- int thresh_mv;
-} const board_versions[] = {
- /* Vin = 3.3V, R1 = 46.4K, R2 values listed below */
- { BOARD_VERSION_1, 328 * 1.03 }, /* 5.11 Kohm */
- { BOARD_VERSION_2, 670 * 1.03 }, /* 11.8 Kohm */
- { BOARD_VERSION_3, 1012 * 1.03 }, /* 20.5 Kohm */
- { BOARD_VERSION_4, 1357 * 1.03 }, /* 32.4 Kohm */
- { BOARD_VERSION_5, 1690 * 1.03 }, /* 48.7 Kohm */
- { BOARD_VERSION_6, 2020 * 1.03 }, /* 73.2 Kohm */
- { BOARD_VERSION_7, 2352 * 1.03 }, /* 115 Kohm */
- { BOARD_VERSION_8, 2802 * 1.03 }, /* 261 Kohm */
+const struct button_config buttons[CONFIG_BUTTON_COUNT] = {
+ {"Volume Down", KEYBOARD_BUTTON_VOLUME_DOWN, GPIO_VOLDN_BTN_ODL,
+ 30 * MSEC, 0},
+ {"Volume Up", KEYBOARD_BUTTON_VOLUME_UP, GPIO_VOLUP_BTN_ODL,
+ 30 * MSEC, 0},
};
-BUILD_ASSERT(ARRAY_SIZE(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 < board_versions[i].thresh_mv) {
- version = board_versions[i].version;
- break;
- }
- }
-
- CPRINTS("Board version: %d\n", version);
- return version;
-}
/* Keyboard scan setting */
struct keyboard_scan_config keyscan_config = {
- /*
- * F3 key scan cycle completed but scan input is not
- * charging to logic high when EC start scan next
- * column for "T" key, so we set .output_settle_us
- * to 80us from 50us.
- */
- .output_settle_us = 80,
- .debounce_down_us = 9 * MSEC,
+ /* Extra delay when KSO2 is tied to Cr50. */
+ .output_settle_us = 60,
+ .debounce_down_us = 6 * MSEC,
.debounce_up_us = 30 * MSEC,
- .scan_period_us = 3 * MSEC,
+ .scan_period_us = 1500,
.min_post_scan_delay_us = 1000,
- .poll_timeout_us = 100 * MSEC,
+ .poll_timeout_us = SECOND,
.actual_key_mask = {
- 0x14, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff,
+ 0x3c, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff,
0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */
},
};
diff --git a/board/grunt/board.h b/board/grunt/board.h
index ce750d42dc..bb15a7e0bf 100644
--- a/board/grunt/board.h
+++ b/board/grunt/board.h
@@ -8,293 +8,72 @@
#ifndef __CROS_EC_BOARD_H
#define __CROS_EC_BOARD_H
-/*
- * By default, enable all console messages excepted HC, ACPI and event:
- * The sensor stack is generating a lot of activity.
- */
-#define CC_DEFAULT (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC)))
-#undef CONFIG_HOSTCMD_DEBUG_MODE
-#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF
-
-/* EC console commands */
-#define CONFIG_CMD_ACCELS
-#define CONFIG_CMD_ACCEL_INFO
-#define CONFIG_CMD_BATT_MFG_ACCESS
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
-#define CONFIG_CMD_CHARGER_PSYS
-
-/* Battery */
-#define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION"
-#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_CHARGE_RAMP_SW
-#define CONFIG_CHARGER
-#define CONFIG_CHARGER_V2
-#define CONFIG_CHARGER_ISL9237
-#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 2137
-#undef CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT
-#undef CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW
-#undef CONFIG_CHARGER_MAINTAIN_VBAT
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
-#define CONFIG_USB_CHARGER
-#undef CONFIG_CHARGER_PROFILE_OVERRIDE
-#undef CONFIG_CHARGER_PROFILE_OVERRIDE_COMMON
-#define CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT
-
-/* USB-A config */
-#define CONFIG_USB_PORT_POWER_SMART
-#define CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE USB_CHARGE_MODE_CDP
-#define CONFIG_USB_PORT_POWER_SMART_SIMPLE
-#undef CONFIG_USB_PORT_POWER_SMART_PORT_COUNT
-#define CONFIG_USB_PORT_POWER_SMART_PORT_COUNT 1
-#define GPIO_USB1_ILIM_SEL GPIO_USB_A_CHARGE_EN_L
-#define GPIO_USB_CTL1 GPIO_USB_A_CHARGE_EN_L
+/* Optional features */
+#define CONFIG_HIBERNATE_PSL
+#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands. */
+
+/* NPCX7 config */
+#define NPCX_UART_MODULE2 1 /* GPIO64/65 are used as UART pins. */
+#define NPCX_TACH_SEL2 0 /* No tach. */
+#define NPCX7_PWM1_SEL 0 /* GPIO C2 is not used as PWM1. */
+
+/* Internal SPI flash on NPCX7 */
+/* Flash is 1MB but reserve half for future use. */
+#define CONFIG_FLASH_SIZE (512 * 1024)
+#define CONFIG_SPI_FLASH_REGS
+#define CONFIG_SPI_FLASH_W25Q80 /* Internal SPI flash type. */
-/* USB PD config */
-#define CONFIG_CASE_CLOSED_DEBUG_EXTERNAL
-#define CONFIG_CMD_PD_CONTROL
-#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_DUAL_ROLE_AUTO_TOGGLE
-#define CONFIG_USB_PD_DISCHARGE
-#define CONFIG_USB_PD_DISCHARGE_TCPC
-#define CONFIG_USB_PD_LOGGING
-#define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0
-#define CONFIG_USB_PD_PORT_COUNT 2
-#undef CONFIG_USB_PD_VBUS_DETECT_CHARGER
-#define ADC_VBUS -1
-#define CONFIG_USB_PD_TCPC_LOW_POWER
-#define CONFIG_USB_PD_TCPM_MUX
-#define CONFIG_USB_PD_TCPM_PS8751
-#define CONFIG_USB_PD_TCPM_TCPCI
-#define CONFIG_USB_PD_TRY_SRC
-#define CONFIG_USB_POWER_DELIVERY
-#define CONFIG_USB_PD_COMM_LOCKED
+/* EC Modules */
+#define CONFIG_ADC
+#define CONFIG_I2C
+#define CONFIG_LPC
-#define CONFIG_USBC_SS_MUX
-#define CONFIG_USBC_SS_MUX_DFP_ONLY
-#define CONFIG_USBC_VCONN
-#define CONFIG_USBC_VCONN_SWAP
+#define CONFIG_BOARD_VERSION
+#define CONFIG_BUTTON_COUNT 2
-/* SoC / PCH */
-#define CONFIG_LPC
#define CONFIG_CHIPSET_STONEY
#define CONFIG_CHIPSET_RESET_HOOK
-#define CONFIG_POWER_BUTTON
-#define CONFIG_POWER_BUTTON_X86
+#define CONFIG_EXTPOWER_GPIO
#define CONFIG_POWER_COMMON
#define CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
-#define GPIO_PCH_WAKE_L 0
+#define CONFIG_POWER_BUTTON
+#define CONFIG_POWER_BUTTON_X86
+#define CONFIG_UART_HOST 0
-/* EC */
-#define CONFIG_ADC
-#define CONFIG_BOARD_VERSION
-#define CONFIG_BOARD_SPECIFIC_VERSION
-#undef CONFIG_BUTTON_COUNT
-#define CONFIG_EXTPOWER_GPIO
-#undef CONFIG_EXTPOWER_DEBOUNCE_MS
-#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
-#define CONFIG_FPU
-#define CONFIG_HOSTCMD_FLASH_SPI_INFO
-#define CONFIG_I2C
#define CONFIG_I2C_MASTER
+
#define CONFIG_KEYBOARD_BOARD_CONFIG
-#define CONFIG_KEYBOARD_PROTOCOL_8042
#define CONFIG_KEYBOARD_COL2_INVERTED
-#define CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI2
-#define CONFIG_LED_COMMON
-#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_FANS 1
-#define CONFIG_TEMP_SENSOR
-#define CONFIG_TEMP_SENSOR_G781
-#define CONFIG_SCI_GPIO GPIO_PCH_SCI_L
-#define CONFIG_UART_HOST 0
-#define CONFIG_VBOOT_HASH
-#define CONFIG_BACKLIGHT_LID
-#define CONFIG_WIRELESS
-#define CONFIG_WIRELESS_SUSPEND EC_WIRELESS_SWITCH_WLAN_POWER
-#define CONFIG_WLAN_POWER_ACTIVE_LOW
-#define WIRELESS_GPIO_WLAN_POWER GPIO_WIRELESS_GPIO_WLAN_POWER
-#define CONFIG_BC12_DETECT_PI3USB9281
-#define CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT 2
-
-/*
- * During shutdown sequence TPS65094x PMIC turns off the sensor rails
- * asynchronously to the EC. If we access the sensors when the sensor power
- * rails are off we get I2C errors. To avoid this issue, defer switching
- * the sensors rate if in S3. By the time deferred function is serviced if
- * the chipset is in S5 we can back out from switching the sensor rate.
- *
- * Time taken by V1P8U rail to go down from S3 is 30ms to 60ms hence defer
- * the sensor switching after 60ms.
- */
-#undef CONFIG_MOTION_SENSE_SUSPEND_DELAY_US
-#define CONFIG_MOTION_SENSE_SUSPEND_DELAY_US (MSEC * 60)
-
-#define CONFIG_FLASH_SIZE 524288
-#define CONFIG_SPI_FLASH_REGS
-#define CONFIG_SPI_FLASH_W25X40
-
-/*
- * 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*/
-#define NPCX_TACH_SEL2 1 /* 0:GPIO40/73 1:GPIO93/A6 as TACH */
-
-/* I2C ports */
-#define I2C_PORT_THERMAL NPCX_I2C_PORT1
-#define I2C_PORT_GYRO NPCX_I2C_PORT2
-#define I2C_PORT_LID_ACCEL NPCX_I2C_PORT2
-#define I2C_PORT_ALS NPCX_I2C_PORT2
-#define I2C_PORT_BARO NPCX_I2C_PORT2
-#define I2C_PORT_BATTERY NPCX_I2C_PORT3
-#define I2C_PORT_CHARGER NPCX_I2C_PORT3
-/* Accelerometer and Gyroscope are the same device. */
-#define I2C_PORT_ACCEL I2C_PORT_GYRO
-
-/* Sensors */
-#define CONFIG_MKBP_EVENT
-#define CONFIG_MKBP_USE_HOST_EVENT
-#define CONFIG_ACCEL_KXCJ9
-#define CONFIG_ALS_AL3010
-#define AL3010_I2C_ADDR AL3010_I2C_ADDR1
-#undef CONFIG_LID_ANGLE
-#undef CONFIG_LID_ANGLE_UPDATE
-#undef CONFIG_LID_ANGLE_SENSOR_BASE
-#undef CONFIG_LID_ANGLE_SENSOR_LID
-
-/* FIFO size is in power of 2. */
-#define CONFIG_ACCEL_FIFO 1024
-
-/* Depends on how fast the AP boots and typical ODRs */
-#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO / 3)
+#define CONFIG_KEYBOARD_PROTOCOL_8042
+#define I2C_PORT_BATTERY I2C_PORT_POWER
+#define I2C_PORT_POWER NPCX_I2C_PORT0_0
+#define I2C_PORT_TCPC0 NPCX_I2C_PORT1_0
+#define I2C_PORT_TCPC1 NPCX_I2C_PORT2_0
+#define I2C_PORT_THERMAL NPCX_I2C_PORT3_0
+#define I2C_PORT_SENSOR NPCX_I2C_PORT7_0
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
#include "registers.h"
-/* ADC signal */
enum adc_channel {
- ADC_IMON1, /* ADC0 */
- ADC_IMON2, /* ADC1 */
- ADC_BOARD_ID, /* ADC2 */
+ ADC_TEMP_SENSOR_CHARGER,
+ ADC_TEMP_SENSOR_SOC,
ADC_CH_COUNT
};
-enum pwm_channel {
- PWM_CH_FAN,
- /* Number of PWM channels */
- PWM_CH_COUNT
-};
-
-enum fan_channel {
- FAN_CH_0,
- /* Number of FAN channels */
- FAN_CH_COUNT
-};
-
-enum mft_channel {
- MFT_CH_0,
- /* Number of MFT channels */
- MFT_CH_COUNT
-};
-
enum power_signal {
- X86_SLP_S3_N = 0,
+ X86_SLP_S3_N,
X86_SLP_S5_N,
+ X86_VGATE,
X86_SPOK,
- X86_ALW_PG,
-
- /* Number of X86 signals */
POWER_SIGNAL_COUNT
};
-enum temp_sensor_id {
- TEMP_SENSOR_I2C_G781_LOCAL = 0,
- TEMP_SENSOR_I2C_G781_REMOTE1,
- TEMP_SENSOR_BATTERY,
- TEMP_SENSOR_COUNT
-};
-
-/* Light sensors */
-enum als_id {
- ALS_AL3010 = 0,
-
- ALS_COUNT
-};
-
-/*
- * Motion sensors:
- * When reading through IO memory is set up for sensors (LPC is used),
- * the first 2 entries must be accelerometers, then gyroscope.
- * For BMI160, accel, gyro and compass sensors must be next to each other.
- */
-enum sensor_id {
- LID_ACCEL = 0,
-};
-
-enum 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,
-};
-
-/* 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
-
-/* Request the max voltage for type-c adapter */
-#define PD_PREFER_HIGH_VOLTAGE
-
-/* Reset PD MCU */
void board_reset_pd_mcu(void);
-int board_get_version(void);
-
-/* Sensors without hardware FIFO are in forced mode */
-#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL)
-
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/grunt/build.mk b/board/grunt/build.mk
index 728d027803..ec727e96c0 100644
--- a/board/grunt/build.mk
+++ b/board/grunt/build.mk
@@ -7,8 +7,9 @@
#
CHIP:=npcx
-CHIP_VARIANT:=npcx5m6g
+CHIP_FAMILY:=npcx7
+CHIP_VARIANT:=npcx7m6f
-board-y=board.o led.o
+board-y=board.o
board-$(CONFIG_BATTERY_SMART)+=battery.o
board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o
diff --git a/board/grunt/ec.tasklist b/board/grunt/ec.tasklist
index 40ef31b65a..1cc4d81ac5 100644
--- a/board/grunt/ec.tasklist
+++ b/board/grunt/ec.tasklist
@@ -22,20 +22,9 @@
#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(CHG_RAMP, chg_ramp_task, NULL, 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_ALWAYS(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, LARGER_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(USB_CHG_P0, usb_charger_task, NULL, TASK_STACK_SIZE) \
- TASK_ALWAYS(USB_CHG_P1, usb_charger_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)
-
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, TASK_STACK_SIZE)
diff --git a/board/grunt/gpio.inc b/board/grunt/gpio.inc
index 45d6b81f3a..406c350d9b 100644
--- a/board/grunt/gpio.inc
+++ b/board/grunt/gpio.inc
@@ -8,128 +8,90 @@
/* Declare symbolic names for all the GPIOs that we care about.
* Note: Those with interrupt handlers must be declared first. */
-GPIO_INT(USB_C0_PD_INT_ODL, PIN(3, 7), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event) /* from Parade TCPC1 */
-GPIO_INT(USB_C1_PD_INT_ODL, PIN(B, 1), GPIO_INT_FALLING | GPIO_PULL_UP, tcpc_alert_event) /* from Parade TCPC2 */
-
-GPIO_INT(USB_C0_BC12_INT_L, PIN(0, 0), GPIO_INT_FALLING | GPIO_PULL_UP, usb0_evt)
-GPIO_INT(USB_C1_BC12_INT_L, PIN(8, 5), GPIO_INT_FALLING | GPIO_PULL_UP, usb1_evt)
-
-GPIO_INT(PCH_SLP_S5_L, PIN(8, 6), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S5_L */
-GPIO_INT(PCH_SLP_S3_L, PIN(7, 3), GPIO_INT_BOTH, power_signal_interrupt) /* SLP_S3_L */
-
-GPIO_INT(AC_PRESENT, PIN(C, 1), GPIO_INT_BOTH, extpower_interrupt) /* ACOK_OD from chargerIC */
-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(WP_L, PIN(4, 0), GPIO_INT_BOTH, switch_interrupt) /* EC_WP_ODL */
-
-GPIO(LID_ACCEL_INT_L, PIN(C, 7), GPIO_INPUT | GPIO_PULL_UP)
-GPIO(ALS_INT_L, PIN(0, 2), GPIO_INPUT | GPIO_PULL_UP)
-
-/* I2C GPIOs will be set to alt. function later. */
-GPIO(EC_I2C_THERMAL_SDA, PIN(8, 7), GPIO_INPUT) /* Thermel sensor & APU */
-GPIO(EC_I2C_THERMAL_SCL, PIN(9, 0), GPIO_INPUT) /* Thermel sensor & APU */
-GPIO(EC_I2C_SENSOR_SDA, PIN(9, 1), GPIO_INPUT) /* Sensor board ( G-sensor, light sensor ) */
-GPIO(EC_I2C_SENSOR_SCL, PIN(9, 2), GPIO_INPUT) /* Sensor board ( G-sensor, light sensor ) */
-GPIO(EC_I2C_USB_C0_PD_SDA, PIN(B, 4), GPIO_INPUT) /* PD1 */
-GPIO(EC_I2C_USB_C0_PD_SCL, PIN(B, 5), GPIO_INPUT) /* PD1 */
-GPIO(EC_I2C_USB_C1_PD_SDA, PIN(B, 2), GPIO_INPUT) /* PD2 */
-GPIO(EC_I2C_USB_C1_PD_SCL, PIN(B, 3), GPIO_INPUT) /* PD2 */
-GPIO(EC_I2C_POWER_SDA, PIN(D, 0), GPIO_INPUT) /* battery & charger */
-GPIO(EC_I2C_POWER_SCL, PIN(D, 1), GPIO_INPUT) /* battery & charger */
-
-/*
- * LPC:
- * Pins 46, 47, 51, 52, 53, 54, 55, default to LPC mode.
- * Pin 56 (CLKRUN#) defaults to GPIO mode.
- * Pin 57 (SER_IRQ) defaults to LPC mode.
- */
-GPIO(PCH_SMI_L, PIN(A, 6), GPIO_ODR_HIGH) /* EC_SMI_ODL */
-GPIO(PCH_SCI_L, PIN(A, 7), GPIO_ODR_HIGH) /* EC_SCI_ODL */
-GPIO(PCH_SLP_S0_L, PIN(7, 5), GPIO_INPUT) /* SLP_S0_L */
-
-/*
- * 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(APU_RST_L, PIN(7, 2), GPIO_INPUT) /* reserved */
-GPIO(ENTERING_RW, PIN(7, 6), GPIO_OUTPUT) /* EC_ENTERING_RW */
-GPIO(EC_BATT_PRES_L, PIN(3, 4), GPIO_INPUT)
-
-GPIO(PCH_RSMRST_L, PIN(7, 0), GPIO_OUT_LOW)
-GPIO(VR_ON, PIN(3, 3), GPIO_OUTPUT)
-GPIO(VGATE, PIN(5, 0), GPIO_INPUT)
-GPIO(SPOK, PIN(6, 0), GPIO_INPUT)
-GPIO(P095VALW_EN, PIN(C, 6), GPIO_OUTPUT)
-GPIO(P095VALW_PG, PIN(7, 1), GPIO_INPUT)
-GPIO(PCH_SYS_PWROK, PIN(E, 7), GPIO_OUT_LOW) /* EC_PCH_PWROK */
-GPIO(GA20, PIN(A, 5), GPIO_ODR_HIGH)
-GPIO(G3_SLEEP_EN, PIN(C, 2), GPIO_OUT_LOW)
-GPIO(KBRST_L, PIN(C, 5), GPIO_ODR_HIGH)
-
-GPIO(EN_TOUCHSCREEN, PIN(8, 3), GPIO_OUT_LOW)
-GPIO(EN_TRACKPAD, PIN(3, 2), GPIO_OUT_LOW)
-GPIO(ENABLE_BACKLIGHT, PIN(9, 7), GPIO_ODR_HIGH) /* EC_BL_EN_OD */
-GPIO(WIRELESS_GPIO_WLAN_POWER, PIN(6, 6), GPIO_ODR_HIGH)
-GPIO(EN_ALC_CLK, PIN(B, 0), GPIO_OUT_LOW) /* Codec OSC EN */
-
-GPIO(CPU_PROCHOT, PIN(A, 3), GPIO_ODR_HIGH) /* PCH_PROCHOT_ODL */
-
-GPIO(PCH_PWRBTN_L, PIN(0, 1), GPIO_ODR_HIGH) /* EC_PCH_PWR_BTN_ODL */
-GPIO(USB_C0_HPD_ODL, PIN(9, 4), GPIO_INPUT)
-GPIO(USB_C1_HPD_ODL, PIN(9, 5), GPIO_INPUT)
-
-/* 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 */
-
-GPIO(USB_A_CHARGE_EN_L, PIN(3, 6), GPIO_OUT_LOW)
-GPIO(USB1_ENABLE, PIN(4, 1), GPIO_OUT_LOW)
-
-GPIO(USB_C0_PD_RST_ODL, PIN(0, 3), GPIO_OUT_LOW)
-GPIO(USB_C1_PD_RST_ODL, PIN(7, 4), GPIO_ODR_LOW)
-
-GPIO(USB_C0_20V_EN, PIN(4, 2), GPIO_OUT_LOW) /* EN_USB_charge1 */
-GPIO(USB_C1_20V_EN, PIN(6, 3), GPIO_OUT_LOW) /* EN_USB_charge2 */
-
-GPIO(USB_C0_5V_EN, PIN(D, 3), GPIO_OUT_LOW) /* EN_USB_C0_5V_OUT, Enable C0 */
-GPIO(USB_C1_5V_EN, PIN(D, 2), GPIO_OUT_LOW) /* EN_USB_C1_5V_OUT, Enable C1 */
-
-GPIO(PWR_LED_GREEN, PIN(C, 4), GPIO_ODR_HIGH)
-GPIO(BAT_LED_GREEN, PIN(8, 4), GPIO_ODR_HIGH)
-GPIO(BAT_LED_AMBER, PIN(B, 6), GPIO_ODR_HIGH)
-
-/*
- * 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) /* IMON1 */
-ALTERNATE(PIN(4, 5), 6, MODULE_ADC, 0) /* IMON2 */
-
-ALTERNATE(PIN_MASK(8, 0x80), 1, MODULE_I2C, 0) /* GPIO87 for EC_I2C_THERMAL_SDA */
-ALTERNATE(PIN_MASK(9, 0x01), 1, MODULE_I2C, 0) /* GPIO90 for EC_I2C_THERMAL_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(D, 0x03), 1, MODULE_I2C, 0) /* GPIOD1-D0 for EC_I2C_POWER_SDA/SCL */
-
-ALTERNATE(PIN_MASK(C, 0x08), 7, MODULE_PWM, 0) /* PWM0 for PWM/FAN Test GPIOC3 */
-ALTERNATE(PIN_MASK(9, 0x08), 3, MODULE_PWM, 0) /* MFT-1/TA1_TACH1 for FAN GPIO93 */
-
-/* FIXME: Make UART RX an interrupt? */
-ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* UART from EC to Servo */
+GPIO_INT(USB_C0_PD_INT_ODL, PIN(6, 1), GPIO_INT_FALLING, tcpc_alert_event)
+GPIO_INT(USB_C1_PD_INT_ODL, PIN(F, 5), GPIO_INT_FALLING, tcpc_alert_event)
+GPIO_INT(PCH_SLP_S3_L, PIN(A, 6), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(PCH_SLP_S5_L, PIN(A, 3), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(VGATE, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(SPOK, PIN(6, 3), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(POWER_BUTTON_L, PIN(0, 1), GPIO_INT_BOTH, power_button_interrupt)
+GPIO_INT(LID_OPEN, PIN(D, 2), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, lid_interrupt)
+GPIO_INT(AC_PRESENT, PIN(0, 0), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, extpower_interrupt)
+GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt)
+GPIO_INT(VOLDN_BTN_ODL, PIN(7, 0), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
+GPIO_INT(VOLUP_BTN_ODL, PIN(7, 5), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt)
+
+GPIO(EN_PWR_A, PIN(E, 2), GPIO_OUT_HIGH) /* Enable Power */
+GPIO(EN_PP1800_SENSOR, PIN(6, 7), GPIO_OUT_HIGH) /* Enable Power */
+GPIO(ENABLE_BACKLIGHT, PIN(D, 3), GPIO_OUT_LOW) /* Enable Backlight */
+GPIO(PCH_RSMRST_L, PIN(C, 2), GPIO_OUT_LOW) /* RSMRST# to SOC */
+GPIO(PCH_PWRBTN_L, PIN(C, 1), GPIO_OUT_HIGH) /* Power Button to SOC */
+GPIO(PCH_WAKE_L, PIN(7, 4), GPIO_OUT_HIGH) /* Wake SOC */
+GPIO(PCH_RCIN_L, PIN(0, 2), GPIO_OUT_HIGH) /* Cold Reset to SOC */
+GPIO(CCD_MODE_ODL, PIN(E, 3), GPIO_INPUT) /* Case Closed Debug Mode */
+GPIO(ENTERING_RW, PIN(E, 1), GPIO_OUT_LOW) /* EC Entering RW */
+GPIO(EC_BATT_PRES_ODL, PIN(E, 5), GPIO_INPUT) /* Battery Present */
+GPIO(PCH_SYS_PWROK, PIN(3, 7), GPIO_OUT_LOW) /* Power OK to SOC */
+GPIO(EC_APU_RST, PIN(E, 4), GPIO_INPUT) /* Reset to SOC */
+GPIO(CPU_PROCHOT, PIN(3, 4), GPIO_INPUT | GPIO_PULL_UP) /* PROCHOT to SOC */
+GPIO(EC_APU_ALERT_L, PIN(4, 0), GPIO_INPUT | GPIO_PULL_UP) /* Alert to SOC */
+
+/* I2C pins - these will be reconfigured for alternate function below */
+GPIO(I2C0_SCL, PIN(B, 5), GPIO_INPUT) /* EC_I2C_POWER_SCL */
+GPIO(I2C0_SDA, PIN(B, 4), GPIO_INPUT) /* EC_I2C_POWER_SDA */
+GPIO(I2C1_SCL, PIN(9, 0), GPIO_INPUT) /* EC_I2C_USB_C0_PD_SCL */
+GPIO(I2C1_SDA, PIN(8, 7), GPIO_INPUT) /* EC_I2C_USB_C0_PD_SDA */
+GPIO(I2C2_SCL, PIN(9, 2), GPIO_INPUT) /* EC_I2C_USB_C1_PD_SCL */
+GPIO(I2C2_SDA, PIN(9, 1), GPIO_INPUT) /* EC_I2C_USB_C1_PD_SDA */
+GPIO(I2C3_SCL, PIN(D, 1), GPIO_INPUT) /* APU_SIC */
+GPIO(I2C3_SDA, PIN(D, 0), GPIO_INPUT) /* APU_SID */
+GPIO(I2C7_SCL, PIN(B, 3), GPIO_INPUT) /* EC_I2C_SENSOR_SCL */
+GPIO(I2C7_SDA, PIN(B, 2), GPIO_INPUT) /* EC_I2C_SENSOR_SDA */
+
+GPIO(PCH_SCI_ODL, PIN(7, 6), GPIO_ODR_HIGH)
+GPIO(PCH_SMI_ODL, PIN(C, 6), GPIO_ODR_HIGH)
+GPIO(PCH_SLP_S0_L, PIN(A, 4), GPIO_INPUT)
+
+GPIO(EN_USB_A0_5V, PIN(A, 0), GPIO_OUT_LOW) /* Enable A0 5V Charging */
+GPIO(EN_USB_A1_5V, PIN(C, 0), GPIO_OUT_LOW) /* Enable A1 5V Charging */
+GPIO(USB_A0_CHARGE_EN_L, PIN(A, 2), GPIO_OUT_HIGH) /* Enable A0 1.5A Charging */
+GPIO(USB_A1_CHARGE_EN_L, PIN(D, 4), GPIO_OUT_HIGH) /* Enable A1 1.5A Charging */
+GPIO(EN_USB_C0_TCPC_PWR, PIN(6, 0), GPIO_OUT_LOW) /* Enable C0 TCPC Power */
+GPIO(USB_C0_OC_L, PIN(7, 3), GPIO_OUT_HIGH) /* C0 Over Current */
+GPIO(USB_C1_OC_L, PIN(D, 7), GPIO_OUT_HIGH) /* C1 Over Current */
+GPIO(USB_C0_PD_RST_L, PIN(F, 1), GPIO_OUT_HIGH) /* C0 PD Reset */
+GPIO(USB_C1_PD_RST_L, PIN(D, 5), GPIO_OUT_HIGH) /* C1 PD Reset */
+GPIO(USB_C0_SWCTL_INT_ODL, PIN(0, 3), GPIO_INPUT) /* C0 Switch Control Interrupt */
+GPIO(USB_C1_SWCTL_INT_ODL, PIN(0, 4), GPIO_INPUT) /* C1 Switch Control Interrupt */
+GPIO(USB_C0_BC12_VBUS_ON_ODL, PIN(8, 2), GPIO_ODR_HIGH) /* C0 BC1.2 Power */
+GPIO(USB_C1_BC12_VBUS_ON_ODL, PIN(B, 1), GPIO_ODR_HIGH) /* C1 BC1.2 Power */
+GPIO(USB_C0_BC12_CHG_MAX, PIN(6, 2), GPIO_INPUT) /* C0 BC1.2 Detect */
+GPIO(USB_C1_BC12_CHG_MAX, PIN(8, 3), GPIO_INPUT) /* C1 BC1.2 Detect */
+
+/* Board ID */
+GPIO(BOARD_VERSION1, PIN(9, 6), GPIO_INPUT)
+GPIO(BOARD_VERSION2, PIN(9, 3), GPIO_INPUT)
+GPIO(BOARD_VERSION3, PIN(8, 0), GPIO_INPUT)
+GPIO(SKU_ID1, PIN(F, 0), GPIO_INPUT)
+GPIO(SKU_ID2, PIN(4, 1), GPIO_INPUT)
+
+/* Alternate functions GPIO definitions */
+ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, GPIO_PULL_UP) /* UART from EC to Servo */
+ALTERNATE(PIN_MASK(B, 0x30), 1, MODULE_I2C, GPIO_PULL_UP) /* I2C0 */
+ALTERNATE(PIN_MASK(9, 0x07), 1, MODULE_I2C, GPIO_PULL_UP) /* I2C1 SCL / I2C2 */
+ALTERNATE(PIN_MASK(8, 0x80), 1, MODULE_I2C, GPIO_PULL_UP) /* I2C1 SDA */
+ALTERNATE(PIN_MASK(D, 0x03), 1, MODULE_I2C, GPIO_PULL_UP) /* I2C3 */
+ALTERNATE(PIN_MASK(B, 0x0C), 1, MODULE_I2C, GPIO_PULL_UP) /* I2C7 */
+ALTERNATE(PIN_MASK(4, 0x30), 1, MODULE_ADC, 0) /* ADC0-1 */
+
+/* Keyboard Pins */
+ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_INPUT) /* KSI_00-01 */
+ALTERNATE(PIN_MASK(2, 0xFC), 0, MODULE_KEYBOARD_SCAN, GPIO_INPUT) /* KSI_02-07 */
+ALTERNATE(PIN_MASK(2, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) /* KSO_00-01 */
+GPIO(KBD_KSO2, PIN(1, 7), GPIO_OUT_LOW) /* KSO_02 inverted */
+ALTERNATE(PIN_MASK(1, 0x7F), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) /* KSO_03-09 */
+ALTERNATE(PIN_MASK(0, 0xE0), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) /* KSO_10-12 */
+
+/* Power Switch Logic (PSL) inputs */
+ALTERNATE(PIN_MASK(0, 0x03), 1, MODULE_PMU, 0) /* GPIO00, GPIO01 */
+ALTERNATE(PIN_MASK(D, 0x04), 1, MODULE_PMU, 0) /* GPIOD2 */