summaryrefslogtreecommitdiff
path: root/board/rammus/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/rammus/board.c')
-rw-r--r--board/rammus/board.c168
1 files changed, 79 insertions, 89 deletions
diff --git a/board/rammus/board.c b/board/rammus/board.c
index a27828694d..8cbc6c6856 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -1,4 +1,4 @@
-/* Copyright 2018 The Chromium OS Authors. All rights reserved.
+/* Copyright 2018 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -39,6 +39,7 @@
#include "math_util.h"
#include "motion_lid.h"
#include "motion_sense.h"
+#include "panic.h"
#include "pi3usb9281.h"
#include "power.h"
#include "power_button.h"
@@ -59,11 +60,11 @@
#include "util.h"
#include "espi.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)
-#define USB_PD_PORT_PS8751 1
-#define USB_PD_PORT_ANX7447 0
+#define USB_PD_PORT_PS8751 1
+#define USB_PD_PORT_ANX7447 0
static void tcpc_alert_event(enum gpio_signal signal)
{
@@ -130,53 +131,44 @@ const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
/* ADC channels */
const struct adc_t adc_channels[] = {
/* Vbus sensing (10x voltage divider). */
- [ADC_VBUS] = {"VBUS", NPCX_ADC_CH2, ADC_MAX_VOLT*10, ADC_READ_MAX+1, 0},
+ [ADC_VBUS] = { "VBUS", NPCX_ADC_CH2, ADC_MAX_VOLT * 10,
+ ADC_READ_MAX + 1, 0 },
/*
* Adapter current output or battery charging/discharging current (uV)
* 18x amplification on charger side.
*/
- [ADC_AMON_BMON] = {"AMON_BMON", NPCX_ADC_CH1, ADC_MAX_VOLT*1000/18,
- ADC_READ_MAX+1, 0},
+ [ADC_AMON_BMON] = { "AMON_BMON", NPCX_ADC_CH1, ADC_MAX_VOLT * 1000 / 18,
+ ADC_READ_MAX + 1, 0 },
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
/* I2C port map */
-const struct i2c_port_t i2c_ports[] = {
- {
- .name = "i2c_0_0",
- .port = NPCX_I2C_PORT0_0,
- .kbps = 400,
- .scl = GPIO_I2C0_0_SCL,
- .sda = GPIO_I2C0_0_SDA
- },
- {
- .name = "i2c_0_1",
- .port = NPCX_I2C_PORT0_1,
- .kbps = 400,
- .scl = GPIO_I2C0_1_SCL,
- .sda = GPIO_I2C0_1_SDA
- },
- {
- .name = "i2c_1",
- .port = NPCX_I2C_PORT1,
- .kbps = 100,
- .scl = GPIO_I2C1_SCL,
- .sda = GPIO_I2C1_SDA
- },
- {
- .name = "i2c_2",
- .port = NPCX_I2C_PORT2,
- .kbps = 400,
- .scl = GPIO_I2C2_SCL,
- .sda = GPIO_I2C2_SDA
- },
- {
- .name = "i2c_3",
- .port = NPCX_I2C_PORT3,
- .kbps = 400,
- .scl = GPIO_I2C3_SCL,
- .sda = GPIO_I2C3_SDA
- },
+const struct i2c_port_t i2c_ports[] = {
+ { .name = "i2c_0_0",
+ .port = NPCX_I2C_PORT0_0,
+ .kbps = 400,
+ .scl = GPIO_I2C0_0_SCL,
+ .sda = GPIO_I2C0_0_SDA },
+ { .name = "i2c_0_1",
+ .port = NPCX_I2C_PORT0_1,
+ .kbps = 400,
+ .scl = GPIO_I2C0_1_SCL,
+ .sda = GPIO_I2C0_1_SDA },
+ { .name = "i2c_1",
+ .port = NPCX_I2C_PORT1,
+ .kbps = 100,
+ .scl = GPIO_I2C1_SCL,
+ .sda = GPIO_I2C1_SDA },
+ { .name = "i2c_2",
+ .port = NPCX_I2C_PORT2,
+ .kbps = 400,
+ .scl = GPIO_I2C2_SCL,
+ .sda = GPIO_I2C2_SDA },
+ { .name = "i2c_3",
+ .port = NPCX_I2C_PORT3,
+ .kbps = 400,
+ .scl = GPIO_I2C3_SCL,
+ .sda = GPIO_I2C3_SDA },
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
@@ -210,16 +202,20 @@ struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
[USB_PD_PORT_PS8751] = {
- .usb_port = USB_PD_PORT_PS8751,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ .mux = &(const struct usb_mux) {
+ .usb_port = USB_PD_PORT_PS8751,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ },
},
[USB_PD_PORT_ANX7447] = {
- .usb_port = USB_PD_PORT_ANX7447,
- .driver = &anx7447_usb_mux_driver,
- .hpd_update = &anx7447_tcpc_update_hpd_status,
+ .mux = &(const struct usb_mux) {
+ .usb_port = USB_PD_PORT_ANX7447,
+ .driver = &anx7447_usb_mux_driver,
+ .hpd_update = &anx7447_tcpc_update_hpd_status,
+ },
}
};
@@ -262,7 +258,7 @@ static void ps8751_i2c_remap(void)
uint32_t board_version;
if (cbi_get_board_version(&board_version) != EC_SUCCESS ||
- board_version > 1)
+ board_version > 1)
return;
/*
* Due to b/118063849, we separate the ps8751 and anx3447 to
@@ -293,9 +289,9 @@ void board_tcpc_init(void)
*/
for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
-DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
+DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
uint16_t tcpc_get_alert_status(void)
{
@@ -315,17 +311,17 @@ uint16_t tcpc_get_alert_status(void)
}
const struct temp_sensor_t temp_sensors[] = {
- {"Battery", TEMP_SENSOR_TYPE_BATTERY, charge_get_battery_temp, 0},
+ { "Battery", TEMP_SENSOR_TYPE_BATTERY, charge_get_battery_temp, 0 },
/* These BD99992GW temp sensors are only readable in S0 */
- {"Ambient", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
- BD99992GW_ADC_CHANNEL_SYSTHERM0},
- {"Charger", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
- BD99992GW_ADC_CHANNEL_SYSTHERM1},
- {"DRAM", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
- BD99992GW_ADC_CHANNEL_SYSTHERM2},
- {"eMMC", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
- BD99992GW_ADC_CHANNEL_SYSTHERM3},
+ { "Ambient", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
+ BD99992GW_ADC_CHANNEL_SYSTHERM0 },
+ { "Charger", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
+ BD99992GW_ADC_CHANNEL_SYSTHERM1 },
+ { "DRAM", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
+ BD99992GW_ADC_CHANNEL_SYSTHERM2 },
+ { "eMMC", TEMP_SENSOR_TYPE_BOARD, bd99992gw_get_val,
+ BD99992GW_ADC_CHANNEL_SYSTHERM3 },
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
@@ -341,8 +337,8 @@ static void board_report_pmic_fault(const char *str)
uint32_t info;
/* RESETIRQ1 -- Bit 4: VRFAULT */
- if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x8, &vrfault)
- != EC_SUCCESS)
+ if (i2c_read8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x8, &vrfault) !=
+ EC_SUCCESS)
return;
if (!(vrfault & BIT(4)))
@@ -433,8 +429,7 @@ static void board_pmic_enable_slp_s0_vr_decay(void)
i2c_write8(I2C_PORT_PMIC, I2C_ADDR_BD99992_FLAGS, 0x38, 0x7a);
}
-__override void power_board_handle_host_sleep_event(
- enum host_sleep_event state)
+__override void power_board_handle_host_sleep_event(enum host_sleep_event state)
{
if (state == HOST_SLEEP_EVENT_S0IX_SUSPEND)
board_pmic_enable_slp_s0_vr_decay();
@@ -508,7 +503,7 @@ static void usb_charge_mode_init(void)
* inhibit_charging_in_suspend.
*/
usb_charge_set_mode(0, CONFIG_USB_PORT_POWER_SMART_DEFAULT_MODE,
- USB_DISALLOW_SUSPEND_CHARGE);
+ USB_DISALLOW_SUSPEND_CHARGE);
}
DECLARE_HOOK(HOOK_INIT, usb_charge_mode_init, HOOK_PRIO_DEFAULT + 1);
@@ -552,10 +547,12 @@ int board_set_active_charge_port(int charge_port)
} else {
/* Make sure non-charging port is disabled */
gpio_set_level(charge_port ? GPIO_EN_USB_C0_CHARGE_EC_L :
- GPIO_EN_USB_C1_CHARGE_EC_L, 1);
+ GPIO_EN_USB_C1_CHARGE_EC_L,
+ 1);
/* Enable charging port */
gpio_set_level(charge_port ? GPIO_EN_USB_C1_CHARGE_EC_L :
- GPIO_EN_USB_C0_CHARGE_EC_L, 0);
+ GPIO_EN_USB_C0_CHARGE_EC_L,
+ 0);
}
return EC_SUCCESS;
@@ -569,8 +566,8 @@ int board_set_active_charge_port(int charge_port)
* @param charge_ma Desired charge limit (mA).
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
+ int charge_mv)
{
/*
* Limit the input current to 96% negotiated limit,
@@ -578,8 +575,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
*/
charge_ma = charge_ma * 96 / 100;
charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT),
- charge_mv);
+ MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
}
void board_hibernate(void)
@@ -625,23 +621,17 @@ static struct accelgyro_saved_data_t g_bma255_data;
static struct kionix_accel_data g_kx022_data;
/* Matrix to rotate accelrator into standard reference frame */
-const mat33_fp_t base_standard_ref = {
- { FLOAT_TO_FP(1), 0, 0 },
- { 0, FLOAT_TO_FP(-1), 0 },
- { 0, 0, FLOAT_TO_FP(-1) }
-};
+const mat33_fp_t base_standard_ref = { { FLOAT_TO_FP(1), 0, 0 },
+ { 0, FLOAT_TO_FP(-1), 0 },
+ { 0, 0, FLOAT_TO_FP(-1) } };
-const mat33_fp_t base_standard_ref_icm = {
- { 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_icm = { { 0, FLOAT_TO_FP(1), 0 },
+ { FLOAT_TO_FP(1), 0, 0 },
+ { 0, 0, FLOAT_TO_FP(-1) } };
-const mat33_fp_t lid_standard_ref = {
- { FLOAT_TO_FP(-1), 0, 0 },
- { 0, FLOAT_TO_FP(1), 0 },
- { 0, 0, FLOAT_TO_FP(-1) }
-};
+const mat33_fp_t lid_standard_ref = { { FLOAT_TO_FP(-1), 0, 0 },
+ { 0, FLOAT_TO_FP(1), 0 },
+ { 0, 0, FLOAT_TO_FP(-1) } };
struct motion_sensor_t base_accel_icm = {
.name = "Base Accel",