isci.h 18 KB

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