.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * 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 | 4 | */ |
---|
14 | 5 | |
---|
15 | 6 | #ifndef __LINUX_USB_TCPM_H |
---|
.. | .. |
---|
75 | 66 | * For example, some tcpcs may include BC1.2 charger detection |
---|
76 | 67 | * and use that in this case. |
---|
77 | 68 | * @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. |
---|
78 | 71 | * @get_cc: Called to read current CC pin values |
---|
79 | 72 | * @set_polarity: |
---|
80 | 73 | * Called to set polarity |
---|
.. | .. |
---|
91 | 84 | * automatically if a connection is established. |
---|
92 | 85 | * @try_role: Optional; called to set a preferred role |
---|
93 | 86 | * @pd_transmit:Called to transmit PD message |
---|
| 87 | + * @set_bist_data: Turn on/off bist data mode for compliance testing |
---|
94 | 88 | * @enable_frs: |
---|
95 | 89 | * Optional; Called to enable/disable PD 3.0 fast role swap. |
---|
96 | 90 | * Enabling frs is accessory dependent as not all PD3.0 |
---|
97 | 91 | * 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. |
---|
98 | 125 | */ |
---|
99 | 126 | struct tcpc_dev { |
---|
100 | 127 | struct fwnode_handle *fwnode; |
---|
.. | .. |
---|
103 | 130 | int (*get_vbus)(struct tcpc_dev *dev); |
---|
104 | 131 | int (*get_current_limit)(struct tcpc_dev *dev); |
---|
105 | 132 | 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); |
---|
106 | 135 | int (*get_cc)(struct tcpc_dev *dev, enum typec_cc_status *cc1, |
---|
107 | 136 | enum typec_cc_status *cc2); |
---|
108 | 137 | int (*set_polarity)(struct tcpc_dev *dev, |
---|
.. | .. |
---|
118 | 147 | enum typec_cc_status cc); |
---|
119 | 148 | int (*try_role)(struct tcpc_dev *dev, int role); |
---|
120 | 149 | 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); |
---|
122 | 152 | 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); |
---|
123 | 160 | }; |
---|
124 | 161 | |
---|
125 | 162 | struct tcpm_port; |
---|
.. | .. |
---|
127 | 164 | struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc); |
---|
128 | 165 | void tcpm_unregister_port(struct tcpm_port *port); |
---|
129 | 166 | |
---|
130 | | -int tcpm_update_source_capabilities(struct tcpm_port *port, const u32 *pdo, |
---|
131 | | - unsigned int nr_pdo); |
---|
132 | 167 | int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, |
---|
133 | 168 | unsigned int nr_pdo, |
---|
134 | 169 | unsigned int operating_snk_mw); |
---|
.. | .. |
---|
143 | 178 | enum tcpm_transmit_status status); |
---|
144 | 179 | void tcpm_pd_hard_reset(struct tcpm_port *port); |
---|
145 | 180 | 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); |
---|
146 | 183 | |
---|
147 | 184 | #endif /* __LINUX_USB_TCPM_H */ |
---|