diff options
author | Scott <scollyer@chromium.org> | 2015-06-04 16:03:28 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-06-23 19:18:44 +0000 |
commit | 99e964c018eec1cba83022361866dd0b14d47610 (patch) | |
tree | 67cb7b386101bbd2abf2f45fc66ffdfd8d1bceb9 /include | |
parent | 0e2176304f3af2b78e8e0b12dab8feb82abccd8f (diff) | |
download | chrome-ec-99e964c018eec1cba83022361866dd0b14d47610.tar.gz |
pd: Add support for TCPC Alert and Alert_Mask registers
Changed the alert function to hold the ec_int line until
all of the alert bits are cleared. Added support for the
alert_mask register. In addition, created ec_int_status
variable to distinguish which of 3 ec_int sources is
driving the pd_mcu_int line.
BUG=none
BRANCH=tot
TEST=Tested Zinger to Glados and Zinger to Samus and verified
that it established a power contract in both cases. Did not
test Oak, but put exact same changes in board.c as in glados.
Change-Id: I372e75b8fd5d66a0c01db18b46100b86fd9ac064
Signed-off-by: Scott Collyer <scollyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/278256
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/ec_commands.h | 5 | ||||
-rw-r--r-- | include/usb_pd_tcpm.h | 59 |
2 files changed, 39 insertions, 25 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h index de603e6d1e..4bfbbb0e39 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -3015,6 +3015,11 @@ struct ec_params_pd_status { #define PD_STATUS_HOST_EVENT (1 << 0) /* Forward host event to AP */ #define PD_STATUS_IN_RW (1 << 1) /* Running RW image */ #define PD_STATUS_JUMPED_TO_IMAGE (1 << 2) /* Current image was jumped to */ +#define PD_STATUS_TCPC_ALERT_0 (1 << 3) /* Alert active in port 0 TCPC */ +#define PD_STATUS_TCPC_ALERT_1 (1 << 4) /* Alert active in port 1 TCPC */ +#define PD_STATUS_EC_INT_ACTIVE (PD_STATUS_TCPC_ALERT_0 | \ + PD_STATUS_TCPC_ALERT_1 | \ + PD_STATUS_HOST_EVENT) struct ec_response_pd_status { uint32_t status; /* PD MCU status */ uint32_t curr_lim_ma; /* input current limit */ diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h index c73ca100e1..71f0610ece 100644 --- a/include/usb_pd_tcpm.h +++ b/include/usb_pd_tcpm.h @@ -24,27 +24,26 @@ #define TCPC_REG_DEV_CAP_2 0xd #define TCPC_REG_DEV_CAP_3 0xe #define TCPC_REG_DEV_CAP_4 0xf -#define TCPC_REG_ALERT1 0x10 -#define TCPC_REG_ALERT1_SLEEP_EXITED (1<<7) -#define TCPC_REG_ALERT1_POWER_STATUS (1<<6) -#define TCPC_REG_ALERT1_CC_STATUS (1<<5) -#define TCPC_REG_ALERT1_RX_STATUS (1<<4) -#define TCPC_REG_ALERT1_RX_HARD_RST (1<<3) -#define TCPC_REG_ALERT1_TX_SUCCESS (1<<2) -#define TCPC_REG_ALERT1_TX_DISCARDED (1<<1) -#define TCPC_REG_ALERT1_TX_FAILED (1<<0) -#define TCPC_REG_ALERT1_TX_COMPLETE (TCPC_REG_ALERT1_TX_SUCCESS | \ - TCPC_REG_ALERT1_TX_DISCARDED | \ - TCPC_REG_ALERT1_TX_FAILED) +#define TCPC_REG_ALERT 0x10 +#define TCPC_REG_ALERT_GPIO_CHANGE (1<<10) +#define TCPC_REG_ALERT_V_ALARM_LO (1<<9) +#define TCPC_REG_ALERT_V_ALARM_HI (1<<8) +#define TCPC_REG_ALERT_SLEEP_EXITED (1<<7) +#define TCPC_REG_ALERT_POWER_STATUS (1<<6) +#define TCPC_REG_ALERT_CC_STATUS (1<<5) +#define TCPC_REG_ALERT_RX_STATUS (1<<4) +#define TCPC_REG_ALERT_RX_HARD_RST (1<<3) +#define TCPC_REG_ALERT_TX_SUCCESS (1<<2) +#define TCPC_REG_ALERT_TX_DISCARDED (1<<1) +#define TCPC_REG_ALERT_TX_FAILED (1<<0) +#define TCPC_REG_ALERT_TX_COMPLETE (TCPC_REG_ALERT_TX_SUCCESS | \ + TCPC_REG_ALERT_TX_DISCARDED | \ + TCPC_REG_ALERT_TX_FAILED) -#define TCPC_REG_ALERT2 0x11 -#define TCPC_REG_ALERT3 0x12 -#define TCPC_REG_ALERT4 0x13 -#define TCPC_REG_ALERT_MASK_1 0x14 -#define TCPC_REG_ALERT_MASK_2 0x15 -#define TCPC_REG_POWER_STATUS_MASK 0x16 -#define TCPC_REG_CC1_STATUS 0x18 -#define TCPC_REG_CC2_STATUS 0x19 +#define TCPC_REG_ALERT_MASK 0x12 +#define TCPC_REG_POWER_STATUS_MASK 0x14 +#define TCPC_REG_CC1_STATUS 0x16 +#define TCPC_REG_CC2_STATUS 0x17 #define TCPC_REG_CC_STATUS_SET(term, volt) \ ((term) << 3 | volt) #define TCPC_REG_CC_STATUS_TERM(reg) (((reg) & 0x38) >> 3) @@ -130,8 +129,8 @@ enum tcpm_transmit_type { /** * TCPC is asserting alert */ -void tcpc_alert(void); - +void tcpc_alert(int port); +void tcpc_alert_clear(int port); /** * Initialize TCPC. * @@ -152,13 +151,23 @@ int tcpc_run(int port, int evt); * Read TCPC alert status * * @param port Type-C port number - * @param alert_reg Alert register to read + * @param reg TCPC register address * @param alert Pointer to location to store alert status - * + * @return EC_SUCCESS or error */ -int tcpm_alert_status(int port, int alert_reg, uint8_t *alert); +int tcpm_alert_status(int port, int reg, uint16_t *alert); +/** + * Write TCPC Alert Mask register + * + * @param port Type-C port number + * @param reg TCPC register address + * @param mask bits to be set in Alert Mask register + + * @return EC_SUCCESS or error + */ +int tcpm_alert_mask_set(int port, int reg, uint16_t mask); /** * Initialize TCPM driver and wait for TCPC readiness. |