From 3fcb4a9e976a87d007e1bf2e68b51ce8c5bb5bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=BBygowski?= Date: Thu, 5 Dec 2024 14:40:29 +0100 Subject: [PATCH] src/board/system76: Add USB port power options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Żygowski --- src/board/novacustom/v540tnx/gpio.c | 4 +- .../novacustom/v540tnx/include/board/gpio.h | 3 + src/board/novacustom/v540tu/gpio.c | 2 - .../novacustom/v540tu/include/board/gpio.h | 3 + src/board/novacustom/v560tnx/gpio.c | 4 +- .../novacustom/v560tnx/include/board/gpio.h | 3 + src/board/novacustom/v560tu/gpio.c | 2 - .../novacustom/v560tu/include/board/gpio.h | 3 + src/board/system76/common/common.mk | 6 +- .../system76/common/include/board/options.h | 7 + src/board/system76/common/options.c | 3 +- src/board/system76/common/power.c | 122 ++++++++++++++++-- src/board/system76/darp7/gpio.c | 12 +- src/board/system76/darp7/include/board/gpio.h | 4 + src/board/system76/darp8/gpio.c | 9 +- src/board/system76/darp8/include/board/gpio.h | 5 + src/board/system76/galp5/gpio.c | 10 +- src/board/system76/galp5/include/board/gpio.h | 4 + src/board/system76/galp6/gpio.c | 6 +- src/board/system76/galp6/include/board/gpio.h | 3 + 20 files changed, 172 insertions(+), 43 deletions(-) diff --git a/src/board/novacustom/v540tnx/gpio.c b/src/board/novacustom/v540tnx/gpio.c index d597933b0..36116621a 100644 --- a/src/board/novacustom/v540tnx/gpio.c +++ b/src/board/novacustom/v540tnx/gpio.c @@ -71,8 +71,6 @@ void gpio_init(void) { GPDRC = 0; // PWR_BTN# GPDRD = BIT(5); - // USB_PWR_EN - GPDRE = BIT(3); // H_PECI GPDRF = BIT(6); // H_PROCHOT_EC @@ -159,7 +157,7 @@ void gpio_init(void) { // TBT_I2C_IRQ2Z GPCRE2 = GPIO_IN; // USB_PWR_EN - GPCRE3 = GPIO_OUT | GPIO_UP; + GPCRE3 = GPIO_OUT; // DD_ON GPCRE4 = GPIO_OUT; // EC_RSMRST# diff --git a/src/board/novacustom/v540tnx/include/board/gpio.h b/src/board/novacustom/v540tnx/include/board/gpio.h index 4f5410265..6f130043a 100644 --- a/src/board/novacustom/v540tnx/include/board/gpio.h +++ b/src/board/novacustom/v540tnx/include/board/gpio.h @@ -48,5 +48,8 @@ extern struct Gpio __code VA_EC_EN; #define HAVE_WLAN_EN 0 extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code XLP_OUT; +#define HAVE_USB_CHARGE_EN 1 +extern struct Gpio __code USB_CHARGE_EN; +extern struct Gpio __code USB_PWR_EN_N; #endif // _BOARD_GPIO_H diff --git a/src/board/novacustom/v540tu/gpio.c b/src/board/novacustom/v540tu/gpio.c index c5dd53b7d..6d1d54586 100644 --- a/src/board/novacustom/v540tu/gpio.c +++ b/src/board/novacustom/v540tu/gpio.c @@ -65,8 +65,6 @@ void gpio_init(void) { GPDRC = 0; // PWR_BTN# GPDRD = BIT(5); - // USB_PWR_EN - GPDRE = BIT(3); // H_PECI GPDRF = BIT(6); // H_PROCHOT_EC diff --git a/src/board/novacustom/v540tu/include/board/gpio.h b/src/board/novacustom/v540tu/include/board/gpio.h index 718801c0f..f3910b522 100644 --- a/src/board/novacustom/v540tu/include/board/gpio.h +++ b/src/board/novacustom/v540tu/include/board/gpio.h @@ -45,5 +45,8 @@ extern struct Gpio __code VA_EC_EN; #define HAVE_WLAN_EN 0 extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code XLP_OUT; +#define HAVE_USB_CHARGE_EN 1 +extern struct Gpio __code USB_CHARGE_EN; +extern struct Gpio __code USB_PWR_EN_N; #endif // _BOARD_GPIO_H diff --git a/src/board/novacustom/v560tnx/gpio.c b/src/board/novacustom/v560tnx/gpio.c index 8a23971fe..f287c6e9f 100644 --- a/src/board/novacustom/v560tnx/gpio.c +++ b/src/board/novacustom/v560tnx/gpio.c @@ -71,8 +71,6 @@ void gpio_init(void) { GPDRC = 0; // PWR_BTN# GPDRD = BIT(5); - // USB_PWR_EN - GPDRE = BIT(3); // H_PECI GPDRF = BIT(6); // H_PROCHOT_EC @@ -159,7 +157,7 @@ void gpio_init(void) { // TBT_I2C_IRQ2Z GPCRE2 = GPIO_IN; // USB_PWR_EN - GPCRE3 = GPIO_OUT | GPIO_UP; + GPCRE3 = GPIO_OUT; // DD_ON GPCRE4 = GPIO_OUT; // EC_RSMRST# diff --git a/src/board/novacustom/v560tnx/include/board/gpio.h b/src/board/novacustom/v560tnx/include/board/gpio.h index 4f5410265..6f130043a 100644 --- a/src/board/novacustom/v560tnx/include/board/gpio.h +++ b/src/board/novacustom/v560tnx/include/board/gpio.h @@ -48,5 +48,8 @@ extern struct Gpio __code VA_EC_EN; #define HAVE_WLAN_EN 0 extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code XLP_OUT; +#define HAVE_USB_CHARGE_EN 1 +extern struct Gpio __code USB_CHARGE_EN; +extern struct Gpio __code USB_PWR_EN_N; #endif // _BOARD_GPIO_H diff --git a/src/board/novacustom/v560tu/gpio.c b/src/board/novacustom/v560tu/gpio.c index c5dd53b7d..6d1d54586 100644 --- a/src/board/novacustom/v560tu/gpio.c +++ b/src/board/novacustom/v560tu/gpio.c @@ -65,8 +65,6 @@ void gpio_init(void) { GPDRC = 0; // PWR_BTN# GPDRD = BIT(5); - // USB_PWR_EN - GPDRE = BIT(3); // H_PECI GPDRF = BIT(6); // H_PROCHOT_EC diff --git a/src/board/novacustom/v560tu/include/board/gpio.h b/src/board/novacustom/v560tu/include/board/gpio.h index 718801c0f..f3910b522 100644 --- a/src/board/novacustom/v560tu/include/board/gpio.h +++ b/src/board/novacustom/v560tu/include/board/gpio.h @@ -45,5 +45,8 @@ extern struct Gpio __code VA_EC_EN; #define HAVE_WLAN_EN 0 extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code XLP_OUT; +#define HAVE_USB_CHARGE_EN 1 +extern struct Gpio __code USB_CHARGE_EN; +extern struct Gpio __code USB_PWR_EN_N; #endif // _BOARD_GPIO_H diff --git a/src/board/system76/common/common.mk b/src/board/system76/common/common.mk index dcb3ec4fe..e393b1fff 100644 --- a/src/board/system76/common/common.mk +++ b/src/board/system76/common/common.mk @@ -36,13 +36,13 @@ board-common-y += wireless.c # 3 - INFO # 4 - DEBUG # 5 - TRACE -CFLAGS+=-DLEVEL=2 +CFLAGS+=-DLEVEL=4 # Uncomment to enable debug logging over keyboard parallel port -#CFLAGS+=-DPARALLEL_DEBUG +CFLAGS+=-DPARALLEL_DEBUG # Uncomment to enable I2C debug on 0x76 -CFLAGS+=-DI2C_DEBUGGER=0x76 +#CFLAGS+=-DI2C_DEBUGGER=0x76 ifeq ($(CONFIG_SECURITY),y) CFLAGS+=-DCONFIG_SECURITY=1 diff --git a/src/board/system76/common/include/board/options.h b/src/board/system76/common/include/board/options.h index c8234110f..367c07214 100644 --- a/src/board/system76/common/include/board/options.h +++ b/src/board/system76/common/include/board/options.h @@ -24,7 +24,14 @@ enum { OPT_BAT_THRESHOLD_START, OPT_BAT_THRESHOLD_STOP, OPT_ALLOW_BAT_BOOST, + OPT_USB_POWER, NUM_OPTIONS }; +enum { + USB_POWER_ON_IN_S0, + USB_POWER_ALWAYS_ON, + USB_POWER_ON_AC +}; + #endif // _BOARD_OPTIONS_H diff --git a/src/board/system76/common/options.c b/src/board/system76/common/options.c index 1bac36b57..9acb6bd9b 100644 --- a/src/board/system76/common/options.c +++ b/src/board/system76/common/options.c @@ -15,10 +15,11 @@ uint8_t DEFAULT_OPTIONS[NUM_OPTIONS] = { [OPT_BAT_THRESHOLD_START] = 95, [OPT_BAT_THRESHOLD_STOP] = 98, [OPT_ALLOW_BAT_BOOST] = 0, + [OPT_USB_POWER] = 0, }; // clang-format on -#define SAVE_IMMEDIATELY BIT(OPT_POWER_ON_AC) +#define SAVE_IMMEDIATELY (BIT(OPT_POWER_ON_AC) || BIT(OPT_USB_POWER)) // Config is in the second to last sector of flash const uint32_t OPTIONS_ADDR = 0x1F800; diff --git a/src/board/system76/common/power.c b/src/board/system76/common/power.c index 524b15e4f..68acbb9ca 100644 --- a/src/board/system76/common/power.c +++ b/src/board/system76/common/power.c @@ -93,6 +93,19 @@ #define HAVE_PD_EN 0 #endif +// Disable by default +#ifndef HAVE_USB_CHARGE_EN +#define HAVE_USB_CHARGE_EN 0 +#endif + +#ifndef HAVE_USB_PWR_EN_N +#define HAVE_USB_PWR_EN_N 1 +#endif + +#ifndef HAVE_CC_EN +#define HAVE_CC_EN 0 +#endif + #ifndef HAVE_XLP_OUT #define HAVE_XLP_OUT 1 #endif @@ -201,6 +214,70 @@ void update_power_state(void) { } } +static void usb_power_control(bool enable) { +#if HAVE_USB_PWR_EN_N + GPIO_SET_DEBUG(USB_PWR_EN_N, enable); + delay_ms(20); +#endif +#if HAVE_PD_EN + GPIO_SET_DEBUG(PD_EN, enable); + delay_ms(20); +#endif +#if HAVE_CC_EN + // CC_EN controls USB Type-C port power + GPIO_SET_DEBUG(CC_EN, enable); + delay_ms(20); +#endif +} + +static void configure_usb_port_power(bool powering_on, bool ac_change) { + bool usb_port_power; + static bool usb_port_power_last = false; + uint8_t usb_power_opt = options_get(OPT_USB_POWER); + + if (usb_power_opt > USB_POWER_ON_AC) + usb_power_opt = USB_POWER_ON_IN_S0; + + usb_port_power = (usb_power_opt == USB_POWER_ALWAYS_ON); + + DEBUG("Configure USB port power, option %u, state %u\n", usb_power_opt, usb_port_power); + + update_power_state(); + + if (powering_on) { + usb_port_power = true; +#if HAVE_USB_CHARGE_EN + GPIO_SET_DEBUG(USB_CHARGE_EN, false); + delay_ms(20); +#endif + } else if (ac_change) { + // If we change AC state, only change USB port power in the powered + // off/S5 state + if (power_state == POWER_STATE_OFF || power_state == POWER_STATE_S5) { + if (usb_power_opt == USB_POWER_ON_AC) + usb_port_power = !gpio_get(&ACIN_N); + } else { + usb_port_power = usb_port_power_last; + } + } else { + if (usb_power_opt == USB_POWER_ON_AC) + usb_port_power = !gpio_get(&ACIN_N); + } + + if (usb_port_power_last != usb_port_power) { + usb_port_power_last = usb_port_power; + + DEBUG("USB ports power change to %sabled\n", usb_port_power ? "en" : "dis"); + + usb_power_control(usb_port_power); +#if HAVE_USB_CHARGE_EN + if (!powering_on) + // Enables VDD5 (like DD_ON), but does not enable 3.3V + GPIO_SET_DEBUG(USB_CHARGE_EN, usb_port_power); +#endif + } +} + void power_init(void) { // See Figure 12-19 in Whiskey Lake Platform Design Guide // | VCCRTC | RTCRST# | VccPRIM | @@ -211,6 +288,11 @@ void power_init(void) { tPCH04; update_power_state(); + + // Set USB power according to option. Must be called when AC is being + // plugged while powered off, otherwise one would have to press a power + // button to make effect. + // configure_usb_port_power(false, false); } void power_on(void) { @@ -229,14 +311,15 @@ void power_on(void) { // avoid leakage GPIO_SET_DEBUG(VA_EC_EN, true); #endif // HAVE_VA_EC_EN -#if HAVE_PD_EN - GPIO_SET_DEBUG(PD_EN, true); -#endif + tPCH06; // Enable VDD5 GPIO_SET_DEBUG(DD_ON, true); + // Configure USB port power before powering on + configure_usb_port_power(true, false); + #if HAVE_SUS_PWR_ACK // De-assert SUS_ACK# - TODO is this needed on non-dsx? GPIO_SET_DEBUG(SUS_PWR_ACK, true); @@ -318,13 +401,12 @@ void power_off(void) { // De-assert RSMRST# GPIO_SET_DEBUG(EC_RSMRST_N, false); + configure_usb_port_power(false, false); + // Disable VDD5 GPIO_SET_DEBUG(DD_ON, false); tPCH12; -#if HAVE_PD_EN - GPIO_SET_DEBUG(PD_EN, false); -#endif #if HAVE_VA_EC_EN // Disable VCCPRIM_* planes GPIO_SET_DEBUG(VA_EC_EN, false); @@ -429,6 +511,7 @@ void power_event(void) { GPIO_SET_DEBUG(H_PROCHOT_EC, false); ac_unplug_time = time_get(); battery_charger_disable(); + configure_usb_port_power(false, true); } else { DEBUG("plugged in\n"); battery_charger_configure(); @@ -438,6 +521,7 @@ void power_event(void) { power_on(); break; case POWER_STATE_S5: + configure_usb_port_power(true, true); GPIO_SET_DEBUG(PWR_BTN_N, false); delay_ms(32); // PWRBTN# must assert for at least 16 ms, we do twice that GPIO_SET_DEBUG(PWR_BTN_N, true); @@ -445,6 +529,8 @@ void power_event(void) { default: break; } + } else { + configure_usb_port_power(false, true); } } power_apply_limit(!ac_new); @@ -542,6 +628,9 @@ void power_event(void) { // Assert SYS_PWROK, system can finally perform PLT_RST# and boot GPIO_SET_DEBUG(PCH_PWROK_EC, true); #endif // HAVE_PCH_PWROK_EC + + configure_usb_port_power(true, false); + } else if (!pg_new && pg_last) { DEBUG("%02X: ALL_SYS_PWRGD de-asserted\n", main_cycle); @@ -554,6 +643,8 @@ void power_event(void) { // De-assert PCH_PWROK GPIO_SET_DEBUG(PM_PWROK, false); #endif // HAVE_PM_PWROK + + configure_usb_port_power(false, false); } pg_last = pg_new; @@ -682,15 +773,22 @@ void power_event(void) { } else { // CPU off and AC adapter unplugged, flashing orange light gpio_set(&LED_PWR, false); - if ((time - last_time) >= 1000) { - gpio_set(&LED_ACIN, !gpio_get(&LED_ACIN)); - last_time = time; - } + // Don't blink if we have USB power enabled, because we can't + // unset XLP_OUT to keep USB powered + if (options_get(OPT_USB_POWER) == USB_POWER_ON_IN_S0) { + if ((time - last_time) >= 1000) { + gpio_set(&LED_ACIN, !gpio_get(&LED_ACIN)); + last_time = time; + } #if HAVE_XLP_OUT - // Power off VDD3 if system should be off - gpio_set(&XLP_OUT, 0); + DEBUG("Powering off VDD3\n"); + // Power off VDD3 if system should be off + gpio_set(&XLP_OUT, 0); #endif // HAVE_XLP_OUT + } else { + gpio_set(&LED_ACIN, false); + } } //TODO: do not require both LEDs diff --git a/src/board/system76/darp7/gpio.c b/src/board/system76/darp7/gpio.c index 7067ff0f0..6587caba4 100644 --- a/src/board/system76/darp7/gpio.c +++ b/src/board/system76/darp7/gpio.c @@ -42,6 +42,8 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4); struct Gpio __code WLAN_EN = GPIO(G, 1); struct Gpio __code WLAN_PWR_EN = GPIO(A, 3); struct Gpio __code XLP_OUT = GPIO(B, 4); +struct Gpio __code USB_CHARGE_EN = GPIO(F, 1); +struct Gpio __code CC_EN = GPIO(F, 7); // clang-format on void gpio_init() { @@ -68,8 +70,6 @@ void gpio_init() { GPDRC = 0; // PWR_BTN#, SMI# GPDRD = BIT(5) | BIT(4); - // USB_PWR_EN# - GPDRE = BIT(3); // H_PECI GPDRF = BIT(6); // H_PROCHOT_EC# @@ -152,7 +152,7 @@ void gpio_init() { // RGBKB-DET# GPCRE2 = GPIO_IN | GPIO_UP; // USB_PWR_EN# - GPCRE3 = GPIO_OUT | GPIO_UP; + GPCRE3 = GPIO_OUT; // DD_ON GPCRE4 = GPIO_OUT | GPIO_DOWN; // EC_RSMRST# @@ -164,7 +164,7 @@ void gpio_init() { // 80CLK GPCRF0 = GPIO_IN; // USB_CHARGE_EN - GPCRF1 = GPIO_OUT | GPIO_UP; + GPCRF1 = GPIO_OUT; // 3IN1 GPCRF2 = GPIO_IN | GPIO_UP; // NC @@ -175,8 +175,8 @@ void gpio_init() { GPCRF5 = GPIO_ALT; // H_PECI GPCRF6 = GPIO_ALT; - //TODO: CC_EN - GPCRF7 = GPIO_IN | GPIO_UP; + // CC_EN + GPCRF7 = GPIO_OUT; // VCCIN_AUX_PG GPCRG0 = GPIO_IN; // WLAN_EN diff --git a/src/board/system76/darp7/include/board/gpio.h b/src/board/system76/darp7/include/board/gpio.h index 6d9f75860..e65141d3b 100644 --- a/src/board/system76/darp7/include/board/gpio.h +++ b/src/board/system76/darp7/include/board/gpio.h @@ -53,6 +53,10 @@ extern struct Gpio __code VR_ON; extern struct Gpio __code WLAN_EN; extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code XLP_OUT; +#define HAVE_USB_CHARGE_EN 1 +extern struct Gpio __code USB_CHARGE_EN; +#define HAVE_CC_EN 1 +extern struct Gpio __code CC_EN; // clang-format on #endif // _BOARD_GPIO_H diff --git a/src/board/system76/darp8/gpio.c b/src/board/system76/darp8/gpio.c index cf2826a6b..5454a0384 100644 --- a/src/board/system76/darp8/gpio.c +++ b/src/board/system76/darp8/gpio.c @@ -36,10 +36,13 @@ struct Gpio __code SMI_N = GPIO(D, 4); struct Gpio __code SUSB_N_PCH = GPIO(H, 6); struct Gpio __code SUSC_N_PCH = GPIO(H, 1); struct Gpio __code SWI_N = GPIO(B, 5); +struct Gpio __code USB_PWR_EN_N = GPIO(E, 3); struct Gpio __code VA_EC_EN = GPIO(J, 4); struct Gpio __code WLAN_EN = GPIO(F, 3); struct Gpio __code WLAN_PWR_EN = GPIO(G, 1); struct Gpio __code XLP_OUT = GPIO(B, 4); +struct Gpio __code USB_CHARGE_EN = GPIO(F, 1); +struct Gpio __code CC_EN = GPIO(F, 7); // clang-format on void gpio_init(void) { @@ -71,8 +74,6 @@ void gpio_init(void) { GPDRC = 0; // PWR_BTN#, SMI# GPDRD = BIT(5) | BIT(4); - // USB_PWR_EN - GPDRE = BIT(3); // H_PECI GPDRF = BIT(6); // H_PROCHOT_EC# @@ -167,7 +168,7 @@ void gpio_init(void) { // 80CLK GPCRF0 = GPIO_IN; // USB_CHARGE_EN - GPCRF1 = GPIO_OUT | GPIO_UP; + GPCRF1 = GPIO_OUT; // 3IN1 GPCRF2 = GPIO_IN | GPIO_UP; // WLAN_EN @@ -179,7 +180,7 @@ void gpio_init(void) { // H_PECI GPCRF6 = GPIO_ALT; // CC_EN - GPCRF7 = GPIO_IN | GPIO_UP; + GPCRF7 = GPIO_OUT; // VCCIN_AUX_PG GPCRG0 = GPIO_IN; // WLAN_PWR_EN diff --git a/src/board/system76/darp8/include/board/gpio.h b/src/board/system76/darp8/include/board/gpio.h index ebd79a758..08325ea63 100644 --- a/src/board/system76/darp8/include/board/gpio.h +++ b/src/board/system76/darp8/include/board/gpio.h @@ -45,10 +45,15 @@ extern struct Gpio __code SMI_N; extern struct Gpio __code SUSB_N_PCH; extern struct Gpio __code SUSC_N_PCH; extern struct Gpio __code SWI_N; +extern struct Gpio __code USB_PWR_EN_N; extern struct Gpio __code VA_EC_EN; extern struct Gpio __code WLAN_EN; extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code XLP_OUT; +#define HAVE_USB_CHARGE_EN 1 +extern struct Gpio __code USB_CHARGE_EN; +#define HAVE_CC_EN 1 +extern struct Gpio __code CC_EN; // clang-format on #endif // _BOARD_GPIO_H diff --git a/src/board/system76/galp5/gpio.c b/src/board/system76/galp5/gpio.c index 400a83e25..24cac44f5 100644 --- a/src/board/system76/galp5/gpio.c +++ b/src/board/system76/galp5/gpio.c @@ -43,6 +43,8 @@ struct Gpio __code VA_EC_EN = GPIO(J, 4); struct Gpio __code WLAN_EN = GPIO(G, 1); struct Gpio __code WLAN_PWR_EN = GPIO(A, 3); struct Gpio __code XLP_OUT = GPIO(B, 4); +struct Gpio __code USB_CHARGE_EN = GPIO(F, 1); +struct Gpio __code CC_EN = GPIO(F, 7); // clang-format on void gpio_init() { @@ -153,7 +155,7 @@ void gpio_init() { // KB-DET GPCRE2 = GPIO_IN | GPIO_UP; // USB_PWR_EN# - GPCRE3 = GPIO_OUT | GPIO_UP; + GPCRE3 = GPIO_OUT; // DD_ON GPCRE4 = GPIO_OUT | GPIO_DOWN; // EC_RSMRST# @@ -165,7 +167,7 @@ void gpio_init() { // 80CLK GPCRF0 = GPIO_IN | GPIO_UP; // USB_CHARGE_EN - GPCRF1 = GPIO_OUT | GPIO_UP; + GPCRF1 = GPIO_OUT; // 3IN1 GPCRF2 = GPIO_IN | GPIO_UP; // BT_EN: Not connected @@ -176,8 +178,8 @@ void gpio_init() { GPCRF5 = GPIO_ALT | GPIO_UP; // H_PECI GPCRF6 = GPIO_ALT; - // CC_EN: TODO! - GPCRF7 = GPIO_IN | GPIO_UP; + // CC_EN + GPCRF7 = GPIO_OUT; // dGPU_GPIO8_OVERT GPCRG0 = GPIO_IN; // WLAN_EN diff --git a/src/board/system76/galp5/include/board/gpio.h b/src/board/system76/galp5/include/board/gpio.h index c5ef9c487..ed4910453 100644 --- a/src/board/system76/galp5/include/board/gpio.h +++ b/src/board/system76/galp5/include/board/gpio.h @@ -53,6 +53,10 @@ extern struct Gpio __code VA_EC_EN; extern struct Gpio __code WLAN_EN; extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code XLP_OUT; +#define HAVE_USB_CHARGE_EN 1 +extern struct Gpio __code USB_CHARGE_EN; +#define HAVE_CC_EN 1 +extern struct Gpio __code CC_EN; // clang-format on #endif // _BOARD_GPIO_H diff --git a/src/board/system76/galp6/gpio.c b/src/board/system76/galp6/gpio.c index 0d83acbaa..3fa8695c2 100644 --- a/src/board/system76/galp6/gpio.c +++ b/src/board/system76/galp6/gpio.c @@ -38,10 +38,12 @@ struct Gpio __code SMI_N = GPIO(D, 4); struct Gpio __code SUSB_N_PCH = GPIO(H, 6); struct Gpio __code SUSC_N_PCH = GPIO(H, 1); struct Gpio __code SWI_N = GPIO(B, 5); +struct Gpio __code USB_PWR_EN_N = GPIO(E, 3); struct Gpio __code VA_EC_EN = GPIO(J, 4); struct Gpio __code WLAN_EN = GPIO(G, 1); struct Gpio __code WLAN_PWR_EN = GPIO(A, 3); struct Gpio __code XLP_OUT = GPIO(B, 4); +struct Gpio __code USB_CHARGE_EN = GPIO(F, 1); // clang-format on void gpio_init(void) { @@ -74,8 +76,6 @@ void gpio_init(void) { GPDRC = BIT(5); // PWR_BTN#, SMI# GPDRD = BIT(5) | BIT(4); - // USB_PWR_EN - GPDRE = BIT(3); // H_PECI GPDRF = BIT(6); // H_PROCHOT_EC @@ -170,7 +170,7 @@ void gpio_init(void) { // 80CLK GPCRF0 = GPIO_IN; // USB_CHARGE_EN - GPCRF1 = GPIO_OUT | GPIO_UP; + GPCRF1 = GPIO_OUT; // 3IN1 GPCRF2 = GPIO_IN | GPIO_UP; // PD_EN diff --git a/src/board/system76/galp6/include/board/gpio.h b/src/board/system76/galp6/include/board/gpio.h index 537f8f124..e03a02ab5 100644 --- a/src/board/system76/galp6/include/board/gpio.h +++ b/src/board/system76/galp6/include/board/gpio.h @@ -48,10 +48,13 @@ extern struct Gpio __code SUSC_N_PCH; #define HAVE_SUSWARN_N 0 #define HAVE_SUS_PWR_ACK 0 extern struct Gpio __code SWI_N; +extern struct Gpio __code USB_PWR_EN_N; extern struct Gpio __code VA_EC_EN; extern struct Gpio __code WLAN_EN; extern struct Gpio __code WLAN_PWR_EN; extern struct Gpio __code XLP_OUT; +#define HAVE_USB_CHARGE_EN 1 +extern struct Gpio __code USB_CHARGE_EN; // clang-format on #endif // _BOARD_GPIO_H