xref: /linux/drivers/scsi/megaraid/megaraid_mbox.h (revision 672b2d38da4fff4c4452685a25fb88b65243d1a6)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *
31da177e4SLinus Torvalds  *			Linux MegaRAID device driver
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Copyright (c) 2003-2004  LSI Logic Corporation.
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  *	   This program is free software; you can redistribute it and/or
81da177e4SLinus Torvalds  *	   modify it under the terms of the GNU General Public License
91da177e4SLinus Torvalds  *	   as published by the Free Software Foundation; either version
101da177e4SLinus Torvalds  *	   2 of the License, or (at your option) any later version.
111da177e4SLinus Torvalds  *
121da177e4SLinus Torvalds  * FILE		: megaraid_mbox.h
131da177e4SLinus Torvalds  */
141da177e4SLinus Torvalds 
151da177e4SLinus Torvalds #ifndef _MEGARAID_H_
161da177e4SLinus Torvalds #define _MEGARAID_H_
171da177e4SLinus Torvalds 
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds #include "mega_common.h"
201da177e4SLinus Torvalds #include "mbox_defs.h"
211da177e4SLinus Torvalds #include "megaraid_ioctl.h"
221da177e4SLinus Torvalds 
231da177e4SLinus Torvalds 
24*672b2d38SJu, Seokmann  #define MEGARAID_VERSION	"2.20.4.6"
25*672b2d38SJu, Seokmann  #define MEGARAID_EXT_VERSION	"(Release Date: Mon Mar 07 12:27:22 EST 2005)"
261da177e4SLinus Torvalds 
271da177e4SLinus Torvalds 
281da177e4SLinus Torvalds /*
291da177e4SLinus Torvalds  * Define some PCI values here until they are put in the kernel
301da177e4SLinus Torvalds  */
311da177e4SLinus Torvalds #define PCI_DEVICE_ID_PERC4_DI_DISCOVERY		0x000E
321da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC4_DI_DISCOVERY		0x0123
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds #define PCI_DEVICE_ID_PERC4_SC				0x1960
351da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC4_SC				0x0520
361da177e4SLinus Torvalds 
371da177e4SLinus Torvalds #define PCI_DEVICE_ID_PERC4_DC				0x1960
381da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC4_DC				0x0518
391da177e4SLinus Torvalds 
40*672b2d38SJu, Seokmann  #define PCI_DEVICE_ID_VERDE				0x0407
411da177e4SLinus Torvalds 
421da177e4SLinus Torvalds #define PCI_DEVICE_ID_PERC4_DI_EVERGLADES		0x000F
431da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC4_DI_EVERGLADES		0x014A
441da177e4SLinus Torvalds 
451da177e4SLinus Torvalds #define PCI_DEVICE_ID_PERC4E_SI_BIGBEND			0x0013
461da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC4E_SI_BIGBEND			0x016c
471da177e4SLinus Torvalds 
481da177e4SLinus Torvalds #define PCI_DEVICE_ID_PERC4E_DI_KOBUK			0x0013
491da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC4E_DI_KOBUK			0x016d
501da177e4SLinus Torvalds 
511da177e4SLinus Torvalds #define PCI_DEVICE_ID_PERC4E_DI_CORVETTE		0x0013
521da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC4E_DI_CORVETTE		0x016e
531da177e4SLinus Torvalds 
541da177e4SLinus Torvalds #define PCI_DEVICE_ID_PERC4E_DI_EXPEDITION		0x0013
551da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC4E_DI_EXPEDITION		0x016f
561da177e4SLinus Torvalds 
571da177e4SLinus Torvalds #define PCI_DEVICE_ID_PERC4E_DI_GUADALUPE		0x0013
581da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC4E_DI_GUADALUPE		0x0170
591da177e4SLinus Torvalds 
60*672b2d38SJu, Seokmann  #define PCI_DEVICE_ID_DOBSON				0x0408
611da177e4SLinus Torvalds 
621da177e4SLinus Torvalds #define PCI_DEVICE_ID_MEGARAID_SCSI_320_0		0x1960
631da177e4SLinus Torvalds #define PCI_SUBSYS_ID_MEGARAID_SCSI_320_0		0xA520
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds #define PCI_DEVICE_ID_MEGARAID_SCSI_320_1		0x1960
661da177e4SLinus Torvalds #define PCI_SUBSYS_ID_MEGARAID_SCSI_320_1		0x0520
671da177e4SLinus Torvalds 
681da177e4SLinus Torvalds #define PCI_DEVICE_ID_MEGARAID_SCSI_320_2		0x1960
691da177e4SLinus Torvalds #define PCI_SUBSYS_ID_MEGARAID_SCSI_320_2		0x0518
701da177e4SLinus Torvalds 
711da177e4SLinus Torvalds #define PCI_DEVICE_ID_MEGARAID_I4_133_RAID		0x1960
721da177e4SLinus Torvalds #define PCI_SUBSYS_ID_MEGARAID_I4_133_RAID		0x0522
731da177e4SLinus Torvalds 
741da177e4SLinus Torvalds #define PCI_DEVICE_ID_MEGARAID_SATA_150_4		0x1960
751da177e4SLinus Torvalds #define PCI_SUBSYS_ID_MEGARAID_SATA_150_4		0x4523
761da177e4SLinus Torvalds 
771da177e4SLinus Torvalds #define PCI_DEVICE_ID_MEGARAID_SATA_150_6		0x1960
781da177e4SLinus Torvalds #define PCI_SUBSYS_ID_MEGARAID_SATA_150_6		0x0523
791da177e4SLinus Torvalds 
80*672b2d38SJu, Seokmann  #define PCI_DEVICE_ID_LINDSAY				0x0409
811da177e4SLinus Torvalds 
821da177e4SLinus Torvalds #define PCI_DEVICE_ID_INTEL_RAID_SRCS16			0x1960
831da177e4SLinus Torvalds #define PCI_SUBSYS_ID_INTEL_RAID_SRCS16			0x0523
841da177e4SLinus Torvalds 
851da177e4SLinus Torvalds #define PCI_DEVICE_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK	0x1960
861da177e4SLinus Torvalds #define PCI_SUBSYS_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK	0x0520
871da177e4SLinus Torvalds 
881da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC3_QC				0x0471
891da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC3_DC				0x0493
901da177e4SLinus Torvalds #define PCI_SUBSYS_ID_PERC3_SC				0x0475
911da177e4SLinus Torvalds 
921da177e4SLinus Torvalds 
931da177e4SLinus Torvalds #define MBOX_MAX_SCSI_CMDS	128	// number of cmds reserved for kernel
941da177e4SLinus Torvalds #define MBOX_MAX_USER_CMDS	32	// number of cmds for applications
951da177e4SLinus Torvalds #define MBOX_DEF_CMD_PER_LUN	64	// default commands per lun
961da177e4SLinus Torvalds #define MBOX_DEFAULT_SG_SIZE	26	// default sg size supported by all fw
971da177e4SLinus Torvalds #define MBOX_MAX_SG_SIZE	32	// maximum scatter-gather list size
981da177e4SLinus Torvalds #define MBOX_MAX_SECTORS	128	// maximum sectors per IO
991da177e4SLinus Torvalds #define MBOX_TIMEOUT		30	// timeout value for internal cmds
1001da177e4SLinus Torvalds #define MBOX_BUSY_WAIT		10	// max usec to wait for busy mailbox
1011da177e4SLinus Torvalds #define MBOX_RESET_WAIT		180	// wait these many seconds in reset
1021da177e4SLinus Torvalds #define MBOX_RESET_EXT_WAIT	120	// extended wait reset
1031da177e4SLinus Torvalds 
1041da177e4SLinus Torvalds /*
1051da177e4SLinus Torvalds  * maximum transfer that can happen through the firmware commands issued
1061da177e4SLinus Torvalds  * internnaly from the driver.
1071da177e4SLinus Torvalds  */
1081da177e4SLinus Torvalds #define MBOX_IBUF_SIZE		4096
1091da177e4SLinus Torvalds 
1101da177e4SLinus Torvalds 
1111da177e4SLinus Torvalds /**
1121da177e4SLinus Torvalds  * mbox_ccb_t - command control block specific to mailbox based controllers
1131da177e4SLinus Torvalds  * @raw_mbox		: raw mailbox pointer
1141da177e4SLinus Torvalds  * @mbox		: mailbox
1151da177e4SLinus Torvalds  * @mbox64		: extended mailbox
1161da177e4SLinus Torvalds  * @mbox_dma_h		: maibox dma address
1171da177e4SLinus Torvalds  * @sgl64		: 64-bit scatter-gather list
1181da177e4SLinus Torvalds  * @sgl32		: 32-bit scatter-gather list
1191da177e4SLinus Torvalds  * @sgl_dma_h		: dma handle for the scatter-gather list
1201da177e4SLinus Torvalds  * @pthru		: passthru structure
1211da177e4SLinus Torvalds  * @pthru_dma_h		: dma handle for the passthru structure
1221da177e4SLinus Torvalds  * @epthru		: extended passthru structure
1231da177e4SLinus Torvalds  * @epthru_dma_h	: dma handle for extended passthru structure
1241da177e4SLinus Torvalds  * @buf_dma_h		: dma handle for buffers w/o sg list
1251da177e4SLinus Torvalds  *
1261da177e4SLinus Torvalds  * command control block specific to the mailbox based controllers
1271da177e4SLinus Torvalds  */
1281da177e4SLinus Torvalds typedef struct {
1291da177e4SLinus Torvalds 	uint8_t			*raw_mbox;
1301da177e4SLinus Torvalds 	mbox_t			*mbox;
1311da177e4SLinus Torvalds 	mbox64_t		*mbox64;
1321da177e4SLinus Torvalds 	dma_addr_t		mbox_dma_h;
1331da177e4SLinus Torvalds 	mbox_sgl64		*sgl64;
1341da177e4SLinus Torvalds 	mbox_sgl32		*sgl32;
1351da177e4SLinus Torvalds 	dma_addr_t		sgl_dma_h;
1361da177e4SLinus Torvalds 	mraid_passthru_t	*pthru;
1371da177e4SLinus Torvalds 	dma_addr_t		pthru_dma_h;
1381da177e4SLinus Torvalds 	mraid_epassthru_t	*epthru;
1391da177e4SLinus Torvalds 	dma_addr_t		epthru_dma_h;
1401da177e4SLinus Torvalds 	dma_addr_t		buf_dma_h;
1411da177e4SLinus Torvalds } mbox_ccb_t;
1421da177e4SLinus Torvalds 
1431da177e4SLinus Torvalds 
1441da177e4SLinus Torvalds /**
1451da177e4SLinus Torvalds  * mraid_device_t - adapter soft state structure for mailbox controllers
1461da177e4SLinus Torvalds  * @param una_mbox64		: 64-bit mbox - unaligned
1471da177e4SLinus Torvalds  * @param una_mbox64_dma	: mbox dma addr - unaligned
1481da177e4SLinus Torvalds  * @param mbox			: 32-bit mbox - aligned
1491da177e4SLinus Torvalds  * @param mbox64		: 64-bit mbox - aligned
1501da177e4SLinus Torvalds  * @param mbox_dma		: mbox dma addr - aligned
1511da177e4SLinus Torvalds  * @param mailbox_lock		: exclusion lock for the mailbox
1521da177e4SLinus Torvalds  * @param baseport		: base port of hba memory
1531da177e4SLinus Torvalds  * @param baseaddr		: mapped addr of hba memory
1541da177e4SLinus Torvalds  * @param mbox_pool		: pool of mailboxes
1551da177e4SLinus Torvalds  * @param mbox_pool_handle	: handle for the mailbox pool memory
1561da177e4SLinus Torvalds  * @param epthru_pool		: a pool for extended passthru commands
1571da177e4SLinus Torvalds  * @param epthru_pool_handle	: handle to the pool above
1581da177e4SLinus Torvalds  * @param sg_pool		: pool of scatter-gather lists for this driver
1591da177e4SLinus Torvalds  * @param sg_pool_handle	: handle to the pool above
1601da177e4SLinus Torvalds  * @param ccb_list		: list of our command control blocks
1611da177e4SLinus Torvalds  * @param uccb_list		: list of cmd control blocks for mgmt module
1621da177e4SLinus Torvalds  * @param umbox64		: array of mailbox for user commands (cmm)
1631da177e4SLinus Torvalds  * @param pdrv_state		: array for state of each physical drive.
1641da177e4SLinus Torvalds  * @param last_disp		: flag used to show device scanning
1651da177e4SLinus Torvalds  * @param hw_error		: set if FW not responding
1661da177e4SLinus Torvalds  * @param fast_load		: If set, skip physical device scanning
1671da177e4SLinus Torvalds  * @channel_class		: channel class, RAID or SCSI
1681da177e4SLinus Torvalds  * @sysfs_sem			: semaphore to serialize access to sysfs res.
1691da177e4SLinus Torvalds  * @sysfs_uioc			: management packet to issue FW calls from sysfs
1701da177e4SLinus Torvalds  * @sysfs_mbox64		: mailbox packet to issue FW calls from sysfs
1711da177e4SLinus Torvalds  * @sysfs_buffer		: data buffer for FW commands issued from sysfs
1721da177e4SLinus Torvalds  * @sysfs_buffer_dma		: DMA buffer for FW commands issued from sysfs
1731da177e4SLinus Torvalds  * @sysfs_wait_q		: wait queue for sysfs operations
1741da177e4SLinus Torvalds  * @random_del_supported	: set if the random deletion is supported
1751da177e4SLinus Torvalds  * @curr_ldmap			: current LDID map
1761da177e4SLinus Torvalds  *
1771da177e4SLinus Torvalds  * Initialization structure for mailbox controllers: memory based and IO based
1781da177e4SLinus Torvalds  * All the fields in this structure are LLD specific and may be discovered at
1791da177e4SLinus Torvalds  * init() or start() time.
1801da177e4SLinus Torvalds  *
1811da177e4SLinus Torvalds  * NOTE: The fields of this structures are placed to minimize cache misses
1821da177e4SLinus Torvalds  */
1831da177e4SLinus Torvalds #define MAX_LD_EXTENDED64	64
1841da177e4SLinus Torvalds typedef struct {
1851da177e4SLinus Torvalds 	mbox64_t			*una_mbox64;
1861da177e4SLinus Torvalds 	dma_addr_t			una_mbox64_dma;
1871da177e4SLinus Torvalds 	mbox_t				*mbox;
1881da177e4SLinus Torvalds 	mbox64_t			*mbox64;
1891da177e4SLinus Torvalds 	dma_addr_t			mbox_dma;
1901da177e4SLinus Torvalds 	spinlock_t			mailbox_lock;
1911da177e4SLinus Torvalds 	unsigned long			baseport;
1921da177e4SLinus Torvalds 	void __iomem *			baseaddr;
1931da177e4SLinus Torvalds 	struct mraid_pci_blk		mbox_pool[MBOX_MAX_SCSI_CMDS];
1941da177e4SLinus Torvalds 	struct dma_pool			*mbox_pool_handle;
1951da177e4SLinus Torvalds 	struct mraid_pci_blk		epthru_pool[MBOX_MAX_SCSI_CMDS];
1961da177e4SLinus Torvalds 	struct dma_pool			*epthru_pool_handle;
1971da177e4SLinus Torvalds 	struct mraid_pci_blk		sg_pool[MBOX_MAX_SCSI_CMDS];
1981da177e4SLinus Torvalds 	struct dma_pool			*sg_pool_handle;
1991da177e4SLinus Torvalds 	mbox_ccb_t			ccb_list[MBOX_MAX_SCSI_CMDS];
2001da177e4SLinus Torvalds 	mbox_ccb_t			uccb_list[MBOX_MAX_USER_CMDS];
2011da177e4SLinus Torvalds 	mbox64_t			umbox64[MBOX_MAX_USER_CMDS];
2021da177e4SLinus Torvalds 
2031da177e4SLinus Torvalds 	uint8_t				pdrv_state[MBOX_MAX_PHYSICAL_DRIVES];
2041da177e4SLinus Torvalds 	uint32_t			last_disp;
2051da177e4SLinus Torvalds 	int				hw_error;
2061da177e4SLinus Torvalds 	int				fast_load;
2071da177e4SLinus Torvalds 	uint8_t				channel_class;
2081da177e4SLinus Torvalds 	struct semaphore		sysfs_sem;
2091da177e4SLinus Torvalds 	uioc_t				*sysfs_uioc;
2101da177e4SLinus Torvalds 	mbox64_t			*sysfs_mbox64;
2111da177e4SLinus Torvalds 	caddr_t				sysfs_buffer;
2121da177e4SLinus Torvalds 	dma_addr_t			sysfs_buffer_dma;
2131da177e4SLinus Torvalds 	wait_queue_head_t		sysfs_wait_q;
2141da177e4SLinus Torvalds 	int				random_del_supported;
2151da177e4SLinus Torvalds 	uint16_t			curr_ldmap[MAX_LD_EXTENDED64];
2161da177e4SLinus Torvalds } mraid_device_t;
2171da177e4SLinus Torvalds 
2181da177e4SLinus Torvalds // route to raid device from adapter
2191da177e4SLinus Torvalds #define ADAP2RAIDDEV(adp)	((mraid_device_t *)((adp)->raid_device))
2201da177e4SLinus Torvalds 
2211da177e4SLinus Torvalds #define MAILBOX_LOCK(rdev)	(&(rdev)->mailbox_lock)
2221da177e4SLinus Torvalds 
2231da177e4SLinus Torvalds // Find out if this channel is a RAID or SCSI
2241da177e4SLinus Torvalds #define IS_RAID_CH(rdev, ch)	(((rdev)->channel_class >> (ch)) & 0x01)
2251da177e4SLinus Torvalds 
2261da177e4SLinus Torvalds 
2271da177e4SLinus Torvalds #define RDINDOOR(rdev)		readl((rdev)->baseaddr + 0x20)
2281da177e4SLinus Torvalds #define RDOUTDOOR(rdev)		readl((rdev)->baseaddr + 0x2C)
2291da177e4SLinus Torvalds #define WRINDOOR(rdev, value)	writel(value, (rdev)->baseaddr + 0x20)
2301da177e4SLinus Torvalds #define WROUTDOOR(rdev, value)	writel(value, (rdev)->baseaddr + 0x2C)
2311da177e4SLinus Torvalds 
2321da177e4SLinus Torvalds #endif // _MEGARAID_H_
2331da177e4SLinus Torvalds 
2341da177e4SLinus Torvalds // vim: set ts=8 sw=8 tw=78:
235