xref: /openbmc/linux/drivers/scsi/aic94xx/aic94xx_hwi.h (revision 3f048109d9c4f8bb028ccb0d256ab65eb44f5988)
12908d778SJames Bottomley /*
22908d778SJames Bottomley  * Aic94xx SAS/SATA driver hardware interface header file.
32908d778SJames Bottomley  *
42908d778SJames Bottomley  * Copyright (C) 2005 Adaptec, Inc.  All rights reserved.
52908d778SJames Bottomley  * Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
62908d778SJames Bottomley  *
72908d778SJames Bottomley  * This file is licensed under GPLv2.
82908d778SJames Bottomley  *
92908d778SJames Bottomley  * This file is part of the aic94xx driver.
102908d778SJames Bottomley  *
112908d778SJames Bottomley  * The aic94xx driver is free software; you can redistribute it and/or
122908d778SJames Bottomley  * modify it under the terms of the GNU General Public License as
132908d778SJames Bottomley  * published by the Free Software Foundation; version 2 of the
142908d778SJames Bottomley  * License.
152908d778SJames Bottomley  *
162908d778SJames Bottomley  * The aic94xx driver is distributed in the hope that it will be useful,
172908d778SJames Bottomley  * but WITHOUT ANY WARRANTY; without even the implied warranty of
182908d778SJames Bottomley  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
192908d778SJames Bottomley  * General Public License for more details.
202908d778SJames Bottomley  *
212908d778SJames Bottomley  * You should have received a copy of the GNU General Public License
222908d778SJames Bottomley  * along with the aic94xx driver; if not, write to the Free Software
232908d778SJames Bottomley  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
242908d778SJames Bottomley  *
252908d778SJames Bottomley  */
262908d778SJames Bottomley 
272908d778SJames Bottomley #ifndef _AIC94XX_HWI_H_
282908d778SJames Bottomley #define _AIC94XX_HWI_H_
292908d778SJames Bottomley 
302908d778SJames Bottomley #include <linux/interrupt.h>
312908d778SJames Bottomley #include <linux/pci.h>
322908d778SJames Bottomley #include <linux/dma-mapping.h>
332908d778SJames Bottomley 
342908d778SJames Bottomley #include <scsi/libsas.h>
352908d778SJames Bottomley 
362908d778SJames Bottomley #include "aic94xx.h"
372908d778SJames Bottomley #include "aic94xx_sas.h"
382908d778SJames Bottomley 
392908d778SJames Bottomley /* Define ASD_MAX_PHYS to the maximum phys ever. Currently 8. */
402908d778SJames Bottomley #define ASD_MAX_PHYS       8
412908d778SJames Bottomley #define ASD_PCBA_SN_SIZE   12
422908d778SJames Bottomley 
432908d778SJames Bottomley /* Those are to be further named properly, the "RAZORx" part, and
442908d778SJames Bottomley  * subsequently included in include/linux/pci_ids.h.
452908d778SJames Bottomley  */
462908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR10 0x410
472908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR12 0x412
482908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR1E 0x41E
493fc2aef5SSergey Kononenko #define PCI_DEVICE_ID_ADAPTEC2_RAZOR1F 0x41F
502908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR30 0x430
512908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR32 0x432
522908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR3E 0x43E
532908d778SJames Bottomley #define PCI_DEVICE_ID_ADAPTEC2_RAZOR3F 0x43F
542908d778SJames Bottomley 
552908d778SJames Bottomley struct asd_ha_addrspace {
562908d778SJames Bottomley 	void __iomem  *addr;
572908d778SJames Bottomley 	unsigned long  start;       /* pci resource start */
582908d778SJames Bottomley 	unsigned long  len;         /* pci resource len */
592908d778SJames Bottomley 	unsigned long  flags;       /* pci resource flags */
602908d778SJames Bottomley 
612908d778SJames Bottomley 	/* addresses internal to the host adapter */
622908d778SJames Bottomley 	u32 swa_base; /* mmspace 1 (MBAR1) uses this only */
632908d778SJames Bottomley 	u32 swb_base;
642908d778SJames Bottomley 	u32 swc_base;
652908d778SJames Bottomley };
662908d778SJames Bottomley 
672908d778SJames Bottomley struct bios_struct {
682908d778SJames Bottomley 	int    present;
692908d778SJames Bottomley 	u8     maj;
702908d778SJames Bottomley 	u8     min;
712908d778SJames Bottomley 	u32    bld;
722908d778SJames Bottomley };
732908d778SJames Bottomley 
742908d778SJames Bottomley struct unit_element_struct {
752908d778SJames Bottomley 	u16    num;
762908d778SJames Bottomley 	u16    size;
772908d778SJames Bottomley 	void   *area;
782908d778SJames Bottomley };
792908d778SJames Bottomley 
802908d778SJames Bottomley struct flash_struct {
812908d778SJames Bottomley 	u32    bar;
822908d778SJames Bottomley 	int    present;
832908d778SJames Bottomley 	int    wide;
842908d778SJames Bottomley 	u8     manuf;
852908d778SJames Bottomley 	u8     dev_id;
862908d778SJames Bottomley 	u8     sec_prot;
872908d778SJames Bottomley 
882908d778SJames Bottomley 	u32    dir_offs;
892908d778SJames Bottomley };
902908d778SJames Bottomley 
912908d778SJames Bottomley struct asd_phy_desc {
922908d778SJames Bottomley 	/* From CTRL-A settings, then set to what is appropriate */
932908d778SJames Bottomley 	u8     sas_addr[SAS_ADDR_SIZE];
942908d778SJames Bottomley 	u8     max_sas_lrate;
952908d778SJames Bottomley 	u8     min_sas_lrate;
962908d778SJames Bottomley 	u8     max_sata_lrate;
972908d778SJames Bottomley 	u8     min_sata_lrate;
982908d778SJames Bottomley 	u8     flags;
992908d778SJames Bottomley #define ASD_CRC_DIS  1
1002908d778SJames Bottomley #define ASD_SATA_SPINUP_HOLD 2
1012908d778SJames Bottomley 
1022908d778SJames Bottomley 	u8     phy_control_0; /* mode 5 reg 0x160 */
1032908d778SJames Bottomley 	u8     phy_control_1; /* mode 5 reg 0x161 */
1042908d778SJames Bottomley 	u8     phy_control_2; /* mode 5 reg 0x162 */
1052908d778SJames Bottomley 	u8     phy_control_3; /* mode 5 reg 0x163 */
1062908d778SJames Bottomley };
1072908d778SJames Bottomley 
1082908d778SJames Bottomley struct asd_dma_tok {
1092908d778SJames Bottomley 	void *vaddr;
1102908d778SJames Bottomley 	dma_addr_t dma_handle;
1112908d778SJames Bottomley 	size_t size;
1122908d778SJames Bottomley };
1132908d778SJames Bottomley 
1142908d778SJames Bottomley struct hw_profile {
1152908d778SJames Bottomley 	struct bios_struct bios;
1162908d778SJames Bottomley 	struct unit_element_struct ue;
1172908d778SJames Bottomley 	struct flash_struct flash;
1182908d778SJames Bottomley 
1192908d778SJames Bottomley 	u8     sas_addr[SAS_ADDR_SIZE];
1202908d778SJames Bottomley 	char   pcba_sn[ASD_PCBA_SN_SIZE+1];
1212908d778SJames Bottomley 
1222908d778SJames Bottomley 	u8     enabled_phys;	  /* mask of enabled phys */
1232908d778SJames Bottomley 	struct asd_phy_desc phy_desc[ASD_MAX_PHYS];
1242908d778SJames Bottomley 	u32    max_scbs;	  /* absolute sequencer scb queue size */
1252908d778SJames Bottomley 	struct asd_dma_tok *scb_ext;
1262908d778SJames Bottomley 	u32    max_ddbs;
1272908d778SJames Bottomley 	struct asd_dma_tok *ddb_ext;
1282908d778SJames Bottomley 
1292908d778SJames Bottomley 	spinlock_t ddb_lock;
1302908d778SJames Bottomley 	void  *ddb_bitmap;
1312908d778SJames Bottomley 
1322908d778SJames Bottomley 	int    num_phys;	  /* ENABLEABLE */
1332908d778SJames Bottomley 	int    max_phys;	  /* REPORTED + ENABLEABLE */
1342908d778SJames Bottomley 
1352908d778SJames Bottomley 	unsigned addr_range;	  /* max # of addrs; max # of possible ports */
1362908d778SJames Bottomley 	unsigned port_name_base;
1372908d778SJames Bottomley 	unsigned dev_name_base;
1382908d778SJames Bottomley 	unsigned sata_name_base;
1392908d778SJames Bottomley };
1402908d778SJames Bottomley 
1412908d778SJames Bottomley struct asd_ascb {
1422908d778SJames Bottomley 	struct list_head list;
1432908d778SJames Bottomley 	struct asd_ha_struct *ha;
1442908d778SJames Bottomley 
1452908d778SJames Bottomley 	struct scb *scb;	  /* equals dma_scb->vaddr */
1462908d778SJames Bottomley 	struct asd_dma_tok dma_scb;
1472908d778SJames Bottomley 	struct asd_dma_tok *sg_arr;
1482908d778SJames Bottomley 
1492908d778SJames Bottomley 	void (*tasklet_complete)(struct asd_ascb *, struct done_list_struct *);
1502908d778SJames Bottomley 	u8     uldd_timer:1;
1512908d778SJames Bottomley 
1522908d778SJames Bottomley 	/* internally generated command */
1532908d778SJames Bottomley 	struct timer_list timer;
1542908d778SJames Bottomley 	struct completion completion;
1552908d778SJames Bottomley 	u8        tag_valid:1;
1562908d778SJames Bottomley 	__be16    tag;		  /* error recovery only */
1572908d778SJames Bottomley 
1582908d778SJames Bottomley 	/* If this is an Empty SCB, index of first edb in seq->edb_arr. */
1592908d778SJames Bottomley 	int    edb_index;
1602908d778SJames Bottomley 
1612908d778SJames Bottomley 	/* Used by the timer timeout function. */
1622908d778SJames Bottomley 	int    tc_index;
1632908d778SJames Bottomley 
1642908d778SJames Bottomley 	void   *uldd_task;
1652908d778SJames Bottomley };
1662908d778SJames Bottomley 
1672908d778SJames Bottomley #define ASD_DL_SIZE_BITS   0x8
1682908d778SJames Bottomley #define ASD_DL_SIZE        (1<<(2+ASD_DL_SIZE_BITS))
1692908d778SJames Bottomley #define ASD_DEF_DL_TOGGLE  0x01
1702908d778SJames Bottomley 
1712908d778SJames Bottomley struct asd_seq_data {
1722908d778SJames Bottomley 	spinlock_t pend_q_lock;
1732908d778SJames Bottomley 	u16    scbpro;
1742908d778SJames Bottomley 	int    pending;
1752908d778SJames Bottomley 	struct list_head pend_q;
1762908d778SJames Bottomley 	int    can_queue;	  /* per adapter */
1772908d778SJames Bottomley 	struct asd_dma_tok next_scb; /* next scb to be delivered to CSEQ */
1782908d778SJames Bottomley 
1792908d778SJames Bottomley 	spinlock_t tc_index_lock;
1802908d778SJames Bottomley 	void **tc_index_array;
1812908d778SJames Bottomley 	void *tc_index_bitmap;
1822908d778SJames Bottomley 	int   tc_index_bitmap_bits;
1832908d778SJames Bottomley 
1842908d778SJames Bottomley 	struct tasklet_struct dl_tasklet;
1852908d778SJames Bottomley 	struct done_list_struct *dl; /* array of done list entries, equals */
1862908d778SJames Bottomley 	struct asd_dma_tok *actual_dl; /* actual_dl->vaddr */
1872908d778SJames Bottomley 	int    dl_toggle;
1882908d778SJames Bottomley 	int    dl_next;
1892908d778SJames Bottomley 
1902908d778SJames Bottomley 	int    num_edbs;
1912908d778SJames Bottomley 	struct asd_dma_tok **edb_arr;
1922908d778SJames Bottomley 	int    num_escbs;
1932908d778SJames Bottomley 	struct asd_ascb **escb_arr; /* array of pointers to escbs */
1942908d778SJames Bottomley };
1952908d778SJames Bottomley 
196*3f048109Smalahal@us.ibm.com /* This is an internal port structure. These are used to get accurate
197*3f048109Smalahal@us.ibm.com  * phy_mask for updating DDB 0.
198*3f048109Smalahal@us.ibm.com  */
199*3f048109Smalahal@us.ibm.com struct asd_port {
200*3f048109Smalahal@us.ibm.com 	u8  sas_addr[SAS_ADDR_SIZE];
201*3f048109Smalahal@us.ibm.com 	u8  attached_sas_addr[SAS_ADDR_SIZE];
202*3f048109Smalahal@us.ibm.com 	u32 phy_mask;
203*3f048109Smalahal@us.ibm.com 	int num_phys;
204*3f048109Smalahal@us.ibm.com };
205*3f048109Smalahal@us.ibm.com 
2062908d778SJames Bottomley /* This is the Host Adapter structure.  It describes the hardware
2072908d778SJames Bottomley  * SAS adapter.
2082908d778SJames Bottomley  */
2092908d778SJames Bottomley struct asd_ha_struct {
2102908d778SJames Bottomley 	struct pci_dev   *pcidev;
2112908d778SJames Bottomley 	const char       *name;
2122908d778SJames Bottomley 
2132908d778SJames Bottomley 	struct sas_ha_struct sas_ha;
2142908d778SJames Bottomley 
2152908d778SJames Bottomley 	u8                revision_id;
2162908d778SJames Bottomley 
2172908d778SJames Bottomley 	int               iospace;
2182908d778SJames Bottomley 	spinlock_t        iolock;
2192908d778SJames Bottomley 	struct asd_ha_addrspace io_handle[2];
2202908d778SJames Bottomley 
2212908d778SJames Bottomley 	struct hw_profile hw_prof;
2222908d778SJames Bottomley 
2232908d778SJames Bottomley 	struct asd_phy    phys[ASD_MAX_PHYS];
224*3f048109Smalahal@us.ibm.com 	spinlock_t        asd_ports_lock;
225*3f048109Smalahal@us.ibm.com 	struct asd_port   asd_ports[ASD_MAX_PHYS];
2262908d778SJames Bottomley 	struct asd_sas_port   ports[ASD_MAX_PHYS];
2272908d778SJames Bottomley 
2282908d778SJames Bottomley 	struct dma_pool  *scb_pool;
2292908d778SJames Bottomley 
2302908d778SJames Bottomley 	struct asd_seq_data  seq; /* sequencer related */
2312908d778SJames Bottomley };
2322908d778SJames Bottomley 
2332908d778SJames Bottomley /* ---------- Common macros ---------- */
2342908d778SJames Bottomley 
2352908d778SJames Bottomley #define ASD_BUSADDR_LO(__dma_handle) ((u32)(__dma_handle))
2362908d778SJames Bottomley #define ASD_BUSADDR_HI(__dma_handle) (((sizeof(dma_addr_t))==8)     \
2372908d778SJames Bottomley                                     ? ((u32)((__dma_handle) >> 32)) \
2382908d778SJames Bottomley                                     : ((u32)0))
2392908d778SJames Bottomley 
2402908d778SJames Bottomley #define dev_to_asd_ha(__dev)  pci_get_drvdata(to_pci_dev(__dev))
2412908d778SJames Bottomley #define SCB_SITE_VALID(__site_no) (((__site_no) & 0xF0FF) != 0x00FF   \
2422908d778SJames Bottomley 				 && ((__site_no) & 0xF0FF) > 0x001F)
2432908d778SJames Bottomley /* For each bit set in __lseq_mask, set __lseq to equal the bit
2442908d778SJames Bottomley  * position of the set bit and execute the statement following.
2452908d778SJames Bottomley  * __mc is the temporary mask, used as a mask "counter".
2462908d778SJames Bottomley  */
2472908d778SJames Bottomley #define for_each_sequencer(__lseq_mask, __mc, __lseq)                        \
2482908d778SJames Bottomley 	for ((__mc)=(__lseq_mask),(__lseq)=0;(__mc)!=0;(__lseq++),(__mc)>>=1)\
2492908d778SJames Bottomley 		if (((__mc) & 1))
2502908d778SJames Bottomley #define for_each_phy(__lseq_mask, __mc, __lseq)                              \
2512908d778SJames Bottomley 	for ((__mc)=(__lseq_mask),(__lseq)=0;(__mc)!=0;(__lseq++),(__mc)>>=1)\
2522908d778SJames Bottomley 		if (((__mc) & 1))
2532908d778SJames Bottomley 
2542908d778SJames Bottomley #define PHY_ENABLED(_HA, _I) ((_HA)->hw_prof.enabled_phys & (1<<(_I)))
2552908d778SJames Bottomley 
2562908d778SJames Bottomley /* ---------- DMA allocs ---------- */
2572908d778SJames Bottomley 
2583cc27547SAl Viro static inline struct asd_dma_tok *asd_dmatok_alloc(gfp_t flags)
2592908d778SJames Bottomley {
2602908d778SJames Bottomley 	return kmem_cache_alloc(asd_dma_token_cache, flags);
2612908d778SJames Bottomley }
2622908d778SJames Bottomley 
2632908d778SJames Bottomley static inline void asd_dmatok_free(struct asd_dma_tok *token)
2642908d778SJames Bottomley {
2652908d778SJames Bottomley 	kmem_cache_free(asd_dma_token_cache, token);
2662908d778SJames Bottomley }
2672908d778SJames Bottomley 
2682908d778SJames Bottomley static inline struct asd_dma_tok *asd_alloc_coherent(struct asd_ha_struct *
2692908d778SJames Bottomley 						     asd_ha, size_t size,
2703cc27547SAl Viro 						     gfp_t flags)
2712908d778SJames Bottomley {
2722908d778SJames Bottomley 	struct asd_dma_tok *token = asd_dmatok_alloc(flags);
2732908d778SJames Bottomley 	if (token) {
2742908d778SJames Bottomley 		token->size = size;
2752908d778SJames Bottomley 		token->vaddr = dma_alloc_coherent(&asd_ha->pcidev->dev,
2762908d778SJames Bottomley 						  token->size,
2772908d778SJames Bottomley 						  &token->dma_handle,
2782908d778SJames Bottomley 						  flags);
2792908d778SJames Bottomley 		if (!token->vaddr) {
2802908d778SJames Bottomley 			asd_dmatok_free(token);
2812908d778SJames Bottomley 			token = NULL;
2822908d778SJames Bottomley 		}
2832908d778SJames Bottomley 	}
2842908d778SJames Bottomley 	return token;
2852908d778SJames Bottomley }
2862908d778SJames Bottomley 
2872908d778SJames Bottomley static inline void asd_free_coherent(struct asd_ha_struct *asd_ha,
2882908d778SJames Bottomley 				     struct asd_dma_tok *token)
2892908d778SJames Bottomley {
2902908d778SJames Bottomley 	if (token) {
2912908d778SJames Bottomley 		dma_free_coherent(&asd_ha->pcidev->dev, token->size,
2922908d778SJames Bottomley 				  token->vaddr, token->dma_handle);
2932908d778SJames Bottomley 		asd_dmatok_free(token);
2942908d778SJames Bottomley 	}
2952908d778SJames Bottomley }
2962908d778SJames Bottomley 
2972908d778SJames Bottomley static inline void asd_init_ascb(struct asd_ha_struct *asd_ha,
2982908d778SJames Bottomley 				 struct asd_ascb *ascb)
2992908d778SJames Bottomley {
3002908d778SJames Bottomley 	INIT_LIST_HEAD(&ascb->list);
3012908d778SJames Bottomley 	ascb->scb = ascb->dma_scb.vaddr;
3022908d778SJames Bottomley 	ascb->ha = asd_ha;
3032908d778SJames Bottomley 	ascb->timer.function = NULL;
3042908d778SJames Bottomley 	init_timer(&ascb->timer);
3052908d778SJames Bottomley 	ascb->tc_index = -1;
3062908d778SJames Bottomley 	init_completion(&ascb->completion);
3072908d778SJames Bottomley }
3082908d778SJames Bottomley 
3092908d778SJames Bottomley /* Must be called with the tc_index_lock held!
3102908d778SJames Bottomley  */
3112908d778SJames Bottomley static inline void asd_tc_index_release(struct asd_seq_data *seq, int index)
3122908d778SJames Bottomley {
3132908d778SJames Bottomley 	seq->tc_index_array[index] = NULL;
3142908d778SJames Bottomley 	clear_bit(index, seq->tc_index_bitmap);
3152908d778SJames Bottomley }
3162908d778SJames Bottomley 
3172908d778SJames Bottomley /* Must be called with the tc_index_lock held!
3182908d778SJames Bottomley  */
3192908d778SJames Bottomley static inline int asd_tc_index_get(struct asd_seq_data *seq, void *ptr)
3202908d778SJames Bottomley {
3212908d778SJames Bottomley 	int index;
3222908d778SJames Bottomley 
3232908d778SJames Bottomley 	index = find_first_zero_bit(seq->tc_index_bitmap,
3242908d778SJames Bottomley 				    seq->tc_index_bitmap_bits);
3252908d778SJames Bottomley 	if (index == seq->tc_index_bitmap_bits)
3262908d778SJames Bottomley 		return -1;
3272908d778SJames Bottomley 
3282908d778SJames Bottomley 	seq->tc_index_array[index] = ptr;
3292908d778SJames Bottomley 	set_bit(index, seq->tc_index_bitmap);
3302908d778SJames Bottomley 
3312908d778SJames Bottomley 	return index;
3322908d778SJames Bottomley }
3332908d778SJames Bottomley 
3342908d778SJames Bottomley /* Must be called with the tc_index_lock held!
3352908d778SJames Bottomley  */
3362908d778SJames Bottomley static inline void *asd_tc_index_find(struct asd_seq_data *seq, int index)
3372908d778SJames Bottomley {
3382908d778SJames Bottomley 	return seq->tc_index_array[index];
3392908d778SJames Bottomley }
3402908d778SJames Bottomley 
3412908d778SJames Bottomley /**
3422908d778SJames Bottomley  * asd_ascb_free -- free a single aSCB after is has completed
3432908d778SJames Bottomley  * @ascb: pointer to the aSCB of interest
3442908d778SJames Bottomley  *
3452908d778SJames Bottomley  * This frees an aSCB after it has been executed/completed by
3462908d778SJames Bottomley  * the sequencer.
3472908d778SJames Bottomley  */
3482908d778SJames Bottomley static inline void asd_ascb_free(struct asd_ascb *ascb)
3492908d778SJames Bottomley {
3502908d778SJames Bottomley 	if (ascb) {
3512908d778SJames Bottomley 		struct asd_ha_struct *asd_ha = ascb->ha;
3522908d778SJames Bottomley 		unsigned long flags;
3532908d778SJames Bottomley 
3542908d778SJames Bottomley 		BUG_ON(!list_empty(&ascb->list));
3552908d778SJames Bottomley 		spin_lock_irqsave(&ascb->ha->seq.tc_index_lock, flags);
3562908d778SJames Bottomley 		asd_tc_index_release(&ascb->ha->seq, ascb->tc_index);
3572908d778SJames Bottomley 		spin_unlock_irqrestore(&ascb->ha->seq.tc_index_lock, flags);
3582908d778SJames Bottomley 		dma_pool_free(asd_ha->scb_pool, ascb->dma_scb.vaddr,
3592908d778SJames Bottomley 			      ascb->dma_scb.dma_handle);
3602908d778SJames Bottomley 		kmem_cache_free(asd_ascb_cache, ascb);
3612908d778SJames Bottomley 	}
3622908d778SJames Bottomley }
3632908d778SJames Bottomley 
3642908d778SJames Bottomley /**
3652908d778SJames Bottomley  * asd_ascb_list_free -- free a list of ascbs
3662908d778SJames Bottomley  * @ascb_list: a list of ascbs
3672908d778SJames Bottomley  *
3682908d778SJames Bottomley  * This function will free a list of ascbs allocated by asd_ascb_alloc_list.
3692908d778SJames Bottomley  * It is used when say the scb queueing function returned QUEUE_FULL,
3702908d778SJames Bottomley  * and we do not need the ascbs any more.
3712908d778SJames Bottomley  */
3722908d778SJames Bottomley static inline void asd_ascb_free_list(struct asd_ascb *ascb_list)
3732908d778SJames Bottomley {
3742908d778SJames Bottomley 	LIST_HEAD(list);
3752908d778SJames Bottomley 	struct list_head *n, *pos;
3762908d778SJames Bottomley 
3772908d778SJames Bottomley 	__list_add(&list, ascb_list->list.prev, &ascb_list->list);
3782908d778SJames Bottomley 	list_for_each_safe(pos, n, &list) {
3792908d778SJames Bottomley 		list_del_init(pos);
3802908d778SJames Bottomley 		asd_ascb_free(list_entry(pos, struct asd_ascb, list));
3812908d778SJames Bottomley 	}
3822908d778SJames Bottomley }
3832908d778SJames Bottomley 
3842908d778SJames Bottomley /* ---------- Function declarations ---------- */
3852908d778SJames Bottomley 
3862908d778SJames Bottomley int  asd_init_hw(struct asd_ha_struct *asd_ha);
3877d12e780SDavid Howells irqreturn_t asd_hw_isr(int irq, void *dev_id);
3882908d778SJames Bottomley 
3892908d778SJames Bottomley 
3902908d778SJames Bottomley struct asd_ascb *asd_ascb_alloc_list(struct asd_ha_struct
3912908d778SJames Bottomley 				     *asd_ha, int *num,
3923cc27547SAl Viro 				     gfp_t gfp_mask);
3932908d778SJames Bottomley 
3942908d778SJames Bottomley int  asd_post_ascb_list(struct asd_ha_struct *asd_ha, struct asd_ascb *ascb,
3952908d778SJames Bottomley 			int num);
3962908d778SJames Bottomley int  asd_post_escb_list(struct asd_ha_struct *asd_ha, struct asd_ascb *ascb,
3972908d778SJames Bottomley 			int num);
3982908d778SJames Bottomley 
3992908d778SJames Bottomley int  asd_init_post_escbs(struct asd_ha_struct *asd_ha);
4002908d778SJames Bottomley void asd_build_control_phy(struct asd_ascb *ascb, int phy_id, u8 subfunc);
4012908d778SJames Bottomley void asd_control_led(struct asd_ha_struct *asd_ha, int phy_id, int op);
4022908d778SJames Bottomley void asd_turn_led(struct asd_ha_struct *asd_ha, int phy_id, int op);
4032908d778SJames Bottomley int  asd_enable_phys(struct asd_ha_struct *asd_ha, const u8 phy_mask);
4042908d778SJames Bottomley void asd_build_initiate_link_adm_task(struct asd_ascb *ascb, int phy_id,
4052908d778SJames Bottomley 				      u8 subfunc);
4062908d778SJames Bottomley 
4072908d778SJames Bottomley void asd_ascb_timedout(unsigned long data);
4082908d778SJames Bottomley int  asd_chip_hardrst(struct asd_ha_struct *asd_ha);
4092908d778SJames Bottomley 
4102908d778SJames Bottomley #endif
411