John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Linaro Ltd. |
| 3 | * Copyright (c) 2015 Hisilicon Limited. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | */ |
| 11 | |
| 12 | #ifndef _HISI_SAS_H_ |
| 13 | #define _HISI_SAS_H_ |
| 14 | |
John Garry | 4d558c7 | 2016-02-04 02:26:08 +0800 | [diff] [blame] | 15 | #include <linux/acpi.h> |
John Garry | 3bc45af | 2016-10-04 19:11:11 +0800 | [diff] [blame] | 16 | #include <linux/clk.h> |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 17 | #include <linux/dmapool.h> |
| 18 | #include <linux/mfd/syscon.h> |
| 19 | #include <linux/module.h> |
| 20 | #include <linux/of_address.h> |
John Garry | 11b7524 | 2017-06-14 23:33:17 +0800 | [diff] [blame^] | 21 | #include <linux/pci.h> |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 22 | #include <linux/platform_device.h> |
John Garry | 4d558c7 | 2016-02-04 02:26:08 +0800 | [diff] [blame] | 23 | #include <linux/property.h> |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 24 | #include <linux/regmap.h> |
John Garry | 6f2ff1a | 2016-01-26 02:47:20 +0800 | [diff] [blame] | 25 | #include <scsi/sas_ata.h> |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 26 | #include <scsi/libsas.h> |
| 27 | |
John Garry | 6328d90 | 2016-08-24 19:05:54 +0800 | [diff] [blame] | 28 | #define DRV_VERSION "v1.6" |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 29 | |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 30 | #define HISI_SAS_MAX_PHYS 9 |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 31 | #define HISI_SAS_MAX_QUEUES 32 |
| 32 | #define HISI_SAS_QUEUE_SLOTS 512 |
John Garry | 5560e9f | 2016-01-26 02:47:04 +0800 | [diff] [blame] | 33 | #define HISI_SAS_MAX_ITCT_ENTRIES 2048 |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 34 | #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 35 | #define HISI_SAS_RESET_BIT 0 |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 36 | |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 37 | #define HISI_SAS_STATUS_BUF_SZ \ |
| 38 | (sizeof(struct hisi_sas_err_record) + 1024) |
| 39 | #define HISI_SAS_COMMAND_TABLE_SZ \ |
| 40 | (((sizeof(union hisi_sas_command_table)+3)/4)*4) |
| 41 | |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 42 | #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] | 43 | #define HISI_SAS_MAX_SMP_RESP_SZ 1028 |
John Garry | 6f2ff1a | 2016-01-26 02:47:20 +0800 | [diff] [blame] | 44 | #define HISI_SAS_MAX_STP_RESP_SZ 28 |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 45 | |
John Garry | 98bf39f | 2016-01-26 02:47:02 +0800 | [diff] [blame] | 46 | #define DEV_IS_EXPANDER(type) \ |
| 47 | ((type == SAS_EDGE_EXPANDER_DEVICE) || \ |
| 48 | (type == SAS_FANOUT_EXPANDER_DEVICE)) |
| 49 | |
Xiang Chen | 6c7bb8a | 2017-06-14 23:33:14 +0800 | [diff] [blame] | 50 | #define HISI_SAS_SATA_PROTOCOL_NONDATA 0x1 |
| 51 | #define HISI_SAS_SATA_PROTOCOL_PIO 0x2 |
| 52 | #define HISI_SAS_SATA_PROTOCOL_DMA 0x4 |
| 53 | #define HISI_SAS_SATA_PROTOCOL_FPDMA 0x8 |
| 54 | #define HISI_SAS_SATA_PROTOCOL_ATAPI 0x10 |
| 55 | |
John Garry | abda97c | 2015-11-18 00:50:51 +0800 | [diff] [blame] | 56 | struct hisi_hba; |
John Garry | af740db | 2015-11-18 00:50:41 +0800 | [diff] [blame] | 57 | |
John Garry | 07d7859 | 2015-11-18 00:50:47 +0800 | [diff] [blame] | 58 | enum { |
| 59 | PORT_TYPE_SAS = (1U << 1), |
| 60 | PORT_TYPE_SATA = (1U << 0), |
| 61 | }; |
| 62 | |
John Garry | af740db | 2015-11-18 00:50:41 +0800 | [diff] [blame] | 63 | enum dev_status { |
| 64 | HISI_SAS_DEV_NORMAL, |
| 65 | HISI_SAS_DEV_EH, |
| 66 | }; |
John Garry | abda97c | 2015-11-18 00:50:51 +0800 | [diff] [blame] | 67 | |
John Garry | 441c274 | 2016-08-24 19:05:47 +0800 | [diff] [blame] | 68 | enum { |
| 69 | HISI_SAS_INT_ABT_CMD = 0, |
| 70 | HISI_SAS_INT_ABT_DEV = 1, |
| 71 | }; |
| 72 | |
John Garry | abda97c | 2015-11-18 00:50:51 +0800 | [diff] [blame] | 73 | enum hisi_sas_dev_type { |
| 74 | HISI_SAS_DEV_TYPE_STP = 0, |
| 75 | HISI_SAS_DEV_TYPE_SSP, |
| 76 | HISI_SAS_DEV_TYPE_SATA, |
| 77 | }; |
| 78 | |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 79 | struct hisi_sas_phy { |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 80 | struct hisi_hba *hisi_hba; |
| 81 | struct hisi_sas_port *port; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 82 | struct asd_sas_phy sas_phy; |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 83 | struct sas_identify identify; |
| 84 | struct timer_list timer; |
John Garry | 6613992 | 2015-11-18 00:50:48 +0800 | [diff] [blame] | 85 | struct work_struct phyup_ws; |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 86 | u64 port_id; /* from hw */ |
John Garry | 5d74242 | 2015-11-18 00:50:38 +0800 | [diff] [blame] | 87 | u64 dev_sas_addr; |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 88 | u64 phy_type; |
| 89 | u64 frame_rcvd_size; |
| 90 | u8 frame_rcvd[32]; |
| 91 | u8 phy_attached; |
| 92 | u8 reserved[3]; |
| 93 | enum sas_linkrate minimum_linkrate; |
| 94 | enum sas_linkrate maximum_linkrate; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | struct hisi_sas_port { |
| 98 | struct asd_sas_port sas_port; |
John Garry | 976867e | 2015-11-18 00:50:42 +0800 | [diff] [blame] | 99 | u8 port_attached; |
| 100 | u8 id; /* from hw */ |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 101 | }; |
| 102 | |
John Garry | 9101a07 | 2015-11-18 00:50:37 +0800 | [diff] [blame] | 103 | struct hisi_sas_cq { |
| 104 | struct hisi_hba *hisi_hba; |
John Garry | d177c40 | 2017-01-03 20:24:48 +0800 | [diff] [blame] | 105 | struct tasklet_struct tasklet; |
John Garry | e6c346f | 2016-09-06 23:36:11 +0800 | [diff] [blame] | 106 | int rd_point; |
John Garry | 9101a07 | 2015-11-18 00:50:37 +0800 | [diff] [blame] | 107 | int id; |
| 108 | }; |
| 109 | |
John Garry | 4fde02a | 2016-09-06 23:36:12 +0800 | [diff] [blame] | 110 | struct hisi_sas_dq { |
| 111 | struct hisi_hba *hisi_hba; |
Xiang Chen | b1a4941 | 2017-06-14 23:33:13 +0800 | [diff] [blame] | 112 | struct hisi_sas_slot *slot_prep; |
| 113 | spinlock_t lock; |
John Garry | 4fde02a | 2016-09-06 23:36:12 +0800 | [diff] [blame] | 114 | int wr_point; |
| 115 | int id; |
| 116 | }; |
| 117 | |
John Garry | af740db | 2015-11-18 00:50:41 +0800 | [diff] [blame] | 118 | struct hisi_sas_device { |
John Garry | abda97c | 2015-11-18 00:50:51 +0800 | [diff] [blame] | 119 | struct hisi_hba *hisi_hba; |
| 120 | struct domain_device *sas_device; |
Xiang Chen | b1a4941 | 2017-06-14 23:33:13 +0800 | [diff] [blame] | 121 | struct hisi_sas_dq *dq; |
John Garry | 405314d | 2017-03-23 01:25:21 +0800 | [diff] [blame] | 122 | struct list_head list; |
John Garry | ad60483 | 2017-06-14 23:33:12 +0800 | [diff] [blame] | 123 | u64 attached_phy; |
| 124 | atomic64_t running_req; |
| 125 | enum sas_device_type dev_type; |
| 126 | int device_id; |
Xiaofei Tan | 32ccba5 | 2017-04-10 21:21:57 +0800 | [diff] [blame] | 127 | int sata_idx; |
John Garry | ad60483 | 2017-06-14 23:33:12 +0800 | [diff] [blame] | 128 | u8 dev_status; |
John Garry | af740db | 2015-11-18 00:50:41 +0800 | [diff] [blame] | 129 | }; |
| 130 | |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 131 | struct hisi_sas_slot { |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 132 | struct list_head entry; |
| 133 | struct sas_task *task; |
| 134 | struct hisi_sas_port *port; |
| 135 | u64 n_elem; |
| 136 | int dlvry_queue; |
| 137 | int dlvry_queue_slot; |
John Garry | 27a3f22 | 2015-11-18 00:50:50 +0800 | [diff] [blame] | 138 | int cmplt_queue; |
| 139 | int cmplt_queue_slot; |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 140 | int idx; |
John Garry | cac9b2a | 2016-02-25 17:42:11 +0800 | [diff] [blame] | 141 | int abort; |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 142 | void *cmd_hdr; |
| 143 | dma_addr_t cmd_hdr_dma; |
| 144 | void *status_buffer; |
| 145 | dma_addr_t status_buffer_dma; |
| 146 | void *command_table; |
| 147 | dma_addr_t command_table_dma; |
| 148 | struct hisi_sas_sge_page *sge_page; |
| 149 | dma_addr_t sge_page_dma; |
John Garry | cac9b2a | 2016-02-25 17:42:11 +0800 | [diff] [blame] | 150 | struct work_struct abort_slot; |
John Garry | 0844a3f | 2017-04-10 21:21:59 +0800 | [diff] [blame] | 151 | struct timer_list internal_abort_timer; |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | struct hisi_sas_tmf_task { |
| 155 | u8 tmf; |
| 156 | u16 tag_of_task_to_be_managed; |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 157 | }; |
| 158 | |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 159 | struct hisi_sas_hw { |
John Garry | 8ff1d57 | 2015-11-18 00:50:46 +0800 | [diff] [blame] | 160 | int (*hw_init)(struct hisi_hba *hisi_hba); |
John Garry | abda97c | 2015-11-18 00:50:51 +0800 | [diff] [blame] | 161 | void (*setup_itct)(struct hisi_hba *hisi_hba, |
| 162 | struct hisi_sas_device *device); |
John Garry | 685b6d6 | 2016-04-15 21:36:36 +0800 | [diff] [blame] | 163 | int (*slot_index_alloc)(struct hisi_hba *hisi_hba, int *slot_idx, |
| 164 | struct domain_device *device); |
| 165 | struct hisi_sas_device *(*alloc_dev)(struct domain_device *device); |
John Garry | 6613992 | 2015-11-18 00:50:48 +0800 | [diff] [blame] | 166 | void (*sl_notify)(struct hisi_hba *hisi_hba, int phy_no); |
Xiang Chen | b1a4941 | 2017-06-14 23:33:13 +0800 | [diff] [blame] | 167 | int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq); |
| 168 | void (*start_delivery)(struct hisi_sas_dq *dq); |
John Garry | 42e7a69 | 2015-11-18 00:50:49 +0800 | [diff] [blame] | 169 | int (*prep_ssp)(struct hisi_hba *hisi_hba, |
| 170 | struct hisi_sas_slot *slot, int is_tmf, |
| 171 | struct hisi_sas_tmf_task *tmf); |
John Garry | 66ee999 | 2015-11-18 00:50:54 +0800 | [diff] [blame] | 172 | int (*prep_smp)(struct hisi_hba *hisi_hba, |
| 173 | struct hisi_sas_slot *slot); |
John Garry | 6f2ff1a | 2016-01-26 02:47:20 +0800 | [diff] [blame] | 174 | int (*prep_stp)(struct hisi_hba *hisi_hba, |
| 175 | struct hisi_sas_slot *slot); |
John Garry | 441c274 | 2016-08-24 19:05:47 +0800 | [diff] [blame] | 176 | int (*prep_abort)(struct hisi_hba *hisi_hba, |
| 177 | struct hisi_sas_slot *slot, |
| 178 | int device_id, int abort_flag, int tag_to_abort); |
John Garry | 27a3f22 | 2015-11-18 00:50:50 +0800 | [diff] [blame] | 179 | int (*slot_complete)(struct hisi_hba *hisi_hba, |
John Garry | 405314d | 2017-03-23 01:25:21 +0800 | [diff] [blame] | 180 | struct hisi_sas_slot *slot); |
John Garry | 396b804 | 2017-03-23 01:25:19 +0800 | [diff] [blame] | 181 | void (*phys_init)(struct hisi_hba *hisi_hba); |
John Garry | e4189d5 | 2015-11-18 00:50:57 +0800 | [diff] [blame] | 182 | void (*phy_enable)(struct hisi_hba *hisi_hba, int phy_no); |
| 183 | void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no); |
| 184 | void (*phy_hard_reset)(struct hisi_hba *hisi_hba, int phy_no); |
Xiang Chen | 2ae7578 | 2016-11-07 20:48:40 +0800 | [diff] [blame] | 185 | void (*phy_set_linkrate)(struct hisi_hba *hisi_hba, int phy_no, |
| 186 | struct sas_phy_linkrates *linkrates); |
| 187 | enum sas_linkrate (*phy_get_max_linkrate)(void); |
John Garry | 27a3f22 | 2015-11-18 00:50:50 +0800 | [diff] [blame] | 188 | void (*free_device)(struct hisi_hba *hisi_hba, |
| 189 | struct hisi_sas_device *dev); |
John Garry | 184a463 | 2015-11-18 00:50:52 +0800 | [diff] [blame] | 190 | int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id); |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 191 | int (*soft_reset)(struct hisi_hba *hisi_hba); |
John Garry | a8d547b | 2016-01-26 02:47:03 +0800 | [diff] [blame] | 192 | int max_command_entries; |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 193 | int complete_hdr_size; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 194 | }; |
| 195 | |
| 196 | struct hisi_hba { |
| 197 | /* This must be the first element, used by SHOST_TO_SAS_HA */ |
| 198 | struct sas_ha_struct *p; |
| 199 | |
John Garry | 11b7524 | 2017-06-14 23:33:17 +0800 | [diff] [blame^] | 200 | struct platform_device *platform_dev; |
| 201 | struct pci_dev *pci_dev; |
| 202 | struct device *dev; |
| 203 | |
John Garry | e26b2f4 | 2015-11-18 00:50:32 +0800 | [diff] [blame] | 204 | void __iomem *regs; |
| 205 | struct regmap *ctrl; |
| 206 | u32 ctrl_reset_reg; |
| 207 | u32 ctrl_reset_sts_reg; |
| 208 | u32 ctrl_clock_ena_reg; |
John Garry | 3bc45af | 2016-10-04 19:11:11 +0800 | [diff] [blame] | 209 | u32 refclk_frequency_mhz; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 210 | u8 sas_addr[SAS_ADDR_SIZE]; |
| 211 | |
| 212 | int n_phy; |
John Garry | fa42d80 | 2015-11-18 00:50:43 +0800 | [diff] [blame] | 213 | spinlock_t lock; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 214 | |
John Garry | fa42d80 | 2015-11-18 00:50:43 +0800 | [diff] [blame] | 215 | struct timer_list timer; |
John Garry | 7e9080e | 2015-11-18 00:50:40 +0800 | [diff] [blame] | 216 | struct workqueue_struct *wq; |
John Garry | 257efd1 | 2015-11-18 00:50:36 +0800 | [diff] [blame] | 217 | |
| 218 | int slot_index_count; |
| 219 | unsigned long *slot_index_tags; |
Xiaofei Tan | c7b9d36 | 2017-04-10 21:21:56 +0800 | [diff] [blame] | 220 | unsigned long reject_stp_links_msk; |
John Garry | 257efd1 | 2015-11-18 00:50:36 +0800 | [diff] [blame] | 221 | |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 222 | /* SCSI/SAS glue */ |
| 223 | struct sas_ha_struct sha; |
| 224 | struct Scsi_Host *shost; |
John Garry | 9101a07 | 2015-11-18 00:50:37 +0800 | [diff] [blame] | 225 | |
| 226 | struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES]; |
John Garry | 4fde02a | 2016-09-06 23:36:12 +0800 | [diff] [blame] | 227 | struct hisi_sas_dq dq[HISI_SAS_MAX_QUEUES]; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 228 | struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS]; |
| 229 | struct hisi_sas_port port[HISI_SAS_MAX_PHYS]; |
John Garry | e26b2f4 | 2015-11-18 00:50:32 +0800 | [diff] [blame] | 230 | |
| 231 | int queue_count; |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 232 | |
| 233 | struct dma_pool *sge_page_pool; |
John Garry | af740db | 2015-11-18 00:50:41 +0800 | [diff] [blame] | 234 | struct hisi_sas_device devices[HISI_SAS_MAX_DEVICES]; |
John Garry | 6be6de1 | 2015-11-18 00:50:34 +0800 | [diff] [blame] | 235 | struct dma_pool *command_table_pool; |
| 236 | struct dma_pool *status_buffer_pool; |
| 237 | struct hisi_sas_cmd_hdr *cmd_hdr[HISI_SAS_MAX_QUEUES]; |
| 238 | dma_addr_t cmd_hdr_dma[HISI_SAS_MAX_QUEUES]; |
| 239 | void *complete_hdr[HISI_SAS_MAX_QUEUES]; |
| 240 | dma_addr_t complete_hdr_dma[HISI_SAS_MAX_QUEUES]; |
| 241 | struct hisi_sas_initial_fis *initial_fis; |
| 242 | dma_addr_t initial_fis_dma; |
| 243 | struct hisi_sas_itct *itct; |
| 244 | dma_addr_t itct_dma; |
| 245 | struct hisi_sas_iost *iost; |
| 246 | dma_addr_t iost_dma; |
| 247 | struct hisi_sas_breakpoint *breakpoint; |
| 248 | dma_addr_t breakpoint_dma; |
| 249 | struct hisi_sas_breakpoint *sata_breakpoint; |
| 250 | dma_addr_t sata_breakpoint_dma; |
| 251 | struct hisi_sas_slot *slot_info; |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 252 | unsigned long flags; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 253 | const struct hisi_sas_hw *hw; /* Low level hw interface */ |
Xiaofei Tan | 32ccba5 | 2017-04-10 21:21:57 +0800 | [diff] [blame] | 254 | unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)]; |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 255 | struct work_struct rst_work; |
John Garry | 7eb7869 | 2015-11-18 00:50:31 +0800 | [diff] [blame] | 256 | }; |
| 257 | |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 258 | /* Generic HW DMA host memory structures */ |
| 259 | /* Delivery queue header */ |
| 260 | struct hisi_sas_cmd_hdr { |
| 261 | /* dw0 */ |
| 262 | __le32 dw0; |
| 263 | |
| 264 | /* dw1 */ |
| 265 | __le32 dw1; |
| 266 | |
| 267 | /* dw2 */ |
| 268 | __le32 dw2; |
| 269 | |
| 270 | /* dw3 */ |
| 271 | __le32 transfer_tags; |
| 272 | |
| 273 | /* dw4 */ |
| 274 | __le32 data_transfer_len; |
| 275 | |
| 276 | /* dw5 */ |
| 277 | __le32 first_burst_num; |
| 278 | |
| 279 | /* dw6 */ |
| 280 | __le32 sg_len; |
| 281 | |
| 282 | /* dw7 */ |
| 283 | __le32 dw7; |
| 284 | |
| 285 | /* dw8-9 */ |
| 286 | __le64 cmd_table_addr; |
| 287 | |
| 288 | /* dw10-11 */ |
| 289 | __le64 sts_buffer_addr; |
| 290 | |
| 291 | /* dw12-13 */ |
| 292 | __le64 prd_table_addr; |
| 293 | |
| 294 | /* dw14-15 */ |
| 295 | __le64 dif_prd_table_addr; |
| 296 | }; |
| 297 | |
| 298 | struct hisi_sas_itct { |
| 299 | __le64 qw0; |
| 300 | __le64 sas_addr; |
| 301 | __le64 qw2; |
| 302 | __le64 qw3; |
John Garry | 281e3bf | 2016-01-26 02:47:06 +0800 | [diff] [blame] | 303 | __le64 qw4_15[12]; |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 304 | }; |
| 305 | |
| 306 | struct hisi_sas_iost { |
| 307 | __le64 qw0; |
| 308 | __le64 qw1; |
| 309 | __le64 qw2; |
| 310 | __le64 qw3; |
| 311 | }; |
| 312 | |
| 313 | struct hisi_sas_err_record { |
John Garry | 8d1eee7 | 2016-01-26 02:47:05 +0800 | [diff] [blame] | 314 | u32 data[4]; |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 315 | }; |
| 316 | |
| 317 | struct hisi_sas_initial_fis { |
| 318 | struct hisi_sas_err_record err_record; |
| 319 | struct dev_to_host_fis fis; |
| 320 | u32 rsvd[3]; |
| 321 | }; |
| 322 | |
| 323 | struct hisi_sas_breakpoint { |
| 324 | u8 data[128]; /*io128 byte*/ |
| 325 | }; |
| 326 | |
| 327 | struct hisi_sas_sge { |
| 328 | __le64 addr; |
| 329 | __le32 page_ctrl_0; |
| 330 | __le32 page_ctrl_1; |
| 331 | __le32 data_len; |
| 332 | __le32 data_off; |
| 333 | }; |
| 334 | |
| 335 | struct hisi_sas_command_table_smp { |
| 336 | u8 bytes[44]; |
| 337 | }; |
| 338 | |
| 339 | struct hisi_sas_command_table_stp { |
| 340 | struct host_to_dev_fis command_fis; |
| 341 | u8 dummy[12]; |
| 342 | u8 atapi_cdb[ATAPI_CDB_LEN]; |
| 343 | }; |
| 344 | |
Ming Lin | 65e8617 | 2016-04-04 14:48:10 -0700 | [diff] [blame] | 345 | #define HISI_SAS_SGE_PAGE_CNT SG_CHUNK_SIZE |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 346 | struct hisi_sas_sge_page { |
| 347 | struct hisi_sas_sge sge[HISI_SAS_SGE_PAGE_CNT]; |
| 348 | }; |
| 349 | |
| 350 | struct hisi_sas_command_table_ssp { |
| 351 | struct ssp_frame_hdr hdr; |
| 352 | union { |
| 353 | struct { |
| 354 | struct ssp_command_iu task; |
| 355 | u32 prot[6]; |
| 356 | }; |
| 357 | struct ssp_tmf_iu ssp_task; |
| 358 | struct xfer_rdy_iu xfer_rdy; |
| 359 | struct ssp_response_iu ssp_res; |
| 360 | } u; |
| 361 | }; |
| 362 | |
| 363 | union hisi_sas_command_table { |
| 364 | struct hisi_sas_command_table_ssp ssp; |
| 365 | struct hisi_sas_command_table_smp smp; |
| 366 | struct hisi_sas_command_table_stp stp; |
| 367 | }; |
John Garry | 2e244f0 | 2017-03-23 01:25:17 +0800 | [diff] [blame] | 368 | |
Xiang Chen | 6c7bb8a | 2017-06-14 23:33:14 +0800 | [diff] [blame] | 369 | extern u8 hisi_sas_get_ata_protocol(u8 cmd, int direction); |
John Garry | 2e244f0 | 2017-03-23 01:25:17 +0800 | [diff] [blame] | 370 | 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] | 371 | extern void hisi_sas_sata_done(struct sas_task *task, |
| 372 | struct hisi_sas_slot *slot); |
Xiang Chen | 318913c | 2017-06-14 23:33:16 +0800 | [diff] [blame] | 373 | extern int hisi_sas_get_ncq_tag(struct sas_task *task, u32 *tag); |
John Garry | 9fb10b5 | 2015-11-18 00:50:44 +0800 | [diff] [blame] | 374 | extern int hisi_sas_probe(struct platform_device *pdev, |
| 375 | const struct hisi_sas_hw *ops); |
| 376 | extern int hisi_sas_remove(struct platform_device *pdev); |
John Garry | c799d6b | 2015-11-18 00:50:33 +0800 | [diff] [blame] | 377 | |
John Garry | 184a463 | 2015-11-18 00:50:52 +0800 | [diff] [blame] | 378 | 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] | 379 | extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, |
| 380 | struct sas_task *task, |
| 381 | struct hisi_sas_slot *slot); |
Xiang Chen | 06ec0fb | 2017-03-23 01:25:18 +0800 | [diff] [blame] | 382 | extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba); |
| 383 | extern void hisi_sas_rescan_topology(struct hisi_hba *hisi_hba, u32 old_state, |
| 384 | u32 state); |
John Garry | e8899fa | 2015-11-18 00:50:30 +0800 | [diff] [blame] | 385 | #endif |