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