summaryrefslogtreecommitdiff
path: root/baseboard/brya
diff options
context:
space:
mode:
Diffstat (limited to 'baseboard/brya')
-rw-r--r--baseboard/brya/baseboard.c4
-rw-r--r--baseboard/brya/baseboard.h43
-rw-r--r--baseboard/brya/baseboard_usbc_config.h2
-rw-r--r--baseboard/brya/battery_presence.c7
-rw-r--r--baseboard/brya/build.mk2
-rw-r--r--baseboard/brya/cbi.c6
-rw-r--r--baseboard/brya/cbi.h2
-rw-r--r--baseboard/brya/charger_bq25720.c12
-rw-r--r--baseboard/brya/prochot.c78
-rw-r--r--baseboard/brya/usb_pd_policy.c140
10 files changed, 155 insertions, 141 deletions
diff --git a/baseboard/brya/baseboard.c b/baseboard/brya/baseboard.c
index 7b9e3c2e00..e65a384578 100644
--- a/baseboard/brya/baseboard.c
+++ b/baseboard/brya/baseboard.c
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -41,5 +41,5 @@ __override void lid_angle_peripheral_enable(int enable)
*/
if (!chipset_in_state(CHIPSET_STATE_ON))
keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_ANGLE);
- }
+ }
}
diff --git a/baseboard/brya/baseboard.h b/baseboard/brya/baseboard.h
index bc44a9d642..84fefa9b53 100644
--- a/baseboard/brya/baseboard.h
+++ b/baseboard/brya/baseboard.h
@@ -1,4 +1,4 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+/* Copyright 2020 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,18 +12,18 @@
* By default, enable all console messages excepted HC, ACPI and event:
* The sensor stack is generating a lot of activity.
*/
-#define CC_DEFAULT (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC)))
+#define CC_DEFAULT (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC)))
#undef CONFIG_HOSTCMD_DEBUG_MODE
#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF
/* NPCX9 config */
-#define NPCX9_PWM1_SEL 1 /* GPIO C2 is used as PWM1. */
+#define NPCX9_PWM1_SEL 1 /* GPIO C2 is used as PWM1. */
/*
* This defines which pads (GPIO10/11 or GPIO64/65) are connected to
* the "UART1" (NPCX_UART_PORT0) controller when used for
* CONSOLE_UART.
*/
-#define NPCX_UART_MODULE2 1 /* 1:GPIO64/65 for UART1 */
+#define NPCX_UART_MODULE2 1 /* 1:GPIO64/65 for UART1 */
/* EC Defines */
#define CONFIG_LTO
@@ -46,8 +46,8 @@
/* Host communication */
#define CONFIG_HOST_INTERFACE_ESPI
-#define CONFIG_HOSTCMD_ESPI_VW_SLP_S4
-#define CONFIG_HOSTCMD_ESPI_VW_SLP_S5
+#define CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S4
+#define CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S5
/*
* TODO(b/179648721): implement sensors
@@ -68,7 +68,7 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CMD_CHARGER_DUMP
@@ -79,8 +79,8 @@
* Don't allow the system to boot to S0 when the battery is low and unable to
* communicate on locked systems (which haven't PD negotiated)
*/
-#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
-#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15001
+#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
+#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15001
/* Common battery defines */
#define CONFIG_BATTERY_SMART
@@ -113,7 +113,7 @@
#define CONFIG_POWER_TRACK_HOST_SLEEP_STATE
#define CONFIG_LOW_POWER_IDLE
-#define CONFIG_HOSTCMD_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
+#define CONFIG_HOST_INTERFACE_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
#define CONFIG_BOARD_HAS_RTC_RESET
#undef CONFIG_S5_EXIT_WAIT
@@ -124,8 +124,8 @@
/* ADL has new lower-power features that require extra-wide virtual wire
* pulses. The EDS specifies 100 microseconds. */
-#undef CONFIG_ESPI_DEFAULT_VW_WIDTH_US
-#define CONFIG_ESPI_DEFAULT_VW_WIDTH_US 100
+#undef CONFIG_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US
+#define CONFIG_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US 100
/* Buttons / Switches */
#define CONFIG_VOLUME_BUTTONS
@@ -181,7 +181,7 @@
#define CONFIG_USB_PD_TCPM_NCT38XX
#define CONFIG_USB_PD_TCPM_MUX
-#define CONFIG_HOSTCMD_PD_CONTROL /* Needed for TCPC FW update */
+#define CONFIG_HOSTCMD_PD_CONTROL /* Needed for TCPC FW update */
#define CONFIG_CMD_USB_PD_PE
/*
@@ -189,7 +189,7 @@
* with non-PD chargers. Override the default low-power mode exit delay.
*/
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
-#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (50*MSEC)
+#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (50 * MSEC)
/* Enable USB3.2 DRD */
#define CONFIG_USB_PD_USB32_DRD
@@ -230,13 +230,13 @@
* bytes. Task stack sizes not listed here use more generic values (see
* ec.tasklist).
*/
-#define BASEBOARD_CHARGER_TASK_STACK_SIZE 1088
-#define BASEBOARD_CHG_RAMP_TASK_STACK_SIZE 1088
-#define BASEBOARD_CHIPSET_TASK_STACK_SIZE 1152
-#define BASEBOARD_PD_INT_TASK_STACK_SIZE 800
-#define BASEBOARD_PD_TASK_STACK_SIZE 1216
-#define BASEBOARD_POWERBTN_TASK_STACK_SIZE 1088
-#define BASEBOARD_RGBKBD_TASK_STACK_SIZE 2048
+#define BASEBOARD_CHARGER_TASK_STACK_SIZE 1088
+#define BASEBOARD_CHG_RAMP_TASK_STACK_SIZE 1088
+#define BASEBOARD_CHIPSET_TASK_STACK_SIZE 1152
+#define BASEBOARD_PD_INT_TASK_STACK_SIZE 800
+#define BASEBOARD_PD_TASK_STACK_SIZE 1216
+#define BASEBOARD_POWERBTN_TASK_STACK_SIZE 1088
+#define BASEBOARD_RGBKBD_TASK_STACK_SIZE 2048
#ifndef __ASSEMBLER__
@@ -248,7 +248,6 @@
#include "baseboard_usbc_config.h"
#include "extpower.h"
-
/*
* Check battery disconnect state.
* This function will return if battery is initialized or not.
diff --git a/baseboard/brya/baseboard_usbc_config.h b/baseboard/brya/baseboard_usbc_config.h
index f8b9fab35c..6d0cf828a3 100644
--- a/baseboard/brya/baseboard_usbc_config.h
+++ b/baseboard/brya/baseboard_usbc_config.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/baseboard/brya/battery_presence.c b/baseboard/brya/battery_presence.c
index 94c9926820..1e4ab4ed44 100644
--- a/baseboard/brya/battery_presence.c
+++ b/baseboard/brya/battery_presence.c
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -18,8 +18,9 @@ __overridable bool board_battery_is_initialized(void)
{
int batt_status;
- return battery_status(&batt_status) != EC_SUCCESS ? false :
- !!(batt_status & STATUS_INITIALIZED);
+ return battery_status(&batt_status) != EC_SUCCESS ?
+ false :
+ !!(batt_status & STATUS_INITIALIZED);
}
/*
diff --git a/baseboard/brya/build.mk b/baseboard/brya/build.mk
index 2ed0186242..c6e93c63f2 100644
--- a/baseboard/brya/build.mk
+++ b/baseboard/brya/build.mk
@@ -1,5 +1,5 @@
# -*- makefile -*-
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
+# Copyright 2020 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
diff --git a/baseboard/brya/cbi.c b/baseboard/brya/cbi.c
index ded310bffc..7bc8dad117 100644
--- a/baseboard/brya/cbi.c
+++ b/baseboard/brya/cbi.c
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -10,8 +10,8 @@
#include "cros_board_info.h"
#include "hooks.h"
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
static uint8_t board_id;
diff --git a/baseboard/brya/cbi.h b/baseboard/brya/cbi.h
index 2ad70aff96..37e02806bd 100644
--- a/baseboard/brya/cbi.h
+++ b/baseboard/brya/cbi.h
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/baseboard/brya/charger_bq25720.c b/baseboard/brya/charger_bq25720.c
index 184cc68eaa..a4fa209246 100644
--- a/baseboard/brya/charger_bq25720.c
+++ b/baseboard/brya/charger_bq25720.c
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -15,9 +15,8 @@
#include "usb_pd.h"
#include "util.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
#ifndef CONFIG_ZEPHYR
/* Charger Chip Configuration */
@@ -86,7 +85,6 @@ int board_set_active_charge_port(int port)
__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
int max_ma, int charge_mv)
{
- charge_set_input_current_limit(MAX(charge_ma,
- CONFIG_CHARGER_INPUT_CURRENT),
- charge_mv);
+ charge_set_input_current_limit(
+ MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
diff --git a/baseboard/brya/prochot.c b/baseboard/brya/prochot.c
index 666f2ca35b..f89ec5a263 100644
--- a/baseboard/brya/prochot.c
+++ b/baseboard/brya/prochot.c
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -16,10 +16,10 @@
#include "task.h"
/* Console output macros */
-#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args)
-#define ADT_RATING_W (PD_MAX_POWER_MW / 1000)
-#define PROCHOT_EVENT_200MS_TICK TASK_EVENT_CUSTOM_BIT(0)
+#define ADT_RATING_W (PD_MAX_POWER_MW / 1000)
+#define PROCHOT_EVENT_200MS_TICK TASK_EVENT_CUSTOM_BIT(0)
struct batt_para {
int battery_continuous_discharge_mw;
@@ -80,8 +80,9 @@ static int get_batt_parameter(void)
rv |= sb_read(SB_DESIGN_VOLTAGE, &battery_design_voltage_mv);
rv |= sb_read(SB_DESIGN_CAPACITY, &battery_design_capacity_mAh);
- batt_params.battery_design_mWh = (battery_design_voltage_mv *
- battery_design_capacity_mAh) / 1000;
+ batt_params.battery_design_mWh =
+ (battery_design_voltage_mv * battery_design_capacity_mAh) /
+ 1000;
if (sb_read(SB_RELATIVE_STATE_OF_CHARGE, &batt_params.state_of_charge))
batt_params.flags |= BATT_FLAG_BAD_STATE_OF_CHARGE;
@@ -109,7 +110,7 @@ static int set_register_charge_option(void)
int rv;
rv = i2c_read16(I2C_PORT_CHARGER, BQ25710_SMBUS_ADDR1_FLAGS,
- BQ25710_REG_CHARGE_OPTION_0, &reg);
+ BQ25710_REG_CHARGE_OPTION_0, &reg);
if (rv == EC_SUCCESS) {
reg = SET_BQ_FIELD(BQ257X0, CHARGE_OPTION_0, IADP_GAIN, 1, reg);
/* if AC only, disable IDPM,
@@ -127,7 +128,7 @@ static int set_register_charge_option(void)
}
return i2c_write16(I2C_PORT_CHARGER, BQ25710_SMBUS_ADDR1_FLAGS,
- BQ25710_REG_CHARGE_OPTION_0, reg);
+ BQ25710_REG_CHARGE_OPTION_0, reg);
}
static void assert_prochot(void)
@@ -154,7 +155,7 @@ static void assert_prochot(void)
/* When battery is discharging, the battery current will be negative */
if (batt_params.battery_continuous_discharge_mw < 0) {
total_W = adpt_mw +
- ABS(batt_params.battery_continuous_discharge_mw);
+ ABS(batt_params.battery_continuous_discharge_mw);
} else {
/* we won't assert prochot when battery is charging. */
total_W = adpt_mw;
@@ -177,15 +178,18 @@ static void assert_prochot(void)
if (!battery_hw_present()) {
gpio_set_level(GPIO_EC_PROCHOT_ODL, 1);
} else {
- batt_params.battery_continuous_discharge_mw =
- ABS(batt_params.battery_continuous_discharge_mw);
+ batt_params.battery_continuous_discharge_mw = ABS(
+ batt_params.battery_continuous_discharge_mw);
if ((batt_params.battery_continuous_discharge_mw /
- 1000) > BATT_MAX_CONTINUE_DISCHARGE_WATT *
- PROCHOT_ASSERTION_BATTERY_RATIO / 100)
+ 1000) > BATT_MAX_CONTINUE_DISCHARGE_WATT *
+ PROCHOT_ASSERTION_BATTERY_RATIO /
+ 100)
gpio_set_level(GPIO_EC_PROCHOT_ODL, 0);
- else if ((batt_params.battery_continuous_discharge_mw
- / 1000) < BATT_MAX_CONTINUE_DISCHARGE_WATT *
- PROCHOT_DEASSERTION_BATTERY_RATIO / 100)
+ else if ((batt_params.battery_continuous_discharge_mw /
+ 1000) <
+ BATT_MAX_CONTINUE_DISCHARGE_WATT *
+ PROCHOT_DEASSERTION_BATTERY_RATIO /
+ 100)
gpio_set_level(GPIO_EC_PROCHOT_ODL, 1);
}
return;
@@ -195,42 +199,48 @@ static void assert_prochot(void)
/* if adapter >= 60W */
/* if no battery or battery < 10% */
if (!battery_hw_present() ||
- batt_params.state_of_charge <= 10) {
- if (total_W > ADT_RATING_W *
- PROCHOT_ASSERTION_PD_RATIO / 100)
+ batt_params.state_of_charge <= 10) {
+ if (total_W >
+ ADT_RATING_W * PROCHOT_ASSERTION_PD_RATIO / 100)
gpio_set_level(GPIO_EC_PROCHOT_ODL, 0);
- else if (total_W <= ADT_RATING_W *
- PROCHOT_DEASSERTION_PD_RATIO / 100)
+ else if (total_W <=
+ ADT_RATING_W * PROCHOT_DEASSERTION_PD_RATIO /
+ 100)
gpio_set_level(GPIO_EC_PROCHOT_ODL, 1);
} else {
/* AC + battery */
- if (total_W > (ADT_RATING_W +
- BATT_MAX_CONTINUE_DISCHARGE_WATT))
+ if (total_W >
+ (ADT_RATING_W + BATT_MAX_CONTINUE_DISCHARGE_WATT))
gpio_set_level(GPIO_EC_PROCHOT_ODL, 0);
- else if (total_W < (ADT_RATING_W +
- BATT_MAX_CONTINUE_DISCHARGE_WATT) *
- PROCHOT_DEASSERTION_PD_BATTERY_RATIO / 100)
+ else if (total_W <
+ (ADT_RATING_W +
+ BATT_MAX_CONTINUE_DISCHARGE_WATT) *
+ PROCHOT_DEASSERTION_PD_BATTERY_RATIO /
+ 100)
gpio_set_level(GPIO_EC_PROCHOT_ODL, 1);
}
} else {
/* if adapter < 60W */
/* if no battery or battery < 10% */
if (!battery_hw_present() ||
- batt_params.state_of_charge <= 10) {
+ batt_params.state_of_charge <= 10) {
if (total_W > (adapter_wattage *
- PROCHOT_ASSERTION_ADAPTER_RATIO / 100))
+ PROCHOT_ASSERTION_ADAPTER_RATIO / 100))
gpio_set_level(GPIO_EC_PROCHOT_ODL, 0);
- else if (total_W <= (adapter_wattage *
- PROCHOT_DEASSERTION_ADAPTER_RATIO / 100))
+ else if (total_W <=
+ (adapter_wattage *
+ PROCHOT_DEASSERTION_ADAPTER_RATIO / 100))
gpio_set_level(GPIO_EC_PROCHOT_ODL, 1);
} else {
/* AC + battery */
if (total_W > (adapter_wattage +
- BATT_MAX_CONTINUE_DISCHARGE_WATT))
+ BATT_MAX_CONTINUE_DISCHARGE_WATT))
gpio_set_level(GPIO_EC_PROCHOT_ODL, 0);
- else if (total_W < (adapter_wattage +
- (BATT_MAX_CONTINUE_DISCHARGE_WATT *
- PROCHOT_DEASSERTION_ADAPTER_BATT_RATIO / 100)))
+ else if (total_W <
+ (adapter_wattage +
+ (BATT_MAX_CONTINUE_DISCHARGE_WATT *
+ PROCHOT_DEASSERTION_ADAPTER_BATT_RATIO /
+ 100)))
gpio_set_level(GPIO_EC_PROCHOT_ODL, 1);
}
}
diff --git a/baseboard/brya/usb_pd_policy.c b/baseboard/brya/usb_pd_policy.c
index e3e85539bf..e902fbc4a6 100644
--- a/baseboard/brya/usb_pd_policy.c
+++ b/baseboard/brya/usb_pd_policy.c
@@ -1,4 +1,4 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+/* Copyright 2021 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -25,8 +25,8 @@
#include "usb_pd_vdo.h"
#include "util.h"
-#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
int pd_check_vconn_swap(int port)
{
@@ -81,80 +81,86 @@ int board_vbus_source_enabled(int port)
return ppc_is_sourcing_vbus(port);
}
+#ifdef CONFIG_USB_PD_TBT_COMPAT_MODE
/* ----------------- Vendor Defined Messages ------------------ */
/* Responses specifically for the enablement of TBT mode in the role of UFP */
#define OPOS_TBT 1
-static const union tbt_mode_resp_device vdo_tbt_modes[1] = {
- {
- .tbt_alt_mode = 0x0001,
- .tbt_adapter = TBT_ADAPTER_TBT3,
- .intel_spec_b0 = 0,
- .vendor_spec_b0 = 0,
- .vendor_spec_b1 = 0,
- }
-};
-
-static const uint32_t vdo_idh = VDO_IDH(
- 1, /* Data caps as USB host */
- 0, /* Not a USB device */
- IDH_PTYPE_PERIPH,
- 1, /* Supports alt modes */
- USB_VID_GOOGLE);
-
-static const uint32_t vdo_idh_rev30 = VDO_IDH_REV30(
- 1, /* Data caps as USB host */
- 0, /* Not a USB device */
- IDH_PTYPE_PERIPH,
- 1, /* Supports alt modes */
- IDH_PTYPE_DFP_HOST,
- USB_TYPEC_RECEPTACLE,
- USB_VID_GOOGLE);
-
-static const uint32_t vdo_product = VDO_PRODUCT(CONFIG_USB_PID,
- CONFIG_USB_BCD_DEV);
+static const union tbt_mode_resp_device vdo_tbt_modes[1] = { {
+ .tbt_alt_mode = 0x0001,
+ .tbt_adapter = TBT_ADAPTER_TBT3,
+ .intel_spec_b0 = 0,
+ .vendor_spec_b0 = 0,
+ .vendor_spec_b1 = 0,
+} };
+
+static const uint32_t vdo_idh = VDO_IDH(1, /* Data caps as USB host */
+ 0, /* Not a USB device */
+ IDH_PTYPE_PERIPH, 1, /* Supports alt
+ modes */
+ USB_VID_GOOGLE);
+
+static const uint32_t vdo_idh_rev30 =
+ VDO_IDH_REV30(1, /* Data caps as USB host */
+ 0, /* Not a USB device */
+ IDH_PTYPE_PERIPH, 1, /* Supports alt modes */
+ IDH_PTYPE_DFP_HOST, USB_TYPEC_RECEPTACLE, USB_VID_GOOGLE);
+
+static const uint32_t vdo_product =
+ VDO_PRODUCT(CONFIG_USB_PID, CONFIG_USB_BCD_DEV);
/* TODO(b/168890624): add USB4 to capability once USB4 response implemented */
static const uint32_t vdo_ufp1 = VDO_UFP1(
- (VDO_UFP1_CAPABILITY_USB20
- | VDO_UFP1_CAPABILITY_USB32),
- USB_TYPEC_RECEPTACLE,
- VDO_UFP1_ALT_MODE_TBT3,
- USB_R30_SS_U40_GEN3);
-
-static const uint32_t vdo_dfp = VDO_DFP(
- (VDO_DFP_HOST_CAPABILITY_USB20
- | VDO_DFP_HOST_CAPABILITY_USB32
- | VDO_DFP_HOST_CAPABILITY_USB4),
- USB_TYPEC_RECEPTACLE,
- 1 /* Port 1 */);
+ (VDO_UFP1_CAPABILITY_USB20 | VDO_UFP1_CAPABILITY_USB32),
+ USB_TYPEC_RECEPTACLE, VDO_UFP1_ALT_MODE_TBT3, USB_R30_SS_U40_GEN3);
+
+static const uint32_t vdo_dfp =
+ VDO_DFP((VDO_DFP_HOST_CAPABILITY_USB20 | VDO_DFP_HOST_CAPABILITY_USB32 |
+ VDO_DFP_HOST_CAPABILITY_USB4),
+ USB_TYPEC_RECEPTACLE, 1 /* Port 1 */);
static int svdm_tbt_compat_response_identity(int port, uint32_t *payload)
{
- /* TODO(b/154962766): Get an XID */
- payload[VDO_I(CSTAT)] = VDO_CSTAT(0);
- payload[VDO_I(PRODUCT)] = vdo_product;
-
- if (pd_get_rev(port, TCPCI_MSG_SOP) == PD_REV30) {
- /* PD Revision 3.0 */
- payload[VDO_I(IDH)] = vdo_idh_rev30;
- payload[VDO_I(PTYPE_UFP1_VDO)] = vdo_ufp1;
- /* TODO(b/181620145): Customize for brya */
- payload[VDO_I(PTYPE_UFP2_VDO)] = 0;
- payload[VDO_I(PTYPE_DFP_VDO)] = vdo_dfp;
- return VDO_I(PTYPE_DFP_VDO) + 1;
- }
+ /*
+ * For PD 3.1 compliance test TEST.PD.VDM.SRC.2,
+ * we should return NAK if we cannot recognized the incoming SVID.
+ */
+ if (PD_VDO_VID(payload[0]) == USB_SID_PD) {
+ /* TODO(b/154962766): Get an XID */
+ payload[VDO_I(CSTAT)] = VDO_CSTAT(0);
+ payload[VDO_I(PRODUCT)] = vdo_product;
+
+ if (pd_get_rev(port, TCPCI_MSG_SOP) == PD_REV30) {
+ /* PD Revision 3.0 */
+ payload[VDO_I(IDH)] = vdo_idh_rev30;
+ payload[VDO_I(PTYPE_UFP1_VDO)] = vdo_ufp1;
+ /* TODO(b/181620145): Customize for brya */
+ payload[VDO_I(PTYPE_UFP2_VDO)] = 0;
+ payload[VDO_I(PTYPE_DFP_VDO)] = vdo_dfp;
+ return VDO_I(PTYPE_DFP_VDO) + 1;
+ }
- /* PD Revision 2.0 */
- payload[VDO_I(IDH)] = vdo_idh;
- return VDO_I(PRODUCT) + 1;
+ /* PD Revision 2.0 */
+ payload[VDO_I(IDH)] = vdo_idh;
+ return VDO_I(PRODUCT) + 1;
+ } else {
+ return 0; /* NAK */
+ }
}
static int svdm_tbt_compat_response_svids(int port, uint32_t *payload)
{
- payload[1] = VDO_SVID(USB_VID_INTEL, 0);
- return 2;
+ /*
+ * For PD 3.1 compliance test TEST.PD.VDM.SRC.2,
+ * we should return NAK if we cannot recognized the incoming SVID.
+ */
+ if (PD_VDO_VID(payload[0]) == USB_SID_PD) {
+ payload[1] = VDO_SVID(USB_VID_INTEL, 0);
+ return 2;
+ } else {
+ return 0; /* NAK */
+ }
}
static int svdm_tbt_compat_response_modes(int port, uint32_t *payload)
@@ -170,8 +176,8 @@ static int svdm_tbt_compat_response_modes(int port, uint32_t *payload)
/* Track whether we've been enabled to ACK TBT EnterModes requests */
static bool tbt_ufp_ack_allowed[CONFIG_USB_PD_PORT_MAX_COUNT];
-__override enum ec_status board_set_tbt_ufp_reply(int port,
- enum typec_tbt_ufp_reply reply)
+__override enum ec_status
+board_set_tbt_ufp_reply(int port, enum typec_tbt_ufp_reply reply)
{
/* Note: Host command has already bounds-checked port */
if (reply == TYPEC_TBT_UFP_REPLY_ACK)
@@ -184,8 +190,7 @@ __override enum ec_status board_set_tbt_ufp_reply(int port,
return EC_RES_SUCCESS;
}
-static int svdm_tbt_compat_response_enter_mode(
- int port, uint32_t *payload)
+static int svdm_tbt_compat_response_enter_mode(int port, uint32_t *payload)
{
mux_state_t mux_state = 0;
@@ -198,7 +203,7 @@ static int svdm_tbt_compat_response_enter_mode(
return 0; /* NAK */
if ((PD_VDO_VID(payload[0]) != USB_VID_INTEL) ||
- (PD_VDO_OPOS(payload[0]) != OPOS_TBT))
+ (PD_VDO_OPOS(payload[0]) != OPOS_TBT))
return 0; /* NAK */
mux_state = usb_mux_get(port);
@@ -208,7 +213,7 @@ static int svdm_tbt_compat_response_enter_mode(
* Mode that requires the reconfiguring of any pins.
*/
if ((mux_state & USB_PD_MUX_USB_ENABLED) ||
- (mux_state & USB_PD_MUX_SAFE_MODE)) {
+ (mux_state & USB_PD_MUX_SAFE_MODE)) {
pd_ufp_set_enter_mode(port, payload);
set_tbt_compat_mode_ready(port);
@@ -237,3 +242,4 @@ const struct svdm_response svdm_rsp = {
.amode = NULL,
.exit_mode = NULL,
};
+#endif /* CONFIG_USB_PD_TBT_COMPAT_MODE */