summaryrefslogtreecommitdiff
path: root/board/morphius
diff options
context:
space:
mode:
Diffstat (limited to 'board/morphius')
-rw-r--r--board/morphius/battery.c2
-rw-r--r--board/morphius/board.c133
-rw-r--r--board/morphius/board.h86
-rw-r--r--board/morphius/build.mk2
-rw-r--r--board/morphius/ec.tasklist2
-rw-r--r--board/morphius/gpio.inc2
-rw-r--r--board/morphius/led.c44
-rw-r--r--board/morphius/thermal.c328
8 files changed, 287 insertions, 312 deletions
diff --git a/board/morphius/battery.c b/board/morphius/battery.c
index 6d8a8190b2..6867bcd8bd 100644
--- a/board/morphius/battery.c
+++ b/board/morphius/battery.c
@@ -1,4 +1,4 @@
-/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+/* Copyright 2019 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/morphius/board.c b/board/morphius/board.c
index beca0d89f0..e801fd8569 100644
--- a/board/morphius/board.c
+++ b/board/morphius/board.c
@@ -1,4 +1,4 @@
-/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+/* Copyright 2019 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -16,7 +16,7 @@
#include "driver/accelgyro_icm426xx.h"
#include "driver/accel_kionix.h"
#include "driver/accel_kx022.h"
-#include "driver/ppc/aoz1380.h"
+#include "driver/ppc/aoz1380_public.h"
#include "driver/ppc/nx20p348x.h"
#include "driver/retimer/pi3dpx1207.h"
#include "driver/retimer/pi3hdx1204.h"
@@ -59,21 +59,15 @@ static bool ignore_c1_dp;
static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
-mat33_fp_t base_standard_ref = {
- { 0, FLOAT_TO_FP(1), 0},
- { FLOAT_TO_FP(1), 0, 0},
- { 0, 0, FLOAT_TO_FP(-1)}
-};
-const mat33_fp_t base_standard_ref_1 = {
- { FLOAT_TO_FP(-1), 0, 0},
- { 0, FLOAT_TO_FP(1), 0},
- { 0, 0, FLOAT_TO_FP(-1)}
-};
-mat33_fp_t lid_standard_ref = {
- { 0, FLOAT_TO_FP(1), 0},
- { FLOAT_TO_FP(-1), 0, 0},
- { 0, 0, FLOAT_TO_FP(1)}
-};
+mat33_fp_t base_standard_ref = { { 0, FLOAT_TO_FP(1), 0 },
+ { FLOAT_TO_FP(1), 0, 0 },
+ { 0, 0, FLOAT_TO_FP(-1) } };
+const mat33_fp_t base_standard_ref_1 = { { FLOAT_TO_FP(-1), 0, 0 },
+ { 0, FLOAT_TO_FP(1), 0 },
+ { 0, 0, FLOAT_TO_FP(-1) } };
+mat33_fp_t lid_standard_ref = { { 0, FLOAT_TO_FP(1), 0 },
+ { FLOAT_TO_FP(-1), 0, 0 },
+ { 0, 0, FLOAT_TO_FP(1) } };
/* sensor private data */
static struct kionix_accel_data g_kx022_data;
@@ -293,6 +287,10 @@ void motion_interrupt(enum gpio_signal signal)
/*****************************************************************************
* USB-C MUX/Retimer dynamic configuration
*/
+
+/* Place holder for second mux in USBC1 chain */
+struct usb_mux_chain usbc1_mux1;
+
static void setup_mux(void)
{
if (ec_config_has_usbc1_retimer_ps8802()) {
@@ -304,12 +302,10 @@ static void setup_mux(void)
* Replace usb_muxes[USBC_PORT_C1] with the PS8802
* table entry.
*/
- memcpy(&usb_muxes[USBC_PORT_C1],
- &usbc1_ps8802,
- sizeof(struct usb_mux));
+ usb_muxes[USBC_PORT_C1].mux = &usbc1_ps8802;
/* Set the AMD FP5 as the secondary MUX */
- usb_muxes[USBC_PORT_C1].next_mux = &usbc1_amd_fp5_usb_mux;
+ usbc1_mux1.mux = &usbc1_amd_fp5_usb_mux;
/* Don't have the AMD FP5 flip */
usbc1_amd_fp5_usb_mux.flags = USB_MUX_FLAG_SET_WITHOUT_FLIP;
@@ -323,12 +319,10 @@ static void setup_mux(void)
* Replace usb_muxes[USBC_PORT_C1] with the AMD FP5
* table entry.
*/
- memcpy(&usb_muxes[USBC_PORT_C1],
- &usbc1_amd_fp5_usb_mux,
- sizeof(struct usb_mux));
+ usb_muxes[USBC_PORT_C1].mux = &usbc1_amd_fp5_usb_mux;
/* Set the PS8818 as the secondary MUX */
- usb_muxes[USBC_PORT_C1].next_mux = &usbc1_ps8818;
+ usbc1_mux1.mux = &usbc1_ps8818;
}
}
@@ -342,23 +336,29 @@ const struct pi3dpx1207_usb_control pi3dpx1207_controls[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pi3dpx1207_controls) == USBC_PORT_COUNT);
-const struct usb_mux usbc0_pi3dpx1207_usb_retimer = {
- .usb_port = USBC_PORT_C0,
- .i2c_port = I2C_PORT_TCPC0,
- .i2c_addr_flags = PI3DPX1207_I2C_ADDR_FLAGS,
- .driver = &pi3dpx1207_usb_retimer,
+const struct usb_mux_chain usbc0_pi3dpx1207_usb_retimer = {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = USBC_PORT_C0,
+ .i2c_port = I2C_PORT_TCPC0,
+ .i2c_addr_flags = PI3DPX1207_I2C_ADDR_FLAGS,
+ .driver = &pi3dpx1207_usb_retimer,
+ },
};
-struct usb_mux usb_muxes[] = {
+struct usb_mux_chain usb_muxes[] = {
[USBC_PORT_C0] = {
- .usb_port = USBC_PORT_C0,
- .i2c_port = I2C_PORT_USB_AP_MUX,
- .i2c_addr_flags = AMD_FP5_MUX_I2C_ADDR_FLAGS,
- .driver = &amd_fp5_usb_mux_driver,
- .next_mux = &usbc0_pi3dpx1207_usb_retimer,
+ .mux = &(const struct usb_mux) {
+ .usb_port = USBC_PORT_C0,
+ .i2c_port = I2C_PORT_USB_AP_MUX,
+ .i2c_addr_flags = AMD_FP5_MUX_I2C_ADDR_FLAGS,
+ .driver = &amd_fp5_usb_mux_driver,
+ },
+ .next = &usbc0_pi3dpx1207_usb_retimer,
},
[USBC_PORT_C1] = {
/* Filled in dynamically at startup */
+ .next = &usbc1_mux1,
},
};
BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
@@ -400,11 +400,9 @@ int board_usbc_port_to_hpd_gpio_or_ioex(int port)
* this will be removed when version_2 hardware is retired.
*/
else if (ec_config_has_mst_hub_rtd2141b())
- return (board_ver >= 4)
- ? GPIO_USB_C1_HPD_IN_DB_V1
- : (board_ver == 3)
- ? IOEX_USB_C1_HPD_IN_DB
- : GPIO_EC_DP1_HPD;
+ return (board_ver >= 4) ? GPIO_USB_C1_HPD_IN_DB_V1 :
+ (board_ver == 3) ? IOEX_USB_C1_HPD_IN_DB :
+ GPIO_EC_DP1_HPD;
/* USB-C1 OPT1 DB uses DP2_HPD. */
return GPIO_DP2_HPD;
@@ -486,7 +484,7 @@ DECLARE_HOOK(HOOK_INIT, setup_fw_config, HOOK_PRIO_INIT_I2C + 2);
/* Physical fans. These are logically separate from pwm_channels. */
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 = -1,
};
@@ -584,8 +582,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(90), \
[EC_TEMP_THRESH_HALT] = C_TO_K(105), \
@@ -605,11 +603,11 @@ static void setup_fans(void)
DECLARE_HOOK(HOOK_INIT, setup_fans, HOOK_PRIO_DEFAULT);
/* Battery functions */
-#define SB_OPTIONALMFG_FUNCTION2 0x26
-#define SMART_CHARGE_SUPPORT 0x01
-#define SMART_CHARGE_ENABLE 0x02
-#define SB_SMART_CHARGE_ENABLE 1
-#define SB_SMART_CHARGE_DISABLE 0
+#define SB_OPTIONALMFG_FUNCTION2 0x26
+#define SMART_CHARGE_SUPPORT 0x01
+#define SMART_CHARGE_ENABLE 0x02
+#define SB_SMART_CHARGE_ENABLE 1
+#define SB_SMART_CHARGE_DISABLE 0
static void sb_smart_charge_mode(int enable)
{
@@ -651,18 +649,18 @@ __override void ppc_interrupt(enum gpio_signal signal)
* the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0
* current limits.
*/
-__override int board_aoz1380_set_vbus_source_current_limit(int port,
- enum tcpc_rp_value rp)
+__override int
+board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
{
int rv;
/* Use the TCPC to set the current limit */
if (port == 0) {
rv = ioex_set_level(IOEX_USB_C0_PPC_ILIM_3A_EN,
- (rp == TYPEC_RP_3A0) ? 1 : 0);
+ (rp == TYPEC_RP_3A0) ? 1 : 0);
} else if (board_ver >= 3) {
rv = ioex_set_level(IOEX_USB_C1_PPC_ILIM_3A_EN,
- (rp == TYPEC_RP_3A0) ? 1 : 0);
+ (rp == TYPEC_RP_3A0) ? 1 : 0);
} else {
rv = 1;
}
@@ -716,8 +714,7 @@ static void board_chipset_resume(void)
ioex_set_level(IOEX_HDMI_POWER_EN_DB, 1);
msleep(PI3HDX1204_POWER_ON_DELAY_MS);
}
- pi3hdx1204_enable(I2C_PORT_TCPC1,
- PI3HDX1204_I2C_ADDR_FLAGS,
+ pi3hdx1204_enable(I2C_PORT_TCPC1, PI3HDX1204_I2C_ADDR_FLAGS,
check_hdmi_hpd_status());
}
}
@@ -735,16 +732,14 @@ static void board_chipset_suspend(void)
sb_smart_charge_mode(SB_SMART_CHARGE_ENABLE);
if (ec_config_has_hdmi_retimer_pi3hdx1204()) {
- pi3hdx1204_enable(I2C_PORT_TCPC1,
- PI3HDX1204_I2C_ADDR_FLAGS,
- 0);
+ pi3hdx1204_enable(I2C_PORT_TCPC1, PI3HDX1204_I2C_ADDR_FLAGS, 0);
if (board_ver >= 3)
ioex_set_level(IOEX_HDMI_POWER_EN_DB, 0);
}
/* Wait 500ms before allowing DP event to cause resume. */
- if (ec_config_has_mst_hub_rtd2141b()
- && (dp_flags[USBC_PORT_C1] & DP_FLAGS_DP_ON)) {
+ if (ec_config_has_mst_hub_rtd2141b() &&
+ (dp_flags[USBC_PORT_C1] & DP_FLAGS_DP_ON)) {
ignore_c1_dp = true;
hook_call_deferred(&board_chipset_suspend_delay_data,
500 * MSEC);
@@ -789,15 +784,14 @@ BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
* The connector has 24 pins total, and there is no pin 0.
*/
const int keyboard_factory_scan_pins[][2] = {
- {3, 0}, {2, 2}, {2, 3}, {1, 2}, {2, 5},
- {2, 4}, {2, 1}, {2, 7}, {2, 6}, {1, 5},
- {2, 0}, {3, 1}, {1, 7}, {1, 6}, {-1, -1},
- {1, 3}, {1, 4}, {-1, -1}, {-1, -1}, {0, 7},
- {0, 6}, {1, 0}, {1, 1}, {0, 5},
+ { 3, 0 }, { 2, 2 }, { 2, 3 }, { 1, 2 }, { 2, 5 }, { 2, 4 },
+ { 2, 1 }, { 2, 7 }, { 2, 6 }, { 1, 5 }, { 2, 0 }, { 3, 1 },
+ { 1, 7 }, { 1, 6 }, { -1, -1 }, { 1, 3 }, { 1, 4 }, { -1, -1 },
+ { -1, -1 }, { 0, 7 }, { 0, 6 }, { 1, 0 }, { 1, 1 }, { 0, 5 },
};
const int keyboard_factory_scan_pins_used =
- ARRAY_SIZE(keyboard_factory_scan_pins);
+ ARRAY_SIZE(keyboard_factory_scan_pins);
#endif
/*****************************************************************************
@@ -840,10 +834,9 @@ static void hdmi_hpd_handler(void)
gpio_set_level(GPIO_EC_DP1_HPD, hpd);
ccprints("HDMI HPD %d", hpd);
- pi3hdx1204_enable(I2C_PORT_TCPC1,
- PI3HDX1204_I2C_ADDR_FLAGS,
- chipset_in_or_transitioning_to_state(CHIPSET_STATE_ON)
- && hpd);
+ pi3hdx1204_enable(
+ I2C_PORT_TCPC1, PI3HDX1204_I2C_ADDR_FLAGS,
+ chipset_in_or_transitioning_to_state(CHIPSET_STATE_ON) && hpd);
}
DECLARE_DEFERRED(hdmi_hpd_handler);
diff --git a/board/morphius/board.h b/board/morphius/board.h
index 180b1df9d0..39bce41a46 100644
--- a/board/morphius/board.h
+++ b/board/morphius/board.h
@@ -1,4 +1,4 @@
-/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+/* Copyright 2019 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -52,36 +52,35 @@
#define RPM_DEVIATION 1
/* GPIO mapping from board specific name to EC common name. */
-#define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_ODL
-#define CONFIG_SCI_GPIO GPIO_EC_FCH_SCI_ODL
-#define GPIO_AC_PRESENT GPIO_ACOK_OD
-#define GPIO_CPU_PROCHOT GPIO_PROCHOT_ODL
-#define GPIO_EC_INT_L GPIO_EC_AP_INT_ODL
-#define GPIO_ENABLE_BACKLIGHT_L GPIO_EC_EDP_BL_DISABLE
-#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW
-#define GPIO_KBD_KSO2 GPIO_EC_KSO_02_INV
-#define GPIO_PCH_PWRBTN_L GPIO_EC_FCH_PWR_BTN_L
-#define GPIO_PCH_RSMRST_L GPIO_EC_FCH_RSMRST_L
-#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
-#define GPIO_PCH_SLP_S5_L GPIO_SLP_S5_L
-#define GPIO_PCH_SYS_PWROK GPIO_EC_FCH_PWROK
-#define GPIO_PCH_WAKE_L GPIO_EC_FCH_WAKE_L
-#define GPIO_POWER_BUTTON_L GPIO_EC_PWR_BTN_ODL
-#define GPIO_S0_PGOOD GPIO_S0_PWROK_OD
-#define GPIO_S5_PGOOD GPIO_EC_PWROK_OD
-#define GPIO_SYS_RESET_L GPIO_EC_SYS_RST_L
-#define GPIO_TEMP_SENSOR_POWER GPIO_EN_PWR_A
-#define GPIO_VOLUME_DOWN_L GPIO_VOLDN_BTN_ODL
-#define GPIO_VOLUME_UP_L GPIO_VOLUP_BTN_ODL
-#define GPIO_WP_L GPIO_EC_WP_L
-#define GPIO_PACKET_MODE_EN GPIO_EC_H1_PACKET_MODE
+#define CONFIG_BATTERY_PRESENT_GPIO GPIO_EC_BATT_PRES_ODL
+#define CONFIG_SCI_GPIO GPIO_EC_FCH_SCI_ODL
+#define GPIO_AC_PRESENT GPIO_ACOK_OD
+#define GPIO_CPU_PROCHOT GPIO_PROCHOT_ODL
+#define GPIO_EC_INT_L GPIO_EC_AP_INT_ODL
+#define GPIO_ENABLE_BACKLIGHT_L GPIO_EC_EDP_BL_DISABLE
+#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW
+#define GPIO_KBD_KSO2 GPIO_EC_KSO_02_INV
+#define GPIO_PCH_PWRBTN_L GPIO_EC_FCH_PWR_BTN_L
+#define GPIO_PCH_RSMRST_L GPIO_EC_FCH_RSMRST_L
+#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
+#define GPIO_PCH_SLP_S5_L GPIO_SLP_S5_L
+#define GPIO_PCH_SYS_PWROK GPIO_EC_FCH_PWROK
+#define GPIO_PCH_WAKE_L GPIO_EC_FCH_WAKE_L
+#define GPIO_POWER_BUTTON_L GPIO_EC_PWR_BTN_ODL
+#define GPIO_S0_PGOOD GPIO_S0_PWROK_OD
+#define GPIO_S5_PGOOD GPIO_EC_PWROK_OD
+#define GPIO_SYS_RESET_L GPIO_EC_SYS_RST_L
+#define GPIO_TEMP_SENSOR_POWER GPIO_EN_PWR_A
+#define GPIO_VOLUME_DOWN_L GPIO_VOLDN_BTN_ODL
+#define GPIO_VOLUME_UP_L GPIO_VOLUP_BTN_ODL
+#define GPIO_WP_L GPIO_EC_WP_L
+#define GPIO_PACKET_MODE_EN GPIO_EC_H1_PACKET_MODE
/* I2C mapping from board specific function*/
-#define I2C_PORT_THERMAL I2C_PORT_AP_HDMI
+#define I2C_PORT_THERMAL I2C_PORT_AP_HDMI
#ifndef __ASSEMBLER__
-
void ps2_pwr_en_interrupt(enum gpio_signal signal);
enum adc_channel {
@@ -118,11 +117,7 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
-enum usba_port {
- USBA_PORT_A0 = 0,
- USBA_PORT_A1,
- USBA_PORT_COUNT
-};
+enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_A1, USBA_PORT_COUNT };
/*****************************************************************************
* CBI EC FW Configuration
@@ -172,40 +167,32 @@ enum ec_cfg_usb_db_type {
#include "cbi_ec_fw_config.h"
-#define HAS_USBC1_RETIMER_PS8802 \
- (BIT(MORPHIUS_DB_T_OPT3_USBC_HDMI_MSTHUB))
+#define HAS_USBC1_RETIMER_PS8802 (BIT(MORPHIUS_DB_T_OPT3_USBC_HDMI_MSTHUB))
static inline bool ec_config_has_usbc1_retimer_ps8802(void)
{
- return !!(BIT(ec_config_get_usb_db()) &
- HAS_USBC1_RETIMER_PS8802);
+ return !!(BIT(ec_config_get_usb_db()) & HAS_USBC1_RETIMER_PS8802);
}
-#define HAS_USBC1_RETIMER_PS8818 \
- (BIT(MORPHIUS_DB_T_OPT1_USBC_HDMI))
+#define HAS_USBC1_RETIMER_PS8818 (BIT(MORPHIUS_DB_T_OPT1_USBC_HDMI))
static inline bool ec_config_has_usbc1_retimer_ps8818(void)
{
- return !!(BIT(ec_config_get_usb_db()) &
- HAS_USBC1_RETIMER_PS8818);
+ return !!(BIT(ec_config_get_usb_db()) & HAS_USBC1_RETIMER_PS8818);
}
-#define HAS_HDMI_RETIMER_PI3HDX1204 \
- (BIT(MORPHIUS_DB_T_OPT1_USBC_HDMI))
+#define HAS_HDMI_RETIMER_PI3HDX1204 (BIT(MORPHIUS_DB_T_OPT1_USBC_HDMI))
static inline bool ec_config_has_hdmi_retimer_pi3hdx1204(void)
{
- return !!(BIT(ec_config_get_usb_db()) &
- HAS_HDMI_RETIMER_PI3HDX1204);
+ return !!(BIT(ec_config_get_usb_db()) & HAS_HDMI_RETIMER_PI3HDX1204);
}
-#define HAS_MST_HUB_RTD2141B \
- (BIT(MORPHIUS_DB_T_OPT3_USBC_HDMI_MSTHUB))
+#define HAS_MST_HUB_RTD2141B (BIT(MORPHIUS_DB_T_OPT3_USBC_HDMI_MSTHUB))
static inline bool ec_config_has_mst_hub_rtd2141b(void)
{
- return !!(BIT(ec_config_get_usb_db()) &
- HAS_MST_HUB_RTD2141B);
+ return !!(BIT(ec_config_get_usb_db()) & HAS_MST_HUB_RTD2141B);
}
void motion_interrupt(enum gpio_signal signal);
@@ -219,12 +206,11 @@ void motion_interrupt(enum gpio_signal signal);
int board_usbc_port_to_hpd_gpio_or_ioex(int port);
#define PORT_TO_HPD(port) board_usbc_port_to_hpd_gpio_or_ioex(port)
-extern const struct usb_mux usbc0_pi3dpx1207_usb_retimer;
-extern const struct usb_mux usbc1_ps8802;
+extern const struct usb_mux_chain usbc0_pi3dpx1207_usb_retimer;
extern const struct usb_mux usbc1_ps8818;
+extern struct usb_mux usbc1_ps8802;
extern struct usb_mux usbc1_amd_fp5_usb_mux;
#endif /* !__ASSEMBLER__ */
-
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/morphius/build.mk b/board/morphius/build.mk
index 4c2a6c5546..d6a15192ec 100644
--- a/board/morphius/build.mk
+++ b/board/morphius/build.mk
@@ -1,5 +1,5 @@
# -*- makefile -*-
-# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Copyright 2019 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/morphius/ec.tasklist b/board/morphius/ec.tasklist
index 41b83cf4f3..4bb60ed55d 100644
--- a/board/morphius/ec.tasklist
+++ b/board/morphius/ec.tasklist
@@ -1,4 +1,4 @@
-/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+/* Copyright 2019 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/morphius/gpio.inc b/board/morphius/gpio.inc
index f14c56c66f..0597419c63 100644
--- a/board/morphius/gpio.inc
+++ b/board/morphius/gpio.inc
@@ -1,6 +1,6 @@
/* -*- mode:c -*-
*
- * Copyright 2019 The Chromium OS Authors. All rights reserved.
+ * Copyright 2019 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/morphius/led.c b/board/morphius/led.c
index 5e72653fe3..23f715da02 100644
--- a/board/morphius/led.c
+++ b/board/morphius/led.c
@@ -1,4 +1,4 @@
-/* Copyright 2019 The Chromium OS Authors. All rights reserved.
+/* Copyright 2019 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -17,8 +17,8 @@
#include "timer.h"
#include "util.h"
-#define LED_BAT_OFF_LVL 0
-#define LED_BAT_ON_LVL 1
+#define LED_BAT_OFF_LVL 0
+#define LED_BAT_ON_LVL 1
#define LED_BAT_S3_OFF_TIME_MS 3000
#define LED_BAT_S3_PWM_RESCALE 5
#define LED_BAT_S3_TICK_MS 50
@@ -34,10 +34,8 @@
static int ticks;
-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);
@@ -45,13 +43,13 @@ enum led_color {
LED_OFF = 0,
LED_WHITE,
LED_AMBER,
- LED_COLOR_COUNT /* Number of colors, not a color itself */
+ LED_COLOR_COUNT /* Number of colors, not a color itself */
};
/* PWM brightness vs. color, in the order of off, white */
static const uint8_t color_brightness[2] = {
- [LED_OFF] = 0,
- [LED_WHITE] = 100,
+ [LED_OFF] = 0,
+ [LED_WHITE] = 100,
};
void led_set_color_power(enum led_color color)
@@ -111,10 +109,10 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
} else if (led_id == EC_LED_ID_POWER_LED) {
if (brightness[EC_LED_COLOR_WHITE] != 0)
pwm_set_duty(PWM_CH_POWER_LED,
- color_brightness[LED_WHITE]);
+ color_brightness[LED_WHITE]);
else
pwm_set_duty(PWM_CH_POWER_LED,
- color_brightness[LED_OFF]);
+ color_brightness[LED_OFF]);
}
return EC_SUCCESS;
@@ -133,8 +131,8 @@ static void suspend_led_update_deferred(void)
if (ticks <= TICKS_STEP2_DIMMER) {
pwm_set_duty(PWM_CH_POWER_LED, ticks * LED_BAT_S3_PWM_RESCALE);
} else if (ticks <= TICKS_STEP3_OFF) {
- pwm_set_duty(PWM_CH_POWER_LED,
- (TICKS_STEP3_OFF - ticks) * LED_BAT_S3_PWM_RESCALE);
+ pwm_set_duty(PWM_CH_POWER_LED, (TICKS_STEP3_OFF - ticks) *
+ LED_BAT_S3_PWM_RESCALE);
} else {
ticks = TICKS_STEP1_BRIGHTER;
delay = LED_BAT_S3_OFF_TIME_MS * MSEC;
@@ -161,7 +159,6 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, suspend_led_deinit, HOOK_PRIO_DEFAULT);
static void led_set_battery(void)
{
static int battery_ticks;
- uint32_t chflags = charge_get_flags();
battery_ticks++;
@@ -177,11 +174,11 @@ static void led_set_battery(void)
led_set_color_battery(LED_WHITE);
break;
case PWR_STATE_IDLE: /* External power connected in IDLE */
- if (chflags & CHARGE_FLAG_FORCE_IDLE)
- led_set_color_battery(
- (battery_ticks & 0x4) ? LED_AMBER : LED_OFF);
- else
- led_set_color_battery(LED_WHITE);
+ led_set_color_battery(LED_WHITE);
+ break;
+ case PWR_STATE_FORCED_IDLE:
+ led_set_color_battery((battery_ticks & 0x4) ? LED_AMBER :
+ LED_OFF);
break;
default:
/* Other states don't alter LED behavior */
@@ -204,9 +201,10 @@ static void led_set_power(void)
power_ticks = 0;
while (blink_ticks < LED_PWR_TICKS_PER_CYCLE) {
- led_set_color_power(
- (power_ticks % LED_TOTAL_TICKS) < LED_ON_TICKS ?
- LED_WHITE : LED_OFF);
+ led_set_color_power((power_ticks % LED_TOTAL_TICKS) <
+ LED_ON_TICKS ?
+ LED_WHITE :
+ LED_OFF);
previous_state_suspend = 1;
return;
diff --git a/board/morphius/thermal.c b/board/morphius/thermal.c
index a51dee7c8b..2ffc2d105b 100644
--- a/board/morphius/thermal.c
+++ b/board/morphius/thermal.c
@@ -1,8 +1,9 @@
-/* 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.
*/
+#include "builtin/assert.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -20,7 +21,7 @@
/* 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 {
/*
@@ -44,316 +45,315 @@ static const struct fan_step *fan_step_table;
static const struct fan_step fan1_table_clamshell[] = {
{
/* level 0 */
- .on = {-1, -1, -1, -1},
- .off = {-1, -1, -1, -1},
- .rpm = {0},
+ .on = { -1, -1, -1, -1 },
+ .off = { -1, -1, -1, -1 },
+ .rpm = { 0 },
},
{
/* level 1 */
- .on = {-1, -1, 40, -1},
- .off = {-1, -1, 31, -1},
- .rpm = {1900},
+ .on = { -1, -1, 40, -1 },
+ .off = { -1, -1, 31, -1 },
+ .rpm = { 1900 },
},
{
/* level 2 */
- .on = {-1, -1, 45, -1},
- .off = {-1, -1, 43, -1},
- .rpm = {2900},
+ .on = { -1, -1, 45, -1 },
+ .off = { -1, -1, 43, -1 },
+ .rpm = { 2900 },
},
{
/* level 3 */
- .on = {-1, -1, 48, -1},
- .off = {-1, -1, 46, -1},
- .rpm = {3200},
+ .on = { -1, -1, 48, -1 },
+ .off = { -1, -1, 46, -1 },
+ .rpm = { 3200 },
},
{
/* level 4 */
- .on = {-1, -1, 51, -1},
- .off = {-1, -1, 49, -1},
- .rpm = {3550},
+ .on = { -1, -1, 51, -1 },
+ .off = { -1, -1, 49, -1 },
+ .rpm = { 3550 },
},
{
/* level 5 */
- .on = {-1, -1, 54, -1},
- .off = {-1, -1, 52, -1},
- .rpm = {3950},
+ .on = { -1, -1, 54, -1 },
+ .off = { -1, -1, 52, -1 },
+ .rpm = { 3950 },
},
{
/* level 6 */
- .on = {-1, -1, 57, -1},
- .off = {-1, -1, 55, -1},
- .rpm = {4250},
+ .on = { -1, -1, 57, -1 },
+ .off = { -1, -1, 55, -1 },
+ .rpm = { 4250 },
},
{
/* level 7 */
- .on = {-1, -1, 60, -1},
- .off = {-1, -1, 58, -1},
- .rpm = {4650},
+ .on = { -1, -1, 60, -1 },
+ .off = { -1, -1, 58, -1 },
+ .rpm = { 4650 },
},
};
static const struct fan_step fan1_table_tablet[] = {
{
/* level 0 */
- .on = {-1, -1, -1, -1},
- .off = {-1, -1, -1, -1},
- .rpm = {0},
+ .on = { -1, -1, -1, -1 },
+ .off = { -1, -1, -1, -1 },
+ .rpm = { 0 },
},
{
/* level 1 */
- .on = {-1, -1, 41, -1},
- .off = {-1, -1, 31, -1},
- .rpm = {2100},
+ .on = { -1, -1, 41, -1 },
+ .off = { -1, -1, 31, -1 },
+ .rpm = { 2100 },
},
{
/* level 2 */
- .on = {-1, -1, 50, -1},
- .off = {-1, -1, 48, -1},
- .rpm = {2600},
+ .on = { -1, -1, 50, -1 },
+ .off = { -1, -1, 48, -1 },
+ .rpm = { 2600 },
},
{
/* level 3 */
- .on = {-1, -1, 54, -1},
- .off = {-1, -1, 52, -1},
- .rpm = {2800},
+ .on = { -1, -1, 54, -1 },
+ .off = { -1, -1, 52, -1 },
+ .rpm = { 2800 },
},
{
/* level 4 */
- .on = {-1, -1, 57, -1},
- .off = {-1, -1, 55, -1},
- .rpm = {3300},
+ .on = { -1, -1, 57, -1 },
+ .off = { -1, -1, 55, -1 },
+ .rpm = { 3300 },
},
{
/* level 5 */
- .on = {-1, -1, 60, -1},
- .off = {-1, -1, 58, -1},
- .rpm = {3800},
+ .on = { -1, -1, 60, -1 },
+ .off = { -1, -1, 58, -1 },
+ .rpm = { 3800 },
},
{
/* level 6 */
- .on = {-1, -1, 72, -1},
- .off = {-1, -1, 69, -1},
- .rpm = {4000},
+ .on = { -1, -1, 72, -1 },
+ .off = { -1, -1, 69, -1 },
+ .rpm = { 4000 },
},
{
/* level 7 */
- .on = {-1, -1, 74, -1},
- .off = {-1, -1, 73, -1},
- .rpm = {4300},
+ .on = { -1, -1, 74, -1 },
+ .off = { -1, -1, 73, -1 },
+ .rpm = { 4300 },
},
};
static const struct fan_step fan1_table_stand[] = {
{
/* level 0 */
- .on = {-1, -1, -1, -1},
- .off = {-1, -1, -1, -1},
- .rpm = {0},
+ .on = { -1, -1, -1, -1 },
+ .off = { -1, -1, -1, -1 },
+ .rpm = { 0 },
},
{
/* level 1 */
- .on = {-1, -1, 34, -1},
- .off = {-1, -1, 31, -1},
- .rpm = {1850},
+ .on = { -1, -1, 34, -1 },
+ .off = { -1, -1, 31, -1 },
+ .rpm = { 1850 },
},
{
/* level 2 */
- .on = {-1, -1, 42, -1},
- .off = {-1, -1, 39, -1},
- .rpm = {2550},
+ .on = { -1, -1, 42, -1 },
+ .off = { -1, -1, 39, -1 },
+ .rpm = { 2550 },
},
{
/* level 3 */
- .on = {-1, -1, 49, -1},
- .off = {-1, -1, 48, -1},
- .rpm = {2900},
+ .on = { -1, -1, 49, -1 },
+ .off = { -1, -1, 48, -1 },
+ .rpm = { 2900 },
},
{
/* level 4 */
- .on = {-1, -1, 51, -1},
- .off = {-1, -1, 50, -1},
- .rpm = {3350},
+ .on = { -1, -1, 51, -1 },
+ .off = { -1, -1, 50, -1 },
+ .rpm = { 3350 },
},
{
/* level 5 */
- .on = {-1, -1, 53, -1},
- .off = {-1, -1, 52, -1},
- .rpm = {3700},
+ .on = { -1, -1, 53, -1 },
+ .off = { -1, -1, 52, -1 },
+ .rpm = { 3700 },
},
{
/* level 6 */
- .on = {-1, -1, 55, -1},
- .off = {-1, -1, 54, -1},
- .rpm = {3900},
+ .on = { -1, -1, 55, -1 },
+ .off = { -1, -1, 54, -1 },
+ .rpm = { 3900 },
},
{
/* level 7 */
- .on = {-1, -1, 57, -1},
- .off = {-1, -1, 56, -1},
- .rpm = {4250},
+ .on = { -1, -1, 57, -1 },
+ .off = { -1, -1, 56, -1 },
+ .rpm = { 4250 },
},
};
static const struct fan_step fan0_table_clamshell[] = {
{
/* level 0 */
- .on = {-1, -1, -1, -1},
- .off = {-1, -1, -1, -1},
- .rpm = {0},
+ .on = { -1, -1, -1, -1 },
+ .off = { -1, -1, -1, -1 },
+ .rpm = { 0 },
},
{
/* level 1 */
- .on = {-1, -1, 41, -1},
- .off = {-1, -1, 31, -1},
- .rpm = {2350},
+ .on = { -1, -1, 41, -1 },
+ .off = { -1, -1, 31, -1 },
+ .rpm = { 2350 },
},
{
/* level 2 */
- .on = {-1, -1, 44, -1},
- .off = {-1, -1, 42, -1},
- .rpm = {3300},
+ .on = { -1, -1, 44, -1 },
+ .off = { -1, -1, 42, -1 },
+ .rpm = { 3300 },
},
{
/* level 3 */
- .on = {-1, -1, 47, -1},
- .off = {-1, -1, 45, -1},
- .rpm = {3600},
+ .on = { -1, -1, 47, -1 },
+ .off = { -1, -1, 45, -1 },
+ .rpm = { 3600 },
},
{
/* level 4 */
- .on = {-1, -1, 50, -1},
- .off = {-1, -1, 48, -1},
- .rpm = {4050},
+ .on = { -1, -1, 50, -1 },
+ .off = { -1, -1, 48, -1 },
+ .rpm = { 4050 },
},
{
/* level 5 */
- .on = {-1, -1, 53, -1},
- .off = {-1, -1, 51, -1},
- .rpm = {4450},
+ .on = { -1, -1, 53, -1 },
+ .off = { -1, -1, 51, -1 },
+ .rpm = { 4450 },
},
{
/* level 6 */
- .on = {-1, -1, 56, -1},
- .off = {-1, -1, 54, -1},
- .rpm = {4750},
+ .on = { -1, -1, 56, -1 },
+ .off = { -1, -1, 54, -1 },
+ .rpm = { 4750 },
},
{
/* level 7 */
- .on = {-1, -1, 59, -1},
- .off = {-1, -1, 57, -1},
- .rpm = {5150},
+ .on = { -1, -1, 59, -1 },
+ .off = { -1, -1, 57, -1 },
+ .rpm = { 5150 },
},
};
static const struct fan_step fan0_table_tablet[] = {
{
/* level 0 */
- .on = {-1, -1, -1, -1},
- .off = {-1, -1, -1, -1},
- .rpm = {0},
+ .on = { -1, -1, -1, -1 },
+ .off = { -1, -1, -1, -1 },
+ .rpm = { 0 },
},
{
/* level 1 */
- .on = {-1, -1, 41, -1},
- .off = {-1, -1, 31, -1},
- .rpm = {2250},
+ .on = { -1, -1, 41, -1 },
+ .off = { -1, -1, 31, -1 },
+ .rpm = { 2250 },
},
{
/* level 2 */
- .on = {-1, -1, 50, -1},
- .off = {-1, -1, 48, -1},
- .rpm = {2850},
+ .on = { -1, -1, 50, -1 },
+ .off = { -1, -1, 48, -1 },
+ .rpm = { 2850 },
},
{
/* level 3 */
- .on = {-1, -1, 54, -1},
- .off = {-1, -1, 51, -1},
- .rpm = {3100},
+ .on = { -1, -1, 54, -1 },
+ .off = { -1, -1, 51, -1 },
+ .rpm = { 3100 },
},
{
/* level 4 */
- .on = {-1, -1, 57, -1},
- .off = {-1, -1, 55, -1},
- .rpm = {3500},
+ .on = { -1, -1, 57, -1 },
+ .off = { -1, -1, 55, -1 },
+ .rpm = { 3500 },
},
{
/* level 5 */
- .on = {-1, -1, 60, -1},
- .off = {-1, -1, 58, -1},
- .rpm = {3900},
+ .on = { -1, -1, 60, -1 },
+ .off = { -1, -1, 58, -1 },
+ .rpm = { 3900 },
},
{
/* level 6 */
- .on = {-1, -1, 72, -1},
- .off = {-1, -1, 69, -1},
- .rpm = {4150},
+ .on = { -1, -1, 72, -1 },
+ .off = { -1, -1, 69, -1 },
+ .rpm = { 4150 },
},
{
/* level 7 */
- .on = {-1, -1, 74, -1},
- .off = {-1, -1, 73, -1},
- .rpm = {4400},
+ .on = { -1, -1, 74, -1 },
+ .off = { -1, -1, 73, -1 },
+ .rpm = { 4400 },
},
};
static const struct fan_step fan0_table_stand[] = {
{
/* level 0 */
- .on = {-1, -1, -1, -1},
- .off = {-1, -1, -1, -1},
- .rpm = {0},
+ .on = { -1, -1, -1, -1 },
+ .off = { -1, -1, -1, -1 },
+ .rpm = { 0 },
},
{
/* level 1 */
- .on = {-1, -1, 34, -1},
- .off = {-1, -1, 31, -1},
- .rpm = {2250},
+ .on = { -1, -1, 34, -1 },
+ .off = { -1, -1, 31, -1 },
+ .rpm = { 2250 },
},
{
/* level 2 */
- .on = {-1, -1, 42, -1},
- .off = {-1, -1, 39, -1},
- .rpm = {2800},
+ .on = { -1, -1, 42, -1 },
+ .off = { -1, -1, 39, -1 },
+ .rpm = { 2800 },
},
{
/* level 3 */
- .on = {-1, -1, 49, -1},
- .off = {-1, -1, 48, -1},
- .rpm = {3150},
+ .on = { -1, -1, 49, -1 },
+ .off = { -1, -1, 48, -1 },
+ .rpm = { 3150 },
},
{
/* level 4 */
- .on = {-1, -1, 51, -1},
- .off = {-1, -1, 50, -1},
- .rpm = {3550},
+ .on = { -1, -1, 51, -1 },
+ .off = { -1, -1, 50, -1 },
+ .rpm = { 3550 },
},
{
/* level 5 */
- .on = {-1, -1, 53, -1},
- .off = {-1, -1, 52, -1},
- .rpm = {3900},
+ .on = { -1, -1, 53, -1 },
+ .off = { -1, -1, 52, -1 },
+ .rpm = { 3900 },
},
{
/* level 6 */
- .on = {-1, -1, 55, -1},
- .off = {-1, -1, 54, -1},
- .rpm = {4150},
+ .on = { -1, -1, 55, -1 },
+ .off = { -1, -1, 54, -1 },
+ .rpm = { 4150 },
},
{
/* level 7 */
- .on = {-1, -1, 57, -1},
- .off = {-1, -1, 56, -1},
- .rpm = {4400},
+ .on = { -1, -1, 57, -1 },
+ .off = { -1, -1, 56, -1 },
+ .rpm = { 4400 },
},
};
#define NUM_FAN_LEVELS ARRAY_SIZE(fan1_table_clamshell)
-#define lid_angle_tablet 340
+#define lid_angle_tablet 340
static int throttle_on;
-BUILD_ASSERT(ARRAY_SIZE(fan1_table_clamshell) ==
- ARRAY_SIZE(fan1_table_tablet));
+BUILD_ASSERT(ARRAY_SIZE(fan1_table_clamshell) == ARRAY_SIZE(fan1_table_tablet));
#define average_time 60
int fan_table_to_rpm(int fan, int *temp)
@@ -404,7 +404,7 @@ int fan_table_to_rpm(int fan, int *temp)
for (j = 0; j < average_time; j++)
avg_sum = avg_sum + avg_calc_tmp[TEMP_SENSOR_CPU][j];
- avg_tmp[TEMP_SENSOR_CPU] = avg_sum/average_time;
+ avg_tmp[TEMP_SENSOR_CPU] = avg_sum / average_time;
/*
* Compare the current and previous temperature, we have
@@ -416,10 +416,10 @@ int fan_table_to_rpm(int fan, int *temp)
if (avg_tmp[TEMP_SENSOR_CPU] < prev_tmp[TEMP_SENSOR_CPU]) {
for (i = current_level; i >= 0; i--) {
if (avg_tmp[TEMP_SENSOR_CPU] <
- fan_step_table[i].off[TEMP_SENSOR_CPU]) {
- /*
- * fan step down debounce
- */
+ fan_step_table[i].off[TEMP_SENSOR_CPU]) {
+ /*
+ * fan step down debounce
+ */
if (fan_down_count < 10) {
fan_down_count++;
fan_up_count = 0;
@@ -434,12 +434,12 @@ int fan_table_to_rpm(int fan, int *temp)
break;
}
} else if (avg_tmp[TEMP_SENSOR_CPU] > prev_tmp[TEMP_SENSOR_CPU]) {
- for (i = current_level+1; i < NUM_FAN_LEVELS; i++) {
+ for (i = current_level + 1; i < NUM_FAN_LEVELS; i++) {
if ((avg_tmp[TEMP_SENSOR_CPU] >
- fan_step_table[i].on[TEMP_SENSOR_CPU])) {
- /*
- * fan step up debounce
- */
+ fan_step_table[i].on[TEMP_SENSOR_CPU])) {
+ /*
+ * fan step up debounce
+ */
if (fan_up_count < 10) {
fan_up_count++;
fan_down_count = 0;
@@ -499,10 +499,8 @@ void thermal_protect(void)
int rv1, rv2;
int thermal_sensor1, thermal_sensor2;
- rv1 = temp_sensor_read(TEMP_SENSOR_5V_REGULATOR,
- &thermal_sensor1);
- rv2 = temp_sensor_read(TEMP_SENSOR_CPU,
- &thermal_sensor2);
+ rv1 = temp_sensor_read(TEMP_SENSOR_5V_REGULATOR, &thermal_sensor1);
+ rv2 = temp_sensor_read(TEMP_SENSOR_CPU, &thermal_sensor2);
if (rv2 == EC_SUCCESS) {
if ((!lid_is_open()) && (!extpower_is_present())) {
@@ -523,8 +521,8 @@ void thermal_protect(void)
}
if (rv1 == EC_SUCCESS) {
- if ((!lid_is_open()) && (!extpower_is_present())
- && thermal_sensor1 > C_TO_K(51))
+ if ((!lid_is_open()) && (!extpower_is_present()) &&
+ thermal_sensor1 > C_TO_K(51))
chipset_force_shutdown(CHIPSET_SHUTDOWN_THERMAL);
}
}