Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015 Linaro Ltd. |
| 4 | * Copyright (c) 2015 Hisilicon Limited. |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef _HISI_SAS_H_ |
| 8 | #define _HISI_SAS_H_ |
| 9 | |
John Garry | 4d558c7 | 2016-02-04 02:26:08 +0800 | [diff] [blame] | 10 | #include <linux/acpi.h> |
John Garry | 3bc45af | 2016-10-04 19:11:11 +0800 | [diff] [blame] | 11 | #include <linux/clk.h> |
Luo Jiaxing | ef63464 | 2018-12-19 23:56:39 +0800 | [diff] [blame] | 12 | #include <linux/debugfs.h> |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 13 | #include <linux/dmapool.h> |
Xiang Chen | a25d0d3 | 2017-08-11 00:09:40 +0800 | [diff] [blame] | 14 | #include <linux/iopoll.h> |
Xiang Chen | 2ba5afb | 2018-05-31 20:50:48 +0800 | [diff] [blame] | 15 | #include <linux/lcm.h> |
Xiang Chen | 57dbb2b | 2019-02-28 22:51:01 +0800 | [diff] [blame] | 16 | #include <linux/libata.h> |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 17 | #include <linux/mfd/syscon.h> |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/of_address.h> |
John Garry | 11b7524 | 2017-06-14 23:33:17 +0800 | [diff] [blame] | 20 | #include <linux/pci.h> |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 21 | #include <linux/platform_device.h> |
John Garry | 4d558c7 | 2016-02-04 02:26:08 +0800 | [diff] [blame] | 22 | #include <linux/property.h> |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 23 | #include <linux/regmap.h> |
John Garry | 6f2ff1a | 2016-01-26 02:47:20 +0800 | [diff] [blame] | 24 | #include <scsi/sas_ata.h> |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 25 | #include <scsi/libsas.h> |
| 26 | |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 27 | #define HISI_SAS_MAX_PHYS 9 |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 28 | #define HISI_SAS_MAX_QUEUES 32 |
Xiang Chen | 1273d65 | 2019-02-06 18:52:53 +0800 | [diff] [blame] | 29 | #define HISI_SAS_QUEUE_SLOTS 4096 |
Xiang Chen | 3297ded | 2017-10-24 23:51:35 +0800 | [diff] [blame] | 30 | #define HISI_SAS_MAX_ITCT_ENTRIES 1024 |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 31 | #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 32 | #define HISI_SAS_RESET_BIT 0 |
Xiaofei Tan | 917d3bd | 2017-08-11 00:09:26 +0800 | [diff] [blame] | 33 | #define HISI_SAS_REJECT_CMD_BIT 1 |
John Garry | 93352ab | 2019-08-05 21:47:58 +0800 | [diff] [blame] | 34 | #define HISI_SAS_MAX_COMMANDS (HISI_SAS_QUEUE_SLOTS) |
| 35 | #define HISI_SAS_RESERVED_IPTT 96 |
| 36 | #define HISI_SAS_UNRESERVED_IPTT \ |
| 37 | (HISI_SAS_MAX_COMMANDS - HISI_SAS_RESERVED_IPTT) |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 38 | |
Luo Jiaxing | bbe0a7b | 2019-08-05 21:48:01 +0800 | [diff] [blame] | 39 | #define HISI_SAS_IOST_ITCT_CACHE_NUM 64 |
| 40 | #define HISI_SAS_IOST_ITCT_CACHE_DW_SZ 10 |
| 41 | |
Xiaofei Tan | f557e32 | 2017-06-29 21:02:14 +0800 | [diff] [blame] | 42 | #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer)) |
| 43 | #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table)) |
| 44 | |
| 45 | #define hisi_sas_status_buf_addr(buf) \ |
Xiang Chen | b3cce12 | 2019-02-06 18:52:51 +0800 | [diff] [blame] | 46 | ((buf) + offsetof(struct hisi_sas_slot_buf_table, status_buffer)) |
| 47 | #define hisi_sas_status_buf_addr_mem(slot) hisi_sas_status_buf_addr((slot)->buf) |
Xiaofei Tan | f557e32 | 2017-06-29 21:02:14 +0800 | [diff] [blame] | 48 | #define hisi_sas_status_buf_addr_dma(slot) \ |
Xiang Chen | b3cce12 | 2019-02-06 18:52:51 +0800 | [diff] [blame] | 49 | hisi_sas_status_buf_addr((slot)->buf_dma) |
Xiaofei Tan | f557e32 | 2017-06-29 21:02:14 +0800 | [diff] [blame] | 50 | |
| 51 | #define hisi_sas_cmd_hdr_addr(buf) \ |
Xiang Chen | b3cce12 | 2019-02-06 18:52:51 +0800 | [diff] [blame] | 52 | ((buf) + offsetof(struct hisi_sas_slot_buf_table, command_header)) |
| 53 | #define hisi_sas_cmd_hdr_addr_mem(slot) hisi_sas_cmd_hdr_addr((slot)->buf) |
| 54 | #define hisi_sas_cmd_hdr_addr_dma(slot) hisi_sas_cmd_hdr_addr((slot)->buf_dma) |
Xiaofei Tan | f557e32 | 2017-06-29 21:02:14 +0800 | [diff] [blame] | 55 | |
| 56 | #define hisi_sas_sge_addr(buf) \ |
Xiang Chen | b3cce12 | 2019-02-06 18:52:51 +0800 | [diff] [blame] | 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 | |
| 61 | #define hisi_sas_sge_dif_addr(buf) \ |
| 62 | ((buf) + offsetof(struct hisi_sas_slot_dif_buf_table, sge_dif_page)) |
| 63 | #define hisi_sas_sge_dif_addr_mem(slot) hisi_sas_sge_dif_addr((slot)->buf) |
| 64 | #define hisi_sas_sge_dif_addr_dma(slot) hisi_sas_sge_dif_addr((slot)->buf_dma) |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 65 | |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 66 | #define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024) |
John Garry | 66ee999 | 2015-11-18 00:50:54 +0800 | [diff] [blame] | 67 | #define HISI_SAS_MAX_SMP_RESP_SZ 1028 |
John Garry | 6f2ff1a | 2016-01-26 02:47:20 +0800 | [diff] [blame] | 68 | #define HISI_SAS_MAX_STP_RESP_SZ 28 |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 69 | |
Xiang Chen | 6c7bb8a | 2017-06-14 23:33:14 +0800 | [diff] [blame] | 70 | #define HISI_SAS_SATA_PROTOCOL_NONDATA 0x1 |
| 71 | #define HISI_SAS_SATA_PROTOCOL_PIO 0x2 |
| 72 | #define HISI_SAS_SATA_PROTOCOL_DMA 0x4 |
| 73 | #define HISI_SAS_SATA_PROTOCOL_FPDMA 0x8 |
| 74 | #define HISI_SAS_SATA_PROTOCOL_ATAPI 0x10 |
| 75 | |
Xiang Chen | d6a9000 | 2018-12-17 22:40:07 +0800 | [diff] [blame] | 76 | #define HISI_SAS_DIF_PROT_MASK (SHOST_DIF_TYPE1_PROTECTION | \ |
| 77 | SHOST_DIF_TYPE2_PROTECTION | \ |
| 78 | SHOST_DIF_TYPE3_PROTECTION) |
| 79 | |
Xiang Chen | b3cce12 | 2019-02-06 18:52:51 +0800 | [diff] [blame] | 80 | #define HISI_SAS_DIX_PROT_MASK (SHOST_DIX_TYPE1_PROTECTION | \ |
| 81 | SHOST_DIX_TYPE2_PROTECTION | \ |
| 82 | SHOST_DIX_TYPE3_PROTECTION) |
| 83 | |
| 84 | #define HISI_SAS_PROT_MASK (HISI_SAS_DIF_PROT_MASK | HISI_SAS_DIX_PROT_MASK) |
Xiang Chen | d6a9000 | 2018-12-17 22:40:07 +0800 | [diff] [blame] | 85 | |
Xiaofei Tan | b6c9b15 | 2019-01-25 22:22:35 +0800 | [diff] [blame] | 86 | #define HISI_SAS_WAIT_PHYUP_TIMEOUT 20 |
| 87 | |
John Garry | abda97c | 2015-11-18 00:50:51 +0800 | [diff] [blame] | 88 | struct hisi_hba; |
John Garry | af740db | 2015-11-18 00:50:41 +0800 | [diff] [blame] | 89 | |
John Garry | 07d7859 | 2015-11-18 00:50:47 +0800 | [diff] [blame] | 90 | enum { |
| 91 | PORT_TYPE_SAS = (1U << 1), |
| 92 | PORT_TYPE_SATA = (1U << 0), |
| 93 | }; |
| 94 | |
Xiang Chen | 57dbb2b | 2019-02-28 22:51:01 +0800 | [diff] [blame] | 95 | enum dev_status { |
| 96 | HISI_SAS_DEV_INIT, |
| 97 | HISI_SAS_DEV_NORMAL, |
| 98 | }; |
| 99 | |
John Garry | 441c274 | 2016-08-24 19:05:47 +0800 | [diff] [blame] | 100 | enum { |
| 101 | HISI_SAS_INT_ABT_CMD = 0, |
| 102 | HISI_SAS_INT_ABT_DEV = 1, |
| 103 | }; |
| 104 | |
John Garry | abda97c | 2015-11-18 00:50:51 +0800 | [diff] [blame] | 105 | enum hisi_sas_dev_type { |
| 106 | HISI_SAS_DEV_TYPE_STP = 0, |
| 107 | HISI_SAS_DEV_TYPE_SSP, |
| 108 | HISI_SAS_DEV_TYPE_SATA, |
| 109 | }; |
| 110 | |
John Garry | 2b38335 | 2017-08-11 00:09:30 +0800 | [diff] [blame] | 111 | struct hisi_sas_hw_error { |
| 112 | u32 irq_msk; |
| 113 | u32 msk; |
| 114 | int shift; |
| 115 | const char *msg; |
| 116 | int reg; |
Shiju Jose | 729428c | 2017-10-24 23:51:39 +0800 | [diff] [blame] | 117 | const struct hisi_sas_hw_error *sub; |
John Garry | 2b38335 | 2017-08-11 00:09:30 +0800 | [diff] [blame] | 118 | }; |
| 119 | |
Xiaofei Tan | e402acd | 2017-12-09 01:16:38 +0800 | [diff] [blame] | 120 | struct hisi_sas_rst { |
| 121 | struct hisi_hba *hisi_hba; |
| 122 | struct completion *completion; |
| 123 | struct work_struct work; |
| 124 | bool done; |
| 125 | }; |
| 126 | |
| 127 | #define HISI_SAS_RST_WORK_INIT(r, c) \ |
| 128 | { .hisi_hba = hisi_hba, \ |
| 129 | .completion = &c, \ |
| 130 | .work = __WORK_INITIALIZER(r.work, \ |
| 131 | hisi_sas_sync_rst_work_handler), \ |
| 132 | .done = false, \ |
| 133 | } |
| 134 | |
| 135 | #define HISI_SAS_DECLARE_RST_WORK_ON_STACK(r) \ |
| 136 | DECLARE_COMPLETION_ONSTACK(c); \ |
Xiaofei Tan | e402acd | 2017-12-09 01:16:38 +0800 | [diff] [blame] | 137 | struct hisi_sas_rst r = HISI_SAS_RST_WORK_INIT(r, c) |
| 138 | |
| 139 | enum hisi_sas_bit_err_type { |
| 140 | HISI_SAS_ERR_SINGLE_BIT_ECC = 0x0, |
| 141 | HISI_SAS_ERR_MULTI_BIT_ECC = 0x1, |
| 142 | }; |
| 143 | |
Xiaofei Tan | e537b62 | 2017-12-09 01:16:44 +0800 | [diff] [blame] | 144 | enum hisi_sas_phy_event { |
| 145 | HISI_PHYE_PHY_UP = 0U, |
Xiaofei Tan | 057c3d1 | 2017-12-09 01:16:45 +0800 | [diff] [blame] | 146 | HISI_PHYE_LINK_RESET, |
Xiaofei Tan | e537b62 | 2017-12-09 01:16:44 +0800 | [diff] [blame] | 147 | HISI_PHYES_NUM, |
| 148 | }; |
| 149 | |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 150 | struct hisi_sas_phy { |
Xiaofei Tan | e537b62 | 2017-12-09 01:16:44 +0800 | [diff] [blame] | 151 | struct work_struct works[HISI_PHYES_NUM]; |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 152 | struct hisi_hba *hisi_hba; |
| 153 | struct hisi_sas_port *port; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 154 | struct asd_sas_phy sas_phy; |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 155 | struct sas_identify identify; |
Xiang Chen | 3e1fb1b | 2018-05-21 18:09:25 +0800 | [diff] [blame] | 156 | struct completion *reset_completion; |
Xiaofei Tan | b6c9b15 | 2019-01-25 22:22:35 +0800 | [diff] [blame] | 157 | struct timer_list timer; |
Xiang Chen | 3e1fb1b | 2018-05-21 18:09:25 +0800 | [diff] [blame] | 158 | spinlock_t lock; |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 159 | u64 port_id; /* from hw */ |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 160 | u64 frame_rcvd_size; |
| 161 | u8 frame_rcvd[32]; |
| 162 | u8 phy_attached; |
Xiang Chen | 3e1fb1b | 2018-05-21 18:09:25 +0800 | [diff] [blame] | 163 | u8 in_reset; |
| 164 | u8 reserved[2]; |
John Garry | d0ef10c | 2017-06-26 18:27:28 +0800 | [diff] [blame] | 165 | u32 phy_type; |
Xiaofei Tan | aaeb823 | 2019-02-28 22:50:59 +0800 | [diff] [blame] | 166 | u32 code_violation_err_count; |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 167 | enum sas_linkrate minimum_linkrate; |
| 168 | enum sas_linkrate maximum_linkrate; |
John Garry | c63b88c | 2019-04-11 20:46:38 +0800 | [diff] [blame] | 169 | int enable; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 170 | }; |
| 171 | |
| 172 | struct hisi_sas_port { |
| 173 | struct asd_sas_port sas_port; |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 174 | u8 port_attached; |
| 175 | u8 id; /* from hw */ |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 176 | }; |
| 177 | |
John Garry | 9101a07 | 2015-11-18 00:50:37 +0800 | [diff] [blame] | 178 | struct hisi_sas_cq { |
| 179 | struct hisi_hba *hisi_hba; |
Xiang Chen | 4fefe5b | 2019-02-06 18:52:55 +0800 | [diff] [blame] | 180 | const struct cpumask *pci_irq_mask; |
John Garry | d177c40 | 2017-01-03 20:24:48 +0800 | [diff] [blame] | 181 | struct tasklet_struct tasklet; |
John Garry | e6c346f | 2016-09-06 23:36:11 +0800 | [diff] [blame] | 182 | int rd_point; |
John Garry | 9101a07 | 2015-11-18 00:50:37 +0800 | [diff] [blame] | 183 | int id; |
| 184 | }; |
| 185 | |
John Garry | 4fde02a | 2016-09-06 23:36:12 +0800 | [diff] [blame] | 186 | struct hisi_sas_dq { |
| 187 | struct hisi_hba *hisi_hba; |
Xiang Chen | fa222db | 2018-05-09 23:10:48 +0800 | [diff] [blame] | 188 | struct list_head list; |
Xiang Chen | b1a4941 | 2017-06-14 23:33:13 +0800 | [diff] [blame] | 189 | spinlock_t lock; |
John Garry | 4fde02a | 2016-09-06 23:36:12 +0800 | [diff] [blame] | 190 | int wr_point; |
| 191 | int id; |
| 192 | }; |
| 193 | |
John Garry | af740db | 2015-11-18 00:50:41 +0800 | [diff] [blame] | 194 | struct hisi_sas_device { |
John Garry | abda97c | 2015-11-18 00:50:51 +0800 | [diff] [blame] | 195 | struct hisi_hba *hisi_hba; |
| 196 | struct domain_device *sas_device; |
Xiang Chen | 640acc9 | 2017-08-11 00:09:33 +0800 | [diff] [blame] | 197 | struct completion *completion; |
Xiang Chen | b1a4941 | 2017-06-14 23:33:13 +0800 | [diff] [blame] | 198 | struct hisi_sas_dq *dq; |
John Garry | 405314d | 2017-03-23 01:25:21 +0800 | [diff] [blame] | 199 | struct list_head list; |
John Garry | ad60483 | 2017-06-14 23:33:12 +0800 | [diff] [blame] | 200 | enum sas_device_type dev_type; |
Xiang Chen | 57dbb2b | 2019-02-28 22:51:01 +0800 | [diff] [blame] | 201 | enum dev_status dev_status; |
John Garry | ad60483 | 2017-06-14 23:33:12 +0800 | [diff] [blame] | 202 | int device_id; |
Xiaofei Tan | 32ccba5 | 2017-04-10 21:21:57 +0800 | [diff] [blame] | 203 | int sata_idx; |
Xiang Chen | 4fefe5b | 2019-02-06 18:52:55 +0800 | [diff] [blame] | 204 | spinlock_t lock; /* For protecting slots */ |
John Garry | af740db | 2015-11-18 00:50:41 +0800 | [diff] [blame] | 205 | }; |
| 206 | |
Xiaofei Tan | 78bd2b4 | 2018-05-21 18:09:21 +0800 | [diff] [blame] | 207 | struct hisi_sas_tmf_task { |
Xiaofei Tan | b09fcd0 | 2018-05-21 18:09:22 +0800 | [diff] [blame] | 208 | int force_phy; |
| 209 | int phy_id; |
Xiaofei Tan | 78bd2b4 | 2018-05-21 18:09:21 +0800 | [diff] [blame] | 210 | u8 tmf; |
| 211 | u16 tag_of_task_to_be_managed; |
| 212 | }; |
| 213 | |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 214 | struct hisi_sas_slot { |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 215 | struct list_head entry; |
Xiang Chen | fa222db | 2018-05-09 23:10:48 +0800 | [diff] [blame] | 216 | struct list_head delivery; |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 217 | struct sas_task *task; |
| 218 | struct hisi_sas_port *port; |
| 219 | u64 n_elem; |
Xiang Chen | b3cce12 | 2019-02-06 18:52:51 +0800 | [diff] [blame] | 220 | u64 n_elem_dif; |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 221 | int dlvry_queue; |
| 222 | int dlvry_queue_slot; |
John Garry | 27a3f22 | 2015-11-18 00:50:50 +0800 | [diff] [blame] | 223 | int cmplt_queue; |
| 224 | int cmplt_queue_slot; |
John Garry | cac9b2a | 2016-02-25 17:42:11 +0800 | [diff] [blame] | 225 | int abort; |
Xiang Chen | fa222db | 2018-05-09 23:10:48 +0800 | [diff] [blame] | 226 | int ready; |
Xiang Chen | 4fefe5b | 2019-02-06 18:52:55 +0800 | [diff] [blame] | 227 | int device_id; |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 228 | void *cmd_hdr; |
| 229 | dma_addr_t cmd_hdr_dma; |
John Garry | 0844a3f | 2017-04-10 21:21:59 +0800 | [diff] [blame] | 230 | struct timer_list internal_abort_timer; |
Xiang Chen | cd938e5 | 2018-05-02 23:56:26 +0800 | [diff] [blame] | 231 | bool is_internal; |
Xiaofei Tan | 78bd2b4 | 2018-05-21 18:09:21 +0800 | [diff] [blame] | 232 | struct hisi_sas_tmf_task *tmf; |
Xiang Chen | 2ba5afb | 2018-05-31 20:50:48 +0800 | [diff] [blame] | 233 | /* Do not reorder/change members after here */ |
| 234 | void *buf; |
| 235 | dma_addr_t buf_dma; |
John Garry | 735bcc7 | 2018-12-06 21:34:40 +0800 | [diff] [blame] | 236 | u16 idx; |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 237 | }; |
| 238 | |
Luo Jiaxing | caefac1 | 2018-12-19 23:56:42 +0800 | [diff] [blame] | 239 | #define HISI_SAS_DEBUGFS_REG(x) {#x, x} |
| 240 | |
| 241 | struct hisi_sas_debugfs_reg_lu { |
| 242 | char *name; |
| 243 | int off; |
| 244 | }; |
| 245 | |
Luo Jiaxing | eb1c2b7 | 2018-12-19 23:56:40 +0800 | [diff] [blame] | 246 | struct hisi_sas_debugfs_reg { |
Luo Jiaxing | caefac1 | 2018-12-19 23:56:42 +0800 | [diff] [blame] | 247 | const struct hisi_sas_debugfs_reg_lu *lu; |
Luo Jiaxing | eb1c2b7 | 2018-12-19 23:56:40 +0800 | [diff] [blame] | 248 | int count; |
Luo Jiaxing | 49159a5 | 2018-12-19 23:56:41 +0800 | [diff] [blame] | 249 | int base_off; |
| 250 | union { |
| 251 | u32 (*read_global_reg)(struct hisi_hba *hisi_hba, u32 off); |
| 252 | u32 (*read_port_reg)(struct hisi_hba *hisi_hba, int port, |
| 253 | u32 off); |
| 254 | }; |
Luo Jiaxing | eb1c2b7 | 2018-12-19 23:56:40 +0800 | [diff] [blame] | 255 | }; |
| 256 | |
Luo Jiaxing | bbe0a7b | 2019-08-05 21:48:01 +0800 | [diff] [blame] | 257 | struct hisi_sas_iost_itct_cache { |
| 258 | u32 data[HISI_SAS_IOST_ITCT_CACHE_DW_SZ]; |
| 259 | }; |
| 260 | |
Luo Jiaxing | b0b3e429 | 2019-08-05 21:48:02 +0800 | [diff] [blame] | 261 | enum hisi_sas_debugfs_reg_array_member { |
| 262 | DEBUGFS_GLOBAL = 0, |
| 263 | DEBUGFS_AXI, |
| 264 | DEBUGFS_RAS, |
| 265 | DEBUGFS_REGS_NUM |
| 266 | }; |
| 267 | |
Luo Jiaxing | bbe0a7b | 2019-08-05 21:48:01 +0800 | [diff] [blame] | 268 | enum hisi_sas_debugfs_cache_type { |
| 269 | HISI_SAS_ITCT_CACHE, |
| 270 | HISI_SAS_IOST_CACHE, |
| 271 | }; |
| 272 | |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 273 | struct hisi_sas_hw { |
John Garry | 8ff1d57 | 2015-11-18 00:50:46 +0800 | [diff] [blame] | 274 | int (*hw_init)(struct hisi_hba *hisi_hba); |
John Garry | abda97c | 2015-11-18 00:50:51 +0800 | [diff] [blame] | 275 | void (*setup_itct)(struct hisi_hba *hisi_hba, |
| 276 | struct hisi_sas_device *device); |
Xiang Chen | 784b46b | 2018-09-24 23:06:33 +0800 | [diff] [blame] | 277 | int (*slot_index_alloc)(struct hisi_hba *hisi_hba, |
John Garry | 685b6d6 | 2016-04-15 21:36:36 +0800 | [diff] [blame] | 278 | struct domain_device *device); |
| 279 | struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); |
Xiang Chen | 569eddc | 2019-01-25 22:22:30 +0800 | [diff] [blame] | 280 | void (*sl_notify_ssp)(struct hisi_hba *hisi_hba, int phy_no); |
Xiang Chen | b1a4941 | 2017-06-14 23:33:13 +0800 | [diff] [blame] | 281 | void (*start_delivery)(struct hisi_sas_dq *dq); |
Xiang Chen | a2b3820 | 2018-05-09 23:10:46 +0800 | [diff] [blame] | 282 | void (*prep_ssp)(struct hisi_hba *hisi_hba, |
Xiaofei Tan | 78bd2b4 | 2018-05-21 18:09:21 +0800 | [diff] [blame] | 283 | struct hisi_sas_slot *slot); |
Xiang Chen | a2b3820 | 2018-05-09 23:10:46 +0800 | [diff] [blame] | 284 | void (*prep_smp)(struct hisi_hba *hisi_hba, |
John Garry | 66ee999 | 2015-11-18 00:50:54 +0800 | [diff] [blame] | 285 | struct hisi_sas_slot *slot); |
Xiang Chen | a2b3820 | 2018-05-09 23:10:46 +0800 | [diff] [blame] | 286 | void (*prep_stp)(struct hisi_hba *hisi_hba, |
John Garry | 6f2ff1a | 2016-01-26 02:47:20 +0800 | [diff] [blame] | 287 | struct hisi_sas_slot *slot); |
Xiang Chen | a2b3820 | 2018-05-09 23:10:46 +0800 | [diff] [blame] | 288 | void (*prep_abort)(struct hisi_hba *hisi_hba, |
John Garry | 441c274 | 2016-08-24 19:05:47 +0800 | [diff] [blame] | 289 | struct hisi_sas_slot *slot, |
| 290 | int device_id, int abort_flag, int tag_to_abort); |
John Garry | 396b804 | 2017-03-23 01:25:19 +0800 | [diff] [blame] | 291 | void (*phys_init)(struct hisi_hba *hisi_hba); |
Xiang Chen | 1eb8eea | 2017-10-24 23:51:36 +0800 | [diff] [blame] | 292 | void (*phy_start)(struct hisi_hba *hisi_hba, int phy_no); |
John Garry | e4189d5 | 2015-11-18 00:50:57 +0800 | [diff] [blame] | 293 | void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no); |
| 294 | void (*phy_hard_reset)(struct hisi_hba *hisi_hba, int phy_no); |
Xiaofei Tan | c52108c | 2017-08-11 00:09:29 +0800 | [diff] [blame] | 295 | void (*get_events)(struct hisi_hba *hisi_hba, int phy_no); |
Xiang Chen | 2ae7578 | 2016-11-07 20:48:40 +0800 | [diff] [blame] | 296 | void (*phy_set_linkrate)(struct hisi_hba *hisi_hba, int phy_no, |
| 297 | struct sas_phy_linkrates *linkrates); |
| 298 | enum sas_linkrate (*phy_get_max_linkrate)(void); |
Xiaofei Tan | 0258141 | 2017-12-09 01:16:34 +0800 | [diff] [blame] | 299 | void (*clear_itct)(struct hisi_hba *hisi_hba, |
John Garry | 27a3f22 | 2015-11-18 00:50:50 +0800 | [diff] [blame] | 300 | struct hisi_sas_device *dev); |
Xiaofei Tan | 0258141 | 2017-12-09 01:16:34 +0800 | [diff] [blame] | 301 | void (*free_device)(struct hisi_sas_device *sas_dev); |
John Garry | 184a463 | 2015-11-18 00:50:52 +0800 | [diff] [blame] | 302 | int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id); |
Xiang Chen | d30ff26 | 2017-06-14 23:33:32 +0800 | [diff] [blame] | 303 | void (*dereg_device)(struct hisi_hba *hisi_hba, |
| 304 | struct domain_device *device); |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 305 | int (*soft_reset)(struct hisi_hba *hisi_hba); |
Xiaofei Tan | 917d3bd | 2017-08-11 00:09:26 +0800 | [diff] [blame] | 306 | u32 (*get_phys_state)(struct hisi_hba *hisi_hba); |
Xiaofei Tan | 6379c56 | 2018-01-18 00:46:53 +0800 | [diff] [blame] | 307 | int (*write_gpio)(struct hisi_hba *hisi_hba, u8 reg_type, |
| 308 | u8 reg_index, u8 reg_count, u8 *write_data); |
Luo Jiaxing | 4bc0580 | 2019-09-06 20:55:34 +0800 | [diff] [blame] | 309 | void (*wait_cmds_complete_timeout)(struct hisi_hba *hisi_hba, |
| 310 | int delay_ms, int timeout_ms); |
Luo Jiaxing | 49159a5 | 2018-12-19 23:56:41 +0800 | [diff] [blame] | 311 | void (*snapshot_prepare)(struct hisi_hba *hisi_hba); |
| 312 | void (*snapshot_restore)(struct hisi_hba *hisi_hba); |
Xiang Chen | 97b151e | 2019-09-06 20:55:36 +0800 | [diff] [blame^] | 313 | int (*set_bist)(struct hisi_hba *hisi_hba, bool enable); |
Luo Jiaxing | bbe0a7b | 2019-08-05 21:48:01 +0800 | [diff] [blame] | 314 | void (*read_iost_itct_cache)(struct hisi_hba *hisi_hba, |
| 315 | enum hisi_sas_debugfs_cache_type type, |
| 316 | u32 *cache); |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 317 | int complete_hdr_size; |
Xiang Chen | 235bfc7 | 2018-05-21 18:09:18 +0800 | [diff] [blame] | 318 | struct scsi_host_template *sht; |
Luo Jiaxing | eb1c2b7 | 2018-12-19 23:56:40 +0800 | [diff] [blame] | 319 | |
Luo Jiaxing | b0b3e429 | 2019-08-05 21:48:02 +0800 | [diff] [blame] | 320 | const struct hisi_sas_debugfs_reg *debugfs_reg_array[DEBUGFS_REGS_NUM]; |
Luo Jiaxing | eb1c2b7 | 2018-12-19 23:56:40 +0800 | [diff] [blame] | 321 | const struct hisi_sas_debugfs_reg *debugfs_reg_port; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 322 | }; |
| 323 | |
| 324 | struct hisi_hba { |
| 325 | /* This must be the first element, used by SHOST_TO_SAS_HA */ |
| 326 | struct sas_ha_struct *p; |
| 327 | |
John Garry | 11b7524 | 2017-06-14 23:33:17 +0800 | [diff] [blame] | 328 | struct platform_device *platform_dev; |
| 329 | struct pci_dev *pci_dev; |
| 330 | struct device *dev; |
| 331 | |
Xiang Chen | d6a9000 | 2018-12-17 22:40:07 +0800 | [diff] [blame] | 332 | int prot_mask; |
| 333 | |
John Garry | e26b2f4 | 2015-11-18 00:50:32 +0800 | [diff] [blame] | 334 | void __iomem *regs; |
Xiaofei Tan | 6379c56 | 2018-01-18 00:46:53 +0800 | [diff] [blame] | 335 | void __iomem *sgpio_regs; |
John Garry | e26b2f4 | 2015-11-18 00:50:32 +0800 | [diff] [blame] | 336 | struct regmap *ctrl; |
| 337 | u32 ctrl_reset_reg; |
| 338 | u32 ctrl_reset_sts_reg; |
| 339 | u32 ctrl_clock_ena_reg; |
John Garry | 3bc45af | 2016-10-04 19:11:11 +0800 | [diff] [blame] | 340 | u32 refclk_frequency_mhz; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 341 | u8 sas_addr[SAS_ADDR_SIZE]; |
| 342 | |
| 343 | int n_phy; |
John Garry | fa42d80 | 2015-11-18 00:50:43 +0800 | [diff] [blame] | 344 | spinlock_t lock; |
Xiaofei Tan | d2fc401 | 2018-05-31 20:50:44 +0800 | [diff] [blame] | 345 | struct semaphore sem; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 346 | |
John Garry | fa42d80 | 2015-11-18 00:50:43 +0800 | [diff] [blame] | 347 | struct timer_list timer; |
John Garry | 7e9080e | 2015-11-18 00:50:40 +0800 | [diff] [blame] | 348 | struct workqueue_struct *wq; |
John Garry | 257efd1 | 2015-11-18 00:50:36 +0800 | [diff] [blame] | 349 | |
| 350 | int slot_index_count; |
Xiang Chen | fa3be0f | 2018-05-21 18:09:14 +0800 | [diff] [blame] | 351 | int last_slot_index; |
Xiang Chen | 1b86518 | 2018-05-21 18:09:15 +0800 | [diff] [blame] | 352 | int last_dev_id; |
John Garry | 257efd1 | 2015-11-18 00:50:36 +0800 | [diff] [blame] | 353 | unsigned long *slot_index_tags; |
Xiaofei Tan | c7b9d36 | 2017-04-10 21:21:56 +0800 | [diff] [blame] | 354 | unsigned long reject_stp_links_msk; |
John Garry | 257efd1 | 2015-11-18 00:50:36 +0800 | [diff] [blame] | 355 | |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 356 | /* SCSI/SAS glue */ |
| 357 | struct sas_ha_struct sha; |
| 358 | struct Scsi_Host *shost; |
John Garry | 9101a07 | 2015-11-18 00:50:37 +0800 | [diff] [blame] | 359 | |
| 360 | struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES]; |
John Garry | 4fde02a | 2016-09-06 23:36:12 +0800 | [diff] [blame] | 361 | struct hisi_sas_dq dq[HISI_SAS_MAX_QUEUES]; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 362 | struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS]; |
| 363 | struct hisi_sas_port port[HISI_SAS_MAX_PHYS]; |
John Garry | e26b2f4 | 2015-11-18 00:50:32 +0800 | [diff] [blame] | 364 | |
| 365 | int queue_count; |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 366 | |
John Garry | af740db | 2015-11-18 00:50:41 +0800 | [diff] [blame] | 367 | struct hisi_sas_device devices[HISI_SAS_MAX_DEVICES]; |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 368 | struct hisi_sas_cmd_hdr *cmd_hdr[HISI_SAS_MAX_QUEUES]; |
| 369 | dma_addr_t cmd_hdr_dma[HISI_SAS_MAX_QUEUES]; |
| 370 | void *complete_hdr[HISI_SAS_MAX_QUEUES]; |
| 371 | dma_addr_t complete_hdr_dma[HISI_SAS_MAX_QUEUES]; |
| 372 | struct hisi_sas_initial_fis *initial_fis; |
| 373 | dma_addr_t initial_fis_dma; |
| 374 | struct hisi_sas_itct *itct; |
| 375 | dma_addr_t itct_dma; |
| 376 | struct hisi_sas_iost *iost; |
| 377 | dma_addr_t iost_dma; |
| 378 | struct hisi_sas_breakpoint *breakpoint; |
| 379 | dma_addr_t breakpoint_dma; |
| 380 | struct hisi_sas_breakpoint *sata_breakpoint; |
| 381 | dma_addr_t sata_breakpoint_dma; |
| 382 | struct hisi_sas_slot *slot_info; |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 383 | unsigned long flags; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 384 | const struct hisi_sas_hw *hw; /* Low level hw interface */ |
Xiaofei Tan | 32ccba5 | 2017-04-10 21:21:57 +0800 | [diff] [blame] | 385 | unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)]; |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 386 | struct work_struct rst_work; |
Luo Jiaxing | 49159a5 | 2018-12-19 23:56:41 +0800 | [diff] [blame] | 387 | struct work_struct debugfs_work; |
Xiaofei Tan | 4522204 | 2018-07-18 22:14:28 +0800 | [diff] [blame] | 388 | u32 phy_state; |
Xiang Chen | 3735979 | 2018-11-09 22:06:34 +0800 | [diff] [blame] | 389 | u32 intr_coal_ticks; /* Time of interrupt coalesce in us */ |
| 390 | u32 intr_coal_count; /* Interrupt count to coalesce */ |
Luo Jiaxing | ef63464 | 2018-12-19 23:56:39 +0800 | [diff] [blame] | 391 | |
John Garry | 795f25a | 2019-02-06 18:52:54 +0800 | [diff] [blame] | 392 | int cq_nvecs; |
Xiang Chen | 4fefe5b | 2019-02-06 18:52:55 +0800 | [diff] [blame] | 393 | unsigned int *reply_map; |
John Garry | 795f25a | 2019-02-06 18:52:54 +0800 | [diff] [blame] | 394 | |
Xiang Chen | 97b151e | 2019-09-06 20:55:36 +0800 | [diff] [blame^] | 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 | |
Luo Jiaxing | eb1c2b7 | 2018-12-19 23:56:40 +0800 | [diff] [blame] | 403 | /* debugfs memories */ |
Luo Jiaxing | b0b3e429 | 2019-08-05 21:48:02 +0800 | [diff] [blame] | 404 | /* Put Global AXI and RAS Register into register array */ |
| 405 | u32 *debugfs_regs[DEBUGFS_REGS_NUM]; |
John Garry | 5b0eeac | 2019-01-25 22:22:28 +0800 | [diff] [blame] | 406 | u32 *debugfs_port_reg[HISI_SAS_MAX_PHYS]; |
Luo Jiaxing | eb1c2b7 | 2018-12-19 23:56:40 +0800 | [diff] [blame] | 407 | void *debugfs_complete_hdr[HISI_SAS_MAX_QUEUES]; |
| 408 | struct hisi_sas_cmd_hdr *debugfs_cmd_hdr[HISI_SAS_MAX_QUEUES]; |
| 409 | struct hisi_sas_iost *debugfs_iost; |
| 410 | struct hisi_sas_itct *debugfs_itct; |
Luo Jiaxing | bbe0a7b | 2019-08-05 21:48:01 +0800 | [diff] [blame] | 411 | u64 *debugfs_iost_cache; |
| 412 | u64 *debugfs_itct_cache; |
Luo Jiaxing | eb1c2b7 | 2018-12-19 23:56:40 +0800 | [diff] [blame] | 413 | |
Luo Jiaxing | ef63464 | 2018-12-19 23:56:39 +0800 | [diff] [blame] | 414 | struct dentry *debugfs_dir; |
Luo Jiaxing | 49159a5 | 2018-12-19 23:56:41 +0800 | [diff] [blame] | 415 | struct dentry *debugfs_dump_dentry; |
Xiang Chen | 97b151e | 2019-09-06 20:55:36 +0800 | [diff] [blame^] | 416 | struct dentry *debugfs_bist_dentry; |
John Garry | c2c7e74 | 2019-01-25 22:22:27 +0800 | [diff] [blame] | 417 | bool debugfs_snapshot; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 418 | }; |
| 419 | |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 420 | /* Generic HW DMA host memory structures */ |
| 421 | /* Delivery queue header */ |
| 422 | struct hisi_sas_cmd_hdr { |
| 423 | /* dw0 */ |
| 424 | __le32 dw0; |
| 425 | |
| 426 | /* dw1 */ |
| 427 | __le32 dw1; |
| 428 | |
| 429 | /* dw2 */ |
| 430 | __le32 dw2; |
| 431 | |
| 432 | /* dw3 */ |
| 433 | __le32 transfer_tags; |
| 434 | |
| 435 | /* dw4 */ |
| 436 | __le32 data_transfer_len; |
| 437 | |
| 438 | /* dw5 */ |
| 439 | __le32 first_burst_num; |
| 440 | |
| 441 | /* dw6 */ |
| 442 | __le32 sg_len; |
| 443 | |
| 444 | /* dw7 */ |
| 445 | __le32 dw7; |
| 446 | |
| 447 | /* dw8-9 */ |
| 448 | __le64 cmd_table_addr; |
| 449 | |
| 450 | /* dw10-11 */ |
| 451 | __le64 sts_buffer_addr; |
| 452 | |
| 453 | /* dw12-13 */ |
| 454 | __le64 prd_table_addr; |
| 455 | |
| 456 | /* dw14-15 */ |
| 457 | __le64 dif_prd_table_addr; |
| 458 | }; |
| 459 | |
| 460 | struct hisi_sas_itct { |
| 461 | __le64 qw0; |
| 462 | __le64 sas_addr; |
| 463 | __le64 qw2; |
| 464 | __le64 qw3; |
John Garry | 281e3bf | 2016-01-26 02:47:06 +0800 | [diff] [blame] | 465 | __le64 qw4_15[12]; |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 466 | }; |
| 467 | |
| 468 | struct hisi_sas_iost { |
| 469 | __le64 qw0; |
| 470 | __le64 qw1; |
| 471 | __le64 qw2; |
| 472 | __le64 qw3; |
| 473 | }; |
| 474 | |
| 475 | struct hisi_sas_err_record { |
John Garry | 8d1eee7 | 2016-01-26 02:47:05 +0800 | [diff] [blame] | 476 | u32 data[4]; |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 477 | }; |
| 478 | |
| 479 | struct hisi_sas_initial_fis { |
| 480 | struct hisi_sas_err_record err_record; |
| 481 | struct dev_to_host_fis fis; |
| 482 | u32 rsvd[3]; |
| 483 | }; |
| 484 | |
| 485 | struct hisi_sas_breakpoint { |
Xiang Chen | 3297ded | 2017-10-24 23:51:35 +0800 | [diff] [blame] | 486 | u8 data[128]; |
| 487 | }; |
| 488 | |
| 489 | struct hisi_sas_sata_breakpoint { |
| 490 | struct hisi_sas_breakpoint tag[32]; |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 491 | }; |
| 492 | |
| 493 | struct hisi_sas_sge { |
| 494 | __le64 addr; |
| 495 | __le32 page_ctrl_0; |
| 496 | __le32 page_ctrl_1; |
| 497 | __le32 data_len; |
| 498 | __le32 data_off; |
| 499 | }; |
| 500 | |
| 501 | struct hisi_sas_command_table_smp { |
| 502 | u8 bytes[44]; |
| 503 | }; |
| 504 | |
| 505 | struct hisi_sas_command_table_stp { |
| 506 | struct host_to_dev_fis command_fis; |
| 507 | u8 dummy[12]; |
| 508 | u8 atapi_cdb[ATAPI_CDB_LEN]; |
| 509 | }; |
| 510 | |
John Garry | c7669f5 | 2019-05-29 17:58:44 +0800 | [diff] [blame] | 511 | #define HISI_SAS_SGE_PAGE_CNT (124) |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 512 | struct hisi_sas_sge_page { |
| 513 | struct hisi_sas_sge sge[HISI_SAS_SGE_PAGE_CNT]; |
Xiaofei Tan | f557e32 | 2017-06-29 21:02:14 +0800 | [diff] [blame] | 514 | } __aligned(16); |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 515 | |
John Garry | c7669f5 | 2019-05-29 17:58:44 +0800 | [diff] [blame] | 516 | #define HISI_SAS_SGE_DIF_PAGE_CNT HISI_SAS_SGE_PAGE_CNT |
Xiang Chen | b3cce12 | 2019-02-06 18:52:51 +0800 | [diff] [blame] | 517 | struct hisi_sas_sge_dif_page { |
| 518 | struct hisi_sas_sge sge[HISI_SAS_SGE_DIF_PAGE_CNT]; |
| 519 | } __aligned(16); |
| 520 | |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 521 | struct hisi_sas_command_table_ssp { |
| 522 | struct ssp_frame_hdr hdr; |
| 523 | union { |
| 524 | struct { |
| 525 | struct ssp_command_iu task; |
Xiang Chen | a14da7a | 2018-05-02 23:56:27 +0800 | [diff] [blame] | 526 | u32 prot[7]; |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 527 | }; |
| 528 | struct ssp_tmf_iu ssp_task; |
| 529 | struct xfer_rdy_iu xfer_rdy; |
| 530 | struct ssp_response_iu ssp_res; |
| 531 | } u; |
| 532 | }; |
| 533 | |
| 534 | union hisi_sas_command_table { |
| 535 | struct hisi_sas_command_table_ssp ssp; |
| 536 | struct hisi_sas_command_table_smp smp; |
| 537 | struct hisi_sas_command_table_stp stp; |
Xiaofei Tan | f557e32 | 2017-06-29 21:02:14 +0800 | [diff] [blame] | 538 | } __aligned(16); |
| 539 | |
| 540 | struct hisi_sas_status_buffer { |
| 541 | struct hisi_sas_err_record err; |
| 542 | u8 iu[1024]; |
| 543 | } __aligned(16); |
| 544 | |
| 545 | struct hisi_sas_slot_buf_table { |
| 546 | struct hisi_sas_status_buffer status_buffer; |
| 547 | union hisi_sas_command_table command_header; |
| 548 | struct hisi_sas_sge_page sge_page; |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 549 | }; |
John Garry | 2e244f0 | 2017-03-23 01:25:17 +0800 | [diff] [blame] | 550 | |
Xiang Chen | b3cce12 | 2019-02-06 18:52:51 +0800 | [diff] [blame] | 551 | struct hisi_sas_slot_dif_buf_table { |
| 552 | struct hisi_sas_slot_buf_table slot_buf; |
| 553 | struct hisi_sas_sge_dif_page sge_dif_page; |
| 554 | }; |
| 555 | |
John Garry | e21fe3a | 2017-06-14 23:33:20 +0800 | [diff] [blame] | 556 | extern struct scsi_transport_template *hisi_sas_stt; |
Luo Jiaxing | ef63464 | 2018-12-19 23:56:39 +0800 | [diff] [blame] | 557 | |
| 558 | extern bool hisi_sas_debugfs_enable; |
| 559 | extern struct dentry *hisi_sas_debugfs_dir; |
| 560 | |
Xiang Chen | a25d0d3 | 2017-08-11 00:09:40 +0800 | [diff] [blame] | 561 | extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba); |
Xiang Chen | ae68b56 | 2019-01-25 22:22:33 +0800 | [diff] [blame] | 562 | extern int hisi_sas_alloc(struct hisi_hba *hisi_hba); |
John Garry | e21fe3a | 2017-06-14 23:33:20 +0800 | [diff] [blame] | 563 | extern void hisi_sas_free(struct hisi_hba *hisi_hba); |
chenxiang | 468f4b8 | 2017-12-28 18:20:47 +0800 | [diff] [blame] | 564 | extern u8 hisi_sas_get_ata_protocol(struct host_to_dev_fis *fis, |
| 565 | int direction); |
John Garry | 2e244f0 | 2017-03-23 01:25:17 +0800 | [diff] [blame] | 566 | extern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port); |
Xiang Chen | 7590407 | 2017-06-14 23:33:15 +0800 | [diff] [blame] | 567 | extern void hisi_sas_sata_done(struct sas_task *task, |
| 568 | struct hisi_sas_slot *slot); |
John Garry | 0fa24c1 | 2017-06-14 23:33:18 +0800 | [diff] [blame] | 569 | extern int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba); |
John Garry | 9fb10b5 | 2015-11-18 00:50:44 +0800 | [diff] [blame] | 570 | extern int hisi_sas_probe(struct platform_device *pdev, |
| 571 | const struct hisi_sas_hw *ops); |
| 572 | extern int hisi_sas_remove(struct platform_device *pdev); |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 573 | |
Xiang Chen | 235bfc7 | 2018-05-21 18:09:18 +0800 | [diff] [blame] | 574 | extern int hisi_sas_slave_configure(struct scsi_device *sdev); |
| 575 | extern int hisi_sas_scan_finished(struct Scsi_Host *shost, unsigned long time); |
| 576 | extern void hisi_sas_scan_start(struct Scsi_Host *shost); |
Xiang Chen | 235bfc7 | 2018-05-21 18:09:18 +0800 | [diff] [blame] | 577 | extern int hisi_sas_host_reset(struct Scsi_Host *shost, int reset_type); |
John Garry | c63b88c | 2019-04-11 20:46:38 +0800 | [diff] [blame] | 578 | extern void hisi_sas_phy_enable(struct hisi_hba *hisi_hba, int phy_no, |
| 579 | int enable); |
John Garry | 184a463 | 2015-11-18 00:50:52 +0800 | [diff] [blame] | 580 | extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy); |
John Garry | 27a3f22 | 2015-11-18 00:50:50 +0800 | [diff] [blame] | 581 | extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, |
| 582 | struct sas_task *task, |
| 583 | struct hisi_sas_slot *slot); |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 584 | extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba); |
Xiaofei Tan | b4241f0 | 2017-10-24 23:51:45 +0800 | [diff] [blame] | 585 | extern void hisi_sas_rst_work_handler(struct work_struct *work); |
Xiaofei Tan | e402acd | 2017-12-09 01:16:38 +0800 | [diff] [blame] | 586 | extern void hisi_sas_sync_rst_work_handler(struct work_struct *work); |
Xiaofei Tan | 571295f | 2017-10-24 23:51:47 +0800 | [diff] [blame] | 587 | extern void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba); |
Xiaofei Tan | b6c9b15 | 2019-01-25 22:22:35 +0800 | [diff] [blame] | 588 | extern void hisi_sas_phy_oob_ready(struct hisi_hba *hisi_hba, int phy_no); |
Xiaofei Tan | e537b62 | 2017-12-09 01:16:44 +0800 | [diff] [blame] | 589 | extern bool hisi_sas_notify_phy_event(struct hisi_sas_phy *phy, |
| 590 | enum hisi_sas_phy_event event); |
Xiang Chen | 4d0951e | 2017-12-09 01:16:50 +0800 | [diff] [blame] | 591 | extern void hisi_sas_release_tasks(struct hisi_hba *hisi_hba); |
Xiang Chen | c2c1d9d | 2018-05-02 23:56:30 +0800 | [diff] [blame] | 592 | extern u8 hisi_sas_get_prog_phy_linkrate_mask(enum sas_linkrate max); |
Xiaofei Tan | 4522204 | 2018-07-18 22:14:28 +0800 | [diff] [blame] | 593 | extern void hisi_sas_controller_reset_prepare(struct hisi_hba *hisi_hba); |
| 594 | extern void hisi_sas_controller_reset_done(struct hisi_hba *hisi_hba); |
Luo Jiaxing | ef63464 | 2018-12-19 23:56:39 +0800 | [diff] [blame] | 595 | extern void hisi_sas_debugfs_init(struct hisi_hba *hisi_hba); |
| 596 | extern void hisi_sas_debugfs_exit(struct hisi_hba *hisi_hba); |
Luo Jiaxing | 49159a5 | 2018-12-19 23:56:41 +0800 | [diff] [blame] | 597 | extern void hisi_sas_debugfs_work_handler(struct work_struct *work); |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 598 | #endif |