summaryrefslogtreecommitdiff
path: root/baseboard/honeybuns/baseboard.c
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2021-05-03 09:15:28 -0700
committerCommit Bot <commit-bot@chromium.org>2021-05-14 16:22:03 +0000
commit81bf98de282dcd11287fc8f5a95cc999437e7597 (patch)
tree84741f3242937acc2ac37e0500675054ef39e072 /baseboard/honeybuns/baseboard.c
parentbcc11b209a014da1436e9abb9a6cd2c2918869f5 (diff)
downloadchrome-ec-81bf98de282dcd11287fc8f5a95cc999437e7597.tar.gz
honeybuns: Board specific power button and LEDs
This CL modifies both power button press/release polairty and power button LED control signals to be board specific instead of platform specific. Previously there were platform specific macros for BUTTON_PRESSED_LEVEL and BUTTON_RELEASED_LEVEL. But, these levels will depend on how the power button circuit is designed. This CL moves these macros to board.h. In addition, macros are added to for the GPIO signals used for green/red LED control. This allows for boards that don't support the power button LED at all. BUG=b:164157329 BRANCH=quiche TEST=Verfied power button works on both quiche and gingerbread. Previously, this was only working on quiche because gingerbread has opposite polarity for the power button signal. Also, verfied that power button/status LED turns off when dock is off. Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: Iee838ee158d23252e8b429f51a1dd1a71d8e94a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2868225 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'baseboard/honeybuns/baseboard.c')
-rw-r--r--baseboard/honeybuns/baseboard.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/baseboard/honeybuns/baseboard.c b/baseboard/honeybuns/baseboard.c
index e61f447240..f32e6bed02 100644
--- a/baseboard/honeybuns/baseboard.c
+++ b/baseboard/honeybuns/baseboard.c
@@ -25,9 +25,6 @@
#define POWER_BUTTON_LONG_USEC (5000 * MSEC)
#define POWER_BUTTON_DEBOUNCE_USEC (30)
-#define BUTTON_PRESSED_LEVEL 1
-#define BUTTON_RELEASED_LEVEL 0
-
#define BUTTON_EVT_CHANGE BIT(0)
#define BUTTON_EVT_INFO BIT(1)
@@ -110,16 +107,16 @@ static void baseboard_set_led(enum led_color color)
CPRINTS("led: color = %d", color);
/* Not all boards may have LEDs under EC control */
-#if defined(GPIO_EC_STATUS_LED1) && defined(GPIO_EC_STATUS_LED2)
+#if defined(GPIO_PWR_BUTTON_RED) && defined(GPIO_PWR_BUTTON_GREEN)
if (color == OFF) {
- gpio_set_level(GPIO_EC_STATUS_LED1, 1);
- gpio_set_level(GPIO_EC_STATUS_LED2, 1);
+ gpio_set_level(GPIO_PWR_BUTTON_RED, 1);
+ gpio_set_level(GPIO_PWR_BUTTON_GREEN, 1);
} else if (color == GREEN) {
- gpio_set_level(GPIO_EC_STATUS_LED1, 1);
- gpio_set_level(GPIO_EC_STATUS_LED2, 0);
+ gpio_set_level(GPIO_PWR_BUTTON_RED, 1);
+ gpio_set_level(GPIO_PWR_BUTTON_GREEN, 0);
} else if (color == YELLOW) {
- gpio_set_level(GPIO_EC_STATUS_LED1, 0);
- gpio_set_level(GPIO_EC_STATUS_LED2, 0);
+ gpio_set_level(GPIO_PWR_BUTTON_RED, 0);
+ gpio_set_level(GPIO_PWR_BUTTON_GREEN, 0);
}
#endif
}
@@ -180,9 +177,14 @@ void baseboard_set_mst_lane_control(int mf)
static void baseboard_enable_mp4245(void)
{
+ int mv;
+ int ma;
+
mp4245_set_voltage_out(5000);
mp4245_votlage_out_enable(1);
msleep(MP4245_VOUT_5V_DELAY_MS);
+ mp3245_get_vbus(&mv, &ma);
+ CPRINTS("mp4245: vout @ %d mV enabled", mv);
}
#endif /* SECTION_IS_RW */
@@ -245,11 +247,16 @@ static void baseboard_power_on(void)
int port_max = board_get_usb_pd_port_count();
int port;
+ CPRINTS("pwrbtn: power on: mf = %d", dock_mf);
/* Adjust system flags to full PPC init occurs */
system_clear_reset_flags(EC_RESET_FLAG_POWER_ON);
system_set_reset_flags(EC_RESET_FLAG_EFS);
/* Enable power rails and release reset signals */
board_power_sequence(1);
+ /* Set VBUS to 5V and enable output from mp4245 */
+ baseboard_enable_mp4245();
+ /* Set dock mf preference LED */
+ baseboard_set_led(dock_mf);
/*
* Lane control (realtek MST) must be set prior to releasing MST
* reset.
@@ -268,8 +275,6 @@ static void baseboard_power_on(void)
/* Inform TC state machine that it can resume */
pd_set_suspend(port, 0);
}
- /* Set VBUS to 5V and enable output from mp4245 */
- baseboard_enable_mp4245();
/* Enable usbc interrupts */
board_enable_usbc_interrupts();
@@ -283,6 +288,7 @@ static void baseboard_power_off(void)
int port_max = board_get_usb_pd_port_count();
int port;
+ CPRINTS("pwrbtn: power off");
/* Put ports in TC suspend state */
for (port = 0; port < port_max; port++)
pd_set_suspend(port, 1);
@@ -296,6 +302,8 @@ static void baseboard_power_off(void)
/* Disable PPC interrupts for PS8803 managed port */
baseboard_usbc_usb3_enable_interrupts(0);
#endif
+ /* Set dock power button/MF preference LED */
+ baseboard_set_led(OFF);
/* Go into power off state */
board_power_sequence(0);
}
@@ -312,9 +320,14 @@ static void baseboard_toggle_mf(void)
dock_mf = CBI_FW_MF_PREFERENCE(fw_config);
/* Flash led for visual indication of user MF change */
baseboard_change_mf_led();
- /* Power the dock off, then on, to apply user preference */
- baseboard_power_off();
- baseboard_power_on();
+
+ /*
+ * Suspend, then release host port to force new MF setting to
+ * take effect.
+ */
+ pd_set_suspend(USB_PD_PORT_HOST, 1);
+ msleep(250);
+ pd_set_suspend(USB_PD_PORT_HOST, 0);
}
}