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