From 9b577161e4206068bf28096f3e7dbf9da81c2ac3 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 19 Jul 2024 14:11:35 -0600 Subject: [PATCH 1/3] Add usbc_mux_info command --- .../system76/common/include/board/usbpd.h | 10 ++ src/board/system76/common/smfi.c | 17 ++ src/board/system76/common/usbpd/tps65987.c | 149 +++++++++++++++++- src/common/include/common/command.h | 33 ++++ 4 files changed, 203 insertions(+), 6 deletions(-) diff --git a/src/board/system76/common/include/board/usbpd.h b/src/board/system76/common/include/board/usbpd.h index 2b38e84a8..a25bb89b1 100644 --- a/src/board/system76/common/include/board/usbpd.h +++ b/src/board/system76/common/include/board/usbpd.h @@ -3,12 +3,16 @@ #ifndef _BOARD_USBPD_H #define _BOARD_USBPD_H +#include +#include + #if CONFIG_HAVE_USBPD void usbpd_init(void); void usbpd_event(void); void usbpd_disable_charging(void); void usbpd_enable_charging(void); +bool usbc_mux_info(uint8_t port, uint16_t *info); #else @@ -17,6 +21,12 @@ static inline void usbpd_event(void) {} static inline void usbpd_disable_charging(void) {} static inline void usbpd_enable_charging(void) {} +static inline bool usbc_mux_info(uint8_t port, uint16_t *info) { + (void)port; + (void)info; + return false; +} + #endif #endif // _BOARD_USBPD_H diff --git a/src/board/system76/common/smfi.c b/src/board/system76/common/smfi.c index 225675aa8..04064f88d 100644 --- a/src/board/system76/common/smfi.c +++ b/src/board/system76/common/smfi.c @@ -20,6 +20,7 @@ #include #include #include +#include #if CONFIG_SECURITY #include @@ -264,6 +265,18 @@ static enum Result cmd_security_set(void) { } #endif // CONFIG_SECURITY +static enum Result cmd_usbc_mux_info(void) { + uint8_t port = smfi_cmd[SMFI_CMD_DATA]; + uint16_t info = 0; + if (usbc_mux_info(port, &info)) { + smfi_cmd[SMFI_CMD_DATA + 1] = (uint8_t)info; + smfi_cmd[SMFI_CMD_DATA + 2] = (uint8_t)(info >> 8); + return RES_OK; + } else { + return RES_ERR; + } +} + #endif // !defined(__SCRATCH__) #if defined(__SCRATCH__) @@ -421,6 +434,10 @@ void smfi_event(void) { break; #endif // CONFIG_SECURITY + case CMD_USBC_MUX_INFO: + smfi_cmd[SMFI_CMD_RES] = cmd_usbc_mux_info(); + break; + #endif // !defined(__SCRATCH__) case CMD_SPI: smfi_cmd[SMFI_CMD_RES] = cmd_spi(); diff --git a/src/board/system76/common/usbpd/tps65987.c b/src/board/system76/common/usbpd/tps65987.c index 487d1544e..16b856350 100644 --- a/src/board/system76/common/usbpd/tps65987.c +++ b/src/board/system76/common/usbpd/tps65987.c @@ -3,21 +3,43 @@ // USB-PD driver for TPS65987 and the mostly compatible TPS65993 and TPS65994. // I2C register reference: https://www.ti.com/lit/ug/slvubh2b/slvubh2b.pdf +#include #include #include #include -#include +#include #include #include #define USBPD_ADDRESS 0x20 +#define REG_CMD_1 0x08 +#define REG_TX_SINK_CAPABILITIES 0x33 #define REG_ACTIVE_CONTRACT_PDO 0x34 +#define REG_DATA_STATUS 0x5F + #define REG_DATA_STATUS_DATA_ORIENTATION BIT(1) + #define REG_DATA_STATUS_ACTIVE_CABLE BIT(2) + #define REG_DATA_STATUS_USB3_CONNECTION BIT(5) + #define REG_DATA_STATUS_USB_DATA_ROLE BIT(7) + #define REG_DATA_STATUS_DP_CONNECTION BIT(8) + #define REG_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK (0b11 << 10) + #define REG_DATA_STATUS_DP_PIN_ASSIGNMENT_AB (0b10 << 10) + #define REG_DATA_STATUS_DP_PIN_ASSIGNMENT_CD (0b01 << 10) + #define REG_DATA_STATUS_DP_PIN_ASSIGNMENT_EF (0b00 << 10) + #define REG_DATA_STATUS_DEBUG_ACCESSORY_MODE BIT(12) + #define REG_DATA_STATUS_HPD_IRQ BIT(14) + #define REG_DATA_STATUS_HPD_LEVEL BIT(15) + +#ifndef HAVE_USBPD_CHARGING +#define HAVE_USBPD_CHARGING 0 +#endif // HAVE_USBPD_CHARGING void usbpd_init(void) { i2c_reset(&I2C_USBPD, true); } +#if HAVE_USBPD_CHARGING + static int16_t usbpd_current_limit(void) { uint8_t value[7] = { 0 }; int16_t res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, REG_ACTIVE_CONTRACT_PDO, value, sizeof(value)); @@ -168,7 +190,7 @@ static int16_t usbpd_aneg(void) { int16_t res; uint8_t cmd[5] = { 4, 'A', 'N', 'e', 'g' }; - res = i2c_set(&I2C_USBPD, USBPD_ADDRESS, 0x08, cmd, sizeof(cmd)); + res = i2c_set(&I2C_USBPD, USBPD_ADDRESS, REG_CMD_1, cmd, sizeof(cmd)); if (res < 0) { return res; } @@ -185,7 +207,7 @@ void usbpd_disable_charging(void) { // Read current value uint8_t value[2] = { 0 }; - res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, 0x33, value, sizeof(value)); + res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, REG_TX_SINK_CAPABILITIES, value, sizeof(value)); if (res < 0) { DEBUG("ERR %04X\n", -res); return; @@ -200,7 +222,7 @@ void usbpd_disable_charging(void) { // Enable only the first TX sink PDO (5V) value[0] = 1; value[1] = 1; - res = i2c_set(&I2C_USBPD, USBPD_ADDRESS, 0x33, value, sizeof(value)); + res = i2c_set(&I2C_USBPD, USBPD_ADDRESS, REG_TX_SINK_CAPABILITIES, value, sizeof(value)); if (res < 0) { DEBUG("ERR %04X\n", -res); return; @@ -223,7 +245,7 @@ void usbpd_enable_charging(void) { // Read current value uint8_t value[2] = { 0 }; - res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, 0x33, value, sizeof(value)); + res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, REG_TX_SINK_CAPABILITIES, value, sizeof(value)); if (res < 0) { DEBUG("ERR %04X\n", -res); return; @@ -238,7 +260,7 @@ void usbpd_enable_charging(void) { // Enable the first two TX sink PDO (5V and 20V) value[0] = 1; value[1] = 2; - res = i2c_set(&I2C_USBPD, USBPD_ADDRESS, 0x33, value, sizeof(value)); + res = i2c_set(&I2C_USBPD, USBPD_ADDRESS, REG_TX_SINK_CAPABILITIES, value, sizeof(value)); if (res < 0) { DEBUG("ERR %04X\n", -res); return; @@ -253,3 +275,118 @@ void usbpd_enable_charging(void) { DEBUG("OK\n"); } + +#else // HAVE_USBPD_CHARGING + +void usbpd_event(void) { + bool update = false; + + static bool last_ac_in = false; + bool ac_in = !gpio_get(&ACIN_N); + if (ac_in != last_ac_in) { + last_ac_in = ac_in; + update = true; + + DEBUG("AC_IN %d\n", ac_in); + } + + if (update) { + int16_t res; + + DEBUG("USBPD DATA STATUS "); + + // Read current value + uint8_t value[6] = { 0 }; + res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, REG_DATA_STATUS, value, sizeof(value)); + if (res < 0) { + DEBUG("ERR %04X\n", -res); + } else { + DEBUG( + "OK %02x = %02X, %02X%02X%02X%02X\n", + value[0], + value[5], + value[4], + value[3], + value[2], + value[1] + ); + } + } +} + +void usbpd_disable_charging(void) {} + +#endif // HAVE_USBPD_CHARGING + +bool usbc_mux_info(uint8_t port, uint16_t *info) { + if (port != 0) { + // Only port 0 is supported right now + WARN("usbc_mux_info does not support port %d\n", port); + return false; + } + + uint8_t value[6] = { 0 }; + int16_t res = i2c_get(&I2C_USBPD, USBPD_ADDRESS, REG_DATA_STATUS, value, sizeof(value)); + if (res < 0) { + DEBUG("ERR %04X\n", -res); + return false; + } + + uint32_t data_status = ((uint32_t)value[1]) | (((uint32_t)value[2]) << 8) | + (((uint32_t)value[3]) << 16) | (((uint32_t)value[4]) << 24); + + DEBUG("OK %02X, %02x = %02X, %08X\n", res, value[0], value[5], data_status); + + *info = 0; + if (data_status & REG_DATA_STATUS_DP_CONNECTION) { + *info |= CMD_USBC_MUX_INFO_DP; + } + if (data_status & REG_DATA_STATUS_USB3_CONNECTION) { + *info |= CMD_USBC_MUX_INFO_USB; + } + if (data_status & REG_DATA_STATUS_ACTIVE_CABLE) { + *info |= CMD_USBC_MUX_INFO_CABLE; + } + if (data_status & REG_DATA_STATUS_DATA_ORIENTATION) { + *info |= CMD_USBC_MUX_INFO_POLARITY; + } + if (data_status & REG_DATA_STATUS_HPD_LEVEL) { + *info |= CMD_USBC_MUX_INFO_HPD_LVL; + } + if (data_status & REG_DATA_STATUS_HPD_IRQ) { + *info |= CMD_USBC_MUX_INFO_HPD_IRQ; + } + if (data_status & REG_DATA_STATUS_USB_DATA_ROLE) { + *info |= CMD_USBC_MUX_INFO_UFP; + } + if (data_status & REG_DATA_STATUS_DEBUG_ACCESSORY_MODE) { + *info |= CMD_USBC_MUX_INFO_DBG_ACC; + } + + switch (data_status & REG_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK) { + case REG_DATA_STATUS_DP_PIN_ASSIGNMENT_AB: + if (data_status & REG_DATA_STATUS_USB3_CONNECTION) { + *info |= CMD_USBC_MUX_INFO_DP_MODE_B; + } else { + *info |= CMD_USBC_MUX_INFO_DP_MODE_A; + } + break; + case REG_DATA_STATUS_DP_PIN_ASSIGNMENT_CD: + if (data_status & REG_DATA_STATUS_USB3_CONNECTION) { + *info |= CMD_USBC_MUX_INFO_DP_MODE_D; + } else { + *info |= CMD_USBC_MUX_INFO_DP_MODE_C; + } + break; + case REG_DATA_STATUS_DP_PIN_ASSIGNMENT_EF: + if (data_status & REG_DATA_STATUS_USB3_CONNECTION) { + *info |= CMD_USBC_MUX_INFO_DP_MODE_F; + } else { + *info |= CMD_USBC_MUX_INFO_DP_MODE_E; + } + break; + } + + DEBUG("USBC_MUX_INFO: %04X\n", *info); + return true; +} diff --git a/src/common/include/common/command.h b/src/common/include/common/command.h index 15c1ad31e..c740b7ca4 100644 --- a/src/common/include/common/command.h +++ b/src/common/include/common/command.h @@ -50,6 +50,8 @@ enum Command { CMD_SECURITY_GET = 20, // Set security state CMD_SECURITY_SET = 21, + // Get USB-C mux info (for coreboot) + CMD_USBC_MUX_INFO = 22, //TODO }; @@ -85,4 +87,35 @@ enum SecurityState { SECURITY_STATE_PREPARE_UNLOCK = 3, }; +enum UsbcMuxInfoFlags { + // DisplayPort connected if set + CMD_USBC_MUX_INFO_DP = BIT(0), + // USB connected if set + CMD_USBC_MUX_INFO_USB = BIT(1), + // Active cable if set, passive if not set + CMD_USBC_MUX_INFO_CABLE = BIT(2), + // Polarity of device, flipped if set, normal if not set + CMD_USBC_MUX_INFO_POLARITY = BIT(3), + // HPD level assert + CMD_USBC_MUX_INFO_HPD_LVL = BIT(4), + // HPD IRQ assert + CMD_USBC_MUX_INFO_HPD_IRQ = BIT(5), + // UFP if set, DFP if not set + CMD_USBC_MUX_INFO_UFP = BIT(6), + // Debug accessory if set + CMD_USBC_MUX_INFO_DBG_ACC = BIT(7), + // DP pin mode A + CMD_USBC_MUX_INFO_DP_MODE_A = BIT(8), + // DP pin mode B + CMD_USBC_MUX_INFO_DP_MODE_B = BIT(9), + // DP pin mode C + CMD_USBC_MUX_INFO_DP_MODE_C = BIT(10), + // DP pin mode D + CMD_USBC_MUX_INFO_DP_MODE_D = BIT(11), + // DP pin mode E + CMD_USBC_MUX_INFO_DP_MODE_E = BIT(12), + // DP pin mode F + CMD_USBC_MUX_INFO_DP_MODE_F = BIT(13), +}; + #endif // _COMMON_COMMAND_H From 52faa7d575f24de196351c535f3db0f6fd94bc9e Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 19 Jul 2024 14:11:35 -0600 Subject: [PATCH 2/3] tool: Implement usbc_mux_info command --- tool/src/ec.rs | 11 +++++++++++ tool/src/main.rs | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tool/src/ec.rs b/tool/src/ec.rs index 0bd793784..c8edb4a39 100644 --- a/tool/src/ec.rs +++ b/tool/src/ec.rs @@ -39,6 +39,7 @@ enum Cmd { SetNoInput = 19, SecurityGet = 20, SecuritySet = 21, + UsbcMuxInfo = 22, } const CMD_SPI_FLAG_READ: u8 = 1 << 0; @@ -327,6 +328,16 @@ impl Ec { self.command(Cmd::SecuritySet, &mut data) } + /// Get USB-C mux info + pub unsafe fn usbc_mux_info(&mut self, port: u8) -> Result { + let mut data = [port, 0, 0]; + self.command(Cmd::UsbcMuxInfo, &mut data)?; + Ok( + (data[1] as u16) | + ((data[2] as u16) << 8) + ) + } + pub fn into_dyn(self) -> Ec> where A: 'static { Ec { diff --git a/tool/src/main.rs b/tool/src/main.rs index a31da3fe9..d194abc12 100644 --- a/tool/src/main.rs +++ b/tool/src/main.rs @@ -301,6 +301,13 @@ unsafe fn security_set(ec: &mut Ec>, state: SecurityState) -> Re Ok(()) } +unsafe fn usbc_mux_info(ec: &mut Ec>, port: u8) -> Result<(), Error> { + let info = ec.usbc_mux_info(port)?; + println!("{:04X}", info); + + Ok(()) +} + fn parse_color(s: &str) -> Result<(u8, u8, u8), String> { let r = u8::from_str_radix(&s[0..2], 16); let g = u8::from_str_radix(&s[2..4], 16); @@ -361,6 +368,9 @@ enum SubCommand { Security { state: Option, }, + UsbcMuxInfo { + port: u8, + }, } #[derive(clap::ValueEnum, Clone)] @@ -638,5 +648,14 @@ fn main() { }, } }, + SubCommand::UsbcMuxInfo { port } => { + match unsafe { usbc_mux_info(&mut ec, port) } { + Ok(()) => (), + Err(err) => { + eprintln!("failed to get usbc_mux_info {}: {:X?}", port, err); + process::exit(1); + }, + } + }, } } From d8c5fee3b554498e3a1abb46ce77ae72349a5f5f Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Fri, 19 Jul 2024 14:11:35 -0600 Subject: [PATCH 3/3] Set USB-PD values for all boards - Use `I2C_1` interface for all boards - Enable USB charging on bonw15, oryp11 Signed-off-by: Tim Crawford --- src/board/system76/addw1/board.mk | 5 +++++ src/board/system76/addw2/board.mk | 5 +++++ src/board/system76/addw3/board.mk | 5 +++++ src/board/system76/addw4/board.mk | 5 +++++ src/board/system76/bonw14/board.mk | 5 +++++ src/board/system76/bonw15/board.mk | 3 ++- src/board/system76/darp10-b/board.mk | 7 ++++++- src/board/system76/darp10/board.mk | 6 ++++++ src/board/system76/darp5/board.mk | 5 +++++ src/board/system76/darp6/board.mk | 5 +++++ src/board/system76/darp7/board.mk | 6 ++++++ src/board/system76/darp8/board.mk | 6 ++++++ src/board/system76/darp9/board.mk | 6 ++++++ src/board/system76/galp3-c/board.mk | 5 +++++ src/board/system76/galp4/board.mk | 5 +++++ src/board/system76/galp5/board.mk | 6 ++++++ src/board/system76/galp6/board.mk | 6 ++++++ src/board/system76/galp7/board.mk | 6 ++++++ src/board/system76/gaze17-3060-b/board.mk | 6 ++++++ src/board/system76/gaze17-3060/board.mk | 6 ++++++ src/board/system76/lemp10/board.mk | 6 ++++++ src/board/system76/lemp11/board.mk | 6 ++++++ src/board/system76/lemp12/board.mk | 6 ++++++ src/board/system76/lemp13-b/board.mk | 5 +++++ src/board/system76/lemp13/board.mk | 5 +++++ src/board/system76/oryp10/board.mk | 5 +++++ src/board/system76/oryp11/board.mk | 3 ++- src/board/system76/oryp6/board.mk | 5 +++++ src/board/system76/oryp7/board.mk | 5 +++++ src/board/system76/oryp8/board.mk | 5 +++++ src/board/system76/oryp9/board.mk | 5 +++++ src/board/system76/serw13/board.mk | 1 - 32 files changed, 162 insertions(+), 4 deletions(-) diff --git a/src/board/system76/addw1/board.mk b/src/board/system76/addw1/board.mk index 9f0e94751..65e27d082 100644 --- a/src/board/system76/addw1/board.mk +++ b/src/board/system76/addw1/board.mk @@ -31,6 +31,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=12600 \ -DCHARGER_INPUT_CURRENT=11800 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/addw2/board.mk b/src/board/system76/addw2/board.mk index c2519c64e..6ff97a7b5 100644 --- a/src/board/system76/addw2/board.mk +++ b/src/board/system76/addw2/board.mk @@ -31,6 +31,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=12600 \ -DCHARGER_INPUT_CURRENT=11800 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/addw3/board.mk b/src/board/system76/addw3/board.mk index 1884df588..8e1b492cf 100644 --- a/src/board/system76/addw3/board.mk +++ b/src/board/system76/addw3/board.mk @@ -38,6 +38,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_INPUT_CURRENT=14000 +# Set USB-PD parameters +# XXX: Actually TPS65993 +USBPD = tps65987 +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=280 \ diff --git a/src/board/system76/addw4/board.mk b/src/board/system76/addw4/board.mk index 3f7573b3b..ed60b077a 100644 --- a/src/board/system76/addw4/board.mk +++ b/src/board/system76/addw4/board.mk @@ -34,6 +34,11 @@ CFLAGS += \ -DCHARGER_CHARGE_VOLTAGE=17400 \ -DCHARGER_INPUT_CURRENT=11500 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS += \ -DPOWER_LIMIT_AC=230 \ diff --git a/src/board/system76/bonw14/board.mk b/src/board/system76/bonw14/board.mk index d6b118cd3..2700cdd04 100644 --- a/src/board/system76/bonw14/board.mk +++ b/src/board/system76/bonw14/board.mk @@ -31,6 +31,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=16800 \ -DCHARGER_INPUT_CURRENT=14000 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/bonw15/board.mk b/src/board/system76/bonw15/board.mk index 260b3c6c9..2636be9c0 100644 --- a/src/board/system76/bonw15/board.mk +++ b/src/board/system76/bonw15/board.mk @@ -27,7 +27,6 @@ CFLAGS+=-DI2C_SMBUS=I2C_4 # Set touchpad PS2 bus CFLAGS+=-DPS2_TOUCHPAD=PS2_3 - # Set smart charger parameters # XXX: PRS1 and PRS2 are in parallel for adapter Rsense? CHARGER=oz26786 @@ -39,9 +38,11 @@ CFLAGS+=\ -DCHARGER_INPUT_CURRENT=16920 # Set USB-PD parameters +# XXX: Actually TPS65994 CONFIG_HAVE_USBPD = y CONFIG_USBPD_TPS65987 = y CFLAGS += -DI2C_USBPD=I2C_1 +CFLAGS += -DHAVE_USBPD_CHARGING=1 # Set CPU power limits in watts CFLAGS+=\ diff --git a/src/board/system76/darp10-b/board.mk b/src/board/system76/darp10-b/board.mk index 97eb0d106..944bc773d 100644 --- a/src/board/system76/darp10-b/board.mk +++ b/src/board/system76/darp10-b/board.mk @@ -21,7 +21,6 @@ CONFIG_HAVE_KBLED = y KBLED = white_dac CFLAGS += -DKBLED_DAC=2 - # Set battery I2C bus CFLAGS += -DI2C_SMBUS=I2C_4 @@ -37,6 +36,12 @@ CFLAGS += \ -DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_INPUT_CURRENT=4740 +# Set USB-PD parameters +# XXX: Actually TPS65994BH +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS += \ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/darp10/board.mk b/src/board/system76/darp10/board.mk index e98ea400a..b5042bac0 100644 --- a/src/board/system76/darp10/board.mk +++ b/src/board/system76/darp10/board.mk @@ -35,6 +35,12 @@ CFLAGS += \ -DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_INPUT_CURRENT=4740 +# Set USB-PD parameters +# XXX: Actually TPS65994BH +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS += \ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/darp5/board.mk b/src/board/system76/darp5/board.mk index 8c9c35181..ccdaab2d0 100644 --- a/src/board/system76/darp5/board.mk +++ b/src/board/system76/darp5/board.mk @@ -32,6 +32,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_INPUT_CURRENT=3420 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/darp6/board.mk b/src/board/system76/darp6/board.mk index 776f80980..4050f3698 100644 --- a/src/board/system76/darp6/board.mk +++ b/src/board/system76/darp6/board.mk @@ -35,6 +35,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_INPUT_CURRENT=3420 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/darp7/board.mk b/src/board/system76/darp7/board.mk index cc8aa50e3..f40a340bd 100644 --- a/src/board/system76/darp7/board.mk +++ b/src/board/system76/darp7/board.mk @@ -32,6 +32,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=8800 \ -DCHARGER_INPUT_CURRENT=3420 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/darp8/board.mk b/src/board/system76/darp8/board.mk index 4a7960512..875c6b87f 100644 --- a/src/board/system76/darp8/board.mk +++ b/src/board/system76/darp8/board.mk @@ -33,6 +33,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=8800 \ -DCHARGER_INPUT_CURRENT=4740 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/darp9/board.mk b/src/board/system76/darp9/board.mk index f40ab5a1d..2f8ad2b56 100644 --- a/src/board/system76/darp9/board.mk +++ b/src/board/system76/darp9/board.mk @@ -35,6 +35,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=8800 \ -DCHARGER_INPUT_CURRENT=4740 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/galp3-c/board.mk b/src/board/system76/galp3-c/board.mk index b75dd7ad8..199ae7b5f 100644 --- a/src/board/system76/galp3-c/board.mk +++ b/src/board/system76/galp3-c/board.mk @@ -33,6 +33,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=13056 \ -DCHARGER_INPUT_CURRENT=2100 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=40 \ diff --git a/src/board/system76/galp4/board.mk b/src/board/system76/galp4/board.mk index efdcd7c02..bea2ead56 100644 --- a/src/board/system76/galp4/board.mk +++ b/src/board/system76/galp4/board.mk @@ -36,6 +36,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=13056 \ -DCHARGER_INPUT_CURRENT=2100 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=40 \ diff --git a/src/board/system76/galp5/board.mk b/src/board/system76/galp5/board.mk index 8ac1eaf88..3100f5fd0 100644 --- a/src/board/system76/galp5/board.mk +++ b/src/board/system76/galp5/board.mk @@ -35,6 +35,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17400 \ -DCHARGER_INPUT_CURRENT=3420 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/galp6/board.mk b/src/board/system76/galp6/board.mk index 5d408012c..720e99922 100644 --- a/src/board/system76/galp6/board.mk +++ b/src/board/system76/galp6/board.mk @@ -38,6 +38,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17400 \ -DCHARGER_INPUT_CURRENT=4740 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/galp7/board.mk b/src/board/system76/galp7/board.mk index 4f73c3df0..09805a0e1 100644 --- a/src/board/system76/galp7/board.mk +++ b/src/board/system76/galp7/board.mk @@ -41,6 +41,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17400 \ -DCHARGER_INPUT_CURRENT=4740 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/gaze17-3060-b/board.mk b/src/board/system76/gaze17-3060-b/board.mk index 31bb08648..f21090968 100644 --- a/src/board/system76/gaze17-3060-b/board.mk +++ b/src/board/system76/gaze17-3060-b/board.mk @@ -38,6 +38,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_INPUT_CURRENT=7500 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/gaze17-3060/board.mk b/src/board/system76/gaze17-3060/board.mk index 2e4ce1277..5061e8605 100644 --- a/src/board/system76/gaze17-3060/board.mk +++ b/src/board/system76/gaze17-3060/board.mk @@ -35,6 +35,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_INPUT_CURRENT=7500 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/lemp10/board.mk b/src/board/system76/lemp10/board.mk index 55ab6b49d..d83f5620f 100644 --- a/src/board/system76/lemp10/board.mk +++ b/src/board/system76/lemp10/board.mk @@ -33,6 +33,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=8800 \ -DCHARGER_INPUT_CURRENT=3420 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/lemp11/board.mk b/src/board/system76/lemp11/board.mk index cfa7c2de5..aa10be34e 100644 --- a/src/board/system76/lemp11/board.mk +++ b/src/board/system76/lemp11/board.mk @@ -34,6 +34,12 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=8800 \ -DCHARGER_INPUT_CURRENT=3420 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/lemp12/board.mk b/src/board/system76/lemp12/board.mk index 78071325d..f4f1197df 100644 --- a/src/board/system76/lemp12/board.mk +++ b/src/board/system76/lemp12/board.mk @@ -39,6 +39,12 @@ CFLAGS+=\ -DCHARGER_INPUT_CURRENT=3420 \ -DCHARGER_PSYS_GAIN=500 +# Set USB-PD parameters +# XXX: Actually TPS65993 +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/lemp13-b/board.mk b/src/board/system76/lemp13-b/board.mk index b9fd40fd4..4d2b4c6b9 100644 --- a/src/board/system76/lemp13-b/board.mk +++ b/src/board/system76/lemp13-b/board.mk @@ -37,6 +37,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_INPUT_CURRENT=3420 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/lemp13/board.mk b/src/board/system76/lemp13/board.mk index 9333dc13c..890d6fc74 100644 --- a/src/board/system76/lemp13/board.mk +++ b/src/board/system76/lemp13/board.mk @@ -36,6 +36,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=17600 \ -DCHARGER_INPUT_CURRENT=3420 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=65 \ diff --git a/src/board/system76/oryp10/board.mk b/src/board/system76/oryp10/board.mk index 9abcddcc3..5c19f4601 100644 --- a/src/board/system76/oryp10/board.mk +++ b/src/board/system76/oryp10/board.mk @@ -40,6 +40,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=13050 \ -DCHARGER_INPUT_CURRENT=11500 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/oryp11/board.mk b/src/board/system76/oryp11/board.mk index 21086d05f..cd0762b65 100644 --- a/src/board/system76/oryp11/board.mk +++ b/src/board/system76/oryp11/board.mk @@ -28,7 +28,6 @@ CFLAGS+=-DI2C_SMBUS=I2C_4 # Set touchpad PS2 bus CFLAGS+=-DPS2_TOUCHPAD=PS2_3 - # Set smart charger parameters # TODO: actually bq24800 CHARGER=bq24780s @@ -40,9 +39,11 @@ CFLAGS+=\ -DCHARGER_INPUT_CURRENT=11500 # Set USB-PD parameters +# XXX: Actually TPS65993 CONFIG_HAVE_USBPD = y CONFIG_USBPD_TPS65987 = y CFLAGS += -DI2C_USBPD=I2C_1 +CFLAGS += -DHAVE_USBPD_CHARGING=1 # Set CPU power limits in watts CFLAGS+=\ diff --git a/src/board/system76/oryp6/board.mk b/src/board/system76/oryp6/board.mk index 09fd10de9..f4f3caa6f 100644 --- a/src/board/system76/oryp6/board.mk +++ b/src/board/system76/oryp6/board.mk @@ -31,6 +31,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=13050 \ -DCHARGER_INPUT_CURRENT=9230 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/oryp7/board.mk b/src/board/system76/oryp7/board.mk index 09fd10de9..f4f3caa6f 100644 --- a/src/board/system76/oryp7/board.mk +++ b/src/board/system76/oryp7/board.mk @@ -31,6 +31,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=13050 \ -DCHARGER_INPUT_CURRENT=9230 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/oryp8/board.mk b/src/board/system76/oryp8/board.mk index 0707f1150..c5e9ceb74 100644 --- a/src/board/system76/oryp8/board.mk +++ b/src/board/system76/oryp8/board.mk @@ -32,6 +32,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=13050 \ -DCHARGER_INPUT_CURRENT=9230 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/oryp9/board.mk b/src/board/system76/oryp9/board.mk index 674139ba8..109c38571 100644 --- a/src/board/system76/oryp9/board.mk +++ b/src/board/system76/oryp9/board.mk @@ -37,6 +37,11 @@ CFLAGS+=\ -DCHARGER_CHARGE_VOLTAGE=13050 \ -DCHARGER_INPUT_CURRENT=11500 +# Set USB-PD parameters +CONFIG_HAVE_USBPD = y +CONFIG_USBPD_TPS65987 = y +CFLAGS += -DI2C_USBPD=I2C_1 + # Set CPU power limits in watts CFLAGS+=\ -DPOWER_LIMIT_AC=180 \ diff --git a/src/board/system76/serw13/board.mk b/src/board/system76/serw13/board.mk index 81fd7c4c9..6d0d1398f 100644 --- a/src/board/system76/serw13/board.mk +++ b/src/board/system76/serw13/board.mk @@ -27,7 +27,6 @@ CFLAGS+=-DI2C_SMBUS=I2C_4 # Set touchpad PS2 bus CFLAGS+=-DPS2_TOUCHPAD=PS2_3 - # Set smart charger parameters # TODO: actually bq24800 CFLAGS+=\