oak: enable MBKP events for PD events

(refer to CL:273620) enable the MKBP event feature to send host event
and wire up the PD specific events.
But, CONFIG_MKBP_EVENT conflicts with CONFIG_KEYBOARD_PROTOCOL_MKBP,
due to the GPIO name of EC interrupt pin. Align the GPIO naming of EC
interrupt pin to EC_INT_L.

BRANCH=none
BUG=chrome-os-partner:44643
TEST=On Oak rev3, plug/unplug USB devices and add kernel trace to see
the PD events happening.

Change-Id: I10de9c6611583bb6165bdc1848e542d4b8bba954
Signed-off-by: Ben Lok <ben.lok@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/296012
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
This commit is contained in:
Ben Lok
2015-08-31 14:35:01 +08:00
committed by chrome-bot
parent a030c63baf
commit c2cf0fb198
13 changed files with 50 additions and 14 deletions

View File

@@ -29,7 +29,7 @@ GPIO(WP_L, PIN(B, 4), GPIO_INPUT)
/* Outputs */
GPIO(AP_RESET_L, PIN(B, 3), GPIO_ODR_HIGH)
GPIO(CHARGER_EN, PIN(B, 2), GPIO_OUT_LOW)
GPIO(EC_INT, PIN(B, 9), GPIO_ODR_HIGH)
GPIO(EC_INT_L, PIN(B, 9), GPIO_ODR_HIGH)
GPIO(ENTERING_RW, PIN(H, 0), GPIO_OUT_LOW)
GPIO(I2C1_SCL, PIN(B, 6), GPIO_ODR_HIGH)
GPIO(I2C1_SDA, PIN(B, 7), GPIO_ODR_HIGH)

View File

