xref: /openbmc/linux/drivers/scsi/aic94xx/aic94xx_hwi.h (revision 2908d778ab3e244900c310974e1fc1c69066e450)
1*2908d778SJames Bottomley /*
2*2908d778SJames Bottomley  * Aic94xx SAS/SATA driver hardware interface header file.
3*2908d778SJames Bottomley  *
4*2908d778SJames Bottomley  * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
5*2908d778SJames Bottomley  * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
6*2908d778SJames Bottomley  *
7*2908d778SJames Bottomley  * This file is licensed under GPLv2.
8*2908d778SJames Bottomley  *
9*2908d778SJames Bottomley  * This file is part of the aic94xx driver.
10*2908d778SJames Bottomley  *
11*2908d778SJames Bottomley  * The aic94xx driver is free software; you can redistribute it and/or
12*2908d778SJames Bottomley  * modify it under the terms of the GNU General Public License as
13*2908d778SJames Bottomley  * published by the Free Software Foundation; version 2 of the
14*2908d778SJames Bottomley  * License.
15*2908d778SJames Bottomley  *
16*2908d778SJames Bottomley  * The aic94xx driver is distributed in the hope that it will be useful,
17*2908d778SJames Bottomley  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18*2908d778SJames Bottomley  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19*2908d778SJames Bottomley  * General Public License for more details.
20*2908d778SJames Bottomley  *
21*2908d778SJames Bottomley  * You should have received a copy of the GNU General Public License
22*2908d778SJames Bottomley  * along with the aic94xx driver; if not, write to the Free Software
23*2908d778SJames Bottomley  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24*2908d778SJames Bottomley  *
25*2908d778SJames Bottomley  */
26*2908d778SJames Bottomley 
27*2908d778SJames Bottomley #ifndef _AIC94XX_HWI_H_
28*2908d778SJames Bottomley #define _AIC94XX_HWI_H_
29*2908d778SJames Bottomley 
30*2908d778SJames Bottomley #include <linux/interrupt.h>
31*2908d778SJames Bottomley #include <linux/pci.h>
32*2908d778SJames Bottomley #include <linux/dma-mapping.h>
33*2908d778SJames Bottomley 
34*2908d778SJames Bottomley #include <scsi/libsas.h>
35*2908d778SJames Bottomley 
36*2908d778SJames Bottomley #include "aic94xx.h"
37*2908d778SJames Bottomley #include "aic94xx_sas.h"
38*2908d778SJames Bottomley 
39*2908d778SJames Bottomley /* Define ASD_MAX_PHYS to the maximum phys ever. Currently 8. */
40*2908d778SJames Bottomley #define ASD_MAX_PHYS       8
41*2908d778SJames Bottomley #define ASD_PCBA_SN_SIZE   12
42*2908d778SJames Bottomley 
43*2908d778SJames Bottomley /* Those are to be further named properly, the "RAZORx" part, and
44*2908d778SJames Bottomley  * subsequently included in include/linux/pci_ids.h.
45*2908d778SJames Bottomley  */
46*2908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR10 0x410
47*2908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR12 0x412
48*2908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR1E 0x41E
49*2908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR30 0x430
50*2908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR32 0x432
51*2908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR3E 0x43E
52*2908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR3F 0x43F
53*2908d778SJames Bottomley 
54*2908d778SJames Bottomley struct asd_ha_addrspace {
55*2908d778SJames Bottomley 	void __iomem  *addr;
56*2908d778SJames Bottomley 	unsigned long  start;       /* pci resource start */
57*2908d778SJames Bottomley 	unsigned long  len;         /* pci resource len */
58*2908d778SJames Bottomley 	unsigned long  flags;       /* pci resource flags */
59*2908d778SJames Bottomley 
60*2908d778SJames Bottomley 	/* addresses internal to the host adapter */
61*2908d778SJames Bottomley 	u32 swa_base; /* mmspace 1 (MBAR1) uses this only */
62*2908d778SJames Bottomley 	u32 swb_base;
63*2908d778SJames Bottomley 	u32 swc_base;
64*2908d778SJames Bottomley };
65*2908d778SJames Bottomley 
66*2908d778SJames Bottomley struct bios_struct {
67*2908d778SJames Bottomley 	int    present;
68*2908d778SJames Bottomley 	u8     maj;
69*2908d778SJames Bottomley 	u8     min;
70*2908d778SJames Bottomley 	u32    bld;
71*2908d778SJames Bottomley };
72*2908d778SJames Bottomley 
73*2908d778SJames Bottomley struct unit_element_struct {
74*2908d778SJames Bottomley 	u16    num;
75*2908d778SJames Bottomley 	u16    size;
76*2908d778SJames Bottomley 	void   *area;
77*2908d778SJames Bottomley };
78*2908d778SJames Bottomley 
79*2908d778SJames Bottomley struct flash_struct {
80*2908d778SJames Bottomley 	u32    bar;
81*2908d778SJames Bottomley 	int    present;
82*2908d778SJames Bottomley 	int    wide;
83*2908d778SJames Bottomley 	u8     manuf;
84*2908d778SJames Bottomley 	u8     dev_id;
85*2908d778SJames Bottomley 	u8     sec_prot;
86*2908d778SJames Bottomley 
87*2908d778SJames Bottomley 	u32    dir_offs;
88*2908d778SJames Bottomley };
89*2908d778SJames Bottomley 
90*2908d778SJames Bottomley struct asd_phy_desc {
91*2908d778SJames Bottomley 	/* From CTRL-A settings, then set to what is appropriate */
92*2908d778SJames Bottomley 	u8     sas_addr[SAS_ADDR_SIZE];
93*2908d778SJames Bottomley 	u8     max_sas_lrate;
94*2908d778SJames Bottomley 	u8     min_sas_lrate;
95*2908d778SJames Bottomley 	u8     max_sata_lrate;
96*2908d778SJames Bottomley 	u8     min_sata_lrate;
97*2908d778SJames Bottomley 	u8     flags;
98*2908d778SJames Bottomley #define ASD_CRC_DIS  1
99*2908d778SJames Bottomley #define ASD_SATA_SPINUP_HOLD 2
100*2908d778SJames Bottomley 
101*2908d778SJames Bottomley 	u8     phy_control_0; /* mode 5 reg 0x160 */
102*2908d778SJames Bottomley 	u8     phy_control_1; /* mode 5 reg 0x161 */
103*2908d778SJames Bottomley 	u8     phy_control_2; /* mode 5 reg 0x162 */
104*2908d778SJames Bottomley 	u8     phy_control_3; /* mode 5 reg 0x163 */
105*2908d778SJames Bottomley };
106*2908d778SJames Bottomley 
107*2908d778SJames Bottomley struct asd_dma_tok {
108*2908d778SJames Bottomley 	void *vaddr;
109*2908d778SJames Bottomley 	dma_addr_t dma_handle;
110*2908d778SJames Bottomley 	size_t size;
111*2908d778SJames Bottomley };
112*2908d778SJames Bottomley 
113*2908d778SJames Bottomley struct hw_profile {
114*2908d778SJames Bottomley 	struct bios_struct bios;
115*2908d778SJames Bottomley 	struct unit_element_struct ue;
116*2908d778SJames Bottomley 	struct flash_struct flash;
117*2908d778SJames Bottomley 
118*2908d778SJames Bottomley 	u8     sas_addr[SAS_ADDR_SIZE];
119*2908d778SJames Bottomley 	char   pcba_sn[ASD_PCBA_SN_SIZE+1];
120*2908d778SJames Bottomley 
121*2908d778SJames Bottomley 	u8     enabled_phys;	  /* mask of enabled phys */
122*2908d778SJames Bottomley 	struct asd_phy_desc phy_desc[ASD_MAX_PHYS];
123*2908d778SJames Bottomley 	u32    max_scbs;	  /* absolute sequencer scb queue size */
124*2908d778SJames Bottomley 	struct asd_dma_tok *scb_ext;
125*2908d778SJames Bottomley 	u32    max_ddbs;
126*2908d778SJames Bottomley 	struct asd_dma_tok *ddb_ext;
127*2908d778SJames Bottomley 
128*2908d778SJames Bottomley 	spinlock_t ddb_lock;
129*2908d778SJames Bottomley 	void  *ddb_bitmap;
130*2908d778SJames Bottomley 
131*2908d778SJames Bottomley 	int    num_phys;	  /* ENABLEABLE */
132*2908d778SJames Bottomley 	int    max_phys;	  /* REPORTED + ENABLEABLE */
133*2908d778SJames Bottomley 
134*2908d778SJames Bottomley 	unsigned addr_range;	  /* max # of addrs; max # of possible ports */
135*2908d778SJames Bottomley 	unsigned port_name_base;
136*2908d778SJames Bottomley 	unsigned dev_name_base;
137*2908d778SJames Bottomley 	unsigned sata_name_base;
138*2908d778SJames Bottomley };
139*2908d778SJames Bottomley 
140*2908d778SJames Bottomley struct asd_ascb {
141*2908d778SJames Bottomley 	struct list_head list;
142*2908d778SJames Bottomley 	struct asd_ha_struct *ha;
143*2908d778SJames Bottomley 
144*2908d778SJames Bottomley 	struct scb *scb;	  /* equals dma_scb->vaddr */
145*2908d778SJames Bottomley 	struct asd_dma_tok dma_scb;
146*2908d778SJames Bottomley 	struct asd_dma_tok *sg_arr;
147*2908d778SJames Bottomley 
148*2908d778SJames Bottomley 	void (*tasklet_complete)(struct asd_ascb *, struct done_list_struct *);
149*2908d778SJames Bottomley 	u8     uldd_timer:1;
150*2908d778SJames Bottomley 
151*2908d778SJames Bottomley 	/* internally generated command */
152*2908d778SJames Bottomley 	struct timer_list timer;
153*2908d778SJames Bottomley 	struct completion completion;
154*2908d778SJames Bottomley 	u8        tag_valid:1;
155*2908d778SJames Bottomley 	__be16    tag;		  /* error recovery only */
156*2908d778SJames Bottomley 
157*2908d778SJames Bottomley 	/* If this is an Empty SCB, index of first edb in seq->edb_arr. */
158*2908d778SJames Bottomley 	int    edb_index;
159*2908d778SJames Bottomley 
160*2908d778SJames Bottomley 	/* Used by the timer timeout function. */
161*2908d778SJames Bottomley 	int    tc_index;
162*2908d778SJames Bottomley 
163*2908d778SJames Bottomley 	void   *uldd_task;
164*2908d778SJames Bottomley };
165*2908d778SJames Bottomley 
166*2908d778SJames Bottomley #define ASD_DL_SIZE_BITS   0x8
167*2908d778SJames Bottomley #define ASD_DL_SIZE        (1<<(2+ASD_DL_SIZE_BITS))
168*2908d778SJames Bottomley #define ASD_DEF_DL_TOGGLE  0x01
169*2908d778SJames Bottomley 
170*2908d778SJames Bottomley struct asd_seq_data {
171*2908d778SJames Bottomley 	spinlock_t pend_q_lock;
172*2908d778SJames Bottomley 	u16    scbpro;
173*2908d778SJames Bottomley 	int    pending;
174*2908d778SJames Bottomley 	struct list_head pend_q;
175*2908d778SJames Bottomley 	int    can_queue;	  /* per adapter */
176*2908d778SJames Bottomley 	struct asd_dma_tok next_scb; /* next scb to be delivered to CSEQ */
177*2908d778SJames Bottomley 
178*2908d778SJames Bottomley 	spinlock_t tc_index_lock;
179*2908d778SJames Bottomley 	void **tc_index_array;
180*2908d778SJames Bottomley 	void *tc_index_bitmap;
181*2908d778SJames Bottomley 	int   tc_index_bitmap_bits;
182*2908d778SJames Bottomley 
183*2908d778SJames Bottomley 	struct tasklet_struct dl_tasklet;
184*2908d778SJames Bottomley 	struct done_list_struct *dl; /* array of done list entries, equals */
185*2908d778SJames Bottomley 	struct asd_dma_tok *actual_dl; /* actual_dl->vaddr */
186*2908d778SJames Bottomley 	int    dl_toggle;
187*2908d778SJames Bottomley 	int    dl_next;
188*2908d778SJames Bottomley 
189*2908d778SJames Bottomley 	int    num_edbs;
190*2908d778SJames Bottomley 	struct asd_dma_tok **edb_arr;
191*2908d778SJames Bottomley 	int    num_escbs;
192*2908d778SJames Bottomley 	struct asd_ascb **escb_arr; /* array of pointers to escbs */
193*2908d778SJames Bottomley };
194*2908d778SJames Bottomley 
195*2908d778SJames Bottomley /* This is the Host Adapter structure.  It describes the hardware
196*2908d778SJames Bottomley  * SAS adapter.
197*2908d778SJames Bottomley  */
198*2908d778SJames Bottomley struct asd_ha_struct {
199*2908d778SJames Bottomley 	struct pci_dev   *pcidev;
200*2908d778SJames Bottomley 	const char       *name;
201*2908d778SJames Bottomley 
202*2908d778SJames Bottomley 	struct sas_ha_struct sas_ha;
203*2908d778SJames Bottomley 
204*2908d778SJames Bottomley 	u8                revision_id;
205*2908d778SJames Bottomley 
206*2908d778SJames Bottomley 	int               iospace;
207*2908d778SJames Bottomley 	spinlock_t        iolock;
208*2908d778SJames Bottomley 	struct asd_ha_addrspace io_handle[2];
209*2908d778SJames Bottomley 
210*2908d778SJames Bottomley 	struct hw_profile hw_prof;
211*2908d778SJames Bottomley 
212*2908d778SJames Bottomley 	struct asd_phy    phys[ASD_MAX_PHYS];
213*2908d778SJames Bottomley 	struct asd_sas_port   ports[ASD_MAX_PHYS];
214*2908d778SJames Bottomley 
215*2908d778SJames Bottomley 	struct dma_pool  *scb_pool;
216*2908d778SJames Bottomley 
217*2908d778SJames Bottomley 	struct asd_seq_data  seq; /* sequencer related */
218*2908d778SJames Bottomley };
219*2908d778SJames Bottomley 
220*2908d778SJames Bottomley /* ---------- Common macros ---------- */
221*2908d778SJames Bottomley 
222*2908d778SJames Bottomley #define ASD_BUSADDR_LO(__dma_handle) ((u32)(__dma_handle))
223*2908d778SJames Bottomley #define ASD_BUSADDR_HI(__dma_handle) (((sizeof(dma_addr_t))==8)     \
224*2908d778SJames Bottomley                                     ? ((u32)((__dma_handle) >> 32)) \
225*2908d778SJames Bottomley                                     : ((u32)0))
226*2908d778SJames Bottomley 
227*2908d778SJames Bottomley #define dev_to_asd_ha(__dev)  pci_get_drvdata(to_pci_dev(__dev))
228*2908d778SJames Bottomley #define SCB_SITE_VALID(__site_no) (((__site_no) & 0xF0FF) != 0x00FF   \
229*2908d778SJames Bottomley 				 && ((__site_no) & 0xF0FF) > 0x001F)
230*2908d778SJames Bottomley /* For each bit set in __lseq_mask, set __lseq to equal the bit
231*2908d778SJames Bottomley  * position of the set bit and execute the statement following.
232*2908d778SJames Bottomley  * __mc is the temporary mask, used as a mask "counter".
233*2908d778SJames Bottomley  */
234*2908d778SJames Bottomley #define for_each_sequencer(__lseq_mask, __mc, __lseq)                        \
235*2908d778SJames Bottomley 	for ((__mc)=(__lseq_mask),(__lseq)=0;(__mc)!=0;(__lseq++),(__mc)>>=1)\
236*2908d778SJames Bottomley 		if (((__mc) & 1))
237*2908d778SJames Bottomley #define for_each_phy(__lseq_mask, __mc, __lseq)                              \
238*2908d778SJames Bottomley 	for ((__mc)=(__lseq_mask),(__lseq)=0;(__mc)!=0;(__lseq++),(__mc)>>=1)\
239*2908d778SJames Bottomley 		if (((__mc) & 1))
240*2908d778SJames Bottomley 
241*2908d778SJames Bottomley #define PHY_ENABLED(_HA, _I) ((_HA)->hw_prof.enabled_phys & (1<<(_I)))
242*2908d778SJames Bottomley 
243*2908d778SJames Bottomley /* ---------- DMA allocs ---------- */
244*2908d778SJames Bottomley 
245*2908d778SJames Bottomley static inline struct asd_dma_tok *asd_dmatok_alloc(unsigned int flags)
246*2908d778SJames Bottomley {
247*2908d778SJames Bottomley 	return kmem_cache_alloc(asd_dma_token_cache, flags);
248*2908d778SJames Bottomley }
249*2908d778SJames Bottomley 
250*2908d778SJames Bottomley static inline void asd_dmatok_free(struct asd_dma_tok *token)
251*2908d778SJames Bottomley {
252*2908d778SJames Bottomley 	kmem_cache_free(asd_dma_token_cache, token);
253*2908d778SJames Bottomley }
254*2908d778SJames Bottomley 
255*2908d778SJames Bottomley static inline struct asd_dma_tok *asd_alloc_coherent(struct asd_ha_struct *
256*2908d778SJames Bottomley 						     asd_ha, size_t size,
257*2908d778SJames Bottomley 						     unsigned int flags)
258*2908d778SJames Bottomley {
259*2908d778SJames Bottomley 	struct asd_dma_tok *token = asd_dmatok_alloc(flags);
260*2908d778SJames Bottomley 	if (token) {
261*2908d778SJames Bottomley 		token->size = size;
262*2908d778SJames Bottomley 		token->vaddr = dma_alloc_coherent(&asd_ha->pcidev->dev,
263*2908d778SJames Bottomley 						  token->size,
264*2908d778SJames Bottomley 						  &token->dma_handle,
265*2908d778SJames Bottomley 						  flags);
266*2908d778SJames Bottomley 		if (!token->vaddr) {
267*2908d778SJames Bottomley 			asd_dmatok_free(token);
268*2908d778SJames Bottomley 			token = NULL;
269*2908d778SJames Bottomley 		}
270*2908d778SJames Bottomley 	}
271*2908d778SJames Bottomley 	return token;
272*2908d778SJames Bottomley }
273*2908d778SJames Bottomley 
274*2908d778SJames Bottomley static inline void asd_free_coherent(struct asd_ha_struct *asd_ha,
275*2908d778SJames Bottomley 				     struct asd_dma_tok *token)
276*2908d778SJames Bottomley {
277*2908d778SJames Bottomley 	if (token) {
278*2908d778SJames Bottomley 		dma_free_coherent(&asd_ha->pcidev->dev, token->size,
279*2908d778SJames Bottomley 				  token->vaddr, token->dma_handle);
280*2908d778SJames Bottomley 		asd_dmatok_free(token);
281*2908d778SJames Bottomley 	}
282*2908d778SJames Bottomley }
283*2908d778SJames Bottomley 
284*2908d778SJames Bottomley static inline void asd_init_ascb(struct asd_ha_struct *asd_ha,
285*2908d778SJames Bottomley 				 struct asd_ascb *ascb)
286*2908d778SJames Bottomley {
287*2908d778SJames Bottomley 	INIT_LIST_HEAD(&ascb->list);
288*2908d778SJames Bottomley 	ascb->scb = ascb->dma_scb.vaddr;
289*2908d778SJames Bottomley 	ascb->ha = asd_ha;
290*2908d778SJames Bottomley 	ascb->timer.function = NULL;
291*2908d778SJames Bottomley 	init_timer(&ascb->timer);
292*2908d778SJames Bottomley 	ascb->tc_index = -1;
293*2908d778SJames Bottomley 	init_completion(&ascb->completion);
294*2908d778SJames Bottomley }
295*2908d778SJames Bottomley 
296*2908d778SJames Bottomley /* Must be called with the tc_index_lock held!
297*2908d778SJames Bottomley  */
298*2908d778SJames Bottomley static inline void asd_tc_index_release(struct asd_seq_data *seq, int index)
299*2908d778SJames Bottomley {
300*2908d778SJames Bottomley 	seq->tc_index_array[index] = NULL;
301*2908d778SJames Bottomley 	clear_bit(index, seq->tc_index_bitmap);
302*2908d778SJames Bottomley }
303*2908d778SJames Bottomley 
304*2908d778SJames Bottomley /* Must be called with the tc_index_lock held!
305*2908d778SJames Bottomley  */
306*2908d778SJames Bottomley static inline int asd_tc_index_get(struct asd_seq_data *seq, void *ptr)
307*2908d778SJames Bottomley {
308*2908d778SJames Bottomley 	int index;
309*2908d778SJames Bottomley 
310*2908d778SJames Bottomley 	index = find_first_zero_bit(seq->tc_index_bitmap,
311*2908d778SJames Bottomley 				    seq->tc_index_bitmap_bits);
312*2908d778SJames Bottomley 	if (index == seq->tc_index_bitmap_bits)
313*2908d778SJames Bottomley 		return -1;
314*2908d778SJames Bottomley 
315*2908d778SJames Bottomley 	seq->tc_index_array[index] = ptr;
316*2908d778SJames Bottomley 	set_bit(index, seq->tc_index_bitmap);
317*2908d778SJames Bottomley 
318*2908d778SJames Bottomley 	return index;
319*2908d778SJames Bottomley }
320*2908d778SJames Bottomley 
321*2908d778SJames Bottomley /* Must be called with the tc_index_lock held!
322*2908d778SJames Bottomley  */
323*2908d778SJames Bottomley static inline void *asd_tc_index_find(struct asd_seq_data *seq, int index)
324*2908d778SJames Bottomley {
325*2908d778SJames Bottomley 	return seq->tc_index_array[index];
326*2908d778SJames Bottomley }
327*2908d778SJames Bottomley 
328*2908d778SJames Bottomley /**
329*2908d778SJames Bottomley  * asd_ascb_free -- free a single aSCB after is has completed
330*2908d778SJames Bottomley  * @ascb: pointer to the aSCB of interest
331*2908d778SJames Bottomley  *
332*2908d778SJames Bottomley  * This frees an aSCB after it has been executed/completed by
333*2908d778SJames Bottomley  * the sequencer.
334*2908d778SJames Bottomley  */
335*2908d778SJames Bottomley static inline void asd_ascb_free(struct asd_ascb *ascb)
336*2908d778SJames Bottomley {
337*2908d778SJames Bottomley 	if (ascb) {
338*2908d778SJames Bottomley 		struct asd_ha_struct *asd_ha = ascb->ha;
339*2908d778SJames Bottomley 		unsigned long flags;
340*2908d778SJames Bottomley 
341*2908d778SJames Bottomley 		BUG_ON(!list_empty(&ascb->list));
342*2908d778SJames Bottomley 		spin_lock_irqsave(&ascb->ha->seq.tc_index_lock, flags);
343*2908d778SJames Bottomley 		asd_tc_index_release(&ascb->ha->seq, ascb->tc_index);
344*2908d778SJames Bottomley 		spin_unlock_irqrestore(&ascb->ha->seq.tc_index_lock, flags);
345*2908d778SJames Bottomley 		dma_pool_free(asd_ha->scb_pool, ascb->dma_scb.vaddr,
346*2908d778SJames Bottomley 			      ascb->dma_scb.dma_handle);
347*2908d778SJames Bottomley 		kmem_cache_free(asd_ascb_cache, ascb);
348*2908d778SJames Bottomley 	}
349*2908d778SJames Bottomley }
350*2908d778SJames Bottomley 
351*2908d778SJames Bottomley /**
352*2908d778SJames Bottomley  * asd_ascb_list_free -- free a list of ascbs
353*2908d778SJames Bottomley  * @ascb_list: a list of ascbs
354*2908d778SJames Bottomley  *
355*2908d778SJames Bottomley  * This function will free a list of ascbs allocated by asd_ascb_alloc_list.
356*2908d778SJames Bottomley  * It is used when say the scb queueing function returned QUEUE_FULL,
357*2908d778SJames Bottomley  * and we do not need the ascbs any more.
358*2908d778SJames Bottomley  */
359*2908d778SJames Bottomley static inline void asd_ascb_free_list(struct asd_ascb *ascb_list)
360*2908d778SJames Bottomley {
361*2908d778SJames Bottomley 	LIST_HEAD(list);
362*2908d778SJames Bottomley 	struct list_head *n, *pos;
363*2908d778SJames Bottomley 
364*2908d778SJames Bottomley 	__list_add(&list, ascb_list->list.prev, &ascb_list->list);
365*2908d778SJames Bottomley 	list_for_each_safe(pos, n, &list) {
366*2908d778SJames Bottomley 		list_del_init(pos);
367*2908d778SJames Bottomley 		asd_ascb_free(list_entry(pos, struct asd_ascb, list));
368*2908d778SJames Bottomley 	}
369*2908d778SJames Bottomley }
370*2908d778SJames Bottomley 
371*2908d778SJames Bottomley /* ---------- Function declarations ---------- */
372*2908d778SJames Bottomley 
373*2908d778SJames Bottomley int  asd_init_hw(struct asd_ha_struct *asd_ha);
374*2908d778SJames Bottomley irqreturn_t asd_hw_isr(int irq, void *dev_id, struct pt_regs *regs);
375*2908d778SJames Bottomley 
376*2908d778SJames Bottomley 
377*2908d778SJames Bottomley struct asd_ascb *asd_ascb_alloc_list(struct asd_ha_struct
378*2908d778SJames Bottomley 				     *asd_ha, int *num,
379*2908d778SJames Bottomley 				     unsigned int gfp_mask);
380*2908d778SJames Bottomley 
381*2908d778SJames Bottomley int  asd_post_ascb_list(struct asd_ha_struct *asd_ha, struct asd_ascb *ascb,
382*2908d778SJames Bottomley 			int num);
383*2908d778SJames Bottomley int  asd_post_escb_list(struct asd_ha_struct *asd_ha, struct asd_ascb *ascb,
384*2908d778SJames Bottomley 			int num);
385*2908d778SJames Bottomley 
386*2908d778SJames Bottomley int  asd_init_post_escbs(struct asd_ha_struct *asd_ha);
387*2908d778SJames Bottomley void asd_build_control_phy(struct asd_ascb *ascb, int phy_id, u8 subfunc);
388*2908d778SJames Bottomley void asd_control_led(struct asd_ha_struct *asd_ha, int phy_id, int op);
389*2908d778SJames Bottomley void asd_turn_led(struct asd_ha_struct *asd_ha, int phy_id, int op);
390*2908d778SJames Bottomley int  asd_enable_phys(struct asd_ha_struct *asd_ha, const u8 phy_mask);
391*2908d778SJames Bottomley void asd_build_initiate_link_adm_task(struct asd_ascb *ascb, int phy_id,
392*2908d778SJames Bottomley 				      u8 subfunc);
393*2908d778SJames Bottomley 
394*2908d778SJames Bottomley void asd_ascb_timedout(unsigned long data);
395*2908d778SJames Bottomley int  asd_chip_hardrst(struct asd_ha_struct *asd_ha);
396*2908d778SJames Bottomley 
397*2908d778SJames Bottomley #endif
398