From 289fc64b22e8f48ccb360c0a211af649f3de555e 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 f33166f30..86b1339f0 100644 --- a/src/board/system76/common/smfi.c +++ b/src/board/system76/common/smfi.c @@ -21,6 +21,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 7c53403d05d4f0743965b054f94c534b6f10e93f 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 3ba3aa96a49d9d6c96edf630e7bb6f51967d70bd 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 f337d40f5..6745131f2 100644 --- a/src/board/system76/addw1/board.mk +++ b/src/board/system76/addw1/board.mk @@ -28,6 +28,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 98b41ff3a..8924872e5 100644 --- a/src/board/system76/addw2/board.mk +++ b/src/board/system76/addw2/board.mk @@ -28,6 +28,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 264499ec7..f9f82aac0 100644 --- a/src/board/system76/addw3/board.mk +++ b/src/board/system76/addw3/board.mk @@ -37,6 +37,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 897624536..4414bbdaa 100644 --- a/src/board/system76/addw4/board.mk +++ b/src/board/system76/addw4/board.mk @@ -33,6 +33,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 dadf0066a..09ff1f91f 100644 --- a/src/board/system76/bonw14/board.mk +++ b/src/board/system76/bonw14/board.mk @@ -28,6 +28,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 6ef4b761a..a2b342c16 100644 --- a/src/board/system76/bonw15/board.mk +++ b/src/board/system76/bonw15/board.mk @@ -26,7 +26,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 @@ -38,9 +37,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 5ce738c9c..7331d39a8 100644 --- a/src/board/system76/darp10-b/board.mk +++ b/src/board/system76/darp10-b/board.mk @@ -20,7 +20,6 @@ CONFIG_HAVE_KBLED = y KBLED = white_dac CFLAGS += -DKBLED_DAC=2 - # Set battery I2C bus CFLAGS += -DI2C_SMBUS=I2C_4 @@ -36,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/darp10/board.mk b/src/board/system76/darp10/board.mk index 01dd7cd61..10c1c93ee 100644 --- a/src/board/system76/darp10/board.mk +++ b/src/board/system76/darp10/board.mk @@ -34,6 +34,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 a53a2adab..2663ade54 100644 --- a/src/board/system76/darp5/board.mk +++ b/src/board/system76/darp5/board.mk @@ -29,6 +29,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 f68b5f55d..187e41dc6 100644 --- a/src/board/system76/darp6/board.mk +++ b/src/board/system76/darp6/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/darp7/board.mk b/src/board/system76/darp7/board.mk index 41d3ca8de..0bb220624 100644 --- a/src/board/system76/darp7/board.mk +++ b/src/board/system76/darp7/board.mk @@ -31,6 +31,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 a23351ce8..7873d1065 100644 --- a/src/board/system76/darp8/board.mk +++ b/src/board/system76/darp8/board.mk @@ -32,6 +32,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 bf1da6e9d..d3e587f49 100644 --- a/src/board/system76/darp9/board.mk +++ b/src/board/system76/darp9/board.mk @@ -34,6 +34,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 2ab9d5769..72eeb291a 100644 --- a/src/board/system76/galp3-c/board.mk +++ b/src/board/system76/galp3-c/board.mk @@ -30,6 +30,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 67dda9b41..c51b62036 100644 --- a/src/board/system76/galp4/board.mk +++ b/src/board/system76/galp4/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/galp5/board.mk b/src/board/system76/galp5/board.mk index 9fc38b6a5..b85704180 100644 --- a/src/board/system76/galp5/board.mk +++ b/src/board/system76/galp5/board.mk @@ -34,6 +34,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 4fdf5de53..49b88f8e7 100644 --- a/src/board/system76/galp6/board.mk +++ b/src/board/system76/galp6/board.mk @@ -37,6 +37,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 074bbcf0b..4e6d388f4 100644 --- a/src/board/system76/galp7/board.mk +++ b/src/board/system76/galp7/board.mk @@ -40,6 +40,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 5bab43714..f9ced5a74 100644 --- a/src/board/system76/gaze17-3060-b/board.mk +++ b/src/board/system76/gaze17-3060-b/board.mk @@ -37,6 +37,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 05b4df52e..e066c273e 100644 --- a/src/board/system76/gaze17-3060/board.mk +++ b/src/board/system76/gaze17-3060/board.mk @@ -34,6 +34,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 1ad67c98f..db11954ec 100644 --- a/src/board/system76/lemp10/board.mk +++ b/src/board/system76/lemp10/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/lemp11/board.mk b/src/board/system76/lemp11/board.mk index 63525e4c8..774f52664 100644 --- a/src/board/system76/lemp11/board.mk +++ b/src/board/system76/lemp11/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/lemp12/board.mk b/src/board/system76/lemp12/board.mk index b60c25af3..b706713b6 100644 --- a/src/board/system76/lemp12/board.mk +++ b/src/board/system76/lemp12/board.mk @@ -38,6 +38,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 a4a46f461..eac1dbdc7 100644 --- a/src/board/system76/lemp13-b/board.mk +++ b/src/board/system76/lemp13-b/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/lemp13/board.mk b/src/board/system76/lemp13/board.mk index b571acb4e..dc046b616 100644 --- a/src/board/system76/lemp13/board.mk +++ b/src/board/system76/lemp13/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/oryp10/board.mk b/src/board/system76/oryp10/board.mk index 06e98e608..554876151 100644 --- a/src/board/system76/oryp10/board.mk +++ b/src/board/system76/oryp10/board.mk @@ -39,6 +39,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 065fda221..4265a6fd5 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 8461a415f..df417f83c 100644 --- a/src/board/system76/oryp6/board.mk +++ b/src/board/system76/oryp6/board.mk @@ -28,6 +28,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 8461a415f..df417f83c 100644 --- a/src/board/system76/oryp7/board.mk +++ b/src/board/system76/oryp7/board.mk @@ -28,6 +28,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 7df7931d0..e6fd99e75 100644 --- a/src/board/system76/oryp8/board.mk +++ b/src/board/system76/oryp8/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/oryp9/board.mk b/src/board/system76/oryp9/board.mk index 8287f6b15..473391c11 100644 --- a/src/board/system76/oryp9/board.mk +++ b/src/board/system76/oryp9/board.mk @@ -36,6 +36,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 149a97d25..eb8f025c0 100644 --- a/src/board/system76/serw13/board.mk +++ b/src/board/system76/serw13/board.mk @@ -26,7 +26,6 @@ CFLAGS+=-DI2C_SMBUS=I2C_4 # Set touchpad PS2 bus CFLAGS+=-DPS2_TOUCHPAD=PS2_3 - # Set smart charger parameters # TODO: actually bq24800 CFLAGS+=\