@@ -12,7 +12,7 @@ GPIO_INT(BUTTON_VOLUME_DOWN_L, PIN(0, 0), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(BUTTON_VOLUME_UP, PIN(0, 0), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(CHARGE_DONE, PIN(0, 0), GPIO_INT_BOTH, inductive_charging_interrupt)
GPIO(EC_INT, PIN(0, 0), 0)
GPIO(EC_INT_L, PIN(0, 0), 0)
GPIO(WP, PIN(0, 0), 0)
GPIO(ENTERING_RW, PIN(0, 0), 0)
GPIO(PCH_BKLTEN, PIN(0, 0), 0)

View File

@@ -31,7 +31,7 @@ GPIO(WP_L, PIN(B, 4), GPIO_INPUT)
GPIO(BAT_LED_RED, PIN(B, 11), GPIO_OUT_HIGH)
GPIO(BAT_LED_GREEN, PIN(A, 11), GPIO_OUT_HIGH)
GPIO(EC_BL_OVERRIDE, PIN(F, 1), GPIO_OUT_LOW)
GPIO(EC_INT, PIN(B, 9), GPIO_OUT_LOW)
GPIO(EC_INT_L, PIN(B, 9), GPIO_OUT_LOW)
GPIO(ENTERING_RW, PIN(F, 0), GPIO_OUT_LOW)
GPIO(I2C1_SCL, PIN(B, 6), GPIO_ODR_HIGH)
GPIO(I2C1_SDA, PIN(B, 7), GPIO_ODR_HIGH)

View File

@@ -34,7 +34,7 @@ GPIO(BOARD_VERSION1, PIN(C, 6), GPIO_INPUT|GPIO_PULL_UP) /* Board version stu
GPIO(BAT_LED0, PIN(B, 11), GPIO_OUT_LOW) /* LED_GREEN */
GPIO(BAT_LED1, PIN(A, 11), GPIO_OUT_LOW) /* LED_ORANGE */
GPIO(EC_BL_OVERRIDE, PIN(F, 1), GPIO_OUT_LOW)
GPIO(EC_INT, PIN(B, 9), GPIO_OUT_HIGH)
GPIO(EC_INT_L, PIN(B, 9), GPIO_OUT_HIGH)
GPIO(ENTERING_RW, PIN(F, 0), GPIO_OUT_LOW)
GPIO(KB_OUT00, PIN(B, 0), GPIO_KB_OUTPUT)
GPIO(KB_OUT01, PIN(B, 8), GPIO_KB_OUTPUT)

View File

@@ -20,7 +20,7 @@ GPIO_INT(LID_OPEN, PIN(3, 3), GPIO_PULL_DOWN | GPIO_INT_BOTH, lid_interr
GPIO(ENTERING_RW, PIN(3, 6), GPIO_OUT_LOW) /* Indicate when EC is entering RW code */
GPIO(PCH_WAKE_L, PIN(5, 0), GPIO_OUT_HIGH) /* Wake signal output to PCH */
/* For testing keyboard mkbp */
GPIO(EC_INT, PIN(7, 4), GPIO_ODR_HIGH) /* Interrupt pin for keyboard mkbp */
GPIO(EC_INT_L, PIN(7, 4), GPIO_ODR_HIGH) /* Interrupt pin for keyboard mkbp */
/* Used for module testing */
GPIO(PGOOD_FAN, PIN(C, 7), GPIO_PULL_UP | GPIO_INPUT) /* Power Good for FAN test */

View File

@@ -7,6 +7,7 @@
#include "adc.h"
#include "adc_chip.h"
#include "atomic.h"
#include "battery.h"
#include "charge_manager.h"
#include "charge_state.h"
@@ -46,6 +47,13 @@
#define GPIO_KB_INPUT (GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH)
#define GPIO_KB_OUTPUT GPIO_ODR_HIGH
/*
* PD host event status for host command
* Note: this variable must be aligned on 4-byte boundary because we pass the
* address to atomic_ functions which use assembly to access them.
*/
static struct ec_response_host_event_status host_event_status __aligned(4);
/* Dispaly port hardware can connect to port 0, 1 or neither. */
#define PD_PORT_NONE -1
@@ -161,6 +169,18 @@ void board_reset_pd_mcu(void)
gpio_set_level(GPIO_USB_PD_RST_L, 1);
}
/* Send host event up to AP */
void pd_send_host_event(int mask)
{
/* mask must be set */
if (!mask)
return;
atomic_or(&(host_event_status.status), mask);
/* interrupt the AP */
host_set_single_event(EC_HOST_EVENT_PD_MCU);
}
void __board_i2c_set_timeout(int port, uint32_t timeout)
{
}
@@ -346,3 +366,19 @@ void board_set_ap_reset(int asserted)
gpio_set_level(GPIO_AP_RESET_L, !asserted);
}
}
/****************************************************************************/
/* Host commands */
static int host_event_status_host_cmd(struct host_cmd_handler_args *args)
{
struct ec_response_host_event_status *r = args->response;
/* Read and clear the host event status to return to AP */
r->status = atomic_read_clear(&(host_event_status.status));
args->response_size = sizeof(*r);
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_PD_HOST_EVENT_STATUS, host_event_status_host_cmd,
EC_VER_MASK(0));

View File

@@ -53,7 +53,7 @@
#define CONFIG_KEYBOARD_PROTOCOL_MKBP
#define CONFIG_LED_COMMON
#define CONFIG_LOW_POWER_IDLE
#define CONFIG_FORCE_CONSOLE_RESUME
#define CONFIG_MKBP_EVENT
#define CONFIG_PMIC_FW_LONG_PRESS_TIMER
#define CONFIG_POWER_BUTTON
#define CONFIG_POWER_COMMON

View File

