diff options
Diffstat (limited to 'board/kodama')
-rw-r--r-- | board/kodama/battery.c | 10 | ||||
-rw-r--r-- | board/kodama/board.c | 101 | ||||
-rw-r--r-- | board/kodama/board.h | 18 | ||||
-rw-r--r-- | board/kodama/build.mk | 2 | ||||
-rw-r--r-- | board/kodama/ec.tasklist | 2 | ||||
-rw-r--r-- | board/kodama/gpio.inc | 2 | ||||
-rw-r--r-- | board/kodama/led.c | 67 |
7 files changed, 98 insertions, 104 deletions
diff --git a/board/kodama/battery.c b/board/kodama/battery.c index 1dbff92a00..1c6737bd3a 100644 --- a/board/kodama/battery.c +++ b/board/kodama/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. */ @@ -14,7 +14,7 @@ #include "usb_pd.h" #include "util.h" -#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args) +#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args) const struct board_batt_params board_battery_info[] = { [BATTERY_SIMPLO] = { @@ -95,9 +95,9 @@ int charger_profile_override(struct charge_state_data *curr) * When smart battery temperature is more than 45 deg C, the max * charging voltage is 4100mV. */ - if (curr->state == ST_CHARGE && bat_temp_c >= 450 - && !(curr->batt.flags & BATT_FLAG_BAD_TEMPERATURE)) - curr->requested_voltage = 4100; + if (curr->state == ST_CHARGE && bat_temp_c >= 450 && + !(curr->batt.flags & BATT_FLAG_BAD_TEMPERATURE)) + curr->requested_voltage = 4100; else curr->requested_voltage = batt_info->voltage_max; diff --git a/board/kodama/board.c b/board/kodama/board.c index 2fa3ae8a3e..5ebcf00d40 100644 --- a/board/kodama/board.c +++ b/board/kodama/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. */ @@ -25,6 +25,7 @@ #include "i2c.h" #include "i2c_bitbang.h" #include "lid_switch.h" +#include "panic.h" #include "power.h" #include "power_button.h" #include "pwm.h" @@ -40,8 +41,8 @@ #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) static void tcpc_alert_event(enum gpio_signal signal) { @@ -53,56 +54,50 @@ static void tcpc_alert_event(enum gpio_signal signal) /******************************************************************************/ /* ADC channels. Must be in the exactly same order as in enum adc_channel. */ const struct adc_t adc_channels[] = { - [ADC_BOARD_ID] = {"BOARD_ID", 3300, 4096, 0, STM32_AIN(10)}, - [ADC_EC_SKU_ID] = {"EC_SKU_ID", 3300, 4096, 0, STM32_AIN(8)}, - [ADC_POGO_ADC_INT_L] = {"POGO_ADC_INT_L", 3300, 4096, 0, STM32_AIN(6)}, + [ADC_BOARD_ID] = { "BOARD_ID", 3300, 4096, 0, STM32_AIN(10) }, + [ADC_EC_SKU_ID] = { "EC_SKU_ID", 3300, 4096, 0, STM32_AIN(8) }, + [ADC_POGO_ADC_INT_L] = { "POGO_ADC_INT_L", 3300, 4096, 0, + STM32_AIN(6) }, }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); /******************************************************************************/ /* I2C ports */ const struct i2c_port_t i2c_ports[] = { - { - .name = "typec", - .port = 0, - .kbps = 400, - .scl = GPIO_I2C1_SCL, - .sda = GPIO_I2C1_SDA - }, - { - .name = "other", - .port = 1, - .kbps = 400, - .scl = GPIO_I2C2_SCL, - .sda = GPIO_I2C2_SDA, - .flags = I2C_PORT_FLAG_DYNAMIC_SPEED - }, + { .name = "typec", + .port = 0, + .kbps = 400, + .scl = GPIO_I2C1_SCL, + .sda = GPIO_I2C1_SDA }, + { .name = "other", + .port = 1, + .kbps = 400, + .scl = GPIO_I2C2_SCL, + .sda = GPIO_I2C2_SDA, + .flags = I2C_PORT_FLAG_DYNAMIC_SPEED }, }; const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); const struct i2c_port_t i2c_bitbang_ports[] = { - { - .name = "battery", - .port = 2, - .kbps = 100, - .scl = GPIO_I2C3_SCL, - .sda = GPIO_I2C3_SDA, - .drv = &bitbang_drv - }, + { .name = "battery", + .port = 2, + .kbps = 100, + .scl = GPIO_I2C3_SCL, + .sda = GPIO_I2C3_SDA, + .drv = &bitbang_drv }, }; const unsigned int i2c_bitbang_ports_used = ARRAY_SIZE(i2c_bitbang_ports); /* power signal list. Must match order of enum power_signal. */ const struct power_signal_info power_signal_list[] = { - {GPIO_AP_IN_SLEEP_L, POWER_SIGNAL_ACTIVE_LOW, "AP_IN_S3_L"}, - {GPIO_PMIC_EC_RESETB, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_PWR_GOOD"}, + { GPIO_AP_IN_SLEEP_L, POWER_SIGNAL_ACTIVE_LOW, "AP_IN_S3_L" }, + { GPIO_PMIC_EC_RESETB, POWER_SIGNAL_ACTIVE_HIGH, "PMIC_PWR_GOOD" }, }; BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); /******************************************************************************/ /* SPI devices */ -const struct spi_device_t spi_devices[] = { -}; +const struct spi_device_t spi_devices[] = {}; const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices); /******************************************************************************/ @@ -122,8 +117,7 @@ struct mt6370_thermal_bound thermal_bound = { .err = 4, }; -static void board_hpd_status(const struct usb_mux *me, - mux_state_t mux_state, +static void board_hpd_status(const struct usb_mux *me, mux_state_t mux_state, bool *ack_required) { /* This driver does not use host command ACKs */ @@ -136,7 +130,6 @@ static void board_hpd_status(const struct usb_mux *me, host_set_single_event(EC_HOST_EVENT_USB_MUX); } - __override const struct rt946x_init_setting *board_rt946x_init_setting(void) { static const struct rt946x_init_setting battery_init_setting = { @@ -151,13 +144,16 @@ __override const struct rt946x_init_setting *board_rt946x_init_setting(void) return &battery_init_setting; } -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_port = 0, - .i2c_port = I2C_PORT_USB_MUX, - .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS, - .driver = &it5205_usb_mux_driver, - .hpd_update = &board_hpd_status, + .mux = + &(const struct usb_mux){ + .usb_port = 0, + .i2c_port = I2C_PORT_USB_MUX, + .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS, + .driver = &it5205_usb_mux_driver, + .hpd_update = &board_hpd_status, + }, }, }; @@ -238,9 +234,8 @@ int extpower_is_present(void) if (board_vbus_source_enabled(CHARGE_PORT_USB_C)) usb_c_extpower_present = 0; else - usb_c_extpower_present = tcpm_check_vbus_level( - CHARGE_PORT_USB_C, - VBUS_PRESENT); + usb_c_extpower_present = + tcpm_check_vbus_level(CHARGE_PORT_USB_C, VBUS_PRESENT); return usb_c_extpower_present; } @@ -260,11 +255,11 @@ static void board_init(void) #ifdef SECTION_IS_RW int val; - i2c_read8(I2C_PORT_CHARGER, CHARGER_I2C_ADDR_FLAGS, - RT946X_REG_CHGCTRL1, &val); + i2c_read8(I2C_PORT_CHARGER, CHARGER_I2C_ADDR_FLAGS, RT946X_REG_CHGCTRL1, + &val); val &= RT946X_MASK_OPA_MODE; i2c_write8(I2C_PORT_CHARGER, CHARGER_I2C_ADDR_FLAGS, - RT946X_REG_CHGCTRL1, (val | RT946X_MASK_STAT_EN)); + RT946X_REG_CHGCTRL1, (val | RT946X_MASK_STAT_EN)); #endif /* If the reset cause is external, pulse PMIC force reset. */ @@ -317,7 +312,7 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); static void board_i2c_init(void) { if (board_get_version() < 2) - i2c_set_freq(1, I2C_FREQ_100KHZ); + i2c_set_freq(1, I2C_FREQ_100KHZ); } DECLARE_HOOK(HOOK_INIT, board_i2c_init, HOOK_PRIO_INIT_I2C); @@ -329,11 +324,9 @@ static struct mutex g_lid_mutex; static struct lsm6dsm_data lsm6dsm_data = LSM6DSM_DATA; /* Matrix to rotate accelerometer into standard reference frame */ -static const mat33_fp_t lid_standard_ref = { - {0, FLOAT_TO_FP(1), 0}, - {FLOAT_TO_FP(-1), 0, 0}, - {0, 0, FLOAT_TO_FP(1)} -}; +static const mat33_fp_t lid_standard_ref = { { 0, FLOAT_TO_FP(1), 0 }, + { FLOAT_TO_FP(-1), 0, 0 }, + { 0, 0, FLOAT_TO_FP(1) } }; struct motion_sensor_t motion_sensors[] = { [LID_ACCEL] = { diff --git a/board/kodama/board.h b/board/kodama/board.h index de953cba0b..b16e9f84a7 100644 --- a/board/kodama/board.h +++ b/board/kodama/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. */ @@ -15,7 +15,6 @@ #define VARIANT_KUKUI_TABLET_PWRBTN #undef CONFIG_CMD_MFALLOW - #ifndef SECTION_IS_RW #define VARIANT_KUKUI_NO_SENSORS #endif /* SECTION_IS_RW */ @@ -39,7 +38,7 @@ #define CONFIG_SMBUS_PEC /* Battery */ -#define BATTERY_DESIRED_CHARGING_CURRENT 2000 /* mA */ +#define BATTERY_DESIRED_CHARGING_CURRENT 2000 /* mA */ #define CONFIG_CHARGER_MT6370_BACKLIGHT #define CONFIG_CHARGER_MAINTAIN_VBAT @@ -53,19 +52,18 @@ /* Camera VSYNC */ #define CONFIG_SYNC #define CONFIG_SYNC_COMMAND -#define CONFIG_SYNC_INT_EVENT \ - TASK_EVENT_MOTION_SENSOR_INTERRUPT(VSYNC) +#define CONFIG_SYNC_INT_EVENT TASK_EVENT_MOTION_SENSOR_INTERRUPT(VSYNC) #endif /* SECTION_IS_RW */ /* Disable verbose output in EC pd */ #define CONFIG_CMD_PD_SRCCAPS_REDUCED_SIZE /* I2C ports */ -#define I2C_PORT_CHARGER 0 -#define I2C_PORT_TCPC0 0 -#define I2C_PORT_USB_MUX 0 -#define I2C_PORT_ACCEL 1 -#define I2C_PORT_BATTERY board_get_battery_i2c() +#define I2C_PORT_CHARGER 0 +#define I2C_PORT_TCPC0 0 +#define I2C_PORT_USB_MUX 0 +#define I2C_PORT_ACCEL 1 +#define I2C_PORT_BATTERY board_get_battery_i2c() #define I2C_PORT_VIRTUAL_BATTERY I2C_PORT_BATTERY /* Define the host events which are allowed to wakeup AP in S3. */ diff --git a/board/kodama/build.mk b/board/kodama/build.mk index 0b3565fd84..6a7e557a0e 100644 --- a/board/kodama/build.mk +++ b/board/kodama/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/kodama/ec.tasklist b/board/kodama/ec.tasklist index f71a208dd6..e66c52616b 100644 --- a/board/kodama/ec.tasklist +++ b/board/kodama/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/kodama/gpio.inc b/board/kodama/gpio.inc index 75a3db7d20..d72532ff70 100644 --- a/board/kodama/gpio.inc +++ b/board/kodama/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/kodama/led.c b/board/kodama/led.c index d96b340d73..d6c4297a44 100644 --- a/board/kodama/led.c +++ b/board/kodama/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. * @@ -11,45 +11,48 @@ #include "led_onoff_states.h" #include "ec_commands.h" -#define LED_RED MT6370_LED_ID1 -#define LED_GREEN MT6370_LED_ID2 -#define LED_WHITE MT6370_LED_ID3 +#define LED_RED MT6370_LED_ID1 +#define LED_GREEN MT6370_LED_ID2 +#define LED_WHITE MT6370_LED_ID3 -#define LED_MASK_OFF 0 -#define LED_MASK_RED MT6370_MASK_RGB_ISNK1DIM_EN -#define LED_MASK_GREEN MT6370_MASK_RGB_ISNK2DIM_EN -#define LED_MASK_WHITE MT6370_MASK_RGB_ISNK3DIM_EN +#define LED_MASK_OFF 0 +#define LED_MASK_RED MT6370_MASK_RGB_ISNK1DIM_EN +#define LED_MASK_GREEN MT6370_MASK_RGB_ISNK2DIM_EN +#define LED_MASK_WHITE MT6370_MASK_RGB_ISNK3DIM_EN __override const int led_charge_lvl_1 = 5; __override const int led_charge_lvl_2 = 97; __override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_RED, LED_INDEFINITE} }, - [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, - [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_GREEN, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S3] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_RED, 1 * LED_ONE_SEC}, - {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_FACTORY_TEST] = {{EC_LED_COLOR_RED, 2 * LED_ONE_SEC}, - {EC_LED_COLOR_GREEN, 2 * LED_ONE_SEC} }, -}; + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, + { EC_LED_COLOR_GREEN, + 2 * LED_ONE_SEC } }, + }; __override const struct led_descriptor - led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { - [PWR_LED_STATE_ON] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, - [PWR_LED_STATE_SUSPEND_AC] = {{EC_LED_COLOR_WHITE, 3 * LED_ONE_SEC}, - {LED_OFF, LED_ONE_SEC / 2} }, - [PWR_LED_STATE_SUSPEND_NO_AC] = {{LED_OFF, LED_INDEFINITE} }, - [PWR_LED_STATE_OFF] = {{LED_OFF, LED_INDEFINITE} }, -}; - -const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_POWER_LED, - EC_LED_ID_BATTERY_LED -}; + led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { + [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, + [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, + 3 * LED_ONE_SEC }, + { LED_OFF, LED_ONE_SEC / 2 } }, + [PWR_LED_STATE_SUSPEND_NO_AC] = { { LED_OFF, LED_INDEFINITE } }, + [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, + }; + +const enum ec_led_id supported_led_ids[] = { EC_LED_ID_POWER_LED, + EC_LED_ID_BATTERY_LED }; const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); |