diff options
author | earlwang <earl_wang@compal.corp-partner.google.com> | 2021-08-17 19:05:24 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-08-25 18:34:11 +0000 |
commit | c50f9a2f7233404c34b31323fdf7ca2673386d7e (patch) | |
tree | 63def2494fb100fa83e5b2ae19e744e8f44d8be4 /board/corori | |
parent | e85e80744d3f5777077d6970dc8a2a854ccf21ee (diff) | |
download | chrome-ec-c50f9a2f7233404c34b31323fdf7ca2673386d7e.tar.gz |
Corori:Initial EC image GPIO
Initial gpio for corori
BUG=b:194356176
BRANCH=keeby
TEST=make -j BOARD=corori success
Signed-off-by: earlwang <earl_wang@compal.corp-partner.google.com>
Change-Id: I0065af9b0738775d2b4d06fea7acc60a0abb298b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3099430
Reviewed-by: SamSP Liu <samsp_liu@compal.corp-partner.google.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Josh Tsai <josh_tsai@compal.corp-partner.google.com>
Reviewed-by: Elmo Lan <elmo_lan@compal.corp-partner.google.com>
Tested-by: SamSP Liu <samsp_liu@compal.corp-partner.google.com>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/corori')
-rw-r--r-- | board/corori/board.c | 73 | ||||
-rw-r--r-- | board/corori/board.h | 9 | ||||
-rw-r--r-- | board/corori/gpio.inc | 19 |
3 files changed, 14 insertions, 87 deletions
diff --git a/board/corori/board.c b/board/corori/board.c index c0ad1eaf36..86425347fc 100644 --- a/board/corori/board.c +++ b/board/corori/board.c @@ -33,8 +33,6 @@ #include "lid_switch.h" #include "power.h" #include "power_button.h" -#include "pwm.h" -#include "pwm_chip.h" #include "stdbool.h" #include "switch.h" #include "system.h" @@ -51,7 +49,6 @@ #define ADC_VOL_UP_MASK BIT(0) #define ADC_VOL_DOWN_MASK BIT(1) -static uint8_t new_adc_key_state; /******************************************************************************/ /* USB-A Configuration */ @@ -143,6 +140,12 @@ static void usb_c0_interrupt(enum gpio_signal s) } +static void c0_ccsbu_ovp_interrupt(enum gpio_signal s) +{ + cprints(CC_USBPD, "C0: CC OVP, SBU OVP, or thermal event"); + pd_handle_cc_overvoltage(0); +} + #include "gpio_list.h" /* ADC channels */ @@ -161,13 +164,6 @@ const struct adc_t adc_channels[] = { .factor_div = ADC_READ_MAX + 1, .shift = 0, }, - [ADC_SUB_ANALOG] = { - .name = "SUB_ANALOG", - .input_ch = NPCX_ADC_CH2, - .factor_mul = ADC_MAX_VOLT, - .factor_div = ADC_READ_MAX + 1, - .shift = 0, - }, [ADC_VSNS_PP3300_A] = { .name = "PP3300_A_PGOOD", .input_ch = NPCX_ADC_CH9, @@ -403,16 +399,6 @@ const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = { }, }; -/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */ -const struct pwm_t pwm_channels[] = { - [PWM_CH_KBLIGHT] = { - .channel = 3, - .flags = PWM_CONFIG_DSLEEP, - .freq = 10000, - }, -}; -BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); - const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { { .bus_type = EC_BUS_TYPE_I2C, @@ -457,50 +443,3 @@ uint16_t tcpc_get_alert_status(void) return status; } - -int adc_to_physical_value(enum gpio_signal gpio) -{ - if (gpio == GPIO_VOLUME_UP_L) - return !!(new_adc_key_state & ADC_VOL_UP_MASK); - else if (gpio == GPIO_VOLUME_DOWN_L) - return !!(new_adc_key_state & ADC_VOL_DOWN_MASK); - - CPRINTS("Not a volume up or down key"); - return 0; -} - -int button_is_adc_detected(enum gpio_signal gpio) -{ - return (gpio == GPIO_VOLUME_DOWN_L) || (gpio == GPIO_VOLUME_UP_L); -} - -static void adc_vol_key_press_check(void) -{ - int volt = adc_read_channel(ADC_SUB_ANALOG); - static uint8_t old_adc_key_state; - uint8_t adc_key_state_change; - - if (volt > 2400 && volt < 2490) { - /* volume-up is pressed */ - new_adc_key_state = ADC_VOL_UP_MASK; - } else if (volt > 2600 && volt < 2690) { - /* volume-down is pressed */ - new_adc_key_state = ADC_VOL_DOWN_MASK; - } else if (volt < 2290) { - /* both volumn-up and volume-down are pressed */ - new_adc_key_state = ADC_VOL_UP_MASK | ADC_VOL_DOWN_MASK; - } else if (volt > 2700) { - /* both volumn-up and volume-down are released */ - new_adc_key_state = 0; - } - if (new_adc_key_state != old_adc_key_state) { - adc_key_state_change = old_adc_key_state ^ new_adc_key_state; - if (adc_key_state_change && ADC_VOL_UP_MASK) - button_interrupt(GPIO_VOLUME_UP_L); - if (adc_key_state_change && ADC_VOL_DOWN_MASK) - button_interrupt(GPIO_VOLUME_DOWN_L); - - old_adc_key_state = new_adc_key_state; - } -} -DECLARE_HOOK(HOOK_TICK, adc_vol_key_press_check, HOOK_PRIO_DEFAULT); diff --git a/board/corori/board.h b/board/corori/board.h index 23377c18f6..a3491648f2 100644 --- a/board/corori/board.h +++ b/board/corori/board.h @@ -31,7 +31,6 @@ /* Keyboard */ #define CONFIG_KEYBOARD_KEYPAD -#define CONFIG_PWM_KBLIGHT /* LED defines */ #define CONFIG_LED_COMMON @@ -41,7 +40,6 @@ /* PWM */ -#define CONFIG_PWM #define NPCX7_PWM1_SEL 1 /* GPIO C2 is used as PWM1. */ /* Temp sensor */ @@ -86,7 +84,6 @@ #define I2C_ADDR_EEPROM_FLAGS 0x50 /* 7b address */ /* Volume Button feature */ -#define CONFIG_ADC_BUTTONS #define CONFIG_VOLUME_BUTTONS #define GPIO_VOLUME_UP_L GPIO_VOLUP_BTN_ODL #define GPIO_VOLUME_DOWN_L GPIO_VOLDN_BTN_ODL @@ -99,7 +96,6 @@ enum adc_channel { ADC_TEMP_SENSOR_1, /* ADC0 */ ADC_TEMP_SENSOR_2, /* ADC1 */ - ADC_SUB_ANALOG, /* ADC2 */ ADC_VSNS_PP3300_A, /* ADC9 */ ADC_CH_COUNT }; @@ -110,11 +106,6 @@ enum temp_sensor_id { TEMP_SENSOR_COUNT }; -enum pwm_channel { - PWM_CH_KBLIGHT, - PWM_CH_COUNT, -}; - enum battery_type { BATTERY_C21N2018, BATTERY_TYPE_COUNT, diff --git a/board/corori/gpio.inc b/board/corori/gpio.inc index 1abed874a9..204b798314 100644 --- a/board/corori/gpio.inc +++ b/board/corori/gpio.inc @@ -26,9 +26,12 @@ GPIO_INT(PG_PP1050_ST_OD, PIN(4, 2), GPIO_INT_BOTH, power_signal_interrupt) /* USB-C interrupts */ GPIO_INT(USB_C0_INT_ODL, PIN(6, 2), GPIO_INT_FALLING | GPIO_PULL_UP, usb_c0_interrupt) +GPIO_INT(USB_C0_CCSBU_OVP_ODL, PIN(A, 2), GPIO_INT_FALLING | GPIO_PULL_UP, c0_ccsbu_ovp_interrupt) /* Fault protection */ /* Button interrupts */ GPIO_INT(EC_PWR_BTN_ODL, PIN(0, 1), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt) +GPIO_INT(VOLDN_BTN_ODL, PIN(4, 0), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) +GPIO_INT(VOLUP_BTN_ODL, PIN(7, 3), GPIO_INT_BOTH | GPIO_PULL_UP, button_interrupt) /* Other interrupts */ GPIO_INT(LID_OPEN, PIN(D, 2), GPIO_INT_BOTH, lid_interrupt) @@ -48,8 +51,6 @@ GPIO(EC_I2C_SUB_USB_C1_SDA, PIN(9, 1), GPIO_INPUT) /* Extra Sub-board I/O pins */ -GPIO(EC_SUB_IO_2, PIN(3, 4), GPIO_OUT_LOW) - /* Misc Enables */ GPIO(EN_VCCIO_EXT, PIN(6, 1), GPIO_OUT_LOW) /* TODO(b:149775160) - Modify if needed if we ever use this signal. */ @@ -58,7 +59,6 @@ GPIO(EN_PP3300_PEN, PIN(6, 3), GPIO_OUT_LOW) GPIO(EN_PP3300_A, PIN(0, 3), GPIO_OUT_LOW) GPIO(EN_PP5000_U, PIN(A, 4), GPIO_OUT_LOW) GPIO(EN_SLP_Z, PIN(8, 3), GPIO_OUT_LOW) -GPIO(EN_KB_BL, PIN(6, 0), GPIO_OUT_LOW) GPIO(EN_BL_OD, PIN(D, 3), GPIO_ODR_LOW) GPIO(EC_CBI_WP, PIN(E, 5), GPIO_OUT_LOW) @@ -95,13 +95,11 @@ GPIO(EN_USB_A0_VBUS, PIN(4, 1), GPIO_OUT_LOW) /* Enable A0 5V Charging */ UNIMPLEMENTED(AC_PRESENT) UNIMPLEMENTED(PG_EC_DSW_PWROK) UNIMPLEMENTED(PG_EC_ALL_SYS_PWRGD) -UNIMPLEMENTED(VOLDN_BTN_ODL) -UNIMPLEMENTED(VOLUP_BTN_ODL) /* Alternate Functions */ /* ADC */ ALTERNATE(PIN_MASK(F, BIT(0)), 0, MODULE_ADC, 0) /* ADC9 */ -ALTERNATE(PIN_MASK(4, 0x38), 0, MODULE_ADC, 0) /* ADC0-2 */ +ALTERNATE(PIN_MASK(4, 0x30), 0, MODULE_ADC, 0) /* ADC0-1 */ /* Keyboard */ ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KEYBOARD_SCAN, GPIO_INPUT | GPIO_PULL_UP) /* KSI0, KSI1 */ @@ -112,9 +110,6 @@ ALTERNATE(PIN_MASK(0, 0xF0), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) /* KSO10- ALTERNATE(PIN_MASK(8, 0x04), 0, MODULE_KEYBOARD_SCAN, GPIO_ODR_HIGH) /* KSO14 */ GPIO(EC_KSO_02_INV, PIN(1, 7), GPIO_OUT_LOW) /* KSO2 inverted */ -/* PWM */ -ALTERNATE(PIN_MASK(8, BIT(0)), 0, MODULE_PWM, 0) /* PWM3 */ - /* UART */ ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* UART1 */ @@ -126,16 +121,18 @@ ALTERNATE(PIN_MASK(8, 0x80), 0, MODULE_I2C, 0) /* I2C1 SDA */ /* NC pins, enable internal pull-up to avoid floating state. */ GPIO(GPIO32_NC, PIN(3, 2), GPIO_INPUT | GPIO_PULL_UP) +GPIO(GPIO34_NC, PIN(3, 4), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIO35_NC, PIN(3, 5), GPIO_INPUT | GPIO_PULL_UP) +GPIO(GPIO43_NC, PIN(4, 3), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIO57_NC, PIN(5, 7), GPIO_INPUT | GPIO_PULL_UP) +GPIO(GPIO60_NC, PIN(6, 0), GPIO_INPUT | GPIO_PULL_UP) +GPIO(GPIO75_NC, PIN(7, 5), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIO81_NC, PIN(8, 1), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIO86_NC, PIN(8, 6), GPIO_INPUT | GPIO_PULL_UP) -GPIO(GPIOC0_NC, PIN(C, 0), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIOD0_NC, PIN(D, 0), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIOD1_NC, PIN(D, 1), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIOD6_NC, PIN(D, 6), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIOE0_NC, PIN(E, 0), GPIO_INPUT | GPIO_PULL_UP) -GPIO(GPIO40_NC, PIN(4, 0), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIO37_NC, PIN(3, 7), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIOF2_NC, PIN(F, 2), GPIO_INPUT | GPIO_PULL_UP) GPIO(GPIOF3_NC, PIN(F, 3), GPIO_INPUT | GPIO_PULL_UP) |