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