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