diff options
| author | Guenter Roeck <linux@roeck-us.net> | 2017-09-11 23:32:07 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-09-18 04:58:31 -0400 |
| commit | 4b4e02c83167dca260e6bf974809979d44694e19 (patch) | |
| tree | 2dff208e127332c9f17f1fc7f5e319c8cc96387c /include/linux/usb | |
| parent | 70cd90be33004ce700f762e85e4919f41af0ca48 (diff) | |
typec: tcpm: Move out of staging
Move tcpm (USB Type-C Port Manager) out of staging.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/usb')
| -rw-r--r-- | include/linux/usb/pd.h | 298 | ||||
| -rw-r--r-- | include/linux/usb/pd_bdo.h | 31 | ||||
| -rw-r--r-- | include/linux/usb/pd_vdo.h | 251 | ||||
| -rw-r--r-- | include/linux/usb/tcpm.h | 204 |
4 files changed, 784 insertions, 0 deletions
diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h new file mode 100644 index 000000000000..e00051ced806 --- /dev/null +++ b/include/linux/usb/pd.h | |||
| @@ -0,0 +1,298 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2015-2017 Google, Inc | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef __LINUX_USB_PD_H | ||
| 16 | #define __LINUX_USB_PD_H | ||
| 17 | |||
| 18 | #include <linux/types.h> | ||
| 19 | #include <linux/usb/typec.h> | ||
| 20 | |||
| 21 | /* USB PD Messages */ | ||
| 22 | enum pd_ctrl_msg_type { | ||
| 23 | /* 0 Reserved */ | ||
| 24 | PD_CTRL_GOOD_CRC = 1, | ||
| 25 | PD_CTRL_GOTO_MIN = 2, | ||
| 26 | PD_CTRL_ACCEPT = 3, | ||
| 27 | PD_CTRL_REJECT = 4, | ||
| 28 | PD_CTRL_PING = 5, | ||
| 29 | PD_CTRL_PS_RDY = 6, | ||
| 30 | PD_CTRL_GET_SOURCE_CAP = 7, | ||
| 31 | PD_CTRL_GET_SINK_CAP = 8, | ||
| 32 | PD_CTRL_DR_SWAP = 9, | ||
| 33 | PD_CTRL_PR_SWAP = 10, | ||
| 34 | PD_CTRL_VCONN_SWAP = 11, | ||
| 35 | PD_CTRL_WAIT = 12, | ||
| 36 | PD_CTRL_SOFT_RESET = 13, | ||
| 37 | /* 14-15 Reserved */ | ||
| 38 | }; | ||
| 39 | |||
| 40 | enum pd_data_msg_type { | ||
| 41 | /* 0 Reserved */ | ||
| 42 | PD_DATA_SOURCE_CAP = 1, | ||
| 43 | PD_DATA_REQUEST = 2, | ||
| 44 | PD_DATA_BIST = 3, | ||
| 45 | PD_DATA_SINK_CAP = 4, | ||
| 46 | /* 5-14 Reserved */ | ||
| 47 | PD_DATA_VENDOR_DEF = 15, | ||
| 48 | }; | ||
| 49 | |||
| 50 | #define PD_REV10 0x0 | ||
| 51 | #define PD_REV20 0x1 | ||
| 52 | |||
| 53 | #define PD_HEADER_CNT_SHIFT 12 | ||
| 54 | #define PD_HEADER_CNT_MASK 0x7 | ||
| 55 | #define PD_HEADER_ID_SHIFT 9 | ||
| 56 | #define PD_HEADER_ID_MASK 0x7 | ||
| 57 | #define PD_HEADER_PWR_ROLE BIT(8) | ||
| 58 | #define PD_HEADER_REV_SHIFT 6 | ||
| 59 | #define PD_HEADER_REV_MASK 0x3 | ||
| 60 | #define PD_HEADER_DATA_ROLE BIT(5) | ||
| 61 | #define PD_HEADER_TYPE_SHIFT 0 | ||
| 62 | #define PD_HEADER_TYPE_MASK 0xf | ||
| 63 | |||
| 64 | #define PD_HEADER(type, pwr, data, id, cnt) \ | ||
| 65 | ((((type) & PD_HEADER_TYPE_MASK) << PD_HEADER_TYPE_SHIFT) | \ | ||
| 66 | ((pwr) == TYPEC_SOURCE ? PD_HEADER_PWR_ROLE : 0) | \ | ||
| 67 | ((data) == TYPEC_HOST ? PD_HEADER_DATA_ROLE : 0) | \ | ||
| 68 | (PD_REV20 << PD_HEADER_REV_SHIFT) | \ | ||
| 69 | (((id) & PD_HEADER_ID_MASK) << PD_HEADER_ID_SHIFT) | \ | ||
| 70 | (((cnt) & PD_HEADER_CNT_MASK) << PD_HEADER_CNT_SHIFT)) | ||
| 71 | |||
| 72 | #define PD_HEADER_LE(type, pwr, data, id, cnt) \ | ||
| 73 | cpu_to_le16(PD_HEADER((type), (pwr), (data), (id), (cnt))) | ||
| 74 | |||
| 75 | static inline unsigned int pd_header_cnt(u16 header) | ||
| 76 | { | ||
| 77 | return (header >> PD_HEADER_CNT_SHIFT) & PD_HEADER_CNT_MASK; | ||
| 78 | } | ||
| 79 | |||
| 80 | static inline unsigned int pd_header_cnt_le(__le16 header) | ||
| 81 | { | ||
| 82 | return pd_header_cnt(le16_to_cpu(header)); | ||
| 83 | } | ||
| 84 | |||
| 85 | static inline unsigned int pd_header_type(u16 header) | ||
| 86 | { | ||
| 87 | return (header >> PD_HEADER_TYPE_SHIFT) & PD_HEADER_TYPE_MASK; | ||
| 88 | } | ||
| 89 | |||
| 90 | static inline unsigned int pd_header_type_le(__le16 header) | ||
| 91 | { | ||
| 92 | return pd_header_type(le16_to_cpu(header)); | ||
| 93 | } | ||
| 94 | |||
| 95 | static inline unsigned int pd_header_msgid(u16 header) | ||
| 96 | { | ||
| 97 | return (header >> PD_HEADER_ID_SHIFT) & PD_HEADER_ID_MASK; | ||
| 98 | } | ||
| 99 | |||
| 100 | static inline unsigned int pd_header_msgid_le(__le16 header) | ||
| 101 | { | ||
| 102 | return pd_header_msgid(le16_to_cpu(header)); | ||
| 103 | } | ||
| 104 | |||
| 105 | #define PD_MAX_PAYLOAD 7 | ||
| 106 | |||
| 107 | /** | ||
| 108 | * struct pd_message - PD message as seen on wire | ||
| 109 | * @header: PD message header | ||
| 110 | * @payload: PD message payload | ||
| 111 | */ | ||
| 112 | struct pd_message { | ||
| 113 | __le16 header; | ||
| 114 | __le32 payload[PD_MAX_PAYLOAD]; | ||
| 115 | } __packed; | ||
| 116 | |||
| 117 | /* PDO: Power Data Object */ | ||
| 118 | #define PDO_MAX_OBJECTS 7 | ||
| 119 | |||
| 120 | enum pd_pdo_type { | ||
| 121 | PDO_TYPE_FIXED = 0, | ||
| 122 | PDO_TYPE_BATT = 1, | ||
| 123 | PDO_TYPE_VAR = 2, | ||
| 124 | }; | ||
| 125 | |||
| 126 | #define PDO_TYPE_SHIFT 30 | ||
| 127 | #define PDO_TYPE_MASK 0x3 | ||
| 128 | |||
| 129 | #define PDO_TYPE(t) ((t) << PDO_TYPE_SHIFT) | ||
| 130 | |||
| 131 | #define PDO_VOLT_MASK 0x3ff | ||
| 132 | #define PDO_CURR_MASK 0x3ff | ||
| 133 | #define PDO_PWR_MASK 0x3ff | ||
| 134 | |||
| 135 | #define PDO_FIXED_DUAL_ROLE BIT(29) /* Power role swap supported */ | ||
| 136 | #define PDO_FIXED_SUSPEND BIT(28) /* USB Suspend supported (Source) */ | ||
| 137 | #define PDO_FIXED_HIGHER_CAP BIT(28) /* Requires more than vSafe5V (Sink) */ | ||
| 138 | #define PDO_FIXED_EXTPOWER BIT(27) /* Externally powered */ | ||
| 139 | #define PDO_FIXED_USB_COMM BIT(26) /* USB communications capable */ | ||
| 140 | #define PDO_FIXED_DATA_SWAP BIT(25) /* Data role swap supported */ | ||
| 141 | #define PDO_FIXED_VOLT_SHIFT 10 /* 50mV units */ | ||
| 142 | #define PDO_FIXED_CURR_SHIFT 0 /* 10mA units */ | ||
| 143 | |||
| 144 | #define PDO_FIXED_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_FIXED_VOLT_SHIFT) | ||
| 145 | #define PDO_FIXED_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_FIXED_CURR_SHIFT) | ||
| 146 | |||
| 147 | #define PDO_FIXED(mv, ma, flags) \ | ||
| 148 | (PDO_TYPE(PDO_TYPE_FIXED) | (flags) | \ | ||
| 149 | PDO_FIXED_VOLT(mv) | PDO_FIXED_CURR(ma)) | ||
| 150 | |||
| 151 | #define PDO_BATT_MAX_VOLT_SHIFT 20 /* 50mV units */ | ||
| 152 | #define PDO_BATT_MIN_VOLT_SHIFT 10 /* 50mV units */ | ||
| 153 | #define PDO_BATT_MAX_PWR_SHIFT 0 /* 250mW units */ | ||
| 154 | |||
| 155 | #define PDO_BATT_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MIN_VOLT_SHIFT) | ||
| 156 | #define PDO_BATT_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_BATT_MAX_VOLT_SHIFT) | ||
| 157 | #define PDO_BATT_MAX_POWER(mw) ((((mw) / 250) & PDO_PWR_MASK) << PDO_BATT_MAX_PWR_SHIFT) | ||
| 158 | |||
| 159 | #define PDO_BATT(min_mv, max_mv, max_mw) \ | ||
| 160 | (PDO_TYPE(PDO_TYPE_BATT) | PDO_BATT_MIN_VOLT(min_mv) | \ | ||
| 161 | PDO_BATT_MAX_VOLT(max_mv) | PDO_BATT_MAX_POWER(max_mw)) | ||
| 162 | |||
| 163 | #define PDO_VAR_MAX_VOLT_SHIFT 20 /* 50mV units */ | ||
| 164 | #define PDO_VAR_MIN_VOLT_SHIFT 10 /* 50mV units */ | ||
| 165 | #define PDO_VAR_MAX_CURR_SHIFT 0 /* 10mA units */ | ||
| 166 | |||
| 167 | #define PDO_VAR_MIN_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MIN_VOLT_SHIFT) | ||
| 168 | #define PDO_VAR_MAX_VOLT(mv) ((((mv) / 50) & PDO_VOLT_MASK) << PDO_VAR_MAX_VOLT_SHIFT) | ||
| 169 | #define PDO_VAR_MAX_CURR(ma) ((((ma) / 10) & PDO_CURR_MASK) << PDO_VAR_MAX_CURR_SHIFT) | ||
| 170 | |||
| 171 | #define PDO_VAR(min_mv, max_mv, max_ma) \ | ||
| 172 | (PDO_TYPE(PDO_TYPE_VAR) | PDO_VAR_MIN_VOLT(min_mv) | \ | ||
| 173 | PDO_VAR_MAX_VOLT(max_mv) | PDO_VAR_MAX_CURR(max_ma)) | ||
| 174 | |||
| 175 | static inline enum pd_pdo_type pdo_type(u32 pdo) | ||
| 176 | { | ||
| 177 | return (pdo >> PDO_TYPE_SHIFT) & PDO_TYPE_MASK; | ||
| 178 | } | ||
| 179 | |||
| 180 | static inline unsigned int pdo_fixed_voltage(u32 pdo) | ||
| 181 | { | ||
| 182 | return ((pdo >> PDO_FIXED_VOLT_SHIFT) & PDO_VOLT_MASK) * 50; | ||
| 183 | } | ||
| 184 | |||
| 185 | static inline unsigned int pdo_min_voltage(u32 pdo) | ||
| 186 | { | ||
| 187 | return ((pdo >> PDO_VAR_MIN_VOLT_SHIFT) & PDO_VOLT_MASK) * 50; | ||
| 188 | } | ||
| 189 | |||
| 190 | static inline unsigned int pdo_max_voltage(u32 pdo) | ||
| 191 | { | ||
| 192 | return ((pdo >> PDO_VAR_MAX_VOLT_SHIFT) & PDO_VOLT_MASK) * 50; | ||
| 193 | } | ||
| 194 | |||
| 195 | static inline unsigned int pdo_max_current(u32 pdo) | ||
| 196 | { | ||
| 197 | return ((pdo >> PDO_VAR_MAX_CURR_SHIFT) & PDO_CURR_MASK) * 10; | ||
| 198 | } | ||
| 199 | |||
| 200 | static inline unsigned int pdo_max_power(u32 pdo) | ||
| 201 | { | ||
| 202 | return ((pdo >> PDO_BATT_MAX_PWR_SHIFT) & PDO_PWR_MASK) * 250; | ||
| 203 | } | ||
| 204 | |||
| 205 | /* RDO: Request Data Object */ | ||
| 206 | #define RDO_OBJ_POS_SHIFT 28 | ||
| 207 | #define RDO_OBJ_POS_MASK 0x7 | ||
| 208 | #define RDO_GIVE_BACK BIT(27) /* Supports reduced operating current */ | ||
| 209 | #define RDO_CAP_MISMATCH BIT(26) /* Not satisfied by source caps */ | ||
| 210 | #define RDO_USB_COMM BIT(25) /* USB communications capable */ | ||
| 211 | #define RDO_NO_SUSPEND BIT(24) /* USB Suspend not supported */ | ||
| 212 | |||
| 213 | #define RDO_PWR_MASK 0x3ff | ||
| 214 | #define RDO_CURR_MASK 0x3ff | ||
| 215 | |||
| 216 | #define RDO_FIXED_OP_CURR_SHIFT 10 | ||
| 217 | #define RDO_FIXED_MAX_CURR_SHIFT 0 | ||
| 218 | |||
| 219 | #define RDO_OBJ(idx) (((idx) & RDO_OBJ_POS_MASK) << RDO_OBJ_POS_SHIFT) | ||
| 220 | |||
| 221 | #define PDO_FIXED_OP_CURR(ma) ((((ma) / 10) & RDO_CURR_MASK) << RDO_FIXED_OP_CURR_SHIFT) | ||
| 222 | #define PDO_FIXED_MAX_CURR(ma) ((((ma) / 10) & RDO_CURR_MASK) << RDO_FIXED_MAX_CURR_SHIFT) | ||
| 223 | |||
| 224 | #define RDO_FIXED(idx, op_ma, max_ma, flags) \ | ||
| 225 | (RDO_OBJ(idx) | (flags) | \ | ||
| 226 | PDO_FIXED_OP_CURR(op_ma) | PDO_FIXED_MAX_CURR(max_ma)) | ||
| 227 | |||
| 228 | #define RDO_BATT_OP_PWR_SHIFT 10 /* 250mW units */ | ||
| 229 | #define RDO_BATT_MAX_PWR_SHIFT 0 /* 250mW units */ | ||
| 230 | |||
| 231 | #define RDO_BATT_OP_PWR(mw) ((((mw) / 250) & RDO_PWR_MASK) << RDO_BATT_OP_PWR_SHIFT) | ||
| 232 | #define RDO_BATT_MAX_PWR(mw) ((((mw) / 250) & RDO_PWR_MASK) << RDO_BATT_MAX_PWR_SHIFT) | ||
| 233 | |||
| 234 | #define RDO_BATT(idx, op_mw, max_mw, flags) \ | ||
| 235 | (RDO_OBJ(idx) | (flags) | \ | ||
| 236 | RDO_BATT_OP_PWR(op_mw) | RDO_BATT_MAX_PWR(max_mw)) | ||
| 237 | |||
| 238 | static inline unsigned int rdo_index(u32 rdo) | ||
| 239 | { | ||
| 240 | return (rdo >> RDO_OBJ_POS_SHIFT) & RDO_OBJ_POS_MASK; | ||
| 241 | } | ||
| 242 | |||
| 243 | static inline unsigned int rdo_op_current(u32 rdo) | ||
| 244 | { | ||
| 245 | return ((rdo >> RDO_FIXED_OP_CURR_SHIFT) & RDO_CURR_MASK) * 10; | ||
| 246 | } | ||
| 247 | |||
| 248 | static inline unsigned int rdo_max_current(u32 rdo) | ||
| 249 | { | ||
| 250 | return ((rdo >> RDO_FIXED_MAX_CURR_SHIFT) & | ||
| 251 | RDO_CURR_MASK) * 10; | ||
| 252 | } | ||
| 253 | |||
| 254 | static inline unsigned int rdo_op_power(u32 rdo) | ||
| 255 | { | ||
| 256 | return ((rdo >> RDO_BATT_OP_PWR_SHIFT) & RDO_PWR_MASK) * 250; | ||
| 257 | } | ||
| 258 | |||
| 259 | static inline unsigned int rdo_max_power(u32 rdo) | ||
| 260 | { | ||
| 261 | return ((rdo >> RDO_BATT_MAX_PWR_SHIFT) & RDO_PWR_MASK) * 250; | ||
| 262 | } | ||
| 263 | |||
| 264 | /* USB PD timers and counters */ | ||
| 265 | #define PD_T_NO_RESPONSE 5000 /* 4.5 - 5.5 seconds */ | ||
| 266 | #define PD_T_DB_DETECT 10000 /* 10 - 15 seconds */ | ||
| 267 | #define PD_T_SEND_SOURCE_CAP 150 /* 100 - 200 ms */ | ||
| 268 | #define PD_T_SENDER_RESPONSE 60 /* 24 - 30 ms, relaxed */ | ||
| 269 | #define PD_T_SOURCE_ACTIVITY 45 | ||
| 270 | #define PD_T_SINK_ACTIVITY 135 | ||
| 271 | #define PD_T_SINK_WAIT_CAP 240 | ||
| 272 | #define PD_T_PS_TRANSITION 500 | ||
| 273 | #define PD_T_SRC_TRANSITION 35 | ||
| 274 | #define PD_T_DRP_SNK 40 | ||
| 275 | #define PD_T_DRP_SRC 30 | ||
| 276 | #define PD_T_PS_SOURCE_OFF 920 | ||
| 277 | #define PD_T_PS_SOURCE_ON 480 | ||
| 278 | #define PD_T_PS_HARD_RESET 30 | ||
| 279 | #define PD_T_SRC_RECOVER 760 | ||
| 280 | #define PD_T_SRC_RECOVER_MAX 1000 | ||
| 281 | #define PD_T_SRC_TURN_ON 275 | ||
| 282 | #define PD_T_SAFE_0V 650 | ||
| 283 | #define PD_T_VCONN_SOURCE_ON 100 | ||
| 284 | #define PD_T_SINK_REQUEST 100 /* 100 ms minimum */ | ||
| 285 | #define PD_T_ERROR_RECOVERY 100 /* minimum 25 is insufficient */ | ||
| 286 | #define PD_T_SRCSWAPSTDBY 625 /* Maximum of 650ms */ | ||
| 287 | #define PD_T_NEWSRC 250 /* Maximum of 275ms */ | ||
| 288 | |||
| 289 | #define PD_T_DRP_TRY 100 /* 75 - 150 ms */ | ||
| 290 | #define PD_T_DRP_TRYWAIT 600 /* 400 - 800 ms */ | ||
| 291 | |||
| 292 | #define PD_T_CC_DEBOUNCE 200 /* 100 - 200 ms */ | ||
| 293 | #define PD_T_PD_DEBOUNCE 20 /* 10 - 20 ms */ | ||
| 294 | |||
| 295 | #define PD_N_CAPS_COUNT (PD_T_NO_RESPONSE / PD_T_SEND_SOURCE_CAP) | ||
| 296 | #define PD_N_HARD_RESET_COUNT 2 | ||
| 297 | |||
| 298 | #endif /* __LINUX_USB_PD_H */ | ||
diff --git a/include/linux/usb/pd_bdo.h b/include/linux/usb/pd_bdo.h new file mode 100644 index 000000000000..90b94d9fea5d --- /dev/null +++ b/include/linux/usb/pd_bdo.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2015-2017 Google, Inc | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef __LINUX_USB_PD_BDO_H | ||
| 16 | #define __LINUX_USB_PD_BDO_H | ||
| 17 | |||
| 18 | /* BDO : BIST Data Object */ | ||
| 19 | #define BDO_MODE_RECV (0 << 28) | ||
| 20 | #define BDO_MODE_TRANSMIT (1 << 28) | ||
| 21 | #define BDO_MODE_COUNTERS (2 << 28) | ||
| 22 | #define BDO_MODE_CARRIER0 (3 << 28) | ||
| 23 | #define BDO_MODE_CARRIER1 (4 << 28) | ||
| 24 | #define BDO_MODE_CARRIER2 (5 << 28) | ||
| 25 | #define BDO_MODE_CARRIER3 (6 << 28) | ||
| 26 | #define BDO_MODE_EYE (7 << 28) | ||
| 27 | #define BDO_MODE_TESTDATA (8 << 28) | ||
| 28 | |||
| 29 | #define BDO_MODE_MASK(mode) ((mode) & 0xf0000000) | ||
| 30 | |||
| 31 | #endif | ||
diff --git a/include/linux/usb/pd_vdo.h b/include/linux/usb/pd_vdo.h new file mode 100644 index 000000000000..d92259f8de0a --- /dev/null +++ b/include/linux/usb/pd_vdo.h | |||
| @@ -0,0 +1,251 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2015-2017 Google, Inc | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef __LINUX_USB_PD_VDO_H | ||
| 16 | #define __LINUX_USB_PD_VDO_H | ||
| 17 | |||
| 18 | #include "pd.h" | ||
| 19 | |||
| 20 | /* | ||
| 21 | * VDO : Vendor Defined Message Object | ||
| 22 | * VDM object is minimum of VDM header + 6 additional data objects. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #define VDO_MAX_OBJECTS 6 | ||
| 26 | #define VDO_MAX_SIZE (VDO_MAX_OBJECTS + 1) | ||
| 27 | |||
| 28 | /* | ||
| 29 | * VDM header | ||
| 30 | * ---------- | ||
| 31 | * <31:16> :: SVID | ||
| 32 | * <15> :: VDM type ( 1b == structured, 0b == unstructured ) | ||
| 33 | * <14:13> :: Structured VDM version (can only be 00 == 1.0 currently) | ||
| 34 | * <12:11> :: reserved | ||
| 35 | * <10:8> :: object position (1-7 valid ... used for enter/exit mode only) | ||
| 36 | * <7:6> :: command type (SVDM only?) | ||
| 37 | * <5> :: reserved (SVDM), command type (UVDM) | ||
| 38 | * <4:0> :: command | ||
| 39 | */ | ||
| 40 | #define VDO(vid, type, custom) \ | ||
| 41 | (((vid) << 16) | \ | ||
| 42 | ((type) << 15) | \ | ||
| 43 | ((custom) & 0x7FFF)) | ||
| 44 | |||
| 45 | #define VDO_SVDM_TYPE (1 << 15) | ||
| 46 | #define VDO_SVDM_VERS(x) ((x) << 13) | ||
| 47 | #define VDO_OPOS(x) ((x) << 8) | ||
| 48 | #define VDO_CMDT(x) ((x) << 6) | ||
| 49 | #define VDO_OPOS_MASK VDO_OPOS(0x7) | ||
| 50 | #define VDO_CMDT_MASK VDO_CMDT(0x3) | ||
| 51 | |||
| 52 | #define CMDT_INIT 0 | ||
| 53 | #define CMDT_RSP_ACK 1 | ||
| 54 | #define CMDT_RSP_NAK 2 | ||
| 55 | #define CMDT_RSP_BUSY 3 | ||
| 56 | |||
| 57 | /* reserved for SVDM ... for Google UVDM */ | ||
| 58 | #define VDO_SRC_INITIATOR (0 << 5) | ||
| 59 | #define VDO_SRC_RESPONDER (1 << 5) | ||
| 60 | |||
| 61 | #define CMD_DISCOVER_IDENT 1 | ||
| 62 | #define CMD_DISCOVER_SVID 2 | ||
| 63 | #define CMD_DISCOVER_MODES 3 | ||
| 64 | #define CMD_ENTER_MODE 4 | ||
| 65 | #define CMD_EXIT_MODE 5 | ||
| 66 | #define CMD_ATTENTION 6 | ||
| 67 | |||
| 68 | #define VDO_CMD_VENDOR(x) (((10 + (x)) & 0x1f)) | ||
| 69 | |||
| 70 | /* ChromeOS specific commands */ | ||
| 71 | #define VDO_CMD_VERSION VDO_CMD_VENDOR(0) | ||
| 72 | #define VDO_CMD_SEND_INFO VDO_CMD_VENDOR(1) | ||
| 73 | #define VDO_CMD_READ_INFO VDO_CMD_VENDOR(2) | ||
| 74 | #define VDO_CMD_REBOOT VDO_CMD_VENDOR(5) | ||
| 75 | #define VDO_CMD_FLASH_ERASE VDO_CMD_VENDOR(6) | ||
| 76 | #define VDO_CMD_FLASH_WRITE VDO_CMD_VENDOR(7) | ||
| 77 | #define VDO_CMD_ERASE_SIG VDO_CMD_VENDOR(8) | ||
| 78 | #define VDO_CMD_PING_ENABLE VDO_CMD_VENDOR(10) | ||
| 79 | #define VDO_CMD_CURRENT VDO_CMD_VENDOR(11) | ||
| 80 | #define VDO_CMD_FLIP VDO_CMD_VENDOR(12) | ||
| 81 | #define VDO_CMD_GET_LOG VDO_CMD_VENDOR(13) | ||
| 82 | #define VDO_CMD_CCD_EN VDO_CMD_VENDOR(14) | ||
| 83 | |||
| 84 | #define PD_VDO_VID(vdo) ((vdo) >> 16) | ||
| 85 | #define PD_VDO_SVDM(vdo) (((vdo) >> 15) & 1) | ||
| 86 | #define PD_VDO_OPOS(vdo) (((vdo) >> 8) & 0x7) | ||
| 87 | #define PD_VDO_CMD(vdo) ((vdo) & 0x1f) | ||
| 88 | #define PD_VDO_CMDT(vdo) (((vdo) >> 6) & 0x3) | ||
| 89 | |||
| 90 | /* | ||
| 91 | * SVDM Identity request -> response | ||
| 92 | * | ||
| 93 | * Request is simply properly formatted SVDM header | ||
| 94 | * | ||
| 95 | * Response is 4 data objects: | ||
| 96 | * [0] :: SVDM header | ||
| 97 | * [1] :: Identitiy header | ||
| 98 | * [2] :: Cert Stat VDO | ||
| 99 | * [3] :: (Product | Cable) VDO | ||
| 100 | * [4] :: AMA VDO | ||
| 101 | * | ||
| 102 | */ | ||
| 103 | #define VDO_INDEX_HDR 0 | ||
| 104 | #define VDO_INDEX_IDH 1 | ||
| 105 | #define VDO_INDEX_CSTAT 2 | ||
| 106 | #define VDO_INDEX_CABLE 3 | ||
| 107 | #define VDO_INDEX_PRODUCT 3 | ||
| 108 | #define VDO_INDEX_AMA 4 | ||
| 109 | |||
| 110 | /* | ||
| 111 | * SVDM Identity Header | ||
| 112 | * -------------------- | ||
| 113 | * <31> :: data capable as a USB host | ||
| 114 | * <30> :: data capable as a USB device | ||
| 115 | * <29:27> :: product type | ||
| 116 | * <26> :: modal operation supported (1b == yes) | ||
| 117 | * <25:16> :: Reserved, Shall be set to zero | ||
| 118 | * <15:0> :: USB-IF assigned VID for this cable vendor | ||
| 119 | */ | ||
| 120 | #define IDH_PTYPE_UNDEF 0 | ||
| 121 | #define IDH_PTYPE_HUB 1 | ||
| 122 | #define IDH_PTYPE_PERIPH 2 | ||
| 123 | #define IDH_PTYPE_PCABLE 3 | ||
| 124 | #define IDH_PTYPE_ACABLE 4 | ||
| 125 | #define IDH_PTYPE_AMA 5 | ||
| 126 | |||
| 127 | #define VDO_IDH(usbh, usbd, ptype, is_modal, vid) \ | ||
| 128 | ((usbh) << 31 | (usbd) << 30 | ((ptype) & 0x7) << 27 \ | ||
| 129 | | (is_modal) << 26 | ((vid) & 0xffff)) | ||
| 130 | |||
| 131 | #define PD_IDH_PTYPE(vdo) (((vdo) >> 27) & 0x7) | ||
| 132 | #define PD_IDH_VID(vdo) ((vdo) & 0xffff) | ||
| 133 | #define PD_IDH_MODAL_SUPP(vdo) ((vdo) & (1 << 26)) | ||
| 134 | |||
| 135 | /* | ||
| 136 | * Cert Stat VDO | ||
| 137 | * ------------- | ||
| 138 | * <31:0> : USB-IF assigned XID for this cable | ||
| 139 | */ | ||
| 140 | #define PD_CSTAT_XID(vdo) (vdo) | ||
| 141 | |||
| 142 | /* | ||
| 143 | * Product VDO | ||
| 144 | * ----------- | ||
| 145 | * <31:16> : USB Product ID | ||
| 146 | * <15:0> : USB bcdDevice | ||
| 147 | */ | ||
| 148 | #define VDO_PRODUCT(pid, bcd) (((pid) & 0xffff) << 16 | ((bcd) & 0xffff)) | ||
| 149 | #define PD_PRODUCT_PID(vdo) (((vdo) >> 16) & 0xffff) | ||
| 150 | |||
| 151 | /* | ||
| 152 | * Cable VDO | ||
| 153 | * --------- | ||
| 154 | * <31:28> :: Cable HW version | ||
| 155 | * <27:24> :: Cable FW version | ||
| 156 | * <23:20> :: Reserved, Shall be set to zero | ||
| 157 | * <19:18> :: type-C to Type-A/B/C (00b == A, 01 == B, 10 == C) | ||
| 158 | * <17> :: Type-C to Plug/Receptacle (0b == plug, 1b == receptacle) | ||
| 159 | * <16:13> :: cable latency (0001 == <10ns(~1m length)) | ||
| 160 | * <12:11> :: cable termination type (11b == both ends active VCONN req) | ||
| 161 | * <10> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable) | ||
| 162 | * <9> :: SSTX2 Directionality support | ||
| 163 | * <8> :: SSRX1 Directionality support | ||
| 164 | * <7> :: SSRX2 Directionality support | ||
| 165 | * <6:5> :: Vbus current handling capability | ||
| 166 | * <4> :: Vbus through cable (0b == no, 1b == yes) | ||
| 167 | * <3> :: SOP" controller present? (0b == no, 1b == yes) | ||
| 168 | * <2:0> :: USB SS Signaling support | ||
| 169 | */ | ||
| 170 | #define CABLE_ATYPE 0 | ||
| 171 | #define CABLE_BTYPE 1 | ||
| 172 | #define CABLE_CTYPE 2 | ||
| 173 | #define CABLE_PLUG 0 | ||
| 174 | #define CABLE_RECEPTACLE 1 | ||
| 175 | #define CABLE_CURR_1A5 0 | ||
| 176 | #define CABLE_CURR_3A 1 | ||
| 177 | #define CABLE_CURR_5A 2 | ||
| 178 | #define CABLE_USBSS_U2_ONLY 0 | ||
| 179 | #define CABLE_USBSS_U31_GEN1 1 | ||
| 180 | #define CABLE_USBSS_U31_GEN2 2 | ||
| 181 | #define VDO_CABLE(hw, fw, cbl, gdr, lat, term, tx1d, tx2d, rx1d, rx2d, cur,\ | ||
| 182 | vps, sopp, usbss) \ | ||
| 183 | (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 | ((cbl) & 0x3) << 18 \ | ||
| 184 | | (gdr) << 17 | ((lat) & 0x7) << 13 | ((term) & 0x3) << 11 \ | ||
| 185 | | (tx1d) << 10 | (tx2d) << 9 | (rx1d) << 8 | (rx2d) << 7 \ | ||
| 186 | | ((cur) & 0x3) << 5 | (vps) << 4 | (sopp) << 3 \ | ||
| 187 | | ((usbss) & 0x7)) | ||
| 188 | |||
| 189 | /* | ||
| 190 | * AMA VDO | ||
| 191 | * --------- | ||
| 192 | * <31:28> :: Cable HW version | ||
| 193 | * <27:24> :: Cable FW version | ||
| 194 | * <23:12> :: Reserved, Shall be set to zero | ||
| 195 | * <11> :: SSTX1 Directionality support (0b == fixed, 1b == cfgable) | ||
| 196 | * <10> :: SSTX2 Directionality support | ||
| 197 | * <9> :: SSRX1 Directionality support | ||
| 198 | * <8> :: SSRX2 Directionality support | ||
| 199 | * <7:5> :: Vconn power | ||
| 200 | * <4> :: Vconn power required | ||
| 201 | * <3> :: Vbus power required | ||
| 202 | * <2:0> :: USB SS Signaling support | ||
| 203 | */ | ||
| 204 | #define VDO_AMA(hw, fw, tx1d, tx2d, rx1d, rx2d, vcpwr, vcr, vbr, usbss) \ | ||
| 205 | (((hw) & 0x7) << 28 | ((fw) & 0x7) << 24 \ | ||
| 206 | | (tx1d) << 11 | (tx2d) << 10 | (rx1d) << 9 | (rx2d) << 8 \ | ||
| 207 | | ((vcpwr) & 0x7) << 5 | (vcr) << 4 | (vbr) << 3 \ | ||
| 208 | | ((usbss) & 0x7)) | ||
| 209 | |||
| 210 | #define PD_VDO_AMA_VCONN_REQ(vdo) (((vdo) >> 4) & 1) | ||
| 211 | #define PD_VDO_AMA_VBUS_REQ(vdo) (((vdo) >> 3) & 1) | ||
| 212 | |||
| 213 | #define AMA_VCONN_PWR_1W 0 | ||
| 214 | #define AMA_VCONN_PWR_1W5 1 | ||
| 215 | #define AMA_VCONN_PWR_2W 2 | ||
| 216 | #define AMA_VCONN_PWR_3W 3 | ||
| 217 | #define AMA_VCONN_PWR_4W 4 | ||
| 218 | #define AMA_VCONN_PWR_5W 5 | ||
| 219 | #define AMA_VCONN_PWR_6W 6 | ||
| 220 | #define AMA_USBSS_U2_ONLY 0 | ||
| 221 | #define AMA_USBSS_U31_GEN1 1 | ||
| 222 | #define AMA_USBSS_U31_GEN2 2 | ||
| 223 | #define AMA_USBSS_BBONLY 3 | ||
| 224 | |||
| 225 | /* | ||
| 226 | * SVDM Discover SVIDs request -> response | ||
| 227 | * | ||
| 228 | * Request is properly formatted VDM Header with discover SVIDs command. | ||
| 229 | * Response is a set of SVIDs of all all supported SVIDs with all zero's to | ||
| 230 | * mark the end of SVIDs. If more than 12 SVIDs are supported command SHOULD be | ||
| 231 | * repeated. | ||
| 232 | */ | ||
| 233 | #define VDO_SVID(svid0, svid1) (((svid0) & 0xffff) << 16 | ((svid1) & 0xffff)) | ||
| 234 | #define PD_VDO_SVID_SVID0(vdo) ((vdo) >> 16) | ||
| 235 | #define PD_VDO_SVID_SVID1(vdo) ((vdo) & 0xffff) | ||
| 236 | |||
| 237 | /* USB-IF SIDs */ | ||
| 238 | #define USB_SID_PD 0xff00 /* power delivery */ | ||
| 239 | #define USB_SID_DISPLAYPORT 0xff01 | ||
| 240 | #define USB_SID_MHL 0xff02 /* Mobile High-Definition Link */ | ||
| 241 | |||
| 242 | /* VDM command timeouts (in ms) */ | ||
| 243 | |||
| 244 | #define PD_T_VDM_UNSTRUCTURED 500 | ||
| 245 | #define PD_T_VDM_BUSY 100 | ||
| 246 | #define PD_T_VDM_WAIT_MODE_E 100 | ||
| 247 | #define PD_T_VDM_SNDR_RSP 30 | ||
| 248 | #define PD_T_VDM_E_MODE 25 | ||
| 249 | #define PD_T_VDM_RCVR_RSP 15 | ||
| 250 | |||
| 251 | #endif /* __LINUX_USB_PD_VDO_H */ | ||
diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h new file mode 100644 index 000000000000..073197f0d2bb --- /dev/null +++ b/include/linux/usb/tcpm.h | |||
| @@ -0,0 +1,204 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2015-2017 Google, Inc | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify | ||
| 5 | * it under the terms of the GNU General Public License as published by | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or | ||
| 7 | * (at your option) any later version. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef __LINUX_USB_TCPM_H | ||
| 16 | #define __LINUX_USB_TCPM_H | ||
| 17 | |||
| 18 | #include <linux/bitops.h> | ||
| 19 | #include <linux/usb/typec.h> | ||
| 20 | #include "pd.h" | ||
| 21 | |||
| 22 | enum typec_cc_status { | ||
| 23 | TYPEC_CC_OPEN, | ||
| 24 | TYPEC_CC_RA, | ||
| 25 | TYPEC_CC_RD, | ||
| 26 | TYPEC_CC_RP_DEF, | ||
| 27 | TYPEC_CC_RP_1_5, | ||
| 28 | TYPEC_CC_RP_3_0, | ||
| 29 | }; | ||
| 30 | |||
| 31 | enum typec_cc_polarity { | ||
| 32 | TYPEC_POLARITY_CC1, | ||
| 33 | TYPEC_POLARITY_CC2, | ||
| 34 | }; | ||
| 35 | |||
| 36 | /* Time to wait for TCPC to complete transmit */ | ||
| 37 | #define PD_T_TCPC_TX_TIMEOUT 100 /* in ms */ | ||
| 38 | #define PD_ROLE_SWAP_TIMEOUT (MSEC_PER_SEC * 10) | ||
| 39 | |||
| 40 | enum tcpm_transmit_status { | ||
| 41 | TCPC_TX_SUCCESS = 0, | ||
| 42 | TCPC_TX_DISCARDED = 1, | ||
| 43 | TCPC_TX_FAILED = 2, | ||
| 44 | }; | ||
| 45 | |||
| 46 | enum tcpm_transmit_type { | ||
| 47 | TCPC_TX_SOP = 0, | ||
| 48 | TCPC_TX_SOP_PRIME = 1, | ||
| 49 | TCPC_TX_SOP_PRIME_PRIME = 2, | ||
| 50 | TCPC_TX_SOP_DEBUG_PRIME = 3, | ||
| 51 | TCPC_TX_SOP_DEBUG_PRIME_PRIME = 4, | ||
| 52 | TCPC_TX_HARD_RESET = 5, | ||
| 53 | TCPC_TX_CABLE_RESET = 6, | ||
| 54 | TCPC_TX_BIST_MODE_2 = 7 | ||
| 55 | }; | ||
| 56 | |||
| 57 | /** | ||
| 58 | * struct tcpc_config - Port configuration | ||
| 59 | * @src_pdo: PDO parameters sent to port partner as response to | ||
| 60 | * PD_CTRL_GET_SOURCE_CAP message | ||
| 61 | * @nr_src_pdo: Number of entries in @src_pdo | ||
| 62 | * @snk_pdo: PDO parameters sent to partner as response to | ||
| 63 | * PD_CTRL_GET_SINK_CAP message | ||
| 64 | * @nr_snk_pdo: Number of entries in @snk_pdo | ||
| 65 | * @max_snk_mv: Maximum acceptable sink voltage in mV | ||
| 66 | * @max_snk_ma: Maximum sink current in mA | ||
| 67 | * @max_snk_mw: Maximum required sink power in mW | ||
| 68 | * @operating_snk_mw: | ||
| 69 | * Required operating sink power in mW | ||
| 70 | * @type: Port type (TYPEC_PORT_DFP, TYPEC_PORT_UFP, or | ||
| 71 | * TYPEC_PORT_DRP) | ||
| 72 | * @default_role: | ||
| 73 | * Default port role (TYPEC_SINK or TYPEC_SOURCE). | ||
| 74 | * Set to TYPEC_NO_PREFERRED_ROLE if no default role. | ||
| 75 | * @try_role_hw:True if try.{Src,Snk} is implemented in hardware | ||
| 76 | * @alt_modes: List of supported alternate modes | ||
| 77 | */ | ||
| 78 | struct tcpc_config { | ||
| 79 | const u32 *src_pdo; | ||
| 80 | unsigned int nr_src_pdo; | ||
| 81 | |||
| 82 | const u32 *snk_pdo; | ||
| 83 | unsigned int nr_snk_pdo; | ||
| 84 | |||
| 85 | const u32 *snk_vdo; | ||
| 86 | unsigned int nr_snk_vdo; | ||
| 87 | |||
| 88 | unsigned int max_snk_mv; | ||
| 89 | unsigned int max_snk_ma; | ||
| 90 | unsigned int max_snk_mw; | ||
| 91 | unsigned int operating_snk_mw; | ||
| 92 | |||
| 93 | enum typec_port_type type; | ||
| 94 | enum typec_role default_role; | ||
| 95 | bool try_role_hw; /* try.{src,snk} implemented in hardware */ | ||
| 96 | |||
| 97 | const struct typec_altmode_desc *alt_modes; | ||
| 98 | }; | ||
| 99 | |||
| 100 | enum tcpc_usb_switch { | ||
| 101 | TCPC_USB_SWITCH_CONNECT, | ||
| 102 | TCPC_USB_SWITCH_DISCONNECT, | ||
| 103 | }; | ||
| 104 | |||
| 105 | /* Mux state attributes */ | ||
| 106 | #define TCPC_MUX_USB_ENABLED BIT(0) /* USB enabled */ | ||
| 107 | #define TCPC_MUX_DP_ENABLED BIT(1) /* DP enabled */ | ||
| 108 | #define TCPC_MUX_POLARITY_INVERTED BIT(2) /* Polarity inverted */ | ||
| 109 | |||
| 110 | /* Mux modes, decoded to attributes */ | ||
| 111 | enum tcpc_mux_mode { | ||
| 112 | TYPEC_MUX_NONE = 0, /* Open switch */ | ||
| 113 | TYPEC_MUX_USB = TCPC_MUX_USB_ENABLED, /* USB only */ | ||
| 114 | TYPEC_MUX_DP = TCPC_MUX_DP_ENABLED, /* DP only */ | ||
| 115 | TYPEC_MUX_DOCK = TCPC_MUX_USB_ENABLED | /* Both USB and DP */ | ||
| 116 | TCPC_MUX_DP_ENABLED, | ||
| 117 | }; | ||
| 118 | |||
| 119 | struct tcpc_mux_dev { | ||
| 120 | int (*set)(struct tcpc_mux_dev *dev, enum tcpc_mux_mode mux_mode, | ||
| 121 | enum tcpc_usb_switch usb_config, | ||
| 122 | enum typec_cc_polarity polarity); | ||
| 123 | bool dfp_only; | ||
| 124 | void *priv_data; | ||
| 125 | }; | ||
| 126 | |||
| 127 | /** | ||
| 128 | * struct tcpc_dev - Port configuration and callback functions | ||
| 129 | * @config: Pointer to port configuration | ||
| 130 | * @get_vbus: Called to read current VBUS state | ||
| 131 | * @get_current_limit: | ||
| 132 | * Optional; called by the tcpm core when configured as a snk | ||
| 133 | * and cc=Rp-def. This allows the tcpm to provide a fallback | ||
| 134 | * current-limit detection method for the cc=Rp-def case. | ||
| 135 | * For example, some tcpcs may include BC1.2 charger detection | ||
| 136 | * and use that in this case. | ||
| 137 | * @set_cc: Called to set value of CC pins | ||
| 138 | * @get_cc: Called to read current CC pin values | ||
| 139 | * @set_polarity: | ||
| 140 | * Called to set polarity | ||
| 141 | * @set_vconn: Called to enable or disable VCONN | ||
| 142 | * @set_vbus: Called to enable or disable VBUS | ||
| 143 | * @set_current_limit: | ||
| 144 | * Optional; called to set current limit as negotiated | ||
| 145 | * with partner. | ||
| 146 | * @set_pd_rx: Called to enable or disable reception of PD messages | ||
| 147 | * @set_roles: Called to set power and data roles | ||
| 148 | * @start_drp_toggling: | ||
| 149 | * Optional; if supported by hardware, called to start DRP | ||
| 150 | * toggling. DRP toggling is stopped automatically if | ||
| 151 | * a connection is established. | ||
| 152 | * @try_role: Optional; called to set a preferred role | ||
| 153 | * @pd_transmit:Called to transmit PD message | ||
| 154 | * @mux: Pointer to multiplexer data | ||
| 155 | */ | ||
| 156 | struct tcpc_dev { | ||
| 157 | const struct tcpc_config *config; | ||
| 158 | |||
| 159 | int (*init)(struct tcpc_dev *dev); | ||
| 160 | int (*get_vbus)(struct tcpc_dev *dev); | ||
| 161 | int (*get_current_limit)(struct tcpc_dev *dev); | ||
| 162 | int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc); | ||
| 163 | int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1, | ||
| 164 | enum typec_cc_status *cc2); | ||
| 165 | int (*set_polarity)(struct tcpc_dev *dev, | ||
| 166 | enum typec_cc_polarity polarity); | ||
| 167 | int (*set_vconn)(struct tcpc_dev *dev, bool on); | ||
| 168 | int (*set_vbus)(struct tcpc_dev *dev, bool on, bool charge); | ||
| 169 | int (*set_current_limit)(struct tcpc_dev *dev, u32 max_ma, u32 mv); | ||
| 170 | int (*set_pd_rx)(struct tcpc_dev *dev, bool on); | ||
| 171 | int (*set_roles)(struct tcpc_dev *dev, bool attached, | ||
| 172 | enum typec_role role, enum typec_data_role data); | ||
| 173 | int (*start_drp_toggling)(struct tcpc_dev *dev, | ||
| 174 | enum typec_cc_status cc); | ||
| 175 | int (*try_role)(struct tcpc_dev *dev, int role); | ||
| 176 | int (*pd_transmit)(struct tcpc_dev *dev, enum tcpm_transmit_type type, | ||
| 177 | const struct pd_message *msg); | ||
| 178 | struct tcpc_mux_dev *mux; | ||
| 179 | }; | ||
| 180 | |||
| 181 | struct tcpm_port; | ||
| 182 | |||
| 183 | struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc); | ||
| 184 | void tcpm_unregister_port(struct tcpm_port *port); | ||
| 185 | |||
| 186 | void tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, | ||
| 187 | unsigned int nr_pdo); | ||
| 188 | void tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, | ||
| 189 | unsigned int nr_pdo, | ||
| 190 | unsigned int max_snk_mv, | ||
| 191 | unsigned int max_snk_ma, | ||
| 192 | unsigned int max_snk_mw, | ||
| 193 | unsigned int operating_snk_mw); | ||
| 194 | |||
| 195 | void tcpm_vbus_change(struct tcpm_port *port); | ||
| 196 | void tcpm_cc_change(struct tcpm_port *port); | ||
| 197 | void tcpm_pd_receive(struct tcpm_port *port, | ||
| 198 | const struct pd_message *msg); | ||
| 199 | void tcpm_pd_transmit_complete(struct tcpm_port *port, | ||
| 200 | enum tcpm_transmit_status status); | ||
| 201 | void tcpm_pd_hard_reset(struct tcpm_port *port); | ||
| 202 | void tcpm_tcpc_reset(struct tcpm_port *port); | ||
| 203 | |||
| 204 | #endif /* __LINUX_USB_TCPM_H */ | ||
