summaryrefslogtreecommitdiff
path: root/board/coral
diff options
context:
space:
mode:
Diffstat (limited to 'board/coral')
-rw-r--r--board/coral/battery.c41
-rw-r--r--board/coral/board.c215
-rw-r--r--board/coral/board.h61
-rw-r--r--board/coral/build.mk2
-rw-r--r--board/coral/ec.tasklist2
-rw-r--r--board/coral/gpio.inc2
-rw-r--r--board/coral/led.c88
-rw-r--r--board/coral/sku.h10
-rw-r--r--board/coral/usb_pd_policy.c13
9 files changed, 210 insertions, 224 deletions
diff --git a/board/coral/battery.c b/board/coral/battery.c
index 8dfb05d631..3b105c90ca 100644
--- a/board/coral/battery.c
+++ b/board/coral/battery.c
@@ -1,4 +1,4 @@
-/* Copyright 2017 The Chromium OS Authors. All rights reserved.
+/* Copyright 2017 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -19,7 +19,7 @@
#include "i2c.h"
#include "util.h"
-#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args)
/* Number of writes needed to invoke battery cutoff command */
#define SHIP_MODE_WRITES 2
@@ -412,7 +412,8 @@ BUILD_ASSERT(ARRAY_SIZE(info) == BATTERY_TYPE_COUNT);
static inline const struct board_batt_params *board_get_batt_params(void)
{
return &info[board_battery_type == BATTERY_TYPE_COUNT ?
- DEFAULT_BATTERY_TYPE : board_battery_type];
+ DEFAULT_BATTERY_TYPE :
+ board_battery_type];
}
/* Get type of the battery connected on the board */
@@ -424,14 +425,16 @@ static int board_get_battery_type(void)
if (!battery_manufacturer_name(manu_name, sizeof(manu_name))) {
for (i = 0; i < BATTERY_TYPE_COUNT; i++) {
if (!strcasecmp(manu_name,
- info[i].fuel_gauge.manuf_name)) {
+ info[i].fuel_gauge.manuf_name)) {
if (info[i].fuel_gauge.device_name == NULL) {
board_battery_type = i;
break;
- } else if (!battery_device_name(device_name,
- sizeof(device_name))) {
+ } else if (!battery_device_name(
+ device_name,
+ sizeof(device_name))) {
if (!strcasecmp(device_name,
- info[i].fuel_gauge.device_name)) {
+ info[i].fuel_gauge
+ .device_name)) {
board_battery_type = i;
break;
}
@@ -496,7 +499,7 @@ static int charger_should_discharge_on_ac(struct charge_state_data *curr)
/* Do not discharge on AC if the battery is still waking up */
if (!(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
- !(curr->batt.status & STATUS_FULLY_CHARGED))
+ !(curr->batt.status & STATUS_FULLY_CHARGED))
return 0;
/*
@@ -513,8 +516,8 @@ static int charger_should_discharge_on_ac(struct charge_state_data *curr)
* and suspend USB charging and DC/DC converter.
*/
if (!battery_is_cut_off() &&
- !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
- (curr->batt.status & STATUS_FULLY_CHARGED))
+ !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
+ (curr->batt.status & STATUS_FULLY_CHARGED))
return 1;
/*
@@ -548,13 +551,13 @@ enum battery_present battery_hw_present(void)
return gpio_get_level(GPIO_EC_BATT_PRES_L) ? BP_NO : BP_YES;
}
-
static int battery_init(void)
{
int batt_status;
- return battery_status(&batt_status) ? 0 :
- !!(batt_status & STATUS_INITIALIZED);
+ return battery_status(&batt_status) ?
+ 0 :
+ !!(batt_status & STATUS_INITIALIZED);
}
/* Allow booting now that the battery has woke up */
@@ -595,12 +598,13 @@ static int battery_check_disconnect(void)
/* Read the status of charge/discharge FETs */
if (info[board_battery_type].fuel_gauge.fet.mfgacc_support == 1) {
rv = sb_read_mfgacc(PARAM_OPERATION_STATUS,
- SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data));
+ SB_ALT_MANUFACTURER_ACCESS, data,
+ sizeof(data));
/* Get the lowest 16bits of the OperationStatus() data */
reg = data[2] | data[3] << 8;
} else
rv = sb_read(info[board_battery_type].fuel_gauge.fet.reg_addr,
- &reg);
+ &reg);
if (rv)
return BATTERY_DISCONNECT_ERROR;
@@ -650,7 +654,7 @@ enum battery_present battery_is_present(void)
* error due to a failed sb_read.
*/
battery_report_present_timer_started = 0;
- } else if (batt_pres == BP_YES && batt_pres_prev == BP_NO &&
+ } else if (batt_pres == BP_YES && batt_pres_prev == BP_NO &&
!battery_report_present_timer_started) {
/*
* Wait 1/2 second before reporting present if it was
@@ -674,11 +678,10 @@ int board_battery_initialized(void)
return battery_hw_present() == batt_pres_prev;
}
-
/* Customs options controllable by host command. */
#define PARAM_FASTCHARGE (CS_PARAM_CUSTOM_PROFILE_MIN + 0)
-#define PARAM_LEARN_MODE 0x10001
-#define PARAM_DISCONNECT_STATE 0x10002
+#define PARAM_LEARN_MODE 0x10001
+#define PARAM_DISCONNECT_STATE 0x10002
enum ec_status charger_profile_override_get_param(uint32_t param,
uint32_t *value)
diff --git a/board/coral/board.c b/board/coral/board.c
index 21729489bc..c63a2f6ddc 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -33,6 +33,7 @@
#include "math_util.h"
#include "motion_sense.h"
#include "motion_lid.h"
+#include "panic.h"
#include "power.h"
#include "power_button.h"
#include "pwm.h"
@@ -53,15 +54,15 @@
#include "usb_pd_tcpm.h"
#include "util.h"
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-#define IN_ALL_SYS_PG POWER_SIGNAL_MASK(X86_ALL_SYS_PG)
-#define IN_PGOOD_PP3300 POWER_SIGNAL_MASK(X86_PGOOD_PP3300)
-#define IN_PGOOD_PP5000 POWER_SIGNAL_MASK(X86_PGOOD_PP5000)
+#define IN_ALL_SYS_PG POWER_SIGNAL_MASK(X86_ALL_SYS_PG)
+#define IN_PGOOD_PP3300 POWER_SIGNAL_MASK(X86_PGOOD_PP3300)
+#define IN_PGOOD_PP5000 POWER_SIGNAL_MASK(X86_PGOOD_PP5000)
-#define USB_PD_PORT_ANX74XX 0
-#define USB_PD_PORT_PS8751 1
+#define USB_PD_PORT_ANX74XX 0
+#define USB_PD_PORT_PS8751 1
static int sku_id;
@@ -128,66 +129,51 @@ void tablet_mode_interrupt(enum gpio_signal signal)
/* ADC channels */
const struct adc_t adc_channels[] = {
/* Vfs = Vref = 2.816V, 10-bit unsigned reading */
- [ADC_TEMP_SENSOR_CHARGER] = {
- "CHARGER", NPCX_ADC_CH0, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0
- },
- [ADC_TEMP_SENSOR_AMB] = {
- "AMBIENT", NPCX_ADC_CH1, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0
- },
- [ADC_BOARD_ID] = {
- "BRD_ID", NPCX_ADC_CH2, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0
- },
- [ADC_BOARD_SKU_1] = {
- "BRD_SKU_1", NPCX_ADC_CH3, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0
- },
- [ADC_BOARD_SKU_0] = {
- "BRD_SKU_0", NPCX_ADC_CH4, ADC_MAX_VOLT, ADC_READ_MAX + 1, 0
- },
+ [ADC_TEMP_SENSOR_CHARGER] = { "CHARGER", NPCX_ADC_CH0, ADC_MAX_VOLT,
+ ADC_READ_MAX + 1, 0 },
+ [ADC_TEMP_SENSOR_AMB] = { "AMBIENT", NPCX_ADC_CH1, ADC_MAX_VOLT,
+ ADC_READ_MAX + 1, 0 },
+ [ADC_BOARD_ID] = { "BRD_ID", NPCX_ADC_CH2, ADC_MAX_VOLT,
+ ADC_READ_MAX + 1, 0 },
+ [ADC_BOARD_SKU_1] = { "BRD_SKU_1", NPCX_ADC_CH3, ADC_MAX_VOLT,
+ ADC_READ_MAX + 1, 0 },
+ [ADC_BOARD_SKU_0] = { "BRD_SKU_0", NPCX_ADC_CH4, ADC_MAX_VOLT,
+ ADC_READ_MAX + 1, 0 },
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
const struct pwm_t pwm_channels[] = {
- [PWM_CH_KBLIGHT] = { 4, PWM_CONFIG_DSLEEP, 100 },
+ [PWM_CH_KBLIGHT] = { 4, PWM_CONFIG_DSLEEP, 100 },
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-const struct i2c_port_t i2c_ports[] = {
- {
- .name = "tcpc0",
- .port = NPCX_I2C_PORT0_0,
- .kbps = 400,
- .scl = GPIO_EC_I2C_USB_C0_PD_SCL,
- .sda = GPIO_EC_I2C_USB_C0_PD_SDA
- },
- {
- .name = "tcpc1",
- .port = NPCX_I2C_PORT0_1,
- .kbps = 400,
- .scl = GPIO_EC_I2C_USB_C1_PD_SCL,
- .sda = GPIO_EC_I2C_USB_C1_PD_SDA
- },
- {
- .name = "accelgyro",
- .port = I2C_PORT_GYRO,
- .kbps = 400,
- .scl = GPIO_EC_I2C_GYRO_SCL,
- .sda = GPIO_EC_I2C_GYRO_SDA
- },
- {
- .name = "sensors",
- .port = NPCX_I2C_PORT2,
- .kbps = 400,
- .scl = GPIO_EC_I2C_SENSOR_SCL,
- .sda = GPIO_EC_I2C_SENSOR_SDA
- },
- {
- .name = "batt",
- .port = NPCX_I2C_PORT3,
- .kbps = 100,
- .scl = GPIO_EC_I2C_POWER_SCL,
- .sda = GPIO_EC_I2C_POWER_SDA
- },
+const struct i2c_port_t i2c_ports[] = {
+ { .name = "tcpc0",
+ .port = NPCX_I2C_PORT0_0,
+ .kbps = 400,
+ .scl = GPIO_EC_I2C_USB_C0_PD_SCL,
+ .sda = GPIO_EC_I2C_USB_C0_PD_SDA },
+ { .name = "tcpc1",
+ .port = NPCX_I2C_PORT0_1,
+ .kbps = 400,
+ .scl = GPIO_EC_I2C_USB_C1_PD_SCL,
+ .sda = GPIO_EC_I2C_USB_C1_PD_SDA },
+ { .name = "accelgyro",
+ .port = I2C_PORT_GYRO,
+ .kbps = 400,
+ .scl = GPIO_EC_I2C_GYRO_SCL,
+ .sda = GPIO_EC_I2C_GYRO_SDA },
+ { .name = "sensors",
+ .port = NPCX_I2C_PORT2,
+ .kbps = 400,
+ .scl = GPIO_EC_I2C_SENSOR_SCL,
+ .sda = GPIO_EC_I2C_SENSOR_SDA },
+ { .name = "batt",
+ .port = NPCX_I2C_PORT3,
+ .kbps = 100,
+ .scl = GPIO_EC_I2C_POWER_SCL,
+ .sda = GPIO_EC_I2C_POWER_SDA },
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
@@ -303,17 +289,21 @@ static int ps8751_tune_mux(const struct usb_mux *me)
return EC_SUCCESS;
}
-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_ANX74XX] = {
- .usb_port = USB_PD_PORT_ANX74XX,
- .driver = &anx74xx_tcpm_usb_mux_driver,
- .hpd_update = &anx74xx_tcpc_update_hpd_status,
+ .mux = &(const struct usb_mux) {
+ .usb_port = USB_PD_PORT_ANX74XX,
+ .driver = &anx74xx_tcpm_usb_mux_driver,
+ .hpd_update = &anx74xx_tcpc_update_hpd_status,
+ },
},
[USB_PD_PORT_PS8751] = {
- .usb_port = USB_PD_PORT_PS8751,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
- .board_init = &ps8751_tune_mux,
+ .mux = &(const struct usb_mux) {
+ .usb_port = USB_PD_PORT_PS8751,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ .board_init = &ps8751_tune_mux,
+ },
}
};
@@ -419,28 +409,28 @@ static void board_tcpc_init(void)
gpio_enable_interrupt(GPIO_USB_C0_CABLE_DET);
#endif
/*
- * Initialize HPD to low; after sysjump SOC needs to see
- * HPD pulse to enable video path
- */
+ * Initialize HPD to low; after sysjump SOC needs to see
+ * HPD pulse to enable video path
+ */
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_DEFAULT);
const struct temp_sensor_t temp_sensors[] = {
- [TEMP_SENSOR_BATTERY] = {.name = "Battery",
- .type = TEMP_SENSOR_TYPE_BATTERY,
- .read = charge_get_battery_temp,
- .idx = 0},
- [TEMP_SENSOR_AMBIENT] = {.name = "Ambient",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_51k1_47k_4050b,
- .idx = ADC_TEMP_SENSOR_AMB},
- [TEMP_SENSOR_CHARGER] = {.name = "Charger",
- .type = TEMP_SENSOR_TYPE_BOARD,
- .read = get_temp_3v3_13k7_47k_4050b,
- .idx = ADC_TEMP_SENSOR_CHARGER},
+ [TEMP_SENSOR_BATTERY] = { .name = "Battery",
+ .type = TEMP_SENSOR_TYPE_BATTERY,
+ .read = charge_get_battery_temp,
+ .idx = 0 },
+ [TEMP_SENSOR_AMBIENT] = { .name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_AMB },
+ [TEMP_SENSOR_CHARGER] = { .name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_13k7_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_CHARGER },
};
BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
@@ -564,8 +554,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)
{
/* Enable charging trigger by BC1.2 detection */
int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP ||
@@ -577,8 +567,8 @@ void board_set_charge_limit(int port, int supplier, int charge_ma,
return;
charge_ma = (charge_ma * 95) / 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);
}
/**
@@ -688,17 +678,17 @@ void board_hibernate_late(void)
int i;
const uint32_t hibernate_pins[][2] = {
/* Turn off LEDs in hibernate */
- {GPIO_BAT_LED_BLUE, GPIO_INPUT | GPIO_PULL_UP},
- {GPIO_BAT_LED_AMBER, GPIO_INPUT | GPIO_PULL_UP},
- {GPIO_LID_OPEN, GPIO_INT_RISING | GPIO_PULL_DOWN},
+ { GPIO_BAT_LED_BLUE, GPIO_INPUT | GPIO_PULL_UP },
+ { GPIO_BAT_LED_AMBER, GPIO_INPUT | GPIO_PULL_UP },
+ { GPIO_LID_OPEN, GPIO_INT_RISING | GPIO_PULL_DOWN },
/*
* BD99956 handles charge input automatically. We'll disable
* charge output in hibernate. Charger will assert ACOK_OD
* when VBUS or VCC are plugged in.
*/
- {GPIO_USB_C0_5V_EN, GPIO_INPUT | GPIO_PULL_DOWN},
- {GPIO_USB_C1_5V_EN, GPIO_INPUT | GPIO_PULL_DOWN},
+ { GPIO_USB_C0_5V_EN, GPIO_INPUT | GPIO_PULL_DOWN },
+ { GPIO_USB_C1_5V_EN, GPIO_INPUT | GPIO_PULL_DOWN },
};
/* Change GPIOs' state in hibernate for better power consumption */
@@ -725,17 +715,13 @@ static struct mutex g_lid_mutex;
static struct mutex g_base_mutex;
/* Matrix to rotate accelrator into standard reference frame */
-const 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 = { { 0, FLOAT_TO_FP(-1), 0 },
+ { FLOAT_TO_FP(1), 0, 0 },
+ { 0, 0, FLOAT_TO_FP(1) } };
-const mat33_fp_t mag_standard_ref = {
- { FLOAT_TO_FP(-1), 0, 0},
- { 0, FLOAT_TO_FP(1), 0},
- { 0, 0, FLOAT_TO_FP(-1)}
-};
+const mat33_fp_t mag_standard_ref = { { FLOAT_TO_FP(-1), 0, 0 },
+ { 0, FLOAT_TO_FP(1), 0 },
+ { 0, 0, FLOAT_TO_FP(-1) } };
/* sensor private data */
static struct kionix_accel_data g_kx022_data;
@@ -845,8 +831,8 @@ static void board_set_motion_sensor_count(uint8_t sku_id)
* sensor. If a new SKU id is used that is not in the table, then the
* number of motion sensors will remain as ARRAY_SIZE(motion_sensors).
*/
- motion_sensor_count = SKU_IS_CONVERTIBLE(sku_id) ?
- ARRAY_SIZE(motion_sensors) : 0;
+ motion_sensor_count =
+ SKU_IS_CONVERTIBLE(sku_id) ? ARRAY_SIZE(motion_sensors) : 0;
CPRINTS("Motion Sensor Count = %d", motion_sensor_count);
}
@@ -857,11 +843,11 @@ struct {
} const coral_board_versions[] = {
/* Vin = 3.3V, Ideal voltage, R2 values listed below */
/* R1 = 51.1 kOhm */
- { BOARD_VERSION_1, 200 }, /* 124 mV, 2.0 Kohm */
- { BOARD_VERSION_2, 366 }, /* 278 mV, 4.7 Kohm */
- { BOARD_VERSION_3, 550 }, /* 456 mV, 8.2 Kohm */
- { BOARD_VERSION_4, 752 }, /* 644 mV, 12.4 Kohm */
- { BOARD_VERSION_5, 927}, /* 860 mV, 18.0 Kohm */
+ { BOARD_VERSION_1, 200 }, /* 124 mV, 2.0 Kohm */
+ { BOARD_VERSION_2, 366 }, /* 278 mV, 4.7 Kohm */
+ { BOARD_VERSION_3, 550 }, /* 456 mV, 8.2 Kohm */
+ { BOARD_VERSION_4, 752 }, /* 644 mV, 12.4 Kohm */
+ { BOARD_VERSION_5, 927 }, /* 860 mV, 18.0 Kohm */
{ BOARD_VERSION_6, 1073 }, /* 993 mV, 22.0 Kohm */
{ BOARD_VERSION_7, 1235 }, /* 1152 mV, 27.4 Kohm */
{ BOARD_VERSION_8, 1386 }, /* 1318 mV, 34.0 Kohm */
@@ -948,15 +934,15 @@ static void print_form_factor_list(int low, int high)
if (high > 255)
high = 255;
for (id = low; id <= high; id++) {
- ccprintf("SKU ID %03d: %s\n", id, SKU_IS_CONVERTIBLE(id) ?
- "Convertible" : "Clamshell");
+ ccprintf("SKU ID %03d: %s\n", id,
+ SKU_IS_CONVERTIBLE(id) ? "Convertible" : "Clamshell");
/* Don't print too many lines at once */
if (!(++count % 5))
msleep(20);
}
}
-static int command_sku(int argc, char **argv)
+static int command_sku(int argc, const char **argv)
{
enum adc_channel chan;
@@ -999,8 +985,7 @@ static int command_sku(int argc, char **argv)
return EC_SUCCESS;
}
-DECLARE_CONSOLE_COMMAND(sku, command_sku,
- "<board|line0|line1|form [low high]>",
+DECLARE_CONSOLE_COMMAND(sku, command_sku, "<board|line0|line1|form [low high]>",
"Get board id, sku, form factor");
__override uint32_t board_get_sku_id(void)
diff --git a/board/coral/board.h b/board/coral/board.h
index 4a1709e7a9..bc6226152c 100644
--- a/board/coral/board.h
+++ b/board/coral/board.h
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -12,7 +12,7 @@
* By default, enable all console messages except Events:
* The sensor stack is generating a lot of activity.
*/
-#define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_EVENTS))
+#define CC_DEFAULT (CC_ALL & ~CC_MASK(CC_EVENTS))
#undef CONFIG_HOSTCMD_DEBUG_MODE
#define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF
@@ -23,14 +23,14 @@
#define CONFIG_CMD_ACCEL_INFO
#define CONFIG_CMD_BATT_MFG_ACCESS
#define CONFIG_CMD_CHARGER_ADC_AMON_BMON
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
#define BD9995X_IOUT_GAIN_SELECT \
- BD9995X_CMD_PMON_IOUT_CTRL_SET_IOUT_GAIN_SET_20V
+ BD9995X_CMD_PMON_IOUT_CTRL_SET_IOUT_GAIN_SET_20V
#define CONFIG_CHARGER_PSYS_READ
#define BD9995X_PSYS_GAIN_SELECT \
- BD9995X_CMD_PMON_IOUT_CTRL_SET_PMON_GAIN_SET_02UAW
+ BD9995X_CMD_PMON_IOUT_CTRL_SET_PMON_GAIN_SET_02UAW
#define CONFIG_CMD_I2C_STRESS_TEST
#define CONFIG_CMD_I2C_STRESS_TEST_ACCEL
@@ -44,7 +44,7 @@
#define CONFIG_PORT80_HISTORY_LEN 256
/* Battery */
-#define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION"
+#define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION"
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_BATTERY_LEVEL_NEAR_FULL 94
@@ -90,7 +90,7 @@
#define CONFIG_USB_PD_PORT_MAX_COUNT 2
#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
#define CONFIG_USB_PD_TCPC_LOW_POWER
-#define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */
+#define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */
#define CONFIG_USB_PD_TCPM_ANX3429
#define CONFIG_USB_PD_TCPM_PS8751
#define CONFIG_USB_PD_TCPM_TCPCI
@@ -117,11 +117,11 @@
/* EC */
#define CONFIG_ADC
#define CONFIG_EXTPOWER_GPIO
-#undef CONFIG_EXTPOWER_DEBOUNCE_MS
-#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
+#undef CONFIG_EXTPOWER_DEBOUNCE_MS
+#define CONFIG_EXTPOWER_DEBOUNCE_MS 1000
#define CONFIG_FPU
/* Region sizes are not a power of 2 so we can't use MPU */
-#undef CONFIG_MPU
+#undef CONFIG_MPU
#define CONFIG_HOSTCMD_FLASH_SPI_INFO
#define CONFIG_I2C
#define CONFIG_I2C_CONTROLLER
@@ -150,7 +150,7 @@
#define CONFIG_WIRELESS
#define CONFIG_WIRELESS_SUSPEND EC_WIRELESS_SWITCH_WLAN_POWER
#define CONFIG_WLAN_POWER_ACTIVE_LOW
-#define WIRELESS_GPIO_WLAN_POWER GPIO_WIRELESS_GPIO_WLAN_POWER
+#define WIRELESS_GPIO_WLAN_POWER GPIO_WIRELESS_GPIO_WLAN_POWER
#define CONFIG_PWR_STATE_DISCHARGE_FULL
/*
@@ -168,7 +168,7 @@
#define CONFIG_FLASH_SIZE_BYTES 524288
#define CONFIG_SPI_FLASH_REGS
-#define CONFIG_SPI_FLASH_W25Q40 /* FIXME: Should be GD25LQ40? */
+#define CONFIG_SPI_FLASH_W25Q40 /* FIXME: Should be GD25LQ40? */
/*
* Enable 1 slot of secure temporary storage to support
@@ -178,19 +178,19 @@
#define CONFIG_VSTORE_SLOT_COUNT 1
/* Optional feature - used by nuvoton */
-#define NPCX_UART_MODULE2 1 /* 0:GPIO10/11 1:GPIO64/65 as UART */
-#define NPCX_JTAG_MODULE2 0 /* 0:GPIO21/17/16/20 1:GPIOD5/E2/D4/E5 as JTAG*/
+#define NPCX_UART_MODULE2 1 /* 0:GPIO10/11 1:GPIO64/65 as UART */
+#define NPCX_JTAG_MODULE2 0 /* 0:GPIO21/17/16/20 1:GPIOD5/E2/D4/E5 as JTAG*/
/* FIXME(dhendrix): these pins are just normal GPIOs on Coral. Do we need
* to change some other setting to put them in GPIO mode? */
-#define NPCX_TACH_SEL2 0 /* 0:GPIO40/73 1:GPIO93/A6 as TACH */
+#define NPCX_TACH_SEL2 0 /* 0:GPIO40/73 1:GPIO93/A6 as TACH */
/* I2C ports */
-#define I2C_PORT_GYRO NPCX_I2C_PORT1
-#define I2C_PORT_LID_ACCEL NPCX_I2C_PORT2
-#define I2C_PORT_BATTERY NPCX_I2C_PORT3
-#define I2C_PORT_CHARGER NPCX_I2C_PORT3
+#define I2C_PORT_GYRO NPCX_I2C_PORT1
+#define I2C_PORT_LID_ACCEL NPCX_I2C_PORT2
+#define I2C_PORT_BATTERY NPCX_I2C_PORT3
+#define I2C_PORT_CHARGER NPCX_I2C_PORT3
/* Accelerometer and Gyroscope are the same device. */
-#define I2C_PORT_ACCEL I2C_PORT_GYRO
+#define I2C_PORT_ACCEL I2C_PORT_GYRO
/* Sensors */
#define CONFIG_MKBP_EVENT
@@ -213,7 +213,6 @@
/* Depends on how fast the AP boots and typical ODRs */
#define CONFIG_ACCEL_FIFO_THRES (CONFIG_ACCEL_FIFO_SIZE / 3)
-
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
@@ -221,11 +220,11 @@
/* ADC signal */
enum adc_channel {
- ADC_TEMP_SENSOR_CHARGER, /* ADC0 */
- ADC_TEMP_SENSOR_AMB, /* ADC1 */
- ADC_BOARD_ID, /* ADC2 */
- ADC_BOARD_SKU_1, /* ADC3 */
- ADC_BOARD_SKU_0, /* ADC4 */
+ ADC_TEMP_SENSOR_CHARGER, /* ADC0 */
+ ADC_TEMP_SENSOR_AMB, /* ADC1 */
+ ADC_BOARD_ID, /* ADC2 */
+ ADC_BOARD_SKU_1, /* ADC3 */
+ ADC_BOARD_SKU_0, /* ADC4 */
ADC_CH_COUNT
};
@@ -283,16 +282,16 @@ enum coral_board_version {
* delay to turn on the power supply max is ~16ms.
* delay to turn off the power supply max is about ~180ms.
*/
-#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
+#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
#define PD_POWER_SUPPLY_TURN_OFF_DELAY 250000 /* us */
/* delay to turn on/off vconn */
/* Define typical operating power and max power */
#define PD_OPERATING_POWER_MW 15000
-#define PD_MAX_POWER_MW 45000
-#define PD_MAX_CURRENT_MA 3000
-#define PD_MAX_VOLTAGE_MV 20000
+#define PD_MAX_POWER_MW 45000
+#define PD_MAX_CURRENT_MA 3000
+#define PD_MAX_VOLTAGE_MV 20000
/* Reset PD MCU */
void board_reset_pd_mcu(void);
diff --git a/board/coral/build.mk b/board/coral/build.mk
index 728d027803..470e439b13 100644
--- a/board/coral/build.mk
+++ b/board/coral/build.mk
@@ -1,5 +1,5 @@
# -*- makefile -*-
-# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Copyright 2015 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/coral/ec.tasklist b/board/coral/ec.tasklist
index eeebc0cc59..bc8668a1db 100644
--- a/board/coral/ec.tasklist
+++ b/board/coral/ec.tasklist
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 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/coral/gpio.inc b/board/coral/gpio.inc
index da15615c86..7f09fe0735 100644
--- a/board/coral/gpio.inc
+++ b/board/coral/gpio.inc
@@ -1,6 +1,6 @@
/* -*- mode:c -*-
*
- * Copyright 2016 The Chromium OS Authors. All rights reserved.
+ * Copyright 2016 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/coral/led.c b/board/coral/led.c
index 2a1e39946c..8af0f6f3e2 100644
--- a/board/coral/led.c
+++ b/board/coral/led.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -28,8 +28,7 @@
#define LED_POWER_ON_TICKS (LED_POWER_BLINK_ON_MSEC / HOOK_TICK_INTERVAL_MS)
#define LED_POWER_OFF_TICKS (LED_POWER_BLINK_OFF_MSEC / HOOK_TICK_INTERVAL_MS)
-const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_BATTERY_LED};
+const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED };
const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
@@ -37,18 +36,14 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
#define GPIO_LED_COLOR_2 GPIO_BAT_LED_BLUE
#define GPIO_LED_COLOR_3 GPIO_POW_LED
-enum led_phase {
- LED_PHASE_0,
- LED_PHASE_1,
- LED_NUM_PHASES
-};
+enum led_phase { LED_PHASE_0, LED_PHASE_1, LED_NUM_PHASES };
enum led_color {
LED_OFF,
LED_COLOR_1,
LED_COLOR_2,
LED_COLOR_BOTH,
- LED_COLOR_COUNT /* Number of colors, not a color itself */
+ LED_COLOR_COUNT /* Number of colors, not a color itself */
};
enum led_states {
@@ -85,37 +80,37 @@ struct led_info {
/* COLOR_1 = Amber, COLOR_2 = Blue */
static const struct led_descriptor led_default_state_table[][LED_NUM_PHASES] = {
- { {LED_COLOR_1, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_2, LED_INDEFINITE}, {LED_COLOR_1, LED_INDEFINITE} },
- { {LED_COLOR_2, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_2, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_1, 1 * LED_ONE_SEC }, {LED_OFF, 3 * LED_ONE_SEC} },
- { {LED_OFF, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_1, 1 * LED_ONE_SEC}, {LED_OFF, 1 * LED_ONE_SEC} },
- { {LED_COLOR_1, 2 * LED_ONE_SEC}, {LED_COLOR_2, 2 * LED_ONE_SEC} },
+ { { LED_COLOR_1, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_2, LED_INDEFINITE }, { LED_COLOR_1, LED_INDEFINITE } },
+ { { LED_COLOR_2, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_2, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_1, 1 * LED_ONE_SEC }, { LED_OFF, 3 * LED_ONE_SEC } },
+ { { LED_OFF, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_1, 1 * LED_ONE_SEC }, { LED_OFF, 1 * LED_ONE_SEC } },
+ { { LED_COLOR_1, 2 * LED_ONE_SEC }, { LED_COLOR_2, 2 * LED_ONE_SEC } },
};
/* COLOR_1 = Green, COLOR_2 = Red */
static const struct led_descriptor led_robo_state_table[][LED_NUM_PHASES] = {
- { {LED_COLOR_2, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_BOTH, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_1, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_OFF, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_OFF, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_OFF, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_2, 1 * LED_ONE_SEC}, {LED_OFF, 1 * LED_ONE_SEC} },
- { {LED_COLOR_2, 2 * LED_ONE_SEC}, {LED_COLOR_1, 2 * LED_ONE_SEC} },
+ { { LED_COLOR_2, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_BOTH, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_1, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_OFF, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_OFF, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_OFF, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_2, 1 * LED_ONE_SEC }, { LED_OFF, 1 * LED_ONE_SEC } },
+ { { LED_COLOR_2, 2 * LED_ONE_SEC }, { LED_COLOR_1, 2 * LED_ONE_SEC } },
};
static const struct led_descriptor led_nasher_state_table[][LED_NUM_PHASES] = {
- { {LED_COLOR_1, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_2, LED_INDEFINITE}, {LED_COLOR_1, LED_INDEFINITE} },
- { {LED_COLOR_2, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_2, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_2, 1 * LED_ONE_SEC}, {LED_OFF, 1 * LED_ONE_SEC} },
- { {LED_OFF, LED_INDEFINITE}, {LED_OFF, LED_INDEFINITE} },
- { {LED_COLOR_1, 1 * LED_ONE_SEC}, {LED_OFF, 1 * LED_ONE_SEC} },
- { {LED_COLOR_1, 2 * LED_ONE_SEC}, {LED_COLOR_2, 2 * LED_ONE_SEC} },
+ { { LED_COLOR_1, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_2, LED_INDEFINITE }, { LED_COLOR_1, LED_INDEFINITE } },
+ { { LED_COLOR_2, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_2, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_2, 1 * LED_ONE_SEC }, { LED_OFF, 1 * LED_ONE_SEC } },
+ { { LED_OFF, LED_INDEFINITE }, { LED_OFF, LED_INDEFINITE } },
+ { { LED_COLOR_1, 1 * LED_ONE_SEC }, { LED_OFF, 1 * LED_ONE_SEC } },
+ { { LED_COLOR_1, 2 * LED_ONE_SEC }, { LED_COLOR_2, 2 * LED_ONE_SEC } },
};
static struct led_info led;
@@ -176,7 +171,7 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
static enum led_states led_get_state(void)
{
- int charge_lvl;
+ int charge_lvl;
enum led_states new_state = LED_NUM_STATES;
switch (charge_get_state()) {
@@ -185,7 +180,8 @@ static enum led_states led_get_state(void)
charge_lvl = charge_get_percent();
/* Determine which charge state to use */
new_state = charge_lvl <= led.charge_lvl_1 ?
- STATE_CHARGING_LVL_1 : STATE_CHARGING_LVL_2;
+ STATE_CHARGING_LVL_1 :
+ STATE_CHARGING_LVL_2;
break;
case PWR_STATE_DISCHARGE_FULL:
if (extpower_is_present()) {
@@ -208,10 +204,10 @@ static enum led_states led_get_state(void)
new_state = STATE_CHARGING_LVL_3;
break;
case PWR_STATE_IDLE: /* External power connected in IDLE */
- if (charge_get_flags() & CHARGE_FLAG_FORCE_IDLE)
- new_state = STATE_FACTORY_TEST;
- else
- new_state = STATE_DISCHARGE_S0;
+ new_state = STATE_DISCHARGE_S0;
+ break;
+ case PWR_STATE_FORCED_IDLE:
+ new_state = STATE_FACTORY_TEST;
break;
default:
/* Other states don't alter LED behavior */
@@ -248,11 +244,13 @@ static void led_update_battery(void)
int period;
period = led.state_table[led.state][LED_PHASE_0].time +
- led.state_table[led.state][LED_PHASE_1].time;
+ led.state_table[led.state][LED_PHASE_1].time;
if (period)
- phase = ticks % period <
- led.state_table[led.state][LED_PHASE_0].time ?
- 0 : 1;
+ phase = ticks % period < led.state_table[led.state]
+ [LED_PHASE_0]
+ .time ?
+ 0 :
+ 1;
}
/* Set the color for the given state and phase */
@@ -278,8 +276,8 @@ static void led_robo_update_power(void)
* power LED is off for 600 msec, on for 3 seconds.
*/
period = LED_POWER_ON_TICKS + LED_POWER_OFF_TICKS;
- level = ticks % period < LED_POWER_OFF_TICKS ?
- LED_OFF_LVL : LED_ON_LVL;
+ level = ticks % period < LED_POWER_OFF_TICKS ? LED_OFF_LVL :
+ LED_ON_LVL;
ticks++;
} else {
level = LED_OFF_LVL;
diff --git a/board/coral/sku.h b/board/coral/sku.h
index 4588932377..c12777a2f7 100644
--- a/board/coral/sku.h
+++ b/board/coral/sku.h
@@ -1,4 +1,4 @@
-/* Copyright 2017 The Chromium OS Authors. All rights reserved.
+/* Copyright 2017 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -8,7 +8,7 @@
#ifndef __CROS_EC_SKU_H
#define __CROS_EC_SKU_H
-#define SKU_CONVERTIBLE(id) (1 << ((id) & 0x7))
+#define SKU_CONVERTIBLE(id) (1 << ((id)&0x7))
/*
* There are 256 possible SKUs for Coral. This table is used to map a given SKU
@@ -22,7 +22,7 @@ static const uint8_t form_factor[32] = {
SKU_CONVERTIBLE(4) | SKU_CONVERTIBLE(5),
/* SKU 8 - 15 */
SKU_CONVERTIBLE(8) | SKU_CONVERTIBLE(9) | SKU_CONVERTIBLE(10) |
- SKU_CONVERTIBLE(11),
+ SKU_CONVERTIBLE(11),
/* SKU 16 - 23 */
0x00,
/* SKU 24 - 31 */
@@ -61,7 +61,7 @@ static const uint8_t form_factor[32] = {
0x00,
/* SKU 160 - 167 */
SKU_CONVERTIBLE(163) | SKU_CONVERTIBLE(164) | SKU_CONVERTIBLE(165) |
- SKU_CONVERTIBLE(166),
+ SKU_CONVERTIBLE(166),
/* SKU 168 - 175 */
0x00,
/* SKU 176 - 183 */
@@ -86,6 +86,6 @@ static const uint8_t form_factor[32] = {
0x00,
};
-#define SKU_IS_CONVERTIBLE(id) ((form_factor[(id) >> 3] >> ((id) & 0x7)) & 1)
+#define SKU_IS_CONVERTIBLE(id) ((form_factor[(id) >> 3] >> ((id)&0x7)) & 1)
#endif /* __CROS_EC_SKU_H */
diff --git a/board/coral/usb_pd_policy.c b/board/coral/usb_pd_policy.c
index e071f6ae2a..a2e1f3c412 100644
--- a/board/coral/usb_pd_policy.c
+++ b/board/coral/usb_pd_policy.c
@@ -1,4 +1,4 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
+/* Copyright 2016 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -23,12 +23,12 @@
#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)
static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT];
-static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = {TYPEC_RP_1A5,
- TYPEC_RP_1A5};
+static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = { TYPEC_RP_1A5,
+ TYPEC_RP_1A5 };
int board_vbus_source_enabled(int port)
{
@@ -39,7 +39,8 @@ static void board_vbus_update_source_current(int port)
{
enum gpio_signal gpio = port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN;
int flags = (vbus_rp[port] == TYPEC_RP_1A5 && vbus_en[port]) ?
- (GPIO_INPUT | GPIO_PULL_UP) : (GPIO_OUTPUT | GPIO_PULL_UP);
+ (GPIO_INPUT | GPIO_PULL_UP) :
+ (GPIO_OUTPUT | GPIO_PULL_UP);
/*
* Driving USB_Cx_5V_EN high, actually put a 16.5k resistance