diff options
author | james_chao <james_chao@asus.com> | 2016-11-07 16:24:12 +0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2016-11-10 16:55:04 +0000 |
commit | 89d1b0b10e8c633eeeaac025dddb3c979ff27657 (patch) | |
tree | 0e43007b85f9a814d770d7d68b53ec704db8a317 | |
parent | b963e88b31cb4ec352b87435c8f5657aeceac303 (diff) | |
download | chrome-ec-89d1b0b10e8c633eeeaac025dddb3c979ff27657.tar.gz |
Bob: Config board Bob
1.battery info: use gru
2.PWM: use gru PWM_CH_DISPLIGHT
3.board version: replace kevin string to bob
4.sensors:
1) use gru matrix
2) Bob don't have BMA255
5.usb: Bob's usb don't support charger, remove GPIO84/GPIOC3
6.pd: Bob is 33w system, 15v/2.2a
7.led: set LED_STD_POLICY
8.GPIOs
1) GPIO36: LID_360_L->BOARD_DET (identify bob or other project use
same ec firmware)
2) GPIOB6: PWR_LED (high active)
3) GPIO44: BAT_LED_GREEN (low active & open drain)
4) GPIO80: BAT_LED_RED (low active & open drain)
5) GPIO84: NC
6) GPIOC3: NC
BUG=chrome-os-partner:59454
BRANCH=firmware-gru-8785.B
TEST=make buildall
Change-Id: Icec2fb88bee64962242843a4b9441e49d2854c6b
Signed-off-by: james_chao <james_chao@asus.com>
Reviewed-on: https://chromium-review.googlesource.com/407744
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | board/bob/battery.c | 15 | ||||
-rw-r--r-- | board/bob/board.c | 107 | ||||
-rw-r--r-- | board/bob/board.h | 21 | ||||
-rw-r--r-- | board/bob/build.mk | 1 | ||||
-rw-r--r-- | board/bob/gpio.inc | 29 | ||||
-rw-r--r-- | board/bob/led_bob.c | 130 | ||||
-rw-r--r-- | board/bob/usb_pd_policy.c | 4 |
7 files changed, 26 insertions, 281 deletions
diff --git a/board/bob/battery.c b/board/bob/battery.c index e81d7d4ecd..48bb1c8ce1 100644 --- a/board/bob/battery.c +++ b/board/bob/battery.c @@ -16,20 +16,6 @@ /* Shutdown mode parameter to write to manufacturer access register */ #define SB_SHUTDOWN_DATA 0x0010 -#ifdef BOARD_KEVIN -static const struct battery_info info = { - .voltage_max = 8688, /* 8700mA, round down for chg reg */ - .voltage_normal = 7600, - .voltage_min = 6000, - .precharge_current = 200, - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = -20, - .discharging_max_c = 70, -}; -#elif defined(BOARD_BOB) static const struct battery_info info = { .voltage_max = 8688, /* 8700mA, round down for chg reg */ .voltage_normal = 7600, @@ -42,7 +28,6 @@ static const struct battery_info info = { .discharging_min_c = -20, .discharging_max_c = 60, }; -#endif const struct battery_info *battery_get_info(void) { diff --git a/board/bob/board.c b/board/bob/board.c index e7d4b2594d..e6fc41a9bb 100644 --- a/board/bob/board.c +++ b/board/bob/board.c @@ -90,19 +90,8 @@ 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[] = { -#ifdef BOARD_KEVIN - [PWM_CH_LED_GREEN] = { 0, PWM_CONFIG_DSLEEP, 100 }, -#endif -#ifdef BOARD_KEVIN - [PWM_CH_DISPLIGHT] = { 2, 0, 210 }, -#else - /* ArcticSand part on Gru requires >= 2.6KHz */ + /* ArcticSand part on Bob requires >= 2.6KHz */ [PWM_CH_DISPLIGHT] = { 2, 0, 2600 }, -#endif - [PWM_CH_LED_RED] = { 3, PWM_CONFIG_DSLEEP, 100 }, -#ifdef BOARD_KEVIN - [PWM_CH_LED_BLUE] = { 4, PWM_CONFIG_DSLEEP, 100 }, -#endif }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); @@ -362,7 +351,7 @@ void board_hibernate(void) cflush(); } -enum kevin_board_version { +enum bob_board_version { BOARD_VERSION_UNKNOWN = -1, BOARD_VERSION_REV0 = 0, BOARD_VERSION_REV1 = 1, @@ -384,9 +373,9 @@ enum kevin_board_version { }; struct { - enum kevin_board_version version; + enum bob_board_version version; int expect_mv; -} const kevin_boards[] = { +} const bob_boards[] = { { BOARD_VERSION_REV0, 109 }, /* 51.1K , 2.2K(gru 3.3K) ohm */ { BOARD_VERSION_REV1, 211 }, /* 51.1k , 6.8K ohm */ { BOARD_VERSION_REV2, 319 }, /* 51.1K , 11K ohm */ @@ -404,9 +393,9 @@ struct { { BOARD_VERSION_REV14, 1684 }, /* 47K , 680K ohm */ { BOARD_VERSION_REV15, 1800 }, /* 56K , NC */ }; -BUILD_ASSERT(ARRAY_SIZE(kevin_boards) == BOARD_VERSION_COUNT); +BUILD_ASSERT(ARRAY_SIZE(bob_boards) == BOARD_VERSION_COUNT); -#define THRESHHOLD_MV 56 /* Simply assume 1800/16/2 */ +#define THRESHOLD_MV 56 /* Simply assume 1800/16/2 */ int board_get_version(void) { @@ -429,8 +418,8 @@ int board_get_version(void) gpio_set_level(GPIO_EC_BOARD_ID_EN_L, 1); for (i = 0; i < BOARD_VERSION_COUNT; ++i) { - if (mv < kevin_boards[i].expect_mv + THRESHHOLD_MV) { - version = kevin_boards[i].version; + if (mv < bob_boards[i].expect_mv + THRESHOLD_MV) { + version = bob_boards[i].version; break; } } @@ -444,25 +433,6 @@ int board_get_version(void) static struct mutex g_base_mutex; static struct mutex g_lid_mutex; -#ifdef BOARD_KEVIN -/* BMA255 private data */ -struct bma2x2_accel_data g_bma255_data = { - .variant = BMA255, -}; - -/* Matrix to rotate accelrator into standard reference frame */ -const matrix_3x3_t base_standard_ref = { - { 0, FLOAT_TO_FP(1), 0}, - { FLOAT_TO_FP(1), 0, 0}, - { 0, 0, FLOAT_TO_FP(-1)} -}; - -const matrix_3x3_t lid_standard_ref = { - { 0, FLOAT_TO_FP(1), 0}, - { FLOAT_TO_FP(-1), 0, 0}, - { 0, 0, FLOAT_TO_FP(1)} -}; -#else /* Matrix to rotate accelerometer into standard reference frame */ const matrix_3x3_t base_standard_ref = { { FLOAT_TO_FP(-1), 0, 0}, @@ -478,7 +448,6 @@ const matrix_3x3_t lid_standard_ref = { /* KX022 private data */ struct kionix_accel_data g_kx022_data; -#endif /* BOARD_KEVIN */ struct motion_sensor_t motion_sensors[] = { /* @@ -534,11 +503,7 @@ struct motion_sensor_t motion_sensors[] = { .port = CONFIG_SPI_ACCEL_PORT, .addr = BMI160_SET_SPI_ADDRESS(CONFIG_SPI_ACCEL_PORT), .default_range = 1000, /* dps */ -#ifdef BOARD_KEVIN - .rot_standard_ref = &base_standard_ref, -#else .rot_standard_ref = NULL, /* Identity matrix. */ -#endif .config = { /* AP: by default shutdown all sensors */ [SENSOR_CONFIG_AP] = { @@ -562,43 +527,6 @@ struct motion_sensor_t motion_sensors[] = { }, }, }, -#ifdef BOARD_KEVIN - [LID_ACCEL] = { - .name = "Lid Accel", - .active_mask = SENSOR_ACTIVE_S0_S3, - .chip = MOTIONSENSE_CHIP_BMA255, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &bma2x2_accel_drv, - .mutex = &g_lid_mutex, - .drv_data = &g_bma255_data, - .port = I2C_PORT_ACCEL, - .addr = BMA2x2_I2C_ADDR1, - .rot_standard_ref = &lid_standard_ref, - .default_range = 2, /* g, enough for laptop. */ - .config = { - /* AP: by default use EC settings */ - [SENSOR_CONFIG_AP] = { - .odr = 0, - .ec_rate = 0, - }, - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 0, - }, - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 10000 | ROUND_UP_FLAG, - .ec_rate = 0, - }, - [SENSOR_CONFIG_EC_S5] = { - .odr = 0, - .ec_rate = 0, - }, - }, - }, -#else [LID_ACCEL] = { .name = "Lid Accel", .active_mask = SENSOR_ACTIVE_S0_S3, @@ -634,7 +562,6 @@ struct motion_sensor_t motion_sensors[] = { }, }, }, -#endif /* BOARD_KEVIN */ }; const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); #endif /* defined(HAS_TASK_MOTIONSENSE) */ @@ -649,24 +576,6 @@ void lid_angle_peripheral_enable(int enable) } #endif -#ifdef BOARD_GRU -static void usb_charge_resume(void) -{ - /* Turn on USB-A ports on as we go into S0 from S3. */ - gpio_set_level(GPIO_USB_A_EN, 1); - gpio_set_level(GPIO_USB_A_CHARGE_EN, 1); -} -DECLARE_HOOK(HOOK_CHIPSET_RESUME, usb_charge_resume, HOOK_PRIO_DEFAULT); - -static void usb_charge_shutdown(void) -{ - /* Turn off USB-A ports as we go back to S5. */ - gpio_set_level(GPIO_USB_A_CHARGE_EN, 0); - gpio_set_level(GPIO_USB_A_EN, 0); -} -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usb_charge_shutdown, HOOK_PRIO_DEFAULT); -#endif - #define PWM_DISPLIGHT_SYSJUMP_TAG 0x5044 /* "PD" */ #define PWM_HOOK_VERSION 1 diff --git a/board/bob/board.h b/board/bob/board.h index 240d80a267..5654a9c8ba 100644 --- a/board/bob/board.h +++ b/board/bob/board.h @@ -18,7 +18,9 @@ #define CONFIG_I2C_MASTER #define CONFIG_I2C_VIRTUAL_BATTERY #define CONFIG_I2C_PASSTHRU_RESTRICTED +#define CONFIG_LED_BAT_ACTIVE_LOW #define CONFIG_LED_COMMON +#define CONFIG_LED_POLICY_STD #define CONFIG_LOW_POWER_IDLE #define CONFIG_POWER_COMMON #define CONFIG_PWM @@ -26,9 +28,7 @@ #define CONFIG_SPI #define CONFIG_SPI_MASTER -#ifdef BOARD_GRU #define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands for testing */ -#endif /* * We are code space-constrained on kevin, so take 10K that is normally used @@ -78,7 +78,6 @@ #define CONFIG_UART_TX_BUF_SIZE 4096 /* Motion Sensors */ -#define CONFIG_ACCEL_BMA255 #define CONFIG_ACCEL_KX022 #define CONFIG_ACCELGYRO_BMI160 #define CONFIG_ACCEL_INTERRUPTS @@ -127,14 +126,12 @@ #define CONFIG_BATTERY_REVIVE_DISCONNECT #define CONFIG_BATTERY_SMART -#ifdef BOARD_KEVIN #define CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD -#endif #define PD_OPERATING_POWER_MW 15000 -#define PD_MAX_POWER_MW 60000 -#define PD_MAX_CURRENT_MA 3000 -#define PD_MAX_VOLTAGE_MV 20000 +#define PD_MAX_POWER_MW 33000 +#define PD_MAX_CURRENT_MA 2200 +#define PD_MAX_VOLTAGE_MV 15000 #define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */ #define PD_POWER_SUPPLY_TURN_OFF_DELAY 50000 /* us */ @@ -213,14 +210,8 @@ enum adc_channel { }; enum pwm_channel { -#ifdef BOARD_KEVIN - PWM_CH_LED_GREEN, -#endif PWM_CH_DISPLIGHT, - PWM_CH_LED_RED, -#ifdef BOARD_KEVIN - PWM_CH_LED_BLUE, -#endif + /* Number of PWM channels */ PWM_CH_COUNT }; diff --git a/board/bob/build.mk b/board/bob/build.mk index 12ee2842a5..1d6e5cf98d 100644 --- a/board/bob/build.mk +++ b/board/bob/build.mk @@ -11,4 +11,3 @@ CHIP:=npcx CHIP_VARIANT:=npcx5m5g board-y=battery.o board.o usb_pd_policy.o -board-$(BOARD_BOB)+=led_bob.o diff --git a/board/bob/gpio.inc b/board/bob/gpio.inc index 4382abd9d5..979108ded9 100644 --- a/board/bob/gpio.inc +++ b/board/bob/gpio.inc @@ -58,9 +58,6 @@ GPIO(PP900_PMU_EN, PIN(C, 2), GPIO_OUT_LOW) GPIO(PP900_USB_EN, PIN(A, 5), GPIO_OUT_LOW) GPIO(PP900_PCIE_EN, PIN(0, 0), GPIO_OUT_LOW) -/* NC */ -GPIO(GPIO81_NC, PIN(8, 1), GPIO_INPUT | GPIO_PULL_UP) - GPIO(PP1800_SENSOR_EN_L, PIN(A, 7), GPIO_OUT_HIGH) GPIO(PP1800_USB_EN_L, PIN(A, 6), GPIO_OUT_HIGH) GPIO(PP1800_LID_EN_L, PIN(B, 0), GPIO_OUT_HIGH) @@ -107,7 +104,6 @@ GPIO(USB_DP_HPD, PIN(6, 6), GPIO_OUT_LOW) GPIO(CHARGER_RESET_L, PIN(0, 1), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) GPIO(TPM_ALLOW_RST, PIN(0, 2), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) GPIO(EC_BATT_PRES_L, PIN(3, 4), GPIO_INPUT) -GPIO(LID_360_L, PIN(3, 6), GPIO_INPUT | GPIO_SEL_1P8V) GPIO(CCD_MODE_ODL, PIN(6, 3), GPIO_INPUT | GPIO_PULL_UP) GPIO(PP3300_S0_EN_L, PIN(7, 0), GPIO_OUT_HIGH) GPIO(SPI_SENSOR_CS_L, PIN(9, 4), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) @@ -115,13 +111,18 @@ GPIO(SPI_SENSOR_CS_L, PIN(9, 4), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) GPIO(USB_C0_DISCHARGE, PIN(0, 3), GPIO_OUT_LOW) GPIO(USB_C1_DISCHARGE, PIN(B, 1), GPIO_OUT_LOW) -#if defined(BOARD_KEVIN) +/* Bob LEDs */ +GPIO(POWER_LED, PIN(B, 6), GPIO_OUT_LOW) +GPIO(BAT_LED_GREEN, PIN(4, 4), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) +GPIO(BAT_LED_RED, PIN(8, 0), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN) + +GPIO(BOARD_DET, PIN(3, 6), GPIO_INPUT) + +/* NC */ +GPIO(GPIO81_NC, PIN(8, 1), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIO84_NC, PIN(8, 4), GPIO_INPUT | GPIO_PULL_UP) -#elif defined(BOARD_GRU) -GPIO(USB_A_EN, PIN(C, 3), GPIO_OUT_LOW) -GPIO(USB_A_CHARGE_EN, PIN(8, 4), GPIO_OUT_LOW) GPIO(GPIOB6_NC, PIN(B, 6), GPIO_INPUT | GPIO_PULL_UP) -#endif +GPIO(GPIOC3_NC, PIN(C, 3), GPIO_INPUT | GPIO_PULL_UP) /* * SPI host interface - enable PDs by default. These will be made functional @@ -148,16 +149,6 @@ ALTERNATE(PIN_MASK(9, 0x07), 1, MODULE_I2C, 0) ALTERNATE(PIN_MASK(D, 0x03), 1, MODULE_I2C, 0) /* PWM2 / BLPWM */ ALTERNATE(PIN_MASK(C, 0x10), 1, MODULE_PWM, 0) -/* PWM3 / LED_RED(net LED_CHARGE) */ -ALTERNATE(PIN_MASK(8, 0x01), 1, MODULE_PWM, 0) - -/* Kevin-only LEDs */ -#ifdef BOARD_KEVIN -/* PWM0 / LED_GREEN(net LED_ACIN) */ -ALTERNATE(PIN_MASK(C, 0x08), 1, MODULE_PWM, 0) -/* PWM4 / LED_BLUE(net LED_POWER) */ -ALTERNATE(PIN_MASK(B, 0x40), 1, MODULE_PWM, 0) -#endif /* CR_SIN/SOUT GPIO64/65 */ ALTERNATE(PIN_MASK(6, 0x30), 1, MODULE_UART, GPIO_PULL_UP) diff --git a/board/bob/led_bob.c b/board/bob/led_bob.c deleted file mode 100644 index cbe59a2ad8..0000000000 --- a/board/bob/led_bob.c +++ /dev/null @@ -1,130 +0,0 @@ -/* Copyright 2016 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. - * - * gru battery LED control - derived from standard policy with PWM - * color control rather than GPIO. - */ - -#include "battery.h" -#include "charge_state.h" -#include "chipset.h" -#include "hooks.h" -#include "led_common.h" -#include "lid_switch.h" -#include "pwm.h" -#include "util.h" - -#define GRU_BAT_LED_PWM PWM_CH_LED_RED - -const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED }; - -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -enum led_color { - LED_OFF = 0, - LED_RED, - LED_AMBER, - LED_GREEN, - LED_COLOR_COUNT /* Number of colors, not a color itself */ -}; - -/* One LED active at a time. PWM low period determines which LED is active. */ -static const int led_color_to_pwm_duty[LED_COLOR_COUNT] = { - [LED_OFF] = 100, - [LED_RED] = 0, - [LED_AMBER] = 80, - [LED_GREEN] = 85, -}; - -static int bat_led_set_color(enum led_color color) -{ - pwm_set_duty(GRU_BAT_LED_PWM, led_color_to_pwm_duty[color]); - return EC_SUCCESS; -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - switch (led_id) { - case EC_LED_ID_BATTERY_LED: - brightness_range[EC_LED_COLOR_RED] = 1; - brightness_range[EC_LED_COLOR_AMBER] = 1; - brightness_range[EC_LED_COLOR_GREEN] = 1; - break; - default: - /* ignore */ - break; - } -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - switch (led_id) { - case EC_LED_ID_BATTERY_LED: - if (brightness[EC_LED_COLOR_RED] != 0) - bat_led_set_color(LED_RED); - else if (brightness[EC_LED_COLOR_AMBER] != 0) - bat_led_set_color(LED_AMBER); - else if (brightness[EC_LED_COLOR_GREEN] != 0) - bat_led_set_color(LED_GREEN); - else - bat_led_set_color(LED_OFF); - break; - default: - return EC_ERROR_UNKNOWN; - } - return EC_SUCCESS; -} - -static void gru_led_set_battery(void) -{ - static int battery_second; - uint32_t chflags = charge_get_flags(); - - battery_second++; - - /* - * BAT LED behavior: Follow chromeos specification. - * Green/Amber for CHARGE_FLAG_FORCE_IDLE - */ - switch (charge_get_state()) { - case PWR_STATE_CHARGE: - bat_led_set_color(LED_AMBER); - break; - case PWR_STATE_DISCHARGE: - if (charge_get_percent() < 3) - bat_led_set_color((battery_second & 1) - ? LED_OFF : LED_AMBER); - else if (charge_get_percent() < 10) - bat_led_set_color((battery_second & 3) - ? LED_OFF : LED_AMBER); - else - bat_led_set_color(LED_OFF); - break; - case PWR_STATE_ERROR: - bat_led_set_color((battery_second & 1) ? LED_OFF : LED_RED); - break; - case PWR_STATE_CHARGE_NEAR_FULL: - bat_led_set_color(LED_GREEN); - break; - case PWR_STATE_IDLE: /* External power connected in IDLE. */ - if (chflags & CHARGE_FLAG_FORCE_IDLE) - bat_led_set_color( - (battery_second & 0x2) ? LED_GREEN : LED_AMBER); - else - bat_led_set_color(LED_GREEN); - break; - default: - /* Other states don't alter LED behavior */ - break; - } -} - -/* Called by hook task every 1 sec */ -static void led_second(void) -{ - if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) - gru_led_set_battery(); -} -DECLARE_HOOK(HOOK_SECOND, led_second, HOOK_PRIO_DEFAULT); - diff --git a/board/bob/usb_pd_policy.c b/board/bob/usb_pd_policy.c index 6dd571ad34..59518d3aed 100644 --- a/board/bob/usb_pd_policy.c +++ b/board/bob/usb_pd_policy.c @@ -37,8 +37,8 @@ const int pd_src_pdo_max_cnt = ARRAY_SIZE(pd_src_pdo_max); const uint32_t pd_snk_pdo[] = { PDO_FIXED(5000, 500, PDO_FIXED_FLAGS), - PDO_BATT(4750, 21000, 15000), - PDO_VAR(4750, 21000, 3000), + PDO_BATT(4750, 15500, 15000), + PDO_VAR(4750, 15500, 2200), }; const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); |