18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (c) 2015 Linaro Ltd. 48c2ecf20Sopenharmony_ci * Copyright (c) 2015 Hisilicon Limited. 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _HISI_SAS_H_ 88c2ecf20Sopenharmony_ci#define _HISI_SAS_H_ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/acpi.h> 118c2ecf20Sopenharmony_ci#include <linux/blk-mq.h> 128c2ecf20Sopenharmony_ci#include <linux/blk-mq-pci.h> 138c2ecf20Sopenharmony_ci#include <linux/clk.h> 148c2ecf20Sopenharmony_ci#include <linux/debugfs.h> 158c2ecf20Sopenharmony_ci#include <linux/dmapool.h> 168c2ecf20Sopenharmony_ci#include <linux/iopoll.h> 178c2ecf20Sopenharmony_ci#include <linux/lcm.h> 188c2ecf20Sopenharmony_ci#include <linux/libata.h> 198c2ecf20Sopenharmony_ci#include <linux/mfd/syscon.h> 208c2ecf20Sopenharmony_ci#include <linux/module.h> 218c2ecf20Sopenharmony_ci#include <linux/of_address.h> 228c2ecf20Sopenharmony_ci#include <linux/pci.h> 238c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 248c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h> 258c2ecf20Sopenharmony_ci#include <linux/property.h> 268c2ecf20Sopenharmony_ci#include <linux/regmap.h> 278c2ecf20Sopenharmony_ci#include <linux/timer.h> 288c2ecf20Sopenharmony_ci#include <scsi/sas_ata.h> 298c2ecf20Sopenharmony_ci#include <scsi/libsas.h> 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define HISI_SAS_MAX_PHYS 9 328c2ecf20Sopenharmony_ci#define HISI_SAS_MAX_QUEUES 32 338c2ecf20Sopenharmony_ci#define HISI_SAS_QUEUE_SLOTS 4096 348c2ecf20Sopenharmony_ci#define HISI_SAS_MAX_ITCT_ENTRIES 1024 358c2ecf20Sopenharmony_ci#define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES 368c2ecf20Sopenharmony_ci#define HISI_SAS_RESET_BIT 0 378c2ecf20Sopenharmony_ci#define HISI_SAS_REJECT_CMD_BIT 1 388c2ecf20Sopenharmony_ci#define HISI_SAS_PM_BIT 2 398c2ecf20Sopenharmony_ci#define HISI_SAS_MAX_COMMANDS (HISI_SAS_QUEUE_SLOTS) 408c2ecf20Sopenharmony_ci#define HISI_SAS_RESERVED_IPTT 96 418c2ecf20Sopenharmony_ci#define HISI_SAS_UNRESERVED_IPTT \ 428c2ecf20Sopenharmony_ci (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define HISI_SAS_IOST_ITCT_CACHE_NUM 64 458c2ecf20Sopenharmony_ci#define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer)) 488c2ecf20Sopenharmony_ci#define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table)) 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define hisi_sas_status_buf_addr(buf) \ 518c2ecf20Sopenharmony_ci ((buf) + offsetof(struct hisi_sas_slot_buf_table, status_buffer)) 528c2ecf20Sopenharmony_ci#define hisi_sas_status_buf_addr_mem(slot) hisi_sas_status_buf_addr((slot)->buf) 538c2ecf20Sopenharmony_ci#define hisi_sas_status_buf_addr_dma(slot) \ 548c2ecf20Sopenharmony_ci hisi_sas_status_buf_addr((slot)->buf_dma) 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define hisi_sas_cmd_hdr_addr(buf) \ 578c2ecf20Sopenharmony_ci ((buf) + offsetof(struct hisi_sas_slot_buf_table, command_header)) 588c2ecf20Sopenharmony_ci#define hisi_sas_cmd_hdr_addr_mem(slot) hisi_sas_cmd_hdr_addr((slot)->buf) 598c2ecf20Sopenharmony_ci#define hisi_sas_cmd_hdr_addr_dma(slot) hisi_sas_cmd_hdr_addr((slot)->buf_dma) 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define hisi_sas_sge_addr(buf) \ 628c2ecf20Sopenharmony_ci ((buf) + offsetof(struct hisi_sas_slot_buf_table, sge_page)) 638c2ecf20Sopenharmony_ci#define hisi_sas_sge_addr_mem(slot) hisi_sas_sge_addr((slot)->buf) 648c2ecf20Sopenharmony_ci#define hisi_sas_sge_addr_dma(slot) hisi_sas_sge_addr((slot)->buf_dma) 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define hisi_sas_sge_dif_addr(buf) \ 678c2ecf20Sopenharmony_ci ((buf) + offsetof(struct hisi_sas_slot_dif_buf_table, sge_dif_page)) 688c2ecf20Sopenharmony_ci#define hisi_sas_sge_dif_addr_mem(slot) hisi_sas_sge_dif_addr((slot)->buf) 698c2ecf20Sopenharmony_ci#define hisi_sas_sge_dif_addr_dma(slot) hisi_sas_sge_dif_addr((slot)->buf_dma) 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024) 728c2ecf20Sopenharmony_ci#define HISI_SAS_MAX_SMP_RESP_SZ 1028 738c2ecf20Sopenharmony_ci#define HISI_SAS_MAX_STP_RESP_SZ 28 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define HISI_SAS_SATA_PROTOCOL_NONDATA 0x1 768c2ecf20Sopenharmony_ci#define HISI_SAS_SATA_PROTOCOL_PIO 0x2 778c2ecf20Sopenharmony_ci#define HISI_SAS_SATA_PROTOCOL_DMA 0x4 788c2ecf20Sopenharmony_ci#define HISI_SAS_SATA_PROTOCOL_FPDMA 0x8 798c2ecf20Sopenharmony_ci#define HISI_SAS_SATA_PROTOCOL_ATAPI 0x10 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define HISI_SAS_DIF_PROT_MASK (SHOST_DIF_TYPE1_PROTECTION | \ 828c2ecf20Sopenharmony_ci SHOST_DIF_TYPE2_PROTECTION | \ 838c2ecf20Sopenharmony_ci SHOST_DIF_TYPE3_PROTECTION) 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#define HISI_SAS_DIX_PROT_MASK (SHOST_DIX_TYPE1_PROTECTION | \ 868c2ecf20Sopenharmony_ci SHOST_DIX_TYPE2_PROTECTION | \ 878c2ecf20Sopenharmony_ci SHOST_DIX_TYPE3_PROTECTION) 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define HISI_SAS_PROT_MASK (HISI_SAS_DIF_PROT_MASK | HISI_SAS_DIX_PROT_MASK) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define HISI_SAS_WAIT_PHYUP_TIMEOUT 20 928c2ecf20Sopenharmony_ci#define CLEAR_ITCT_TIMEOUT 20 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistruct hisi_hba; 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cienum { 978c2ecf20Sopenharmony_ci PORT_TYPE_SAS = (1U << 1), 988c2ecf20Sopenharmony_ci PORT_TYPE_SATA = (1U << 0), 998c2ecf20Sopenharmony_ci}; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_cienum dev_status { 1028c2ecf20Sopenharmony_ci HISI_SAS_DEV_INIT, 1038c2ecf20Sopenharmony_ci HISI_SAS_DEV_NORMAL, 1048c2ecf20Sopenharmony_ci}; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cienum { 1078c2ecf20Sopenharmony_ci HISI_SAS_INT_ABT_CMD = 0, 1088c2ecf20Sopenharmony_ci HISI_SAS_INT_ABT_DEV = 1, 1098c2ecf20Sopenharmony_ci}; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_cienum hisi_sas_dev_type { 1128c2ecf20Sopenharmony_ci HISI_SAS_DEV_TYPE_STP = 0, 1138c2ecf20Sopenharmony_ci HISI_SAS_DEV_TYPE_SSP, 1148c2ecf20Sopenharmony_ci HISI_SAS_DEV_TYPE_SATA, 1158c2ecf20Sopenharmony_ci}; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cistruct hisi_sas_hw_error { 1188c2ecf20Sopenharmony_ci u32 irq_msk; 1198c2ecf20Sopenharmony_ci u32 msk; 1208c2ecf20Sopenharmony_ci int shift; 1218c2ecf20Sopenharmony_ci const char *msg; 1228c2ecf20Sopenharmony_ci int reg; 1238c2ecf20Sopenharmony_ci const struct hisi_sas_hw_error *sub; 1248c2ecf20Sopenharmony_ci}; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_cistruct hisi_sas_rst { 1278c2ecf20Sopenharmony_ci struct hisi_hba *hisi_hba; 1288c2ecf20Sopenharmony_ci struct completion *completion; 1298c2ecf20Sopenharmony_ci struct work_struct work; 1308c2ecf20Sopenharmony_ci bool done; 1318c2ecf20Sopenharmony_ci}; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#define HISI_SAS_RST_WORK_INIT(r, c) \ 1348c2ecf20Sopenharmony_ci { .hisi_hba = hisi_hba, \ 1358c2ecf20Sopenharmony_ci .completion = &c, \ 1368c2ecf20Sopenharmony_ci .work = __WORK_INITIALIZER(r.work, \ 1378c2ecf20Sopenharmony_ci hisi_sas_sync_rst_work_handler), \ 1388c2ecf20Sopenharmony_ci .done = false, \ 1398c2ecf20Sopenharmony_ci } 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci#define HISI_SAS_DECLARE_RST_WORK_ON_STACK(r) \ 1428c2ecf20Sopenharmony_ci DECLARE_COMPLETION_ONSTACK(c); \ 1438c2ecf20Sopenharmony_ci struct hisi_sas_rst r = HISI_SAS_RST_WORK_INIT(r, c) 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_cienum hisi_sas_bit_err_type { 1468c2ecf20Sopenharmony_ci HISI_SAS_ERR_SINGLE_BIT_ECC = 0x0, 1478c2ecf20Sopenharmony_ci HISI_SAS_ERR_MULTI_BIT_ECC = 0x1, 1488c2ecf20Sopenharmony_ci}; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_cienum hisi_sas_phy_event { 1518c2ecf20Sopenharmony_ci HISI_PHYE_PHY_UP = 0U, 1528c2ecf20Sopenharmony_ci HISI_PHYE_LINK_RESET, 1538c2ecf20Sopenharmony_ci HISI_PHYES_NUM, 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistruct hisi_sas_phy { 1578c2ecf20Sopenharmony_ci struct work_struct works[HISI_PHYES_NUM]; 1588c2ecf20Sopenharmony_ci struct hisi_hba *hisi_hba; 1598c2ecf20Sopenharmony_ci struct hisi_sas_port *port; 1608c2ecf20Sopenharmony_ci struct asd_sas_phy sas_phy; 1618c2ecf20Sopenharmony_ci struct sas_identify identify; 1628c2ecf20Sopenharmony_ci struct completion *reset_completion; 1638c2ecf20Sopenharmony_ci struct timer_list timer; 1648c2ecf20Sopenharmony_ci spinlock_t lock; 1658c2ecf20Sopenharmony_ci u64 port_id; /* from hw */ 1668c2ecf20Sopenharmony_ci u64 frame_rcvd_size; 1678c2ecf20Sopenharmony_ci u8 frame_rcvd[32]; 1688c2ecf20Sopenharmony_ci u8 phy_attached; 1698c2ecf20Sopenharmony_ci u8 in_reset; 1708c2ecf20Sopenharmony_ci u8 reserved[2]; 1718c2ecf20Sopenharmony_ci u32 phy_type; 1728c2ecf20Sopenharmony_ci u32 code_violation_err_count; 1738c2ecf20Sopenharmony_ci enum sas_linkrate minimum_linkrate; 1748c2ecf20Sopenharmony_ci enum sas_linkrate maximum_linkrate; 1758c2ecf20Sopenharmony_ci int enable; 1768c2ecf20Sopenharmony_ci atomic_t down_cnt; 1778c2ecf20Sopenharmony_ci}; 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_cistruct hisi_sas_port { 1808c2ecf20Sopenharmony_ci struct asd_sas_port sas_port; 1818c2ecf20Sopenharmony_ci u8 port_attached; 1828c2ecf20Sopenharmony_ci u8 id; /* from hw */ 1838c2ecf20Sopenharmony_ci}; 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_cistruct hisi_sas_cq { 1868c2ecf20Sopenharmony_ci struct hisi_hba *hisi_hba; 1878c2ecf20Sopenharmony_ci const struct cpumask *irq_mask; 1888c2ecf20Sopenharmony_ci int rd_point; 1898c2ecf20Sopenharmony_ci int id; 1908c2ecf20Sopenharmony_ci int irq_no; 1918c2ecf20Sopenharmony_ci}; 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_cistruct hisi_sas_dq { 1948c2ecf20Sopenharmony_ci struct hisi_hba *hisi_hba; 1958c2ecf20Sopenharmony_ci struct list_head list; 1968c2ecf20Sopenharmony_ci spinlock_t lock; 1978c2ecf20Sopenharmony_ci int wr_point; 1988c2ecf20Sopenharmony_ci int id; 1998c2ecf20Sopenharmony_ci}; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_cistruct hisi_sas_device { 2028c2ecf20Sopenharmony_ci struct hisi_hba *hisi_hba; 2038c2ecf20Sopenharmony_ci struct domain_device *sas_device; 2048c2ecf20Sopenharmony_ci struct completion *completion; 2058c2ecf20Sopenharmony_ci struct hisi_sas_dq *dq; 2068c2ecf20Sopenharmony_ci struct list_head list; 2078c2ecf20Sopenharmony_ci enum sas_device_type dev_type; 2088c2ecf20Sopenharmony_ci enum dev_status dev_status; 2098c2ecf20Sopenharmony_ci int device_id; 2108c2ecf20Sopenharmony_ci int sata_idx; 2118c2ecf20Sopenharmony_ci spinlock_t lock; /* For protecting slots */ 2128c2ecf20Sopenharmony_ci}; 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_cistruct hisi_sas_tmf_task { 2158c2ecf20Sopenharmony_ci int force_phy; 2168c2ecf20Sopenharmony_ci int phy_id; 2178c2ecf20Sopenharmony_ci u8 tmf; 2188c2ecf20Sopenharmony_ci u16 tag_of_task_to_be_managed; 2198c2ecf20Sopenharmony_ci}; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_cistruct hisi_sas_slot { 2228c2ecf20Sopenharmony_ci struct list_head entry; 2238c2ecf20Sopenharmony_ci struct list_head delivery; 2248c2ecf20Sopenharmony_ci struct sas_task *task; 2258c2ecf20Sopenharmony_ci struct hisi_sas_port *port; 2268c2ecf20Sopenharmony_ci u64 n_elem; 2278c2ecf20Sopenharmony_ci u64 n_elem_dif; 2288c2ecf20Sopenharmony_ci int dlvry_queue; 2298c2ecf20Sopenharmony_ci int dlvry_queue_slot; 2308c2ecf20Sopenharmony_ci int cmplt_queue; 2318c2ecf20Sopenharmony_ci int cmplt_queue_slot; 2328c2ecf20Sopenharmony_ci int abort; 2338c2ecf20Sopenharmony_ci int ready; 2348c2ecf20Sopenharmony_ci int device_id; 2358c2ecf20Sopenharmony_ci void *cmd_hdr; 2368c2ecf20Sopenharmony_ci dma_addr_t cmd_hdr_dma; 2378c2ecf20Sopenharmony_ci struct timer_list internal_abort_timer; 2388c2ecf20Sopenharmony_ci bool is_internal; 2398c2ecf20Sopenharmony_ci struct hisi_sas_tmf_task *tmf; 2408c2ecf20Sopenharmony_ci /* Do not reorder/change members after here */ 2418c2ecf20Sopenharmony_ci void *buf; 2428c2ecf20Sopenharmony_ci dma_addr_t buf_dma; 2438c2ecf20Sopenharmony_ci u16 idx; 2448c2ecf20Sopenharmony_ci}; 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_ci#define HISI_SAS_DEBUGFS_REG(x) {#x, x} 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_reg_lu { 2498c2ecf20Sopenharmony_ci char *name; 2508c2ecf20Sopenharmony_ci int off; 2518c2ecf20Sopenharmony_ci}; 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_reg { 2548c2ecf20Sopenharmony_ci const struct hisi_sas_debugfs_reg_lu *lu; 2558c2ecf20Sopenharmony_ci int count; 2568c2ecf20Sopenharmony_ci int base_off; 2578c2ecf20Sopenharmony_ci union { 2588c2ecf20Sopenharmony_ci u32 (*read_global_reg)(struct hisi_hba *hisi_hba, u32 off); 2598c2ecf20Sopenharmony_ci u32 (*read_port_reg)(struct hisi_hba *hisi_hba, int port, 2608c2ecf20Sopenharmony_ci u32 off); 2618c2ecf20Sopenharmony_ci }; 2628c2ecf20Sopenharmony_ci}; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_cistruct hisi_sas_iost_itct_cache { 2658c2ecf20Sopenharmony_ci u32 data[HISI_SAS_IOST_ITCT_CACHE_DW_SZ]; 2668c2ecf20Sopenharmony_ci}; 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_cienum hisi_sas_debugfs_reg_array_member { 2698c2ecf20Sopenharmony_ci DEBUGFS_GLOBAL = 0, 2708c2ecf20Sopenharmony_ci DEBUGFS_AXI, 2718c2ecf20Sopenharmony_ci DEBUGFS_RAS, 2728c2ecf20Sopenharmony_ci DEBUGFS_REGS_NUM 2738c2ecf20Sopenharmony_ci}; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_cienum hisi_sas_debugfs_cache_type { 2768c2ecf20Sopenharmony_ci HISI_SAS_ITCT_CACHE, 2778c2ecf20Sopenharmony_ci HISI_SAS_IOST_CACHE, 2788c2ecf20Sopenharmony_ci}; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_cienum hisi_sas_debugfs_bist_ffe_cfg { 2818c2ecf20Sopenharmony_ci FFE_SAS_1_5_GBPS, 2828c2ecf20Sopenharmony_ci FFE_SAS_3_0_GBPS, 2838c2ecf20Sopenharmony_ci FFE_SAS_6_0_GBPS, 2848c2ecf20Sopenharmony_ci FFE_SAS_12_0_GBPS, 2858c2ecf20Sopenharmony_ci FFE_RESV, 2868c2ecf20Sopenharmony_ci FFE_SATA_1_5_GBPS, 2878c2ecf20Sopenharmony_ci FFE_SATA_3_0_GBPS, 2888c2ecf20Sopenharmony_ci FFE_SATA_6_0_GBPS, 2898c2ecf20Sopenharmony_ci FFE_CFG_MAX 2908c2ecf20Sopenharmony_ci}; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_cienum hisi_sas_debugfs_bist_fixed_code { 2938c2ecf20Sopenharmony_ci FIXED_CODE, 2948c2ecf20Sopenharmony_ci FIXED_CODE_1, 2958c2ecf20Sopenharmony_ci FIXED_CODE_MAX 2968c2ecf20Sopenharmony_ci}; 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_cienum { 2998c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_PRBS7, 3008c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_PRBS23, 3018c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_PRBS31, 3028c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_JTPAT, 3038c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_CJTPAT, 3048c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_SCRAMBED_0, 3058c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_TRAIN, 3068c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_TRAIN_DONE, 3078c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_HFTP, 3088c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_MFTP, 3098c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_LFTP, 3108c2ecf20Sopenharmony_ci HISI_SAS_BIST_CODE_MODE_FIXED_DATA, 3118c2ecf20Sopenharmony_ci}; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_cistruct hisi_sas_hw { 3148c2ecf20Sopenharmony_ci int (*hw_init)(struct hisi_hba *hisi_hba); 3158c2ecf20Sopenharmony_ci void (*setup_itct)(struct hisi_hba *hisi_hba, 3168c2ecf20Sopenharmony_ci struct hisi_sas_device *device); 3178c2ecf20Sopenharmony_ci int (*slot_index_alloc)(struct hisi_hba *hisi_hba, 3188c2ecf20Sopenharmony_ci struct domain_device *device); 3198c2ecf20Sopenharmony_ci struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); 3208c2ecf20Sopenharmony_ci void (*sl_notify_ssp)(struct hisi_hba *hisi_hba, int phy_no); 3218c2ecf20Sopenharmony_ci void (*start_delivery)(struct hisi_sas_dq *dq); 3228c2ecf20Sopenharmony_ci void (*prep_ssp)(struct hisi_hba *hisi_hba, 3238c2ecf20Sopenharmony_ci struct hisi_sas_slot *slot); 3248c2ecf20Sopenharmony_ci void (*prep_smp)(struct hisi_hba *hisi_hba, 3258c2ecf20Sopenharmony_ci struct hisi_sas_slot *slot); 3268c2ecf20Sopenharmony_ci void (*prep_stp)(struct hisi_hba *hisi_hba, 3278c2ecf20Sopenharmony_ci struct hisi_sas_slot *slot); 3288c2ecf20Sopenharmony_ci void (*prep_abort)(struct hisi_hba *hisi_hba, 3298c2ecf20Sopenharmony_ci struct hisi_sas_slot *slot, 3308c2ecf20Sopenharmony_ci int device_id, int abort_flag, int tag_to_abort); 3318c2ecf20Sopenharmony_ci void (*phys_init)(struct hisi_hba *hisi_hba); 3328c2ecf20Sopenharmony_ci void (*phy_start)(struct hisi_hba *hisi_hba, int phy_no); 3338c2ecf20Sopenharmony_ci void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no); 3348c2ecf20Sopenharmony_ci void (*phy_hard_reset)(struct hisi_hba *hisi_hba, int phy_no); 3358c2ecf20Sopenharmony_ci void (*get_events)(struct hisi_hba *hisi_hba, int phy_no); 3368c2ecf20Sopenharmony_ci void (*phy_set_linkrate)(struct hisi_hba *hisi_hba, int phy_no, 3378c2ecf20Sopenharmony_ci struct sas_phy_linkrates *linkrates); 3388c2ecf20Sopenharmony_ci enum sas_linkrate (*phy_get_max_linkrate)(void); 3398c2ecf20Sopenharmony_ci int (*clear_itct)(struct hisi_hba *hisi_hba, 3408c2ecf20Sopenharmony_ci struct hisi_sas_device *dev); 3418c2ecf20Sopenharmony_ci void (*free_device)(struct hisi_sas_device *sas_dev); 3428c2ecf20Sopenharmony_ci int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id); 3438c2ecf20Sopenharmony_ci void (*dereg_device)(struct hisi_hba *hisi_hba, 3448c2ecf20Sopenharmony_ci struct domain_device *device); 3458c2ecf20Sopenharmony_ci int (*soft_reset)(struct hisi_hba *hisi_hba); 3468c2ecf20Sopenharmony_ci u32 (*get_phys_state)(struct hisi_hba *hisi_hba); 3478c2ecf20Sopenharmony_ci int (*write_gpio)(struct hisi_hba *hisi_hba, u8 reg_type, 3488c2ecf20Sopenharmony_ci u8 reg_index, u8 reg_count, u8 *write_data); 3498c2ecf20Sopenharmony_ci void (*wait_cmds_complete_timeout)(struct hisi_hba *hisi_hba, 3508c2ecf20Sopenharmony_ci int delay_ms, int timeout_ms); 3518c2ecf20Sopenharmony_ci void (*snapshot_prepare)(struct hisi_hba *hisi_hba); 3528c2ecf20Sopenharmony_ci void (*snapshot_restore)(struct hisi_hba *hisi_hba); 3538c2ecf20Sopenharmony_ci int (*set_bist)(struct hisi_hba *hisi_hba, bool enable); 3548c2ecf20Sopenharmony_ci void (*read_iost_itct_cache)(struct hisi_hba *hisi_hba, 3558c2ecf20Sopenharmony_ci enum hisi_sas_debugfs_cache_type type, 3568c2ecf20Sopenharmony_ci u32 *cache); 3578c2ecf20Sopenharmony_ci int complete_hdr_size; 3588c2ecf20Sopenharmony_ci struct scsi_host_template *sht; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci const struct hisi_sas_debugfs_reg *debugfs_reg_array[DEBUGFS_REGS_NUM]; 3618c2ecf20Sopenharmony_ci const struct hisi_sas_debugfs_reg *debugfs_reg_port; 3628c2ecf20Sopenharmony_ci}; 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci#define HISI_SAS_MAX_DEBUGFS_DUMP (50) 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_cq { 3678c2ecf20Sopenharmony_ci struct hisi_sas_cq *cq; 3688c2ecf20Sopenharmony_ci void *complete_hdr; 3698c2ecf20Sopenharmony_ci}; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_dq { 3728c2ecf20Sopenharmony_ci struct hisi_sas_dq *dq; 3738c2ecf20Sopenharmony_ci struct hisi_sas_cmd_hdr *hdr; 3748c2ecf20Sopenharmony_ci}; 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_regs { 3778c2ecf20Sopenharmony_ci struct hisi_hba *hisi_hba; 3788c2ecf20Sopenharmony_ci u32 *data; 3798c2ecf20Sopenharmony_ci}; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_port { 3828c2ecf20Sopenharmony_ci struct hisi_sas_phy *phy; 3838c2ecf20Sopenharmony_ci u32 *data; 3848c2ecf20Sopenharmony_ci}; 3858c2ecf20Sopenharmony_ci 3868c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_iost { 3878c2ecf20Sopenharmony_ci struct hisi_sas_iost *iost; 3888c2ecf20Sopenharmony_ci}; 3898c2ecf20Sopenharmony_ci 3908c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_itct { 3918c2ecf20Sopenharmony_ci struct hisi_sas_itct *itct; 3928c2ecf20Sopenharmony_ci}; 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_iost_cache { 3958c2ecf20Sopenharmony_ci struct hisi_sas_iost_itct_cache *cache; 3968c2ecf20Sopenharmony_ci}; 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_cistruct hisi_sas_debugfs_itct_cache { 3998c2ecf20Sopenharmony_ci struct hisi_sas_iost_itct_cache *cache; 4008c2ecf20Sopenharmony_ci}; 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_cistruct hisi_hba { 4038c2ecf20Sopenharmony_ci /* This must be the first element, used by SHOST_TO_SAS_HA */ 4048c2ecf20Sopenharmony_ci struct sas_ha_struct *p; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci struct platform_device *platform_dev; 4078c2ecf20Sopenharmony_ci struct pci_dev *pci_dev; 4088c2ecf20Sopenharmony_ci struct device *dev; 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci int prot_mask; 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci void __iomem *regs; 4138c2ecf20Sopenharmony_ci void __iomem *sgpio_regs; 4148c2ecf20Sopenharmony_ci struct regmap *ctrl; 4158c2ecf20Sopenharmony_ci u32 ctrl_reset_reg; 4168c2ecf20Sopenharmony_ci u32 ctrl_reset_sts_reg; 4178c2ecf20Sopenharmony_ci u32 ctrl_clock_ena_reg; 4188c2ecf20Sopenharmony_ci u32 refclk_frequency_mhz; 4198c2ecf20Sopenharmony_ci u8 sas_addr[SAS_ADDR_SIZE]; 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci int n_phy; 4228c2ecf20Sopenharmony_ci spinlock_t lock; 4238c2ecf20Sopenharmony_ci struct semaphore sem; 4248c2ecf20Sopenharmony_ci 4258c2ecf20Sopenharmony_ci struct timer_list timer; 4268c2ecf20Sopenharmony_ci struct workqueue_struct *wq; 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci int slot_index_count; 4298c2ecf20Sopenharmony_ci int last_slot_index; 4308c2ecf20Sopenharmony_ci int last_dev_id; 4318c2ecf20Sopenharmony_ci unsigned long *slot_index_tags; 4328c2ecf20Sopenharmony_ci unsigned long reject_stp_links_msk; 4338c2ecf20Sopenharmony_ci 4348c2ecf20Sopenharmony_ci /* SCSI/SAS glue */ 4358c2ecf20Sopenharmony_ci struct sas_ha_struct sha; 4368c2ecf20Sopenharmony_ci struct Scsi_Host *shost; 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES]; 4398c2ecf20Sopenharmony_ci struct hisi_sas_dq dq[HISI_SAS_MAX_QUEUES]; 4408c2ecf20Sopenharmony_ci struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS]; 4418c2ecf20Sopenharmony_ci struct hisi_sas_port port[HISI_SAS_MAX_PHYS]; 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci int queue_count; 4448c2ecf20Sopenharmony_ci 4458c2ecf20Sopenharmony_ci struct hisi_sas_device devices[HISI_SAS_MAX_DEVICES]; 4468c2ecf20Sopenharmony_ci struct hisi_sas_cmd_hdr *cmd_hdr[HISI_SAS_MAX_QUEUES]; 4478c2ecf20Sopenharmony_ci dma_addr_t cmd_hdr_dma[HISI_SAS_MAX_QUEUES]; 4488c2ecf20Sopenharmony_ci void *complete_hdr[HISI_SAS_MAX_QUEUES]; 4498c2ecf20Sopenharmony_ci dma_addr_t complete_hdr_dma[HISI_SAS_MAX_QUEUES]; 4508c2ecf20Sopenharmony_ci struct hisi_sas_initial_fis *initial_fis; 4518c2ecf20Sopenharmony_ci dma_addr_t initial_fis_dma; 4528c2ecf20Sopenharmony_ci struct hisi_sas_itct *itct; 4538c2ecf20Sopenharmony_ci dma_addr_t itct_dma; 4548c2ecf20Sopenharmony_ci struct hisi_sas_iost *iost; 4558c2ecf20Sopenharmony_ci dma_addr_t iost_dma; 4568c2ecf20Sopenharmony_ci struct hisi_sas_breakpoint *breakpoint; 4578c2ecf20Sopenharmony_ci dma_addr_t breakpoint_dma; 4588c2ecf20Sopenharmony_ci struct hisi_sas_breakpoint *sata_breakpoint; 4598c2ecf20Sopenharmony_ci dma_addr_t sata_breakpoint_dma; 4608c2ecf20Sopenharmony_ci struct hisi_sas_slot *slot_info; 4618c2ecf20Sopenharmony_ci unsigned long flags; 4628c2ecf20Sopenharmony_ci const struct hisi_sas_hw *hw; /* Low level hw interface */ 4638c2ecf20Sopenharmony_ci unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)]; 4648c2ecf20Sopenharmony_ci struct work_struct rst_work; 4658c2ecf20Sopenharmony_ci struct work_struct debugfs_work; 4668c2ecf20Sopenharmony_ci u32 phy_state; 4678c2ecf20Sopenharmony_ci u32 intr_coal_ticks; /* Time of interrupt coalesce in us */ 4688c2ecf20Sopenharmony_ci u32 intr_coal_count; /* Interrupt count to coalesce */ 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci int cq_nvecs; 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_ci /* bist */ 4738c2ecf20Sopenharmony_ci enum sas_linkrate debugfs_bist_linkrate; 4748c2ecf20Sopenharmony_ci int debugfs_bist_code_mode; 4758c2ecf20Sopenharmony_ci int debugfs_bist_phy_no; 4768c2ecf20Sopenharmony_ci int debugfs_bist_mode; 4778c2ecf20Sopenharmony_ci u32 debugfs_bist_cnt; 4788c2ecf20Sopenharmony_ci int debugfs_bist_enable; 4798c2ecf20Sopenharmony_ci u32 debugfs_bist_ffe[HISI_SAS_MAX_PHYS][FFE_CFG_MAX]; 4808c2ecf20Sopenharmony_ci u32 debugfs_bist_fixed_code[FIXED_CODE_MAX]; 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci /* debugfs memories */ 4838c2ecf20Sopenharmony_ci /* Put Global AXI and RAS Register into register array */ 4848c2ecf20Sopenharmony_ci struct hisi_sas_debugfs_regs debugfs_regs[HISI_SAS_MAX_DEBUGFS_DUMP][DEBUGFS_REGS_NUM]; 4858c2ecf20Sopenharmony_ci struct hisi_sas_debugfs_port debugfs_port_reg[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_PHYS]; 4868c2ecf20Sopenharmony_ci struct hisi_sas_debugfs_cq debugfs_cq[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_QUEUES]; 4878c2ecf20Sopenharmony_ci struct hisi_sas_debugfs_dq debugfs_dq[HISI_SAS_MAX_DEBUGFS_DUMP][HISI_SAS_MAX_QUEUES]; 4888c2ecf20Sopenharmony_ci struct hisi_sas_debugfs_iost debugfs_iost[HISI_SAS_MAX_DEBUGFS_DUMP]; 4898c2ecf20Sopenharmony_ci struct hisi_sas_debugfs_itct debugfs_itct[HISI_SAS_MAX_DEBUGFS_DUMP]; 4908c2ecf20Sopenharmony_ci struct hisi_sas_debugfs_iost_cache debugfs_iost_cache[HISI_SAS_MAX_DEBUGFS_DUMP]; 4918c2ecf20Sopenharmony_ci struct hisi_sas_debugfs_itct_cache debugfs_itct_cache[HISI_SAS_MAX_DEBUGFS_DUMP]; 4928c2ecf20Sopenharmony_ci 4938c2ecf20Sopenharmony_ci u64 debugfs_timestamp[HISI_SAS_MAX_DEBUGFS_DUMP]; 4948c2ecf20Sopenharmony_ci int debugfs_dump_index; 4958c2ecf20Sopenharmony_ci struct dentry *debugfs_dir; 4968c2ecf20Sopenharmony_ci struct dentry *debugfs_dump_dentry; 4978c2ecf20Sopenharmony_ci struct dentry *debugfs_bist_dentry; 4988c2ecf20Sopenharmony_ci}; 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci/* Generic HW DMA host memory structures */ 5018c2ecf20Sopenharmony_ci/* Delivery queue header */ 5028c2ecf20Sopenharmony_cistruct hisi_sas_cmd_hdr { 5038c2ecf20Sopenharmony_ci /* dw0 */ 5048c2ecf20Sopenharmony_ci __le32 dw0; 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci /* dw1 */ 5078c2ecf20Sopenharmony_ci __le32 dw1; 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci /* dw2 */ 5108c2ecf20Sopenharmony_ci __le32 dw2; 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_ci /* dw3 */ 5138c2ecf20Sopenharmony_ci __le32 transfer_tags; 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci /* dw4 */ 5168c2ecf20Sopenharmony_ci __le32 data_transfer_len; 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci /* dw5 */ 5198c2ecf20Sopenharmony_ci __le32 first_burst_num; 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci /* dw6 */ 5228c2ecf20Sopenharmony_ci __le32 sg_len; 5238c2ecf20Sopenharmony_ci 5248c2ecf20Sopenharmony_ci /* dw7 */ 5258c2ecf20Sopenharmony_ci __le32 dw7; 5268c2ecf20Sopenharmony_ci 5278c2ecf20Sopenharmony_ci /* dw8-9 */ 5288c2ecf20Sopenharmony_ci __le64 cmd_table_addr; 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci /* dw10-11 */ 5318c2ecf20Sopenharmony_ci __le64 sts_buffer_addr; 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci /* dw12-13 */ 5348c2ecf20Sopenharmony_ci __le64 prd_table_addr; 5358c2ecf20Sopenharmony_ci 5368c2ecf20Sopenharmony_ci /* dw14-15 */ 5378c2ecf20Sopenharmony_ci __le64 dif_prd_table_addr; 5388c2ecf20Sopenharmony_ci}; 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_cistruct hisi_sas_itct { 5418c2ecf20Sopenharmony_ci __le64 qw0; 5428c2ecf20Sopenharmony_ci __le64 sas_addr; 5438c2ecf20Sopenharmony_ci __le64 qw2; 5448c2ecf20Sopenharmony_ci __le64 qw3; 5458c2ecf20Sopenharmony_ci __le64 qw4_15[12]; 5468c2ecf20Sopenharmony_ci}; 5478c2ecf20Sopenharmony_ci 5488c2ecf20Sopenharmony_cistruct hisi_sas_iost { 5498c2ecf20Sopenharmony_ci __le64 qw0; 5508c2ecf20Sopenharmony_ci __le64 qw1; 5518c2ecf20Sopenharmony_ci __le64 qw2; 5528c2ecf20Sopenharmony_ci __le64 qw3; 5538c2ecf20Sopenharmony_ci}; 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_cistruct hisi_sas_err_record { 5568c2ecf20Sopenharmony_ci u32 data[4]; 5578c2ecf20Sopenharmony_ci}; 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_cistruct hisi_sas_initial_fis { 5608c2ecf20Sopenharmony_ci struct hisi_sas_err_record err_record; 5618c2ecf20Sopenharmony_ci struct dev_to_host_fis fis; 5628c2ecf20Sopenharmony_ci u32 rsvd[3]; 5638c2ecf20Sopenharmony_ci}; 5648c2ecf20Sopenharmony_ci 5658c2ecf20Sopenharmony_cistruct hisi_sas_breakpoint { 5668c2ecf20Sopenharmony_ci u8 data[128]; 5678c2ecf20Sopenharmony_ci}; 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_cistruct hisi_sas_sata_breakpoint { 5708c2ecf20Sopenharmony_ci struct hisi_sas_breakpoint tag[32]; 5718c2ecf20Sopenharmony_ci}; 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_cistruct hisi_sas_sge { 5748c2ecf20Sopenharmony_ci __le64 addr; 5758c2ecf20Sopenharmony_ci __le32 page_ctrl_0; 5768c2ecf20Sopenharmony_ci __le32 page_ctrl_1; 5778c2ecf20Sopenharmony_ci __le32 data_len; 5788c2ecf20Sopenharmony_ci __le32 data_off; 5798c2ecf20Sopenharmony_ci}; 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_cistruct hisi_sas_command_table_smp { 5828c2ecf20Sopenharmony_ci u8 bytes[44]; 5838c2ecf20Sopenharmony_ci}; 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_cistruct hisi_sas_command_table_stp { 5868c2ecf20Sopenharmony_ci struct host_to_dev_fis command_fis; 5878c2ecf20Sopenharmony_ci u8 dummy[12]; 5888c2ecf20Sopenharmony_ci u8 atapi_cdb[ATAPI_CDB_LEN]; 5898c2ecf20Sopenharmony_ci}; 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci#define HISI_SAS_SGE_PAGE_CNT (124) 5928c2ecf20Sopenharmony_cistruct hisi_sas_sge_page { 5938c2ecf20Sopenharmony_ci struct hisi_sas_sge sge[HISI_SAS_SGE_PAGE_CNT]; 5948c2ecf20Sopenharmony_ci} __aligned(16); 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci#define HISI_SAS_SGE_DIF_PAGE_CNT HISI_SAS_SGE_PAGE_CNT 5978c2ecf20Sopenharmony_cistruct hisi_sas_sge_dif_page { 5988c2ecf20Sopenharmony_ci struct hisi_sas_sge sge[HISI_SAS_SGE_DIF_PAGE_CNT]; 5998c2ecf20Sopenharmony_ci} __aligned(16); 6008c2ecf20Sopenharmony_ci 6018c2ecf20Sopenharmony_cistruct hisi_sas_command_table_ssp { 6028c2ecf20Sopenharmony_ci struct ssp_frame_hdr hdr; 6038c2ecf20Sopenharmony_ci union { 6048c2ecf20Sopenharmony_ci struct { 6058c2ecf20Sopenharmony_ci struct ssp_command_iu task; 6068c2ecf20Sopenharmony_ci u32 prot[7]; 6078c2ecf20Sopenharmony_ci }; 6088c2ecf20Sopenharmony_ci struct ssp_tmf_iu ssp_task; 6098c2ecf20Sopenharmony_ci struct xfer_rdy_iu xfer_rdy; 6108c2ecf20Sopenharmony_ci struct ssp_response_iu ssp_res; 6118c2ecf20Sopenharmony_ci } u; 6128c2ecf20Sopenharmony_ci}; 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ciunion hisi_sas_command_table { 6158c2ecf20Sopenharmony_ci struct hisi_sas_command_table_ssp ssp; 6168c2ecf20Sopenharmony_ci struct hisi_sas_command_table_smp smp; 6178c2ecf20Sopenharmony_ci struct hisi_sas_command_table_stp stp; 6188c2ecf20Sopenharmony_ci} __aligned(16); 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_cistruct hisi_sas_status_buffer { 6218c2ecf20Sopenharmony_ci struct hisi_sas_err_record err; 6228c2ecf20Sopenharmony_ci u8 iu[1024]; 6238c2ecf20Sopenharmony_ci} __aligned(16); 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_cistruct hisi_sas_slot_buf_table { 6268c2ecf20Sopenharmony_ci struct hisi_sas_status_buffer status_buffer; 6278c2ecf20Sopenharmony_ci union hisi_sas_command_table command_header; 6288c2ecf20Sopenharmony_ci struct hisi_sas_sge_page sge_page; 6298c2ecf20Sopenharmony_ci}; 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_cistruct hisi_sas_slot_dif_buf_table { 6328c2ecf20Sopenharmony_ci struct hisi_sas_slot_buf_table slot_buf; 6338c2ecf20Sopenharmony_ci struct hisi_sas_sge_dif_page sge_dif_page; 6348c2ecf20Sopenharmony_ci}; 6358c2ecf20Sopenharmony_ci 6368c2ecf20Sopenharmony_ciextern struct scsi_transport_template *hisi_sas_stt; 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ciextern bool hisi_sas_debugfs_enable; 6398c2ecf20Sopenharmony_ciextern u32 hisi_sas_debugfs_dump_count; 6408c2ecf20Sopenharmony_ciextern struct dentry *hisi_sas_debugfs_dir; 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ciextern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba); 6438c2ecf20Sopenharmony_ciextern int hisi_sas_alloc(struct hisi_hba *hisi_hba); 6448c2ecf20Sopenharmony_ciextern void hisi_sas_free(struct hisi_hba *hisi_hba); 6458c2ecf20Sopenharmony_ciextern u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, 6468c2ecf20Sopenharmony_ci int direction); 6478c2ecf20Sopenharmony_ciextern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port); 6488c2ecf20Sopenharmony_ciextern void hisi_sas_sata_done(struct sas_task *task, 6498c2ecf20Sopenharmony_ci struct hisi_sas_slot *slot); 6508c2ecf20Sopenharmony_ciextern int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba); 6518c2ecf20Sopenharmony_ciextern int hisi_sas_probe(struct platform_device *pdev, 6528c2ecf20Sopenharmony_ci const struct hisi_sas_hw *ops); 6538c2ecf20Sopenharmony_ciextern int hisi_sas_remove(struct platform_device *pdev); 6548c2ecf20Sopenharmony_ci 6558c2ecf20Sopenharmony_ciextern int hisi_sas_slave_configure(struct scsi_device *sdev); 6568c2ecf20Sopenharmony_ciextern int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time); 6578c2ecf20Sopenharmony_ciextern void hisi_sas_scan_start(struct Scsi_Host *shost); 6588c2ecf20Sopenharmony_ciextern int hisi_sas_host_reset(struct Scsi_Host *shost, int reset_type); 6598c2ecf20Sopenharmony_ciextern void hisi_sas_phy_enable(struct hisi_hba *hisi_hba, int phy_no, 6608c2ecf20Sopenharmony_ci int enable); 6618c2ecf20Sopenharmony_ciextern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy); 6628c2ecf20Sopenharmony_ciextern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, 6638c2ecf20Sopenharmony_ci struct sas_task *task, 6648c2ecf20Sopenharmony_ci struct hisi_sas_slot *slot); 6658c2ecf20Sopenharmony_ciextern void hisi_sas_init_mem(struct hisi_hba *hisi_hba); 6668c2ecf20Sopenharmony_ciextern void hisi_sas_rst_work_handler(struct work_struct *work); 6678c2ecf20Sopenharmony_ciextern void hisi_sas_sync_rst_work_handler(struct work_struct *work); 6688c2ecf20Sopenharmony_ciextern void hisi_sas_sync_irqs(struct hisi_hba *hisi_hba); 6698c2ecf20Sopenharmony_ciextern void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no); 6708c2ecf20Sopenharmony_ciextern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, 6718c2ecf20Sopenharmony_ci enum hisi_sas_phy_event event); 6728c2ecf20Sopenharmony_ciextern void hisi_sas_release_tasks(struct hisi_hba *hisi_hba); 6738c2ecf20Sopenharmony_ciextern u8 hisi_sas_get_prog_phy_linkrate_mask(enum sas_linkrate max); 6748c2ecf20Sopenharmony_ciextern void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba); 6758c2ecf20Sopenharmony_ciextern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba); 6768c2ecf20Sopenharmony_ciextern void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba); 6778c2ecf20Sopenharmony_ciextern void hisi_sas_debugfs_exit(struct hisi_hba *hisi_hba); 6788c2ecf20Sopenharmony_ciextern void hisi_sas_debugfs_work_handler(struct work_struct *work); 6798c2ecf20Sopenharmony_ci#endif 680