isci.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. /*
  2. * This file is provided under a dual BSD/GPLv2 license. When using or
  3. * redistributing this file, you may do so under either license.
  4. *
  5. * GPL LICENSE SUMMARY
  6. *
  7. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of version 2 of the GNU General Public License as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  21. * The full GNU General Public License is included in this distribution
  22. * in the file called LICENSE.GPL.
  23. *
  24. * BSD LICENSE
  25. *
  26. * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
  27. * All rights reserved.
  28. *
  29. * Redistribution and use in source and binary forms, with or without
  30. * modification, are permitted provided that the following conditions
  31. * are met:
  32. *
  33. * * Redistributions of source code must retain the above copyright
  34. * notice, this list of conditions and the following disclaimer.
  35. * * Redistributions in binary form must reproduce the above copyright
  36. * notice, this list of conditions and the following disclaimer in
  37. * the documentation and/or other materials provided with the
  38. * distribution.
  39. * * Neither the name of Intel Corporation nor the names of its
  40. * contributors may be used to endorse or promote products derived
  41. * from this software without specific prior written permission.
  42. *
  43. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  44. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  45. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  46. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  47. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  48. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  49. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  50. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  51. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  52. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  53. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  54. */
  55. #ifndef __ISCI_H__
  56. #define __ISCI_H__
  57. #include <linux/interrupt.h>
  58. #include <linux/types.h>
  59. #define DRV_NAME "isci"
  60. #define SCI_PCI_BAR_COUNT 2
  61. #define SCI_NUM_MSI_X_INT 2
  62. #define SCI_SMU_BAR 0
  63. #define SCI_SMU_BAR_SIZE (16*1024)
  64. #define SCI_SCU_BAR 1
  65. #define SCI_SCU_BAR_SIZE (4*1024*1024)
  66. #define SCI_IO_SPACE_BAR0 2
  67. #define SCI_IO_SPACE_BAR1 3
  68. #define ISCI_CAN_QUEUE_VAL 250 /* < SCI_MAX_IO_REQUESTS ? */
  69. #define SCIC_CONTROLLER_STOP_TIMEOUT 5000
  70. #define SCI_CONTROLLER_INVALID_IO_TAG 0xFFFF
  71. #define SCI_MAX_PHYS (4UL)
  72. #define SCI_MAX_PORTS SCI_MAX_PHYS
  73. #define SCI_MAX_SMP_PHYS (384) /* not silicon constrained */
  74. #define SCI_MAX_REMOTE_DEVICES (256UL)
  75. #define SCI_MAX_IO_REQUESTS (256UL)
  76. #define SCI_MAX_SEQ (16)
  77. #define SCI_MAX_MSIX_MESSAGES (2)
  78. #define SCI_MAX_SCATTER_GATHER_ELEMENTS 130 /* not silicon constrained */
  79. #define SCI_MAX_CONTROLLERS 2
  80. #define SCI_MAX_DOMAINS SCI_MAX_PORTS
  81. #define SCU_MAX_CRITICAL_NOTIFICATIONS (384)
  82. #define SCU_MAX_EVENTS_SHIFT (7)
  83. #define SCU_MAX_EVENTS (1 << SCU_MAX_EVENTS_SHIFT)
  84. #define SCU_MAX_UNSOLICITED_FRAMES (128)
  85. #define SCU_MAX_COMPLETION_QUEUE_SCRATCH (128)
  86. #define SCU_MAX_COMPLETION_QUEUE_ENTRIES (SCU_MAX_CRITICAL_NOTIFICATIONS \
  87. + SCU_MAX_EVENTS \
  88. + SCU_MAX_UNSOLICITED_FRAMES \
  89. + SCI_MAX_IO_REQUESTS \
  90. + SCU_MAX_COMPLETION_QUEUE_SCRATCH)
  91. #define SCU_MAX_COMPLETION_QUEUE_SHIFT (ilog2(SCU_MAX_COMPLETION_QUEUE_ENTRIES))
  92. #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096)
  93. #define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024U)
  94. #define SCU_INVALID_FRAME_INDEX (0xFFFF)
  95. #define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF)
  96. #define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH (0x00FFFFFF)
  97. static inline void check_sizes(void)
  98. {
  99. BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_EVENTS);
  100. BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES <= 8);
  101. BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_UNSOLICITED_FRAMES);
  102. BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_COMPLETION_QUEUE_ENTRIES);
  103. BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES > SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES);
  104. BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_IO_REQUESTS);
  105. BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_SEQ);
  106. }
  107. /**
  108. * enum sci_status - This is the general return status enumeration for non-IO,
  109. * non-task management related SCI interface methods.
  110. *
  111. *
  112. */
  113. enum sci_status {
  114. /**
  115. * This member indicates successful completion.
  116. */
  117. SCI_SUCCESS = 0,
  118. /**
  119. * This value indicates that the calling method completed successfully,
  120. * but that the IO may have completed before having it's start method
  121. * invoked. This occurs during SAT translation for requests that do
  122. * not require an IO to the target or for any other requests that may
  123. * be completed without having to submit IO.
  124. */
  125. SCI_SUCCESS_IO_COMPLETE_BEFORE_START,
  126. /**
  127. * This Value indicates that the SCU hardware returned an early response
  128. * because the io request specified more data than is returned by the
  129. * target device (mode pages, inquiry data, etc.). The completion routine
  130. * will handle this case to get the actual number of bytes transferred.
  131. */
  132. SCI_SUCCESS_IO_DONE_EARLY,
  133. /**
  134. * This member indicates that the object for which a state change is
  135. * being requested is already in said state.
  136. */
  137. SCI_WARNING_ALREADY_IN_STATE,
  138. /**
  139. * This member indicates interrupt coalescence timer may cause SAS
  140. * specification compliance issues (i.e. SMP target mode response
  141. * frames must be returned within 1.9 milliseconds).
  142. */
  143. SCI_WARNING_TIMER_CONFLICT,
  144. /**
  145. * This field indicates a sequence of action is not completed yet. Mostly,
  146. * this status is used when multiple ATA commands are needed in a SATI translation.
  147. */
  148. SCI_WARNING_SEQUENCE_INCOMPLETE,
  149. /**
  150. * This member indicates that there was a general failure.
  151. */
  152. SCI_FAILURE,
  153. /**
  154. * This member indicates that the SCI implementation is unable to complete
  155. * an operation due to a critical flaw the prevents any further operation
  156. * (i.e. an invalid pointer).
  157. */
  158. SCI_FATAL_ERROR,
  159. /**
  160. * This member indicates the calling function failed, because the state
  161. * of the controller is in a state that prevents successful completion.
  162. */
  163. SCI_FAILURE_INVALID_STATE,
  164. /**
  165. * This member indicates the calling function failed, because there is
  166. * insufficient resources/memory to complete the request.
  167. */
  168. SCI_FAILURE_INSUFFICIENT_RESOURCES,
  169. /**
  170. * This member indicates the calling function failed, because the
  171. * controller object required for the operation can't be located.
  172. */
  173. SCI_FAILURE_CONTROLLER_NOT_FOUND,
  174. /**
  175. * This member indicates the calling function failed, because the
  176. * discovered controller type is not supported by the library.
  177. */
  178. SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE,
  179. /**
  180. * This member indicates the calling function failed, because the
  181. * requested initialization data version isn't supported.
  182. */
  183. SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION,
  184. /**
  185. * This member indicates the calling function failed, because the
  186. * requested configuration of SAS Phys into SAS Ports is not supported.
  187. */
  188. SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION,
  189. /**
  190. * This member indicates the calling function failed, because the
  191. * requested protocol is not supported by the remote device, port,
  192. * or controller.
  193. */
  194. SCI_FAILURE_UNSUPPORTED_PROTOCOL,
  195. /**
  196. * This member indicates the calling function failed, because the
  197. * requested information type is not supported by the SCI implementation.
  198. */
  199. SCI_FAILURE_UNSUPPORTED_INFORMATION_TYPE,
  200. /**
  201. * This member indicates the calling function failed, because the
  202. * device already exists.
  203. */
  204. SCI_FAILURE_DEVICE_EXISTS,
  205. /**
  206. * This member indicates the calling function failed, because adding
  207. * a phy to the object is not possible.
  208. */
  209. SCI_FAILURE_ADDING_PHY_UNSUPPORTED,
  210. /**
  211. * This member indicates the calling function failed, because the
  212. * requested information type is not supported by the SCI implementation.
  213. */
  214. SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD,
  215. /**
  216. * This member indicates the calling function failed, because the SCI
  217. * implementation does not support the supplied time limit.
  218. */
  219. SCI_FAILURE_UNSUPPORTED_TIME_LIMIT,
  220. /**
  221. * This member indicates the calling method failed, because the SCI
  222. * implementation does not contain the specified Phy.
  223. */
  224. SCI_FAILURE_INVALID_PHY,
  225. /**
  226. * This member indicates the calling method failed, because the SCI
  227. * implementation does not contain the specified Port.
  228. */
  229. SCI_FAILURE_INVALID_PORT,
  230. /**
  231. * This member indicates the calling method was partly successful
  232. * The port was reset but not all phys in port are operational
  233. */
  234. SCI_FAILURE_RESET_PORT_PARTIAL_SUCCESS,
  235. /**
  236. * This member indicates that calling method failed
  237. * The port reset did not complete because none of the phys are operational
  238. */
  239. SCI_FAILURE_RESET_PORT_FAILURE,
  240. /**
  241. * This member indicates the calling method failed, because the SCI
  242. * implementation does not contain the specified remote device.
  243. */
  244. SCI_FAILURE_INVALID_REMOTE_DEVICE,
  245. /**
  246. * This member indicates the calling method failed, because the remote
  247. * device is in a bad state and requires a reset.
  248. */
  249. SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
  250. /**
  251. * This member indicates the calling method failed, because the SCI
  252. * implementation does not contain or support the specified IO tag.
  253. */
  254. SCI_FAILURE_INVALID_IO_TAG,
  255. /**
  256. * This member indicates that the operation failed and the user should
  257. * check the response data associated with the IO.
  258. */
  259. SCI_FAILURE_IO_RESPONSE_VALID,
  260. /**
  261. * This member indicates that the operation failed, the failure is
  262. * controller implementation specific, and the response data associated
  263. * with the request is not valid. You can query for the controller
  264. * specific error information via sci_controller_get_request_status()
  265. */
  266. SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
  267. /**
  268. * This member indicated that the operation failed because the
  269. * user requested this IO to be terminated.
  270. */
  271. SCI_FAILURE_IO_TERMINATED,
  272. /**
  273. * This member indicates that the operation failed and the associated
  274. * request requires a SCSI abort task to be sent to the target.
  275. */
  276. SCI_FAILURE_IO_REQUIRES_SCSI_ABORT,
  277. /**
  278. * This member indicates that the operation failed because the supplied
  279. * device could not be located.
  280. */
  281. SCI_FAILURE_DEVICE_NOT_FOUND,
  282. /**
  283. * This member indicates that the operation failed because the
  284. * objects association is required and is not correctly set.
  285. */
  286. SCI_FAILURE_INVALID_ASSOCIATION,
  287. /**
  288. * This member indicates that the operation failed, because a timeout
  289. * occurred.
  290. */
  291. SCI_FAILURE_TIMEOUT,
  292. /**
  293. * This member indicates that the operation failed, because the user
  294. * specified a value that is either invalid or not supported.
  295. */
  296. SCI_FAILURE_INVALID_PARAMETER_VALUE,
  297. /**
  298. * This value indicates that the operation failed, because the number
  299. * of messages (MSI-X) is not supported.
  300. */
  301. SCI_FAILURE_UNSUPPORTED_MESSAGE_COUNT,
  302. /**
  303. * This value indicates that the method failed due to a lack of
  304. * available NCQ tags.
  305. */
  306. SCI_FAILURE_NO_NCQ_TAG_AVAILABLE,
  307. /**
  308. * This value indicates that a protocol violation has occurred on the
  309. * link.
  310. */
  311. SCI_FAILURE_PROTOCOL_VIOLATION,
  312. /**
  313. * This value indicates a failure condition that retry may help to clear.
  314. */
  315. SCI_FAILURE_RETRY_REQUIRED,
  316. /**
  317. * This field indicates the retry limit was reached when a retry is attempted
  318. */
  319. SCI_FAILURE_RETRY_LIMIT_REACHED,
  320. /**
  321. * This member indicates the calling method was partly successful.
  322. * Mostly, this status is used when a LUN_RESET issued to an expander attached
  323. * STP device in READY NCQ substate needs to have RNC suspended/resumed
  324. * before posting TC.
  325. */
  326. SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS,
  327. /**
  328. * This field indicates an illegal phy connection based on the routing attribute
  329. * of both expander phy attached to each other.
  330. */
  331. SCI_FAILURE_ILLEGAL_ROUTING_ATTRIBUTE_CONFIGURATION,
  332. /**
  333. * This field indicates a CONFIG ROUTE INFO command has a response with function result
  334. * INDEX DOES NOT EXIST, usually means exceeding max route index.
  335. */
  336. SCI_FAILURE_EXCEED_MAX_ROUTE_INDEX,
  337. /**
  338. * This value indicates that an unsupported PCI device ID has been
  339. * specified. This indicates that attempts to invoke
  340. * sci_library_allocate_controller() will fail.
  341. */
  342. SCI_FAILURE_UNSUPPORTED_PCI_DEVICE_ID
  343. };
  344. /**
  345. * enum sci_io_status - This enumeration depicts all of the possible IO
  346. * completion status values. Each value in this enumeration maps directly
  347. * to a value in the enum sci_status enumeration. Please refer to that
  348. * enumeration for detailed comments concerning what the status represents.
  349. *
  350. * Add the API to retrieve the SCU status from the core. Check to see that the
  351. * following status are properly handled: - SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL
  352. * - SCI_IO_FAILURE_INVALID_IO_TAG
  353. */
  354. enum sci_io_status {
  355. SCI_IO_SUCCESS = SCI_SUCCESS,
  356. SCI_IO_FAILURE = SCI_FAILURE,
  357. SCI_IO_SUCCESS_COMPLETE_BEFORE_START = SCI_SUCCESS_IO_COMPLETE_BEFORE_START,
  358. SCI_IO_SUCCESS_IO_DONE_EARLY = SCI_SUCCESS_IO_DONE_EARLY,
  359. SCI_IO_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE,
  360. SCI_IO_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES,
  361. SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL,
  362. SCI_IO_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID,
  363. SCI_IO_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
  364. SCI_IO_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED,
  365. SCI_IO_FAILURE_REQUIRES_SCSI_ABORT = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT,
  366. SCI_IO_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE,
  367. SCI_IO_FAILURE_NO_NCQ_TAG_AVAILABLE = SCI_FAILURE_NO_NCQ_TAG_AVAILABLE,
  368. SCI_IO_FAILURE_PROTOCOL_VIOLATION = SCI_FAILURE_PROTOCOL_VIOLATION,
  369. SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
  370. SCI_IO_FAILURE_RETRY_REQUIRED = SCI_FAILURE_RETRY_REQUIRED,
  371. SCI_IO_FAILURE_RETRY_LIMIT_REACHED = SCI_FAILURE_RETRY_LIMIT_REACHED,
  372. SCI_IO_FAILURE_INVALID_REMOTE_DEVICE = SCI_FAILURE_INVALID_REMOTE_DEVICE
  373. };
  374. /**
  375. * enum sci_task_status - This enumeration depicts all of the possible task
  376. * completion status values. Each value in this enumeration maps directly
  377. * to a value in the enum sci_status enumeration. Please refer to that
  378. * enumeration for detailed comments concerning what the status represents.
  379. *
  380. * Check to see that the following status are properly handled:
  381. */
  382. enum sci_task_status {
  383. SCI_TASK_SUCCESS = SCI_SUCCESS,
  384. SCI_TASK_FAILURE = SCI_FAILURE,
  385. SCI_TASK_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE,
  386. SCI_TASK_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES,
  387. SCI_TASK_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL,
  388. SCI_TASK_FAILURE_INVALID_TAG = SCI_FAILURE_INVALID_IO_TAG,
  389. SCI_TASK_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID,
  390. SCI_TASK_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
  391. SCI_TASK_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED,
  392. SCI_TASK_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE,
  393. SCI_TASK_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
  394. SCI_TASK_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS = SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS
  395. };
  396. /**
  397. * sci_swab32_cpy - convert between scsi and scu-hardware byte format
  398. * @dest: receive the 4-byte endian swapped version of src
  399. * @src: word aligned source buffer
  400. *
  401. * scu hardware handles SSP/SMP control, response, and unidentified
  402. * frames in "big endian dword" order. Regardless of host endian this
  403. * is always a swab32()-per-dword conversion of the standard definition,
  404. * i.e. single byte fields swapped and multi-byte fields in little-
  405. * endian
  406. */
  407. static inline void sci_swab32_cpy(void *_dest, void *_src, ssize_t word_cnt)
  408. {
  409. u32 *dest = _dest, *src = _src;
  410. while (--word_cnt >= 0)
  411. dest[word_cnt] = swab32(src[word_cnt]);
  412. }
  413. extern unsigned char no_outbound_task_to;
  414. extern u16 ssp_max_occ_to;
  415. extern u16 stp_max_occ_to;
  416. extern u16 ssp_inactive_to;
  417. extern u16 stp_inactive_to;
  418. extern unsigned char phy_gen;
  419. extern unsigned char max_concurr_spinup;
  420. extern uint cable_selection_override;
  421. irqreturn_t isci_msix_isr(int vec, void *data);
  422. irqreturn_t isci_intx_isr(int vec, void *data);
  423. irqreturn_t isci_error_isr(int vec, void *data);
  424. /*
  425. * Each timer is associated with a cancellation flag that is set when
  426. * del_timer() is called and checked in the timer callback function. This
  427. * is needed since del_timer_sync() cannot be called with sci_lock held.
  428. * For deinit however, del_timer_sync() is used without holding the lock.
  429. */
  430. struct sci_timer {
  431. struct timer_list timer;
  432. bool cancel;
  433. };
  434. static inline
  435. void sci_init_timer(struct sci_timer *tmr, void (*fn)(struct timer_list *t))
  436. {
  437. tmr->cancel = 0;
  438. timer_setup(&tmr->timer, fn, 0);
  439. }
  440. static inline void sci_mod_timer(struct sci_timer *tmr, unsigned long msec)
  441. {
  442. tmr->cancel = 0;
  443. mod_timer(&tmr->timer, jiffies + msecs_to_jiffies(msec));
  444. }
  445. static inline void sci_del_timer(struct sci_timer *tmr)
  446. {
  447. tmr->cancel = 1;
  448. del_timer(&tmr->timer);
  449. }
  450. struct sci_base_state_machine {
  451. const struct sci_base_state *state_table;
  452. u32 initial_state_id;
  453. u32 current_state_id;
  454. u32 previous_state_id;
  455. };
  456. typedef void (*sci_state_transition_t)(struct sci_base_state_machine *sm);
  457. struct sci_base_state {
  458. sci_state_transition_t enter_state; /* Called on state entry */
  459. sci_state_transition_t exit_state; /* Called on state exit */
  460. };
  461. extern void sci_init_sm(struct sci_base_state_machine *sm,
  462. const struct sci_base_state *state_table,
  463. u32 initial_state);
  464. extern void sci_change_state(struct sci_base_state_machine *sm, u32 next_state);
  465. #endif /* __ISCI_H__ */