Greg Kroah-Hartman | 5fd54ac | 2017-11-03 11:28:30 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 2 | /* Copyright (C) 2007,2008 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License as published by the |
| 6 | * Free Software Foundation; either version 2 of the License, or (at your |
| 7 | * option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but |
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along |
| 15 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | * 675 Mass Ave, Cambridge, MA 02139, USA. |
| 17 | */ |
| 18 | |
Anton Tikhomirov | d49dd78 | 2013-11-26 10:08:58 -0600 | [diff] [blame] | 19 | #ifndef __LINUX_USB_OTG_FSM_H |
| 20 | #define __LINUX_USB_OTG_FSM_H |
| 21 | |
Anton Tikhomirov | 16e569e | 2013-11-26 11:46:05 +0900 | [diff] [blame] | 22 | #include <linux/mutex.h> |
Felipe Balbi | cc9d9cc | 2013-11-26 10:06:00 -0600 | [diff] [blame] | 23 | #include <linux/errno.h> |
| 24 | |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 25 | #define PROTO_UNDEF (0) |
| 26 | #define PROTO_HOST (1) |
| 27 | #define PROTO_GADGET (2) |
| 28 | |
Li Jun | ae57e97 | 2016-02-19 10:04:42 +0800 | [diff] [blame] | 29 | #define OTG_STS_SELECTOR 0xF000 /* OTG status selector, according to |
| 30 | * OTG and EH 2.0 Chapter 6.2.3 |
| 31 | * Table:6-4 |
| 32 | */ |
| 33 | |
| 34 | #define HOST_REQUEST_FLAG 1 /* Host request flag, according to |
| 35 | * OTG and EH 2.0 Charpter 6.2.3 |
| 36 | * Table:6-5 |
| 37 | */ |
| 38 | |
| 39 | #define T_HOST_REQ_POLL (1500) /* 1500ms, HNP polling interval */ |
| 40 | |
Anton Tikhomirov | f6de27e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 41 | enum otg_fsm_timer { |
Anton Tikhomirov | 3294908 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 42 | /* Standard OTG timers */ |
Anton Tikhomirov | f6de27e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 43 | A_WAIT_VRISE, |
Anton Tikhomirov | 3294908 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 44 | A_WAIT_VFALL, |
Anton Tikhomirov | f6de27e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 45 | A_WAIT_BCON, |
| 46 | A_AIDL_BDIS, |
| 47 | B_ASE0_BRST, |
Anton Tikhomirov | 3294908 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 48 | A_BIDL_ADIS, |
Li Jun | 9c527f4 | 2016-02-19 10:04:48 +0800 | [diff] [blame] | 49 | B_AIDL_BDIS, |
Anton Tikhomirov | 3294908 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 50 | |
| 51 | /* Auxiliary timers */ |
Anton Tikhomirov | f6de27e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 52 | B_SE0_SRP, |
| 53 | B_SRP_FAIL, |
| 54 | A_WAIT_ENUM, |
Li Jun | 2f8a467 | 2015-03-20 16:28:05 +0800 | [diff] [blame] | 55 | B_DATA_PLS, |
| 56 | B_SSEND_SRP, |
Anton Tikhomirov | 3294908 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 57 | |
Anton Tikhomirov | f6de27e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 58 | NUM_OTG_FSM_TIMERS, |
| 59 | }; |
| 60 | |
Roger Quadros | fa59507f | 2016-03-30 12:56:28 +0300 | [diff] [blame] | 61 | /** |
| 62 | * struct otg_fsm - OTG state machine according to the OTG spec |
| 63 | * |
| 64 | * OTG hardware Inputs |
| 65 | * |
| 66 | * Common inputs for A and B device |
| 67 | * @id: TRUE for B-device, FALSE for A-device. |
| 68 | * @adp_change: TRUE when current ADP measurement (n) value, compared to the |
| 69 | * ADP measurement taken at n-2, differs by more than CADP_THR |
| 70 | * @power_up: TRUE when the OTG device first powers up its USB system and |
| 71 | * ADP measurement taken if ADP capable |
| 72 | * |
| 73 | * A-Device state inputs |
| 74 | * @a_srp_det: TRUE if the A-device detects SRP |
| 75 | * @a_vbus_vld: TRUE when VBUS voltage is in regulation |
| 76 | * @b_conn: TRUE if the A-device detects connection from the B-device |
| 77 | * @a_bus_resume: TRUE when the B-device detects that the A-device is signaling |
| 78 | * a resume (K state) |
| 79 | * B-Device state inputs |
| 80 | * @a_bus_suspend: TRUE when the B-device detects that the A-device has put the |
| 81 | * bus into suspend |
| 82 | * @a_conn: TRUE if the B-device detects a connection from the A-device |
| 83 | * @b_se0_srp: TRUE when the line has been at SE0 for more than the minimum |
| 84 | * time before generating SRP |
| 85 | * @b_ssend_srp: TRUE when the VBUS has been below VOTG_SESS_VLD for more than |
| 86 | * the minimum time before generating SRP |
| 87 | * @b_sess_vld: TRUE when the B-device detects that the voltage on VBUS is |
| 88 | * above VOTG_SESS_VLD |
| 89 | * @test_device: TRUE when the B-device switches to B-Host and detects an OTG |
| 90 | * test device. This must be set by host/hub driver |
| 91 | * |
| 92 | * Application inputs (A-Device) |
| 93 | * @a_bus_drop: TRUE when A-device application needs to power down the bus |
| 94 | * @a_bus_req: TRUE when A-device application wants to use the bus. |
| 95 | * FALSE to suspend the bus |
| 96 | * |
| 97 | * Application inputs (B-Device) |
| 98 | * @b_bus_req: TRUE during the time that the Application running on the |
| 99 | * B-device wants to use the bus |
| 100 | * |
| 101 | * Auxilary inputs (OTG v1.3 only. Obsolete now.) |
| 102 | * @a_sess_vld: TRUE if the A-device detects that VBUS is above VA_SESS_VLD |
| 103 | * @b_bus_suspend: TRUE when the A-device detects that the B-device has put |
| 104 | * the bus into suspend |
| 105 | * @b_bus_resume: TRUE when the A-device detects that the B-device is signaling |
| 106 | * resume on the bus |
| 107 | * |
| 108 | * OTG Output status. Read only for users. Updated by OTG FSM helpers defined |
| 109 | * in this file |
| 110 | * |
| 111 | * Outputs for Both A and B device |
| 112 | * @drv_vbus: TRUE when A-device is driving VBUS |
| 113 | * @loc_conn: TRUE when the local device has signaled that it is connected |
| 114 | * to the bus |
| 115 | * @loc_sof: TRUE when the local device is generating activity on the bus |
| 116 | * @adp_prb: TRUE when the local device is in the process of doing |
| 117 | * ADP probing |
| 118 | * |
| 119 | * Outputs for B-device state |
| 120 | * @adp_sns: TRUE when the B-device is in the process of carrying out |
| 121 | * ADP sensing |
| 122 | * @data_pulse: TRUE when the B-device is performing data line pulsing |
| 123 | * |
| 124 | * Internal Variables |
| 125 | * |
| 126 | * a_set_b_hnp_en: TRUE when the A-device has successfully set the |
| 127 | * b_hnp_enable bit in the B-device. |
| 128 | * Unused as OTG fsm uses otg->host->b_hnp_enable instead |
| 129 | * b_srp_done: TRUE when the B-device has completed initiating SRP |
| 130 | * b_hnp_enable: TRUE when the B-device has accepted the |
| 131 | * SetFeature(b_hnp_enable) B-device. |
| 132 | * Unused as OTG fsm uses otg->gadget->b_hnp_enable instead |
| 133 | * a_clr_err: Asserted (by application ?) to clear a_vbus_err due to an |
| 134 | * overcurrent condition and causes the A-device to transition |
| 135 | * to a_wait_vfall |
| 136 | */ |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 137 | struct otg_fsm { |
| 138 | /* Input */ |
Anton Tikhomirov | 4662e5e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 139 | int id; |
Anton Tikhomirov | ec04996 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 140 | int adp_change; |
| 141 | int power_up; |
Anton Tikhomirov | 4662e5e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 142 | int a_srp_det; |
| 143 | int a_vbus_vld; |
| 144 | int b_conn; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 145 | int a_bus_resume; |
| 146 | int a_bus_suspend; |
| 147 | int a_conn; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 148 | int b_se0_srp; |
Anton Tikhomirov | 6804178 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 149 | int b_ssend_srp; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 150 | int b_sess_vld; |
Roger Quadros | fa59507f | 2016-03-30 12:56:28 +0300 | [diff] [blame] | 151 | int test_device; |
| 152 | int a_bus_drop; |
| 153 | int a_bus_req; |
| 154 | int b_bus_req; |
| 155 | |
Anton Tikhomirov | 4662e5e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 156 | /* Auxilary inputs */ |
| 157 | int a_sess_vld; |
| 158 | int b_bus_resume; |
| 159 | int b_bus_suspend; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 160 | |
| 161 | /* Output */ |
| 162 | int drv_vbus; |
| 163 | int loc_conn; |
| 164 | int loc_sof; |
Anton Tikhomirov | ec04996 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 165 | int adp_prb; |
| 166 | int adp_sns; |
Roger Quadros | fa59507f | 2016-03-30 12:56:28 +0300 | [diff] [blame] | 167 | int data_pulse; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 168 | |
Anton Tikhomirov | 4662e5e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 169 | /* Internal variables */ |
| 170 | int a_set_b_hnp_en; |
| 171 | int b_srp_done; |
| 172 | int b_hnp_enable; |
| 173 | int a_clr_err; |
| 174 | |
Roger Quadros | fa59507f | 2016-03-30 12:56:28 +0300 | [diff] [blame] | 175 | /* Informative variables. All unused as of now */ |
Anton Tikhomirov | 4662e5e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 176 | int a_bus_drop_inf; |
| 177 | int a_bus_req_inf; |
| 178 | int a_clr_err_inf; |
| 179 | int b_bus_req_inf; |
| 180 | /* Auxilary informative variables */ |
| 181 | int a_suspend_req_inf; |
| 182 | |
| 183 | /* Timeout indicator for timers */ |
| 184 | int a_wait_vrise_tmout; |
| 185 | int a_wait_vfall_tmout; |
| 186 | int a_wait_bcon_tmout; |
| 187 | int a_aidl_bdis_tmout; |
| 188 | int b_ase0_brst_tmout; |
| 189 | int a_bidl_adis_tmout; |
| 190 | |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 191 | struct otg_fsm_ops *ops; |
Heikki Krogerus | 7e062c0 | 2012-02-13 13:24:06 +0200 | [diff] [blame] | 192 | struct usb_otg *otg; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 193 | |
| 194 | /* Current usb protocol used: 0:undefine; 1:host; 2:client */ |
| 195 | int protocol; |
Anton Tikhomirov | 16e569e | 2013-11-26 11:46:05 +0900 | [diff] [blame] | 196 | struct mutex lock; |
Li Jun | ae57e97 | 2016-02-19 10:04:42 +0800 | [diff] [blame] | 197 | u8 *host_req_flag; |
| 198 | struct delayed_work hnp_polling_work; |
Roger Quadros | 4e332df | 2016-03-30 12:56:29 +0300 | [diff] [blame] | 199 | bool state_changed; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 200 | }; |
| 201 | |
| 202 | struct otg_fsm_ops { |
Anton Tikhomirov | da8cc16 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 203 | void (*chrg_vbus)(struct otg_fsm *fsm, int on); |
| 204 | void (*drv_vbus)(struct otg_fsm *fsm, int on); |
| 205 | void (*loc_conn)(struct otg_fsm *fsm, int on); |
| 206 | void (*loc_sof)(struct otg_fsm *fsm, int on); |
| 207 | void (*start_pulse)(struct otg_fsm *fsm); |
Anton Tikhomirov | ec04996 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 208 | void (*start_adp_prb)(struct otg_fsm *fsm); |
| 209 | void (*start_adp_sns)(struct otg_fsm *fsm); |
Anton Tikhomirov | f6de27e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 210 | void (*add_timer)(struct otg_fsm *fsm, enum otg_fsm_timer timer); |
| 211 | void (*del_timer)(struct otg_fsm *fsm, enum otg_fsm_timer timer); |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 212 | int (*start_host)(struct otg_fsm *fsm, int on); |
| 213 | int (*start_gadget)(struct otg_fsm *fsm, int on); |
| 214 | }; |
| 215 | |
| 216 | |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 217 | static inline int otg_chrg_vbus(struct otg_fsm *fsm, int on) |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 218 | { |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 219 | if (!fsm->ops->chrg_vbus) |
| 220 | return -EOPNOTSUPP; |
Anton Tikhomirov | da8cc16 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 221 | fsm->ops->chrg_vbus(fsm, on); |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 222 | return 0; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 223 | } |
| 224 | |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 225 | static inline int otg_drv_vbus(struct otg_fsm *fsm, int on) |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 226 | { |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 227 | if (!fsm->ops->drv_vbus) |
| 228 | return -EOPNOTSUPP; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 229 | if (fsm->drv_vbus != on) { |
| 230 | fsm->drv_vbus = on; |
Anton Tikhomirov | da8cc16 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 231 | fsm->ops->drv_vbus(fsm, on); |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 232 | } |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 233 | return 0; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 234 | } |
| 235 | |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 236 | static inline int otg_loc_conn(struct otg_fsm *fsm, int on) |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 237 | { |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 238 | if (!fsm->ops->loc_conn) |
| 239 | return -EOPNOTSUPP; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 240 | if (fsm->loc_conn != on) { |
| 241 | fsm->loc_conn = on; |
Anton Tikhomirov | da8cc16 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 242 | fsm->ops->loc_conn(fsm, on); |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 243 | } |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 244 | return 0; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 245 | } |
| 246 | |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 247 | static inline int otg_loc_sof(struct otg_fsm *fsm, int on) |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 248 | { |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 249 | if (!fsm->ops->loc_sof) |
| 250 | return -EOPNOTSUPP; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 251 | if (fsm->loc_sof != on) { |
| 252 | fsm->loc_sof = on; |
Anton Tikhomirov | da8cc16 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 253 | fsm->ops->loc_sof(fsm, on); |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 254 | } |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 255 | return 0; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 256 | } |
| 257 | |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 258 | static inline int otg_start_pulse(struct otg_fsm *fsm) |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 259 | { |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 260 | if (!fsm->ops->start_pulse) |
| 261 | return -EOPNOTSUPP; |
Anton Tikhomirov | ec04996 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 262 | if (!fsm->data_pulse) { |
| 263 | fsm->data_pulse = 1; |
| 264 | fsm->ops->start_pulse(fsm); |
| 265 | } |
| 266 | return 0; |
| 267 | } |
| 268 | |
| 269 | static inline int otg_start_adp_prb(struct otg_fsm *fsm) |
| 270 | { |
| 271 | if (!fsm->ops->start_adp_prb) |
| 272 | return -EOPNOTSUPP; |
| 273 | if (!fsm->adp_prb) { |
| 274 | fsm->adp_sns = 0; |
| 275 | fsm->adp_prb = 1; |
| 276 | fsm->ops->start_adp_prb(fsm); |
| 277 | } |
| 278 | return 0; |
| 279 | } |
| 280 | |
| 281 | static inline int otg_start_adp_sns(struct otg_fsm *fsm) |
| 282 | { |
| 283 | if (!fsm->ops->start_adp_sns) |
| 284 | return -EOPNOTSUPP; |
| 285 | if (!fsm->adp_sns) { |
| 286 | fsm->adp_sns = 1; |
| 287 | fsm->ops->start_adp_sns(fsm); |
| 288 | } |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 289 | return 0; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 290 | } |
| 291 | |
Anton Tikhomirov | f6de27e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 292 | static inline int otg_add_timer(struct otg_fsm *fsm, enum otg_fsm_timer timer) |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 293 | { |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 294 | if (!fsm->ops->add_timer) |
| 295 | return -EOPNOTSUPP; |
Anton Tikhomirov | da8cc16 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 296 | fsm->ops->add_timer(fsm, timer); |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 297 | return 0; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 298 | } |
| 299 | |
Anton Tikhomirov | f6de27e | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 300 | static inline int otg_del_timer(struct otg_fsm *fsm, enum otg_fsm_timer timer) |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 301 | { |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 302 | if (!fsm->ops->del_timer) |
| 303 | return -EOPNOTSUPP; |
Anton Tikhomirov | da8cc16 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 304 | fsm->ops->del_timer(fsm, timer); |
Anton Tikhomirov | 737cc66 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 305 | return 0; |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 306 | } |
| 307 | |
Anton Tikhomirov | 425d710 | 2013-10-03 12:42:04 +0900 | [diff] [blame] | 308 | static inline int otg_start_host(struct otg_fsm *fsm, int on) |
| 309 | { |
| 310 | if (!fsm->ops->start_host) |
| 311 | return -EOPNOTSUPP; |
| 312 | return fsm->ops->start_host(fsm, on); |
| 313 | } |
| 314 | |
| 315 | static inline int otg_start_gadget(struct otg_fsm *fsm, int on) |
| 316 | { |
| 317 | if (!fsm->ops->start_gadget) |
| 318 | return -EOPNOTSUPP; |
| 319 | return fsm->ops->start_gadget(fsm, on); |
| 320 | } |
| 321 | |
Li Yang | 0807c50 | 2011-04-18 22:01:59 +0200 | [diff] [blame] | 322 | int otg_statemachine(struct otg_fsm *fsm); |
Anton Tikhomirov | d49dd78 | 2013-11-26 10:08:58 -0600 | [diff] [blame] | 323 | |
| 324 | #endif /* __LINUX_USB_OTG_FSM_H */ |