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 24cd96d96fSSumant Patro #define MEGARAID_VERSION "2.20.5.1" 25cd96d96fSSumant Patro #define MEGARAID_EXT_VERSION "(Release Date: Thu Nov 16 15:32:35 EST 2006)" 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 40672b2d38SJu, 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 60672b2d38SJu, 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 80672b2d38SJu, 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 103c005fb4fSJu, Seokmann #define MBOX_SYNC_WAIT_CNT 0xFFFF // wait loop index for synchronous mode 104c005fb4fSJu, Seokmann 105c005fb4fSJu, Seokmann #define MBOX_SYNC_DELAY_200 200 // 200 micro-seconds 1061da177e4SLinus Torvalds 1071da177e4SLinus Torvalds /* 1081da177e4SLinus Torvalds * maximum transfer that can happen through the firmware commands issued 1091da177e4SLinus Torvalds * internnaly from the driver. 1101da177e4SLinus Torvalds */ 1111da177e4SLinus Torvalds #define MBOX_IBUF_SIZE 4096 1121da177e4SLinus Torvalds 1131da177e4SLinus Torvalds 1141da177e4SLinus Torvalds /** 1151da177e4SLinus Torvalds * mbox_ccb_t - command control block specific to mailbox based controllers 1161da177e4SLinus Torvalds * @raw_mbox : raw mailbox pointer 1171da177e4SLinus Torvalds * @mbox : mailbox 1181da177e4SLinus Torvalds * @mbox64 : extended mailbox 1191da177e4SLinus Torvalds * @mbox_dma_h : maibox dma address 1201da177e4SLinus Torvalds * @sgl64 : 64-bit scatter-gather list 1211da177e4SLinus Torvalds * @sgl32 : 32-bit scatter-gather list 1221da177e4SLinus Torvalds * @sgl_dma_h : dma handle for the scatter-gather list 1231da177e4SLinus Torvalds * @pthru : passthru structure 1241da177e4SLinus Torvalds * @pthru_dma_h : dma handle for the passthru structure 1251da177e4SLinus Torvalds * @epthru : extended passthru structure 1261da177e4SLinus Torvalds * @epthru_dma_h : dma handle for extended passthru structure 1271da177e4SLinus Torvalds * @buf_dma_h : dma handle for buffers w/o sg list 1281da177e4SLinus Torvalds * 1291da177e4SLinus Torvalds * command control block specific to the mailbox based controllers 1301da177e4SLinus Torvalds */ 1311da177e4SLinus Torvalds typedef struct { 1321da177e4SLinus Torvalds uint8_t *raw_mbox; 1331da177e4SLinus Torvalds mbox_t *mbox; 1341da177e4SLinus Torvalds mbox64_t *mbox64; 1351da177e4SLinus Torvalds dma_addr_t mbox_dma_h; 1361da177e4SLinus Torvalds mbox_sgl64 *sgl64; 1371da177e4SLinus Torvalds mbox_sgl32 *sgl32; 1381da177e4SLinus Torvalds dma_addr_t sgl_dma_h; 1391da177e4SLinus Torvalds mraid_passthru_t *pthru; 1401da177e4SLinus Torvalds dma_addr_t pthru_dma_h; 1411da177e4SLinus Torvalds mraid_epassthru_t *epthru; 1421da177e4SLinus Torvalds dma_addr_t epthru_dma_h; 1431da177e4SLinus Torvalds dma_addr_t buf_dma_h; 1441da177e4SLinus Torvalds } mbox_ccb_t; 1451da177e4SLinus Torvalds 1461da177e4SLinus Torvalds 1471da177e4SLinus Torvalds /** 1481da177e4SLinus Torvalds * mraid_device_t - adapter soft state structure for mailbox controllers 149a69b74d3SRandy Dunlap * @una_mbox64 : 64-bit mbox - unaligned 150a69b74d3SRandy Dunlap * @una_mbox64_dma : mbox dma addr - unaligned 151a69b74d3SRandy Dunlap * @mbox : 32-bit mbox - aligned 152a69b74d3SRandy Dunlap * @mbox64 : 64-bit mbox - aligned 153a69b74d3SRandy Dunlap * @mbox_dma : mbox dma addr - aligned 154a69b74d3SRandy Dunlap * @mailbox_lock : exclusion lock for the mailbox 155a69b74d3SRandy Dunlap * @baseport : base port of hba memory 156a69b74d3SRandy Dunlap * @baseaddr : mapped addr of hba memory 157a69b74d3SRandy Dunlap * @mbox_pool : pool of mailboxes 158a69b74d3SRandy Dunlap * @mbox_pool_handle : handle for the mailbox pool memory 159a69b74d3SRandy Dunlap * @epthru_pool : a pool for extended passthru commands 160a69b74d3SRandy Dunlap * @epthru_pool_handle : handle to the pool above 161a69b74d3SRandy Dunlap * @sg_pool : pool of scatter-gather lists for this driver 162a69b74d3SRandy Dunlap * @sg_pool_handle : handle to the pool above 163a69b74d3SRandy Dunlap * @ccb_list : list of our command control blocks 164a69b74d3SRandy Dunlap * @uccb_list : list of cmd control blocks for mgmt module 165a69b74d3SRandy Dunlap * @umbox64 : array of mailbox for user commands (cmm) 166a69b74d3SRandy Dunlap * @pdrv_state : array for state of each physical drive. 167a69b74d3SRandy Dunlap * @last_disp : flag used to show device scanning 168a69b74d3SRandy Dunlap * @hw_error : set if FW not responding 169a69b74d3SRandy Dunlap * @fast_load : If set, skip physical device scanning 1701da177e4SLinus Torvalds * @channel_class : channel class, RAID or SCSI 171*0c2cc433SMatthias Kaehlcke * @sysfs_mtx : mutex to serialize access to sysfs res. 1721da177e4SLinus Torvalds * @sysfs_uioc : management packet to issue FW calls from sysfs 1731da177e4SLinus Torvalds * @sysfs_mbox64 : mailbox packet to issue FW calls from sysfs 1741da177e4SLinus Torvalds * @sysfs_buffer : data buffer for FW commands issued from sysfs 1751da177e4SLinus Torvalds * @sysfs_buffer_dma : DMA buffer for FW commands issued from sysfs 1761da177e4SLinus Torvalds * @sysfs_wait_q : wait queue for sysfs operations 1771da177e4SLinus Torvalds * @random_del_supported : set if the random deletion is supported 1781da177e4SLinus Torvalds * @curr_ldmap : current LDID map 1791da177e4SLinus Torvalds * 1801da177e4SLinus Torvalds * Initialization structure for mailbox controllers: memory based and IO based 1811da177e4SLinus Torvalds * All the fields in this structure are LLD specific and may be discovered at 1821da177e4SLinus Torvalds * init() or start() time. 1831da177e4SLinus Torvalds * 1841da177e4SLinus Torvalds * NOTE: The fields of this structures are placed to minimize cache misses 1851da177e4SLinus Torvalds */ 1861da177e4SLinus Torvalds #define MAX_LD_EXTENDED64 64 1871da177e4SLinus Torvalds typedef struct { 1881da177e4SLinus Torvalds mbox64_t *una_mbox64; 1891da177e4SLinus Torvalds dma_addr_t una_mbox64_dma; 1901da177e4SLinus Torvalds mbox_t *mbox; 1911da177e4SLinus Torvalds mbox64_t *mbox64; 1921da177e4SLinus Torvalds dma_addr_t mbox_dma; 1931da177e4SLinus Torvalds spinlock_t mailbox_lock; 1941da177e4SLinus Torvalds unsigned long baseport; 1951da177e4SLinus Torvalds void __iomem * baseaddr; 1961da177e4SLinus Torvalds struct mraid_pci_blk mbox_pool[MBOX_MAX_SCSI_CMDS]; 1971da177e4SLinus Torvalds struct dma_pool *mbox_pool_handle; 1981da177e4SLinus Torvalds struct mraid_pci_blk epthru_pool[MBOX_MAX_SCSI_CMDS]; 1991da177e4SLinus Torvalds struct dma_pool *epthru_pool_handle; 2001da177e4SLinus Torvalds struct mraid_pci_blk sg_pool[MBOX_MAX_SCSI_CMDS]; 2011da177e4SLinus Torvalds struct dma_pool *sg_pool_handle; 2021da177e4SLinus Torvalds mbox_ccb_t ccb_list[MBOX_MAX_SCSI_CMDS]; 2031da177e4SLinus Torvalds mbox_ccb_t uccb_list[MBOX_MAX_USER_CMDS]; 2041da177e4SLinus Torvalds mbox64_t umbox64[MBOX_MAX_USER_CMDS]; 2051da177e4SLinus Torvalds 2061da177e4SLinus Torvalds uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES]; 2071da177e4SLinus Torvalds uint32_t last_disp; 2081da177e4SLinus Torvalds int hw_error; 2091da177e4SLinus Torvalds int fast_load; 2101da177e4SLinus Torvalds uint8_t channel_class; 211*0c2cc433SMatthias Kaehlcke struct mutex sysfs_mtx; 2121da177e4SLinus Torvalds uioc_t *sysfs_uioc; 2131da177e4SLinus Torvalds mbox64_t *sysfs_mbox64; 2141da177e4SLinus Torvalds caddr_t sysfs_buffer; 2151da177e4SLinus Torvalds dma_addr_t sysfs_buffer_dma; 2161da177e4SLinus Torvalds wait_queue_head_t sysfs_wait_q; 2171da177e4SLinus Torvalds int random_del_supported; 2181da177e4SLinus Torvalds uint16_t curr_ldmap[MAX_LD_EXTENDED64]; 2191da177e4SLinus Torvalds } mraid_device_t; 2201da177e4SLinus Torvalds 2211da177e4SLinus Torvalds // route to raid device from adapter 2221da177e4SLinus Torvalds #define ADAP2RAIDDEV(adp) ((mraid_device_t *)((adp)->raid_device)) 2231da177e4SLinus Torvalds 2241da177e4SLinus Torvalds #define MAILBOX_LOCK(rdev) (&(rdev)->mailbox_lock) 2251da177e4SLinus Torvalds 2261da177e4SLinus Torvalds // Find out if this channel is a RAID or SCSI 2271da177e4SLinus Torvalds #define IS_RAID_CH(rdev, ch) (((rdev)->channel_class >> (ch)) & 0x01) 2281da177e4SLinus Torvalds 2291da177e4SLinus Torvalds 2301da177e4SLinus Torvalds #define RDINDOOR(rdev) readl((rdev)->baseaddr + 0x20) 2311da177e4SLinus Torvalds #define RDOUTDOOR(rdev) readl((rdev)->baseaddr + 0x2C) 2321da177e4SLinus Torvalds #define WRINDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x20) 2331da177e4SLinus Torvalds #define WROUTDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x2C) 2341da177e4SLinus Torvalds 2351da177e4SLinus Torvalds #endif // _MEGARAID_H_ 2361da177e4SLinus Torvalds 2371da177e4SLinus Torvalds // vim: set ts=8 sw=8 tw=78: 238