summaryrefslogtreecommitdiff
path: root/board/primus
diff options
context:
space:
mode:
Diffstat (limited to 'board/primus')
-rw-r--r--board/primus/board.c42
-rw-r--r--board/primus/board.h9
-rw-r--r--board/primus/build.mk1
-rw-r--r--board/primus/ec.tasklist1
-rw-r--r--board/primus/fans.c11
-rw-r--r--board/primus/fw_config.c5
-rw-r--r--board/primus/fw_config.h18
-rw-r--r--board/primus/i2c.c4
-rw-r--r--board/primus/thermal.c157
-rw-r--r--board/primus/usbc_config.c8
10 files changed, 239 insertions, 17 deletions
diff --git a/board/primus/board.c b/board/primus/board.c
index 0881ab1c86..d0fa9f6cae 100644
--- a/board/primus/board.c
+++ b/board/primus/board.c
@@ -8,6 +8,7 @@
#include "charge_ramp.h"
#include "charger.h"
#include "common.h"
+#include "charge_manager.h"
#include "charge_state_v2.h"
#include "compile_time_macros.h"
#include "console.h"
@@ -35,6 +36,8 @@
#define KBLIGHT_LED_ON_LVL 100
#define KBLIGHT_LED_OFF_LVL 0
+#define PD_MAX_SUSPEND_CURRENT_MA 3000
+
/******************************************************************************/
/* USB-A charging control */
@@ -123,12 +126,45 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma,
int max_ma, int charge_mv)
{
/*
- * Follow OEM request to limit the input current to
- * 97% negotiated limit.
+ * Need to set different input current limit depend on system state.
+ * Guard adapter plug/ un-plug here.
*/
- charge_ma = charge_ma * 97 / 100;
+
+ if (((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);
}
+
+static void configure_input_current_limit(void)
+{
+ /*
+ * If adapter == 3250mA, we need system be charged at 3150mA in S5.
+ * And system be charged at 3000mA in S0.
+ */
+ int adapter_current_ma;
+ int adapter_current_mv;
+ /* Get adapter voltage/ current */
+ adapter_current_mv = charge_manager_get_charger_voltage();
+ 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))
+ 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);
+}
+DECLARE_HOOK(HOOK_CHIPSET_STARTUP, configure_input_current_limit,
+ HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN_COMPLETE, configure_input_current_limit,
+ HOOK_PRIO_DEFAULT);
diff --git a/board/primus/board.h b/board/primus/board.h
index 5b87eb6477..830ad20529 100644
--- a/board/primus/board.h
+++ b/board/primus/board.h
@@ -49,8 +49,8 @@
* Passive USB-C cables only support up to 60W.
*/
#define PD_OPERATING_POWER_MW 15000
-#define PD_MAX_POWER_MW 60000
-#define PD_MAX_CURRENT_MA 3000
+#define PD_MAX_POWER_MW 65000
+#define PD_MAX_CURRENT_MA 3250
#define PD_MAX_VOLTAGE_MV 20000
/*
@@ -71,6 +71,7 @@
#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
@@ -124,12 +125,14 @@
/* Thermal features */
#define CONFIG_THERMISTOR
#define CONFIG_TEMP_SENSOR
-#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_SEQ_EC_DSW_PWROK
+#define CONFIG_TEMP_SENSOR_POWER
#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
/* LED */
#define CONFIG_BATTERY_LEVEL_NEAR_FULL 91
+/* Fan features */
+#define CONFIG_CUSTOM_FAN_CONTROL
#define CONFIG_FANS FAN_CH_COUNT
#define RPM_DEVIATION 1
diff --git a/board/primus/build.mk b/board/primus/build.mk
index d6fe9b4808..217f95da10 100644
--- a/board/primus/build.mk
+++ b/board/primus/build.mk
@@ -23,4 +23,5 @@ board-y+=led.o
board-y+=pwm.o
board-y+=ps2.o
board-y+=sensors.o
+board-y+=thermal.o
board-y+=usbc_config.o
diff --git a/board/primus/ec.tasklist b/board/primus/ec.tasklist
index 2a9c288ee6..bf2ec04c62 100644
--- a/board/primus/ec.tasklist
+++ b/board/primus/ec.tasklist
@@ -18,6 +18,7 @@
TASK_ALWAYS(CHARGER, charger_task, NULL, BASEBOARD_CHARGER_TASK_STACK_SIZE) \
TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, BASEBOARD_CHIPSET_TASK_STACK_SIZE) \
+ TASK_ALWAYS(USB_MUX, usb_mux_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(CONSOLE, console_task, NULL, CONSOLE_TASK_STACK_SIZE) \
TASK_ALWAYS(POWERBTN, power_button_task, NULL, BASEBOARD_POWERBTN_TASK_STACK_SIZE) \
diff --git a/board/primus/fans.c b/board/primus/fans.c
index d966056331..001c6fde5c 100644
--- a/board/primus/fans.c
+++ b/board/primus/fans.c
@@ -31,15 +31,12 @@ static const struct fan_conf fan_conf_0 = {
};
/*
- * TOOD(b/180681346): need to update for real fan
- *
- * Prototype fan spins at about 7200 RPM at 100% PWM.
- * Set minimum at around 30% PWM.
+ * Set maximum rpm at 4800/ minimum rpm at 1800.
*/
static const struct fan_rpm fan_rpm_0 = {
- .rpm_min = 2200,
- .rpm_start = 2200,
- .rpm_max = 7200,
+ .rpm_min = 1800,
+ .rpm_start = 1800,
+ .rpm_max = 4800,
};
const struct fan_t fans[FAN_CH_COUNT] = {
diff --git a/board/primus/fw_config.c b/board/primus/fw_config.c
index 9506e778b5..0384d05b9d 100644
--- a/board/primus/fw_config.c
+++ b/board/primus/fw_config.c
@@ -54,6 +54,11 @@ union primus_cbi_fw_config get_fw_config(void)
return fw_config;
}
+enum ec_cfg_mlb_usb ec_cfg_mlb_usb(void)
+{
+ return fw_config.mlb_usb;
+}
+
enum ec_cfg_usb_db_type ec_cfg_usb_db_type(void)
{
return fw_config.usb_db;
diff --git a/board/primus/fw_config.h b/board/primus/fw_config.h
index cbccbd07a9..f8792f1443 100644
--- a/board/primus/fw_config.h
+++ b/board/primus/fw_config.h
@@ -25,14 +25,21 @@ enum ec_cfg_keyboard_backlight_type {
KEYBOARD_BACKLIGHT_ENABLED = 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 lte_db : 1;
+ uint32_t reserved_0 : 1;
enum ec_cfg_keyboard_backlight_type kb_bl : 1;
uint32_t audio : 3;
- uint32_t reserved_1 : 21;
+ uint32_t cellular_db : 2;
+ enum ec_cfg_mlb_usb mlb_usb : 1;
+ uint32_t reserved_1 : 18;
};
uint32_t raw_value;
};
@@ -45,6 +52,13 @@ union primus_cbi_fw_config {
union primus_cbi_fw_config get_fw_config(void);
/**
+ * Get MLB USB type from FW_CONFIG.
+ *
+ * @return the MLB USB type.
+ */
+enum ec_cfg_mlb_usb ec_cfg_mlb_usb(void);
+
+/**
* Get the USB daughter board type from FW_CONFIG.
*
* @return the USB daughter board type.
diff --git a/board/primus/i2c.c b/board/primus/i2c.c
index 3a4fe69b0c..019862f441 100644
--- a/board/primus/i2c.c
+++ b/board/primus/i2c.c
@@ -17,7 +17,7 @@ const struct i2c_port_t i2c_ports[] = {
*/
.name = "tcpc0",
.port = I2C_PORT_USB_C0_TCPC,
- .kbps = 400,
+ .kbps = 1000,
.scl = GPIO_EC_I2C_USB_C0_TCPC_SCL,
.sda = GPIO_EC_I2C_USB_C0_TCPC_SDA,
},
@@ -44,7 +44,7 @@ const struct i2c_port_t i2c_ports[] = {
*/
.name = "tcpc1",
.port = I2C_PORT_USB_C1_TCPC,
- .kbps = 400,
+ .kbps = 1000,
.scl = GPIO_EC_I2C_USB_C1_TCPC_SCL,
.sda = GPIO_EC_I2C_USB_C1_TCPC_SDA,
},
diff --git a/board/primus/thermal.c b/board/primus/thermal.c
new file mode 100644
index 0000000000..f5e200b14c
--- /dev/null
+++ b/board/primus/thermal.c
@@ -0,0 +1,157 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "chipset.h"
+#include "common.h"
+#include "console.h"
+#include "fan.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "temp_sensor.h"
+#include "thermal.h"
+#include "util.h"
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_THERMAL, outstr)
+#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ## args)
+
+
+
+struct fan_step {
+ /*
+ * Sensor 1~4 trigger point, set -1 if we're not using this
+ * sensor to determine fan speed.
+ */
+ int8_t on[TEMP_SENSOR_COUNT];
+ /*
+ * Sensor 1~4 trigger point, set -1 if we're not using this
+ * sensor to determine fan speed.
+ */
+ int8_t off[TEMP_SENSOR_COUNT];
+ /* Fan rpm */
+ uint16_t rpm[FAN_CH_COUNT];
+};
+
+static const struct fan_step fan_table[] = {
+ {
+ /* level 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},
+ },
+ {
+ /* level 2 */
+ .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},
+ },
+ {
+ /* level 4 */
+ .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},
+ },
+ {
+ /* level 6 */
+ .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},
+ },
+};
+const int num_fan_levels = ARRAY_SIZE(fan_table);
+
+int fan_table_to_rpm(int fan, int *temp, enum temp_sensor_id temp_sensor)
+{
+ /* current fan level */
+ static int current_level;
+ /* previous fan level */
+ static int prev_current_level;
+
+ /* previous sensor temperature */
+ static int prev_temp[TEMP_SENSOR_COUNT];
+ int i;
+ int new_rpm = 0;
+
+ /*
+ * Compare the current and previous temperature, we have
+ * the three paths :
+ * 1. decreasing path. (check the release point)
+ * 2. increasing path. (check the trigger point)
+ * 3. invariant path. (return the current RPM)
+ */
+ 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])
+ current_level = i - 1;
+ else
+ break;
+ }
+ } 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])
+ current_level = i + 1;
+ else
+ break;
+ }
+ }
+ if (current_level < 0)
+ current_level = 0;
+
+ if (current_level != prev_current_level) {
+ CPRINTS("temp: %d, prev_temp: %d", temp[temp_sensor],
+ prev_temp[temp_sensor]);
+ CPRINTS("current_level: %d", current_level);
+ }
+
+ prev_temp[temp_sensor] = temp[temp_sensor];
+ prev_current_level = current_level;
+
+ switch (fan) {
+ case FAN_CH_0:
+ new_rpm = fan_table[current_level].rpm[FAN_CH_0];
+ break;
+ default:
+ break;
+ }
+ return new_rpm;
+}
+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));
+ } else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) {
+ /* Stop fan when enter S0ix */
+ fan_set_rpm_mode(FAN_CH(fan), 1);
+ fan_set_rpm_target(FAN_CH(fan), 0);
+ }
+}
diff --git a/board/primus/usbc_config.c b/board/primus/usbc_config.c
index 2207b1b085..44f58c184e 100644
--- a/board/primus/usbc_config.c
+++ b/board/primus/usbc_config.c
@@ -274,3 +274,11 @@ __override bool board_is_dts_port(int port)
{
return port == USBC_PORT_C0;
}
+
+__override enum tbt_compat_cable_speed board_get_max_tbt_speed(int port)
+{
+ if (ec_cfg_mlb_usb())
+ return TBT_SS_U32_GEN1_GEN2;
+
+ return TBT_SS_TBT_GEN3;
+}