diff options
author | Alex1 Kao <alex1_kao@pegatron.corp-partner.google.com> | 2021-05-03 10:49:53 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-05 06:57:42 +0000 |
commit | 90ff2e74092bc13b9ef6eee8efddaed5670df1d5 (patch) | |
tree | dc903bb0d3732fda03f7c5802f6a3d83effa5d7a | |
parent | 0a6f9f0dc91ec6a570268b8a7a556baedde11889 (diff) | |
download | chrome-ec-90ff2e74092bc13b9ef6eee8efddaed5670df1d5.tar.gz |
pirika: Sync EC GPIO and LED setting with galtic
Sync EC GPIO and LED setting with galtic
BUG=b:186704225
BRANCH=none
TEST=BOARD=pirika and pirette
Change-Id: Iedaa7cecfed7e2734fcb8e719e04588d65319018
Signed-off-by: Alex1 Kao <alex1_kao@pegatron.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2866028
Reviewed-by: Kirk Wang <kirk_wang@pegatron.corp-partner.google.com>
Reviewed-by: Shou-Chieh Hsu <shouchieh@chromium.org>
Commit-Queue: Shou-Chieh Hsu <shouchieh@chromium.org>
-rw-r--r-- | board/pirika/board.c | 82 | ||||
-rw-r--r-- | board/pirika/board.h | 16 | ||||
-rw-r--r-- | board/pirika/gpio.inc | 33 | ||||
-rw-r--r-- | board/pirika/led.c | 137 |
4 files changed, 164 insertions, 104 deletions
diff --git a/board/pirika/board.c b/board/pirika/board.c index 0582864dac..bc3e92cc09 100644 --- a/board/pirika/board.c +++ b/board/pirika/board.c @@ -144,12 +144,12 @@ const struct adc_t adc_channels[] = { .shift = 0, .channel = CHIP_ADC_CH3 }, - [ADC_SUB_ANALOG] = { - .name = "SUB_ANALOG", + [ADC_TEMP_SENSOR_3] = { + .name = "TEMP_SENSOR3", .factor_mul = ADC_MAX_MVOLT, .factor_div = ADC_READ_MAX + 1, .shift = 0, - .channel = CHIP_ADC_CH13 + .channel = CHIP_ADC_CH15 }, }; BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); @@ -539,25 +539,6 @@ const struct pwm_t pwm_channels[] = { .flags = PWM_CONFIG_DSLEEP, .freq_hz = 10000, }, - - [PWM_CH_LED_RED] = { - .channel = 1, - .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, - .freq_hz = 2400, - }, - - [PWM_CH_LED_GREEN] = { - .channel = 2, - .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, - .freq_hz = 2400, - }, - - [PWM_CH_LED_BLUE] = { - .channel = 3, - .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW, - .freq_hz = 2400, - } - }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); @@ -650,17 +631,55 @@ const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); /* Thermistors */ const struct temp_sensor_t temp_sensors[] = { - [TEMP_SENSOR_1] = {.name = "Memory", + [TEMP_SENSOR_1] = {.name = "Charger", .type = TEMP_SENSOR_TYPE_BOARD, .read = get_temp_3v3_51k1_47k_4050b, .idx = ADC_TEMP_SENSOR_1}, - [TEMP_SENSOR_2] = {.name = "Ambient", + [TEMP_SENSOR_2] = {.name = "Vcore", .type = TEMP_SENSOR_TYPE_BOARD, .read = get_temp_3v3_51k1_47k_4050b, .idx = ADC_TEMP_SENSOR_2}, + [TEMP_SENSOR_3] = {.name = "Ambient", + .type = TEMP_SENSOR_TYPE_BOARD, + .read = get_temp_3v3_51k1_47k_4050b, + .idx = ADC_TEMP_SENSOR_3}, }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); +const static struct ec_thermal_config thermal_charger = { + .temp_host = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(85), + [EC_TEMP_THRESH_HALT] = C_TO_K(98), + }, + .temp_host_release = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(65), + }, +}; +const static struct ec_thermal_config thermal_vcore = { + .temp_host = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(65), + [EC_TEMP_THRESH_HALT] = C_TO_K(80), + }, + .temp_host_release = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(50), + }, +}; +const static struct ec_thermal_config thermal_ambient = { + .temp_host = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(65), + [EC_TEMP_THRESH_HALT] = C_TO_K(80), + }, + .temp_host_release = { + [EC_TEMP_THRESH_HIGH] = C_TO_K(50), + }, +}; +struct ec_thermal_config thermal_params[] = { + [TEMP_SENSOR_1] = thermal_charger, + [TEMP_SENSOR_2] = thermal_vcore, + [TEMP_SENSOR_3] = thermal_ambient, +}; +BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); + #ifndef TEST_BUILD /* This callback disables keyboard when convertibles are fully open */ void lid_angle_peripheral_enable(int enable) @@ -688,3 +707,18 @@ void lid_angle_peripheral_enable(int enable) } } #endif + +__override void board_pulse_entering_rw(void) +{ + /* + * On the ITE variants, the EC_ENTERING_RW signal was connected to a pin + * which is active high by default. This cause Cr50 to think that the + * EC has jumped to its RW image even though this may not be the case. + * The pin is changed to GPIO_EC_ENTERING_RW2. + */ + gpio_set_level(GPIO_EC_ENTERING_RW, 1); + gpio_set_level(GPIO_EC_ENTERING_RW2, 1); + usleep(MSEC); + gpio_set_level(GPIO_EC_ENTERING_RW, 0); + gpio_set_level(GPIO_EC_ENTERING_RW2, 0); +} diff --git a/board/pirika/board.h b/board/pirika/board.h index 4c3f8f9cac..b4a0dbe0df 100644 --- a/board/pirika/board.h +++ b/board/pirika/board.h @@ -37,8 +37,8 @@ #define GPIO_USB_C1_INT_ODL GPIO_SUB_USB_C1_INT_ODL /* LED */ -#define CONFIG_LED_PWM -#define CONFIG_LED_PWM_COUNT 1 +#define CONFIG_LED_ONOFF_STATES +#define CONFIG_LED_ONOFF_STATES_BAT_LOW 10 /* PWM */ #define CONFIG_PWM @@ -79,6 +79,7 @@ #define CONFIG_THERMISTOR #define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B #define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_EN_PP3300_A +#define CONFIG_THROTTLE_AP /* USB Mux and Retimer */ #define CONFIG_USB_MUX_IT5205 /* C1: ITE Mux */ @@ -86,6 +87,11 @@ #define CONFIG_USBC_RETIMER_TUSB544 /* C1 Redriver: TUSB544 */ +/* Keyboard */ +#define CONFIG_KEYBOARD_VIVALDI +#define CONFIG_KEYBOARD_REFRESH_ROW3 +#define CONFIG_KEYBOARD_KEYPAD + #ifndef __ASSEMBLER__ #include "gpio_signal.h" @@ -99,9 +105,6 @@ enum chg_id { enum pwm_channel { PWM_CH_KBLIGHT, - PWM_CH_LED_RED, - PWM_CH_LED_GREEN, - PWM_CH_LED_BLUE, PWM_CH_COUNT, }; @@ -118,13 +121,14 @@ enum adc_channel { ADC_VSNS_PP3300_A, /* ADC0 */ ADC_TEMP_SENSOR_1, /* ADC2 */ ADC_TEMP_SENSOR_2, /* ADC3 */ - ADC_SUB_ANALOG, /* ADC13 */ + ADC_TEMP_SENSOR_3, /* ADC15 */ ADC_CH_COUNT }; enum temp_sensor_id { TEMP_SENSOR_1, TEMP_SENSOR_2, + TEMP_SENSOR_3, TEMP_SENSOR_COUNT }; diff --git a/board/pirika/gpio.inc b/board/pirika/gpio.inc index 8100fa9347..e5b5f1543f 100644 --- a/board/pirika/gpio.inc +++ b/board/pirika/gpio.inc @@ -79,44 +79,53 @@ GPIO(EC_I2C_USB_C0_SCL, PIN(A, 4), GPIO_INPUT) GPIO(EC_I2C_USB_C0_SDA, PIN(A, 5), GPIO_INPUT) /* USB pins */ -GPIO(EN_USB_C0_CC1_VCONN, PIN(H, 4), GPIO_OUT_LOW) -GPIO(EN_USB_C0_CC2_VCONN, PIN(H, 6), GPIO_OUT_LOW) GPIO(EC_AP_USB_C0_HPD, PIN(L, 4), GPIO_OUT_LOW) GPIO(EC_AP_USB_C1_HDMI_HPD, PIN(K, 7), GPIO_OUT_LOW) -GPIO(USB_C0_FRS, PIN(C, 4), GPIO_OUT_LOW) -GPIO(HDMI_SEL_L, PIN(C, 6), GPIO_OUT_HIGH) GPIO(EN_USB_A0_VBUS, PIN(L, 6), GPIO_OUT_LOW) /* Board rev 1, NC board rev 0 */ /* MKBP event synchronization */ GPIO(EC_AP_MKBP_INT_L, PIN(L, 5), GPIO_ODR_HIGH) /* Misc pins which will run to the I/O board */ -GPIO(EC_SUB_IO_1_1, PIN(L, 3), GPIO_INPUT) -GPIO(EC_SUB_IO_1_2, PIN(F, 0), GPIO_INPUT) -GPIO(EC_SUB_IO_2_1, PIN(F, 1), GPIO_INPUT) -GPIO(EC_SUB_IO_2_2, PIN(L, 2), GPIO_INPUT) /* Misc */ GPIO(EN_BL_OD, PIN(K, 4), GPIO_ODR_LOW) GPIO(EC_ENTERING_RW, PIN(G, 0), GPIO_OUT_LOW) +GPIO(EC_ENTERING_RW2, PIN(C, 7), GPIO_OUT_LOW) GPIO(CCD_MODE_ODL, PIN(H, 5), GPIO_INPUT) GPIO(EC_BATTERY_PRES_ODL, PIN(I, 4), GPIO_INPUT) -GPIO(PEN_DET_ODL, PIN(J, 1), GPIO_INPUT | GPIO_PULL_UP) -GPIO(EN_KB_BL, PIN(J, 3), GPIO_OUT_LOW) /* Currently unused */ GPIO(ECH1_PACKET_MODE, PIN(H, 1), GPIO_OUT_LOW) +/* LED */ +GPIO(LED_R_ODL, PIN(A, 1), GPIO_OUT_HIGH) +GPIO(LED_G_ODL, PIN(A, 2), GPIO_OUT_HIGH) + /* NC pins, enable internal pull-down to avoid floating state. */ +GPIO(GPIOA0_NC, PIN(A, 0), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOA3_NC, PIN(A, 3), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOB5_NC, PIN(B, 5), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOC0_NC, PIN(C, 0), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOC3_NC, PIN(C, 3), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOC4_NC, PIN(C, 4), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOC6_NC, PIN(C, 6), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOF0_NC, PIN(F, 0), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOF1_NC, PIN(F, 1), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOF4_NC, PIN(F, 4), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOF5_NC, PIN(F, 5), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOG3_NC, PIN(G, 3), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOG4_NC, PIN(G, 4), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOG5_NC, PIN(G, 5), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOG6_NC, PIN(G, 6), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOG7_NC, PIN(G, 7), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOH4_NC, PIN(H, 4), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOH6_NC, PIN(H, 6), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOJ1_NC, PIN(J, 1), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOJ3_NC, PIN(J, 3), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOJ4_NC, PIN(J, 4), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOJ5_NC, PIN(J, 5), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOJ6_NC, PIN(J, 6), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOL0_NC, PIN(L, 0), GPIO_INPUT | GPIO_PULL_DOWN) +GPIO(GPIOL3_NC, PIN(L, 3), GPIO_INPUT | GPIO_PULL_DOWN) GPIO(GPIOM6_NC, PIN(M, 6), GPIO_INPUT | GPIO_PULL_DOWN) /* Alternate functions GPIO definitions */ @@ -131,8 +140,6 @@ ALTERNATE(PIN_MASK(E, BIT(0) | BIT(7)), 0, MODULE_I2C, 0) /* I2C4 */ ALTERNATE(PIN_MASK(A, BIT(4) | BIT(5)), 0, MODULE_I2C, 0) /* I2C5 */ /* ADC */ -ALTERNATE(PIN_MASK(L, BIT(0)), 0, MODULE_ADC, 0) /* ADC13: EC_SUB_ANALOG */ +ALTERNATE(PIN_MASK(L, BIT(2)), 0, MODULE_ADC, 0) /* ADC15: TEMP_SENSOR_3 */ ALTERNATE(PIN_MASK(I, BIT(0) | BIT(2) | BIT(3)), 0, MODULE_ADC, 0) /* ADC0: EC_VSNS_PP3300_A, ADC2: TEMP_SENSOR_1, ADC3: TEMP_SENSOR_2 */ -/* PWM */ -ALTERNATE(PIN_MASK(A, BIT(0) | BIT(1) | BIT(2) | BIT(3)), 0, MODULE_PWM, 0) /* KB_BL_PWM, LED_[R,G,B]_ODL */ diff --git a/board/pirika/led.c b/board/pirika/led.c index 1c64d7c7d5..2fe70f5fe8 100644 --- a/board/pirika/led.c +++ b/board/pirika/led.c @@ -3,80 +3,95 @@ * found in the LICENSE file. */ -/* Waddledee specific PWM LED settings. */ - -#include "common.h" +#include "chipset.h" #include "ec_commands.h" -#include "led_pwm.h" -#include "pwm.h" -#include "util.h" +#include "gpio.h" +#include "led_common.h" +#include "led_onoff_states.h" -const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_POWER_LED, -}; -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); +#define LED_OFF_LVL 1 +#define LED_ON_LVL 0 -/* - * Board has one physical LED with red, green, and blue - */ -struct pwm_led led_color_map[EC_LED_COLOR_COUNT] = { - /* Red, Green, Blue */ - [EC_LED_COLOR_RED] = { 100, 0, 0 }, - [EC_LED_COLOR_GREEN] = { 0, 100, 0 }, - [EC_LED_COLOR_BLUE] = { 0, 0, 100 }, - [EC_LED_COLOR_YELLOW] = { 50, 50, 0 }, - [EC_LED_COLOR_WHITE] = { 50, 50, 50 }, - [EC_LED_COLOR_AMBER] = { 70, 30, 0 }, +__override const int led_charge_lvl_1; +__override const int led_charge_lvl_2 = 95; + +__override struct led_descriptor + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, + [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, + [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, + [STATE_DISCHARGE_S0] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, + [STATE_DISCHARGE_S0_BAT_LOW] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, + {LED_OFF, 3 * LED_ONE_SEC} }, + [STATE_DISCHARGE_S3] = {{EC_LED_COLOR_WHITE, 2 * LED_ONE_SEC}, + {LED_OFF, 2 * LED_ONE_SEC} }, + [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} }, + [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, + {LED_OFF, 1 * LED_ONE_SEC} }, + [STATE_FACTORY_TEST] = {{EC_LED_COLOR_WHITE, 2 * LED_ONE_SEC}, + {EC_LED_COLOR_AMBER, 2 * LED_ONE_SEC} }, }; -/* One logical LED with red, green, and blue channels. */ -struct pwm_led pwm_leds[CONFIG_LED_PWM_COUNT] = { - { - .ch0 = PWM_CH_LED_RED, - .ch1 = PWM_CH_LED_GREEN, - .ch2 = PWM_CH_LED_BLUE, - .enable = &pwm_enable, - .set_duty = &pwm_set_duty, - }, +const enum ec_led_id supported_led_ids[] = { + EC_LED_ID_BATTERY_LED, }; +const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); + +__override void led_set_color_battery(enum ec_led_colors color) +{ + switch (color) { + case EC_LED_COLOR_WHITE: + gpio_set_level(GPIO_LED_R_ODL, LED_OFF_LVL); + gpio_set_level(GPIO_LED_G_ODL, LED_ON_LVL); + break; + case EC_LED_COLOR_AMBER: + gpio_set_level(GPIO_LED_R_ODL, LED_ON_LVL); + gpio_set_level(GPIO_LED_G_ODL, LED_OFF_LVL); + break; + default: /* LED_OFF and other unsupported colors */ + gpio_set_level(GPIO_LED_R_ODL, LED_OFF_LVL); + gpio_set_level(GPIO_LED_G_ODL, LED_OFF_LVL); + break; + } +} + void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) { - memset(brightness_range, '\0', - sizeof(*brightness_range) * EC_LED_COLOR_COUNT); - brightness_range[EC_LED_COLOR_RED] = 100; - brightness_range[EC_LED_COLOR_GREEN] = 100; - brightness_range[EC_LED_COLOR_BLUE] = 100; - brightness_range[EC_LED_COLOR_YELLOW] = 100; - brightness_range[EC_LED_COLOR_WHITE] = 100; - brightness_range[EC_LED_COLOR_AMBER] = 100; + if (led_id == EC_LED_ID_BATTERY_LED) { + brightness_range[EC_LED_COLOR_WHITE] = 1; + brightness_range[EC_LED_COLOR_AMBER] = 1; + } } int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) { - enum pwm_led_id pwm_id; - - /* Convert ec_led_id to pwm_led_id. */ - if (led_id == EC_LED_ID_POWER_LED) - pwm_id = PWM_LED0; - else - return EC_ERROR_UNKNOWN; + if (led_id == EC_LED_ID_BATTERY_LED) { + if (brightness[EC_LED_COLOR_WHITE] != 0) + led_set_color_battery(EC_LED_COLOR_WHITE); + else if (brightness[EC_LED_COLOR_AMBER] != 0) + led_set_color_battery(EC_LED_COLOR_AMBER); + else + led_set_color_battery(LED_OFF); + } + return EC_SUCCESS; +} - if (brightness[EC_LED_COLOR_RED]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_RED); - else if (brightness[EC_LED_COLOR_GREEN]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_GREEN); - else if (brightness[EC_LED_COLOR_BLUE]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_BLUE); - else if (brightness[EC_LED_COLOR_YELLOW]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_YELLOW); - else if (brightness[EC_LED_COLOR_WHITE]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_WHITE); - else if (brightness[EC_LED_COLOR_AMBER]) - set_pwm_led_color(pwm_id, EC_LED_COLOR_AMBER); - else - /* Otherwise, the "color" is "off". */ - set_pwm_led_color(pwm_id, -1); +__override enum led_states board_led_get_state(enum led_states desired_state) +{ + /* Battery error LED behavior as below: + * S0: Blinking Amber LED, 1s on/ 1s off + * S3/S5: following S3/S5 behavior + * Add function to let battery error LED follow S3/S5 behavior in S3/S5. + */ - return EC_SUCCESS; + if (desired_state == STATE_BATTERY_ERROR) { + if (chipset_in_state(CHIPSET_STATE_ON)) + return desired_state; + else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) + return STATE_DISCHARGE_S3; + else + return STATE_DISCHARGE_S5; + } + return desired_state; } |