hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/usb/tcpm.h
....@@ -1,15 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * 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.
134 */
145
156 #ifndef __LINUX_USB_TCPM_H
....@@ -75,6 +66,8 @@
7566 * For example, some tcpcs may include BC1.2 charger detection
7667 * and use that in this case.
7768 * @set_cc: Called to set value of CC pins
69
+ * @apply_rc: Optional; Needed to move TCPCI based chipset to APPLY_RC state
70
+ * as stated by the TCPCI specification.
7871 * @get_cc: Called to read current CC pin values
7972 * @set_polarity:
8073 * Called to set polarity
....@@ -91,10 +84,44 @@
9184 * automatically if a connection is established.
9285 * @try_role: Optional; called to set a preferred role
9386 * @pd_transmit:Called to transmit PD message
87
+ * @set_bist_data: Turn on/off bist data mode for compliance testing
9488 * @enable_frs:
9589 * Optional; Called to enable/disable PD 3.0 fast role swap.
9690 * Enabling frs is accessory dependent as not all PD3.0
9791 * accessories support fast role swap.
92
+ * @frs_sourcing_vbus:
93
+ * Optional; Called to notify that vbus is now being sourced.
94
+ * Low level drivers can perform chip specific operations, if any.
95
+ * @enable_auto_vbus_discharge:
96
+ * Optional; TCPCI spec based TCPC implementations can optionally
97
+ * support hardware to autonomously dischrge vbus upon disconnecting
98
+ * as sink or source. TCPM signals TCPC to enable the mechanism upon
99
+ * entering connected state and signals disabling upon disconnect.
100
+ * @set_auto_vbus_discharge_threshold:
101
+ * Mandatory when enable_auto_vbus_discharge is implemented. TCPM
102
+ * calls this function to allow lower levels drivers to program the
103
+ * vbus threshold voltage below which the vbus discharge circuit
104
+ * will be turned on. requested_vbus_voltage is set to 0 when vbus
105
+ * is going to disappear knowingly i.e. during PR_SWAP and
106
+ * HARD_RESET etc.
107
+ * @is_vbus_vsafe0v:
108
+ * Optional; TCPCI spec based TCPC implementations are expected to
109
+ * detect VSAFE0V voltage level at vbus. When detection of VSAFE0V
110
+ * is supported by TCPC, set this callback for TCPM to query
111
+ * whether vbus is at VSAFE0V when needed.
112
+ * Returns true when vbus is at VSAFE0V, false otherwise.
113
+ * @set_partner_usb_comm_capable:
114
+ * Optional; The USB Communications Capable bit indicates if port
115
+ * partner is capable of communication over the USB data lines
116
+ * (e.g. D+/- or SS Tx/Rx). Called to notify the status of the bit.
117
+ * @check_contaminant:
118
+ * Optional; The callback is called when CC pins report open status
119
+ * at the end of the toggling period. Chip level drivers are
120
+ * expected to check for contaminant and re-enable toggling if
121
+ * needed. When 0 is not returned, check_contaminant is expected to
122
+ * restart toggling after checking the connector for contaminant.
123
+ * This forces the TCPM state machine to tranistion to TOGGLING state
124
+ * without calling start_toggling callback.
98125 */
99126 struct tcpc_dev {
100127 struct fwnode_handle *fwnode;
....@@ -103,6 +130,8 @@
103130 int (*get_vbus)(struct tcpc_dev *dev);
104131 int (*get_current_limit)(struct tcpc_dev *dev);
105132 int (*set_cc)(struct tcpc_dev *dev, enum typec_cc_status cc);
133
+ int (*apply_rc)(struct tcpc_dev *dev, enum typec_cc_status cc,
134
+ enum typec_cc_polarity polarity);
106135 int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1,
107136 enum typec_cc_status *cc2);
108137 int (*set_polarity)(struct tcpc_dev *dev,
....@@ -118,8 +147,16 @@
118147 enum typec_cc_status cc);
119148 int (*try_role)(struct tcpc_dev *dev, int role);
120149 int (*pd_transmit)(struct tcpc_dev *dev, enum tcpm_transmit_type type,
121
- const struct pd_message *msg);
150
+ const struct pd_message *msg, unsigned int negotiated_rev);
151
+ int (*set_bist_data)(struct tcpc_dev *dev, bool on);
122152 int (*enable_frs)(struct tcpc_dev *dev, bool enable);
153
+ void (*frs_sourcing_vbus)(struct tcpc_dev *dev);
154
+ int (*enable_auto_vbus_discharge)(struct tcpc_dev *dev, bool enable);
155
+ int (*set_auto_vbus_discharge_threshold)(struct tcpc_dev *dev, enum typec_pwr_opmode mode,
156
+ bool pps_active, u32 requested_vbus_voltage);
157
+ int (*check_contaminant)(struct tcpc_dev *dev);
158
+ bool (*is_vbus_vsafe0v)(struct tcpc_dev *dev);
159
+ void (*set_partner_usb_comm_capable)(struct tcpc_dev *dev, bool enable);
123160 };
124161
125162 struct tcpm_port;
....@@ -127,8 +164,6 @@
127164 struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc);
128165 void tcpm_unregister_port(struct tcpm_port *port);
129166
130
-int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo,
131
- unsigned int nr_pdo);
132167 int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo,
133168 unsigned int nr_pdo,
134169 unsigned int operating_snk_mw);
....@@ -143,5 +178,7 @@
143178 enum tcpm_transmit_status status);
144179 void tcpm_pd_hard_reset(struct tcpm_port *port);
145180 void tcpm_tcpc_reset(struct tcpm_port *port);
181
+bool tcpm_is_debouncing(struct tcpm_port *tcpm);
182
+bool tcpm_is_toggling(struct tcpm_port *port);
146183
147184 #endif /* __LINUX_USB_TCPM_H */