@@ -42,7 +42,7 @@ GPIO(BAT_LED1, PIN(A, 11), GPIO_OUT_LOW) /* LED_ORANGE or LED_RED(>re
GPIO(PWR_LED0, PIN(F, 10), GPIO_OUT_LOW) /* LED_GREEN */
GPIO(PWR_LED1, PIN(F, 9), GPIO_OUT_LOW) /* LED_ORANGE */
GPIO(EC_BL_OVERRIDE, PIN(F, 1), GPIO_OUT_LOW)
GPIO(EC_INT, PIN(B, 9), GPIO_OUT_HIGH)
GPIO(EC_INT_L, PIN(B, 9), GPIO_OUT_HIGH)
GPIO(ENTERING_RW, PIN(F, 0), GPIO_OUT_LOW)

View File

@@ -31,7 +31,7 @@ GPIO(WP_L, PIN(B, 4), GPIO_INPUT)
/* Outputs */
GPIO(AP_RESET_L, PIN(B, 3), GPIO_ODR_HIGH)
GPIO(CHARGER_EN, PIN(B, 2), GPIO_OUT_LOW)
GPIO(EC_INT, PIN(B, 9), GPIO_ODR_HIGH)
GPIO(EC_INT_L, PIN(B, 9), GPIO_ODR_HIGH)
GPIO(EN_PP1350, PIN(H, 1), GPIO_OUT_LOW)
GPIO(EN_PP3300, PIN(A, 8), GPIO_OUT_LOW)
GPIO(EN_PP5000, PIN(A, 11), GPIO_OUT_LOW)

View File

@@ -102,7 +102,7 @@ static int kb_fifo_remove(uint8_t *buffp)
static void set_host_interrupt(int active)
{
/* interrupt host by using active low EC_INT signal */
gpio_set_level(GPIO_EC_INT, !active);
gpio_set_level(GPIO_EC_INT_L, !active);
}
/*****************************************************************************/

View File

@@ -475,7 +475,7 @@ static void power_off(void)
GPIO_INPUT);
/* Change EC_INT to low */
gpio_set_level(GPIO_EC_INT, 0);
gpio_set_level(GPIO_EC_INT_L, 0);
lid_opened = 0;
enable_sleep(SLEEP_MASK_AP_RUN);
@@ -589,7 +589,7 @@ static void power_on(void)
/* enable interrupt */
gpio_set_flags(GPIO_SUSPEND_L, INT_BOTH_PULL_UP);
gpio_set_flags(GPIO_EC_INT, GPIO_OUTPUT | GPIO_OUT_HIGH);
gpio_set_flags(GPIO_EC_INT_L, GPIO_OUTPUT | GPIO_OUT_HIGH);
disable_sleep(SLEEP_MASK_AP_RUN);
#ifdef HAS_TASK_POWERLED

View File

@@ -370,7 +370,7 @@ static void power_off(void)
chipset_turn_off_power_rails();
/* Change SUSPEND_L and EC_INT pin to high-Z to reduce power draw. */
gpio_set_flags(GPIO_SUSPEND_L, GPIO_INPUT);
gpio_set_flags(GPIO_EC_INT, GPIO_INPUT);
gpio_set_flags(GPIO_EC_INT_L, GPIO_INPUT);
/* Wait till we actually turn off to not mess up the state machine. */
while (power_get_signals() & IN_POWER_GOOD) {
@@ -453,7 +453,7 @@ enum power_state power_handle_state(enum power_state state)
/* setup misc gpio for S3/S0 functionality */
gpio_set_flags(GPIO_SUSPEND_L, GPIO_INPUT
| GPIO_INT_BOTH | GPIO_PULL_DOWN);
gpio_set_flags(GPIO_EC_INT, GPIO_OUTPUT
gpio_set_flags(GPIO_EC_INT_L, GPIO_OUTPUT
| GPIO_OUT_HIGH);
/* Call hooks now that AP is running */

View File

@@ -31,7 +31,7 @@ void host_send_response(struct host_cmd_handler_args *args)
void gpio_set_level(enum gpio_signal signal, int level)
{
if (signal == GPIO_EC_INT)
if (signal == GPIO_EC_INT_L)
ec_int_level = !!level;
}