isci.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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. enum sci_controller_mode {
  72. SCI_MODE_SPEED,
  73. SCI_MODE_SIZE /* deprecated */
  74. };
  75. #define SCI_MAX_PHYS (4UL)
  76. #define SCI_MAX_PORTS SCI_MAX_PHYS
  77. #define SCI_MAX_SMP_PHYS (384) /* not silicon constrained */
  78. #define SCI_MAX_REMOTE_DEVICES (256UL)
  79. #define SCI_MAX_IO_REQUESTS (256UL)
  80. #define SCI_MAX_SEQ (16)
  81. #define SCI_MAX_MSIX_MESSAGES (2)
  82. #define SCI_MAX_SCATTER_GATHER_ELEMENTS 130 /* not silicon constrained */
  83. #define SCI_MAX_CONTROLLERS 2
  84. #define SCI_MAX_DOMAINS SCI_MAX_PORTS
  85. #define SCU_MAX_CRITICAL_NOTIFICATIONS (384)
  86. #define SCU_MAX_EVENTS (128)
  87. #define SCU_MAX_UNSOLICITED_FRAMES (128)
  88. #define SCU_MAX_COMPLETION_QUEUE_SCRATCH (128)
  89. #define SCU_MAX_COMPLETION_QUEUE_ENTRIES (SCU_MAX_CRITICAL_NOTIFICATIONS \
  90. + SCU_MAX_EVENTS \
  91. + SCU_MAX_UNSOLICITED_FRAMES \
  92. + SCI_MAX_IO_REQUESTS \
  93. + SCU_MAX_COMPLETION_QUEUE_SCRATCH)
  94. #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096)
  95. #define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024)
  96. #define SCU_INVALID_FRAME_INDEX (0xFFFF)
  97. #define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF)
  98. #define SCU_IO_REQUEST_MAX_TRANSFER_LENGTH (0x00FFFFFF)
  99. static inline void check_sizes(void)
  100. {
  101. BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_EVENTS);
  102. BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES <= 8);
  103. BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_UNSOLICITED_FRAMES);
  104. BUILD_BUG_ON_NOT_POWER_OF_2(SCU_MAX_COMPLETION_QUEUE_ENTRIES);
  105. BUILD_BUG_ON(SCU_MAX_UNSOLICITED_FRAMES > SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES);
  106. BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_IO_REQUESTS);
  107. BUILD_BUG_ON_NOT_POWER_OF_2(SCI_MAX_SEQ);
  108. }
  109. /**
  110. * enum sci_status - This is the general return status enumeration for non-IO,
  111. * non-task management related SCI interface methods.
  112. *
  113. *
  114. */
  115. enum sci_status {
  116. /**
  117. * This member indicates successful completion.
  118. */
  119. SCI_SUCCESS = 0,
  120. /**
  121. * This value indicates that the calling method completed successfully,
  122. * but that the IO may have completed before having it's start method
  123. * invoked. This occurs during SAT translation for requests that do
  124. * not require an IO to the target or for any other requests that may
  125. * be completed without having to submit IO.
  126. */
  127. SCI_SUCCESS_IO_COMPLETE_BEFORE_START,
  128. /**
  129. * This Value indicates that the SCU hardware returned an early response
  130. * because the io request specified more data than is returned by the
  131. * target device (mode pages, inquiry data, etc.). The completion routine
  132. * will handle this case to get the actual number of bytes transferred.
  133. */
  134. SCI_SUCCESS_IO_DONE_EARLY,
  135. /**
  136. * This member indicates that the object for which a state change is
  137. * being requested is already in said state.
  138. */
  139. SCI_WARNING_ALREADY_IN_STATE,
  140. /**
  141. * This member indicates interrupt coalescence timer may cause SAS
  142. * specification compliance issues (i.e. SMP target mode response
  143. * frames must be returned within 1.9 milliseconds).
  144. */
  145. SCI_WARNING_TIMER_CONFLICT,
  146. /**
  147. * This field indicates a sequence of action is not completed yet. Mostly,
  148. * this status is used when multiple ATA commands are needed in a SATI translation.
  149. */
  150. SCI_WARNING_SEQUENCE_INCOMPLETE,
  151. /**
  152. * This member indicates that there was a general failure.
  153. */
  154. SCI_FAILURE,
  155. /**
  156. * This member indicates that the SCI implementation is unable to complete
  157. * an operation due to a critical flaw the prevents any further operation
  158. * (i.e. an invalid pointer).
  159. */
  160. SCI_FATAL_ERROR,
  161. /**
  162. * This member indicates the calling function failed, because the state
  163. * of the controller is in a state that prevents successful completion.
  164. */
  165. SCI_FAILURE_INVALID_STATE,
  166. /**
  167. * This member indicates the calling function failed, because there is
  168. * insufficient resources/memory to complete the request.
  169. */
  170. SCI_FAILURE_INSUFFICIENT_RESOURCES,
  171. /**
  172. * This member indicates the calling function failed, because the
  173. * controller object required for the operation can't be located.
  174. */
  175. SCI_FAILURE_CONTROLLER_NOT_FOUND,
  176. /**
  177. * This member indicates the calling function failed, because the
  178. * discovered controller type is not supported by the library.
  179. */
  180. SCI_FAILURE_UNSUPPORTED_CONTROLLER_TYPE,
  181. /**
  182. * This member indicates the calling function failed, because the
  183. * requested initialization data version isn't supported.
  184. */
  185. SCI_FAILURE_UNSUPPORTED_INIT_DATA_VERSION,
  186. /**
  187. * This member indicates the calling function failed, because the
  188. * requested configuration of SAS Phys into SAS Ports is not supported.
  189. */
  190. SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION,
  191. /**
  192. * This member indicates the calling function failed, because the
  193. * requested protocol is not supported by the remote device, port,
  194. * or controller.
  195. */
  196. SCI_FAILURE_UNSUPPORTED_PROTOCOL,
  197. /**
  198. * This member indicates the calling function failed, because the
  199. * requested information type is not supported by the SCI implementation.
  200. */
  201. SCI_FAILURE_UNSUPPORTED_INFORMATION_TYPE,
  202. /**
  203. * This member indicates the calling function failed, because the
  204. * device already exists.
  205. */
  206. SCI_FAILURE_DEVICE_EXISTS,
  207. /**
  208. * This member indicates the calling function failed, because adding
  209. * a phy to the object is not possible.
  210. */
  211. SCI_FAILURE_ADDING_PHY_UNSUPPORTED,
  212. /**
  213. * This member indicates the calling function failed, because the
  214. * requested information type is not supported by the SCI implementation.
  215. */
  216. SCI_FAILURE_UNSUPPORTED_INFORMATION_FIELD,
  217. /**
  218. * This member indicates the calling function failed, because the SCI
  219. * implementation does not support the supplied time limit.
  220. */
  221. SCI_FAILURE_UNSUPPORTED_TIME_LIMIT,
  222. /**
  223. * This member indicates the calling method failed, because the SCI
  224. * implementation does not contain the specified Phy.
  225. */
  226. SCI_FAILURE_INVALID_PHY,
  227. /**
  228. * This member indicates the calling method failed, because the SCI
  229. * implementation does not contain the specified Port.
  230. */
  231. SCI_FAILURE_INVALID_PORT,
  232. /**
  233. * This member indicates the calling method was partly successful
  234. * The port was reset but not all phys in port are operational
  235. */
  236. SCI_FAILURE_RESET_PORT_PARTIAL_SUCCESS,
  237. /**
  238. * This member indicates that calling method failed
  239. * The port reset did not complete because none of the phys are operational
  240. */
  241. SCI_FAILURE_RESET_PORT_FAILURE,
  242. /**
  243. * This member indicates the calling method failed, because the SCI
  244. * implementation does not contain the specified remote device.
  245. */
  246. SCI_FAILURE_INVALID_REMOTE_DEVICE,
  247. /**
  248. * This member indicates the calling method failed, because the remote
  249. * device is in a bad state and requires a reset.
  250. */
  251. SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
  252. /**
  253. * This member indicates the calling method failed, because the SCI
  254. * implementation does not contain or support the specified IO tag.
  255. */
  256. SCI_FAILURE_INVALID_IO_TAG,
  257. /**
  258. * This member indicates that the operation failed and the user should
  259. * check the response data associated with the IO.
  260. */
  261. SCI_FAILURE_IO_RESPONSE_VALID,
  262. /**
  263. * This member indicates that the operation failed, the failure is
  264. * controller implementation specific, and the response data associated
  265. * with the request is not valid. You can query for the controller
  266. * specific error information via scic_controller_get_request_status()
  267. */
  268. SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
  269. /**
  270. * This member indicated that the operation failed because the
  271. * user requested this IO to be terminated.
  272. */
  273. SCI_FAILURE_IO_TERMINATED,
  274. /**
  275. * This member indicates that the operation failed and the associated
  276. * request requires a SCSI abort task to be sent to the target.
  277. */
  278. SCI_FAILURE_IO_REQUIRES_SCSI_ABORT,
  279. /**
  280. * This member indicates that the operation failed because the supplied
  281. * device could not be located.
  282. */
  283. SCI_FAILURE_DEVICE_NOT_FOUND,
  284. /**
  285. * This member indicates that the operation failed because the
  286. * objects association is required and is not correctly set.
  287. */
  288. SCI_FAILURE_INVALID_ASSOCIATION,
  289. /**
  290. * This member indicates that the operation failed, because a timeout
  291. * occurred.
  292. */
  293. SCI_FAILURE_TIMEOUT,
  294. /**
  295. * This member indicates that the operation failed, because the user
  296. * specified a value that is either invalid or not supported.
  297. */
  298. SCI_FAILURE_INVALID_PARAMETER_VALUE,
  299. /**
  300. * This value indicates that the operation failed, because the number
  301. * of messages (MSI-X) is not supported.
  302. */
  303. SCI_FAILURE_UNSUPPORTED_MESSAGE_COUNT,
  304. /**
  305. * This value indicates that the method failed due to a lack of
  306. * available NCQ tags.
  307. */
  308. SCI_FAILURE_NO_NCQ_TAG_AVAILABLE,
  309. /**
  310. * This value indicates that a protocol violation has occurred on the
  311. * link.
  312. */
  313. SCI_FAILURE_PROTOCOL_VIOLATION,
  314. /**
  315. * This value indicates a failure condition that retry may help to clear.
  316. */
  317. SCI_FAILURE_RETRY_REQUIRED,
  318. /**
  319. * This field indicates the retry limit was reached when a retry is attempted
  320. */
  321. SCI_FAILURE_RETRY_LIMIT_REACHED,
  322. /**
  323. * This member indicates the calling method was partly successful.
  324. * Mostly, this status is used when a LUN_RESET issued to an expander attached
  325. * STP device in READY NCQ substate needs to have RNC suspended/resumed
  326. * before posting TC.
  327. */
  328. SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS,
  329. /**
  330. * This field indicates an illegal phy connection based on the routing attribute
  331. * of both expander phy attached to each other.
  332. */
  333. SCI_FAILURE_ILLEGAL_ROUTING_ATTRIBUTE_CONFIGURATION,
  334. /**
  335. * This field indicates a CONFIG ROUTE INFO command has a response with function result
  336. * INDEX DOES NOT EXIST, usually means exceeding max route index.
  337. */
  338. SCI_FAILURE_EXCEED_MAX_ROUTE_INDEX,
  339. /**
  340. * This value indicates that an unsupported PCI device ID has been
  341. * specified. This indicates that attempts to invoke
  342. * scic_library_allocate_controller() will fail.
  343. */
  344. SCI_FAILURE_UNSUPPORTED_PCI_DEVICE_ID
  345. };
  346. /**
  347. * enum sci_io_status - This enumeration depicts all of the possible IO
  348. * completion status values. Each value in this enumeration maps directly
  349. * to a value in the enum sci_status enumeration. Please refer to that
  350. * enumeration for detailed comments concerning what the status represents.
  351. *
  352. * Add the API to retrieve the SCU status from the core. Check to see that the
  353. * following status are properly handled: - SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL
  354. * - SCI_IO_FAILURE_INVALID_IO_TAG
  355. */
  356. enum sci_io_status {
  357. SCI_IO_SUCCESS = SCI_SUCCESS,
  358. SCI_IO_FAILURE = SCI_FAILURE,
  359. SCI_IO_SUCCESS_COMPLETE_BEFORE_START = SCI_SUCCESS_IO_COMPLETE_BEFORE_START,
  360. SCI_IO_SUCCESS_IO_DONE_EARLY = SCI_SUCCESS_IO_DONE_EARLY,
  361. SCI_IO_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE,
  362. SCI_IO_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES,
  363. SCI_IO_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL,
  364. SCI_IO_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID,
  365. SCI_IO_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
  366. SCI_IO_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED,
  367. SCI_IO_FAILURE_REQUIRES_SCSI_ABORT = SCI_FAILURE_IO_REQUIRES_SCSI_ABORT,
  368. SCI_IO_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE,
  369. SCI_IO_FAILURE_NO_NCQ_TAG_AVAILABLE = SCI_FAILURE_NO_NCQ_TAG_AVAILABLE,
  370. SCI_IO_FAILURE_PROTOCOL_VIOLATION = SCI_FAILURE_PROTOCOL_VIOLATION,
  371. SCI_IO_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
  372. SCI_IO_FAILURE_RETRY_REQUIRED = SCI_FAILURE_RETRY_REQUIRED,
  373. SCI_IO_FAILURE_RETRY_LIMIT_REACHED = SCI_FAILURE_RETRY_LIMIT_REACHED,
  374. SCI_IO_FAILURE_INVALID_REMOTE_DEVICE = SCI_FAILURE_INVALID_REMOTE_DEVICE
  375. };
  376. /**
  377. * enum sci_task_status - This enumeration depicts all of the possible task
  378. * completion status values. Each value in this enumeration maps directly
  379. * to a value in the enum sci_status enumeration. Please refer to that
  380. * enumeration for detailed comments concerning what the status represents.
  381. *
  382. * Check to see that the following status are properly handled:
  383. */
  384. enum sci_task_status {
  385. SCI_TASK_SUCCESS = SCI_SUCCESS,
  386. SCI_TASK_FAILURE = SCI_FAILURE,
  387. SCI_TASK_FAILURE_INVALID_STATE = SCI_FAILURE_INVALID_STATE,
  388. SCI_TASK_FAILURE_INSUFFICIENT_RESOURCES = SCI_FAILURE_INSUFFICIENT_RESOURCES,
  389. SCI_TASK_FAILURE_UNSUPPORTED_PROTOCOL = SCI_FAILURE_UNSUPPORTED_PROTOCOL,
  390. SCI_TASK_FAILURE_INVALID_TAG = SCI_FAILURE_INVALID_IO_TAG,
  391. SCI_TASK_FAILURE_RESPONSE_VALID = SCI_FAILURE_IO_RESPONSE_VALID,
  392. SCI_TASK_FAILURE_CONTROLLER_SPECIFIC_ERR = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR,
  393. SCI_TASK_FAILURE_TERMINATED = SCI_FAILURE_IO_TERMINATED,
  394. SCI_TASK_FAILURE_INVALID_PARAMETER_VALUE = SCI_FAILURE_INVALID_PARAMETER_VALUE,
  395. SCI_TASK_FAILURE_REMOTE_DEVICE_RESET_REQUIRED = SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED,
  396. SCI_TASK_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS = SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS
  397. };
  398. /**
  399. * sci_swab32_cpy - convert between scsi and scu-hardware byte format
  400. * @dest: receive the 4-byte endian swapped version of src
  401. * @src: word aligned source buffer
  402. *
  403. * scu hardware handles SSP/SMP control, response, and unidentified
  404. * frames in "big endian dword" order. Regardless of host endian this
  405. * is always a swab32()-per-dword conversion of the standard definition,
  406. * i.e. single byte fields swapped and multi-byte fields in little-
  407. * endian
  408. */
  409. static inline void sci_swab32_cpy(void *_dest, void *_src, ssize_t word_cnt)
  410. {
  411. u32 *dest = _dest, *src = _src;
  412. while (--word_cnt >= 0)
  413. dest[word_cnt] = swab32(src[word_cnt]);
  414. }
  415. extern unsigned char no_outbound_task_to;
  416. extern u16 ssp_max_occ_to;
  417. extern u16 stp_max_occ_to;
  418. extern u16 ssp_inactive_to;
  419. extern u16 stp_inactive_to;
  420. extern unsigned char phy_gen;
  421. extern unsigned char max_concurr_spinup;
  422. irqreturn_t isci_msix_isr(int vec, void *data);
  423. irqreturn_t isci_intx_isr(int vec, void *data);
  424. irqreturn_t isci_error_isr(int vec, void *data);
  425. /*
  426. * Each timer is associated with a cancellation flag that is set when
  427. * del_timer() is called and checked in the timer callback function. This
  428. * is needed since del_timer_sync() cannot be called with scic_lock held.
  429. * For deinit however, del_timer_sync() is used without holding the lock.
  430. */
  431. struct sci_timer {
  432. struct timer_list timer;
  433. bool cancel;
  434. };
  435. static inline
  436. void sci_init_timer(struct sci_timer *tmr, void (*fn)(unsigned long))
  437. {
  438. tmr->timer.function = fn;
  439. tmr->timer.data = (unsigned long) tmr;
  440. tmr->cancel = 0;
  441. init_timer(&tmr->timer);
  442. }
  443. static inline void sci_mod_timer(struct sci_timer *tmr, unsigned long msec)
  444. {
  445. tmr->cancel = 0;
  446. mod_timer(&tmr->timer, jiffies + msecs_to_jiffies(msec));
  447. }
  448. static inline void sci_del_timer(struct sci_timer *tmr)
  449. {
  450. tmr->cancel = 1;
  451. del_timer(&tmr->timer);
  452. }
  453. struct sci_base_state_machine {
  454. const struct sci_base_state *state_table;
  455. u32 initial_state_id;
  456. u32 current_state_id;
  457. u32 previous_state_id;
  458. };
  459. typedef void (*sci_state_transition_t)(struct sci_base_state_machine *sm);
  460. struct sci_base_state {
  461. sci_state_transition_t enter_state; /* Called on state entry */
  462. sci_state_transition_t exit_state; /* Called on state exit */
  463. };
  464. extern void sci_init_sm(struct sci_base_state_machine *sm,
  465. const struct sci_base_state *state_table,
  466. u32 initial_state);
  467. extern void sci_change_state(struct sci_base_state_machine *sm, u32 next_state);
  468. #endif /* __ISCI_H__ */