diff options
author | Bob Moragues <moragues@google.com> | 2018-11-28 14:17:04 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-12-08 11:23:22 -0800 |
commit | 014ed9cdd9ebcea19de0873b764aa3f97b381983 (patch) | |
tree | 0ce56255facc01cf0a30b4c302dad118b913e18c | |
parent | 89e13f198fce934b0f1452255b15f6244dbcabb7 (diff) | |
download | chrome-ec-014ed9cdd9ebcea19de0873b764aa3f97b381983.tar.gz |
meowth: remove meowth/zoombini overlays and repositories
BRANCH=none
BUG=b:118494679
TEST=Verify PreCQ build
Signed-off-by: Bob Moragues <moragues@chromium.org>
Change-Id: Id6889d922a2b4d812cc92ddbb35b2581d881459d
Reviewed-on: https://chromium-review.googlesource.com/1354316
Commit-Ready: Bob Moragues <moragues@chromium.org>
Tested-by: Bob Moragues <moragues@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
l--------- | board/meowth | 1 | ||||
l--------- | board/nami_fp | 2 | ||||
l--------- | board/nocturne_fp | 1 | ||||
-rw-r--r-- | board/nocturne_fp/board.c (renamed from board/meowth_fp/board.c) | 0 | ||||
-rw-r--r-- | board/nocturne_fp/board.h (renamed from board/meowth_fp/board.h) | 0 | ||||
-rw-r--r-- | board/nocturne_fp/build.mk (renamed from board/meowth_fp/build.mk) | 0 | ||||
-rw-r--r-- | board/nocturne_fp/dev_key.pem (renamed from board/meowth_fp/dev_key.pem) | 0 | ||||
-rw-r--r-- | board/nocturne_fp/ec.tasklist (renamed from board/meowth_fp/ec.tasklist) | 0 | ||||
-rwxr-xr-x | board/nocturne_fp/flash_fp_mcu (renamed from board/meowth_fp/flash_fp_mcu) | 0 | ||||
-rw-r--r-- | board/nocturne_fp/gpio.inc (renamed from board/meowth_fp/gpio.inc) | 0 | ||||
-rw-r--r-- | board/zoombini/base_detect.c | 306 | ||||
-rw-r--r-- | board/zoombini/battery.c | 114 | ||||
-rw-r--r-- | board/zoombini/board.c | 738 | ||||
-rw-r--r-- | board/zoombini/board.h | 316 | ||||
-rw-r--r-- | board/zoombini/build.mk | 14 | ||||
-rw-r--r-- | board/zoombini/ec.tasklist | 58 | ||||
-rw-r--r-- | board/zoombini/gpio.inc | 240 | ||||
-rw-r--r-- | board/zoombini/led.c | 114 | ||||
-rw-r--r-- | board/zoombini/usb_pd_policy.c | 427 | ||||
-rw-r--r-- | util/build.mk | 2 | ||||
-rwxr-xr-x | util/flash_ec | 13 |
21 files changed, 3 insertions, 2343 deletions
diff --git a/board/meowth b/board/meowth deleted file mode 120000 index 69cccffc63..0000000000 --- a/board/meowth +++ /dev/null @@ -1 +0,0 @@ -zoombini/
\ No newline at end of file diff --git a/board/nami_fp b/board/nami_fp index 643a606728..c8a3bc0df6 120000 --- a/board/nami_fp +++ b/board/nami_fp @@ -1 +1 @@ -meowth_fp
\ No newline at end of file +nocturne_fp/
\ No newline at end of file diff --git a/board/nocturne_fp b/board/nocturne_fp deleted file mode 120000 index 643a606728..0000000000 --- a/board/nocturne_fp +++ /dev/null @@ -1 +0,0 @@ -meowth_fp
\ No newline at end of file diff --git a/board/meowth_fp/board.c b/board/nocturne_fp/board.c index 84f6ae9445..84f6ae9445 100644 --- a/board/meowth_fp/board.c +++ b/board/nocturne_fp/board.c diff --git a/board/meowth_fp/board.h b/board/nocturne_fp/board.h index 5d3807c709..5d3807c709 100644 --- a/board/meowth_fp/board.h +++ b/board/nocturne_fp/board.h diff --git a/board/meowth_fp/build.mk b/board/nocturne_fp/build.mk index 2c7a5d3d73..2c7a5d3d73 100644 --- a/board/meowth_fp/build.mk +++ b/board/nocturne_fp/build.mk diff --git a/board/meowth_fp/dev_key.pem b/board/nocturne_fp/dev_key.pem index 35c0035b20..35c0035b20 100644 --- a/board/meowth_fp/dev_key.pem +++ b/board/nocturne_fp/dev_key.pem diff --git a/board/meowth_fp/ec.tasklist b/board/nocturne_fp/ec.tasklist index 6dfaaeff14..6dfaaeff14 100644 --- a/board/meowth_fp/ec.tasklist +++ b/board/nocturne_fp/ec.tasklist diff --git a/board/meowth_fp/flash_fp_mcu b/board/nocturne_fp/flash_fp_mcu index 7f5a566c13..7f5a566c13 100755 --- a/board/meowth_fp/flash_fp_mcu +++ b/board/nocturne_fp/flash_fp_mcu diff --git a/board/meowth_fp/gpio.inc b/board/nocturne_fp/gpio.inc index e0470b2cb6..e0470b2cb6 100644 --- a/board/meowth_fp/gpio.inc +++ b/board/nocturne_fp/gpio.inc diff --git a/board/zoombini/base_detect.c b/board/zoombini/base_detect.c deleted file mode 100644 index b2c4490970..0000000000 --- a/board/zoombini/base_detect.c +++ /dev/null @@ -1,306 +0,0 @@ -/* Copyright 2018 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. - */ - -/* - * Meowth base detection code. - * - * Meowth has two analog detection pins with which it monitors to determine the - * base status: the attach, and detach pins. - * - * When the voltages cross a certain threshold, after some debouncing, the base - * is deemed connected. Meowth then applies the base power and monitors for - * power faults from the eFuse as well as base disconnection. Similarly, once - * the voltages cross a different threshold, after some debouncing, the base is - * deemed disconnected. At this point, Meowth disables the base power. - */ - -#include "adc.h" -#include "chipset.h" -#include "common.h" -#include "console.h" -#include "gpio.h" -#include "hooks.h" -#include "tablet_mode.h" -#include "timer.h" -#include "util.h" - -#define CPRINTS(format, args...) cprints(CC_USB, format, ## args) - -#define DEFAULT_POLL_TIMEOUT_US (250 * MSEC) -#define DEBOUNCE_TIMEOUT_US (20 * MSEC) -#define POWER_FAULT_RETRY_INTERVAL_US (15 * MSEC) - -/* - * Number of times to attempt re-applying power within 1s when a fault occurs. - */ -#define POWER_FAULT_MAX_RETRIES 3 - -/* Thresholds for attach pin reading when power is not applied. */ -#define ATTACH_MIN_MV 300 -#define ATTACH_MAX_MV 800 - -/* Threshold for attach pin reading when power IS applied. */ -#define PWREN_ATTACH_MIN_MV 2300 - -/* Threshold for detach pin reading. */ -#define DETACH_MIN_MV 10 - - -enum base_detect_state { - BASE_DETACHED = 0, - BASE_ATTACHED_DEBOUNCE, - BASE_ATTACHED, - BASE_DETACHED_DEBOUNCE, - // Default for |forced_state|. Should be set only on |forced_state|. - BASE_NO_FORCED_STATE, -}; - -static int debug; -static enum base_detect_state state; -static enum base_detect_state forced_state = BASE_NO_FORCED_STATE; - -static void base_power_enable(int enable) -{ - /* Nothing to do if the state is the same. */ - if (gpio_get_level(GPIO_BASE_PWR_EN) == enable) - return; - - if (enable) { - /* Apply power to the base only if the AP is on or sleeping. */ - if (chipset_in_state(CHIPSET_STATE_ON | - CHIPSET_STATE_ANY_SUSPEND)) { - gpio_set_level(GPIO_BASE_PWR_EN, 1); - /* Allow time for the fault line to rise. */ - msleep(1); - /* Monitor for base power faults. */ - gpio_enable_interrupt(GPIO_BASE_PWR_FLT_L); - } - } else { - /* - * Disable power fault interrupt. It will read low when base - * power is removed. - */ - gpio_disable_interrupt(GPIO_BASE_PWR_FLT_L); - /* Now, remove power to the base. */ - gpio_set_level(GPIO_BASE_PWR_EN, 0); - } - - CPRINTS("BP: %d", enable); -} - -static void base_detect_changed(void) -{ - switch (state) { - case BASE_DETACHED: - /* Indicate that we are in tablet mode. */ - tablet_set_mode(1); - base_power_enable(0); - break; - - case BASE_ATTACHED: - /* - * TODO(b/73133611): Note, this simple logic may suffice for - * now, but we may have to revisit this. - */ - tablet_set_mode(0); - base_power_enable(1); - break; - - default: - return; - }; -} - -static int base_seems_attached(int attach_pin_mv, int detach_pin_mv) -{ - /* We can't tell if we don't have good readings. */ - if (attach_pin_mv == ADC_READ_ERROR || - detach_pin_mv == ADC_READ_ERROR) - return 0; - - if (gpio_get_level(GPIO_BASE_PWR_EN)) - return (attach_pin_mv >= PWREN_ATTACH_MIN_MV) && - (detach_pin_mv >= DETACH_MIN_MV); - else - return (attach_pin_mv <= ATTACH_MAX_MV) && - (attach_pin_mv >= ATTACH_MIN_MV) && - (detach_pin_mv <= DETACH_MIN_MV); -} - -static int base_seems_detached(int attach_pin_mv, int detach_pin_mv) -{ - /* We can't tell if we don't have good readings. */ - if (attach_pin_mv == ADC_READ_ERROR || - detach_pin_mv == ADC_READ_ERROR) - return 0; - - return (attach_pin_mv >= PWREN_ATTACH_MIN_MV) && - (detach_pin_mv <= DETACH_MIN_MV); -} - -static void set_state(enum base_detect_state new_state) -{ - if (new_state != state) { - CPRINTS("BD: st%d", new_state); - state = new_state; - } -} - -static void base_detect_deferred(void); -DECLARE_DEFERRED(base_detect_deferred); -static void base_detect_deferred(void) -{ - int attach_reading; - int detach_reading; - int timeout = DEFAULT_POLL_TIMEOUT_US; - - attach_reading = adc_read_channel(ADC_BASE_ATTACH); - detach_reading = adc_read_channel(ADC_BASE_DETACH); - - if (debug) - CPRINTS("BD st%d: att: %dmV det: %dmV", state, - attach_reading, - detach_reading); - - if (forced_state != BASE_NO_FORCED_STATE) { - if (state != forced_state) { - CPRINTS("BD Forced %s", - forced_state == BASE_ATTACHED ? - "attached" : "detached"); - set_state(forced_state); - } - return; - } - - switch (state) { - case BASE_DETACHED: - /* Check to see if a base may be attached. */ - if (base_seems_attached(attach_reading, detach_reading)) { - timeout = DEBOUNCE_TIMEOUT_US; - set_state(BASE_ATTACHED_DEBOUNCE); - } - break; - - case BASE_ATTACHED_DEBOUNCE: - /* Check to see if it's still attached. */ - if (base_seems_attached(attach_reading, detach_reading)) { - set_state(BASE_ATTACHED); - base_detect_changed(); - } else if (base_seems_detached(attach_reading, - detach_reading)) { - set_state(BASE_DETACHED); - } - break; - - case BASE_ATTACHED: - /* Check to see if a base may be detached. */ - if (base_seems_detached(attach_reading, detach_reading)) { - timeout = DEBOUNCE_TIMEOUT_US; - set_state(BASE_DETACHED_DEBOUNCE); - } - break; - - case BASE_DETACHED_DEBOUNCE: - /* Check to see if a base is still detached. */ - if (base_seems_detached(attach_reading, detach_reading)) { - set_state(BASE_DETACHED); - base_detect_changed(); - } else if (base_seems_attached(attach_reading, - detach_reading)) { - set_state(BASE_ATTACHED); - } - break; - /* TODO(b/74239259): do you want to add an interrupt? */ - - default: - break; - }; - - /* Check again in the appropriate time only if the AP is on. */ - if (chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND)) - hook_call_deferred(&base_detect_deferred_data, timeout); -}; -DECLARE_HOOK(HOOK_INIT, base_detect_deferred, HOOK_PRIO_INIT_ADC + 1); - -static void power_on_base(void) -{ - hook_call_deferred(&base_detect_deferred_data, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, power_on_base, HOOK_PRIO_DEFAULT); - -static void power_off_base(void) -{ - base_power_enable(0); -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, power_off_base, HOOK_PRIO_DEFAULT); - -static uint8_t base_power_on_attempts; -static void clear_base_power_on_attempts_deferred(void) -{ - base_power_on_attempts = 0; -} -DECLARE_DEFERRED(clear_base_power_on_attempts_deferred); - -static void check_and_reapply_base_power_deferred(void) -{ - if (state != BASE_ATTACHED) - return; - - if (base_power_on_attempts < POWER_FAULT_MAX_RETRIES) { - CPRINTS("Reapply base pwr"); - base_power_enable(1); - base_power_on_attempts++; - - hook_call_deferred(&clear_base_power_on_attempts_deferred_data, - SECOND); - } - -} -DECLARE_DEFERRED(check_and_reapply_base_power_deferred); - -void base_pwr_fault_interrupt(enum gpio_signal s) -{ - /* Inverted because active low. */ - int fault_detected = !gpio_get_level(GPIO_BASE_PWR_FLT_L); - - if (fault_detected) { - /* Turn off base power. */ - CPRINTS("Base Pwr Flt!"); - base_power_enable(0); - - /* - * Try and apply power in a bit if maybe it was just a temporary - * condition. - */ - hook_call_deferred(&check_and_reapply_base_power_deferred_data, - POWER_FAULT_RETRY_INTERVAL_US); - } -} - -static int command_basedetectdebug(int argc, char **argv) -{ - if ((argc > 1) && !parse_bool(argv[1], &debug)) - return EC_ERROR_PARAM1; - - CPRINTS("BD: %sst%d", forced_state != BASE_NO_FORCED_STATE ? - "forced " : "", state); - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(basedebug, command_basedetectdebug, "[ena|dis]", - "En/Disable base detection debug"); - - -void base_force_state(int state) -{ - if (state == 1) - forced_state = BASE_ATTACHED; - else if (state == 0) - forced_state = BASE_DETACHED; - else - forced_state = BASE_NO_FORCED_STATE; - - hook_call_deferred(&base_detect_deferred_data, 0); -} diff --git a/board/zoombini/battery.c b/board/zoombini/battery.c deleted file mode 100644 index d508e88d65..0000000000 --- a/board/zoombini/battery.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Battery pack vendor provided charging profile - */ - -#include "battery.h" -#include "battery_smart.h" -#include "common.h" -#include "ec_commands.h" -#include "extpower.h" - -/* Shutdown mode parameter to write to manufacturer access register */ -#define SB_SHUTDOWN_DATA 0x0010 - -/* Battery info for proto */ -static const struct battery_info info = { -#ifdef BOARD_ZOOMBINI - .voltage_max = 13200, - .voltage_normal = 11250, - .voltage_min = 9000, - .precharge_current = 189, - .start_charging_min_c = 0, - .start_charging_max_c = 60, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 60, -#else /* !defined(BOARD_ZOOMBINI) */ - /* Meowth battery info. */ -#if 0 /* planned pack settings */ - .voltage_max = 8780, - .voltage_normal = 7700, - .voltage_min = 6000, - .precharge_current = 160, - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 45, - .discharging_min_c = -20, - .discharging_max_c = 60, -#endif /* 0 */ - /* Borrowed eve batteries for the time being. */ - .voltage_max = TARGET_WITH_MARGIN(8800, 5), /* mV */ - .voltage_normal = 7700, - .voltage_min = 6100, /* Add 100mV for charger accuracy */ - .precharge_current = 256, /* mA */ - .start_charging_min_c = 0, - .start_charging_max_c = 46, - .charging_min_c = 10, - .charging_max_c = 50, - .discharging_min_c = 0, - .discharging_max_c = 60, -#endif /* defined(BOARD_ZOOMBINI) */ -}; - -int board_cut_off_battery(void) -{ - int rv; - - /* Ship mode command must be sent twice to take effect */ - rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); - if (rv != EC_SUCCESS) - return EC_RES_ERROR; - - rv = sb_write(SB_MANUFACTURER_ACCESS, SB_SHUTDOWN_DATA); - return rv ? EC_RES_ERROR : EC_RES_SUCCESS; -} - -const struct battery_info *battery_get_info(void) -{ - return &info; -} - -enum battery_disconnect_state battery_get_disconnect_state(void) -{ - uint8_t data[6]; - int rv; - - /* - * Take note if we find that the battery isn't in disconnect state, - * and always return NOT_DISCONNECTED without probing the battery. - * This assumes the battery will not go to disconnect state during - * runtime. - */ - static int not_disconnected; - - if (not_disconnected) - return BATTERY_NOT_DISCONNECTED; - - /* Check if battery charging + discharging is disabled. */ - rv = sb_read_mfgacc(PARAM_OPERATION_STATUS, - SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data)); - if (rv) - return BATTERY_DISCONNECT_ERROR; - if (~data[3] & (BATTERY_DISCHARGING_DISABLED | - BATTERY_CHARGING_DISABLED)) { - not_disconnected = 1; - return BATTERY_NOT_DISCONNECTED; - } - - /* - * Battery is neither charging nor discharging. Verify that - * we didn't enter this state due to a safety fault. - */ - rv = sb_read_mfgacc(PARAM_SAFETY_STATUS, - SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data)); - if (rv || data[2] || data[3] || data[4] || data[5]) - return BATTERY_DISCONNECT_ERROR; - - /* No safety fault, battery is disconnected */ - return BATTERY_DISCONNECTED; -} diff --git a/board/zoombini/board.c b/board/zoombini/board.c deleted file mode 100644 index e7c51dc2bb..0000000000 --- a/board/zoombini/board.c +++ /dev/null @@ -1,738 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Meowth/Zoombini board-specific configuration */ - -#include "adc_chip.h" -#include "button.h" -#include "charge_manager.h" -#include "charge_state.h" -#include "charge_state_v2.h" -#include "common.h" -#include "console.h" -#include "compile_time_macros.h" -#include "driver/accelgyro_lsm6dsm.h" -#include "driver/als_opt3001.h" -#include "driver/bc12/max14637.h" -#include "driver/led/lm3630a.h" -#include "driver/pmic_tps650x30.h" -#include "driver/ppc/sn5s330.h" -#include "driver/sync.h" -#include "driver/tcpm/ps8xxx.h" -#include "ec_commands.h" -#ifdef CONFIG_HOSTCMD_ESPI_VW_SLP_SIGNALS -#include "espi.h" -#endif /* defined(CONFIG_HOSTCMD_ESPI_VW_SLP_SIGNALS) */ -#include "extpower.h" -#include "gpio.h" -#include "hooks.h" -#include "i2c.h" -#include "keyboard_scan.h" -#include "lid_switch.h" -#include "motion_sense.h" -#include "power.h" -#include "power_button.h" -#include "pwm.h" -#include "pwm_chip.h" -#include "registers.h" -#include "system.h" -#include "switch.h" -#include "task.h" -#include "tcpci.h" -#include "usb_mux.h" -#include "usb_pd_tcpm.h" -#include "usbc_ppc.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 s) -{ - int port = -1; - - switch (s) { - case GPIO_USB_C0_PD_INT_L: - port = 0; - break; - case GPIO_USB_C1_PD_INT_L: - port = 1; - break; -#ifdef BOARD_ZOOMBINI - case GPIO_USB_C2_PD_INT_L: - port = 2; - break; -#endif /* defined(BOARD_ZOOMBINI) */ - default: - return; - } - - schedule_deferred_pd_interrupt(port); -} - -#ifdef BOARD_MEOWTH -/* - * Meowth shares the TCPC Alert# line with the TI SN5S330's interrupt line. - * Therefore, we need to also check on that part. - */ -static void usb_c_interrupt(enum gpio_signal s) -{ - int port = (s == GPIO_USB_C0_PD_INT_L) ? 0 : 1; - - tcpc_alert_event(s); - sn5s330_interrupt(port); -} -#endif /* defined(BOARD_MEOWTH) */ - -#ifdef BOARD_ZOOMBINI -static void ppc_interrupt(enum gpio_signal s) -{ - switch (s) { - case GPIO_USB_C0_PPC_INT_L: - sn5s330_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_L: - sn5s330_interrupt(1); - break; - - case GPIO_USB_C2_PPC_INT_L: - sn5s330_interrupt(2); - break; - - default: - break; - - }; -} -#endif /* defined(BOARD_ZOOMBINI) */ - -#include "gpio_list.h" - -const enum gpio_signal hibernate_wake_pins[] = { - GPIO_LID_OPEN, - GPIO_AC_PRESENT, - GPIO_POWER_BUTTON_L, -}; -const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); - -const struct adc_t adc_channels[] = { -#ifdef BOARD_ZOOMBINI - [ADC_TEMP_SENSOR_SOC] = { - "SOC", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0 - }, - - [ADC_TEMP_SENSOR_CHARGER] = { - "CHARGER", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0 - }, -#else /* defined(BOARD_MEOWTH) */ - [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 - }, - - [ADC_TEMP_SENSOR_WIFI] = { - "WIFI", NPCX_ADC_CH8, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0 - }, - - [ADC_BASE_ATTACH] = { - "BASE ATTACH", NPCX_ADC_CH9, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0 - }, - - [ADC_BASE_DETACH] = { - "BASE DETACH", NPCX_ADC_CH4, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0 - }, -#endif /* defined(BOARD_ZOOMBINI) */ -}; - -/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */ -const struct pwm_t pwm_channels[] = { -#ifdef BOARD_MEOWTH - [PWM_CH_DB0_LED_RED] = { 3, PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - 2400 }, - [PWM_CH_DB0_LED_GREEN] = { 0, PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - 2400 }, - [PWM_CH_DB0_LED_BLUE] = { 2, PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - 2400 }, - [PWM_CH_DB1_LED_RED] = { 7, PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - 2400 }, - [PWM_CH_DB1_LED_GREEN] = { 5, PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - 2400 }, - [PWM_CH_DB1_LED_BLUE] = { 6, PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - 2400 }, -#else /* !defined(BOARD_MEOWTH) */ - [PWM_CH_LED_GREEN] = { 0, PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - 2400 }, - [PWM_CH_LED_RED] = { 2, PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, - 2400 }, - [PWM_CH_KBLIGHT] = { 3, 0, 100 }, -#endif /* defined(BOARD_MEOWTH) */ -}; -BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); - -/* Power signal list. Must match order of enum power_signal. */ -const struct power_signal_info power_signal_list[] = { - {GPIO_PCH_SLP_S0_L, - POWER_SIGNAL_ACTIVE_HIGH | POWER_SIGNAL_DISABLE_AT_BOOT, - "SLP_S0_DEASSERTED"}, -#ifdef CONFIG_HOSTCMD_ESPI_VW_SLP_SIGNALS - {VW_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"}, - {VW_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"}, -#else - {GPIO_PCH_SLP_S3_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S3_DEASSERTED"}, - {GPIO_PCH_SLP_S4_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_S4_DEASSERTED"}, -#endif /* defined(CONFIG_HOSTCMD_ESPI_VW_SLP_SIGNALS) */ - {GPIO_PCH_SLP_SUS_L, POWER_SIGNAL_ACTIVE_HIGH, "SLP_SUS_DEASSERTED"}, - {GPIO_RSMRST_L_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "RSMRST_L_PGOOD"}, - {GPIO_PMIC_DPWROK, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_DPWROK"}, -#ifdef BOARD_ZOOMBINI - {GPIO_PP5000_PGOOD, POWER_SIGNAL_ACTIVE_HIGH, "PP5000_A_PGOOD"}, -#endif /* defined(BOARD_ZOOMBINI) */ -}; -BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); - -/* I2C port map. */ -#ifdef BOARD_ZOOMBINI -const struct i2c_port_t i2c_ports[] = { - {"power", I2C_PORT_POWER, 100, GPIO_I2C0_SCL, GPIO_I2C0_SDA}, - {"pmic", I2C_PORT_PMIC, 400, GPIO_I2C3_SCL, GPIO_I2C3_SDA}, - {"kblight", I2C_PORT_KBLIGHT, 100, GPIO_I2C4_SCL, GPIO_I2C4_SDA}, - {"sensor", I2C_PORT_SENSOR, 400, GPIO_I2C7_SCL, GPIO_I2C7_SDA}, - {"tcpc0", I2C_PORT_TCPC0, 1000, GPIO_TCPC0_SCL, GPIO_TCPC0_SDA}, - {"tcpc1", I2C_PORT_TCPC1, 1000, GPIO_TCPC1_SCL, GPIO_TCPC1_SDA}, - {"tcpc2", I2C_PORT_TCPC2, 1000, GPIO_TCPC2_SCL, GPIO_TCPC2_SDA}, -}; -#else -const struct i2c_port_t i2c_ports[] = { - {"battery", I2C_PORT_BATTERY, 100, GPIO_I2C0_SCL, GPIO_I2C0_SDA}, - {"charger", I2C_PORT_CHARGER, 100, GPIO_I2C4_SCL, GPIO_I2C4_SDA}, - {"pmic", I2C_PORT_PMIC, 400, GPIO_I2C3_SCL, GPIO_I2C3_SDA}, - {"sensor", I2C_PORT_SENSOR, 400, GPIO_I2C7_SCL, GPIO_I2C7_SDA}, - {"tcpc0", I2C_PORT_TCPC0, 1000, GPIO_TCPC0_SCL, GPIO_TCPC0_SDA}, - {"tcpc1", I2C_PORT_TCPC1, 1000, GPIO_TCPC1_SCL, GPIO_TCPC1_SDA}, -}; -#endif - -const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); - -static struct opt3001_drv_data_t g_opt3001_data = { - .scale = 1, - .uscale = 0, - .offset = 0, -}; - -/* Base Sensor mutex */ -static struct mutex g_base_mutex; - -/* - * Motion Sense - */ - -struct lsm6dsm_data lsm6dsm_a_data; -struct lsm6dsm_data lsm6dsm_g_data; -struct lsm6dsm_data lsm6dsm_m_data; - -struct motion_sensor_t motion_sensors[] = { - [LID_ACCEL] = { - .name = "LSM6DSL ACC", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_a_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .rot_standard_ref = NULL, - .default_range = 4, /* g, enough for laptop. */ - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 13000, - .ec_rate = 76 * MSEC, - }, - }, - }, - [LID_GYRO] = { - .name = "LSM6DSL GYRO", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_LSM6DSM, - .type = MOTIONSENSE_TYPE_GYRO, - .location = MOTIONSENSE_LOC_LID, - .drv = &lsm6dsm_drv, - .mutex = &g_base_mutex, - .drv_data = &lsm6dsm_g_data, - .port = I2C_PORT_SENSOR, - .addr = LSM6DSM_ADDR0, - .rot_standard_ref = NULL, - .default_range = 1000, /* dps */ - .min_frequency = LSM6DSM_ODR_MIN_VAL, - .max_frequency = LSM6DSM_ODR_MAX_VAL, - }, - [LID_ALS] = { - .name = "Light", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_OPT3001, - .type = MOTIONSENSE_TYPE_LIGHT, - .location = MOTIONSENSE_LOC_LID, - .drv = &opt3001_drv, - .drv_data = &g_opt3001_data, - .port = I2C_PORT_SENSOR, - .addr = OPT3001_I2C_ADDR, - .rot_standard_ref = NULL, - .default_range = 0x10000, /* scale = 1; uscale = 0 */ - .min_frequency = OPT3001_LIGHT_MIN_FREQ, - .max_frequency = OPT3001_LIGHT_MAX_FREQ, - .config = { - /* Run ALS sensor in S0 */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 1000, - }, - }, - }, -#ifdef BOARD_MEOWTH - [VSYNC] = { - .name = "Camera vsync", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_GPIO, - .type = MOTIONSENSE_TYPE_SYNC, - .location = MOTIONSENSE_LOC_CAMERA, - .drv = &sync_drv, - .default_range = 0, - .min_frequency = 0, - .max_frequency = 1, - }, -#endif -}; -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); - -/* ALS instances when LPC mapping is needed. Each entry directs to a sensor. */ -const struct motion_sensor_t *motion_als_sensors[] = { - &motion_sensors[LID_ALS], -}; -BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT); - -/* TODO(aaboagye): Add the other ports. 3 for Zoombini, 2 for Meowth */ -struct ppc_config_t ppc_chips[] = { - { - .i2c_port = I2C_PORT_TCPC0, - .i2c_addr = SN5S330_ADDR0, - .drv = &sn5s330_drv - }, - { - .i2c_port = I2C_PORT_TCPC1, - .i2c_addr = SN5S330_ADDR0, - .drv = &sn5s330_drv, - }, -#ifdef BOARD_ZOOMBINI - { - .i2c_port = I2C_PORT_TCPC2, - .i2c_addr = SN5S330_ADDR0, - .drv = &sn5s330_drv - } -#endif /* defined(BOARD_ZOOMBINI) */ -}; -unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); - -#ifdef BOARD_ZOOMBINI -/* BC 1.2 chip Configuration */ -const struct max14637_config_t max14637_config[CONFIG_USB_PD_PORT_COUNT] = { - { - .chip_enable_pin = GPIO_USB_C0_BC12_VBUS_ON_L, - .chg_det_pin = GPIO_USB_C0_BC12_CHG_DET, - .flags = MAX14637_FLAGS_ENABLE_ACTIVE_LOW, - }, - { - .chip_enable_pin = GPIO_USB_C1_BC12_VBUS_ON_L, - .chg_det_pin = GPIO_USB_C1_BC12_CHG_DET, - .flags = MAX14637_FLAGS_ENABLE_ACTIVE_LOW, - }, - { - .chip_enable_pin = GPIO_USB_C2_BC12_VBUS_ON_L, - .chg_det_pin = GPIO_USB_C2_BC12_CHG_DET, - .flags = MAX14637_FLAGS_ENABLE_ACTIVE_LOW, - }, -}; - -/* GPIO to enable/disable the USB Type-A port. */ -const int usb_port_enable[CONFIG_USB_PORT_POWER_SMART_PORT_COUNT] = { - GPIO_USB_A_5V_EN, -}; - -/* Keyboard scan setting */ -struct keyboard_scan_config keyscan_config = { - /* 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 = 1500, - .min_post_scan_delay_us = 1000, - .poll_timeout_us = SECOND, - .actual_key_mask = { - 0x3c, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff, - 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */ - }, -}; -#endif /* defined(BOARD_ZOOMBINI) */ - -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = { - { - .i2c_host_port = I2C_PORT_TCPC0, - .i2c_slave_addr = PS8751_I2C_ADDR1, - .drv = &tcpci_tcpm_drv, - .pol = TCPC_ALERT_ACTIVE_LOW, - }, - - { - .i2c_host_port = I2C_PORT_TCPC1, - .i2c_slave_addr = PS8751_I2C_ADDR1, - .drv = &tcpci_tcpm_drv, - .pol = TCPC_ALERT_ACTIVE_LOW, - }, - -#ifdef BOARD_ZOOMBINI - { - .i2c_host_port = I2C_PORT_TCPC2, - .i2c_slave_addr = PS8751_I2C_ADDR1, - .drv = &tcpci_tcpm_drv, - .pol = TCPC_ALERT_ACTIVE_LOW, - }, -#endif /* defined(BOARD_ZOOMBINI) */ -}; - -/* The order is PD port (same as tcpc) */ -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = { - { - .driver = &tcpci_tcpm_usb_mux_driver, - .hpd_update = &ps8xxx_tcpc_update_hpd_status, - }, - - { - .driver = &tcpci_tcpm_usb_mux_driver, - .hpd_update = &ps8xxx_tcpc_update_hpd_status, - }, - -#ifdef BOARD_ZOOMBINI - { - .driver = &tcpci_tcpm_usb_mux_driver, - .hpd_update = &ps8xxx_tcpc_update_hpd_status, - }, -#endif /* defined(BOARD_ZOOMBINI) */ -}; - -static void board_chipset_resume(void) -{ - /* Enable display backlight. */ - gpio_set_level(GPIO_ENABLE_BACKLIGHT, 1); -} -DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT); - -static void board_chipset_startup(void) -{ -#ifdef BOARD_MEOWTH - gpio_set_level(GPIO_EN_PP1800_U, 1); -#endif /* defined(BOARD_MEOWTH) */ -} -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); - -static void board_chipset_shutdown(void) -{ -#ifdef BOARD_MEOWTH - gpio_set_level(GPIO_EN_PP1800_U, 0); -#endif /* defined(BOARD_MEOWTH ) */ -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); - -static void board_chipset_suspend(void) -{ - /* Disable display backlight. */ - gpio_set_level(GPIO_ENABLE_BACKLIGHT, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); - -#ifdef BOARD_MEOWTH -int board_get_version(void) -{ - static int board_version = -1; - - if (board_version == -1) { - board_version = 0; - /* BD_ID3 is LSb. */ - if (gpio_get_level(GPIO_BOARD_VERSION3)) - board_version |= 0x1; - if (gpio_get_level(GPIO_BOARD_VERSION2)) - board_version |= 0x2; - if (gpio_get_level(GPIO_BOARD_VERSION1)) - board_version |= 0x4; - if (gpio_get_level(GPIO_BOARD_VERSION0)) - board_version |= 0x8; - } - - return board_version; -} -#endif /* BOARD_MEOWTH */ - -static void board_init(void) -{ -#ifdef BOARD_ZOOMBINI - /* Enable PPC interrupts. */ - gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_L); - gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_L); - gpio_enable_interrupt(GPIO_USB_C2_PPC_INT_L); -#else - gpio_enable_interrupt(GPIO_SIXAXIS_INT_L); - gpio_enable_interrupt(GPIO_RCAM_VSYNC); -#endif /* defined(BOARD_ZOOMBINI) */ - - /* Enable TCPC interrupts. */ - gpio_enable_interrupt(GPIO_USB_C0_PD_INT_L); - gpio_enable_interrupt(GPIO_USB_C1_PD_INT_L); -#ifdef BOARD_ZOOMBINI - gpio_enable_interrupt(GPIO_USB_C2_PD_INT_L); -#endif /* defined(BOARD_ZOOMBINI) */ -} -DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); - -void board_overcurrent_event(int port) -{ - /* Sanity check the port. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_COUNT)) - return; - - /* Note that the levels are inverted because the pin is active low. */ - switch (port) { - case 0: - gpio_set_level(GPIO_USB_C0_OC_L, 0); - break; - - case 1: - gpio_set_level(GPIO_USB_C1_OC_L, 0); - break; - -#ifdef BOARD_ZOOMBINI - case 2: - gpio_set_level(GPIO_USB_C2_OC_L, 0); - break; -#endif /* defined(BOARD_ZOOMBINI) */ - - default: - return; - }; - - /* TODO(aaboagye): Write a PD log entry for the OC event. */ - CPRINTS("C%d: overcurrent!", port); -} - -static void board_pmic_init(void) -{ - /* No need to re-initialize the PMIC on sysjumps. */ - if (system_jumped_to_this_image()) - return; - - /* - * The PMIC_EN has been de-asserted since gpio_pre_init. Make sure - * it's de-asserted for at least 30ms. - * - * TODO(aaboagye): Characterize the discharge times for the power rails - * to see if we can shorten this delay. - */ - while (get_time().val < 30 * MSEC) - ; - gpio_set_level(GPIO_PMIC_EN, 1); - - /* - * Mask COMP_C fault. Meowth has the enable connected, but no PGOOD. - * Zoombini has the enable grounded, so it's fine to mask it for - * zoombini as well. - */ - if (i2c_write8(I2C_PORT_PMIC, PMIC_I2C_ADDR, - TPS650X30_REG_PWFAULT_MASK2, 1)) - cprints(CC_SYSTEM, "failed to mask pwfault_mask2"); - - /* - * PGMASK1 : Mask VCCIO and 5V from Power Good Tree - * [7] : 1b MVCCIOPG is masked. - * [6] : 1b MV5APG is masked. - */ - if (i2c_write8(I2C_PORT_PMIC, PMIC_I2C_ADDR, TPS650X30_REG_PGMASK1, - ((1 << 7) | (1 << 6)))) - cprints(CC_SYSTEM, "PMIC init failed!"); - else - cprints(CC_SYSTEM, "PMIC init'd"); -} -DECLARE_HOOK(HOOK_INIT, board_pmic_init, HOOK_PRIO_INIT_I2C+1); - -#ifdef BOARD_ZOOMBINI -static void board_kblight_init(void) -{ - gpio_set_level(GPIO_KB_BL_EN, 1); - lm3630a_poweron(); -} -DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_kblight_init, HOOK_PRIO_DEFAULT); - -static void board_kblight_stop(void) -{ - lm3630a_poweroff(); - gpio_set_level(GPIO_KB_BL_EN, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_kblight_stop, HOOK_PRIO_DEFAULT); -#endif /* defined(BOARD_ZOOMBINI) */ - -void board_reset_pd_mcu(void) -{ - /* GPIO_USB_PD_RST_L resets all the TCPCs. */ - gpio_set_level(GPIO_USB_PD_RST_L, 0); - msleep(10); /* TODO(aaboagye): Verify min hold time. */ - gpio_set_level(GPIO_USB_PD_RST_L, 1); -} - -int board_set_active_charge_port(int port) -{ - int is_real_port = (port >= 0 && - port < CONFIG_USB_PD_PORT_COUNT); - int i; - int rv; - - if (!is_real_port && port != CHARGE_PORT_NONE) - return EC_ERROR_INVAL; - - CPRINTS("New chg p%d", port); - - if (port == CHARGE_PORT_NONE) { - /* Disable all ports. */ - for (i = 0; i < ppc_cnt; i++) { - rv = ppc_vbus_sink_enable(i, 0); - if (rv) { - CPRINTS("Disabling p%d sink path failed.", i); - return rv; - } - } - - return EC_SUCCESS; - } - - /* Check if the port is sourcing VBUS. */ - if (ppc_is_sourcing_vbus(port)) { - CPRINTF("Skip enable p%d", port); - return EC_ERROR_INVAL; - } - - /* - * Turn off the other ports' sink path FETs, before enabling the - * requested charge port. - */ - for (i = 0; i < ppc_cnt; i++) { - if (i == port) - continue; - - if (ppc_vbus_sink_enable(i, 0)) - CPRINTS("p%d: sink path disable failed.", i); - } - - /* Enable requested charge port. */ - if (ppc_vbus_sink_enable(port, 1)) { - CPRINTS("p%d: sink path enable failed."); - return EC_ERROR_UNKNOWN; - } - - return EC_SUCCESS; -} - -void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - /* - * To protect the charge inductor, at voltages above 18V we should - * set the current limit to 2.7A. - */ - if (charge_mv > 18000) - charge_ma = MIN(2700, charge_ma); - - charge_set_input_current_limit(MAX(charge_ma, - CONFIG_CHARGER_INPUT_CURRENT), - charge_mv); -} - -uint16_t tcpc_get_alert_status(void) -{ - uint16_t status = 0; -#ifdef BOARD_MEOWTH - int regval; - - /* - * For Meowth, the interrupt line is shared between the TCPC and PPC. - * Therefore, go out and actually read the alert registers to report the - * alert status. - */ - if (!tcpc_read16(0, TCPC_REG_ALERT, ®val)) { - /* The TCPCI spec says to ignore bits 14:12. */ - regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); - - if (regval) - status |= PD_STATUS_TCPC_ALERT_0; - } - - if (!tcpc_read16(1, TCPC_REG_ALERT, ®val)) { - /* TCPCI spec says to ignore bits 14:12. */ - regval &= ~((1 << 14) | (1 << 13) | (1 << 12)); - - if (regval) - status |= PD_STATUS_TCPC_ALERT_1; - } -#else - if (!gpio_get_level(GPIO_USB_C0_PD_INT_L)) - status |= PD_STATUS_TCPC_ALERT_0; - if (!gpio_get_level(GPIO_USB_C1_PD_INT_L)) - status |= PD_STATUS_TCPC_ALERT_1; - if (!gpio_get_level(GPIO_USB_C2_PD_INT_L)) - status |= PD_STATUS_TCPC_ALERT_2; -#endif /* defined(BOARD_ZOOMBINI) */ - - return status; -} - -/* TODO(aaboagye): Remove if not needed later. */ -static int command_tcpc_dump_reg(int argc, char **argv) -{ - int port; - int regval; - int reg; - int rv; - - if (argc < 2) - return EC_ERROR_PARAM_COUNT; - - port = atoi(argv[1]); - - if (port < 0 || port > 2) - return EC_ERROR_PARAM1; - - /* Dump the regs for the queried TCPC port. */ - regval = 0; - - cflush(); - ccprintf("TCPC %d reg dump:\n", port); - - for (reg = 0; reg <= 0xff; reg++) { - regval = 0; - ccprintf("[0x%02x] = ", reg); - rv = tcpc_read(port, reg, ®val); - if (!rv) - ccprintf("0x%02x\n", regval); - else - ccprintf("ERR (%d)\n", rv); - cflush(); - } - - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(tcpcdump, command_tcpc_dump_reg, "<port>", - "Dumps TCPCI regs 0-ff"); diff --git a/board/zoombini/board.h b/board/zoombini/board.h deleted file mode 100644 index 2369362de1..0000000000 --- a/board/zoombini/board.h +++ /dev/null @@ -1,316 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Meowth/Zoombini board configuration */ - -#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 - -/* Optional features */ -#define CONFIG_HIBERNATE_PSL -#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands. */ -#define CONFIG_CMD_ACCELS -#define CONFIG_CMD_ACCEL_INFO -#define CONFIG_CMD_BUTTON -#define CONFIG_CMD_PPC_DUMP - -/* 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 */ -#define CONFIG_FLASH_SIZE (512 * 1024) /* It's really 1MB. */ -#define CONFIG_SPI_FLASH_REGS -#define CONFIG_SPI_FLASH_W25Q80 /* Internal SPI flash type. */ - -/* EC Modules */ -#define CONFIG_ADC -#define CONFIG_HOSTCMD_ESPI -/* TODO(aaboagye): Uncomment when Si arrives. */ -/* #define CONFIG_HOSTCMD_ESPI_VW_SLP_SIGNALS */ -#define CONFIG_I2C -#define CONFIG_PWM - -/* KB backlight driver */ -#ifdef BOARD_ZOOMBINI -#define CONFIG_LED_DRIVER_LM3630A -#endif /* defined(BOARD_ZOOMBINI) */ - -#define CONFIG_ACCELGYRO_LSM6DSM -#define CONFIG_ALS -#define CONFIG_ALS_OPT3001 -#define OPT3001_I2C_ADDR OPT3001_I2C_ADDR1 -#define ALS_COUNT 1 - -#ifdef BOARD_MEOWTH -#define CONFIG_SYNC -#endif - -#ifdef BOARD_MEOWTH -/* 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) -#endif - -/* Interrupt management. */ -#define CONFIG_ACCEL_INTERRUPTS - -/* Custom sensor option. */ -#define CONFIG_ACCEL_LSM6DSM_INT_EVENT TASK_EVENT_CUSTOM(4) -#define CONFIG_SYNC_INT_EVENT TASK_EVENT_CUSTOM(8) - -#define CONFIG_BACKLIGHT_LID - -#define CONFIG_BATTERY_CUT_OFF -#define CONFIG_BATTERY_SMART -#define CONFIG_BATTERY_REVIVE_DISCONNECT -#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L - -#ifdef BOARD_MEOWTH -#define CONFIG_DETACHABLE_BASE -#endif - -#ifdef BOARD_MEOWTH -#define CONFIG_BOARD_VERSION_CUSTOM -#else -#define CONFIG_BOARD_VERSION_GPIO -#endif - -#ifdef BOARD_MEOWTH -#define CONFIG_BUTTON_TRIGGERED_RECOVERY -#endif /* defined(BOARD_MEOWTH) */ - -#ifdef BOARD_ZOOMBINI -#define CONFIG_BC12_DETECT_MAX14637 -#endif /* defined(BOARD_ZOOMBINI) */ -#define CONFIG_CHARGER -#define CONFIG_CHARGER_V2 -#define CONFIG_CHARGE_MANAGER -#define CONFIG_CHARGER_INPUT_CURRENT 128 -#define CONFIG_CHARGER_ISL9238 -#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1 -#define CONFIG_CHARGER_SENSE_RESISTOR 10 -#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20 -#ifdef BOARD_ZOOMBINI -#define CONFIG_CHARGE_RAMP_HW -#define CONFIG_USB_CHARGER -#endif /* defined(BOARD_ZOOMBINI) */ -#define CONFIG_CHARGER_DISCHARGE_ON_AC - -#define CONFIG_CHIPSET_CANNONLAKE -#define CONFIG_CHIPSET_RESET_HOOK -#define CONFIG_EXTPOWER_GPIO -#define CONFIG_POWER_COMMON -#define CONFIG_POWER_BUTTON -#define CONFIG_POWER_BUTTON_X86 -#define CONFIG_POWER_PP5000_CONTROL -#define CONFIG_POWER_S0IX -#define CONFIG_POWER_TRACK_HOST_SLEEP_STATE - -#define CONFIG_I2C_MASTER - -#ifdef BOARD_ZOOMBINI -#define CONFIG_KEYBOARD_BOARD_CONFIG -#define CONFIG_KEYBOARD_COL2_INVERTED -#define CONFIG_KEYBOARD_PROTOCOL_8042 -#define CONFIG_PWM_KBLIGHT -#define CONFIG_SWITCH -#endif /* defined(BOARD_ZOOMBINI) */ - -/* TODO(aaboagye): Eventually, enable MKBP for zoombini as well. */ -#ifdef BOARD_MEOWTH -#define CONFIG_MKBP_EVENT -#define CONFIG_MKBP_USE_HOST_EVENT -#define CONFIG_KEYBOARD_PROTOCOL_MKBP -#endif /* defined(BOARD_MEOWTH) */ - -#define CONFIG_LED_COMMON -#ifdef BOARD_MEOWTH -#define CONFIG_LED_PWM_COUNT 2 -#else -#define CONFIG_LED_PWM_COUNT 1 -#endif /* defined(BOARD_MEOWTH) */ - -#define CONFIG_SUPPRESSED_HOST_COMMANDS \ - EC_CMD_CONSOLE_SNAPSHOT, EC_CMD_CONSOLE_READ, EC_CMD_PD_GET_LOG_ENTRY - -#ifdef BOARD_MEOWTH -#define CONFIG_TABLET_MODE -#define CONFIG_TABLET_MODE_SWITCH -#endif /* defined(BOARD_MEOWTH) */ - -/* USB PD config */ -#define CONFIG_USB_POWER_DELIVERY -#define CONFIG_CMD_PD_CONTROL -#define CONFIG_USB_PD_ALT_MODE -#define CONFIG_USB_PD_ALT_MODE_DFP -#ifdef BOARD_ZOOMBINI -#define CONFIG_USB_PD_PORT_COUNT 3 -#else -#define CONFIG_USB_PD_PORT_COUNT 2 -#endif /* defined(BOARD_ZOOMBINI) */ -#define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_LOGGING -#define CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT TYPEC_RP_3A0 -#define CONFIG_USB_PD_VBUS_DETECT_TCPC -#define CONFIG_USB_PD_TCPM_PS8805 -#define CONFIG_USB_PD_TCPM_TCPCI -#define CONFIG_USB_PD_TCPM_MUX -#define CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT -#define CONFIG_USBC_PPC_SN5S330 -#define CONFIG_USBC_SS_MUX -#define CONFIG_USBC_VCONN -#define CONFIG_USBC_VCONN_SWAP - -#define CONFIG_VBOOT_HASH -#define CONFIG_VOLUME_BUTTONS -#define CONFIG_VSTORE -#define CONFIG_VSTORE_SLOT_COUNT 1 - -#ifdef BOARD_ZOOMBINI -/* USB Type-A Port BC1.2 support */ -#define CONFIG_USB_PORT_POWER_SMART -#undef CONFIG_USB_PORT_POWER_SMART_PORT_COUNT -#define CONFIG_USB_PORT_POWER_SMART_PORT_COUNT 1 -#define CONFIG_USB_PORT_POWER_SMART_CDP_SDP_ONLY -#define GPIO_USB1_ILIM_SEL GPIO_USB_A_HIGH_POWER_EN -#endif /* defined(BOARD_ZOOMBINI) */ - -/* Define typical operating power and max power. */ -#define PD_MAX_VOLTAGE_MV 20000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_POWER_MW 60000 -#define PD_OPERATING_POWER_MW 15000 -#define PD_VCONN_SWAP_DELAY 5000 /* us */ - -/* TODO(aaboagye): Verify these timings... */ -/* - * 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 */ - -/* I2C Ports */ -/* Zoombini I2C config */ -#ifdef BOARD_ZOOMBINI -#define I2C_PORT_BATTERY I2C_PORT_POWER -#define I2C_PORT_CHARGER I2C_PORT_POWER -#define I2C_PORT_POWER NPCX_I2C_PORT0_0 -#define I2C_PORT_PMIC NPCX_I2C_PORT3_0 -#define I2C_PORT_KBLIGHT NPCX_I2C_PORT4_1 -#define I2C_PORT_SENSOR NPCX_I2C_PORT7_0 -#define I2C_PORT_TCPC0 NPCX_I2C_PORT1_0 -#define I2C_PORT_TCPC1 NPCX_I2C_PORT2_0 -#define I2C_PORT_TCPC2 NPCX_I2C_PORT5_0 - -#define GPIO_TCPC0_SCL GPIO_I2C1_SCL -#define GPIO_TCPC0_SDA GPIO_I2C1_SDA -#define GPIO_TCPC1_SCL GPIO_I2C2_SCL -#define GPIO_TCPC1_SDA GPIO_I2C2_SDA -#define GPIO_TCPC2_SCL GPIO_I2C5_SCL -#define GPIO_TCPC2_SDA GPIO_I2C5_SDA - -#else /* Meowth I2C config */ -#define I2C_PORT_CHARGER NPCX_I2C_PORT4_1 -#define I2C_PORT_BATTERY NPCX_I2C_PORT0_0 -#define I2C_PORT_PMIC NPCX_I2C_PORT3_0 -#define I2C_PORT_SENSOR NPCX_I2C_PORT7_0 -#define I2C_PORT_TCPC0 NPCX_I2C_PORT5_0 -#define I2C_PORT_TCPC1 NPCX_I2C_PORT1_0 - -#define GPIO_TCPC0_SCL GPIO_I2C5_SCL -#define GPIO_TCPC0_SDA GPIO_I2C5_SDA -#define GPIO_TCPC1_SCL GPIO_I2C1_SCL -#define GPIO_TCPC1_SDA GPIO_I2C1_SDA -#endif /* defined(BOARD_ZOOMBINI) */ - -#define PMIC_I2C_ADDR TPS650X30_I2C_ADDR1 - -#ifdef BOARD_MEOWTH -#define PP5000_PGOOD_POWER_SIGNAL_MASK 0 -#else -#define PP5000_PGOOD_POWER_SIGNAL_MASK \ -POWER_SIGNAL_MASK(PP5000_PGOOD) -#endif /* defined(BOARD_MEOWTH) */ - -#ifndef __ASSEMBLER__ - -#include "gpio_signal.h" -#include "registers.h" - -/* ADC signal */ -enum adc_channel { - ADC_TEMP_SENSOR_SOC, - ADC_TEMP_SENSOR_CHARGER, -#ifdef BOARD_MEOWTH - ADC_TEMP_SENSOR_WIFI, - ADC_BASE_ATTACH, - ADC_BASE_DETACH, -#endif /* defined(BOARD_MEOWTH) */ - ADC_CH_COUNT -}; - -enum pwm_channel { -#ifdef BOARD_MEOWTH - PWM_CH_DB0_LED_RED = 0, - PWM_CH_DB0_LED_GREEN, - PWM_CH_DB0_LED_BLUE, - PWM_CH_DB1_LED_RED, - PWM_CH_DB1_LED_GREEN, - PWM_CH_DB1_LED_BLUE, -#else /* !defined(BOARD_MEOWTH) */ - PWM_CH_LED_GREEN = 0, - PWM_CH_LED_RED, - PWM_CH_KBLIGHT, -#endif /* defined(BOARD_MEOWTH) */ - PWM_CH_COUNT -}; - -enum power_signal { - X86_SLP_S0_DEASSERTED, - X86_SLP_S3_DEASSERTED, - X86_SLP_S4_DEASSERTED, - X86_SLP_SUS_DEASSERTED, - X86_RSMRST_L_PGOOD, - X86_PMIC_DPWROK, -#ifdef BOARD_ZOOMBINI - PP5000_PGOOD, -#endif /* defined(BOARD_ZOOMBINI) */ - POWER_SIGNAL_COUNT -}; - -enum sensor_id { - LID_ACCEL, - LID_GYRO, - LID_ALS, - VSYNC, -}; - -#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ALS) - -#ifdef BOARD_MEOWTH -int board_get_version(void); -#endif /* defined(BOARD_MEOWTH) */ - -void base_pwr_fault_interrupt(enum gpio_signal s); - -/* Reset all TCPCs. */ -void board_reset_pd_mcu(void); - -#endif /* !defined(__ASSEMBLER__) */ - -#endif /* __CROS_EC_BOARD_H */ diff --git a/board/zoombini/build.mk b/board/zoombini/build.mk deleted file mode 100644 index a24c848e65..0000000000 --- a/board/zoombini/build.mk +++ /dev/null @@ -1,14 +0,0 @@ -# -*- makefile -*- -# Copyright 2017 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# -# Board specific files build -# - -CHIP:=npcx -CHIP_FAMILY:=npcx7 -CHIP_VARIANT:=npcx7m6f - -board-y=battery.o board.o led.o usb_pd_policy.o -board-$(BOARD_MEOWTH)+=base_detect.o diff --git a/board/zoombini/ec.tasklist b/board/zoombini/ec.tasklist deleted file mode 100644 index 81c49bde9a..0000000000 --- a/board/zoombini/ec.tasklist +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* - * 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. - */ - -#ifdef BOARD_ZOOMBINI -#define CONFIG_TASK_LIST \ - TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 1, TASK_STACK_SIZE) \ - TASK_ALWAYS(USB_CHG_P2, usb_charger_task, 2, 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, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_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) \ - TASK_ALWAYS(PD_C2, pd_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_INT_C2, pd_interrupt_handler_task, 2, TASK_STACK_SIZE) -#else -#define CONFIG_TASK_LIST \ - TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_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(PDCMD, pd_command_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_ALWAYS(POWERBTN, power_button_task, NULL, LARGER_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_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, TASK_STACK_SIZE) \ - TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, TASK_STACK_SIZE) -#endif /* defined(BOARD_ZOOMBINI) */ diff --git a/board/zoombini/gpio.inc b/board/zoombini/gpio.inc deleted file mode 100644 index 7d41d17148..0000000000 --- a/board/zoombini/gpio.inc +++ /dev/null @@ -1,240 +0,0 @@ -/* -*- mode:c -*- - * - * Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Declare symbolic names for all the GPIOs that we care about. - * Note: Those with interrupt handlers must be declared first. */ - -/* Zoombini GPIOs */ -#ifdef BOARD_ZOOMBINI -GPIO_INT(USB_C0_PD_INT_L, PIN(6, 1), GPIO_INT_FALLING, tcpc_alert_event) -GPIO_INT(USB_C1_PD_INT_L, PIN(F, 5), GPIO_INT_FALLING, tcpc_alert_event) -GPIO_INT(USB_C2_PD_INT_L, PIN(9, 5), GPIO_INT_FALLING, tcpc_alert_event) - -GPIO_INT(USB_C0_PPC_INT_L, PIN(0, 3), GPIO_INT_FALLING, ppc_interrupt) -GPIO_INT(USB_C1_PPC_INT_L, PIN(0, 4), GPIO_INT_FALLING, ppc_interrupt) -GPIO_INT(USB_C2_PPC_INT_L, PIN(4, 0), GPIO_INT_FALLING, ppc_interrupt) - -GPIO_INT(POWER_BUTTON_L, PIN(0, 1), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt) -GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_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) - -/* Power Signals. */ -GPIO_INT(PCH_SLP_S0_L, PIN(A, 4), GPIO_INT_BOTH, power_signal_interrupt) -#ifndef CONFIG_HOSTCMD_ESPI_VW_SLP_SIGNALS -GPIO_INT(PCH_SLP_S3_L, PIN(A, 6), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(PCH_SLP_S4_L, PIN(A, 3), GPIO_INT_BOTH, power_signal_interrupt) -#endif /* defined(CONFIG_HOSTCMD_ESPI_VW_SLP_SIGNALS) */ -GPIO_INT(PCH_SLP_SUS_L, PIN(D, 4), GPIO_INT_BOTH, power_signal_interrupt) -/* TODO(aaboagye): Internal PU may be needed later on... */ -GPIO_INT(RSMRST_L_PGOOD, PIN(E, 2), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(PMIC_DPWROK, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(PMIC_INT_L, PIN(D, 5), GPIO_INT_FALLING | GPIO_PULL_UP, power_signal_interrupt) -GPIO_INT(PP5000_PGOOD, PIN(C, 0), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(VOLUME_UP_L, PIN(7, 5), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) -GPIO_INT(VOLUME_DOWN_L, PIN(4, 1), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) - -/* Power Enables. */ -GPIO(EN_PP3300_DSW, PIN(6, 0), GPIO_OUT_LOW) -GPIO(EN_PP5000, PIN(7, 3), GPIO_OUT_LOW) - -GPIO(ENTERING_RW, PIN(E, 1), GPIO_OUT_LOW) -GPIO(CCD_MODE_ODL, PIN(E, 3), GPIO_INPUT) /* Case Closed Debug mode. */ -GPIO(KB_BL_EN, PIN(8, 6), GPIO_OUT_LOW) -GPIO(PMIC_EN, PIN(D, 7), GPIO_ODR_LOW) -GPIO(ENABLE_BACKLIGHT, PIN(D, 3), GPIO_ODR_LOW) /* EC_BL_EN_OD */ - -GPIO(PCH_DSW_PWROK, PIN(3, 7), GPIO_OUT_LOW) /* EC_PCH_DSW_PWROK */ -GPIO(PCH_RSMRST_L, PIN(C, 2), GPIO_OUT_LOW) /* EC_PCH_RSMRST_L */ -GPIO(PCH_RTCRST, PIN(7, 6), GPIO_OUT_LOW) /* EC_PCH_RTCRST */ -GPIO(EN_TOP_SWAP, PIN(B, 7), GPIO_INPUT) /* GPP_B14_STRAP */ -GPIO(PCH_PWRBTN_L, PIN(C, 1), GPIO_ODR_HIGH) /* EC_PCH_PWR_BTN_ODL */ -GPIO(PCH_WAKE_L, PIN(7, 4), GPIO_ODR_HIGH) /* EC_PCH_WAKE_ODL */ -GPIO(CPU_PROCHOT, PIN(3, 4), GPIO_INPUT) /* PCH_PROCHOT_ODL */ -GPIO(SYS_RESET_L, PIN(0, 2), GPIO_ODR_HIGH) /* SYS_RST_ODL */ - -GPIO(I2C0_SCL, PIN(B, 5), GPIO_INPUT) -GPIO(I2C0_SDA, PIN(B, 4), GPIO_INPUT) -GPIO(I2C1_SCL, PIN(9, 0), GPIO_INPUT) -GPIO(I2C1_SDA, PIN(8, 7), GPIO_INPUT) -GPIO(I2C2_SCL, PIN(9, 2), GPIO_INPUT) -GPIO(I2C2_SDA, PIN(9, 1), GPIO_INPUT) -GPIO(I2C3_SCL, PIN(D, 1), GPIO_INPUT) -GPIO(I2C3_SDA, PIN(D, 0), GPIO_INPUT) -GPIO(I2C4_SCL, PIN(F, 3), GPIO_INPUT) -GPIO(I2C4_SDA, PIN(F, 2), GPIO_INPUT) -GPIO(I2C5_SCL, PIN(3, 3), GPIO_INPUT) -GPIO(I2C5_SDA, PIN(3, 6), GPIO_INPUT) -GPIO(I2C7_SCL, PIN(B, 3), GPIO_INPUT) -GPIO(I2C7_SDA, PIN(B, 2), GPIO_INPUT) - -GPIO(BAT_PRESENT_L, PIN(E, 5), GPIO_INPUT) -GPIO(USB_PD_RST_L, PIN(F, 1), GPIO_ODR_HIGH) - -GPIO(USB_A_5V_EN, PIN(A, 0), GPIO_ODR_LOW) -GPIO(USB_A_HIGH_POWER_EN, PIN(A, 2), GPIO_ODR_LOW) - -GPIO(USB_C0_BC12_VBUS_ON_L, PIN(8, 2), GPIO_ODR_HIGH) -GPIO(USB_C1_BC12_VBUS_ON_L, PIN(B, 1), GPIO_ODR_HIGH) -GPIO(USB_C2_BC12_VBUS_ON_L, PIN(E, 0), GPIO_ODR_HIGH) -GPIO(USB_C0_BC12_CHG_DET, PIN(6, 2), GPIO_INPUT) -GPIO(USB_C1_BC12_CHG_DET, PIN(8, 3), GPIO_INPUT) -GPIO(USB_C2_BC12_CHG_DET, PIN(E, 4), GPIO_INPUT) -GPIO(USB_C0_OC_L, PIN(6, 7), GPIO_ODR_HIGH) -GPIO(USB_C1_OC_L, PIN(7, 0), GPIO_ODR_HIGH) -GPIO(USB_C2_OC_L, PIN(6, 3), GPIO_ODR_HIGH) -GPIO(USB_C0_DP_HPD, PIN(C, 5), GPIO_OUT_LOW) -GPIO(USB_C1_DP_HPD, PIN(C, 6), GPIO_OUT_LOW) -GPIO(USB_C2_DP_HPD, PIN(C, 7), GPIO_OUT_LOW) - -GPIO(BOARD_VERSION1, PIN(9, 6), GPIO_INPUT) -GPIO(BOARD_VERSION2, PIN(9, 3), GPIO_INPUT) -GPIO(BOARD_VERSION3, PIN(F, 0), GPIO_INPUT) - -/* UART Pins */ -ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* Cr50 requires no pullups. */ -/* I2C Ports */ -ALTERNATE(PIN_MASK(B, 0x30), 1, MODULE_I2C, 0) /* I2C0 */ -ALTERNATE(PIN_MASK(9, 0x06), 1, MODULE_I2C, 0) /* I2C2 */ -ALTERNATE(PIN_MASK(9, 0x01), 1, MODULE_I2C, 0) /* I2C1 SDA */ -ALTERNATE(PIN_MASK(8, 0x80), 1, MODULE_I2C, 0) /* I2C1 SCL */ -ALTERNATE(PIN_MASK(D, 0x03), 1, MODULE_I2C, 0) /* I2C3 */ -ALTERNATE(PIN_MASK(3, 0x48), 1, MODULE_I2C, 0) /* I2C5 */ -ALTERNATE(PIN_MASK(B, 0x0C), 1, MODULE_I2C, 0) /* I2C7 */ -ALTERNATE(PIN_MASK(F, 0x0C), 1, MODULE_I2C, 0) /* I2C4 */ - -/* Keyboard Pins */ -/* KSI_00-01 */ -ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_INPUT) -/* KSI_02-07 */ -ALTERNATE(PIN_MASK(2, 0xFC), 0, MODULE_KEYBOARD_SCAN, GPIO_INPUT) -/* KSO_00-01 */ -ALTERNATE(PIN_MASK(2, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) -/* KSO_02 inverted */ -GPIO(KBD_KSO2, PIN(1, 7), GPIO_OUT_LOW) -/* KSO_03-09 */ -ALTERNATE(PIN_MASK(1, 0x7F), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) -/* KSO_10-12 */ -ALTERNATE(PIN_MASK(0, 0xE0), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) - -/* PWMs. */ -ALTERNATE(PIN_MASK(C, 0x18), 1, MODULE_PWM, 0) /* LED 1 & 2 */ -ALTERNATE(PIN_MASK(8, 0x01), 1, MODULE_PWM, 0) /* KB Backlight */ - -/* ADC */ -ALTERNATE(PIN_MASK(4, 0x30), 1, MODULE_ADC, 0) /* ADC0-1 */ - -/* 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 */ - -#else /* defined(BOARD_ZOOMBINI) */ - -GPIO_INT(USB_C0_PD_INT_L, PIN(6, 1), GPIO_INT_FALLING, usb_c_interrupt) -GPIO_INT(USB_C1_PD_INT_L, PIN(F, 5), GPIO_INT_FALLING, usb_c_interrupt) - -GPIO_INT(POWER_BUTTON_L, PIN(0, 1), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt) -GPIO_INT(WP_L, PIN(A, 1), GPIO_INT_BOTH, switch_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) - -/* Power Signals. */ -GPIO_INT(PCH_SLP_S0_L, PIN(A, 4), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(PCH_SLP_S3_L, PIN(A, 6), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(PCH_SLP_S4_L, PIN(A, 3), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(PCH_SLP_SUS_L, PIN(D, 4), GPIO_INT_BOTH, power_signal_interrupt) -/* TODO(aaboagye): Internal PU may be needed later on... */ -GPIO_INT(RSMRST_L_PGOOD, PIN(E, 2), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(PMIC_DPWROK, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt) -GPIO_INT(PMIC_INT_L, PIN(D, 5), GPIO_INT_FALLING | GPIO_PULL_UP, power_signal_interrupt) -GPIO_INT(VOLUME_UP_L, PIN(7, 5), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) -GPIO_INT(VOLUME_DOWN_L, PIN(6, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) -GPIO_INT(BASE_PWR_FLT_L, PIN(2, 4), GPIO_INT_FALLING, base_pwr_fault_interrupt) - -/* MEMS Sensors. */ -GPIO_INT(SIXAXIS_INT_L, PIN(5, 6), GPIO_INT_FALLING, lsm6dsm_interrupt) -GPIO_INT(RCAM_VSYNC, PIN(E, 0), GPIO_INT_FALLING, sync_interrupt) -GPIO(ALS_INT_L, PIN(5, 0), GPIO_INPUT) - - -/* Power Enables. */ -GPIO(EN_PP3300_DSW, PIN(8, 2), GPIO_OUT_LOW) -GPIO(EN_PP5000, PIN(7, 3), GPIO_OUT_LOW) -GPIO(EN_PP1800_U, PIN(A, 0), GPIO_OUT_LOW) -GPIO(EN_PP3300_WLAN, PIN(8, 3), GPIO_OUT_HIGH) -GPIO(BASE_PWR_EN, PIN(2, 2), GPIO_OUT_LOW) - -GPIO(ENTERING_RW, PIN(E, 1), GPIO_OUT_LOW) -GPIO(CCD_MODE_ODL, PIN(E, 3), GPIO_INPUT) /* Case Closed Debug mode. */ -GPIO(PMIC_EN, PIN(8, 6), GPIO_ODR_LOW) -GPIO(USB_C0_OC_L, PIN(6, 7), GPIO_ODR_HIGH) -GPIO(USB_C1_OC_L, PIN(7, 0), GPIO_ODR_HIGH) -GPIO(ENABLE_BACKLIGHT, PIN(D, 3), GPIO_ODR_LOW) /* EC_BL_EN_OD */ -GPIO(USB_C0_DP_HPD, PIN(C, 5), GPIO_OUT_LOW) -GPIO(USB_C1_DP_HPD, PIN(C, 6), GPIO_OUT_LOW) - -GPIO(PCH_DSW_PWROK, PIN(3, 7), GPIO_OUT_LOW) /* EC_PCH_DSW_PWROK */ -GPIO(PCH_RSMRST_L, PIN(C, 2), GPIO_OUT_LOW) /* EC_PCH_RSMRST_L */ -GPIO(PCH_RTCRST, PIN(7, 6), GPIO_OUT_LOW) /* EC_PCH_RTCRST */ -GPIO(PCH_PWRBTN_L, PIN(C, 1), GPIO_ODR_HIGH) /* EC_PCH_PWR_BTN_ODL */ -GPIO(PCH_WAKE_L, PIN(7, 4), GPIO_ODR_HIGH) /* EC_PCH_WAKE_ODL */ -GPIO(CPU_PROCHOT, PIN(3, 4), GPIO_INPUT) /* PCH_PROCHOT_ODL */ -GPIO(SYS_RESET_L, PIN(0, 2), GPIO_ODR_HIGH) /* SYS_RST_ODL */ - -GPIO(I2C0_SCL, PIN(B, 5), GPIO_INPUT) -GPIO(I2C0_SDA, PIN(B, 4), GPIO_INPUT) -GPIO(I2C1_SCL, PIN(9, 0), GPIO_INPUT) -GPIO(I2C1_SDA, PIN(8, 7), GPIO_INPUT) -GPIO(I2C3_SCL, PIN(D, 1), GPIO_INPUT) -GPIO(I2C3_SDA, PIN(D, 0), GPIO_INPUT) -GPIO(I2C4_SCL, PIN(F, 3), GPIO_INPUT) -GPIO(I2C4_SDA, PIN(F, 2), GPIO_INPUT) -GPIO(I2C5_SCL, PIN(3, 3), GPIO_INPUT) -GPIO(I2C5_SDA, PIN(3, 6), GPIO_INPUT) -GPIO(I2C7_SCL, PIN(B, 3), GPIO_INPUT) -GPIO(I2C7_SDA, PIN(B, 2), GPIO_INPUT) - -GPIO(BAT_PRESENT_L, PIN(E, 5), GPIO_INPUT) -GPIO(USB_PD_RST_L, PIN(6, 2), GPIO_ODR_HIGH) - -GPIO(BOARD_VERSION0, PIN(4, 0), GPIO_INPUT) -GPIO(BOARD_VERSION1, PIN(9, 6), GPIO_INPUT) -GPIO(BOARD_VERSION2, PIN(9, 3), GPIO_INPUT) -GPIO(BOARD_VERSION3, PIN(A, 2), GPIO_INPUT) - -/* Misc */ -/* GPP_B14_STRAP was moved between these two ECs. */ -GPIO(GPP_B14_STRAP_796F, PIN(D, 7), GPIO_INPUT) -GPIO(GPP_B14_STRAP_797W, PIN(7, 2), GPIO_INPUT) - -/* UART Pins */ -ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* Cr50 requires no pullups. */ -/* I2C Ports */ -ALTERNATE(PIN_MASK(B, 0x30), 1, MODULE_I2C, 0) /* I2C0 */ -ALTERNATE(PIN_MASK(9, 0x01), 1, MODULE_I2C, 0) /* I2C1 SDA */ -ALTERNATE(PIN_MASK(8, 0x80), 1, MODULE_I2C, 0) /* I2C1 SCL */ -ALTERNATE(PIN_MASK(D, 0x03), 1, MODULE_I2C, 0) /* I2C3 */ -ALTERNATE(PIN_MASK(3, 0x48), 1, MODULE_I2C, 0) /* I2C5 */ -ALTERNATE(PIN_MASK(B, 0x0C), 1, MODULE_I2C, 0) /* I2C7 */ -ALTERNATE(PIN_MASK(F, 0x0C), 1, MODULE_I2C, 0) /* I2C4 */ - -/* PWMs. */ -ALTERNATE(PIN_MASK(C, 0x18), 1, MODULE_PWM, 0) /* DB0 Green/Blue LED (M) */ -ALTERNATE(PIN_MASK(8, 0x01), 1, MODULE_PWM, 0) /* DB0 Red LED (M) */ -ALTERNATE(PIN_MASK(6, 0x01), 1, MODULE_PWM, 0) /* DB1 Red LED (M) */ -ALTERNATE(PIN_MASK(B, 0x80), 1, MODULE_PWM, 0) /* DB1 Green LED (M) */ -ALTERNATE(PIN_MASK(C, 0x01), 1, MODULE_PWM, 0) /* DB1 Blue LED (M) */ - -/* ADC */ -ALTERNATE(PIN_MASK(4, 0x32), 1, MODULE_ADC, 0) /* ADC0-1,4 */ -ALTERNATE(PIN_MASK(F, 0x03), 1, MODULE_ADC, 0) /* ADC8-9 */ - -/* 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 */ - -#endif /* defined(BOARD_ZOOMBINI) */ diff --git a/board/zoombini/led.c b/board/zoombini/led.c deleted file mode 100644 index f3ee559f3b..0000000000 --- a/board/zoombini/led.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Zoombini/Meowth specific LED settings. */ - -#include "common.h" -#include "ec_commands.h" -#include "led_pwm.h" -#include "pwm.h" -#include "util.h" - -const enum ec_led_id supported_led_ids[] = { -#ifdef BOARD_MEOWTH - EC_LED_ID_LEFT_LED, - EC_LED_ID_RIGHT_LED, -#else - EC_LED_ID_POWER_LED, -#endif /* defined(BOARD_MEOWTH) */ -}; -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -#ifdef BOARD_MEOWTH -/* Meowth LED definitions */ -/* We won't be using the blue channel long term. */ -struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = { - /* Red, Green, Blue */ - [EC_LED_COLOR_RED] = { 8, 0, 0 }, - [EC_LED_COLOR_GREEN] = { 0, 8, 0 }, - [EC_LED_COLOR_BLUE] = { 0, 0, 0 }, - [EC_LED_COLOR_YELLOW] = { 8, 24, 0 }, - [EC_LED_COLOR_WHITE] = { 0, 0, 0 }, - [EC_LED_COLOR_AMBER] = { 12, 9, 0 }, -}; - -/* Two tri-color LEDs with red, green, and blue channels. */ -struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = { - { - PWM_CH_DB0_LED_RED, - PWM_CH_DB0_LED_GREEN, - PWM_CH_DB0_LED_BLUE, - }, - - { - PWM_CH_DB1_LED_RED, - PWM_CH_DB1_LED_GREEN, - PWM_CH_DB1_LED_BLUE, - }, -}; -#else -/* Zoombini LED definitions. */ -struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = { - /* Red, Green, Blue */ - [EC_LED_COLOR_RED] = { 100, 0, 0 }, - [EC_LED_COLOR_GREEN] = { 0, 100, 0 }, - [EC_LED_COLOR_BLUE] = { 0, 0, 0 }, - [EC_LED_COLOR_YELLOW] = { 100, 50, 0 }, - [EC_LED_COLOR_WHITE] = { 0, 0, 0 }, - [EC_LED_COLOR_AMBER] = { 100, 10, 0 }, -}; - -/* A single bi-color LED with red and green channels. */ -struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = { - { - .ch0 = PWM_CH_LED_RED, - .ch1 = PWM_CH_LED_GREEN, - .ch2 = PWM_LED_NO_CHANNEL, - }, -}; -#endif /* !defined(BOARD_MEOWTH) */ - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - brightness_range[EC_LED_COLOR_RED] = 100; - brightness_range[EC_LED_COLOR_GREEN] = 100; - brightness_range[EC_LED_COLOR_YELLOW] = 100; - brightness_range[EC_LED_COLOR_AMBER] = 100; - /* Zoombini has no blue channel; it's also going away for Meowth. */ - brightness_range[EC_LED_COLOR_BLUE] = 0; - brightness_range[EC_LED_COLOR_WHITE] = 0; -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - enum pwm_led_id pwm_id; - - /* Convert ec_led_id to pwm_led_id. */ -#ifdef BOARD_MEOWTH - if (led_id == EC_LED_ID_LEFT_LED) - pwm_id = PWM_LED0; - else if (led_id == EC_LED_ID_RIGHT_LED) - pwm_id = PWM_LED1; -#else - if (led_id == EC_LED_ID_POWER_LED) - pwm_id = PWM_LED0; -#endif /* defined(BOARD_MEOWTH) */ - else - return EC_ERROR_UNKNOWN; - - if (brightness[EC_LED_COLOR_RED]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_RED); - else if (brightness[EC_LED_COLOR_GREEN]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_GREEN); - else if (brightness[EC_LED_COLOR_YELLOW]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_YELLOW); - else if (brightness[EC_LED_COLOR_AMBER]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER); - else - /* Otherwise, the "color" is "off". */ - set_pwm_led_color(pwm_id, -1); - - return EC_SUCCESS; -} diff --git a/board/zoombini/usb_pd_policy.c b/board/zoombini/usb_pd_policy.c deleted file mode 100644 index 09ac156425..0000000000 --- a/board/zoombini/usb_pd_policy.c +++ /dev/null @@ -1,427 +0,0 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "charge_manager.h" -#include "common.h" -#include "console.h" -#include "compile_time_macros.h" -#include "ec_commands.h" -#include "gpio.h" -#include "system.h" -#include "usb_mux.h" -#include "usb_pd.h" -#include "usbc_ppc.h" -#include "util.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_COMM_CAP|\ - PDO_FIXED_DATA_SWAP) - -/* TODO(aaboagye): Determine correct values. */ -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_src_pdo_max[] = { - PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS), -}; -const int pd_src_pdo_max_cnt = ARRAY_SIZE(pd_src_pdo_max); - -/* TODO(aaboagye): Determine correct values. */ -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_board_checks(void) -{ - return EC_SUCCESS; -} - -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; -} - -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 && - system_get_image_copy() != SYSTEM_IMAGE_RO) - pd_request_data_swap(port); -} - -/* TODO(aaboagye): re-eval for 3.0 & FRS. */ -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(port) == PD_DRP_TOGGLE_ON ? 1 : 0; -} - -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(port) == 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); - } -} - -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_PCH_SLP_SUS_L); -} - -void pd_execute_data_swap(int port, int data_role) -{ - /* Do nothing */ -} - -int pd_is_valid_input_voltage(int mv) -{ - return 1; -} - -void pd_power_supply_reset(int port) -{ - /* Disable VBUS. */ - ppc_vbus_source_enable(port, 0); - -#ifdef CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT - /* Give back the current quota we are no longer using */ - charge_manager_source_port(port, 0); -#endif /* defined(CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) */ - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); -} - -int pd_set_power_supply_ready(int port) -{ - int rv; - - if (port >= ppc_cnt) - return EC_ERROR_INVAL; - - /* Disable charging. */ - rv = ppc_vbus_sink_enable(port, 0); - if (rv) - return rv; - - /* Provide Vbus. */ - rv = ppc_vbus_source_enable(port, 1); - if (rv) - return rv; - -#ifdef CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT - /* Ensure we advertise the proper available current quota */ - charge_manager_source_port(port, 1); -#endif /* defined(CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) */ - - /* Notify host of power info change. */ - pd_send_host_event(PD_EVENT_POWER_CHANGE); - - return EC_SUCCESS; -} - -void pd_transition_voltage(int idx) -{ - /* No-operation: we are always 5V */ -} - -void typec_set_source_current_limit(int p, int rp) -{ - ppc_set_vbus_source_current_limit(p, rp); -} - -/* ----------------- 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, is_latest; - - /* 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]); - - is_latest = pd_dev_store_rw_hash(port, - dev_id, - payload + 1, - is_rw ? - SYSTEM_IMAGE_RW : - SYSTEM_IMAGE_RO); - - /* - * Send update host event unless our RW hash is - * already known to be the latest update RW. - */ - if (!is_rw || !is_latest) - pd_send_host_event(PD_EVENT_UPDATE_DEVICE); - - 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 uint32_t dp_status[CONFIG_USB_PD_PORT_COUNT]; - -static void svdm_safe_dp_mode(int port) -{ - /* make DP interface safe until configure */ - dp_flags[port] = 0; - dp_status[port] = 0; - usb_mux_set(port, TYPEC_MUX_NONE, - USB_SWITCH_CONNECT, 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); - int mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]); - int pin_mode = pd_dfp_dp_get_pin_mode(port, dp_status[port]); - - if (!pin_mode) - return 0; - - usb_mux_set(port, mf_pref ? TYPEC_MUX_DOCK : TYPEC_MUX_DP, - USB_SWITCH_CONNECT, pd_get_polarity(port)); - - payload[0] = VDO(USB_SID_DISPLAYPORT, 1, - CMD_DP_CONFIG | VDO_OPOS(opos)); - payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ - 1, /* DPv1.3 signaling */ - 2); /* UFP connected */ - return 2; -}; - -/* - * timestamp of the next possible toggle to ensure the 2-ms spacing - * between IRQ_HPD. - */ -static uint64_t hpd_deadline[CONFIG_USB_PD_PORT_COUNT]; - -#ifdef BOARD_MEOWTH -#define PORT_TO_HPD(port) ((port) ? GPIO_USB_C1_DP_HPD : GPIO_USB_C0_DP_HPD) -#else -#define PORT_TO_HPD(port) ((port == 2) ? GPIO_USB_C2_DP_HPD : \ - (port) ? GPIO_USB_C1_DP_HPD : GPIO_USB_C0_DP_HPD) -#endif /* defined(BOARD_MEOWTH) */ -static void svdm_dp_post_config(int port) -{ - const struct usb_mux *mux = &usb_muxes[port]; - - dp_flags[port] |= DP_FLAGS_DP_ON; - if (!(dp_flags[port] & DP_FLAGS_HPD_HI_PENDING)) - return; - - gpio_set_level(PORT_TO_HPD(port), 1); - - /* set the minimum time delay (2ms) for the next HPD IRQ */ - hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - - mux->hpd_update(port, 1, 0); -} - -static int svdm_dp_attention(int port, uint32_t *payload) -{ - int cur_lvl; - int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); - int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); - enum gpio_signal hpd = PORT_TO_HPD(port); - const struct usb_mux *mux = &usb_muxes[port]; - - cur_lvl = gpio_get_level(hpd); - dp_status[port] = payload[1]; - - /* Its initial DP status message prior to config */ - if (!(dp_flags[port] & DP_FLAGS_DP_ON)) { - if (lvl) - dp_flags[port] |= DP_FLAGS_HPD_HI_PENDING; - return 1; - } - - if (irq & cur_lvl) { - uint64_t now = get_time().val; - /* wait for the minimum spacing between IRQ_HPD if needed */ - if (now < hpd_deadline[port]) - usleep(hpd_deadline[port] - now); - - /* generate IRQ_HPD pulse */ - gpio_set_level(hpd, 0); - usleep(HPD_DSTREAM_DEBOUNCE_IRQ); - gpio_set_level(hpd, 1); - - /* set the minimum time delay (2ms) for the next HPD IRQ */ - hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - } else if (irq & !cur_lvl) { - CPRINTF("ERR:HPD:IRQ&LOW\n"); - return 0; /* nak */ - } else { - gpio_set_level(hpd, lvl); - /* set the minimum time delay (2ms) for the next HPD IRQ */ - hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; - } - mux->hpd_update(port, lvl, irq); - /* ack */ - return 1; -} - -static void svdm_exit_dp_mode(int port) -{ - const struct usb_mux *mux = &usb_muxes[port]; - - svdm_safe_dp_mode(port); - gpio_set_level(PORT_TO_HPD(port), 0); - mux->hpd_update(port, 0, 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 */ diff --git a/util/build.mk b/util/build.mk index f61a11d628..fef646f2de 100644 --- a/util/build.mk +++ b/util/build.mk @@ -18,7 +18,7 @@ uartupdatetool-objs=uut/main.o uut/cmd.o uut/opr.o uut/l_com_port.o \ uut/lib_crc.o $(out)/util/uartupdatetool: HOST_CFLAGS+=-Iutil/ # Build on a limited subset of boards to save build time -ifeq ($(BOARD),meowth_fp) +ifeq ($(BOARD),nocturne_fp) build-util-bin+=ectool_servo endif diff --git a/util/flash_ec b/util/flash_ec index 1803a523ae..72de0f6306 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -71,7 +71,6 @@ BOARDS_STM32=( jerry kitty kukui - meowth_fp minimuffin nami_fp nocturne_fp @@ -140,11 +139,9 @@ BOARDS_NPCX_INT_SPI=( fleex grunt meep - meowth nocturne phaser yorp - zoombini ) BOARDS_NPCX_UUT=( @@ -643,7 +640,7 @@ case "${BOARD}" in chocodile_bec ) MCU="usbpd" ;; oak_pd|samus_pd|strago_pd ) MCU="usbpd" ;; chell_pd|glados_pd ) MCU="usbpd" ;; - meowth_fp|nami_fp|nocturne_fp ) MCU="usbpd" ;; + nami_fp|nocturne_fp ) MCU="usbpd" ;; dingdong|hoho|twinkie ) DUT_CONTROL_CMD="true" ; MCU="ec" ;; *) MCU="ec" ;; esac @@ -833,14 +830,6 @@ function flash_flashrom() { # Servo micro doesn't support this control. dut_control spi1_buf_on_flex_en:on fi - - # b/65694390: Zoombini and Meowth take enough power that when - # flashing without power, the SPI Vref voltage dips for a little - # bit. Therefore, wait 1 second to let the voltage stabilize. - if [[ "${BOARD}" == "zoombini" || \ - "${BOARD}" == "meowth" ]]; then - sleep 1 - fi else if [ $board_is_npcx_internal_spi -eq 0 ]; then # Set GP_SEL# as low then start ec |