summaryrefslogtreecommitdiff
path: root/board/primus
diff options
context:
space:
mode:
Diffstat (limited to 'board/primus')
-rw-r--r--board/primus/battery.c97
-rw-r--r--board/primus/board.c31
-rw-r--r--board/primus/board.h137
-rw-r--r--board/primus/build.mk2
-rw-r--r--board/primus/cbi_ssfc.c2
-rw-r--r--board/primus/cbi_ssfc.h2
-rw-r--r--[l---------]board/primus/charger.c91
-rw-r--r--board/primus/ec.tasklist2
-rw-r--r--board/primus/fans.c4
-rw-r--r--board/primus/fw_config.c4
-rw-r--r--board/primus/fw_config.h23
-rw-r--r--board/primus/gpio.inc2
-rw-r--r--board/primus/i2c.c2
-rw-r--r--board/primus/keyboard.c2
-rw-r--r--board/primus/led.c64
-rw-r--r--board/primus/ps2.c20
-rw-r--r--board/primus/ps2.h20
-rw-r--r--board/primus/pwm.c2
-rw-r--r--board/primus/sensors.c64
-rw-r--r--board/primus/thermal.c66
-rw-r--r--board/primus/usbc_config.c61
-rw-r--r--board/primus/usbc_config.h10
22 files changed, 433 insertions, 275 deletions
diff --git a/board/primus/battery.c b/board/primus/battery.c
index e9e822f2e8..1b0d74bed3 100644
--- a/board/primus/battery.c
+++ b/board/primus/battery.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.
*
@@ -32,7 +32,7 @@
* address, mask, and disconnect value need to be provided.
*/
const struct board_batt_params board_battery_info[] = {
- [BATTERY_SUNWODA] = {
+ [BATTERY_SUNWODA_5B11F21946] = {
.fuel_gauge = {
.manuf_name = "Sunwoda",
.device_name = "LNV-5B11F21946",
@@ -61,7 +61,36 @@ const struct board_batt_params board_battery_info[] = {
},
},
- [BATTERY_SMP] = {
+ [BATTERY_SUNWODA_5B11H56342] = {
+ .fuel_gauge = {
+ .manuf_name = "Sunwoda",
+ .device_name = "LNV-5B11H56342",
+ .ship_mode = {
+ .reg_addr = 0x00,
+ .reg_data = { 0x0010, 0x0010 },
+ },
+ .fet = {
+ .mfgacc_support = 1,
+ .reg_addr = 0x0000,
+ .reg_mask = 0x6000,
+ .disconnect_val = 0x6000,
+ }
+ },
+ .batt_info = {
+ .voltage_max = 13200, /* mV */
+ .voltage_normal = 11520, /* mV */
+ .voltage_min = 9000, /* mV */
+ .precharge_current = 251, /* mA */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 50,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = -20,
+ .discharging_max_c = 60,
+ },
+ },
+
+ [BATTERY_SMP_5B11F21953] = {
.fuel_gauge = {
.manuf_name = "SMP",
.device_name = "LNV-5B11F21953",
@@ -90,7 +119,36 @@ const struct board_batt_params board_battery_info[] = {
},
},
- [BATTERY_CELXPERT] = {
+ [BATTERY_SMP_5B11H56344] = {
+ .fuel_gauge = {
+ .manuf_name = "SMP",
+ .device_name = "LNV-5B11H56344",
+ .ship_mode = {
+ .reg_addr = 0x00,
+ .reg_data = { 0x0010, 0x0010 },
+ },
+ .fet = {
+ .mfgacc_support = 1,
+ .reg_addr = 0x0000,
+ .reg_mask = 0x6000,
+ .disconnect_val = 0x6000,
+ }
+ },
+ .batt_info = {
+ .voltage_max = 13200, /* mV */
+ .voltage_normal = 11520, /* mV */
+ .voltage_min = 9000, /* mV */
+ .precharge_current = 250, /* mA */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 60,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = -20,
+ .discharging_max_c = 60,
+ },
+ },
+
+ [BATTERY_CELXPERT_5B11F21941] = {
.fuel_gauge = {
.manuf_name = "Celxpert",
.device_name = "LNV-5B11F21941",
@@ -118,7 +176,36 @@ const struct board_batt_params board_battery_info[] = {
.discharging_max_c = 70,
},
},
+
+ [BATTERY_CELXPERT_5B11H56343] = {
+ .fuel_gauge = {
+ .manuf_name = "Celxpert",
+ .device_name = "LNV-5B11H56343",
+ .ship_mode = {
+ .reg_addr = 0x00,
+ .reg_data = { 0x0010, 0x0010 },
+ },
+ .fet = {
+ .mfgacc_support = 1,
+ .reg_addr = 0x0000,
+ .reg_mask = 0x6000,
+ .disconnect_val = 0x6000,
+ }
+ },
+ .batt_info = {
+ .voltage_max = 13200, /* mV */
+ .voltage_normal = 11520, /* mV */
+ .voltage_min = 9000, /* mV */
+ .precharge_current = 487, /* mA */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 50,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = -20,
+ .discharging_max_c = 70,
+ },
+ },
};
BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
-const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_SUNWODA;
+const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_SUNWODA_5B11F21946;
diff --git a/board/primus/board.c b/board/primus/board.c
index d0fa9f6cae..8b5f1a86fc 100644
--- a/board/primus/board.c
+++ b/board/primus/board.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.
*/
@@ -30,8 +30,8 @@
#include "gpio_list.h" /* Must come after other header files. */
/* Console output macros */
-#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
-#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
+#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args)
#define KBLIGHT_LED_ON_LVL 100
#define KBLIGHT_LED_OFF_LVL 0
@@ -93,8 +93,8 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
}
if (voltage < BC12_MIN_VOLTAGE) {
- CPRINTS("%s: port %d: vbus %d lower than %d", __func__,
- port, voltage, BC12_MIN_VOLTAGE);
+ CPRINTS("%s: port %d: vbus %d lower than %d", __func__, port,
+ voltage, BC12_MIN_VOLTAGE);
return 1;
}
@@ -123,7 +123,7 @@ static void keyboard_init(void)
DECLARE_HOOK(HOOK_INIT, keyboard_init, HOOK_PRIO_DEFAULT);
__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
+ int max_ma, int charge_mv)
{
/*
* Need to set different input current limit depend on system state.
@@ -131,15 +131,14 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma,
*/
if (((max_ma == PD_MAX_CURRENT_MA) &&
- chipset_in_state(CHIPSET_STATE_ANY_OFF)) ||
- (max_ma != PD_MAX_CURRENT_MA))
+ chipset_in_state(CHIPSET_STATE_ANY_OFF)) ||
+ (max_ma != PD_MAX_CURRENT_MA))
charge_ma = charge_ma * 97 / 100;
else
charge_ma = charge_ma * 93 / 100;
- 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);
}
static void configure_input_current_limit(void)
@@ -155,16 +154,16 @@ static void configure_input_current_limit(void)
adapter_current_ma = charge_manager_get_charger_current();
if ((adapter_current_ma == PD_MAX_CURRENT_MA) &&
- chipset_in_or_transitioning_to_state(CHIPSET_STATE_SUSPEND))
+ chipset_in_or_transitioning_to_state(CHIPSET_STATE_SUSPEND))
adapter_current_ma = PD_MAX_SUSPEND_CURRENT_MA;
else
adapter_current_ma = adapter_current_ma * 97 / 100;
charge_set_input_current_limit(MAX(adapter_current_ma,
- CONFIG_CHARGER_INPUT_CURRENT),
- adapter_current_mv);
+ CONFIG_CHARGER_INPUT_CURRENT),
+ adapter_current_mv);
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, configure_input_current_limit,
- HOOK_PRIO_DEFAULT);
+ HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN_COMPLETE, configure_input_current_limit,
- HOOK_PRIO_DEFAULT);
+ HOOK_PRIO_DEFAULT);
diff --git a/board/primus/board.h b/board/primus/board.h
index 0b118efb6d..7346acc2ab 100644
--- a/board/primus/board.h
+++ b/board/primus/board.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.
*/
@@ -31,29 +31,29 @@
#undef CONFIG_VOLUME_BUTTONS
/* USB Type A Features */
-#define USB_PORT_COUNT 1
+#define USB_PORT_COUNT 1
#define CONFIG_USB_PORT_POWER_DUMB
/* USB Type C and USB PD defines */
#define CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY
-#undef CONFIG_USB_PD_TCPM_NCT38XX
+#undef CONFIG_USB_PD_TCPM_NCT38XX
#define CONFIG_USB_PD_TCPM_RT1715
#define CONFIG_USBC_RETIMER_INTEL_BB
#define CONFIG_USBC_PPC_SYV682X
-#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
-#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */
-#define PD_VCONN_SWAP_DELAY 5000 /* us */
+#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
+#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */
+#define PD_VCONN_SWAP_DELAY 5000 /* us */
/*
* Passive USB-C cables only support up to 60W.
*/
-#define PD_OPERATING_POWER_MW 15000
-#define PD_MAX_POWER_MW 65000
-#define PD_MAX_CURRENT_MA 3250
-#define PD_MAX_VOLTAGE_MV 20000
+#define PD_OPERATING_POWER_MW 15000
+#define PD_MAX_POWER_MW 65000
+#define PD_MAX_CURRENT_MA 3250
+#define PD_MAX_VOLTAGE_MV 20000
/*
* Macros for GPIO signals used in common code that don't match the
@@ -61,33 +61,33 @@
* then redefined here to so it's more clear which signal is being used for
* which purpose.
*/
-#define GPIO_AC_PRESENT GPIO_ACOK_OD
-#define GPIO_CPU_PROCHOT GPIO_EC_PROCHOT_ODL
-#define GPIO_EC_INT_L GPIO_EC_PCH_INT_ODL
-#define GPIO_ENABLE_BACKLIGHT GPIO_EC_EN_EDP_BL
-#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW
-#define GPIO_KBD_KSO2 GPIO_EC_KSO_02_INV
-#define GPIO_PACKET_MODE_EN GPIO_EC_GSC_PACKET_MODE
-#define GPIO_PCH_PWRBTN_L GPIO_EC_PCH_PWR_BTN_ODL
-#define GPIO_PCH_RSMRST_L GPIO_EC_PCH_RSMRST_L
-#define GPIO_PCH_RTCRST GPIO_EC_PCH_RTCRST
-#define GPIO_PCH_SLP_S0_L GPIO_SYS_SLP_S0IX_L
-#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
-#define GPIO_TEMP_SENSOR_POWER GPIO_SEQ_EC_DSW_PWROK
+#define GPIO_AC_PRESENT GPIO_ACOK_OD
+#define GPIO_CPU_PROCHOT GPIO_EC_PROCHOT_ODL
+#define GPIO_EC_INT_L GPIO_EC_PCH_INT_ODL
+#define GPIO_ENABLE_BACKLIGHT GPIO_EC_EN_EDP_BL
+#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW
+#define GPIO_KBD_KSO2 GPIO_EC_KSO_02_INV
+#define GPIO_PACKET_MODE_EN GPIO_EC_GSC_PACKET_MODE
+#define GPIO_PCH_PWRBTN_L GPIO_EC_PCH_PWR_BTN_ODL
+#define GPIO_PCH_RSMRST_L GPIO_EC_PCH_RSMRST_L
+#define GPIO_PCH_RTCRST GPIO_EC_PCH_RTCRST
+#define GPIO_PCH_SLP_S0_L GPIO_SYS_SLP_S0IX_L
+#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
+#define GPIO_TEMP_SENSOR_POWER GPIO_SEQ_EC_DSW_PWROK
/*
* GPIO_EC_PCH_INT_ODL is used for MKBP events as well as a PCH wakeup
* signal.
*/
-#define GPIO_PCH_WAKE_L GPIO_EC_PCH_INT_ODL
-#define GPIO_PG_EC_ALL_SYS_PWRGD GPIO_SEQ_EC_ALL_SYS_PG
-#define GPIO_PG_EC_DSW_PWROK GPIO_SEQ_EC_DSW_PWROK
-#define GPIO_PG_EC_RSMRST_ODL GPIO_SEQ_EC_RSMRST_ODL
-#define GPIO_POWER_BUTTON_L GPIO_GSC_EC_PWR_BTN_ODL
-#define GPIO_SYS_RESET_L GPIO_SYS_RST_ODL
-#define GPIO_WP_L GPIO_EC_WP_ODL
+#define GPIO_PCH_WAKE_L GPIO_EC_PCH_INT_ODL
+#define GPIO_PG_EC_ALL_SYS_PWRGD GPIO_SEQ_EC_ALL_SYS_PG
+#define GPIO_PG_EC_DSW_PWROK GPIO_SEQ_EC_DSW_PWROK
+#define GPIO_PG_EC_RSMRST_ODL GPIO_SEQ_EC_RSMRST_ODL
+#define GPIO_POWER_BUTTON_L GPIO_GSC_EC_PWR_BTN_ODL
+#define GPIO_SYS_RESET_L GPIO_SYS_RST_ODL
+#define GPIO_WP_L GPIO_EC_WP_ODL
-#define GPIO_ID_1_EC_KB_BL_EN GPIO_EC_BATT_PRES_ODL
+#define GPIO_ID_1_EC_KB_BL_EN GPIO_EC_BATT_PRES_ODL
/* System has back-lit keyboard */
#define CONFIG_PWM_KBLIGHT
@@ -97,23 +97,23 @@
/* I2C Bus Configuration */
-#define I2C_PORT_USB_C0_TCPC NPCX_I2C_PORT1_0
-#define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1
-#define I2C_PORT_USB_C0_C1_PPC_BC NPCX_I2C_PORT2_0
-#define I2C_PORT_USB_C0_C1_BC12 NPCX_I2C_PORT2_0
-#define I2C_PORT_USB_C0_C1_RT NPCX_I2C_PORT3_0
-#define I2C_PORT_BATTERY NPCX_I2C_PORT5_0
-#define I2C_PORT_USB_A0_A1_MIX NPCX_I2C_PORT6_1
-#define I2C_PORT_CHARGER NPCX_I2C_PORT7_0
-#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0
-#define I2C_PORT_MP2964 NPCX_I2C_PORT7_0
+#define I2C_PORT_USB_C0_TCPC NPCX_I2C_PORT1_0
+#define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1
+#define I2C_PORT_USB_C0_C1_PPC_BC NPCX_I2C_PORT2_0
+#define I2C_PORT_USB_C0_C1_BC12 NPCX_I2C_PORT2_0
+#define I2C_PORT_USB_C0_C1_RT NPCX_I2C_PORT3_0
+#define I2C_PORT_BATTERY NPCX_I2C_PORT5_0
+#define I2C_PORT_USB_A0_A1_MIX NPCX_I2C_PORT6_1
+#define I2C_PORT_CHARGER NPCX_I2C_PORT7_0
+#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0
+#define I2C_PORT_MP2964 NPCX_I2C_PORT7_0
-#define I2C_ADDR_EEPROM_FLAGS 0x50
+#define I2C_ADDR_EEPROM_FLAGS 0x50
-#define I2C_ADDR_MP2964_FLAGS 0x20
+#define I2C_ADDR_MP2964_FLAGS 0x20
-#define USBC_PORT_C0_BB_RETIMER_I2C_ADDR 0x56
-#define USBC_PORT_C1_BB_RETIMER_I2C_ADDR 0x57
+#define USBC_PORT_C0_BB_RETIMER_I2C_ADDR 0x56
+#define USBC_PORT_C1_BB_RETIMER_I2C_ADDR 0x57
/* Enabling Thunderbolt-compatible mode */
#define CONFIG_USB_PD_TBT_COMPAT_MODE
@@ -135,19 +135,19 @@
/* Fan features */
#define CONFIG_CUSTOM_FAN_CONTROL
-#define CONFIG_FANS FAN_CH_COUNT
-#define RPM_DEVIATION 1
+#define CONFIG_FANS FAN_CH_COUNT
+#define RPM_DEVIATION 1
/* Charger defines */
#define CONFIG_CHARGER_BQ25720
#define CONFIG_CHARGER_BQ25720_VSYS_TH2_CUSTOM
-#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
+#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
#define CONFIG_CHARGE_RAMP_SW
-#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
/* PROCHOT defines */
-#define BATT_MAX_CONTINUE_DISCHARGE_WATT 66
+#define BATT_MAX_CONTINUE_DISCHARGE_WATT 66
/* Prochot assertion/deassertion ratios*/
#define PROCHOT_ADAPTER_WATT_RATIO 97
@@ -164,11 +164,11 @@
#define CONFIG_8042_AUX
#define CONFIG_PS2
#define CONFIG_CMD_PS2
-#define PRIMUS_PS2_CH NPCX_PS2_CH1
+#define PRIMUS_PS2_CH NPCX_PS2_CH1
#ifndef __ASSEMBLER__
-#include "gpio_signal.h" /* needed by registers.h */
+#include "gpio_signal.h" /* needed by registers.h */
#include "registers.h"
#include "usbc_config.h"
@@ -201,31 +201,28 @@ enum sensor_id {
};
enum battery_type {
- BATTERY_SUNWODA,
- BATTERY_SMP,
- BATTERY_CELXPERT,
+ BATTERY_SUNWODA_5B11F21946,
+ BATTERY_SUNWODA_5B11H56342,
+ BATTERY_SMP_5B11F21953,
+ BATTERY_SMP_5B11H56344,
+ BATTERY_CELXPERT_5B11F21941,
+ BATTERY_CELXPERT_5B11H56343,
BATTERY_TYPE_COUNT
};
enum pwm_channel {
- PWM_CH_LED2_WHITE = 0, /* PWM0 (white charger) */
- PWM_CH_TKP_A_LED_N, /* PWM1 (LOGO led on A cover) */
- PWM_CH_LED1_AMBER, /* PWM2 (orange charger) */
- PWM_CH_KBLIGHT, /* PWM3 */
- PWM_CH_FAN, /* PWM5 */
- PWM_CH_LED4, /* PWM7 (power) */
+ PWM_CH_LED2_WHITE = 0, /* PWM0 (white charger) */
+ PWM_CH_TKP_A_LED_N, /* PWM1 (LOGO led on A cover) */
+ PWM_CH_LED1_AMBER, /* PWM2 (orange charger) */
+ PWM_CH_KBLIGHT, /* PWM3 */
+ PWM_CH_FAN, /* PWM5 */
+ PWM_CH_LED4, /* PWM7 (power) */
PWM_CH_COUNT
};
-enum fan_channel {
- FAN_CH_0 = 0,
- FAN_CH_COUNT
-};
+enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT };
-enum mft_channel {
- MFT_CH_0 = 0,
- MFT_CH_COUNT
-};
+enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT };
#endif /* !__ASSEMBLER__ */
diff --git a/board/primus/build.mk b/board/primus/build.mk
index ddf50b46e2..409a9dd45e 100644
--- a/board/primus/build.mk
+++ b/board/primus/build.mk
@@ -1,5 +1,5 @@
# -*- makefile -*-
-# 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/board/primus/cbi_ssfc.c b/board/primus/cbi_ssfc.c
index dd59bb2c9f..45afa622ab 100644
--- a/board/primus/cbi_ssfc.c
+++ b/board/primus/cbi_ssfc.c
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 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/board/primus/cbi_ssfc.h b/board/primus/cbi_ssfc.h
index d1ad8c991f..fe4c2fb4e5 100644
--- a/board/primus/cbi_ssfc.h
+++ b/board/primus/cbi_ssfc.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 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/board/primus/charger.c b/board/primus/charger.c
index 476ce97df2..a4fa209246 120000..100644
--- a/board/primus/charger.c
+++ b/board/primus/charger.c
@@ -1 +1,90 @@
-../../baseboard/brya/charger_bq25720.c \ No newline at end of file
+/* 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.
+ */
+
+#include "common.h"
+
+#include "charge_manager.h"
+#include "charge_state_v2.h"
+#include "charger.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "driver/charger/bq25710.h"
+#include "usbc_ppc.h"
+#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)
+
+#ifndef CONFIG_ZEPHYR
+/* Charger Chip Configuration */
+const struct charger_config_t chg_chips[] = {
+ {
+ .i2c_port = I2C_PORT_CHARGER,
+ .i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS,
+ .drv = &bq25710_drv,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(chg_chips) == CHARGER_NUM);
+#endif
+
+int board_set_active_charge_port(int port)
+{
+ int is_valid_port = board_is_usb_pd_port_present(port);
+ int i;
+
+ if (port == CHARGE_PORT_NONE) {
+ CPRINTSUSB("Disabling all charger ports");
+
+ /* Disable all ports. */
+ for (i = 0; i < ppc_cnt; i++) {
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (ppc_vbus_sink_enable(i, 0))
+ CPRINTSUSB("Disabling C%d as sink failed.", i);
+ }
+
+ return EC_SUCCESS;
+ } else if (!is_valid_port) {
+ return EC_ERROR_INVAL;
+ }
+
+ /* Check if the port is sourcing VBUS. */
+ if (ppc_is_sourcing_vbus(port)) {
+ CPRINTFUSB("Skip enable C%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ CPRINTSUSB("New charge port: C%d", port);
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < ppc_cnt; i++) {
+ if (i == port)
+ continue;
+
+ if (ppc_vbus_sink_enable(i, 0))
+ CPRINTSUSB("C%d: sink path disable failed.", i);
+ }
+
+ /* Enable requested charge port. */
+ if (ppc_vbus_sink_enable(port, 1)) {
+ CPRINTSUSB("C%d: sink path enable failed.", port);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ return EC_SUCCESS;
+}
+
+__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);
+}
diff --git a/board/primus/ec.tasklist b/board/primus/ec.tasklist
index bf2ec04c62..3afcca805e 100644
--- a/board/primus/ec.tasklist
+++ b/board/primus/ec.tasklist
@@ -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/board/primus/fans.c b/board/primus/fans.c
index 001c6fde5c..b3c72c074b 100644
--- a/board/primus/fans.c
+++ b/board/primus/fans.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,7 +25,7 @@ BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT);
static const struct fan_conf fan_conf_0 = {
.flags = FAN_USE_RPM_MODE,
- .ch = MFT_CH_0, /* Use MFT id to control fan */
+ .ch = MFT_CH_0, /* Use MFT id to control fan */
.pgood_gpio = -1,
.enable_gpio = GPIO_EN_PP5000_FAN,
};
diff --git a/board/primus/fw_config.c b/board/primus/fw_config.c
index 0384d05b9d..82ba396901 100644
--- a/board/primus/fw_config.c
+++ b/board/primus/fw_config.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.
*/
@@ -9,7 +9,7 @@
#include "cros_board_info.h"
#include "fw_config.h"
-#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ##args)
static union primus_cbi_fw_config fw_config;
BUILD_ASSERT(sizeof(fw_config) == sizeof(uint32_t));
diff --git a/board/primus/fw_config.h b/board/primus/fw_config.h
index f8792f1443..81fa5481f8 100644
--- a/board/primus/fw_config.h
+++ b/board/primus/fw_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.
*/
@@ -25,21 +25,18 @@ enum ec_cfg_keyboard_backlight_type {
KEYBOARD_BACKLIGHT_ENABLED = 1
};
-enum ec_cfg_mlb_usb {
- MLB_USB_TBT = 0,
- MLB_USB_USB4 = 1
-};
+enum ec_cfg_mlb_usb { MLB_USB_TBT = 0, MLB_USB_USB4 = 1 };
union primus_cbi_fw_config {
struct {
- enum ec_cfg_usb_db_type usb_db : 4;
- uint32_t sd_db : 2;
- uint32_t reserved_0 : 1;
- enum ec_cfg_keyboard_backlight_type kb_bl : 1;
- uint32_t audio : 3;
- uint32_t cellular_db : 2;
- enum ec_cfg_mlb_usb mlb_usb : 1;
- uint32_t reserved_1 : 18;
+ enum ec_cfg_usb_db_type usb_db : 4;
+ uint32_t sd_db : 2;
+ uint32_t reserved_0 : 1;
+ enum ec_cfg_keyboard_backlight_type kb_bl : 1;
+ uint32_t audio : 3;
+ uint32_t cellular_db : 2;
+ enum ec_cfg_mlb_usb mlb_usb : 1;
+ uint32_t reserved_1 : 18;
};
uint32_t raw_value;
};
diff --git a/board/primus/gpio.inc b/board/primus/gpio.inc
index ce66027514..9928eb0cc5 100644
--- a/board/primus/gpio.inc
+++ b/board/primus/gpio.inc
@@ -1,6 +1,6 @@
/* -*- mode:c -*-
*
- * 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/board/primus/i2c.c b/board/primus/i2c.c
index 019862f441..21939347b1 100644
--- a/board/primus/i2c.c
+++ b/board/primus/i2c.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.
*/
diff --git a/board/primus/keyboard.c b/board/primus/keyboard.c
index 5b45b60b19..9c9a37e9fc 100644
--- a/board/primus/keyboard.c
+++ b/board/primus/keyboard.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.
*/
diff --git a/board/primus/led.c b/board/primus/led.c
index 3a8da5ac32..70c1c89188 100644
--- a/board/primus/led.c
+++ b/board/primus/led.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.
*/
@@ -24,32 +24,30 @@
#include "task.h"
#include "timer.h"
#include "util.h"
-#define CPRINTS(format, args...) cprints(CC_LOGOLED, format, ## args)
-
-#define LED_ON_LVL 100
-#define LED_OFF_LVL 0
-#define LED_BAT_S3_OFF_TIME_MS 3000
-#define LED_BAT_S3_TICK_MS 50
-#define LED_BAT_S3_PWM_RESCALE 5
-#define LED_TOTAL_TICKS 6
-#define TICKS_STEP1_BRIGHTER 0
-#define TICKS_STEP2_DIMMER (1000 / LED_BAT_S3_TICK_MS)
-#define TICKS_STEP3_OFF (2 * TICKS_STEP2_DIMMER)
-#define LED_ONE_SEC (1000 / HOOK_TICK_INTERVAL_MS)
-#define LED_LOGO_TICK_SEC (LED_ONE_SEC / 4)
+#define CPRINTS(format, args...) cprints(CC_LOGOLED, format, ##args)
+
+#define LED_ON_LVL 100
+#define LED_OFF_LVL 0
+#define LED_BAT_S3_OFF_TIME_MS 3000
+#define LED_BAT_S3_TICK_MS 50
+#define LED_BAT_S3_PWM_RESCALE 5
+#define LED_TOTAL_TICKS 6
+#define TICKS_STEP1_BRIGHTER 0
+#define TICKS_STEP2_DIMMER (1000 / LED_BAT_S3_TICK_MS)
+#define TICKS_STEP3_OFF (2 * TICKS_STEP2_DIMMER)
+#define LED_ONE_SEC (1000 / HOOK_TICK_INTERVAL_MS)
+#define LED_LOGO_TICK_SEC (LED_ONE_SEC / 4)
/* Total on/off duration in a period */
-#define PERIOD (LED_LOGO_TICK_SEC * 2)
-#define LED_ON 1
-#define LED_OFF EC_LED_COLOR_COUNT
-#define LED_EVENT_SUSPEND TASK_EVENT_CUSTOM_BIT(0)
-#define LED_EVENT_200MS_TICK TASK_EVENT_CUSTOM_BIT(1)
+#define PERIOD (LED_LOGO_TICK_SEC * 2)
+#define LED_ON 1
+#define LED_OFF EC_LED_COLOR_COUNT
+#define LED_EVENT_SUSPEND TASK_EVENT_CUSTOM_BIT(0)
+#define LED_EVENT_200MS_TICK TASK_EVENT_CUSTOM_BIT(1)
static int tick;
-const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_BATTERY_LED,
- EC_LED_ID_POWER_LED
-};
+const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED,
+ EC_LED_ID_POWER_LED };
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
static void led_set_color_battery(enum ec_led_colors color)
@@ -94,11 +92,11 @@ void led_set_color_power(int onoff_status)
/* primus logo led and power led have same behavior. */
if (onoff_status == LED_ON) {
pwm_set_duty(PWM_CH_TKP_A_LED_N, LED_ON_LVL);
- pwm_set_duty(PWM_CH_LED4, LED_ON_LVL);
+ pwm_set_duty(PWM_CH_LED4, LED_ON_LVL);
} else {
/* LED_OFF and unsupported colors */
pwm_set_duty(PWM_CH_TKP_A_LED_N, LED_OFF_LVL);
- pwm_set_duty(PWM_CH_LED4, LED_OFF_LVL);
+ pwm_set_duty(PWM_CH_LED4, LED_OFF_LVL);
}
}
@@ -176,7 +174,7 @@ static void suspend_led_update(void)
* if we are not transitioning to suspend, we should break here.
*/
if (!chipset_in_or_transitioning_to_state(
- CHIPSET_STATE_ANY_SUSPEND))
+ CHIPSET_STATE_ANY_SUSPEND))
break;
/* 1s gradual on, 1s gradual off, 3s off */
@@ -187,9 +185,9 @@ static void suspend_led_update(void)
* behavior.
*/
pwm_set_duty(PWM_CH_TKP_A_LED_N,
- tick * LED_BAT_S3_PWM_RESCALE);
+ tick * LED_BAT_S3_PWM_RESCALE);
pwm_set_duty(PWM_CH_LED4,
- tick * LED_BAT_S3_PWM_RESCALE);
+ tick * LED_BAT_S3_PWM_RESCALE);
msleep(LED_BAT_S3_TICK_MS);
} else if (tick <= TICKS_STEP3_OFF) {
/* decrease 5 duty every 50ms until PWM=0
@@ -197,10 +195,12 @@ static void suspend_led_update(void)
* A-cover and power button led are shared same
* behavior.
*/
- pwm_set_duty(PWM_CH_TKP_A_LED_N, (TICKS_STEP3_OFF
- - tick) * LED_BAT_S3_PWM_RESCALE);
- pwm_set_duty(PWM_CH_LED4, (TICKS_STEP3_OFF
- - tick) * LED_BAT_S3_PWM_RESCALE);
+ pwm_set_duty(PWM_CH_TKP_A_LED_N,
+ (TICKS_STEP3_OFF - tick) *
+ LED_BAT_S3_PWM_RESCALE);
+ pwm_set_duty(PWM_CH_LED4,
+ (TICKS_STEP3_OFF - tick) *
+ LED_BAT_S3_PWM_RESCALE);
msleep(LED_BAT_S3_TICK_MS);
} else {
tick = TICKS_STEP1_BRIGHTER;
diff --git a/board/primus/ps2.c b/board/primus/ps2.c
index ba341f6be0..2a0a764d5e 100644
--- a/board/primus/ps2.c
+++ b/board/primus/ps2.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,7 +15,7 @@
#include "registers.h"
#include "time.h"
-#define PS2_TRANSMIT_DELAY_MS 10
+#define PS2_TRANSMIT_DELAY_MS 10
static uint8_t queue_data[3];
static int data_count;
@@ -39,8 +39,8 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
*/
static void enable_ps2(void)
{
- gpio_set_alternate_function(GPIO_PORT_6,
- BIT(2) | BIT(3), GPIO_ALT_FUNC_DEFAULT);
+ gpio_set_alternate_function(GPIO_PORT_6, BIT(2) | BIT(3),
+ GPIO_ALT_FUNC_DEFAULT);
}
DECLARE_DEFERRED(enable_ps2);
@@ -48,8 +48,8 @@ static void disable_ps2(void)
{
gpio_set_flags(GPIO_EC_PS2_SCL_TPAD, GPIO_ODR_LOW);
gpio_set_flags(GPIO_EC_PS2_SDA_TPAD, GPIO_ODR_LOW);
- gpio_set_alternate_function(GPIO_PORT_6,
- BIT(2) | BIT(3), GPIO_ALT_FUNC_NONE);
+ gpio_set_alternate_function(GPIO_PORT_6, BIT(2) | BIT(3),
+ GPIO_ALT_FUNC_NONE);
/* make sure PLTRST# goes high and re-enable PS2.*/
hook_call_deferred(&enable_ps2_data, 2 * SECOND);
}
@@ -96,7 +96,7 @@ uint8_t get_trackpoint_id(void)
* Also make sure only return the trackpoint device ID.
*/
if (queue_data[1] == TP_VARIANT_ELAN ||
- queue_data[1] == TP_VARIANT_SYNAPTICS)
+ queue_data[1] == TP_VARIANT_SYNAPTICS)
return queue_data[1];
else
return 0;
@@ -129,10 +129,10 @@ static void ps2_suspend(void)
*/
if (trackpoint_id == TP_VARIANT_ELAN)
send_command_to_trackpoint(TP_TOGGLE_BURST,
- TP_TOGGLE_ELAN_SLEEP);
+ TP_TOGGLE_ELAN_SLEEP);
else if (trackpoint_id == TP_VARIANT_SYNAPTICS)
send_command_to_trackpoint(TP_TOGGLE_SOURCE_TAG,
- TP_TOGGLE_SNAPTICS_SLEEP);
+ TP_TOGGLE_SNAPTICS_SLEEP);
/* Clear the data in queue and the counter */
memset(queue_data, 0, ARRAY_SIZE(queue_data));
@@ -154,7 +154,7 @@ static void ps2_resume(void)
*/
if (trackpoint_id == TP_VARIANT_SYNAPTICS)
send_command_to_trackpoint(TP_TOGGLE_SOURCE_TAG,
- TP_TOGGLE_SNAPTICS_SLEEP);
+ TP_TOGGLE_SNAPTICS_SLEEP);
/* Clear the data in queue and the counter */
memset(queue_data, 0, ARRAY_SIZE(queue_data));
diff --git a/board/primus/ps2.h b/board/primus/ps2.h
index 0943d5ba4b..a82d6d566a 100644
--- a/board/primus/ps2.h
+++ b/board/primus/ps2.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,20 +12,20 @@
* 0x01 was the original IBM trackpoint, others implement very limited
* subset of trackpoint features.
*/
-#define TP_READ_ID 0xE1 /* Sent for device identification */
+#define TP_READ_ID 0xE1 /* Sent for device identification */
-#define TP_COMMAND 0xE2 /* Commands start with this */
+#define TP_COMMAND 0xE2 /* Commands start with this */
/*
* Toggling Flag bits
*/
-#define TP_TOGGLE 0x47 /* Toggle command */
+#define TP_TOGGLE 0x47 /* Toggle command */
-#define TP_VARIANT_ELAN 0x03
-#define TP_VARIANT_SYNAPTICS 0x06
-#define TP_TOGGLE_SOURCE_TAG 0x20
-#define TP_TOGGLE_BURST 0x28
-#define TP_TOGGLE_SNAPTICS_SLEEP 0x10
-#define TP_TOGGLE_ELAN_SLEEP 0x8
+#define TP_VARIANT_ELAN 0x03
+#define TP_VARIANT_SYNAPTICS 0x06
+#define TP_TOGGLE_SOURCE_TAG 0x20
+#define TP_TOGGLE_BURST 0x28
+#define TP_TOGGLE_SNAPTICS_SLEEP 0x10
+#define TP_TOGGLE_ELAN_SLEEP 0x8
#endif /* __CROS_EC_PRIMUS_PS2_H */
diff --git a/board/primus/pwm.c b/board/primus/pwm.c
index 26ca6e5b92..f2889c2b8e 100644
--- a/board/primus/pwm.c
+++ b/board/primus/pwm.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.
*/
diff --git a/board/primus/sensors.c b/board/primus/sensors.c
index 60cfa1428f..9c0a9d69e8 100644
--- a/board/primus/sensors.c
+++ b/board/primus/sensors.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.
*/
@@ -59,36 +59,26 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
/* Temperature sensor configuration */
const struct temp_sensor_t temp_sensors[] = {
- [TEMP_SENSOR_1_DDR_SOC] = {
- .name = "DDR and SOC",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_1_DDR_SOC
- },
- [TEMP_SENSOR_2_SSD] = {
- .name = "SSD",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_2_SSD
- },
- [TEMP_SENSOR_3_CHARGER] = {
- .name = "Charger",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_3_CHARGER
- },
- [TEMP_SENSOR_4_MEMORY] = {
- .name = "MEMORY",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_4_MEMORY
- },
- [TEMP_SENSOR_5_USBC] = {
- .name = "USBC",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_30k9_47k_4050b,
- .idx = ADC_TEMP_SENSOR_5_USBC
- },
+ [TEMP_SENSOR_1_DDR_SOC] = { .name = "DDR and SOC",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_1_DDR_SOC },
+ [TEMP_SENSOR_2_SSD] = { .name = "SSD",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_2_SSD },
+ [TEMP_SENSOR_3_CHARGER] = { .name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_3_CHARGER },
+ [TEMP_SENSOR_4_MEMORY] = { .name = "MEMORY",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_4_MEMORY },
+ [TEMP_SENSOR_5_USBC] = { .name = "USBC",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_5_USBC },
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
@@ -102,8 +92,8 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
/*
* TODO(b/202062363): Remove when clang is fixed.
*/
-#define THERMAL_CPU \
- { \
+#define THERMAL_CPU \
+ { \
.temp_host = { \
[EC_TEMP_THRESH_HIGH] = C_TO_K(70), \
[EC_TEMP_THRESH_HALT] = C_TO_K(90), \
@@ -119,8 +109,8 @@ __maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU;
/*
* TODO(b/202062363): Remove when clang is fixed.
*/
-#define THERMAL_SSD \
- { \
+#define THERMAL_SSD \
+ { \
.temp_host = { \
[EC_TEMP_THRESH_HIGH] = C_TO_K(75), \
[EC_TEMP_THRESH_HALT] = C_TO_K(92), \
@@ -149,8 +139,8 @@ __maybe_unused static const struct ec_thermal_config thermal_ssd = THERMAL_SSD;
/*
* TODO(b/202062363): Remove when clang is fixed.
*/
-#define THERMAL_INDUCTOR \
- { \
+#define THERMAL_INDUCTOR \
+ { \
.temp_host = { \
[EC_TEMP_THRESH_HIGH] = C_TO_K(75), \
[EC_TEMP_THRESH_HALT] = C_TO_K(90), \
diff --git a/board/primus/thermal.c b/board/primus/thermal.c
index f5e200b14c..00e2dddf98 100644
--- a/board/primus/thermal.c
+++ b/board/primus/thermal.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.
*/
@@ -14,9 +14,7 @@
#include "util.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_THERMAL, outstr)
-#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ## args)
-
-
+#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ##args)
struct fan_step {
/*
@@ -36,51 +34,51 @@ struct fan_step {
static const struct fan_step fan_table[] = {
{
/* level 0 */
- .on = {40, -1, -1, -1, -1},
- .off = {0, -1, -1, -1, -1},
- .rpm = {0},
+ .on = { 40, -1, -1, -1, -1 },
+ .off = { 0, -1, -1, -1, -1 },
+ .rpm = { 0 },
},
{
/* level 1 */
- .on = {42, -1, -1, -1, -1},
- .off = {40, -1, -1, -1, -1},
- .rpm = {1800},
+ .on = { 42, -1, -1, -1, -1 },
+ .off = { 40, -1, -1, -1, -1 },
+ .rpm = { 1800 },
},
{
/* level 2 */
- .on = {43, -1, -1, -1, -1},
- .off = {42, -1, -1, -1, -1},
- .rpm = {2000},
+ .on = { 43, -1, -1, -1, -1 },
+ .off = { 42, -1, -1, -1, -1 },
+ .rpm = { 2000 },
},
{
/* level 3 */
- .on = {44, -1, -1, -1, -1},
- .off = {43, -1, -1, -1, -1},
- .rpm = {2200},
+ .on = { 44, -1, -1, -1, -1 },
+ .off = { 43, -1, -1, -1, -1 },
+ .rpm = { 2200 },
},
{
/* level 4 */
- .on = {45, -1, -1, -1, -1},
- .off = {44, -1, -1, -1, -1},
- .rpm = {2500},
+ .on = { 45, -1, -1, -1, -1 },
+ .off = { 44, -1, -1, -1, -1 },
+ .rpm = { 2500 },
},
{
/* level 5 */
- .on = {46, -1, -1, -1, -1},
- .off = {45, -1, -1, -1, -1},
- .rpm = {2800},
+ .on = { 46, -1, -1, -1, -1 },
+ .off = { 45, -1, -1, -1, -1 },
+ .rpm = { 2800 },
},
{
/* level 6 */
- .on = {47, -1, -1, -1, -1},
- .off = {46, -1, -1, -1, -1},
- .rpm = {3000},
+ .on = { 47, -1, -1, -1, -1 },
+ .off = { 46, -1, -1, -1, -1 },
+ .rpm = { 3000 },
},
{
/* level 7 */
- .on = {75, -1, -1, -1, -1},
- .off = {72, -1, -1, -1, -1},
- .rpm = {3200},
+ .on = { 75, -1, -1, -1, -1 },
+ .off = { 72, -1, -1, -1, -1 },
+ .rpm = { 3200 },
},
};
const int num_fan_levels = ARRAY_SIZE(fan_table);
@@ -106,17 +104,14 @@ int fan_table_to_rpm(int fan, int *temp, enum temp_sensor_id temp_sensor)
*/
if (temp[temp_sensor] < prev_temp[temp_sensor]) {
for (i = current_level; i > 0; i--) {
- if (temp[temp_sensor] <
- fan_table[i].off[temp_sensor])
+ if (temp[temp_sensor] < fan_table[i].off[temp_sensor])
current_level = i - 1;
else
break;
}
- } else if (temp[temp_sensor] >
- prev_temp[temp_sensor]) {
+ } else if (temp[temp_sensor] > prev_temp[temp_sensor]) {
for (i = current_level; i < num_fan_levels; i++) {
- if (temp[temp_sensor] >
- fan_table[i].on[temp_sensor])
+ if (temp[temp_sensor] > fan_table[i].on[temp_sensor])
current_level = i + 1;
else
break;
@@ -148,7 +143,8 @@ void board_override_fan_control(int fan, int *temp)
if (chipset_in_state(CHIPSET_STATE_ON)) {
fan_set_rpm_mode(FAN_CH(fan), 1);
fan_set_rpm_target(FAN_CH(fan),
- fan_table_to_rpm(FAN_CH(fan), temp, TEMP_SENSOR_1_DDR_SOC));
+ fan_table_to_rpm(FAN_CH(fan), temp,
+ TEMP_SENSOR_1_DDR_SOC));
} else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) {
/* Stop fan when enter S0ix */
fan_set_rpm_mode(FAN_CH(fan), 1);
diff --git a/board/primus/usbc_config.c b/board/primus/usbc_config.c
index ecaac56b2d..a11a8d588f 100644
--- a/board/primus/usbc_config.c
+++ b/board/primus/usbc_config.c
@@ -1,9 +1,8 @@
-/* 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.
*/
-
#include <stdint.h>
#include <stdbool.h>
@@ -32,8 +31,8 @@
#include "usb_pd.h"
#include "usb_pd_tcpm.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)
/* USBC TCPC configuration */
const struct tcpc_config_t tcpc_config[] = {
@@ -75,33 +74,43 @@ BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT);
unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
/* USBC mux configuration - Alder Lake includes internal mux */
-static const struct usb_mux usbc0_tcss_usb_mux = {
- .usb_port = USBC_PORT_C0,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
+static const struct usb_mux_chain usbc0_tcss_usb_mux = {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = USBC_PORT_C0,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
+ },
};
-static const struct usb_mux usbc1_tcss_usb_mux = {
- .usb_port = USBC_PORT_C1,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
+static const struct usb_mux_chain usbc1_tcss_usb_mux = {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = USBC_PORT_C1,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
+ },
};
-const struct usb_mux usb_muxes[] = {
+const struct usb_mux_chain usb_muxes[] = {
[USBC_PORT_C0] = {
- .usb_port = USBC_PORT_C0,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_C0_C1_RT,
- .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR,
- .next_mux = &usbc0_tcss_usb_mux,
+ .mux = &(const struct usb_mux) {
+ .usb_port = USBC_PORT_C0,
+ .driver = &bb_usb_retimer,
+ .hpd_update = bb_retimer_hpd_update,
+ .i2c_port = I2C_PORT_USB_C0_C1_RT,
+ .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR,
+ },
+ .next = &usbc0_tcss_usb_mux,
},
[USBC_PORT_C1] = {
- .usb_port = USBC_PORT_C1,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_C0_C1_RT,
- .i2c_addr_flags = USBC_PORT_C1_BB_RETIMER_I2C_ADDR,
- .next_mux = &usbc1_tcss_usb_mux,
+ .mux = &(const struct usb_mux) {
+ .usb_port = USBC_PORT_C1,
+ .driver = &bb_usb_retimer,
+ .hpd_update = bb_retimer_hpd_update,
+ .i2c_port = I2C_PORT_USB_C0_C1_RT,
+ .i2c_addr_flags = USBC_PORT_C1_BB_RETIMER_I2C_ADDR,
+ },
+ .next = &usbc1_tcss_usb_mux,
},
};
BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
@@ -178,7 +187,6 @@ void board_reset_pd_mcu(void)
static void board_tcpc_init(void)
{
-
/* Don't reset TCPCs after initial reset */
if (!system_jumped_late()) {
board_reset_pd_mcu();
@@ -195,7 +203,6 @@ static void board_tcpc_init(void)
/* Enable BC1.2 interrupts. */
gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL);
gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_ODL);
-
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_CHIPSET);
diff --git a/board/primus/usbc_config.h b/board/primus/usbc_config.h
index 8bc1918c02..1e087f083c 100644
--- a/board/primus/usbc_config.h
+++ b/board/primus/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.
*/
@@ -8,13 +8,9 @@
#ifndef __CROS_EC_USBC_CONFIG_H
#define __CROS_EC_USBC_CONFIG_H
-#define CONFIG_USB_PD_PORT_MAX_COUNT 2
+#define CONFIG_USB_PD_PORT_MAX_COUNT 2
-enum usbc_port {
- USBC_PORT_C0 = 0,
- USBC_PORT_C1,
- USBC_PORT_COUNT
-};
+enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
void config_usb_db_type(void);