12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 2e8899fadSJohn Garry /* 3e8899fadSJohn Garry * Copyright (c) 2015 Linaro Ltd. 4e8899fadSJohn Garry * Copyright (c) 2015 Hisilicon Limited. 5e8899fadSJohn Garry */ 6e8899fadSJohn Garry 7e8899fadSJohn Garry #ifndef _HISI_SAS_H_ 8e8899fadSJohn Garry #define _HISI_SAS_H_ 9e8899fadSJohn Garry 104d558c77SJohn Garry #include <linux/acpi.h> 118d98416aSJohn Garry #include <linux/blk-mq.h> 123bc45af8SJohn Garry #include <linux/clk.h> 13ef63464bSLuo Jiaxing #include <linux/debugfs.h> 14e8899fadSJohn Garry #include <linux/dmapool.h> 15a25d0d3dSXiang Chen #include <linux/iopoll.h> 1674a29219SJohn Garry #include <linux/irq.h> 172ba5afb6SXiang Chen #include <linux/lcm.h> 1857dbb2b2SXiang Chen #include <linux/libata.h> 19e8899fadSJohn Garry #include <linux/mfd/syscon.h> 20e8899fadSJohn Garry #include <linux/module.h> 21e8899fadSJohn Garry #include <linux/of_address.h> 2211b75249SJohn Garry #include <linux/pci.h> 23e8899fadSJohn Garry #include <linux/platform_device.h> 2465ff4aefSXiang Chen #include <linux/pm_runtime.h> 254d558c77SJohn Garry #include <linux/property.h> 26e8899fadSJohn Garry #include <linux/regmap.h> 27d28ed83bSLuo Jiaxing #include <linux/timer.h> 286f2ff1a1SJohn Garry #include <scsi/sas_ata.h> 29e8899fadSJohn Garry #include <scsi/libsas.h> 30e8899fadSJohn Garry 317eb7869fSJohn Garry #define HISI_SAS_MAX_PHYS 9 326be6de18SJohn Garry #define HISI_SAS_MAX_QUEUES 32 331273d65fSXiang Chen #define HISI_SAS_QUEUE_SLOTS 4096 343297ded1SXiang Chen #define HISI_SAS_MAX_ITCT_ENTRIES 1024 357eb7869fSJohn Garry #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES 36b5a9fa20SLuo Jiaxing #define HISI_SAS_RESETTING_BIT 0 37917d3bdaSXiaofei Tan #define HISI_SAS_REJECT_CMD_BIT 1 3865ff4aefSXiang Chen #define HISI_SAS_PM_BIT 2 39e8a4d0daSLuo Jiaxing #define HISI_SAS_HW_FAULT_BIT 3 4093352abcSJohn Garry #define HISI_SAS_MAX_COMMANDS (HISI_SAS_QUEUE_SLOTS) 4193352abcSJohn Garry #define HISI_SAS_RESERVED_IPTT 96 4293352abcSJohn Garry #define HISI_SAS_UNRESERVED_IPTT \ 4393352abcSJohn Garry (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT) 447eb7869fSJohn Garry 45bbe0a7b3SLuo Jiaxing #define HISI_SAS_IOST_ITCT_CACHE_NUM 64 46bbe0a7b3SLuo Jiaxing #define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10 47cd96fe60SLuo Jiaxing #define HISI_SAS_FIFO_DATA_DW_SIZE 32 48bbe0a7b3SLuo Jiaxing 494ca7fe99SYihang Li #define HISI_SAS_REG_MEM_SIZE 4 504ca7fe99SYihang Li #define HISI_SAS_MAX_CDB_LEN 16 514ca7fe99SYihang Li #define HISI_SAS_BLK_QUEUE_DEPTH 64 524ca7fe99SYihang Li 534ca7fe99SYihang Li #define BYTE_TO_DW 4 544ca7fe99SYihang Li #define BYTE_TO_DDW 8 554ca7fe99SYihang Li 56f557e32cSXiaofei Tan #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer)) 57f557e32cSXiaofei Tan #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table)) 58f557e32cSXiaofei Tan 59f557e32cSXiaofei Tan #define hisi_sas_status_buf_addr(buf) \ 60b3cce125SXiang Chen ((buf) + offsetof(struct hisi_sas_slot_buf_table, status_buffer)) 61b3cce125SXiang Chen #define hisi_sas_status_buf_addr_mem(slot) hisi_sas_status_buf_addr((slot)->buf) 62f557e32cSXiaofei Tan #define hisi_sas_status_buf_addr_dma(slot) \ 63b3cce125SXiang Chen hisi_sas_status_buf_addr((slot)->buf_dma) 64f557e32cSXiaofei Tan 65f557e32cSXiaofei Tan #define hisi_sas_cmd_hdr_addr(buf) \ 66b3cce125SXiang Chen ((buf) + offsetof(struct hisi_sas_slot_buf_table, command_header)) 67b3cce125SXiang Chen #define hisi_sas_cmd_hdr_addr_mem(slot) hisi_sas_cmd_hdr_addr((slot)->buf) 68b3cce125SXiang Chen #define hisi_sas_cmd_hdr_addr_dma(slot) hisi_sas_cmd_hdr_addr((slot)->buf_dma) 69f557e32cSXiaofei Tan 70f557e32cSXiaofei Tan #define hisi_sas_sge_addr(buf) \ 71b3cce125SXiang Chen ((buf) + offsetof(struct hisi_sas_slot_buf_table, sge_page)) 72b3cce125SXiang Chen #define hisi_sas_sge_addr_mem(slot) hisi_sas_sge_addr((slot)->buf) 73b3cce125SXiang Chen #define hisi_sas_sge_addr_dma(slot) hisi_sas_sge_addr((slot)->buf_dma) 74b3cce125SXiang Chen 75b3cce125SXiang Chen #define hisi_sas_sge_dif_addr(buf) \ 76b3cce125SXiang Chen ((buf) + offsetof(struct hisi_sas_slot_dif_buf_table, sge_dif_page)) 77b3cce125SXiang Chen #define hisi_sas_sge_dif_addr_mem(slot) hisi_sas_sge_dif_addr((slot)->buf) 78b3cce125SXiang Chen #define hisi_sas_sge_dif_addr_dma(slot) hisi_sas_sge_dif_addr((slot)->buf_dma) 796be6de18SJohn Garry 8042e7a693SJohn Garry #define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024) 8166ee999bSJohn Garry #define HISI_SAS_MAX_SMP_RESP_SZ 1028 826f2ff1a1SJohn Garry #define HISI_SAS_MAX_STP_RESP_SZ 28 8342e7a693SJohn Garry 846c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_NONDATA 0x1 856c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_PIO 0x2 866c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_DMA 0x4 876c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_FPDMA 0x8 886c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_ATAPI 0x10 896c7bb8a1SXiang Chen 90d6a9000bSXiang Chen #define HISI_SAS_DIF_PROT_MASK (SHOST_DIF_TYPE1_PROTECTION | \ 91d6a9000bSXiang Chen SHOST_DIF_TYPE2_PROTECTION | \ 92d6a9000bSXiang Chen SHOST_DIF_TYPE3_PROTECTION) 93d6a9000bSXiang Chen 94b3cce125SXiang Chen #define HISI_SAS_DIX_PROT_MASK (SHOST_DIX_TYPE1_PROTECTION | \ 95b3cce125SXiang Chen SHOST_DIX_TYPE2_PROTECTION | \ 96b3cce125SXiang Chen SHOST_DIX_TYPE3_PROTECTION) 97b3cce125SXiang Chen 98b3cce125SXiang Chen #define HISI_SAS_PROT_MASK (HISI_SAS_DIF_PROT_MASK | HISI_SAS_DIX_PROT_MASK) 99d6a9000bSXiang Chen 100512623deSXiang Chen #define HISI_SAS_WAIT_PHYUP_TIMEOUT (30 * HZ) 1012f12a499SLuo Jiaxing #define HISI_SAS_CLEAR_ITCT_TIMEOUT (20 * HZ) 1024ca7fe99SYihang Li #define HISI_SAS_DELAY_FOR_PHY_DISABLE 100 1034ca7fe99SYihang Li #define NAME_BUF_SIZE 256 104b6c9b15eSXiaofei Tan 105abda97c2SJohn Garry struct hisi_hba; 106af740dbeSJohn Garry 10707d78592SJohn Garry enum { 10807d78592SJohn Garry PORT_TYPE_SAS = (1U << 1), 10907d78592SJohn Garry PORT_TYPE_SATA = (1U << 0), 11007d78592SJohn Garry }; 11107d78592SJohn Garry 11257dbb2b2SXiang Chen enum dev_status { 11357dbb2b2SXiang Chen HISI_SAS_DEV_INIT, 11457dbb2b2SXiang Chen HISI_SAS_DEV_NORMAL, 115930d97daSXingui Yang HISI_SAS_DEV_NCQ_ERR, 11657dbb2b2SXiang Chen }; 11757dbb2b2SXiang Chen 118441c2740SJohn Garry enum { 119441c2740SJohn Garry HISI_SAS_INT_ABT_CMD = 0, 120441c2740SJohn Garry HISI_SAS_INT_ABT_DEV = 1, 121441c2740SJohn Garry }; 122441c2740SJohn Garry 123abda97c2SJohn Garry enum hisi_sas_dev_type { 124abda97c2SJohn Garry HISI_SAS_DEV_TYPE_STP = 0, 125abda97c2SJohn Garry HISI_SAS_DEV_TYPE_SSP, 126abda97c2SJohn Garry HISI_SAS_DEV_TYPE_SATA, 127abda97c2SJohn Garry }; 128abda97c2SJohn Garry 1292b383351SJohn Garry struct hisi_sas_hw_error { 1302b383351SJohn Garry u32 irq_msk; 1312b383351SJohn Garry u32 msk; 1322b383351SJohn Garry int shift; 1332b383351SJohn Garry const char *msg; 1342b383351SJohn Garry int reg; 135729428caSShiju Jose const struct hisi_sas_hw_error *sub; 1362b383351SJohn Garry }; 1372b383351SJohn Garry 138e402acdbSXiaofei Tan struct hisi_sas_rst { 139e402acdbSXiaofei Tan struct hisi_hba *hisi_hba; 140e402acdbSXiaofei Tan struct completion *completion; 141e402acdbSXiaofei Tan struct work_struct work; 142e402acdbSXiaofei Tan bool done; 143e402acdbSXiaofei Tan }; 144e402acdbSXiaofei Tan 145e402acdbSXiaofei Tan #define HISI_SAS_RST_WORK_INIT(r, c) \ 146e402acdbSXiaofei Tan { .hisi_hba = hisi_hba, \ 147e402acdbSXiaofei Tan .completion = &c, \ 148e402acdbSXiaofei Tan .work = __WORK_INITIALIZER(r.work, \ 149e402acdbSXiaofei Tan hisi_sas_sync_rst_work_handler), \ 150e402acdbSXiaofei Tan .done = false, \ 151e402acdbSXiaofei Tan } 152e402acdbSXiaofei Tan 153e402acdbSXiaofei Tan #define HISI_SAS_DECLARE_RST_WORK_ON_STACK(r) \ 154e402acdbSXiaofei Tan DECLARE_COMPLETION_ONSTACK(c); \ 155e402acdbSXiaofei Tan struct hisi_sas_rst r = HISI_SAS_RST_WORK_INIT(r, c) 156e402acdbSXiaofei Tan 157e402acdbSXiaofei Tan enum hisi_sas_bit_err_type { 158e402acdbSXiaofei Tan HISI_SAS_ERR_SINGLE_BIT_ECC = 0x0, 159e402acdbSXiaofei Tan HISI_SAS_ERR_MULTI_BIT_ECC = 0x1, 160e402acdbSXiaofei Tan }; 161e402acdbSXiaofei Tan 162e537b62bSXiaofei Tan enum hisi_sas_phy_event { 163e537b62bSXiaofei Tan HISI_PHYE_PHY_UP = 0U, 164057c3d1fSXiaofei Tan HISI_PHYE_LINK_RESET, 165ae9b69e8SXiang Chen HISI_PHYE_PHY_UP_PM, 166e537b62bSXiaofei Tan HISI_PHYES_NUM, 167e537b62bSXiaofei Tan }; 168e537b62bSXiaofei Tan 169cd96fe60SLuo Jiaxing struct hisi_sas_debugfs_fifo { 170cd96fe60SLuo Jiaxing u32 signal_sel; 171cd96fe60SLuo Jiaxing u32 dump_msk; 172cd96fe60SLuo Jiaxing u32 dump_mode; 173cd96fe60SLuo Jiaxing u32 trigger; 174cd96fe60SLuo Jiaxing u32 trigger_msk; 175cd96fe60SLuo Jiaxing u32 trigger_mode; 176cd96fe60SLuo Jiaxing u32 rd_data[HISI_SAS_FIFO_DATA_DW_SIZE]; 177cd96fe60SLuo Jiaxing }; 178cd96fe60SLuo Jiaxing 1794ca7fe99SYihang Li #define FRAME_RCVD_BUF 32 1804ca7fe99SYihang Li #define SAS_PHY_RESV_SIZE 2 1817eb7869fSJohn Garry struct hisi_sas_phy { 182e537b62bSXiaofei Tan struct work_struct works[HISI_PHYES_NUM]; 183976867e6SJohn Garry struct hisi_hba *hisi_hba; 184976867e6SJohn Garry struct hisi_sas_port *port; 1857eb7869fSJohn Garry struct asd_sas_phy sas_phy; 186976867e6SJohn Garry struct sas_identify identify; 1873e1fb1b8SXiang Chen struct completion *reset_completion; 188b6c9b15eSXiaofei Tan struct timer_list timer; 1893e1fb1b8SXiang Chen spinlock_t lock; 190976867e6SJohn Garry u64 port_id; /* from hw */ 191976867e6SJohn Garry u64 frame_rcvd_size; 1924ca7fe99SYihang Li u8 frame_rcvd[FRAME_RCVD_BUF]; 193976867e6SJohn Garry u8 phy_attached; 1943e1fb1b8SXiang Chen u8 in_reset; 1954ca7fe99SYihang Li u8 reserved[SAS_PHY_RESV_SIZE]; 196d0ef10c9SJohn Garry u32 phy_type; 197aaeb8232SXiaofei Tan u32 code_violation_err_count; 198976867e6SJohn Garry enum sas_linkrate minimum_linkrate; 199976867e6SJohn Garry enum sas_linkrate maximum_linkrate; 200c63b88ccSJohn Garry int enable; 201366da0daSLuo Jiaxing int wait_phyup_cnt; 202f873b661SLuo Jiaxing atomic_t down_cnt; 203cd96fe60SLuo Jiaxing 204cd96fe60SLuo Jiaxing /* Trace FIFO */ 205cd96fe60SLuo Jiaxing struct hisi_sas_debugfs_fifo fifo; 2067eb7869fSJohn Garry }; 2077eb7869fSJohn Garry 2087eb7869fSJohn Garry struct hisi_sas_port { 2097eb7869fSJohn Garry struct asd_sas_port sas_port; 210976867e6SJohn Garry u8 port_attached; 211976867e6SJohn Garry u8 id; /* from hw */ 2127eb7869fSJohn Garry }; 2137eb7869fSJohn Garry 2149101a079SJohn Garry struct hisi_sas_cq { 2159101a079SJohn Garry struct hisi_hba *hisi_hba; 21611e67320SJohn Garry const struct cpumask *irq_mask; 217e6c346f3SJohn Garry int rd_point; 2189101a079SJohn Garry int id; 21981f338e9SXiang Chen int irq_no; 2200e47effaSXiang Chen spinlock_t poll_lock; 2219101a079SJohn Garry }; 2229101a079SJohn Garry 2234fde02adSJohn Garry struct hisi_sas_dq { 2244fde02adSJohn Garry struct hisi_hba *hisi_hba; 225fa222db0SXiang Chen struct list_head list; 226b1a49412SXiang Chen spinlock_t lock; 2274fde02adSJohn Garry int wr_point; 2284fde02adSJohn Garry int id; 2294fde02adSJohn Garry }; 2304fde02adSJohn Garry 231af740dbeSJohn Garry struct hisi_sas_device { 232abda97c2SJohn Garry struct hisi_hba *hisi_hba; 233abda97c2SJohn Garry struct domain_device *sas_device; 234640acc9aSXiang Chen struct completion *completion; 235b1a49412SXiang Chen struct hisi_sas_dq *dq; 236405314dfSJohn Garry struct list_head list; 237ad604832SJohn Garry enum sas_device_type dev_type; 23857dbb2b2SXiang Chen enum dev_status dev_status; 239ad604832SJohn Garry int device_id; 24032ccba52SXiaofei Tan int sata_idx; 2414fefe5bbSXiang Chen spinlock_t lock; /* For protecting slots */ 242af740dbeSJohn Garry }; 243af740dbeSJohn Garry 2446be6de18SJohn Garry struct hisi_sas_slot { 24542e7a693SJohn Garry struct list_head entry; 246fa222db0SXiang Chen struct list_head delivery; 24742e7a693SJohn Garry struct sas_task *task; 24842e7a693SJohn Garry struct hisi_sas_port *port; 24942e7a693SJohn Garry u64 n_elem; 250b3cce125SXiang Chen u64 n_elem_dif; 25142e7a693SJohn Garry int dlvry_queue; 25242e7a693SJohn Garry int dlvry_queue_slot; 25327a3f229SJohn Garry int cmplt_queue; 25427a3f229SJohn Garry int cmplt_queue_slot; 255cac9b2a2SJohn Garry int abort; 256fa222db0SXiang Chen int ready; 2574fefe5bbSXiang Chen int device_id; 25842e7a693SJohn Garry void *cmd_hdr; 25942e7a693SJohn Garry dma_addr_t cmd_hdr_dma; 2600844a3ffSJohn Garry struct timer_list internal_abort_timer; 261cd938e53SXiang Chen bool is_internal; 262bbfe82cdSJohn Garry struct sas_tmf_task *tmf; 2632ba5afb6SXiang Chen /* Do not reorder/change members after here */ 2642ba5afb6SXiang Chen void *buf; 2652ba5afb6SXiang Chen dma_addr_t buf_dma; 266735bcc77SJohn Garry u16 idx; 2676be6de18SJohn Garry }; 2686be6de18SJohn Garry 269bbe0a7b3SLuo Jiaxing struct hisi_sas_iost_itct_cache { 270bbe0a7b3SLuo Jiaxing u32 data[HISI_SAS_IOST_ITCT_CACHE_DW_SZ]; 271bbe0a7b3SLuo Jiaxing }; 272bbe0a7b3SLuo Jiaxing 273b0b3e429SLuo Jiaxing enum hisi_sas_debugfs_reg_array_member { 274b0b3e429SLuo Jiaxing DEBUGFS_GLOBAL = 0, 275b0b3e429SLuo Jiaxing DEBUGFS_AXI, 276b0b3e429SLuo Jiaxing DEBUGFS_RAS, 277b0b3e429SLuo Jiaxing DEBUGFS_REGS_NUM 278b0b3e429SLuo Jiaxing }; 279b0b3e429SLuo Jiaxing 280bbe0a7b3SLuo Jiaxing enum hisi_sas_debugfs_cache_type { 281bbe0a7b3SLuo Jiaxing HISI_SAS_ITCT_CACHE, 282bbe0a7b3SLuo Jiaxing HISI_SAS_IOST_CACHE, 283bbe0a7b3SLuo Jiaxing }; 284bbe0a7b3SLuo Jiaxing 2852c4d5823SLuo Jiaxing enum hisi_sas_debugfs_bist_ffe_cfg { 2862c4d5823SLuo Jiaxing FFE_SAS_1_5_GBPS, 2872c4d5823SLuo Jiaxing FFE_SAS_3_0_GBPS, 2882c4d5823SLuo Jiaxing FFE_SAS_6_0_GBPS, 2892c4d5823SLuo Jiaxing FFE_SAS_12_0_GBPS, 2902c4d5823SLuo Jiaxing FFE_RESV, 2912c4d5823SLuo Jiaxing FFE_SATA_1_5_GBPS, 2922c4d5823SLuo Jiaxing FFE_SATA_3_0_GBPS, 2932c4d5823SLuo Jiaxing FFE_SATA_6_0_GBPS, 2942c4d5823SLuo Jiaxing FFE_CFG_MAX 2952c4d5823SLuo Jiaxing }; 2962c4d5823SLuo Jiaxing 297981cc23eSLuo Jiaxing enum hisi_sas_debugfs_bist_fixed_code { 298981cc23eSLuo Jiaxing FIXED_CODE, 299981cc23eSLuo Jiaxing FIXED_CODE_1, 300981cc23eSLuo Jiaxing FIXED_CODE_MAX 301981cc23eSLuo Jiaxing }; 302981cc23eSLuo Jiaxing 303981cc23eSLuo Jiaxing enum { 304981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_PRBS7, 305981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_PRBS23, 306981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_PRBS31, 307981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_JTPAT, 308981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_CJTPAT, 309981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_SCRAMBED_0, 310981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_TRAIN, 311981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_TRAIN_DONE, 312981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_HFTP, 313981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_MFTP, 314981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_LFTP, 315981cc23eSLuo Jiaxing HISI_SAS_BIST_CODE_MODE_FIXED_DATA, 316981cc23eSLuo Jiaxing }; 317981cc23eSLuo Jiaxing 3187eb7869fSJohn Garry struct hisi_sas_hw { 3198ff1d571SJohn Garry int (*hw_init)(struct hisi_hba *hisi_hba); 3202c335fa7SYihang Li int (*fw_info_check)(struct hisi_hba *hisi_hba); 32174a29219SJohn Garry int (*interrupt_preinit)(struct hisi_hba *hisi_hba); 322abda97c2SJohn Garry void (*setup_itct)(struct hisi_hba *hisi_hba, 323abda97c2SJohn Garry struct hisi_sas_device *device); 324784b46b7SXiang Chen int (*slot_index_alloc)(struct hisi_hba *hisi_hba, 325685b6d6eSJohn Garry struct domain_device *device); 326685b6d6eSJohn Garry struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); 327569eddcfSXiang Chen void (*sl_notify_ssp)(struct hisi_hba *hisi_hba, int phy_no); 328b1a49412SXiang Chen void (*start_delivery)(struct hisi_sas_dq *dq); 329a2b3820bSXiang Chen void (*prep_ssp)(struct hisi_hba *hisi_hba, 33078bd2b4fSXiaofei Tan struct hisi_sas_slot *slot); 331a2b3820bSXiang Chen void (*prep_smp)(struct hisi_hba *hisi_hba, 33266ee999bSJohn Garry struct hisi_sas_slot *slot); 333a2b3820bSXiang Chen void (*prep_stp)(struct hisi_hba *hisi_hba, 3346f2ff1a1SJohn Garry struct hisi_sas_slot *slot); 335a2b3820bSXiang Chen void (*prep_abort)(struct hisi_hba *hisi_hba, 336095478a6SJohn Garry struct hisi_sas_slot *slot); 337396b8044SJohn Garry void (*phys_init)(struct hisi_hba *hisi_hba); 3381eb8eeacSXiang Chen void (*phy_start)(struct hisi_hba *hisi_hba, int phy_no); 339e4189d53SJohn Garry void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no); 340e4189d53SJohn Garry void (*phy_hard_reset)(struct hisi_hba *hisi_hba, int phy_no); 341c52108c6SXiaofei Tan void (*get_events)(struct hisi_hba *hisi_hba, int phy_no); 3422ae75787SXiang Chen void (*phy_set_linkrate)(struct hisi_hba *hisi_hba, int phy_no, 3432ae75787SXiang Chen struct sas_phy_linkrates *linkrates); 3442ae75787SXiang Chen enum sas_linkrate (*phy_get_max_linkrate)(void); 3458fa9a7bdSXiang Chen int (*clear_itct)(struct hisi_hba *hisi_hba, 34627a3f229SJohn Garry struct hisi_sas_device *dev); 3470258141aSXiaofei Tan void (*free_device)(struct hisi_sas_device *sas_dev); 348184a4635SJohn Garry int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id); 349d30ff263SXiang Chen void (*dereg_device)(struct hisi_hba *hisi_hba, 350d30ff263SXiang Chen struct domain_device *device); 35106ec0fb9SXiang Chen int (*soft_reset)(struct hisi_hba *hisi_hba); 352917d3bdaSXiaofei Tan u32 (*get_phys_state)(struct hisi_hba *hisi_hba); 3536379c560SXiaofei Tan int (*write_gpio)(struct hisi_hba *hisi_hba, u8 reg_type, 3546379c560SXiaofei Tan u8 reg_index, u8 reg_count, u8 *write_data); 3554bc05809SLuo Jiaxing void (*wait_cmds_complete_timeout)(struct hisi_hba *hisi_hba, 356a865ae14SXiaofei Tan int delay_ms, int timeout_ms); 35763f0733dSYihang Li int (*debugfs_snapshot_regs)(struct hisi_hba *hisi_hba); 3586be6de18SJohn Garry int complete_hdr_size; 359e8c0ced9SBart Van Assche const struct scsi_host_template *sht; 3607eb7869fSJohn Garry }; 3617eb7869fSJohn Garry 362*92c8fe15SYihang Li #define HISI_SAS_MAX_DEBUGFS_DUMP 50 3634ca7fe99SYihang Li #define HISI_SAS_DEFAULT_DEBUGFS_DUMP 1 364a70e33eaSLuo Jiaxing 36535ea630bSLuo Jiaxing struct hisi_sas_debugfs_cq { 36635ea630bSLuo Jiaxing struct hisi_sas_cq *cq; 36735ea630bSLuo Jiaxing void *complete_hdr; 36835ea630bSLuo Jiaxing }; 36935ea630bSLuo Jiaxing 3701b54c4dbSLuo Jiaxing struct hisi_sas_debugfs_dq { 3711b54c4dbSLuo Jiaxing struct hisi_sas_dq *dq; 3721b54c4dbSLuo Jiaxing struct hisi_sas_cmd_hdr *hdr; 3731b54c4dbSLuo Jiaxing }; 3741b54c4dbSLuo Jiaxing 375c6116398SLuo Jiaxing struct hisi_sas_debugfs_regs { 376c6116398SLuo Jiaxing struct hisi_hba *hisi_hba; 377c6116398SLuo Jiaxing u32 *data; 378c6116398SLuo Jiaxing }; 379c6116398SLuo Jiaxing 3801f66e1fdSLuo Jiaxing struct hisi_sas_debugfs_port { 3811f66e1fdSLuo Jiaxing struct hisi_sas_phy *phy; 3821f66e1fdSLuo Jiaxing u32 *data; 3831f66e1fdSLuo Jiaxing }; 3841f66e1fdSLuo Jiaxing 385e15f2e2dSLuo Jiaxing struct hisi_sas_debugfs_iost { 386e15f2e2dSLuo Jiaxing struct hisi_sas_iost *iost; 387e15f2e2dSLuo Jiaxing }; 388e15f2e2dSLuo Jiaxing 3890161d55fSLuo Jiaxing struct hisi_sas_debugfs_itct { 3900161d55fSLuo Jiaxing struct hisi_sas_itct *itct; 3910161d55fSLuo Jiaxing }; 3920161d55fSLuo Jiaxing 393b714dd8fSLuo Jiaxing struct hisi_sas_debugfs_iost_cache { 394b714dd8fSLuo Jiaxing struct hisi_sas_iost_itct_cache *cache; 395b714dd8fSLuo Jiaxing }; 396b714dd8fSLuo Jiaxing 397357e4fc7SLuo Jiaxing struct hisi_sas_debugfs_itct_cache { 398357e4fc7SLuo Jiaxing struct hisi_sas_iost_itct_cache *cache; 399357e4fc7SLuo Jiaxing }; 400357e4fc7SLuo Jiaxing 4017eb7869fSJohn Garry struct hisi_hba { 4027eb7869fSJohn Garry /* This must be the first element, used by SHOST_TO_SAS_HA */ 4037eb7869fSJohn Garry struct sas_ha_struct *p; 4047eb7869fSJohn Garry 40511b75249SJohn Garry struct platform_device *platform_dev; 40611b75249SJohn Garry struct pci_dev *pci_dev; 40711b75249SJohn Garry struct device *dev; 40811b75249SJohn Garry 409d6a9000bSXiang Chen int prot_mask; 410d6a9000bSXiang Chen 411e26b2f40SJohn Garry void __iomem *regs; 4126379c560SXiaofei Tan void __iomem *sgpio_regs; 413e26b2f40SJohn Garry struct regmap *ctrl; 414e26b2f40SJohn Garry u32 ctrl_reset_reg; 415e26b2f40SJohn Garry u32 ctrl_reset_sts_reg; 416e26b2f40SJohn Garry u32 ctrl_clock_ena_reg; 4173bc45af8SJohn Garry u32 refclk_frequency_mhz; 4187eb7869fSJohn Garry u8 sas_addr[SAS_ADDR_SIZE]; 4197eb7869fSJohn Garry 42074a29219SJohn Garry int *irq_map; /* v2 hw */ 42174a29219SJohn Garry 4227eb7869fSJohn Garry int n_phy; 423fa42d80dSJohn Garry spinlock_t lock; 424d2fc401eSXiaofei Tan struct semaphore sem; 4257eb7869fSJohn Garry 426fa42d80dSJohn Garry struct timer_list timer; 4277e9080e1SJohn Garry struct workqueue_struct *wq; 428257efd1fSJohn Garry 429257efd1fSJohn Garry int slot_index_count; 430fa3be0f2SXiang Chen int last_slot_index; 4311b865185SXiang Chen int last_dev_id; 432257efd1fSJohn Garry unsigned long *slot_index_tags; 433c7b9d369SXiaofei Tan unsigned long reject_stp_links_msk; 434257efd1fSJohn Garry 4357eb7869fSJohn Garry /* SCSI/SAS glue */ 4367eb7869fSJohn Garry struct sas_ha_struct sha; 4377eb7869fSJohn Garry struct Scsi_Host *shost; 4389101a079SJohn Garry 4399101a079SJohn Garry struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES]; 4404fde02adSJohn Garry struct hisi_sas_dq dq[HISI_SAS_MAX_QUEUES]; 4417eb7869fSJohn Garry struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS]; 4427eb7869fSJohn Garry struct hisi_sas_port port[HISI_SAS_MAX_PHYS]; 443e26b2f40SJohn Garry 444e26b2f40SJohn Garry int queue_count; 4456be6de18SJohn Garry 446af740dbeSJohn Garry struct hisi_sas_device devices[HISI_SAS_MAX_DEVICES]; 4476be6de18SJohn Garry struct hisi_sas_cmd_hdr *cmd_hdr[HISI_SAS_MAX_QUEUES]; 4486be6de18SJohn Garry dma_addr_t cmd_hdr_dma[HISI_SAS_MAX_QUEUES]; 4496be6de18SJohn Garry void *complete_hdr[HISI_SAS_MAX_QUEUES]; 4506be6de18SJohn Garry dma_addr_t complete_hdr_dma[HISI_SAS_MAX_QUEUES]; 4516be6de18SJohn Garry struct hisi_sas_initial_fis *initial_fis; 4526be6de18SJohn Garry dma_addr_t initial_fis_dma; 4536be6de18SJohn Garry struct hisi_sas_itct *itct; 4546be6de18SJohn Garry dma_addr_t itct_dma; 4556be6de18SJohn Garry struct hisi_sas_iost *iost; 4566be6de18SJohn Garry dma_addr_t iost_dma; 4576be6de18SJohn Garry struct hisi_sas_breakpoint *breakpoint; 4586be6de18SJohn Garry dma_addr_t breakpoint_dma; 4596be6de18SJohn Garry struct hisi_sas_breakpoint *sata_breakpoint; 4606be6de18SJohn Garry dma_addr_t sata_breakpoint_dma; 4616be6de18SJohn Garry struct hisi_sas_slot *slot_info; 46206ec0fb9SXiang Chen unsigned long flags; 4637eb7869fSJohn Garry const struct hisi_sas_hw *hw; /* Low level hw interface */ 46432ccba52SXiaofei Tan unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)]; 46506ec0fb9SXiang Chen struct work_struct rst_work; 4664522204aSXiaofei Tan u32 phy_state; 46737359798SXiang Chen u32 intr_coal_ticks; /* Time of interrupt coalesce in us */ 46837359798SXiang Chen u32 intr_coal_count; /* Interrupt count to coalesce */ 469ef63464bSLuo Jiaxing 470795f25a3SJohn Garry int cq_nvecs; 471795f25a3SJohn Garry 47297b151e7SXiang Chen /* bist */ 47397b151e7SXiang Chen enum sas_linkrate debugfs_bist_linkrate; 47497b151e7SXiang Chen int debugfs_bist_code_mode; 47597b151e7SXiang Chen int debugfs_bist_phy_no; 47697b151e7SXiang Chen int debugfs_bist_mode; 47797b151e7SXiang Chen u32 debugfs_bist_cnt; 47897b151e7SXiang Chen int debugfs_bist_enable; 4792c4d5823SLuo Jiaxing u32 debugfs_bist_ffe[HISI_SAS_MAX_PHYS][FFE_CFG_MAX]; 480981cc23eSLuo Jiaxing u32 debugfs_bist_fixed_code[FIXED_CODE_MAX]; 48197b151e7SXiang Chen 482eb1c2b72SLuo Jiaxing /* debugfs memories */ 483b0b3e429SLuo Jiaxing /* Put Global AXI and RAS Register into register array */ 484a70e33eaSLuo Jiaxing struct hisi_sas_debugfs_regs debugfs_regs[HISI_SAS_MAX_DEBUGFS_DUMP][DEBUGFS_REGS_NUM]; 485a70e33eaSLuo Jiaxing struct hisi_sas_debugfs_port debugfs_port_reg[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_PHYS]; 486a70e33eaSLuo Jiaxing struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_QUEUES]; 487a70e33eaSLuo Jiaxing struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_QUEUES]; 488a70e33eaSLuo Jiaxing struct hisi_sas_debugfs_iost debugfs_iost[HISI_SAS_MAX_DEBUGFS_DUMP]; 489a70e33eaSLuo Jiaxing struct hisi_sas_debugfs_itct debugfs_itct[HISI_SAS_MAX_DEBUGFS_DUMP]; 490a70e33eaSLuo Jiaxing struct hisi_sas_debugfs_iost_cache debugfs_iost_cache[HISI_SAS_MAX_DEBUGFS_DUMP]; 491a70e33eaSLuo Jiaxing struct hisi_sas_debugfs_itct_cache debugfs_itct_cache[HISI_SAS_MAX_DEBUGFS_DUMP]; 492a70e33eaSLuo Jiaxing 4938f643298SLuo Jiaxing u64 debugfs_timestamp[HISI_SAS_MAX_DEBUGFS_DUMP]; 4948f643298SLuo Jiaxing int debugfs_dump_index; 495ef63464bSLuo Jiaxing struct dentry *debugfs_dir; 49649159a5eSLuo Jiaxing struct dentry *debugfs_dump_dentry; 49797b151e7SXiang Chen struct dentry *debugfs_bist_dentry; 498cd96fe60SLuo Jiaxing struct dentry *debugfs_fifo_dentry; 4990e47effaSXiang Chen 5000e47effaSXiang Chen int iopoll_q_cnt; 5017eb7869fSJohn Garry }; 5027eb7869fSJohn Garry 503c799d6bdSJohn Garry /* Generic HW DMA host memory structures */ 504c799d6bdSJohn Garry /* Delivery queue header */ 505c799d6bdSJohn Garry struct hisi_sas_cmd_hdr { 506c799d6bdSJohn Garry /* dw0 */ 507c799d6bdSJohn Garry __le32 dw0; 508c799d6bdSJohn Garry 509c799d6bdSJohn Garry /* dw1 */ 510c799d6bdSJohn Garry __le32 dw1; 511c799d6bdSJohn Garry 512c799d6bdSJohn Garry /* dw2 */ 513c799d6bdSJohn Garry __le32 dw2; 514c799d6bdSJohn Garry 515c799d6bdSJohn Garry /* dw3 */ 516c799d6bdSJohn Garry __le32 transfer_tags; 517c799d6bdSJohn Garry 518c799d6bdSJohn Garry /* dw4 */ 519c799d6bdSJohn Garry __le32 data_transfer_len; 520c799d6bdSJohn Garry 521c799d6bdSJohn Garry /* dw5 */ 522c799d6bdSJohn Garry __le32 first_burst_num; 523c799d6bdSJohn Garry 524c799d6bdSJohn Garry /* dw6 */ 525c799d6bdSJohn Garry __le32 sg_len; 526c799d6bdSJohn Garry 527c799d6bdSJohn Garry /* dw7 */ 528c799d6bdSJohn Garry __le32 dw7; 529c799d6bdSJohn Garry 530c799d6bdSJohn Garry /* dw8-9 */ 531c799d6bdSJohn Garry __le64 cmd_table_addr; 532c799d6bdSJohn Garry 533c799d6bdSJohn Garry /* dw10-11 */ 534c799d6bdSJohn Garry __le64 sts_buffer_addr; 535c799d6bdSJohn Garry 536c799d6bdSJohn Garry /* dw12-13 */ 537c799d6bdSJohn Garry __le64 prd_table_addr; 538c799d6bdSJohn Garry 539c799d6bdSJohn Garry /* dw14-15 */ 540c799d6bdSJohn Garry __le64 dif_prd_table_addr; 541c799d6bdSJohn Garry }; 542c799d6bdSJohn Garry 5434ca7fe99SYihang Li #define ITCT_RESV_DDW 12 544c799d6bdSJohn Garry struct hisi_sas_itct { 545c799d6bdSJohn Garry __le64 qw0; 546c799d6bdSJohn Garry __le64 sas_addr; 547c799d6bdSJohn Garry __le64 qw2; 548c799d6bdSJohn Garry __le64 qw3; 5494ca7fe99SYihang Li __le64 qw4_15[ITCT_RESV_DDW]; 550c799d6bdSJohn Garry }; 551c799d6bdSJohn Garry 552c799d6bdSJohn Garry struct hisi_sas_iost { 553c799d6bdSJohn Garry __le64 qw0; 554c799d6bdSJohn Garry __le64 qw1; 555c799d6bdSJohn Garry __le64 qw2; 556c799d6bdSJohn Garry __le64 qw3; 557c799d6bdSJohn Garry }; 558c799d6bdSJohn Garry 5594ca7fe99SYihang Li #define ERROR_RECORD_BUF_DW 4 560c799d6bdSJohn Garry struct hisi_sas_err_record { 5614ca7fe99SYihang Li u32 data[ERROR_RECORD_BUF_DW]; 562c799d6bdSJohn Garry }; 563c799d6bdSJohn Garry 5644ca7fe99SYihang Li #define FIS_RESV_DW 3 565c799d6bdSJohn Garry struct hisi_sas_initial_fis { 566c799d6bdSJohn Garry struct hisi_sas_err_record err_record; 567c799d6bdSJohn Garry struct dev_to_host_fis fis; 5684ca7fe99SYihang Li u32 rsvd[FIS_RESV_DW]; 569c799d6bdSJohn Garry }; 570c799d6bdSJohn Garry 5714ca7fe99SYihang Li #define BREAKPOINT_DATA_SIZE 128 572c799d6bdSJohn Garry struct hisi_sas_breakpoint { 5734ca7fe99SYihang Li u8 data[BREAKPOINT_DATA_SIZE]; 5743297ded1SXiang Chen }; 5753297ded1SXiang Chen 5764ca7fe99SYihang Li #define BREAKPOINT_TAG_NUM 32 5773297ded1SXiang Chen struct hisi_sas_sata_breakpoint { 5784ca7fe99SYihang Li struct hisi_sas_breakpoint tag[BREAKPOINT_TAG_NUM]; 579c799d6bdSJohn Garry }; 580c799d6bdSJohn Garry 581c799d6bdSJohn Garry struct hisi_sas_sge { 582c799d6bdSJohn Garry __le64 addr; 583c799d6bdSJohn Garry __le32 page_ctrl_0; 584c799d6bdSJohn Garry __le32 page_ctrl_1; 585c799d6bdSJohn Garry __le32 data_len; 586c799d6bdSJohn Garry __le32 data_off; 587c799d6bdSJohn Garry }; 588c799d6bdSJohn Garry 5894ca7fe99SYihang Li #define SMP_CMD_TABLE_SIZE 44 590c799d6bdSJohn Garry struct hisi_sas_command_table_smp { 5914ca7fe99SYihang Li u8 bytes[SMP_CMD_TABLE_SIZE]; 592c799d6bdSJohn Garry }; 593c799d6bdSJohn Garry 5944ca7fe99SYihang Li #define DUMMY_BUF_SIZE 12 595c799d6bdSJohn Garry struct hisi_sas_command_table_stp { 596c799d6bdSJohn Garry struct host_to_dev_fis command_fis; 5974ca7fe99SYihang Li u8 dummy[DUMMY_BUF_SIZE]; 598c799d6bdSJohn Garry u8 atapi_cdb[ATAPI_CDB_LEN]; 599c799d6bdSJohn Garry }; 600c799d6bdSJohn Garry 601c7669f50SJohn Garry #define HISI_SAS_SGE_PAGE_CNT (124) 602c799d6bdSJohn Garry struct hisi_sas_sge_page { 603c799d6bdSJohn Garry struct hisi_sas_sge sge[HISI_SAS_SGE_PAGE_CNT]; 604f557e32cSXiaofei Tan } __aligned(16); 605c799d6bdSJohn Garry 606c7669f50SJohn Garry #define HISI_SAS_SGE_DIF_PAGE_CNT HISI_SAS_SGE_PAGE_CNT 607b3cce125SXiang Chen struct hisi_sas_sge_dif_page { 608b3cce125SXiang Chen struct hisi_sas_sge sge[HISI_SAS_SGE_DIF_PAGE_CNT]; 609b3cce125SXiang Chen } __aligned(16); 610b3cce125SXiang Chen 6114ca7fe99SYihang Li #define PROT_BUF_SIZE 7 612c799d6bdSJohn Garry struct hisi_sas_command_table_ssp { 613c799d6bdSJohn Garry struct ssp_frame_hdr hdr; 614c799d6bdSJohn Garry union { 615c799d6bdSJohn Garry struct { 616c799d6bdSJohn Garry struct ssp_command_iu task; 6174ca7fe99SYihang Li u32 prot[PROT_BUF_SIZE]; 618c799d6bdSJohn Garry }; 619c799d6bdSJohn Garry struct ssp_tmf_iu ssp_task; 620c799d6bdSJohn Garry struct xfer_rdy_iu xfer_rdy; 621c799d6bdSJohn Garry struct ssp_response_iu ssp_res; 622c799d6bdSJohn Garry } u; 623c799d6bdSJohn Garry }; 624c799d6bdSJohn Garry 625c799d6bdSJohn Garry union hisi_sas_command_table { 626c799d6bdSJohn Garry struct hisi_sas_command_table_ssp ssp; 627c799d6bdSJohn Garry struct hisi_sas_command_table_smp smp; 628c799d6bdSJohn Garry struct hisi_sas_command_table_stp stp; 629f557e32cSXiaofei Tan } __aligned(16); 630f557e32cSXiaofei Tan 6314ca7fe99SYihang Li #define IU_BUF_SIZE 1024 632f557e32cSXiaofei Tan struct hisi_sas_status_buffer { 633f557e32cSXiaofei Tan struct hisi_sas_err_record err; 6344ca7fe99SYihang Li u8 iu[IU_BUF_SIZE]; 635f557e32cSXiaofei Tan } __aligned(16); 636f557e32cSXiaofei Tan 637f557e32cSXiaofei Tan struct hisi_sas_slot_buf_table { 638f557e32cSXiaofei Tan struct hisi_sas_status_buffer status_buffer; 639f557e32cSXiaofei Tan union hisi_sas_command_table command_header; 640f557e32cSXiaofei Tan struct hisi_sas_sge_page sge_page; 641c799d6bdSJohn Garry }; 6422e244f0fSJohn Garry 643b3cce125SXiang Chen struct hisi_sas_slot_dif_buf_table { 644b3cce125SXiang Chen struct hisi_sas_slot_buf_table slot_buf; 645b3cce125SXiang Chen struct hisi_sas_sge_dif_page sge_dif_page; 646b3cce125SXiang Chen }; 647b3cce125SXiang Chen 648e21fe3a5SJohn Garry extern struct scsi_transport_template *hisi_sas_stt; 649ef63464bSLuo Jiaxing 650ef63464bSLuo Jiaxing extern bool hisi_sas_debugfs_enable; 651905ab01fSLuo Jiaxing extern u32 hisi_sas_debugfs_dump_count; 652ef63464bSLuo Jiaxing extern struct dentry *hisi_sas_debugfs_dir; 653ef63464bSLuo Jiaxing 654a25d0d3dSXiang Chen extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba); 655ae68b566SXiang Chen extern int hisi_sas_alloc(struct hisi_hba *hisi_hba); 656e21fe3a5SJohn Garry extern void hisi_sas_free(struct hisi_hba *hisi_hba); 657750d4fbeSXingui Yang extern u8 hisi_sas_get_ata_protocol(struct sas_task *task); 6582e244f0fSJohn Garry extern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port); 65975904077SXiang Chen extern void hisi_sas_sata_done(struct sas_task *task, 66075904077SXiang Chen struct hisi_sas_slot *slot); 6610fa24c19SJohn Garry extern int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba); 6629fb10b54SJohn Garry extern int hisi_sas_probe(struct platform_device *pdev, 6639fb10b54SJohn Garry const struct hisi_sas_hw *ops); 6648cd6d0a3SUwe Kleine-König extern void hisi_sas_remove(struct platform_device *pdev); 665c799d6bdSJohn Garry 66647c2e30aSBart Van Assche int hisi_sas_sdev_configure(struct scsi_device *sdev, struct queue_limits *lim); 667ed638918SBart Van Assche extern int hisi_sas_sdev_init(struct scsi_device *sdev); 668235bfc7fSXiang Chen extern int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time); 669235bfc7fSXiang Chen extern void hisi_sas_scan_start(struct Scsi_Host *shost); 670235bfc7fSXiang Chen extern int hisi_sas_host_reset(struct Scsi_Host *shost, int reset_type); 671c63b88ccSJohn Garry extern void hisi_sas_phy_enable(struct hisi_hba *hisi_hba, int phy_no, 672c63b88ccSJohn Garry int enable); 67326c7efc3SAhmed S. Darwish extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy, 67426c7efc3SAhmed S. Darwish gfp_t gfp_flags); 675e9b6badaSJohn Garry extern void hisi_sas_phy_bcast(struct hisi_sas_phy *phy); 67627a3f229SJohn Garry extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, 67727a3f229SJohn Garry struct sas_task *task, 67871fb36b5SXingui Yang struct hisi_sas_slot *slot, 67971fb36b5SXingui Yang bool need_lock); 68006ec0fb9SXiang Chen extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba); 681b4241f0fSXiaofei Tan extern void hisi_sas_rst_work_handler(struct work_struct *work); 682e402acdbSXiaofei Tan extern void hisi_sas_sync_rst_work_handler(struct work_struct *work); 683b6c9b15eSXiaofei Tan extern void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no); 684e537b62bSXiaofei Tan extern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, 685e537b62bSXiaofei Tan enum hisi_sas_phy_event event); 6864d0951eeSXiang Chen extern void hisi_sas_release_tasks(struct hisi_hba *hisi_hba); 687c2c1d9deSXiang Chen extern u8 hisi_sas_get_prog_phy_linkrate_mask(enum sas_linkrate max); 688b711ef5eSXiang Chen extern void hisi_sas_sync_cqs(struct hisi_hba *hisi_hba); 689b711ef5eSXiang Chen extern void hisi_sas_sync_poll_cqs(struct hisi_hba *hisi_hba); 6904522204aSXiaofei Tan extern void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba); 6914522204aSXiaofei Tan extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba); 692e8899fadSJohn Garry #endif 693