diff options
author | Andrew McRae <amcrae@google.com> | 2020-09-16 18:51:20 +1000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-09-17 01:59:51 +0000 |
commit | c3256cdae920d801cabdff7204e6e61f556cac87 (patch) | |
tree | 518a4d2ee0580111eba5210ea4617d207d6b573b /board/dooly | |
parent | 5c752c2eec0a1ba2c3e801c3d91c274cfcc4d728 (diff) | |
download | chrome-ec-c3256cdae920d801cabdff7204e6e61f556cac87.tar.gz |
Dooly: Initial EC board configuration
Initial Dooly board and GPIO configuration.
BUG=b:164921469
TEST=buildall
BRANCH=none
Signed-off-by: Andrew McRae <amcrae@google.com>
Change-Id: Iec035a1e3f31d094888ab9a2283fc429512e328b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2413807
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Commit-Queue: Andrew McRae <amcrae@chromium.org>
Tested-by: Andrew McRae <amcrae@chromium.org>
Diffstat (limited to 'board/dooly')
-rw-r--r-- | board/dooly/board.c | 186 | ||||
-rw-r--r-- | board/dooly/board.h | 37 | ||||
-rw-r--r-- | board/dooly/gpio.inc | 67 | ||||
-rw-r--r-- | board/dooly/led.c | 60 |
4 files changed, 184 insertions, 166 deletions
diff --git a/board/dooly/board.c b/board/dooly/board.c index 376d615ce1..15c4a877d1 100644 --- a/board/dooly/board.c +++ b/board/dooly/board.c @@ -54,19 +54,47 @@ DECLARE_DEFERRED(power_monitor); static void ppc_interrupt(enum gpio_signal signal) { - if (signal == GPIO_USB_C0_TCPPC_INT_ODL) - sn5s330_interrupt(0); + switch (signal) { + case GPIO_USB_C0_TCPPC_INT_ODL: + sn5s330_interrupt(USB_PD_PORT_TCPC_0); + break; + case GPIO_USB_C1_TCPPC_INT_ODL: + sn5s330_interrupt(USB_PD_PORT_TCPC_1); + break; + default: + break; + } } int ppc_get_alert_status(int port) { - return gpio_get_level(GPIO_USB_C0_TCPPC_INT_ODL) == 0; + int status = 0; + + switch (port) { + case USB_PD_PORT_TCPC_0: + status = gpio_get_level(GPIO_USB_C0_TCPPC_INT_ODL) == 0; + break; + case USB_PD_PORT_TCPC_1: + status = gpio_get_level(GPIO_USB_C1_TCPPC_INT_ODL) == 0; + break; + default: + break; + } + return status; } static void tcpc_alert_event(enum gpio_signal signal) { - if (signal == GPIO_USB_C0_TCPC_INT_ODL) - schedule_deferred_pd_interrupt(0); + switch (signal) { + case GPIO_USB_C0_TCPC_INT_ODL: + schedule_deferred_pd_interrupt(USB_PD_PORT_TCPC_0); + break; + case GPIO_USB_C1_TCPC_INT_ODL: + schedule_deferred_pd_interrupt(USB_PD_PORT_TCPC_1); + break; + default: + break; + } } uint16_t tcpc_get_alert_status(void) @@ -84,6 +112,12 @@ uint16_t tcpc_get_alert_status(void) if (gpio_get_level(GPIO_USB_C0_TCPC_RST) != level) status |= PD_STATUS_TCPC_ALERT_0; } + if (!gpio_get_level(GPIO_USB_C1_TCPC_INT_ODL)) { + level = !!(tcpc_config[USB_PD_PORT_TCPC_1].flags & + TCPC_FLAGS_RESET_ACTIVE_HIGH); + if (gpio_get_level(GPIO_USB_C1_TCPC_RST) != level) + status |= PD_STATUS_TCPC_ALERT_1; + } return status; } @@ -99,7 +133,8 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, led_alert(insufficient_power); } -static uint8_t usbc_overcurrent; +static uint8_t usbc_0_overcurrent; +static uint8_t usbc_1_overcurrent; static int32_t base_5v_power; /* @@ -109,8 +144,6 @@ static int32_t base_5v_power; #define PWR_BASE_LOAD (5*1335) #define PWR_FRONT_HIGH (5*1603) #define PWR_FRONT_LOW (5*963) -#define PWR_REAR (5*1075) -#define PWR_HDMI (5*562) #define PWR_C_HIGH (5*3740) #define PWR_C_LOW (5*2090) #define PWR_MAX (5*10000) @@ -139,17 +172,9 @@ static void update_5v_usage(void) */ if (front_ports > 0) base_5v_power += PWR_FRONT_HIGH - PWR_FRONT_LOW; - if (!gpio_get_level(GPIO_USB_A2_OC_ODL)) - base_5v_power += PWR_REAR; - if (!gpio_get_level(GPIO_USB_A3_OC_ODL)) - base_5v_power += PWR_REAR; - if (ec_config_get_usb4_present() && !gpio_get_level(GPIO_USB_A4_OC_ODL)) - base_5v_power += PWR_REAR; - if (!gpio_get_level(GPIO_HDMI_CONN0_OC_ODL)) - base_5v_power += PWR_HDMI; - if (!gpio_get_level(GPIO_HDMI_CONN1_OC_ODL)) - base_5v_power += PWR_HDMI; - if (usbc_overcurrent) + if (usbc_0_overcurrent) + base_5v_power += PWR_C_HIGH; + if (usbc_1_overcurrent) base_5v_power += PWR_C_HIGH; /* * Invoke the power handler immediately. @@ -255,11 +280,7 @@ const struct pwm_t pwm_channels[] = { [PWM_CH_FAN] = { .channel = 5, .flags = PWM_CONFIG_OPEN_DRAIN, .freq = 25000}, - [PWM_CH_LED_RED] = { .channel = 0, - .flags = PWM_CONFIG_ACTIVE_LOW | - PWM_CONFIG_DSLEEP, - .freq = 2000 }, - [PWM_CH_LED_GREEN] = { .channel = 2, + [PWM_CH_LED_WHITE] = { .channel = 0, .flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP, .freq = 2000 }, @@ -277,6 +298,15 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { .drv = &anx7447_tcpm_drv, .flags = TCPC_FLAGS_RESET_ACTIVE_HIGH, }, + [USB_PD_PORT_TCPC_1] = { + .bus_type = EC_BUS_TYPE_I2C, + .i2c_info = { + .port = I2C_PORT_TCPC1, + .addr_flags = AN7447_TCPC0_I2C_ADDR_FLAGS, + }, + .drv = &anx7447_tcpm_drv, + .flags = TCPC_FLAGS_RESET_ACTIVE_HIGH, + }, }; const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { [USB_PD_PORT_TCPC_0] = { @@ -284,6 +314,11 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { .driver = &anx7447_usb_mux_driver, .hpd_update = &anx7447_tcpc_update_hpd_status, }, + [USB_PD_PORT_TCPC_1] = { + .usb_port = USB_PD_PORT_TCPC_1, + .driver = &anx7447_usb_mux_driver, + .hpd_update = &anx7447_tcpc_update_hpd_status, + }, }; /******************************************************************************/ @@ -291,7 +326,9 @@ const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { const struct i2c_port_t i2c_ports[] = { {"ina", I2C_PORT_INA, 400, GPIO_I2C0_SCL, GPIO_I2C0_SDA}, {"ppc0", I2C_PORT_PPC0, 400, GPIO_I2C1_SCL, GPIO_I2C1_SDA}, + {"ppc1", I2C_PORT_PPC1, 400, GPIO_I2C2_SCL, GPIO_I2C1_SDA}, {"tcpc0", I2C_PORT_TCPC0, 400, GPIO_I2C3_SCL, GPIO_I2C3_SDA}, + {"tcpc1", I2C_PORT_TCPC1, 400, GPIO_I2C4_SCL, GPIO_I2C3_SDA}, {"power", I2C_PORT_POWER, 400, GPIO_I2C5_SCL, GPIO_I2C5_SDA}, {"eeprom", I2C_PORT_EEPROM, 400, GPIO_I2C7_SCL, GPIO_I2C7_SDA}, }; @@ -334,16 +371,28 @@ const struct adc_t adc_channels[] = { .factor_mul = ADC_MAX_VOLT, .factor_div = ADC_READ_MAX + 1, }, + [ADC_TEMP_SENSOR_2] = { + .name = "TEMP_SENSOR_2", + .input_ch = NPCX_ADC_CH1, + .factor_mul = ADC_MAX_VOLT, + .factor_div = ADC_READ_MAX + 1, + }, }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); const struct temp_sensor_t temp_sensors[] = { - [TEMP_SENSOR_CORE] = { - .name = "Core", + [TEMP_SENSOR_1] = { + .name = "PP3300", .type = TEMP_SENSOR_TYPE_BOARD, .read = get_temp_3v3_30k9_47k_4050b, .idx = ADC_TEMP_SENSOR_1, }, + [TEMP_SENSOR_2] = { + .name = "PP5000", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_30k9_47k_4050b, + .idx = ADC_TEMP_SENSOR_2, + }, }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); @@ -398,7 +447,8 @@ const static struct ec_thermal_config thermal_a = { }; struct ec_thermal_config thermal_params[] = { - [TEMP_SENSOR_CORE] = thermal_a, + [TEMP_SENSOR_1] = thermal_a, + [TEMP_SENSOR_2] = thermal_a, }; BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); @@ -462,12 +512,6 @@ static void board_init(void) /* Always claim AC is online, because we don't have a battery. */ memmap_batt_flags = host_get_memmap(EC_MEMMAP_BATT_FLAG); *memmap_batt_flags |= EC_BATT_FLAG_AC_PRESENT; - /* - * For board version < 2, the directly connected recovery - * button is not available. - */ - if (board_version < 2) - button_disable_gpio(GPIO_EC_RECOVERY_BTN_ODL); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); @@ -483,8 +527,10 @@ static void board_chipset_startup(void) * The workaround is to check whether the PPC is sourcing VBUS, and * if so, make sure it is enabled. */ - if (ppc_is_sourcing_vbus(0)) - ppc_vbus_source_enable(0, 1); + if (ppc_is_sourcing_vbus(USB_PD_PORT_TCPC_0)) + ppc_vbus_source_enable(USB_PD_PORT_TCPC_0, 1); + if (ppc_is_sourcing_vbus(USB_PD_PORT_TCPC_1)) + ppc_vbus_source_enable(USB_PD_PORT_TCPC_1, 1); } DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); @@ -496,6 +542,11 @@ struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { .i2c_addr_flags = SN5S330_ADDR0_FLAGS, .drv = &sn5s330_drv }, + [USB_PD_PORT_TCPC_1] = { + .i2c_port = I2C_PORT_PPC1, + .i2c_addr_flags = SN5S330_ADDR0_FLAGS, + .drv = &sn5s330_drv + }, }; unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); @@ -517,24 +568,11 @@ static void board_tcpc_init(void) /* Enable TCPC interrupts. */ gpio_enable_interrupt(GPIO_USB_C0_TCPPC_INT_ODL); gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_TCPPC_INT_ODL); + gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL); /* Enable other overcurrent interrupts */ - gpio_enable_interrupt(GPIO_HDMI_CONN0_OC_ODL); - gpio_enable_interrupt(GPIO_HDMI_CONN1_OC_ODL); gpio_enable_interrupt(GPIO_USB_A0_OC_ODL); gpio_enable_interrupt(GPIO_USB_A1_OC_ODL); - gpio_enable_interrupt(GPIO_USB_A2_OC_ODL); - gpio_enable_interrupt(GPIO_USB_A3_OC_ODL); - if (ec_config_get_usb4_present()) { - /* - * By default configured as output low. - */ - gpio_set_flags(GPIO_USB_A4_OC_ODL, - GPIO_INPUT | GPIO_INT_BOTH); - gpio_enable_interrupt(GPIO_USB_A4_OC_ODL); - } else { - /* Ensure no interrupts from pin */ - gpio_disable_interrupt(GPIO_USB_A4_OC_ODL); - } } /* Make sure this is called after fw_config is initialised */ @@ -548,12 +586,16 @@ int64_t get_time_dsw_pwrok(void) void board_reset_pd_mcu(void) { - int level = !!(tcpc_config[USB_PD_PORT_TCPC_0].flags & - TCPC_FLAGS_RESET_ACTIVE_HIGH); + int level0 = !!(tcpc_config[USB_PD_PORT_TCPC_0].flags & + TCPC_FLAGS_RESET_ACTIVE_HIGH); + int level1 = !!(tcpc_config[USB_PD_PORT_TCPC_1].flags & + TCPC_FLAGS_RESET_ACTIVE_HIGH); - gpio_set_level(GPIO_USB_C0_TCPC_RST, level); + gpio_set_level(GPIO_USB_C0_TCPC_RST, level0); + gpio_set_level(GPIO_USB_C1_TCPC_RST, level1); msleep(BOARD_TCPC_C0_RESET_HOLD_DELAY); - gpio_set_level(GPIO_USB_C0_TCPC_RST, !level); + gpio_set_level(GPIO_USB_C0_TCPC_RST, !level0); + gpio_set_level(GPIO_USB_C1_TCPC_RST, !level1); if (BOARD_TCPC_C0_RESET_POST_DELAY) msleep(BOARD_TCPC_C0_RESET_POST_DELAY); } @@ -605,6 +647,7 @@ int board_set_active_charge_port(int port) switch (port) { case CHARGE_PORT_TYPEC0: + case CHARGE_PORT_TYPEC1: /* TODO(b/143975429) need to touch the PD controller? */ gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 1); break; @@ -624,10 +667,16 @@ int board_set_active_charge_port(int port) void board_overcurrent_event(int port, int is_overcurrented) { - /* Check that port number is valid. */ - if ((port < 0) || (port >= CONFIG_USB_PD_PORT_MAX_COUNT)) + switch (port) { + case USB_PD_PORT_TCPC_0: + usbc_0_overcurrent = is_overcurrented; + break; + case USB_PD_PORT_TCPC_1: + usbc_1_overcurrent = is_overcurrented; + break; + default: return; - usbc_overcurrent = is_overcurrented; + } update_5v_usage(); } @@ -638,18 +687,11 @@ int extpower_is_present(void) int board_is_c10_gate_enabled(void) { - /* - * Puff proto drives EN_PP5000_HDMI from EN_S0_RAILS so we cannot gate - * core rails while in S0 because HDMI should remain powered. - * EN_PP5000_HDMI is a separate EC output on all other boards. - */ - return board_version != 0; + return 1; } void board_enable_s0_rails(int enable) { - /* This output isn't connected on protos; safe to set anyway. */ - gpio_set_level(GPIO_EN_PP5000_HDMI, enable); } unsigned int ec_config_get_bj_power(void) @@ -662,11 +704,6 @@ unsigned int ec_config_get_bj_power(void) return bj; } -int ec_config_get_usb4_present(void) -{ - return !(fw_config & EC_CFG_NO_USB4_MASK); -} - unsigned int ec_config_get_thermal_solution(void) { return (fw_config & EC_CFG_THERMAL_MASK) >> EC_CFG_THERMAL_L; @@ -820,12 +857,14 @@ static void power_monitor(void) /* * If the type-C port is sourcing power, * check whether it should be throttled. + * TODO(amcrae): selectively disable ports. */ - if (ppc_is_sourcing_vbus(0) && gap <= 0) { + if (gap <= 0 && (ppc_is_sourcing_vbus(0) || + ppc_is_sourcing_vbus(1))) { new_state |= THROT_TYPE_C; headroom_5v += PWR_C_HIGH - PWR_C_LOW; if (!(current_state & THROT_TYPE_C)) - gap += POWER_GAIN_TYPE_C; + gap += POWER_GAIN_TYPE_C * 2; } /* * As a last resort, turn on PROCHOT to @@ -857,7 +896,8 @@ static void power_monitor(void) * Check whether type C is not throttled, * and is not overcurrent. */ - if (!((new_state & THROT_TYPE_C) || usbc_overcurrent)) { + if (!((new_state & THROT_TYPE_C) || + usbc_0_overcurrent || usbc_1_overcurrent)) { /* * [1] Type C not in overcurrent, throttle it. */ diff --git a/board/dooly/board.h b/board/dooly/board.h index 714cbc870f..39ff870980 100644 --- a/board/dooly/board.h +++ b/board/dooly/board.h @@ -25,11 +25,7 @@ #define CONFIG_BOARD_HAS_RTC_RESET #define CONFIG_BOARD_VERSION_CBI #define CONFIG_DEDICATED_RECOVERY_BUTTON -#define CONFIG_DEDICATED_RECOVERY_BUTTON_2 -#define CONFIG_BUTTONS_RUNTIME_CONFIG #define CONFIG_BOARD_RESET_AFTER_POWER_ON -/* TODO: (b/143496253) re-enable CEC */ -/* #define CONFIG_CEC */ #define CONFIG_CRC8 #define CONFIG_CROS_BOARD_INFO #define CONFIG_EMULATED_SYSRQ @@ -90,7 +86,13 @@ /* Dedicated barreljack charger port */ #undef CONFIG_DEDICATED_CHARGE_PORT_COUNT #define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1 -#define DEDICATED_CHARGE_PORT 1 +#define DEDICATED_CHARGE_PORT 2 + +/* + * TODO(amcrae): Currently we do not allow both + * dedicated recovery button and volume buttons. + */ +#undef CONFIG_VOLUME_BUTTONS #define CONFIG_POWER_BUTTON #define CONFIG_POWER_BUTTON_IGNORE_LID @@ -145,7 +147,7 @@ #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_PORT_MAX_COUNT 1 +#define CONFIG_USB_PD_PORT_MAX_COUNT 2 #define CONFIG_USB_PD_VBUS_DETECT_PPC #define CONFIG_USBC_PPC_SN5S330 #define CONFIG_USBC_PPC_DEDICATED_INT @@ -162,10 +164,13 @@ #define USB_PD_PORT_TCPC_0 0 #define BOARD_TCPC_C0_RESET_HOLD_DELAY ANX74XX_RESET_HOLD_MS #define BOARD_TCPC_C0_RESET_POST_DELAY ANX74XX_RESET_HOLD_MS +#define USB_PD_PORT_TCPC_1 1 +#define BOARD_TCPC_C1_RESET_HOLD_DELAY ANX74XX_RESET_HOLD_MS +#define BOARD_TCPC_C1_RESET_POST_DELAY ANX74XX_RESET_HOLD_MS /* USB Type A Features */ #define CONFIG_USB_PORT_POWER_DUMB -/* There are five ports, but power enable is ganged across all of them. */ +/* There are two ports, but power enable is ganged across all of them. */ #define USB_PORT_COUNT 1 /* I2C Bus Configuration */ @@ -173,7 +178,9 @@ #define CONFIG_I2C_MASTER #define I2C_PORT_INA NPCX_I2C_PORT0_0 #define I2C_PORT_PPC0 NPCX_I2C_PORT1_0 +#define I2C_PORT_PPC1 NPCX_I2C_PORT2_0 #define I2C_PORT_TCPC0 NPCX_I2C_PORT3_0 +#define I2C_PORT_TCPC1 NPCX_I2C_PORT4_1 #define I2C_PORT_POWER NPCX_I2C_PORT5_0 #define I2C_PORT_EEPROM NPCX_I2C_PORT7_0 #define I2C_ADDR_EEPROM_FLAGS 0x50 @@ -187,6 +194,7 @@ enum charge_port { CHARGE_PORT_TYPEC0, + CHARGE_PORT_TYPEC1, CHARGE_PORT_BARRELJACK, }; @@ -196,14 +204,14 @@ enum adc_channel { ADC_VBUS, /* ADC4 */ ADC_PPVAR_IMON, /* ADC9 */ ADC_TEMP_SENSOR_1, /* ADC0 */ + ADC_TEMP_SENSOR_2, /* ADC1 */ /* Number of ADC channels */ ADC_CH_COUNT }; enum pwm_channel { PWM_CH_FAN, - PWM_CH_LED_RED, - PWM_CH_LED_GREEN, + PWM_CH_LED_WHITE, /* Number of PWM channels */ PWM_CH_COUNT }; @@ -221,7 +229,8 @@ enum mft_channel { }; enum temp_sensor_id { - TEMP_SENSOR_CORE, + TEMP_SENSOR_1, + TEMP_SENSOR_2, TEMP_SENSOR_COUNT }; @@ -233,7 +242,7 @@ void led_alert(int enable); void show_critical_error(void); /* - * firmware config fields + * firmware config fields - keep in sync with Puff. */ /* * Barrel-jack power (4 bits). @@ -242,7 +251,7 @@ void show_critical_error(void); #define EC_CFG_BJ_POWER_H 3 #define EC_CFG_BJ_POWER_MASK GENMASK(EC_CFG_BJ_POWER_H, EC_CFG_BJ_POWER_L) /* - * USB Connector 4 not present (1 bit). + * USB Connector 4 not present (1 bit) (not used). */ #define EC_CFG_NO_USB4_L 4 #define EC_CFG_NO_USB4_H 4 @@ -255,7 +264,6 @@ void show_critical_error(void); #define EC_CFG_THERMAL_MASK GENMASK(EC_CFG_THERMAL_H, EC_CFG_THERMAL_L) unsigned int ec_config_get_bj_power(void); -int ec_config_get_usb4_present(void); unsigned int ec_config_get_thermal_solution(void); #endif /* !__ASSEMBLER__ */ @@ -265,8 +273,9 @@ unsigned int ec_config_get_thermal_solution(void); #define GPIO_PP5000_A_PG_OD GPIO_PG_PP5000_A_OD #define GPIO_EN_PP5000 GPIO_EN_PP5000_A #define GPIO_RECOVERY_L GPIO_EC_RECOVERY_BTN_ODL -#define GPIO_RECOVERY_L_2 GPIO_H1_EC_RECOVERY_BTN_ODL #define GPIO_POWER_BUTTON_L GPIO_H1_EC_PWR_BTN_ODL +#define GPIO_VOLUME_UP_L GPIO_EC_VOLUP_BTN_ODL +#define GPIO_VOLUME_DOWN_L GPIO_EC_VOLDN_BTN_ODL #define GPIO_PCH_WAKE_L GPIO_EC_PCH_WAKE_ODL #define GPIO_PCH_PWRBTN_L GPIO_EC_PCH_PWR_BTN_ODL #define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW diff --git a/board/dooly/gpio.inc b/board/dooly/gpio.inc index 7876786f38..70a839ab50 100644 --- a/board/dooly/gpio.inc +++ b/board/dooly/gpio.inc @@ -40,8 +40,10 @@ GPIO_INT(IMVP8_VRRDY_OD, PIN(1, 6), GPIO_INT_BOTH, power_signal_interrupt) /* Other interrupts */ GPIO_INT(USB_C0_TCPPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, ppc_interrupt) GPIO_INT(USB_C0_TCPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, tcpc_alert_event) +GPIO_INT(USB_C1_TCPPC_INT_ODL, PIN(D, 6), GPIO_INT_FALLING, ppc_interrupt) +GPIO_INT(USB_C1_TCPC_INT_ODL, PIN(3, 2), GPIO_INT_FALLING, tcpc_alert_event) /* - * Directly connected recovery button (not available on some boards). + * Directly connected recovery button. */ GPIO_INT(EC_RECOVERY_BTN_ODL, PIN(F, 1), GPIO_INT_BOTH, button_interrupt) /* @@ -51,14 +53,12 @@ GPIO_INT(H1_EC_RECOVERY_BTN_ODL, PIN(2, 4), GPIO_INT_BOTH, button_interrupt) GPIO_INT(BJ_ADP_PRESENT_L, PIN(8, 2), GPIO_INT_BOTH | GPIO_PULL_UP, adp_connect_interrupt) /* Port power control interrupts */ -GPIO_INT(HDMI_CONN0_OC_ODL, PIN(0, 7), GPIO_INT_BOTH, port_ocp_interrupt) -GPIO_INT(HDMI_CONN1_OC_ODL, PIN(0, 6), GPIO_INT_BOTH, port_ocp_interrupt) -GPIO_INT(USB_A0_OC_ODL, PIN(E, 4), GPIO_INT_BOTH, port_ocp_interrupt) -GPIO_INT(USB_A1_OC_ODL, PIN(A, 2), GPIO_INT_BOTH, port_ocp_interrupt) -GPIO_INT(USB_A2_OC_ODL, PIN(F, 5), GPIO_INT_BOTH, port_ocp_interrupt) -GPIO_INT(USB_A3_OC_ODL, PIN(0, 3), GPIO_INT_BOTH, port_ocp_interrupt) -/* May be reconfigured as input */ -GPIO_INT(USB_A4_OC_ODL, PIN(B, 0), GPIO_OUT_LOW | GPIO_INT_BOTH, port_ocp_interrupt) +GPIO_INT(USB_A0_OC_ODL, PIN(F, 5), GPIO_INT_BOTH, port_ocp_interrupt) +GPIO_INT(USB_A1_OC_ODL, PIN(0, 3), GPIO_INT_BOTH, port_ocp_interrupt) + +/* Volume button interrupts */ +GPIO_INT(EC_VOLDN_BTN_ODL, PIN(9, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) +GPIO_INT(EC_VOLUP_BTN_ODL, PIN(8, 0), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) /* PCH/CPU signals */ GPIO(EC_PCH_PWROK, PIN(0, 5), GPIO_OUT_LOW) @@ -87,54 +87,54 @@ GPIO(EN_PPVAR_BJ_ADP_L, PIN(0, 4), GPIO_OUT_LOW) /* USB type A */ GPIO(EN_PP5000_USB_VBUS, PIN(8, 3), GPIO_OUT_LOW) GPIO(USB_A_LOW_PWR_OD, PIN(9, 4), GPIO_ODR_LOW) -GPIO(USB_A2_STATUS_L, PIN(6, 1), GPIO_INPUT) -GPIO(USB_A3_STATUS_L, PIN(C, 7), GPIO_INPUT) +GPIO(USB_A0_STATUS_L, PIN(6, 1), GPIO_INPUT) /* Marked as A2 */ +GPIO(USB_A1_STATUS_L, PIN(C, 7), GPIO_INPUT) /* Marked as A3 */ /* USB type C */ GPIO(USB_C0_TCPC_RST, PIN(9, 7), GPIO_OUT_LOW) +GPIO(USB_C1_TCPC_RST, PIN(D, 2), GPIO_OUT_LOW) /* Misc. */ GPIO(M2_SSD_PLN, PIN(A, 0), GPIO_INPUT) GPIO(EC_ENTERING_RW, PIN(E, 3), GPIO_OUT_LOW) GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_ODR_HIGH) -GPIO(EN_PP_MST_OD, PIN(9, 6), GPIO_ODR_HIGH) GPIO(PACKET_MODE_EN, PIN(7, 5), GPIO_OUT_LOW) -/* HDMI/CEC */ -GPIO(EN_PP5000_HDMI, PIN(5, 0), GPIO_OUT_LOW) -GPIO(HDMI_CONN0_CEC_OUT, PIN(B, 1), GPIO_ODR_HIGH) -GPIO(HDMI_CONN0_CEC_IN, PIN(4, 0), GPIO_INPUT) -GPIO(HDMI_CONN1_CEC_OUT, PIN(9, 5), GPIO_ODR_HIGH) -GPIO(HDMI_CONN1_CEC_IN, PIN(D, 3), GPIO_INPUT) - /* I2C pins - Alternate function below configures I2C module on these pins */ GPIO(I2C0_SCL, PIN(B, 5), GPIO_INPUT) /* EC_I2C_INA_SCL */ GPIO(I2C0_SDA, PIN(B, 4), GPIO_INPUT) /* EC_I2C_INA_SDA */ GPIO(I2C1_SCL, PIN(9, 0), GPIO_INPUT) /* EC_I2C_USB_C0_TCPPC_SCL */ GPIO(I2C1_SDA, PIN(8, 7), GPIO_INPUT) /* EC_I2C_USB_C0_TCPPC_SDA */ +GPIO(I2C2_SCL, PIN(9, 2), GPIO_INPUT) /* EC_I2C_USB_C1_TCPPC_SCL */ +GPIO(I2C2_SDA, PIN(9, 1), GPIO_INPUT) /* EC_I2C_USB_C1_TCPPC_SDA */ GPIO(I2C3_SCL, PIN(D, 1), GPIO_INPUT) /* EC_I2C_USB_C0_TCPC_SCL */ GPIO(I2C3_SDA, PIN(D, 0), GPIO_INPUT) /* EC_I2C_USB_C0_TCPC_SDA */ +GPIO(I2C4_SCL, PIN(F, 3), GPIO_INPUT) /* EC_I2C_USB_C1_TCPC_SCL */ +GPIO(I2C4_SDA, PIN(F, 2), GPIO_INPUT) /* EC_I2C_USB_C1_TCPC_SDA */ GPIO(I2C5_SCL, PIN(3, 3), GPIO_INPUT) /* EC_I2C_IMVP8_SCL */ GPIO(I2C5_SDA, PIN(3, 6), GPIO_INPUT) /* EC_I2C_IMVP8_SDA */ +/* + * Also used for LCM backlight. + */ GPIO(I2C7_SCL, PIN(B, 3), GPIO_INPUT) /* EC_I2C_EEPROM_SCL */ GPIO(I2C7_SDA, PIN(B, 2), GPIO_INPUT) /* EC_I2C_EEPROM_SDA */ /* Alternate functions GPIO definitions */ ALTERNATE(PIN_MASK(B, 0x30), 0, MODULE_I2C, 0) /* I2C0 */ -ALTERNATE(PIN_MASK(9, 0x01), 0, MODULE_I2C, 0) /* I2C1 SCL */ +ALTERNATE(PIN_MASK(9, 0x07), 0, MODULE_I2C, 0) /* I2C1 SCL / I2C2 */ ALTERNATE(PIN_MASK(8, 0x80), 0, MODULE_I2C, 0) /* I2C1 SDA */ ALTERNATE(PIN_MASK(D, 0x03), 0, MODULE_I2C, 0) /* I2C3 */ +ALTERNATE(PIN_MASK(F, 0x0C), 0, MODULE_I2C, 0) /* I2C4 */ ALTERNATE(PIN_MASK(3, 0x48), 0, MODULE_I2C, 0) /* I2C5 */ ALTERNATE(PIN_MASK(B, 0x0C), 0, MODULE_I2C, 0) /* I2C7 */ /* PWM */ -ALTERNATE(PIN_MASK(C, 0x08), 0, MODULE_PWM, 0) /* PWM0 - Red Led */ -ALTERNATE(PIN_MASK(C, 0x10), 0, MODULE_PWM, 0) /* PWM2 - Green Led */ +ALTERNATE(PIN_MASK(C, 0x10), 0, MODULE_PWM, 0) /* PWM2 - White Led */ ALTERNATE(PIN_MASK(B, 0x80), 0, MODULE_PWM, 0) /* PWM5 - Fan 1 */ ALTERNATE(PIN_MASK(7, 0x08), 0, MODULE_PWM, 0) /* TA2 - Fan Tachometer */ /* ADC */ -ALTERNATE(PIN_MASK(4, 0x2A), 0, MODULE_ADC, 0) /* ADC0, ADC2, ADC4 */ +ALTERNATE(PIN_MASK(4, 0x3A), 0, MODULE_ADC, 0) /* ADC0 - ADC2, ADC4 */ ALTERNATE(PIN_MASK(E, 0x02), 0, MODULE_ADC, 0) /* ADC7 */ ALTERNATE(PIN_MASK(F, 0x01), 0, MODULE_ADC, 0) /* ADC9 */ @@ -142,16 +142,21 @@ ALTERNATE(PIN_MASK(F, 0x01), 0, MODULE_ADC, 0) /* ADC9 */ ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* UART from EC to Servo */ /* Unused pins */ +UNUSED(PIN(D, 3)) /* E9 TP55 */ +UNUSED(PIN(9, 5)) /* H10 TP54 */ +UNUSED(PIN(4, 0)) /* E4 TP56 */ +UNUSED(PIN(B, 1)) /* F8 TP59 */ +UNUSED(PIN(5, 0)) /* G4 NC */ +UNUSED(PIN(9, 6)) /* M12 TP998 */ +UNUSED(PIN(0, 7)) /* E8 TP991 */ +UNUSED(PIN(0, 6)) /* B10 TP992 */ +UNUSED(PIN(E, 4)) /* H8 TP993 */ +UNUSED(PIN(A, 2)) /* J11 TP994 */ +UNUSED(PIN(B, 0)) /* G8 TP49 */ UNUSED(PIN(1, 3)) /* EC_GP_SEL1_ODL */ -UNUSED(PIN(F, 2)) /* EC_I2C_RFU_SDA */ -UNUSED(PIN(F, 3)) /* EC_I2C_RFU_SCL */ UNUSED(PIN(C, 0)) /* FAN_PWM_2 */ -UNUSED(PIN(8, 0)) /* LED_BLUE_L */ -UNUSED(PIN(4, 4)) /* ADC1/TEMP_SENSOR_2 */ UNUSED(PIN(4, 2)) /* ADC3/TEMP_SENSOR_3 */ UNUSED(PIN(C, 2)) /* A12 NC */ -UNUSED(PIN(9, 2)) /* K8 NC */ -UNUSED(PIN(9, 1)) /* L8 NC */ UNUSED(PIN(1, 2)) /* C6 NC */ UNUSED(PIN(6, 6)) /* H4 NC */ UNUSED(PIN(8, 1)) /* L6 NC */ @@ -159,11 +164,7 @@ UNUSED(PIN(C, 6)) /* B11 NC */ UNUSED(PIN(E, 2)) /* B8 NC */ UNUSED(PIN(8, 5)) /* L7 NC */ UNUSED(PIN(0, 0)) /* D11 NC */ -UNUSED(PIN(3, 2)) /* E5 NC */ -UNUSED(PIN(D, 6)) /* F6 NC */ UNUSED(PIN(3, 5)) /* F5 NC */ UNUSED(PIN(5, 6)) /* M2 NC */ -UNUSED(PIN(D, 2)) /* C11 NC */ UNUSED(PIN(8, 6)) /* J8 NC */ -UNUSED(PIN(9, 3)) /* M11 NC */ UNUSED(PIN(7, 2)) /* H6 NC */ diff --git a/board/dooly/led.c b/board/dooly/led.c index 2c910bcbdb..eeb52b2844 100644 --- a/board/dooly/led.c +++ b/board/dooly/led.c @@ -33,9 +33,7 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); enum led_color { LED_OFF = 0, - LED_RED, - LED_GREEN, - LED_AMBER, + LED_WHITE, /* Number of colors, not a color itself */ LED_COLOR_COUNT @@ -43,39 +41,20 @@ enum led_color { static int set_color_power(enum led_color color, int duty) { - int green = 0; - int red = 0; - if (duty < 0 || 100 < duty) return EC_ERROR_UNKNOWN; switch (color) { case LED_OFF: + pwm_set_duty(PWM_CH_LED_WHITE, 0); break; - case LED_GREEN: - green = 1; - break; - case LED_RED: - red = 1; - break; - case LED_AMBER: - green = 1; - red = 1; + case LED_WHITE: + pwm_set_duty(PWM_CH_LED_WHITE, duty); break; default: return EC_ERROR_UNKNOWN; } - if (red) - pwm_set_duty(PWM_CH_LED_RED, duty); - else - pwm_set_duty(PWM_CH_LED_RED, 0); - - if (green) - pwm_set_duty(PWM_CH_LED_GREEN, duty); - else - pwm_set_duty(PWM_CH_LED_GREEN, 0); - return EC_SUCCESS; } @@ -141,7 +120,7 @@ static void led_tick(void) static void led_suspend(void) { - CONFIGURE_TICK(LED_PULSE_TICK_US, LED_GREEN); + CONFIGURE_TICK(LED_PULSE_TICK_US, LED_WHITE); led_tick(); } DECLARE_DEFERRED(led_suspend); @@ -179,14 +158,13 @@ static void led_resume(void) hook_call_deferred(&led_suspend_data, -1); hook_call_deferred(&led_shutdown_data, -1); if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) - set_color(EC_LED_ID_POWER_LED, LED_GREEN, 100); + set_color(EC_LED_ID_POWER_LED, LED_WHITE, 100); } DECLARE_HOOK(HOOK_CHIPSET_RESUME, led_resume, HOOK_PRIO_DEFAULT); static void led_init(void) { - pwm_enable(PWM_CH_LED_RED, 1); - pwm_enable(PWM_CH_LED_GREEN, 1); + pwm_enable(PWM_CH_LED_WHITE, 1); } DECLARE_HOOK(HOOK_INIT, led_init, HOOK_PRIO_INIT_PWM + 1); @@ -194,7 +172,7 @@ void led_alert(int enable) { if (enable) { /* Overwrite the current signal */ - config_tick(1 * SECOND, 100, LED_RED); + config_tick(1 * SECOND, 100, LED_WHITE); led_tick(); } else { /* Restore the previous signal */ @@ -211,7 +189,7 @@ void show_critical_error(void) { hook_call_deferred(&led_tick_data, -1); if (led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) - set_color(EC_LED_ID_POWER_LED, LED_RED, 100); + set_color(EC_LED_ID_POWER_LED, LED_WHITE, 100); } static int command_led(int argc, char **argv) @@ -226,12 +204,8 @@ static int command_led(int argc, char **argv) ccprintf("o%s\n", led_auto_control_is_enabled(id) ? "ff" : "n"); } else if (!strcasecmp(argv[1], "off")) { set_color(id, LED_OFF, 0); - } else if (!strcasecmp(argv[1], "red")) { - set_color(id, LED_RED, 100); - } else if (!strcasecmp(argv[1], "green")) { - set_color(id, LED_GREEN, 100); - } else if (!strcasecmp(argv[1], "amber")) { - set_color(id, LED_AMBER, 100); + } else if (!strcasecmp(argv[1], "white")) { + set_color(id, LED_WHITE, 100); } else if (!strcasecmp(argv[1], "alert")) { led_alert(1); } else if (!strcasecmp(argv[1], "crit")) { @@ -247,19 +221,13 @@ DECLARE_CONSOLE_COMMAND(led, command_led, 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_AMBER] = 100; + brightness_range[EC_LED_COLOR_WHITE] = 100; } int led_set_brightness(enum ec_led_id id, const uint8_t *brightness) { - if (brightness[EC_LED_COLOR_RED]) - return set_color(id, LED_RED, brightness[EC_LED_COLOR_RED]); - else if (brightness[EC_LED_COLOR_GREEN]) - return set_color(id, LED_GREEN, brightness[EC_LED_COLOR_GREEN]); - else if (brightness[EC_LED_COLOR_AMBER]) - return set_color(id, LED_AMBER, brightness[EC_LED_COLOR_AMBER]); + if (brightness[EC_LED_COLOR_WHITE]) + return set_color(id, LED_WHITE, brightness[EC_LED_COLOR_WHITE]); else return set_color(id, LED_OFF, 0); } |