diff options
author | Denis Brockus <dbrockus@chromium.org> | 2020-03-05 14:28:22 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-10 23:44:43 +0000 |
commit | 3515ab7ed26fd6b07be2f8154fed3836c3192b96 (patch) | |
tree | 148829908d7a7f740cd114fc051174babdd2b122 /baseboard/zork | |
parent | 6c25137279a382ed186aff0d21f471503dcca16b (diff) | |
download | chrome-ec-3515ab7ed26fd6b07be2f8154fed3836c3192b96.tar.gz |
zork: add EC fw_config framework
BUG=none
BRANCH=none
TEST=verify adding a call to fw_config routines work
Signed-off-by: Denis Brockus <dbrockus@chromium.org>
Change-Id: Ib56bae5a0ce0b1078fdd235a3595fa059181dc2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2090086
Reviewed-by: Edward Hill <ecgh@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'baseboard/zork')
-rw-r--r-- | baseboard/zork/baseboard.c | 9 | ||||
-rw-r--r-- | baseboard/zork/build.mk | 1 | ||||
-rw-r--r-- | baseboard/zork/cbi_ec_fw_config.c | 80 | ||||
-rw-r--r-- | baseboard/zork/cbi_ec_fw_config.h | 111 |
4 files changed, 201 insertions, 0 deletions
diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c index d0917d5685..412a2e4c2d 100644 --- a/baseboard/zork/baseboard.c +++ b/baseboard/zork/baseboard.c @@ -8,6 +8,7 @@ #include "adc.h" #include "adc_chip.h" #include "button.h" +#include "cbi_ec_fw_config.h" #include "charge_manager.h" #include "charge_state.h" #include "charge_state_v2.h" @@ -597,6 +598,13 @@ static void cbi_init(void) sku_id = val; ccprints("SKU: %d (0x%x)", sku_id, sku_id); + /* FW config */ + val = get_cbi_fw_config(); + if (val == UNINITIALIZED_FW_CONFIG) + ccprints("FW Config: not set in cbi"); + else + ccprints("FW Config: %d (0x%x)", val, val); + #ifdef HAS_TASK_MOTIONSENSE board_update_sensor_config_from_sku(); #endif @@ -604,6 +612,7 @@ static void cbi_init(void) } DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1); +/* TODO(b/151075885) Base initialization off the fw_config */ uint32_t system_get_sku_id(void) { return sku_id; diff --git a/baseboard/zork/build.mk b/baseboard/zork/build.mk index 7709c1d6e8..740252ac9a 100644 --- a/baseboard/zork/build.mk +++ b/baseboard/zork/build.mk @@ -7,6 +7,7 @@ # baseboard-y=baseboard.o +baseboard-y+=cbi_ec_fw_config.o baseboard-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o baseboard-$(VARIANT_ZORK_TREMBYLE)+=variant_trembyle.o baseboard-$(VARIANT_ZORK_DALBOZ)+=variant_dalboz.o diff --git a/baseboard/zork/cbi_ec_fw_config.c b/baseboard/zork/cbi_ec_fw_config.c new file mode 100644 index 0000000000..d8101855f7 --- /dev/null +++ b/baseboard/zork/cbi_ec_fw_config.c @@ -0,0 +1,80 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "cbi_ec_fw_config.h" +#include "cros_board_info.h" + +/**************************************************************************** + * CBI Zork EC FW Configuration + */ +uint32_t get_cbi_fw_config(void) +{ + static uint32_t cached_fw_config = UNINITIALIZED_FW_CONFIG; + + if (cached_fw_config == UNINITIALIZED_FW_CONFIG) { + uint32_t val; + + if (cbi_get_fw_config(&val) == EC_SUCCESS) + cached_fw_config = val; + } + return cached_fw_config; +} + +/* + * get_cbi_ec_cfg_usb_db() will return the DB option number. + */ +enum ec_cfg_usb_db_type ec_config_get_usb_db(void) +{ + return ((get_cbi_fw_config() & EC_CFG_USB_DB_MASK) + >> EC_CFG_USB_DB_L); +} + +/* + * get_cbi_ec_cfg_usb_mb() will return the MB option number. + */ +enum ec_cfg_usb_mb_type ec_config_get_usb_mb(void) +{ + return ((get_cbi_fw_config() & EC_CFG_USB_MB_MASK) + >> EC_CFG_USB_MB_L); +} + +/* + * ec_config_has_lid_accel_sensor() will return ec_cfg_lid_accel_sensor_type + */ +enum ec_cfg_lid_accel_sensor_type ec_config_has_lid_accel_sensor(void) +{ + return ((get_cbi_fw_config() & EC_CFG_LID_ACCEL_SENSOR_MASK) + >> EC_CFG_LID_ACCEL_SENSOR_L); +} + +/* + * ec_config_has_base_gyro_sensor() will return ec_cfg_base_gyro_sensor_type + */ +enum ec_cfg_base_gyro_sensor_type ec_config_has_base_gyro_sensor(void) +{ + return ((get_cbi_fw_config() & EC_CFG_BASE_GYRO_SENSOR_MASK) + >> EC_CFG_BASE_GYRO_SENSOR_L); +} + +/* + * ec_config_has_pwm_keyboard_backlight() will return 1 is present or 0 + */ +enum ec_cfg_pwm_keyboard_backlight_type ec_config_has_pwm_keyboard_backlight( + void) +{ + return ((get_cbi_fw_config() & EC_CFG_PWM_KEYBOARD_BACKLIGHT_MASK) + >> EC_CFG_PWM_KEYBOARD_BACKLIGHT_L); +} + +/* + * ec_config_has_lid_angle_tablet_mode() will return 1 is present or 0 + */ +enum ec_cfg_lid_angle_tablet_mode_type ec_config_has_lid_angle_tablet_mode( + void) +{ + return ((get_cbi_fw_config() & EC_CFG_LID_ANGLE_TABLET_MODE_MASK) + >> EC_CFG_LID_ANGLE_TABLET_MODE_L); +} diff --git a/baseboard/zork/cbi_ec_fw_config.h b/baseboard/zork/cbi_ec_fw_config.h new file mode 100644 index 0000000000..9222dd9f45 --- /dev/null +++ b/baseboard/zork/cbi_ec_fw_config.h @@ -0,0 +1,111 @@ +/* Copyright 2020 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef _ZORK_CBI_EC_FW_CONFIG__H_ +#define _ZORK_CBI_EC_FW_CONFIG__H_ + +/**************************************************************************** + * CBI Zork EC FW Configuration + */ +#define UNINITIALIZED_FW_CONFIG 0xFFFFFFFF + +/* + * USB Daughter Board (4 bits) + * + * get_cbi_ec_cfg_usb_db() will return the DB option number. + * The option number will be defined in a variant or board level enumeration + */ +#define EC_CFG_USB_DB_L 0 +#define EC_CFG_USB_DB_H 3 +#define EC_CFG_USB_DB_MASK \ + GENMASK(EC_CFG_USB_DB_H,\ + EC_CFG_USB_DB_L) + +/* + * USB Main Board (4 bits) + * + * get_cbi_ec_cfg_usb_mb() will return the MB option number. + * The option number will be defined in a variant or board level enumeration + */ +#define EC_CFG_USB_MB_L 4 +#define EC_CFG_USB_MB_H 7 +#define EC_CFG_USB_MB_MASK \ + GENMASK(EC_CFG_USB_MB_H,\ + EC_CFG_USB_MB_L) + +/* + * Lid Accelerometer Sensor (3 bits) + * + * ec_config_has_lid_accel_sensor() will return ec_cfg_lid_accel_sensor_type + */ +enum ec_cfg_lid_accel_sensor_type { + LID_ACCEL_NONE = 0, + LID_ACCEL_KX022 = 1, + LID_ACCEL_LIS2DWL = 2, +}; +#define EC_CFG_LID_ACCEL_SENSOR_L 8 +#define EC_CFG_LID_ACCEL_SENSOR_H 10 +#define EC_CFG_LID_ACCEL_SENSOR_MASK \ + GENMASK(EC_CFG_LID_ACCEL_SENSOR_H,\ + EC_CFG_LID_ACCEL_SENSOR_L) + +/* + * Base Gyro Sensor (3 bits) + * + * ec_config_has_base_gyro_sensor() will return ec_cfg_base_gyro_sensor_type + */ +enum ec_cfg_base_gyro_sensor_type { + BASE_GYRO_NONE = 0, + BASE_GYRO_BMI160 = 1, + BASE_GYRO_LSM6DSM = 2, +}; +#define EC_CFG_BASE_GYRO_SENSOR_L 11 +#define EC_CFG_BASE_GYRO_SENSOR_H 13 +#define EC_CFG_BASE_GYRO_SENSOR_MASK \ + GENMASK(EC_CFG_BASE_GYRO_SENSOR_H,\ + EC_CFG_BASE_GYRO_SENSOR_L) + +/* + * PWM Keyboard Backlight (1 bit) + * + * ec_config_has_pwm_keyboard_backlight() will return 1 is present or 0 + */ +enum ec_cfg_pwm_keyboard_backlight_type { + PWM_KEYBOARD_BACKLIGHT_NO = 0, + PWM_KEYBOARD_BACKLIGHT_YES = 1, +}; +#define EC_CFG_PWM_KEYBOARD_BACKLIGHT_L 14 +#define EC_CFG_PWM_KEYBOARD_BACKLIGHT_H 14 +#define EC_CFG_PWM_KEYBOARD_BACKLIGHT_MASK \ + GENMASK(EC_CFG_PWM_KEYBOARD_BACKLIGHT_H,\ + EC_CFG_PWM_KEYBOARD_BACKLIGHT_L) + +/* + * Lid Angle Tablet Mode (1 bit) + * + * ec_config_has_lid_angle_tablet_mode() will return 1 is present or 0 + */ +enum ec_cfg_lid_angle_tablet_mode_type { + LID_ANGLE_TABLET_MODE_NO = 0, + LID_ANGLE_TABLET_MODE_YES = 1, +}; +#define EC_CFG_LID_ANGLE_TABLET_MODE_L 15 +#define EC_CFG_LID_ANGLE_TABLET_MODE_H 15 +#define EC_CFG_LID_ANGLE_TABLET_MODE_MASK \ + GENMASK(EC_CFG_LID_ANGLE_TABLET_MODE_H,\ + EC_CFG_LID_ANGLE_TABLET_MODE_L) + + +uint32_t get_cbi_fw_config(void); +enum ec_cfg_usb_db_type ec_config_get_usb_db(void); +enum ec_cfg_usb_mb_type ec_config_get_usb_mb(void); +enum ec_cfg_lid_accel_sensor_type ec_config_has_lid_accel_sensor(void); +enum ec_cfg_base_gyro_sensor_type ec_config_has_base_gyro_sensor(void); +enum ec_cfg_pwm_keyboard_backlight_type ec_config_has_pwm_keyboard_backlight( + void); +enum ec_cfg_lid_angle_tablet_mode_type ec_config_has_lid_angle_tablet_mode( + void); + +#endif /* _ZORK_CBI_EC_FW_CONFIG__H_ */ |