hisi_sas.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (c) 2015 Linaro Ltd.
  4. * Copyright (c) 2015 Hisilicon Limited.
  5. */
  6. #ifndef _HISI_SAS_H_
  7. #define _HISI_SAS_H_
  8. #include <linux/acpi.h>
  9. #include <linux/blk-mq.h>
  10. #include <linux/blk-mq-pci.h>
  11. #include <linux/clk.h>
  12. #include <linux/debugfs.h>
  13. #include <linux/dmapool.h>
  14. #include <linux/iopoll.h>
  15. #include <linux/irq.h>
  16. #include <linux/lcm.h>
  17. #include <linux/libata.h>
  18. #include <linux/mfd/syscon.h>
  19. #include <linux/module.h>
  20. #include <linux/of_address.h>
  21. #include <linux/pci.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/pm_runtime.h>
  24. #include <linux/property.h>
  25. #include <linux/regmap.h>
  26. #include <linux/timer.h>
  27. #include <scsi/sas_ata.h>
  28. #include <scsi/libsas.h>
  29. #define HISI_SAS_MAX_PHYS 9
  30. #define HISI_SAS_MAX_QUEUES 32
  31. #define HISI_SAS_QUEUE_SLOTS 4096
  32. #define HISI_SAS_MAX_ITCT_ENTRIES 1024
  33. #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES
  34. #define HISI_SAS_RESETTING_BIT 0
  35. #define HISI_SAS_REJECT_CMD_BIT 1
  36. #define HISI_SAS_PM_BIT 2
  37. #define HISI_SAS_HW_FAULT_BIT 3
  38. #define HISI_SAS_MAX_COMMANDS (HISI_SAS_QUEUE_SLOTS)
  39. #define HISI_SAS_RESERVED_IPTT 96
  40. #define HISI_SAS_UNRESERVED_IPTT \
  41. (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT)
  42. #define HISI_SAS_IOST_ITCT_CACHE_NUM 64
  43. #define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10
  44. #define HISI_SAS_FIFO_DATA_DW_SIZE 32
  45. #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer))
  46. #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table))
  47. #define hisi_sas_status_buf_addr(buf) \
  48. ((buf) + offsetof(struct hisi_sas_slot_buf_table, status_buffer))
  49. #define hisi_sas_status_buf_addr_mem(slot) hisi_sas_status_buf_addr((slot)->buf)
  50. #define hisi_sas_status_buf_addr_dma(slot) \
  51. hisi_sas_status_buf_addr((slot)->buf_dma)
  52. #define hisi_sas_cmd_hdr_addr(buf) \
  53. ((buf) + offsetof(struct hisi_sas_slot_buf_table, command_header))
  54. #define hisi_sas_cmd_hdr_addr_mem(slot) hisi_sas_cmd_hdr_addr((slot)->buf)
  55. #define hisi_sas_cmd_hdr_addr_dma(slot) hisi_sas_cmd_hdr_addr((slot)->buf_dma)
  56. #define hisi_sas_sge_addr(buf) \
  57. ((buf) + offsetof(struct hisi_sas_slot_buf_table, sge_page))
  58. #define hisi_sas_sge_addr_mem(slot) hisi_sas_sge_addr((slot)->buf)
  59. #define hisi_sas_sge_addr_dma(slot) hisi_sas_sge_addr((slot)->buf_dma)
  60. #define hisi_sas_sge_dif_addr(buf) \
  61. ((buf) + offsetof(struct hisi_sas_slot_dif_buf_table, sge_dif_page))
  62. #define hisi_sas_sge_dif_addr_mem(slot) hisi_sas_sge_dif_addr((slot)->buf)
  63. #define hisi_sas_sge_dif_addr_dma(slot) hisi_sas_sge_dif_addr((slot)->buf_dma)
  64. #define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024)
  65. #define HISI_SAS_MAX_SMP_RESP_SZ 1028
  66. #define HISI_SAS_MAX_STP_RESP_SZ 28
  67. #define HISI_SAS_SATA_PROTOCOL_NONDATA 0x1
  68. #define HISI_SAS_SATA_PROTOCOL_PIO 0x2
  69. #define HISI_SAS_SATA_PROTOCOL_DMA 0x4
  70. #define HISI_SAS_SATA_PROTOCOL_FPDMA 0x8
  71. #define HISI_SAS_SATA_PROTOCOL_ATAPI 0x10
  72. #define HISI_SAS_DIF_PROT_MASK (SHOST_DIF_TYPE1_PROTECTION | \
  73. SHOST_DIF_TYPE2_PROTECTION | \
  74. SHOST_DIF_TYPE3_PROTECTION)
  75. #define HISI_SAS_DIX_PROT_MASK (SHOST_DIX_TYPE1_PROTECTION | \
  76. SHOST_DIX_TYPE2_PROTECTION | \
  77. SHOST_DIX_TYPE3_PROTECTION)
  78. #define HISI_SAS_PROT_MASK (HISI_SAS_DIF_PROT_MASK | HISI_SAS_DIX_PROT_MASK)
  79. #define HISI_SAS_WAIT_PHYUP_TIMEOUT (30 * HZ)
  80. #define HISI_SAS_CLEAR_ITCT_TIMEOUT (20 * HZ)
  81. struct hisi_hba;
  82. enum {
  83. PORT_TYPE_SAS = (1U << 1),
  84. PORT_TYPE_SATA = (1U << 0),
  85. };
  86. enum dev_status {
  87. HISI_SAS_DEV_INIT,
  88. HISI_SAS_DEV_NORMAL,
  89. };
  90. enum {
  91. HISI_SAS_INT_ABT_CMD = 0,
  92. HISI_SAS_INT_ABT_DEV = 1,
  93. };
  94. enum hisi_sas_dev_type {
  95. HISI_SAS_DEV_TYPE_STP = 0,
  96. HISI_SAS_DEV_TYPE_SSP,
  97. HISI_SAS_DEV_TYPE_SATA,
  98. };
  99. struct hisi_sas_hw_error {
  100. u32 irq_msk;
  101. u32 msk;
  102. int shift;
  103. const char *msg;
  104. int reg;
  105. const struct hisi_sas_hw_error *sub;
  106. };
  107. struct hisi_sas_rst {
  108. struct hisi_hba *hisi_hba;
  109. struct completion *completion;
  110. struct work_struct work;
  111. bool done;
  112. };
  113. #define HISI_SAS_RST_WORK_INIT(r, c) \
  114. { .hisi_hba = hisi_hba, \
  115. .completion = &c, \
  116. .work = __WORK_INITIALIZER(r.work, \
  117. hisi_sas_sync_rst_work_handler), \
  118. .done = false, \
  119. }
  120. #define HISI_SAS_DECLARE_RST_WORK_ON_STACK(r) \
  121. DECLARE_COMPLETION_ONSTACK(c); \
  122. struct hisi_sas_rst r = HISI_SAS_RST_WORK_INIT(r, c)
  123. enum hisi_sas_bit_err_type {
  124. HISI_SAS_ERR_SINGLE_BIT_ECC = 0x0,
  125. HISI_SAS_ERR_MULTI_BIT_ECC = 0x1,
  126. };
  127. enum hisi_sas_phy_event {
  128. HISI_PHYE_PHY_UP = 0U,
  129. HISI_PHYE_LINK_RESET,
  130. HISI_PHYE_PHY_UP_PM,
  131. HISI_PHYES_NUM,
  132. };
  133. struct hisi_sas_debugfs_fifo {
  134. u32 signal_sel;
  135. u32 dump_msk;
  136. u32 dump_mode;
  137. u32 trigger;
  138. u32 trigger_msk;
  139. u32 trigger_mode;
  140. u32 rd_data[HISI_SAS_FIFO_DATA_DW_SIZE];
  141. };
  142. struct hisi_sas_phy {
  143. struct work_struct works[HISI_PHYES_NUM];
  144. struct hisi_hba *hisi_hba;
  145. struct hisi_sas_port *port;
  146. struct asd_sas_phy sas_phy;
  147. struct sas_identify identify;
  148. struct completion *reset_completion;
  149. struct timer_list timer;
  150. spinlock_t lock;
  151. u64 port_id; /* from hw */
  152. u64 frame_rcvd_size;
  153. u8 frame_rcvd[32];
  154. u8 phy_attached;
  155. u8 in_reset;
  156. u8 reserved[2];
  157. u32 phy_type;
  158. u32 code_violation_err_count;
  159. enum sas_linkrate minimum_linkrate;
  160. enum sas_linkrate maximum_linkrate;
  161. int enable;
  162. int wait_phyup_cnt;
  163. atomic_t down_cnt;
  164. /* Trace FIFO */
  165. struct hisi_sas_debugfs_fifo fifo;
  166. };
  167. struct hisi_sas_port {
  168. struct asd_sas_port sas_port;
  169. u8 port_attached;
  170. u8 id; /* from hw */
  171. };
  172. struct hisi_sas_cq {
  173. struct hisi_hba *hisi_hba;
  174. const struct cpumask *irq_mask;
  175. int rd_point;
  176. int id;
  177. int irq_no;
  178. };
  179. struct hisi_sas_dq {
  180. struct hisi_hba *hisi_hba;
  181. struct list_head list;
  182. spinlock_t lock;
  183. int wr_point;
  184. int id;
  185. };
  186. struct hisi_sas_device {
  187. struct hisi_hba *hisi_hba;
  188. struct domain_device *sas_device;
  189. struct completion *completion;
  190. struct hisi_sas_dq *dq;
  191. struct list_head list;
  192. enum sas_device_type dev_type;
  193. enum dev_status dev_status;
  194. int device_id;
  195. int sata_idx;
  196. spinlock_t lock; /* For protecting slots */
  197. };
  198. struct hisi_sas_slot {
  199. struct list_head entry;
  200. struct list_head delivery;
  201. struct sas_task *task;
  202. struct hisi_sas_port *port;
  203. u64 n_elem;
  204. u64 n_elem_dif;
  205. int dlvry_queue;
  206. int dlvry_queue_slot;
  207. int cmplt_queue;
  208. int cmplt_queue_slot;
  209. int abort;
  210. int ready;
  211. int device_id;
  212. void *cmd_hdr;
  213. dma_addr_t cmd_hdr_dma;
  214. struct timer_list internal_abort_timer;
  215. bool is_internal;
  216. struct sas_tmf_task *tmf;
  217. /* Do not reorder/change members after here */
  218. void *buf;
  219. dma_addr_t buf_dma;
  220. u16 idx;
  221. };
  222. struct hisi_sas_iost_itct_cache {
  223. u32 data[HISI_SAS_IOST_ITCT_CACHE_DW_SZ];
  224. };
  225. enum hisi_sas_debugfs_reg_array_member {
  226. DEBUGFS_GLOBAL = 0,
  227. DEBUGFS_AXI,
  228. DEBUGFS_RAS,
  229. DEBUGFS_REGS_NUM
  230. };
  231. enum hisi_sas_debugfs_cache_type {
  232. HISI_SAS_ITCT_CACHE,
  233. HISI_SAS_IOST_CACHE,
  234. };
  235. enum hisi_sas_debugfs_bist_ffe_cfg {
  236. FFE_SAS_1_5_GBPS,
  237. FFE_SAS_3_0_GBPS,
  238. FFE_SAS_6_0_GBPS,
  239. FFE_SAS_12_0_GBPS,
  240. FFE_RESV,
  241. FFE_SATA_1_5_GBPS,
  242. FFE_SATA_3_0_GBPS,
  243. FFE_SATA_6_0_GBPS,
  244. FFE_CFG_MAX
  245. };
  246. enum hisi_sas_debugfs_bist_fixed_code {
  247. FIXED_CODE,
  248. FIXED_CODE_1,
  249. FIXED_CODE_MAX
  250. };
  251. enum {
  252. HISI_SAS_BIST_CODE_MODE_PRBS7,
  253. HISI_SAS_BIST_CODE_MODE_PRBS23,
  254. HISI_SAS_BIST_CODE_MODE_PRBS31,
  255. HISI_SAS_BIST_CODE_MODE_JTPAT,
  256. HISI_SAS_BIST_CODE_MODE_CJTPAT,
  257. HISI_SAS_BIST_CODE_MODE_SCRAMBED_0,
  258. HISI_SAS_BIST_CODE_MODE_TRAIN,
  259. HISI_SAS_BIST_CODE_MODE_TRAIN_DONE,
  260. HISI_SAS_BIST_CODE_MODE_HFTP,
  261. HISI_SAS_BIST_CODE_MODE_MFTP,
  262. HISI_SAS_BIST_CODE_MODE_LFTP,
  263. HISI_SAS_BIST_CODE_MODE_FIXED_DATA,
  264. };
  265. struct hisi_sas_hw {
  266. int (*hw_init)(struct hisi_hba *hisi_hba);
  267. int (*interrupt_preinit)(struct hisi_hba *hisi_hba);
  268. void (*setup_itct)(struct hisi_hba *hisi_hba,
  269. struct hisi_sas_device *device);
  270. int (*slot_index_alloc)(struct hisi_hba *hisi_hba,
  271. struct domain_device *device);
  272. struct hisi_sas_device *(*alloc_dev)(struct domain_device *device);
  273. void (*sl_notify_ssp)(struct hisi_hba *hisi_hba, int phy_no);
  274. void (*start_delivery)(struct hisi_sas_dq *dq);
  275. void (*prep_ssp)(struct hisi_hba *hisi_hba,
  276. struct hisi_sas_slot *slot);
  277. void (*prep_smp)(struct hisi_hba *hisi_hba,
  278. struct hisi_sas_slot *slot);
  279. void (*prep_stp)(struct hisi_hba *hisi_hba,
  280. struct hisi_sas_slot *slot);
  281. void (*prep_abort)(struct hisi_hba *hisi_hba,
  282. struct hisi_sas_slot *slot);
  283. void (*phys_init)(struct hisi_hba *hisi_hba);
  284. void (*phy_start)(struct hisi_hba *hisi_hba, int phy_no);
  285. void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no);
  286. void (*phy_hard_reset)(struct hisi_hba *hisi_hba, int phy_no);
  287. void (*get_events)(struct hisi_hba *hisi_hba, int phy_no);
  288. void (*phy_set_linkrate)(struct hisi_hba *hisi_hba, int phy_no,
  289. struct sas_phy_linkrates *linkrates);
  290. enum sas_linkrate (*phy_get_max_linkrate)(void);
  291. int (*clear_itct)(struct hisi_hba *hisi_hba,
  292. struct hisi_sas_device *dev);
  293. void (*free_device)(struct hisi_sas_device *sas_dev);
  294. int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id);
  295. void (*dereg_device)(struct hisi_hba *hisi_hba,
  296. struct domain_device *device);
  297. int (*soft_reset)(struct hisi_hba *hisi_hba);
  298. u32 (*get_phys_state)(struct hisi_hba *hisi_hba);
  299. int (*write_gpio)(struct hisi_hba *hisi_hba, u8 reg_type,
  300. u8 reg_index, u8 reg_count, u8 *write_data);
  301. void (*wait_cmds_complete_timeout)(struct hisi_hba *hisi_hba,
  302. int delay_ms, int timeout_ms);
  303. void (*debugfs_snapshot_regs)(struct hisi_hba *hisi_hba);
  304. int complete_hdr_size;
  305. struct scsi_host_template *sht;
  306. };
  307. #define HISI_SAS_MAX_DEBUGFS_DUMP (50)
  308. struct hisi_sas_debugfs_cq {
  309. struct hisi_sas_cq *cq;
  310. void *complete_hdr;
  311. };
  312. struct hisi_sas_debugfs_dq {
  313. struct hisi_sas_dq *dq;
  314. struct hisi_sas_cmd_hdr *hdr;
  315. };
  316. struct hisi_sas_debugfs_regs {
  317. struct hisi_hba *hisi_hba;
  318. u32 *data;
  319. };
  320. struct hisi_sas_debugfs_port {
  321. struct hisi_sas_phy *phy;
  322. u32 *data;
  323. };
  324. struct hisi_sas_debugfs_iost {
  325. struct hisi_sas_iost *iost;
  326. };
  327. struct hisi_sas_debugfs_itct {
  328. struct hisi_sas_itct *itct;
  329. };
  330. struct hisi_sas_debugfs_iost_cache {
  331. struct hisi_sas_iost_itct_cache *cache;
  332. };
  333. struct hisi_sas_debugfs_itct_cache {
  334. struct hisi_sas_iost_itct_cache *cache;
  335. };
  336. struct hisi_hba {
  337. /* This must be the first element, used by SHOST_TO_SAS_HA */
  338. struct sas_ha_struct *p;
  339. struct platform_device *platform_dev;
  340. struct pci_dev *pci_dev;
  341. struct device *dev;
  342. int prot_mask;
  343. void __iomem *regs;
  344. void __iomem *sgpio_regs;
  345. struct regmap *ctrl;
  346. u32 ctrl_reset_reg;
  347. u32 ctrl_reset_sts_reg;
  348. u32 ctrl_clock_ena_reg;
  349. u32 refclk_frequency_mhz;
  350. u8 sas_addr[SAS_ADDR_SIZE];
  351. int *irq_map; /* v2 hw */
  352. int n_phy;
  353. spinlock_t lock;
  354. struct semaphore sem;
  355. struct timer_list timer;
  356. struct workqueue_struct *wq;
  357. int slot_index_count;
  358. int last_slot_index;
  359. int last_dev_id;
  360. unsigned long *slot_index_tags;
  361. unsigned long reject_stp_links_msk;
  362. /* SCSI/SAS glue */
  363. struct sas_ha_struct sha;
  364. struct Scsi_Host *shost;
  365. struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES];
  366. struct hisi_sas_dq dq[HISI_SAS_MAX_QUEUES];
  367. struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS];
  368. struct hisi_sas_port port[HISI_SAS_MAX_PHYS];
  369. int queue_count;
  370. struct hisi_sas_device devices[HISI_SAS_MAX_DEVICES];
  371. struct hisi_sas_cmd_hdr *cmd_hdr[HISI_SAS_MAX_QUEUES];
  372. dma_addr_t cmd_hdr_dma[HISI_SAS_MAX_QUEUES];
  373. void *complete_hdr[HISI_SAS_MAX_QUEUES];
  374. dma_addr_t complete_hdr_dma[HISI_SAS_MAX_QUEUES];
  375. struct hisi_sas_initial_fis *initial_fis;
  376. dma_addr_t initial_fis_dma;
  377. struct hisi_sas_itct *itct;
  378. dma_addr_t itct_dma;
  379. struct hisi_sas_iost *iost;
  380. dma_addr_t iost_dma;
  381. struct hisi_sas_breakpoint *breakpoint;
  382. dma_addr_t breakpoint_dma;
  383. struct hisi_sas_breakpoint *sata_breakpoint;
  384. dma_addr_t sata_breakpoint_dma;
  385. struct hisi_sas_slot *slot_info;
  386. unsigned long flags;
  387. const struct hisi_sas_hw *hw; /* Low level hw interface */
  388. unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)];
  389. struct work_struct rst_work;
  390. struct work_struct debugfs_work;
  391. u32 phy_state;
  392. u32 intr_coal_ticks; /* Time of interrupt coalesce in us */
  393. u32 intr_coal_count; /* Interrupt count to coalesce */
  394. int cq_nvecs;
  395. /* bist */
  396. enum sas_linkrate debugfs_bist_linkrate;
  397. int debugfs_bist_code_mode;
  398. int debugfs_bist_phy_no;
  399. int debugfs_bist_mode;
  400. u32 debugfs_bist_cnt;
  401. int debugfs_bist_enable;
  402. u32 debugfs_bist_ffe[HISI_SAS_MAX_PHYS][FFE_CFG_MAX];
  403. u32 debugfs_bist_fixed_code[FIXED_CODE_MAX];
  404. /* debugfs memories */
  405. /* Put Global AXI and RAS Register into register array */
  406. struct hisi_sas_debugfs_regs debugfs_regs[HISI_SAS_MAX_DEBUGFS_DUMP][DEBUGFS_REGS_NUM];
  407. struct hisi_sas_debugfs_port debugfs_port_reg[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_PHYS];
  408. struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_QUEUES];
  409. struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_QUEUES];
  410. struct hisi_sas_debugfs_iost debugfs_iost[HISI_SAS_MAX_DEBUGFS_DUMP];
  411. struct hisi_sas_debugfs_itct debugfs_itct[HISI_SAS_MAX_DEBUGFS_DUMP];
  412. struct hisi_sas_debugfs_iost_cache debugfs_iost_cache[HISI_SAS_MAX_DEBUGFS_DUMP];
  413. struct hisi_sas_debugfs_itct_cache debugfs_itct_cache[HISI_SAS_MAX_DEBUGFS_DUMP];
  414. u64 debugfs_timestamp[HISI_SAS_MAX_DEBUGFS_DUMP];
  415. int debugfs_dump_index;
  416. struct dentry *debugfs_dir;
  417. struct dentry *debugfs_dump_dentry;
  418. struct dentry *debugfs_bist_dentry;
  419. struct dentry *debugfs_fifo_dentry;
  420. };
  421. /* Generic HW DMA host memory structures */
  422. /* Delivery queue header */
  423. struct hisi_sas_cmd_hdr {
  424. /* dw0 */
  425. __le32 dw0;
  426. /* dw1 */
  427. __le32 dw1;
  428. /* dw2 */
  429. __le32 dw2;
  430. /* dw3 */
  431. __le32 transfer_tags;
  432. /* dw4 */
  433. __le32 data_transfer_len;
  434. /* dw5 */
  435. __le32 first_burst_num;
  436. /* dw6 */
  437. __le32 sg_len;
  438. /* dw7 */
  439. __le32 dw7;
  440. /* dw8-9 */
  441. __le64 cmd_table_addr;
  442. /* dw10-11 */
  443. __le64 sts_buffer_addr;
  444. /* dw12-13 */
  445. __le64 prd_table_addr;
  446. /* dw14-15 */
  447. __le64 dif_prd_table_addr;
  448. };
  449. struct hisi_sas_itct {
  450. __le64 qw0;
  451. __le64 sas_addr;
  452. __le64 qw2;
  453. __le64 qw3;
  454. __le64 qw4_15[12];
  455. };
  456. struct hisi_sas_iost {
  457. __le64 qw0;
  458. __le64 qw1;
  459. __le64 qw2;
  460. __le64 qw3;
  461. };
  462. struct hisi_sas_err_record {
  463. u32 data[4];
  464. };
  465. struct hisi_sas_initial_fis {
  466. struct hisi_sas_err_record err_record;
  467. struct dev_to_host_fis fis;
  468. u32 rsvd[3];
  469. };
  470. struct hisi_sas_breakpoint {
  471. u8 data[128];
  472. };
  473. struct hisi_sas_sata_breakpoint {
  474. struct hisi_sas_breakpoint tag[32];
  475. };
  476. struct hisi_sas_sge {
  477. __le64 addr;
  478. __le32 page_ctrl_0;
  479. __le32 page_ctrl_1;
  480. __le32 data_len;
  481. __le32 data_off;
  482. };
  483. struct hisi_sas_command_table_smp {
  484. u8 bytes[44];
  485. };
  486. struct hisi_sas_command_table_stp {
  487. struct host_to_dev_fis command_fis;
  488. u8 dummy[12];
  489. u8 atapi_cdb[ATAPI_CDB_LEN];
  490. };
  491. #define HISI_SAS_SGE_PAGE_CNT (124)
  492. struct hisi_sas_sge_page {
  493. struct hisi_sas_sge sge[HISI_SAS_SGE_PAGE_CNT];
  494. } __aligned(16);
  495. #define HISI_SAS_SGE_DIF_PAGE_CNT HISI_SAS_SGE_PAGE_CNT
  496. struct hisi_sas_sge_dif_page {
  497. struct hisi_sas_sge sge[HISI_SAS_SGE_DIF_PAGE_CNT];
  498. } __aligned(16);
  499. struct hisi_sas_command_table_ssp {
  500. struct ssp_frame_hdr hdr;
  501. union {
  502. struct {
  503. struct ssp_command_iu task;
  504. u32 prot[7];
  505. };
  506. struct ssp_tmf_iu ssp_task;
  507. struct xfer_rdy_iu xfer_rdy;
  508. struct ssp_response_iu ssp_res;
  509. } u;
  510. };
  511. union hisi_sas_command_table {
  512. struct hisi_sas_command_table_ssp ssp;
  513. struct hisi_sas_command_table_smp smp;
  514. struct hisi_sas_command_table_stp stp;
  515. } __aligned(16);
  516. struct hisi_sas_status_buffer {
  517. struct hisi_sas_err_record err;
  518. u8 iu[1024];
  519. } __aligned(16);
  520. struct hisi_sas_slot_buf_table {
  521. struct hisi_sas_status_buffer status_buffer;
  522. union hisi_sas_command_table command_header;
  523. struct hisi_sas_sge_page sge_page;
  524. };
  525. struct hisi_sas_slot_dif_buf_table {
  526. struct hisi_sas_slot_buf_table slot_buf;
  527. struct hisi_sas_sge_dif_page sge_dif_page;
  528. };
  529. extern struct scsi_transport_template *hisi_sas_stt;
  530. extern bool hisi_sas_debugfs_enable;
  531. extern u32 hisi_sas_debugfs_dump_count;
  532. extern struct dentry *hisi_sas_debugfs_dir;
  533. extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba);
  534. extern int hisi_sas_alloc(struct hisi_hba *hisi_hba);
  535. extern void hisi_sas_free(struct hisi_hba *hisi_hba);
  536. extern u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis,
  537. int direction);
  538. extern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port);
  539. extern void hisi_sas_sata_done(struct sas_task *task,
  540. struct hisi_sas_slot *slot);
  541. extern int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba);
  542. extern int hisi_sas_probe(struct platform_device *pdev,
  543. const struct hisi_sas_hw *ops);
  544. extern int hisi_sas_remove(struct platform_device *pdev);
  545. extern int hisi_sas_slave_configure(struct scsi_device *sdev);
  546. extern int hisi_sas_slave_alloc(struct scsi_device *sdev);
  547. extern int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time);
  548. extern void hisi_sas_scan_start(struct Scsi_Host *shost);
  549. extern int hisi_sas_host_reset(struct Scsi_Host *shost, int reset_type);
  550. extern void hisi_sas_phy_enable(struct hisi_hba *hisi_hba, int phy_no,
  551. int enable);
  552. extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy,
  553. gfp_t gfp_flags);
  554. extern void hisi_sas_phy_bcast(struct hisi_sas_phy *phy);
  555. extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,
  556. struct sas_task *task,
  557. struct hisi_sas_slot *slot);
  558. extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba);
  559. extern void hisi_sas_rst_work_handler(struct work_struct *work);
  560. extern void hisi_sas_sync_rst_work_handler(struct work_struct *work);
  561. extern void hisi_sas_sync_irqs(struct hisi_hba *hisi_hba);
  562. extern void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no);
  563. extern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy,
  564. enum hisi_sas_phy_event event);
  565. extern void hisi_sas_release_tasks(struct hisi_hba *hisi_hba);
  566. extern u8 hisi_sas_get_prog_phy_linkrate_mask(enum sas_linkrate max);
  567. extern void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba);
  568. extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba);
  569. #endif