summaryrefslogtreecommitdiff
path: root/include/usb_pd_tcpm.h
diff options
context:
space:
mode:
authorScott <scollyer@chromium.org>2015-06-04 16:03:28 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-23 19:18:44 +0000
commit99e964c018eec1cba83022361866dd0b14d47610 (patch)
tree67cb7b386101bbd2abf2f45fc66ffdfd8d1bceb9 /include/usb_pd_tcpm.h
parent0e2176304f3af2b78e8e0b12dab8feb82abccd8f (diff)
downloadchrome-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/usb_pd_tcpm.h')
-rw-r--r--include/usb_pd_tcpm.h59
1 files changed, 34 insertions, 25 deletions
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.