xref: /linux/drivers/scsi/hisi_sas/hisi_sas.h (revision 0258141aaab3007949ba0e67c3d28436354429bb)
1e8899fadSJohn Garry /*
2e8899fadSJohn Garry  * Copyright (c) 2015 Linaro Ltd.
3e8899fadSJohn Garry  * Copyright (c) 2015 Hisilicon Limited.
4e8899fadSJohn Garry  *
5e8899fadSJohn Garry  * This program is free software; you can redistribute it and/or modify
6e8899fadSJohn Garry  * it under the terms of the GNU General Public License as published by
7e8899fadSJohn Garry  * the Free Software Foundation; either version 2 of the License, or
8e8899fadSJohn Garry  * (at your option) any later version.
9e8899fadSJohn Garry  *
10e8899fadSJohn Garry  */
11e8899fadSJohn Garry 
12e8899fadSJohn Garry #ifndef _HISI_SAS_H_
13e8899fadSJohn Garry #define _HISI_SAS_H_
14e8899fadSJohn Garry 
154d558c77SJohn Garry #include <linux/acpi.h>
163bc45af8SJohn Garry #include <linux/clk.h>
17e8899fadSJohn Garry #include <linux/dmapool.h>
18a25d0d3dSXiang Chen #include <linux/iopoll.h>
19e8899fadSJohn Garry #include <linux/mfd/syscon.h>
20e8899fadSJohn Garry #include <linux/module.h>
21e8899fadSJohn Garry #include <linux/of_address.h>
2211b75249SJohn Garry #include <linux/pci.h>
23e8899fadSJohn Garry #include <linux/platform_device.h>
244d558c77SJohn Garry #include <linux/property.h>
25e8899fadSJohn Garry #include <linux/regmap.h>
266f2ff1a1SJohn Garry #include <scsi/sas_ata.h>
27e8899fadSJohn Garry #include <scsi/libsas.h>
28e8899fadSJohn Garry 
297eb7869fSJohn Garry #define HISI_SAS_MAX_PHYS	9
306be6de18SJohn Garry #define HISI_SAS_MAX_QUEUES	32
316be6de18SJohn Garry #define HISI_SAS_QUEUE_SLOTS 512
323297ded1SXiang Chen #define HISI_SAS_MAX_ITCT_ENTRIES 1024
337eb7869fSJohn Garry #define HISI_SAS_MAX_DEVICES HISI_SAS_MAX_ITCT_ENTRIES
3406ec0fb9SXiang Chen #define HISI_SAS_RESET_BIT	0
35917d3bdaSXiaofei Tan #define HISI_SAS_REJECT_CMD_BIT	1
367eb7869fSJohn Garry 
37f557e32cSXiaofei Tan #define HISI_SAS_STATUS_BUF_SZ (sizeof(struct hisi_sas_status_buffer))
38f557e32cSXiaofei Tan #define HISI_SAS_COMMAND_TABLE_SZ (sizeof(union hisi_sas_command_table))
39f557e32cSXiaofei Tan 
40f557e32cSXiaofei Tan #define hisi_sas_status_buf_addr(buf) \
41f557e32cSXiaofei Tan 	(buf + offsetof(struct hisi_sas_slot_buf_table, status_buffer))
42f557e32cSXiaofei Tan #define hisi_sas_status_buf_addr_mem(slot) hisi_sas_status_buf_addr(slot->buf)
43f557e32cSXiaofei Tan #define hisi_sas_status_buf_addr_dma(slot) \
44f557e32cSXiaofei Tan 	hisi_sas_status_buf_addr(slot->buf_dma)
45f557e32cSXiaofei Tan 
46f557e32cSXiaofei Tan #define hisi_sas_cmd_hdr_addr(buf) \
47f557e32cSXiaofei Tan 	(buf + offsetof(struct hisi_sas_slot_buf_table, command_header))
48f557e32cSXiaofei Tan #define hisi_sas_cmd_hdr_addr_mem(slot) hisi_sas_cmd_hdr_addr(slot->buf)
49f557e32cSXiaofei Tan #define hisi_sas_cmd_hdr_addr_dma(slot) hisi_sas_cmd_hdr_addr(slot->buf_dma)
50f557e32cSXiaofei Tan 
51f557e32cSXiaofei Tan #define hisi_sas_sge_addr(buf) \
52f557e32cSXiaofei Tan 	(buf + offsetof(struct hisi_sas_slot_buf_table, sge_page))
53f557e32cSXiaofei Tan #define hisi_sas_sge_addr_mem(slot) hisi_sas_sge_addr(slot->buf)
54f557e32cSXiaofei Tan #define hisi_sas_sge_addr_dma(slot) hisi_sas_sge_addr(slot->buf_dma)
556be6de18SJohn Garry 
5642e7a693SJohn Garry #define HISI_SAS_MAX_SSP_RESP_SZ (sizeof(struct ssp_frame_hdr) + 1024)
5766ee999bSJohn Garry #define HISI_SAS_MAX_SMP_RESP_SZ 1028
586f2ff1a1SJohn Garry #define HISI_SAS_MAX_STP_RESP_SZ 28
5942e7a693SJohn Garry 
6098bf39fcSJohn Garry #define DEV_IS_EXPANDER(type) \
6198bf39fcSJohn Garry 	((type == SAS_EDGE_EXPANDER_DEVICE) || \
6298bf39fcSJohn Garry 	(type == SAS_FANOUT_EXPANDER_DEVICE))
6398bf39fcSJohn Garry 
646c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_NONDATA		0x1
656c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_PIO			0x2
666c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_DMA			0x4
676c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_FPDMA		0x8
686c7bb8a1SXiang Chen #define HISI_SAS_SATA_PROTOCOL_ATAPI		0x10
696c7bb8a1SXiang Chen 
70abda97c2SJohn Garry struct hisi_hba;
71af740dbeSJohn Garry 
7207d78592SJohn Garry enum {
7307d78592SJohn Garry 	PORT_TYPE_SAS = (1U << 1),
7407d78592SJohn Garry 	PORT_TYPE_SATA = (1U << 0),
7507d78592SJohn Garry };
7607d78592SJohn Garry 
77af740dbeSJohn Garry enum dev_status {
78af740dbeSJohn Garry 	HISI_SAS_DEV_NORMAL,
79af740dbeSJohn Garry 	HISI_SAS_DEV_EH,
80af740dbeSJohn Garry };
81abda97c2SJohn Garry 
82441c2740SJohn Garry enum {
83441c2740SJohn Garry 	HISI_SAS_INT_ABT_CMD = 0,
84441c2740SJohn Garry 	HISI_SAS_INT_ABT_DEV = 1,
85441c2740SJohn Garry };
86441c2740SJohn Garry 
87abda97c2SJohn Garry enum hisi_sas_dev_type {
88abda97c2SJohn Garry 	HISI_SAS_DEV_TYPE_STP = 0,
89abda97c2SJohn Garry 	HISI_SAS_DEV_TYPE_SSP,
90abda97c2SJohn Garry 	HISI_SAS_DEV_TYPE_SATA,
91abda97c2SJohn Garry };
92abda97c2SJohn Garry 
932b383351SJohn Garry struct hisi_sas_hw_error {
942b383351SJohn Garry 	u32 irq_msk;
952b383351SJohn Garry 	u32 msk;
962b383351SJohn Garry 	int shift;
972b383351SJohn Garry 	const char *msg;
982b383351SJohn Garry 	int reg;
99729428caSShiju Jose 	const struct hisi_sas_hw_error *sub;
1002b383351SJohn Garry };
1012b383351SJohn Garry 
1027eb7869fSJohn Garry struct hisi_sas_phy {
103976867e6SJohn Garry 	struct hisi_hba	*hisi_hba;
104976867e6SJohn Garry 	struct hisi_sas_port	*port;
1057eb7869fSJohn Garry 	struct asd_sas_phy	sas_phy;
106976867e6SJohn Garry 	struct sas_identify	identify;
10766139921SJohn Garry 	struct work_struct	phyup_ws;
108976867e6SJohn Garry 	u64		port_id; /* from hw */
1095d74242eSJohn Garry 	u64		dev_sas_addr;
110976867e6SJohn Garry 	u64		frame_rcvd_size;
111976867e6SJohn Garry 	u8		frame_rcvd[32];
112976867e6SJohn Garry 	u8		phy_attached;
113976867e6SJohn Garry 	u8		reserved[3];
114d0ef10c9SJohn Garry 	u32		phy_type;
115976867e6SJohn Garry 	enum sas_linkrate	minimum_linkrate;
116976867e6SJohn Garry 	enum sas_linkrate	maximum_linkrate;
1177eb7869fSJohn Garry };
1187eb7869fSJohn Garry 
1197eb7869fSJohn Garry struct hisi_sas_port {
1207eb7869fSJohn Garry 	struct asd_sas_port	sas_port;
121976867e6SJohn Garry 	u8	port_attached;
122976867e6SJohn Garry 	u8	id; /* from hw */
1237eb7869fSJohn Garry };
1247eb7869fSJohn Garry 
1259101a079SJohn Garry struct hisi_sas_cq {
1269101a079SJohn Garry 	struct hisi_hba *hisi_hba;
127d177c408SJohn Garry 	struct tasklet_struct tasklet;
128e6c346f3SJohn Garry 	int	rd_point;
1299101a079SJohn Garry 	int	id;
1309101a079SJohn Garry };
1319101a079SJohn Garry 
1324fde02adSJohn Garry struct hisi_sas_dq {
1334fde02adSJohn Garry 	struct hisi_hba *hisi_hba;
134b1a49412SXiang Chen 	struct hisi_sas_slot	*slot_prep;
135b1a49412SXiang Chen 	spinlock_t lock;
1364fde02adSJohn Garry 	int	wr_point;
1374fde02adSJohn Garry 	int	id;
1384fde02adSJohn Garry };
1394fde02adSJohn Garry 
140af740dbeSJohn Garry struct hisi_sas_device {
141abda97c2SJohn Garry 	struct hisi_hba		*hisi_hba;
142abda97c2SJohn Garry 	struct domain_device	*sas_device;
143640acc9aSXiang Chen 	struct completion *completion;
144b1a49412SXiang Chen 	struct hisi_sas_dq	*dq;
145405314dfSJohn Garry 	struct list_head	list;
146ad604832SJohn Garry 	u64 attached_phy;
147ad604832SJohn Garry 	atomic64_t running_req;
148ad604832SJohn Garry 	enum sas_device_type	dev_type;
149ad604832SJohn Garry 	int device_id;
15032ccba52SXiaofei Tan 	int sata_idx;
151ad604832SJohn Garry 	u8 dev_status;
152af740dbeSJohn Garry };
153af740dbeSJohn Garry 
1546be6de18SJohn Garry struct hisi_sas_slot {
15542e7a693SJohn Garry 	struct list_head entry;
15642e7a693SJohn Garry 	struct sas_task *task;
15742e7a693SJohn Garry 	struct hisi_sas_port	*port;
15842e7a693SJohn Garry 	u64	n_elem;
15942e7a693SJohn Garry 	int	dlvry_queue;
16042e7a693SJohn Garry 	int	dlvry_queue_slot;
16127a3f229SJohn Garry 	int	cmplt_queue;
16227a3f229SJohn Garry 	int	cmplt_queue_slot;
16342e7a693SJohn Garry 	int	idx;
164cac9b2a2SJohn Garry 	int	abort;
165f557e32cSXiaofei Tan 	void	*buf;
166f557e32cSXiaofei Tan 	dma_addr_t buf_dma;
16742e7a693SJohn Garry 	void	*cmd_hdr;
16842e7a693SJohn Garry 	dma_addr_t cmd_hdr_dma;
169cac9b2a2SJohn Garry 	struct work_struct abort_slot;
1700844a3ffSJohn Garry 	struct timer_list internal_abort_timer;
17142e7a693SJohn Garry };
17242e7a693SJohn Garry 
17342e7a693SJohn Garry struct hisi_sas_tmf_task {
17442e7a693SJohn Garry 	u8 tmf;
17542e7a693SJohn Garry 	u16 tag_of_task_to_be_managed;
1766be6de18SJohn Garry };
1776be6de18SJohn Garry 
1787eb7869fSJohn Garry struct hisi_sas_hw {
1798ff1d571SJohn Garry 	int (*hw_init)(struct hisi_hba *hisi_hba);
180abda97c2SJohn Garry 	void (*setup_itct)(struct hisi_hba *hisi_hba,
181abda97c2SJohn Garry 			   struct hisi_sas_device *device);
182685b6d6eSJohn Garry 	int (*slot_index_alloc)(struct hisi_hba *hisi_hba, int *slot_idx,
183685b6d6eSJohn Garry 				struct domain_device *device);
184685b6d6eSJohn Garry 	struct hisi_sas_device *(*alloc_dev)(struct domain_device *device);
18566139921SJohn Garry 	void (*sl_notify)(struct hisi_hba *hisi_hba, int phy_no);
186b1a49412SXiang Chen 	int (*get_free_slot)(struct hisi_hba *hisi_hba, struct hisi_sas_dq *dq);
187b1a49412SXiang Chen 	void (*start_delivery)(struct hisi_sas_dq *dq);
18842e7a693SJohn Garry 	int (*prep_ssp)(struct hisi_hba *hisi_hba,
18942e7a693SJohn Garry 			struct hisi_sas_slot *slot, int is_tmf,
19042e7a693SJohn Garry 			struct hisi_sas_tmf_task *tmf);
19166ee999bSJohn Garry 	int (*prep_smp)(struct hisi_hba *hisi_hba,
19266ee999bSJohn Garry 			struct hisi_sas_slot *slot);
1936f2ff1a1SJohn Garry 	int (*prep_stp)(struct hisi_hba *hisi_hba,
1946f2ff1a1SJohn Garry 			struct hisi_sas_slot *slot);
195441c2740SJohn Garry 	int (*prep_abort)(struct hisi_hba *hisi_hba,
196441c2740SJohn Garry 			  struct hisi_sas_slot *slot,
197441c2740SJohn Garry 			  int device_id, int abort_flag, int tag_to_abort);
19827a3f229SJohn Garry 	int (*slot_complete)(struct hisi_hba *hisi_hba,
199405314dfSJohn Garry 			     struct hisi_sas_slot *slot);
200396b8044SJohn Garry 	void (*phys_init)(struct hisi_hba *hisi_hba);
2011eb8eeacSXiang Chen 	void (*phy_start)(struct hisi_hba *hisi_hba, int phy_no);
202e4189d53SJohn Garry 	void (*phy_disable)(struct hisi_hba *hisi_hba, int phy_no);
203e4189d53SJohn Garry 	void (*phy_hard_reset)(struct hisi_hba *hisi_hba, int phy_no);
204c52108c6SXiaofei Tan 	void (*get_events)(struct hisi_hba *hisi_hba, int phy_no);
2052ae75787SXiang Chen 	void (*phy_set_linkrate)(struct hisi_hba *hisi_hba, int phy_no,
2062ae75787SXiang Chen 			struct sas_phy_linkrates *linkrates);
2072ae75787SXiang Chen 	enum sas_linkrate (*phy_get_max_linkrate)(void);
208*0258141aSXiaofei Tan 	void (*clear_itct)(struct hisi_hba *hisi_hba,
20927a3f229SJohn Garry 			    struct hisi_sas_device *dev);
210*0258141aSXiaofei Tan 	void (*free_device)(struct hisi_sas_device *sas_dev);
211184a4635SJohn Garry 	int (*get_wideport_bitmap)(struct hisi_hba *hisi_hba, int port_id);
212d30ff263SXiang Chen 	void (*dereg_device)(struct hisi_hba *hisi_hba,
213d30ff263SXiang Chen 				struct domain_device *device);
21406ec0fb9SXiang Chen 	int (*soft_reset)(struct hisi_hba *hisi_hba);
215917d3bdaSXiaofei Tan 	u32 (*get_phys_state)(struct hisi_hba *hisi_hba);
216a8d547bdSJohn Garry 	int max_command_entries;
2176be6de18SJohn Garry 	int complete_hdr_size;
2187eb7869fSJohn Garry };
2197eb7869fSJohn Garry 
2207eb7869fSJohn Garry struct hisi_hba {
2217eb7869fSJohn Garry 	/* This must be the first element, used by SHOST_TO_SAS_HA */
2227eb7869fSJohn Garry 	struct sas_ha_struct *p;
2237eb7869fSJohn Garry 
22411b75249SJohn Garry 	struct platform_device *platform_dev;
22511b75249SJohn Garry 	struct pci_dev *pci_dev;
22611b75249SJohn Garry 	struct device *dev;
22711b75249SJohn Garry 
228e26b2f40SJohn Garry 	void __iomem *regs;
229e26b2f40SJohn Garry 	struct regmap *ctrl;
230e26b2f40SJohn Garry 	u32 ctrl_reset_reg;
231e26b2f40SJohn Garry 	u32 ctrl_reset_sts_reg;
232e26b2f40SJohn Garry 	u32 ctrl_clock_ena_reg;
2333bc45af8SJohn Garry 	u32 refclk_frequency_mhz;
2347eb7869fSJohn Garry 	u8 sas_addr[SAS_ADDR_SIZE];
2357eb7869fSJohn Garry 
2367eb7869fSJohn Garry 	int n_phy;
237fa42d80dSJohn Garry 	spinlock_t lock;
2387eb7869fSJohn Garry 
239fa42d80dSJohn Garry 	struct timer_list timer;
2407e9080e1SJohn Garry 	struct workqueue_struct *wq;
241257efd1fSJohn Garry 
242257efd1fSJohn Garry 	int slot_index_count;
243257efd1fSJohn Garry 	unsigned long *slot_index_tags;
244c7b9d369SXiaofei Tan 	unsigned long reject_stp_links_msk;
245257efd1fSJohn Garry 
2467eb7869fSJohn Garry 	/* SCSI/SAS glue */
2477eb7869fSJohn Garry 	struct sas_ha_struct sha;
2487eb7869fSJohn Garry 	struct Scsi_Host *shost;
2499101a079SJohn Garry 
2509101a079SJohn Garry 	struct hisi_sas_cq cq[HISI_SAS_MAX_QUEUES];
2514fde02adSJohn Garry 	struct hisi_sas_dq dq[HISI_SAS_MAX_QUEUES];
2527eb7869fSJohn Garry 	struct hisi_sas_phy phy[HISI_SAS_MAX_PHYS];
2537eb7869fSJohn Garry 	struct hisi_sas_port port[HISI_SAS_MAX_PHYS];
254e26b2f40SJohn Garry 
255e26b2f40SJohn Garry 	int	queue_count;
2566be6de18SJohn Garry 
257f557e32cSXiaofei Tan 	struct dma_pool *buffer_pool;
258af740dbeSJohn Garry 	struct hisi_sas_device	devices[HISI_SAS_MAX_DEVICES];
2596be6de18SJohn Garry 	struct hisi_sas_cmd_hdr	*cmd_hdr[HISI_SAS_MAX_QUEUES];
2606be6de18SJohn Garry 	dma_addr_t cmd_hdr_dma[HISI_SAS_MAX_QUEUES];
2616be6de18SJohn Garry 	void *complete_hdr[HISI_SAS_MAX_QUEUES];
2626be6de18SJohn Garry 	dma_addr_t complete_hdr_dma[HISI_SAS_MAX_QUEUES];
2636be6de18SJohn Garry 	struct hisi_sas_initial_fis *initial_fis;
2646be6de18SJohn Garry 	dma_addr_t initial_fis_dma;
2656be6de18SJohn Garry 	struct hisi_sas_itct *itct;
2666be6de18SJohn Garry 	dma_addr_t itct_dma;
2676be6de18SJohn Garry 	struct hisi_sas_iost *iost;
2686be6de18SJohn Garry 	dma_addr_t iost_dma;
2696be6de18SJohn Garry 	struct hisi_sas_breakpoint *breakpoint;
2706be6de18SJohn Garry 	dma_addr_t breakpoint_dma;
2716be6de18SJohn Garry 	struct hisi_sas_breakpoint *sata_breakpoint;
2726be6de18SJohn Garry 	dma_addr_t sata_breakpoint_dma;
2736be6de18SJohn Garry 	struct hisi_sas_slot	*slot_info;
27406ec0fb9SXiang Chen 	unsigned long flags;
2757eb7869fSJohn Garry 	const struct hisi_sas_hw *hw;	/* Low level hw interface */
27632ccba52SXiaofei Tan 	unsigned long sata_dev_bitmap[BITS_TO_LONGS(HISI_SAS_MAX_DEVICES)];
27706ec0fb9SXiang Chen 	struct work_struct rst_work;
2787eb7869fSJohn Garry };
2797eb7869fSJohn Garry 
280c799d6bdSJohn Garry /* Generic HW DMA host memory structures */
281c799d6bdSJohn Garry /* Delivery queue header */
282c799d6bdSJohn Garry struct hisi_sas_cmd_hdr {
283c799d6bdSJohn Garry 	/* dw0 */
284c799d6bdSJohn Garry 	__le32 dw0;
285c799d6bdSJohn Garry 
286c799d6bdSJohn Garry 	/* dw1 */
287c799d6bdSJohn Garry 	__le32 dw1;
288c799d6bdSJohn Garry 
289c799d6bdSJohn Garry 	/* dw2 */
290c799d6bdSJohn Garry 	__le32 dw2;
291c799d6bdSJohn Garry 
292c799d6bdSJohn Garry 	/* dw3 */
293c799d6bdSJohn Garry 	__le32 transfer_tags;
294c799d6bdSJohn Garry 
295c799d6bdSJohn Garry 	/* dw4 */
296c799d6bdSJohn Garry 	__le32 data_transfer_len;
297c799d6bdSJohn Garry 
298c799d6bdSJohn Garry 	/* dw5 */
299c799d6bdSJohn Garry 	__le32 first_burst_num;
300c799d6bdSJohn Garry 
301c799d6bdSJohn Garry 	/* dw6 */
302c799d6bdSJohn Garry 	__le32 sg_len;
303c799d6bdSJohn Garry 
304c799d6bdSJohn Garry 	/* dw7 */
305c799d6bdSJohn Garry 	__le32 dw7;
306c799d6bdSJohn Garry 
307c799d6bdSJohn Garry 	/* dw8-9 */
308c799d6bdSJohn Garry 	__le64 cmd_table_addr;
309c799d6bdSJohn Garry 
310c799d6bdSJohn Garry 	/* dw10-11 */
311c799d6bdSJohn Garry 	__le64 sts_buffer_addr;
312c799d6bdSJohn Garry 
313c799d6bdSJohn Garry 	/* dw12-13 */
314c799d6bdSJohn Garry 	__le64 prd_table_addr;
315c799d6bdSJohn Garry 
316c799d6bdSJohn Garry 	/* dw14-15 */
317c799d6bdSJohn Garry 	__le64 dif_prd_table_addr;
318c799d6bdSJohn Garry };
319c799d6bdSJohn Garry 
320c799d6bdSJohn Garry struct hisi_sas_itct {
321c799d6bdSJohn Garry 	__le64 qw0;
322c799d6bdSJohn Garry 	__le64 sas_addr;
323c799d6bdSJohn Garry 	__le64 qw2;
324c799d6bdSJohn Garry 	__le64 qw3;
325281e3bf6SJohn Garry 	__le64 qw4_15[12];
326c799d6bdSJohn Garry };
327c799d6bdSJohn Garry 
328c799d6bdSJohn Garry struct hisi_sas_iost {
329c799d6bdSJohn Garry 	__le64 qw0;
330c799d6bdSJohn Garry 	__le64 qw1;
331c799d6bdSJohn Garry 	__le64 qw2;
332c799d6bdSJohn Garry 	__le64 qw3;
333c799d6bdSJohn Garry };
334c799d6bdSJohn Garry 
335c799d6bdSJohn Garry struct hisi_sas_err_record {
3368d1eee7dSJohn Garry 	u32	data[4];
337c799d6bdSJohn Garry };
338c799d6bdSJohn Garry 
339c799d6bdSJohn Garry struct hisi_sas_initial_fis {
340c799d6bdSJohn Garry 	struct hisi_sas_err_record err_record;
341c799d6bdSJohn Garry 	struct dev_to_host_fis fis;
342c799d6bdSJohn Garry 	u32 rsvd[3];
343c799d6bdSJohn Garry };
344c799d6bdSJohn Garry 
345c799d6bdSJohn Garry struct hisi_sas_breakpoint {
3463297ded1SXiang Chen 	u8	data[128];
3473297ded1SXiang Chen };
3483297ded1SXiang Chen 
3493297ded1SXiang Chen struct hisi_sas_sata_breakpoint {
3503297ded1SXiang Chen 	struct hisi_sas_breakpoint tag[32];
351c799d6bdSJohn Garry };
352c799d6bdSJohn Garry 
353c799d6bdSJohn Garry struct hisi_sas_sge {
354c799d6bdSJohn Garry 	__le64 addr;
355c799d6bdSJohn Garry 	__le32 page_ctrl_0;
356c799d6bdSJohn Garry 	__le32 page_ctrl_1;
357c799d6bdSJohn Garry 	__le32 data_len;
358c799d6bdSJohn Garry 	__le32 data_off;
359c799d6bdSJohn Garry };
360c799d6bdSJohn Garry 
361c799d6bdSJohn Garry struct hisi_sas_command_table_smp {
362c799d6bdSJohn Garry 	u8 bytes[44];
363c799d6bdSJohn Garry };
364c799d6bdSJohn Garry 
365c799d6bdSJohn Garry struct hisi_sas_command_table_stp {
366c799d6bdSJohn Garry 	struct	host_to_dev_fis command_fis;
367c799d6bdSJohn Garry 	u8	dummy[12];
368c799d6bdSJohn Garry 	u8	atapi_cdb[ATAPI_CDB_LEN];
369c799d6bdSJohn Garry };
370c799d6bdSJohn Garry 
37165e8617fSMing Lin #define HISI_SAS_SGE_PAGE_CNT SG_CHUNK_SIZE
372c799d6bdSJohn Garry struct hisi_sas_sge_page {
373c799d6bdSJohn Garry 	struct hisi_sas_sge sge[HISI_SAS_SGE_PAGE_CNT];
374f557e32cSXiaofei Tan }  __aligned(16);
375c799d6bdSJohn Garry 
376c799d6bdSJohn Garry struct hisi_sas_command_table_ssp {
377c799d6bdSJohn Garry 	struct ssp_frame_hdr hdr;
378c799d6bdSJohn Garry 	union {
379c799d6bdSJohn Garry 		struct {
380c799d6bdSJohn Garry 			struct ssp_command_iu task;
381c799d6bdSJohn Garry 			u32 prot[6];
382c799d6bdSJohn Garry 		};
383c799d6bdSJohn Garry 		struct ssp_tmf_iu ssp_task;
384c799d6bdSJohn Garry 		struct xfer_rdy_iu xfer_rdy;
385c799d6bdSJohn Garry 		struct ssp_response_iu ssp_res;
386c799d6bdSJohn Garry 	} u;
387c799d6bdSJohn Garry };
388c799d6bdSJohn Garry 
389c799d6bdSJohn Garry union hisi_sas_command_table {
390c799d6bdSJohn Garry 	struct hisi_sas_command_table_ssp ssp;
391c799d6bdSJohn Garry 	struct hisi_sas_command_table_smp smp;
392c799d6bdSJohn Garry 	struct hisi_sas_command_table_stp stp;
393f557e32cSXiaofei Tan }  __aligned(16);
394f557e32cSXiaofei Tan 
395f557e32cSXiaofei Tan struct hisi_sas_status_buffer {
396f557e32cSXiaofei Tan 	struct hisi_sas_err_record err;
397f557e32cSXiaofei Tan 	u8	iu[1024];
398f557e32cSXiaofei Tan }  __aligned(16);
399f557e32cSXiaofei Tan 
400f557e32cSXiaofei Tan struct hisi_sas_slot_buf_table {
401f557e32cSXiaofei Tan 	struct hisi_sas_status_buffer status_buffer;
402f557e32cSXiaofei Tan 	union hisi_sas_command_table command_header;
403f557e32cSXiaofei Tan 	struct hisi_sas_sge_page sge_page;
404c799d6bdSJohn Garry };
4052e244f0fSJohn Garry 
406e21fe3a5SJohn Garry extern struct scsi_transport_template *hisi_sas_stt;
407e21fe3a5SJohn Garry extern struct scsi_host_template *hisi_sas_sht;
408e21fe3a5SJohn Garry 
409a25d0d3dSXiang Chen extern void hisi_sas_stop_phys(struct hisi_hba *hisi_hba);
410e21fe3a5SJohn Garry extern void hisi_sas_init_add(struct hisi_hba *hisi_hba);
411e21fe3a5SJohn Garry extern int hisi_sas_alloc(struct hisi_hba *hisi_hba, struct Scsi_Host *shost);
412e21fe3a5SJohn Garry extern void hisi_sas_free(struct hisi_hba *hisi_hba);
4136c7bb8a1SXiang Chen extern u8 hisi_sas_get_ata_protocol(u8 cmd, int direction);
4142e244f0fSJohn Garry extern struct hisi_sas_port *to_hisi_sas_port(struct asd_sas_port *sas_port);
41575904077SXiang Chen extern void hisi_sas_sata_done(struct sas_task *task,
41675904077SXiang Chen 			    struct hisi_sas_slot *slot);
417318913c6SXiang Chen extern int hisi_sas_get_ncq_tag(struct sas_task *task, u32 *tag);
4180fa24c19SJohn Garry extern int hisi_sas_get_fw_info(struct hisi_hba *hisi_hba);
4199fb10b54SJohn Garry extern int hisi_sas_probe(struct platform_device *pdev,
4209fb10b54SJohn Garry 			  const struct hisi_sas_hw *ops);
4219fb10b54SJohn Garry extern int hisi_sas_remove(struct platform_device *pdev);
422c799d6bdSJohn Garry 
423184a4635SJohn Garry extern void hisi_sas_phy_down(struct hisi_hba *hisi_hba, int phy_no, int rdy);
42427a3f229SJohn Garry extern void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba,
42527a3f229SJohn Garry 				    struct sas_task *task,
42627a3f229SJohn Garry 				    struct hisi_sas_slot *slot);
42706ec0fb9SXiang Chen extern void hisi_sas_init_mem(struct hisi_hba *hisi_hba);
428b4241f0fSXiaofei Tan extern void hisi_sas_rst_work_handler(struct work_struct *work);
429571295f8SXiaofei Tan extern void hisi_sas_kill_tasklets(struct hisi_hba *hisi_hba);
430e8899fadSJohn Garry #endif
431