diff options
Diffstat (limited to 'board/mchpevb1')
-rw-r--r-- | board/mchpevb1/battery.c | 23 | ||||
-rw-r--r-- | board/mchpevb1/board.c | 172 | ||||
-rw-r--r-- | board/mchpevb1/board.h | 67 | ||||
-rw-r--r-- | board/mchpevb1/build.mk | 2 | ||||
-rw-r--r-- | board/mchpevb1/ec.tasklist | 2 | ||||
-rw-r--r-- | board/mchpevb1/gpio.inc | 2 | ||||
-rw-r--r-- | board/mchpevb1/led.c | 42 | ||||
-rw-r--r-- | board/mchpevb1/usb_pd_policy.c | 18 |
8 files changed, 146 insertions, 182 deletions
diff --git a/board/mchpevb1/battery.c b/board/mchpevb1/battery.c index fcc09994bf..d8f7496fa0 100644 --- a/board/mchpevb1/battery.c +++ b/board/mchpevb1/battery.c @@ -1,4 +1,4 @@ -/* 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. * @@ -14,15 +14,15 @@ #include "util.h" /* Shutdown mode parameter to write to manufacturer access register */ -#define PARAM_CUT_OFF_LOW 0x10 +#define PARAM_CUT_OFF_LOW 0x10 #define PARAM_CUT_OFF_HIGH 0x00 /* Battery info for BQ40Z55 */ static const struct battery_info info = { - .voltage_max = 8700, /* mV */ + .voltage_max = 8700, /* mV */ .voltage_normal = 7600, .voltage_min = 6000, - .precharge_current = 256, /* mA */ + .precharge_current = 256, /* mA */ .start_charging_min_c = 0, .start_charging_max_c = 46, .charging_min_c = 0, @@ -47,10 +47,10 @@ int board_cut_off_battery(void) buf[2] = PARAM_CUT_OFF_HIGH; i2c_lock(I2C_PORT_BATTERY, 1); - rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, - buf, 3, NULL, 0, I2C_XFER_SINGLE); - rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, - buf, 3, NULL, 0, I2C_XFER_SINGLE); + rv = i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, buf, 3, + NULL, 0, I2C_XFER_SINGLE); + rv |= i2c_xfer_unlocked(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, buf, 3, + NULL, 0, I2C_XFER_SINGLE); i2c_lock(I2C_PORT_BATTERY, 0); return rv; @@ -214,7 +214,7 @@ enum ec_status charger_profile_override_set_param(uint32_t param, return EC_RES_INVALID_PARAM; } -static int command_fastcharge(int argc, char **argv) +static int command_fastcharge(int argc, const char **argv) { if (argc > 1 && !parse_bool(argv[1], &fast_charging_allowed)) return EC_ERROR_PARAM1; @@ -223,8 +223,7 @@ static int command_fastcharge(int argc, char **argv) return EC_SUCCESS; } -DECLARE_CONSOLE_COMMAND(fastcharge, command_fastcharge, - "[on|off]", +DECLARE_CONSOLE_COMMAND(fastcharge, command_fastcharge, "[on|off]", "Get or set fast charging profile"); -#endif /* CONFIG_CHARGER_PROFILE_OVERRIDE */ +#endif /* CONFIG_CHARGER_PROFILE_OVERRIDE */ diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c index 2991b59299..23135108f6 100644 --- a/board/mchpevb1/board.c +++ b/board/mchpevb1/board.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. */ @@ -58,26 +58,25 @@ /* Console output macros */ #define CPUTS(outstr) cputs(CC_LPC, outstr) -#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) /* NOTE: MEC17xx EVB + SKL RVP3 does not use BD99992 PMIC. * RVP3 PMIC controlled by RVP3 logic. */ -#define I2C_ADDR_BD99992_FLAGS 0x30 +#define I2C_ADDR_BD99992_FLAGS 0x30 /* * Maxim DS1624 I2C temperature sensor used for testing I2C. * DS1624 contains one internal temperature sensor * and EEPROM. It has no external temperature inputs. */ -#define DS1624_I2C_ADDR_FLAGS (0x48 | I2C_FLAG_BIG_ENDIAN) -#define DS1624_IDX_LOCAL 0 -#define DS1624_READ_TEMP16 0xAA /* read 16-bit temperature */ -#define DS1624_ACCESS_CFG 0xAC /* read/write 8-bit config */ -#define DS1624_CMD_START 0xEE -#define DS1624_CMD_STOP 0x22 +#define DS1624_I2C_ADDR_FLAGS (0x48 | I2C_FLAG_BIG_ENDIAN) +#define DS1624_IDX_LOCAL 0 +#define DS1624_READ_TEMP16 0xAA /* read 16-bit temperature */ +#define DS1624_ACCESS_CFG 0xAC /* read/write 8-bit config */ +#define DS1624_CMD_START 0xEE +#define DS1624_CMD_STOP 0x22 /* * static global and routine to return smart battery @@ -116,7 +115,6 @@ void board_config_pre_init(void) } #endif /* #ifdef CONFIG_BOARD_PRE_INIT */ - /* * Use EC to handle ALL_SYS_PWRGD signal. * MEC17xx connected to SKL/KBL RVP3 reference board @@ -135,8 +133,8 @@ static void board_all_sys_pwrgd(void) CPRINTS("ALL_SYS_PWRGD=%d SYS_RESET_L=%d", allsys_in, allsys_out); - trace2(0, BRD, 0, "ALL_SYS_PWRGD=%d SYS_RESET_L=%d", - allsys_in, allsys_out); + trace2(0, BRD, 0, "ALL_SYS_PWRGD=%d SYS_RESET_L=%d", allsys_in, + allsys_out); /* * Wait at least 10 ms between power signals going high @@ -161,14 +159,12 @@ void all_sys_pwrgd_interrupt(enum gpio_signal signal) } #endif /* #ifdef CONFIG_BOARD_HAS_ALL_SYS_PWRGD */ - #ifdef HAS_TASK_PDCMD /* Exchange status with PD MCU. */ static void pd_mcu_interrupt(enum gpio_signal signal) { /* Exchange status with PD MCU to determine interrupt cause */ host_command_pd_send_status(0); - } #endif @@ -217,33 +213,29 @@ void tablet_mode_interrupt(enum gpio_signal signal) */ const struct adc_t adc_channels[] = { /* Vbus sensing. Converted to mV, full ADC is equivalent to 30V. */ - [ADC_VBUS] = {"VBUS", 30000, 1024, 0, 1}, + [ADC_VBUS] = { "VBUS", 30000, 1024, 0, 1 }, /* Adapter current output or battery discharging current */ - [ADC_AMON_BMON] = {"AMON_BMON", 25000, 3072, 0, 3}, + [ADC_AMON_BMON] = { "AMON_BMON", 25000, 3072, 0, 3 }, /* System current consumption */ - [ADC_PSYS] = {"PSYS", 1, 1, 0, 4}, - [ADC_CASE] = {"CASE", 1, 1, 0, 7}, + [ADC_PSYS] = { "PSYS", 1, 1, 0, 4 }, + [ADC_CASE] = { "CASE", 1, 1, 0, 7 }, }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); /* * MCHP EVB connected to KBL RVP3 */ -const struct i2c_port_t i2c_ports[] = { - { - .name = "sensors", - .port = MCHP_I2C_PORT4, - .kbps = 100, - .scl = GPIO_SMB04_SCL, - .sda = GPIO_SMB04_SDA - }, - { - .name = "batt", - .port = MCHP_I2C_PORT5, - .kbps = 100, - .scl = GPIO_SMB05_SCL, - .sda = GPIO_SMB05_SDA - }, +const struct i2c_port_t i2c_ports[] = { + { .name = "sensors", + .port = MCHP_I2C_PORT4, + .kbps = 100, + .scl = GPIO_SMB04_SCL, + .sda = GPIO_SMB04_SDA }, + { .name = "batt", + .port = MCHP_I2C_PORT5, + .kbps = 100, + .scl = GPIO_SMB05_SCL, + .sda = GPIO_SMB05_SDA }, }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); @@ -273,19 +265,15 @@ int board_i2c_p2c(int port) #ifdef CONFIG_USB_POWER_DELIVERY const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - {I2C_PORT_TCPC, - CONFIG_TCPC_I2C_BASE_ADDR_FLAGS, - &tcpci_tcpm_drv}, + { I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR_FLAGS, &tcpci_tcpm_drv }, - {I2C_PORT_TCPC, - CONFIG_TCPC_I2C_BASE_ADDR_FLAGS + 1, - &tcpci_tcpm_drv}, + { I2C_PORT_TCPC, CONFIG_TCPC_I2C_BASE_ADDR_FLAGS + 1, &tcpci_tcpm_drv }, }; #endif /* SPI devices */ const struct spi_device_t spi_devices[] = { - { QMSPI0_PORT, 4, GPIO_QMSPI_CS0}, + { QMSPI0_PORT, 4, GPIO_QMSPI_CS0 }, #if defined(CONFIG_SPI_ACCEL_PORT) { GPSPI0_PORT, 2, GPIO_SPI0_CS0 }, #endif @@ -299,7 +287,6 @@ const enum gpio_signal hibernate_wake_pins[] = { }; const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins); - /* * Deep sleep support, called by chip level. */ @@ -362,18 +349,24 @@ struct pi3usb9281_config pi3usb9281_chips[] = { BUILD_ASSERT(ARRAY_SIZE(pi3usb9281_chips) == CONFIG_BC12_DETECT_PI3USB9281_CHIP_COUNT); -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { +struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { { - .usb_port = 0, - .i2c_port = I2C_PORT_USB_MUX, - .i2c_addr_flags = PI3USB3X532_I2C_ADDR0, - .driver = &pi3usb3x532_usb_mux_driver, + .mux = + &(const struct usb_mux){ + .usb_port = 0, + .i2c_port = I2C_PORT_USB_MUX, + .i2c_addr_flags = PI3USB3X532_I2C_ADDR0, + .driver = &pi3usb3x532_usb_mux_driver, + }, }, { - .usb_port = 1, - .i2c_port = I2C_PORT_USB_MUX, - .i2c_addr_flags = 0x10, - .driver = &ps8740_usb_mux_driver, + .mux = + &(const struct usb_mux){ + .usb_port = 1, + .i2c_port = I2C_PORT_USB_MUX, + .i2c_addr_flags = 0x10, + .driver = &ps8740_usb_mux_driver, + }, } }; #endif @@ -429,9 +422,9 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); * a static global in this module. */ const struct temp_sensor_t temp_sensors[] = { - {"Battery", TEMP_SENSOR_TYPE_BATTERY, sb_temp, 0}, - {"Ambient", TEMP_SENSOR_TYPE_BOARD, ds1624_get_val, 0}, - {"Case", TEMP_SENSOR_TYPE_CASE, therm_get_val, (int)ADC_CASE}, + { "Battery", TEMP_SENSOR_TYPE_BATTERY, sb_temp, 0 }, + { "Ambient", TEMP_SENSOR_TYPE_BOARD, ds1624_get_val, 0 }, + { "Case", TEMP_SENSOR_TYPE_CASE, therm_get_val, (int)ADC_CASE }, }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); #endif @@ -440,16 +433,16 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); #ifdef CONFIG_ALS /* ALS instances. Must be in same order as enum als_id. */ struct als_t als[] = { - {"TI", opt3001_init, opt3001_read_lux, 5}, + { "TI", opt3001_init, opt3001_read_lux, 5 }, }; BUILD_ASSERT(ARRAY_SIZE(als) == ALS_COUNT); #endif const struct button_config buttons[CONFIG_BUTTON_COUNT] = { - {"Volume Down", KEYBOARD_BUTTON_VOLUME_DOWN, GPIO_VOLUME_DOWN_L, - 30 * MSEC, 0}, - {"Volume Up", KEYBOARD_BUTTON_VOLUME_UP, GPIO_VOLUME_UP_L, - 30 * MSEC, 0}, + { "Volume Down", KEYBOARD_BUTTON_VOLUME_DOWN, GPIO_VOLUME_DOWN_L, + 30 * MSEC, 0 }, + { "Volume Up", KEYBOARD_BUTTON_VOLUME_UP, GPIO_VOLUME_UP_L, 30 * MSEC, + 0 }, }; /* MCHP mec1701_evb connected to Intel SKL RVP3 with Kabylake @@ -490,8 +483,7 @@ static void board_pmic_init(void) cfg = 0x66; rv = i2c_read8(I2C_PORT_THERMAL, DS1624_I2C_ADDR_FLAGS, DS1624_ACCESS_CFG, &cfg); - trace2(0, BRD, 0, "Read DS1624 Config rv = %d cfg = 0x%02X", - rv, cfg); + trace2(0, BRD, 0, "Read DS1624 Config rv = %d cfg = 0x%02X", rv, cfg); if ((rv == EC_SUCCESS) && (cfg & (1u << 0))) { /* one-shot mode switch to continuous */ @@ -536,16 +528,13 @@ static void board_init(void) /* Provide AC status to the PCH */ gpio_set_level(GPIO_PCH_ACOK, extpower_is_present()); - if (system_jumped_late() && - chipset_in_state(CHIPSET_STATE_ON)) { + if (system_jumped_late() && chipset_in_state(CHIPSET_STATE_ON)) { trace0(0, BRD, 0, "board_init: S0 call board_spi_enable"); board_spi_enable(); } - } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); - /** * Buffer the AC present GPIO to the PCH. */ @@ -577,8 +566,7 @@ int board_set_active_charge_port(int charge_port) if (is_real_port && source) { CPRINTS("MEC1701 Skip enable p%d", charge_port); - trace1(0, BOARD, 0, "Skip enable charge port %d", - charge_port); + trace1(0, BOARD, 0, "Skip enable charge port %d", charge_port); return EC_ERROR_INVAL; } @@ -592,10 +580,12 @@ int board_set_active_charge_port(int charge_port) } else { /* Make sure non-charging port is disabled */ gpio_set_level(charge_port ? GPIO_USB_C0_CHARGE_EN_L : - GPIO_USB_C1_CHARGE_EN_L, 1); + GPIO_USB_C1_CHARGE_EN_L, + 1); /* Enable charging port */ gpio_set_level(charge_port ? GPIO_USB_C1_CHARGE_EN_L : - GPIO_USB_C0_CHARGE_EN_L, 0); + GPIO_USB_C0_CHARGE_EN_L, + 0); } return EC_SUCCESS; @@ -609,23 +599,12 @@ 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) -{ - charge_set_input_current_limit(MAX(charge_ma, - CONFIG_CHARGER_INPUT_CURRENT), charge_mv); -} -#else -/* - * TODO HACK providing functions from common/charge_state_v2.c - * which is not compiled in when no charger - */ -int charge_prevent_power_on(int power_button_pressed) +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) { - return 0; + charge_set_input_current_limit( + MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); } - - #endif /* @@ -657,23 +636,18 @@ static void board_chipset_startup(void) gpio_set_level(GPIO_USB2_ENABLE, 1); hook_call_deferred(&enable_input_devices_data, 0); } -DECLARE_HOOK(HOOK_CHIPSET_STARTUP, - board_chipset_startup, - HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT); /* Called on AP S3 -> S5 transition */ static void board_chipset_shutdown(void) { CPRINTS("MEC1701 HOOK_CHIPSET_SHUTDOWN board_chipset_shutdown"); - trace0(0, HOOK, 0, - "HOOK_CHIPSET_SHUTDOWN board_chipset_shutdown"); + trace0(0, HOOK, 0, "HOOK_CHIPSET_SHUTDOWN board_chipset_shutdown"); gpio_set_level(GPIO_USB1_ENABLE, 0); gpio_set_level(GPIO_USB2_ENABLE, 0); hook_call_deferred(&enable_input_devices_data, 0); } -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, - board_chipset_shutdown, - HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT); /* Called on AP S3 -> S0 transition */ static void board_chipset_resume(void) @@ -685,10 +659,9 @@ static void board_chipset_resume(void) gpio_set_level(GPIO_PP1800_DX_AUDIO_EN, 1); gpio_set_level(GPIO_PP1800_DX_SENSOR_EN, 1); #endif - } DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, - MOTION_SENSE_HOOK_PRIO-1); + MOTION_SENSE_HOOK_PRIO - 1); /* Called on AP S0 -> S3 transition */ static void board_chipset_suspend(void) @@ -701,9 +674,7 @@ static void board_chipset_suspend(void) gpio_set_level(GPIO_PP1800_DX_SENSOR_EN, 0); #endif } -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, - board_chipset_suspend, - HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT); void board_hibernate_late(void) { @@ -780,7 +751,6 @@ static void board_handle_reboot(void) } DECLARE_HOOK(HOOK_INIT, board_handle_reboot, HOOK_PRIO_FIRST); - static int sb_temp(int idx, int *temp_ptr) { if (idx != 0) @@ -817,8 +787,8 @@ static void sb_update(void) rv = sb_read(SB_TEMPERATURE, &smart_batt_temp); smart_batt_temp = smart_batt_temp / 10; - trace12(0, BRD, 0, "sb_read temperature rv=%d temp=%d K", - rv, smart_batt_temp); + trace12(0, BRD, 0, "sb_read temperature rv=%d temp=%d K", rv, + smart_batt_temp); } /* diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h index e16d0bb10f..10208ca736 100644 --- a/board/mchpevb1/board.h +++ b/board/mchpevb1/board.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. */ @@ -88,7 +88,6 @@ * #define EVB_NO_ESPI_TEST_MODE */ - /* * DEBUG * Disable ARM Cortex-M4 write buffer so @@ -104,7 +103,7 @@ * Values in MHz are 20, 25, 33, 50, and 66 */ /* KBL + EVB fly-wire hook up only supports 20MHz */ -#define CONFIG_HOSTCMD_ESPI_EC_MAX_FREQ MCHP_ESPI_CAP1_MAX_FREQ_20M +#define CONFIG_HOST_INTERFACE_ESPI_EC_MAX_FREQ MCHP_ESPI_CAP1_MAX_FREQ_20M /* * EC eSPI advertises IO lanes @@ -114,7 +113,7 @@ * 3 = Single, Dual, and Quad */ /* KBL + EVB fly-wire hook up only support Single mode */ -#define CONFIG_HOSTCMD_ESPI_EC_MODE MCHP_ESPI_CAP1_SINGLE_MODE +#define CONFIG_HOST_INTERFACE_ESPI_EC_MODE MCHP_ESPI_CAP1_SINGLE_MODE /* * Bit map of eSPI channels EC advertises @@ -123,7 +122,7 @@ * bit[2] = 1 OOB channel * bit[3] = 1 Flash channel */ -#define CONFIG_HOSTCMD_ESPI_EC_CHAN_BITMAP MCHP_ESPI_CAP0_ALL_CHAN_SUPP +#define CONFIG_HOST_INTERFACE_ESPI_EC_CHAN_BITMAP MCHP_ESPI_CAP0_ALL_CHAN_SUPP #define CONFIG_MCHP_ESPI_VW_SAVE_ON_SLEEP @@ -146,7 +145,6 @@ /* #define CONFIG_CHARGE_MANAGER */ /* #define CONFIG_CHARGE_RAMP_SW */ - /* #define CONFIG_CHARGER */ /* #define CONFIG_CHARGER_DISCHARGE_ON_AC */ @@ -164,8 +162,8 @@ #define CONFIG_CHIPSET_RESET_HOOK #define CONFIG_HOST_INTERFACE_ESPI -#define CONFIG_HOSTCMD_ESPI_VW_SLP_S3 -#define CONFIG_HOSTCMD_ESPI_VW_SLP_S4 +#define CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S3 +#define CONFIG_HOST_INTERFACE_ESPI_VW_SLP_S4 #define GPIO_PG_EC_RSMRST_ODL GPIO_RSMRST_L_PGOOD #define CONFIG_CLOCK_CRYSTAL @@ -190,7 +188,6 @@ * #define CONFIG_LOW_POWER_IDLE */ - /* #define CONFIG_GPIO_POWER_DOWN */ /* @@ -270,8 +267,8 @@ * Configure for smaller flash is OK for testing except * for SPI flash lock bit. */ - #define CONFIG_FLASH_SIZE_BYTES 524288 - #define CONFIG_SPI_FLASH_W25X40 +#define CONFIG_FLASH_SIZE_BYTES 524288 +#define CONFIG_SPI_FLASH_W25X40 /* * #define CONFIG_FLASH_SIZE_BYTES 0x1000000 * #define CONFIG_SPI_FLASH_W25Q128 @@ -321,7 +318,7 @@ * Make sure to not include GPSPI in little-firmware(LFW) */ #ifndef LFW -#define CONFIG_MCHP_GPSPI 0x01 +#define CONFIG_MCHP_GPSPI 0x01 #endif /* SPI Accelerometer @@ -360,9 +357,8 @@ #define GPIO_BAT_LED_GREEN GPIO_CHARGE_LED_2 /* I2C ports */ -#define I2C_CONTROLLER_COUNT 2 -#define I2C_PORT_COUNT 2 - +#define I2C_CONTROLLER_COUNT 2 +#define I2C_PORT_COUNT 2 /* * Map I2C Ports to Controllers for this board. @@ -377,26 +373,26 @@ * All other ports set to 0xff (not used) */ -#define I2C_PORT_PMIC MCHP_I2C_PORT10 -#define I2C_PORT_USB_CHARGER_1 MCHP_I2C_PORT2 -#define I2C_PORT_USB_MUX MCHP_I2C_PORT2 -#define I2C_PORT_USB_CHARGER_2 MCHP_I2C_PORT2 -#define I2C_PORT_PD_MCU MCHP_I2C_PORT3 -#define I2C_PORT_TCPC MCHP_I2C_PORT3 -#define I2C_PORT_ALS MCHP_I2C_PORT4 -#define I2C_PORT_ACCEL MCHP_I2C_PORT4 -#define I2C_PORT_BATTERY MCHP_I2C_PORT5 -#define I2C_PORT_CHARGER MCHP_I2C_PORT5 +#define I2C_PORT_PMIC MCHP_I2C_PORT10 +#define I2C_PORT_USB_CHARGER_1 MCHP_I2C_PORT2 +#define I2C_PORT_USB_MUX MCHP_I2C_PORT2 +#define I2C_PORT_USB_CHARGER_2 MCHP_I2C_PORT2 +#define I2C_PORT_PD_MCU MCHP_I2C_PORT3 +#define I2C_PORT_TCPC MCHP_I2C_PORT3 +#define I2C_PORT_ALS MCHP_I2C_PORT4 +#define I2C_PORT_ACCEL MCHP_I2C_PORT4 +#define I2C_PORT_BATTERY MCHP_I2C_PORT5 +#define I2C_PORT_CHARGER MCHP_I2C_PORT5 /* Thermal sensors read through PMIC ADC interface */ #if 0 -#define I2C_PORT_THERMAL I2C_PORT_PMIC +#define I2C_PORT_THERMAL I2C_PORT_PMIC #else -#define I2C_PORT_THERMAL MCHP_I2C_PORT4 +#define I2C_PORT_THERMAL MCHP_I2C_PORT4 #endif /* Ambient Light Sensor address */ -#define OPT3001_I2C_ADDR_FLAGS OPT3001_I2C_ADDR1_FLAGS +#define OPT3001_I2C_ADDR_FLAGS OPT3001_I2C_ADDR1_FLAGS /* Modules we want to exclude */ #undef CONFIG_CMD_HASH @@ -425,9 +421,9 @@ enum temp_sensor_id { /* These temp sensors are only readable in S0 */ TEMP_SENSOR_AMBIENT, TEMP_SENSOR_CASE, -/* TEMP_SENSOR_CHARGER, */ -/* TEMP_SENSOR_DRAM, */ -/* TEMP_SENSOR_WIFI, */ + /* TEMP_SENSOR_CHARGER, */ + /* TEMP_SENSOR_DRAM, */ + /* TEMP_SENSOR_WIFI, */ TEMP_SENSOR_COUNT }; @@ -453,25 +449,24 @@ enum als_id { * 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_POWER_MW 45000 +#define PD_MAX_CURRENT_MA 3000 /* Try to negotiate to 20V since i2c noise problems should be fixed. */ -#define PD_MAX_VOLTAGE_MV 20000 +#define PD_MAX_VOLTAGE_MV 20000 /* * include TFDP macros from mchp chip level */ #include "tfdp_chip.h" - /* Map I2C port to controller */ int board_i2c_p2c(int port); diff --git a/board/mchpevb1/build.mk b/board/mchpevb1/build.mk index 412b04d46b..c92a045646 100644 --- a/board/mchpevb1/build.mk +++ b/board/mchpevb1/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/mchpevb1/ec.tasklist b/board/mchpevb1/ec.tasklist index 6fcd5faa98..f187bb914a 100644 --- a/board/mchpevb1/ec.tasklist +++ b/board/mchpevb1/ec.tasklist @@ -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. */ diff --git a/board/mchpevb1/gpio.inc b/board/mchpevb1/gpio.inc index 3949e31843..b3aa29941e 100644 --- a/board/mchpevb1/gpio.inc +++ b/board/mchpevb1/gpio.inc @@ -1,6 +1,6 @@ /* -*- mode:c -*- * - * 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. */ diff --git a/board/mchpevb1/led.c b/board/mchpevb1/led.c index 7b9f7646cb..8a5d85e97d 100644 --- a/board/mchpevb1/led.c +++ b/board/mchpevb1/led.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. * @@ -30,8 +30,7 @@ * NOTE: GPIO_BAT_LED_xxx defined in board.h */ -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); @@ -40,7 +39,7 @@ enum led_color { LED_RED, LED_AMBER, LED_GREEN, - LED_COLOR_COUNT /* Number of colors, not a color itself */ + LED_COLOR_COUNT /* Number of colors, not a color itself */ }; static int bat_led_set_color(enum led_color color) @@ -68,8 +67,7 @@ static int bat_led_set_color(enum led_color color) return EC_SUCCESS; } -void led_get_brightness_range(enum ec_led_id led_id, - uint8_t *brightness_range) +void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { brightness_range[EC_LED_COLOR_RED] = 1; brightness_range[EC_LED_COLOR_GREEN] = 1; @@ -114,7 +112,6 @@ static void board_led_set_battery(void) { #ifdef CONFIG_CHARGER static int battery_ticks; - uint32_t chflags = charge_get_flags(); battery_ticks++; @@ -129,34 +126,42 @@ static void board_led_set_battery(void) case PWR_STATE_DISCHARGE: /* Less than 3%, blink one second every two second */ if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) && - charge_get_percent() < CRITICAL_LOW_BATTERY_PERCENTAGE) + charge_get_percent() < CRITICAL_LOW_BATTERY_PERCENTAGE) board_led_set_color_battery( (battery_ticks % LED_TOTAL_2SECS_TICKS < - LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); + LED_ON_1SEC_TICKS) ? + LED_AMBER : + LED_OFF); /* Less than 10%, blink one second every four seconds */ else if (!chipset_in_state(CHIPSET_STATE_ANY_OFF) && - charge_get_percent() < LOW_BATTERY_PERCENTAGE) + charge_get_percent() < LOW_BATTERY_PERCENTAGE) board_led_set_color_battery( (battery_ticks % LED_TOTAL_4SECS_TICKS < - LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); + LED_ON_1SEC_TICKS) ? + LED_AMBER : + LED_OFF); else board_led_set_color_battery(LED_OFF); break; case PWR_STATE_ERROR: board_led_set_color_battery( (battery_ticks % LED_TOTAL_2SECS_TICKS < - LED_ON_1SEC_TICKS) ? LED_RED : LED_OFF); + LED_ON_1SEC_TICKS) ? + LED_RED : + LED_OFF); break; case PWR_STATE_CHARGE_NEAR_FULL: board_led_set_color_battery(LED_GREEN); break; case PWR_STATE_IDLE: /* External power connected in IDLE */ - if (chflags & CHARGE_FLAG_FORCE_IDLE) - board_led_set_color_battery( - (battery_ticks % LED_TOTAL_4SECS_TICKS < - LED_ON_2SECS_TICKS) ? LED_GREEN : LED_AMBER); - else - board_led_set_color_battery(LED_GREEN); + board_led_set_color_battery(LED_GREEN); + break; + case PWR_STATE_FORCED_IDLE: + board_led_set_color_battery( + (battery_ticks % LED_TOTAL_4SECS_TICKS < + LED_ON_2SECS_TICKS) ? + LED_GREEN : + LED_AMBER); break; default: /* Other states don't alter LED behavior */ @@ -165,7 +170,6 @@ static void board_led_set_battery(void) #endif } - static void led_second(void) { if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) diff --git a/board/mchpevb1/usb_pd_policy.c b/board/mchpevb1/usb_pd_policy.c index 690f8b8a3c..f84d5d1171 100644 --- a/board/mchpevb1/usb_pd_policy.c +++ b/board/mchpevb1/usb_pd_policy.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. */ @@ -18,19 +18,16 @@ #include "usb_mux.h" #include "usb_pd.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) int pd_set_power_supply_ready(int port) { /* Disable charging */ - gpio_set_level(port ? GPIO_USB_C1_CHARGE_EN_L : - GPIO_USB_C0_CHARGE_EN_L, 1); + gpio_set_level(port ? GPIO_USB_C1_CHARGE_EN_L : GPIO_USB_C0_CHARGE_EN_L, + 1); /* Provide VBUS */ - gpio_set_level(port ? GPIO_USB_C1_5V_EN : - GPIO_USB_C0_5V_EN, 1); + gpio_set_level(port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN, 1); /* notify host of power info change */ pd_send_host_event(PD_EVENT_POWER_CHANGE); @@ -41,8 +38,7 @@ int pd_set_power_supply_ready(int port) void pd_power_supply_reset(int port) { /* Disable VBUS */ - gpio_set_level(port ? GPIO_USB_C1_5V_EN : - GPIO_USB_C0_5V_EN, 0); + gpio_set_level(port ? GPIO_USB_C1_5V_EN : GPIO_USB_C0_5V_EN, 0); /* notify host of power info change */ pd_send_host_event(PD_EVENT_POWER_CHANGE); |