18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Linux MegaRAID device driver 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (c) 2003-2004 LSI Logic Corporation. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * FILE : megaraid_mbox.h 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _MEGARAID_H_ 128c2ecf20Sopenharmony_ci#define _MEGARAID_H_ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "mega_common.h" 168c2ecf20Sopenharmony_ci#include "mbox_defs.h" 178c2ecf20Sopenharmony_ci#include "megaraid_ioctl.h" 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define MEGARAID_VERSION "2.20.5.1" 218c2ecf20Sopenharmony_ci#define MEGARAID_EXT_VERSION "(Release Date: Thu Nov 16 15:32:35 EST 2006)" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 258c2ecf20Sopenharmony_ci * Define some PCI values here until they are put in the kernel 268c2ecf20Sopenharmony_ci */ 278c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PERC4_DI_DISCOVERY 0x000E 288c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4_DI_DISCOVERY 0x0123 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PERC4_SC 0x1960 318c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4_SC 0x0520 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PERC4_DC 0x1960 348c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4_DC 0x0518 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_VERDE 0x0407 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PERC4_DI_EVERGLADES 0x000F 398c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4_DI_EVERGLADES 0x014A 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_SI_BIGBEND 0x0013 428c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_SI_BIGBEND 0x016c 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_DI_KOBUK 0x0013 458c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_DI_KOBUK 0x016d 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_DI_CORVETTE 0x0013 488c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_DI_CORVETTE 0x016e 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_DI_EXPEDITION 0x0013 518c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_DI_EXPEDITION 0x016f 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_DI_GUADALUPE 0x0013 548c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_DI_GUADALUPE 0x0170 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_DOBSON 0x0408 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SCSI_320_0 0x1960 598c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_0 0xA520 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SCSI_320_1 0x1960 628c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_1 0x0520 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SCSI_320_2 0x1960 658c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_2 0x0518 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_I4_133_RAID 0x1960 688c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_I4_133_RAID 0x0522 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SATA_150_4 0x1960 718c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SATA_150_4 0x4523 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SATA_150_6 0x1960 748c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SATA_150_6 0x0523 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_LINDSAY 0x0409 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_INTEL_RAID_SRCS16 0x1960 798c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_INTEL_RAID_SRCS16 0x0523 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x1960 828c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x0520 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC3_QC 0x0471 858c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC3_DC 0x0493 868c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_PERC3_SC 0x0475 878c2ecf20Sopenharmony_ci#define PCI_SUBSYS_ID_CERC_ATA100_4CH 0x0511 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define MBOX_MAX_SCSI_CMDS 128 // number of cmds reserved for kernel 918c2ecf20Sopenharmony_ci#define MBOX_MAX_USER_CMDS 32 // number of cmds for applications 928c2ecf20Sopenharmony_ci#define MBOX_DEF_CMD_PER_LUN 64 // default commands per lun 938c2ecf20Sopenharmony_ci#define MBOX_DEFAULT_SG_SIZE 26 // default sg size supported by all fw 948c2ecf20Sopenharmony_ci#define MBOX_MAX_SG_SIZE 32 // maximum scatter-gather list size 958c2ecf20Sopenharmony_ci#define MBOX_MAX_SECTORS 128 // maximum sectors per IO 968c2ecf20Sopenharmony_ci#define MBOX_TIMEOUT 30 // timeout value for internal cmds 978c2ecf20Sopenharmony_ci#define MBOX_BUSY_WAIT 10 // max usec to wait for busy mailbox 988c2ecf20Sopenharmony_ci#define MBOX_RESET_WAIT 180 // wait these many seconds in reset 998c2ecf20Sopenharmony_ci#define MBOX_RESET_EXT_WAIT 120 // extended wait reset 1008c2ecf20Sopenharmony_ci#define MBOX_SYNC_WAIT_CNT 0xFFFF // wait loop index for synchronous mode 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define MBOX_SYNC_DELAY_200 200 // 200 micro-seconds 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* 1058c2ecf20Sopenharmony_ci * maximum transfer that can happen through the firmware commands issued 1068c2ecf20Sopenharmony_ci * internnaly from the driver. 1078c2ecf20Sopenharmony_ci */ 1088c2ecf20Sopenharmony_ci#define MBOX_IBUF_SIZE 4096 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci/** 1128c2ecf20Sopenharmony_ci * mbox_ccb_t - command control block specific to mailbox based controllers 1138c2ecf20Sopenharmony_ci * @raw_mbox : raw mailbox pointer 1148c2ecf20Sopenharmony_ci * @mbox : mailbox 1158c2ecf20Sopenharmony_ci * @mbox64 : extended mailbox 1168c2ecf20Sopenharmony_ci * @mbox_dma_h : mailbox dma address 1178c2ecf20Sopenharmony_ci * @sgl64 : 64-bit scatter-gather list 1188c2ecf20Sopenharmony_ci * @sgl32 : 32-bit scatter-gather list 1198c2ecf20Sopenharmony_ci * @sgl_dma_h : dma handle for the scatter-gather list 1208c2ecf20Sopenharmony_ci * @pthru : passthru structure 1218c2ecf20Sopenharmony_ci * @pthru_dma_h : dma handle for the passthru structure 1228c2ecf20Sopenharmony_ci * @epthru : extended passthru structure 1238c2ecf20Sopenharmony_ci * @epthru_dma_h : dma handle for extended passthru structure 1248c2ecf20Sopenharmony_ci * @buf_dma_h : dma handle for buffers w/o sg list 1258c2ecf20Sopenharmony_ci * 1268c2ecf20Sopenharmony_ci * command control block specific to the mailbox based controllers 1278c2ecf20Sopenharmony_ci */ 1288c2ecf20Sopenharmony_citypedef struct { 1298c2ecf20Sopenharmony_ci uint8_t *raw_mbox; 1308c2ecf20Sopenharmony_ci mbox_t *mbox; 1318c2ecf20Sopenharmony_ci mbox64_t *mbox64; 1328c2ecf20Sopenharmony_ci dma_addr_t mbox_dma_h; 1338c2ecf20Sopenharmony_ci mbox_sgl64 *sgl64; 1348c2ecf20Sopenharmony_ci mbox_sgl32 *sgl32; 1358c2ecf20Sopenharmony_ci dma_addr_t sgl_dma_h; 1368c2ecf20Sopenharmony_ci mraid_passthru_t *pthru; 1378c2ecf20Sopenharmony_ci dma_addr_t pthru_dma_h; 1388c2ecf20Sopenharmony_ci mraid_epassthru_t *epthru; 1398c2ecf20Sopenharmony_ci dma_addr_t epthru_dma_h; 1408c2ecf20Sopenharmony_ci dma_addr_t buf_dma_h; 1418c2ecf20Sopenharmony_ci} mbox_ccb_t; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci/** 1458c2ecf20Sopenharmony_ci * mraid_device_t - adapter soft state structure for mailbox controllers 1468c2ecf20Sopenharmony_ci * @una_mbox64 : 64-bit mbox - unaligned 1478c2ecf20Sopenharmony_ci * @una_mbox64_dma : mbox dma addr - unaligned 1488c2ecf20Sopenharmony_ci * @mbox : 32-bit mbox - aligned 1498c2ecf20Sopenharmony_ci * @mbox64 : 64-bit mbox - aligned 1508c2ecf20Sopenharmony_ci * @mbox_dma : mbox dma addr - aligned 1518c2ecf20Sopenharmony_ci * @mailbox_lock : exclusion lock for the mailbox 1528c2ecf20Sopenharmony_ci * @baseport : base port of hba memory 1538c2ecf20Sopenharmony_ci * @baseaddr : mapped addr of hba memory 1548c2ecf20Sopenharmony_ci * @mbox_pool : pool of mailboxes 1558c2ecf20Sopenharmony_ci * @mbox_pool_handle : handle for the mailbox pool memory 1568c2ecf20Sopenharmony_ci * @epthru_pool : a pool for extended passthru commands 1578c2ecf20Sopenharmony_ci * @epthru_pool_handle : handle to the pool above 1588c2ecf20Sopenharmony_ci * @sg_pool : pool of scatter-gather lists for this driver 1598c2ecf20Sopenharmony_ci * @sg_pool_handle : handle to the pool above 1608c2ecf20Sopenharmony_ci * @ccb_list : list of our command control blocks 1618c2ecf20Sopenharmony_ci * @uccb_list : list of cmd control blocks for mgmt module 1628c2ecf20Sopenharmony_ci * @umbox64 : array of mailbox for user commands (cmm) 1638c2ecf20Sopenharmony_ci * @pdrv_state : array for state of each physical drive. 1648c2ecf20Sopenharmony_ci * @last_disp : flag used to show device scanning 1658c2ecf20Sopenharmony_ci * @hw_error : set if FW not responding 1668c2ecf20Sopenharmony_ci * @fast_load : If set, skip physical device scanning 1678c2ecf20Sopenharmony_ci * @channel_class : channel class, RAID or SCSI 1688c2ecf20Sopenharmony_ci * @sysfs_mtx : mutex to serialize access to sysfs res. 1698c2ecf20Sopenharmony_ci * @sysfs_uioc : management packet to issue FW calls from sysfs 1708c2ecf20Sopenharmony_ci * @sysfs_mbox64 : mailbox packet to issue FW calls from sysfs 1718c2ecf20Sopenharmony_ci * @sysfs_buffer : data buffer for FW commands issued from sysfs 1728c2ecf20Sopenharmony_ci * @sysfs_buffer_dma : DMA buffer for FW commands issued from sysfs 1738c2ecf20Sopenharmony_ci * @sysfs_wait_q : wait queue for sysfs operations 1748c2ecf20Sopenharmony_ci * @random_del_supported : set if the random deletion is supported 1758c2ecf20Sopenharmony_ci * @curr_ldmap : current LDID map 1768c2ecf20Sopenharmony_ci * 1778c2ecf20Sopenharmony_ci * Initialization structure for mailbox controllers: memory based and IO based 1788c2ecf20Sopenharmony_ci * All the fields in this structure are LLD specific and may be discovered at 1798c2ecf20Sopenharmony_ci * init() or start() time. 1808c2ecf20Sopenharmony_ci * 1818c2ecf20Sopenharmony_ci * NOTE: The fields of this structures are placed to minimize cache misses 1828c2ecf20Sopenharmony_ci */ 1838c2ecf20Sopenharmony_ci#define MAX_LD_EXTENDED64 64 1848c2ecf20Sopenharmony_citypedef struct { 1858c2ecf20Sopenharmony_ci mbox64_t *una_mbox64; 1868c2ecf20Sopenharmony_ci dma_addr_t una_mbox64_dma; 1878c2ecf20Sopenharmony_ci mbox_t *mbox; 1888c2ecf20Sopenharmony_ci mbox64_t *mbox64; 1898c2ecf20Sopenharmony_ci dma_addr_t mbox_dma; 1908c2ecf20Sopenharmony_ci spinlock_t mailbox_lock; 1918c2ecf20Sopenharmony_ci unsigned long baseport; 1928c2ecf20Sopenharmony_ci void __iomem * baseaddr; 1938c2ecf20Sopenharmony_ci struct mraid_pci_blk mbox_pool[MBOX_MAX_SCSI_CMDS]; 1948c2ecf20Sopenharmony_ci struct dma_pool *mbox_pool_handle; 1958c2ecf20Sopenharmony_ci struct mraid_pci_blk epthru_pool[MBOX_MAX_SCSI_CMDS]; 1968c2ecf20Sopenharmony_ci struct dma_pool *epthru_pool_handle; 1978c2ecf20Sopenharmony_ci struct mraid_pci_blk sg_pool[MBOX_MAX_SCSI_CMDS]; 1988c2ecf20Sopenharmony_ci struct dma_pool *sg_pool_handle; 1998c2ecf20Sopenharmony_ci mbox_ccb_t ccb_list[MBOX_MAX_SCSI_CMDS]; 2008c2ecf20Sopenharmony_ci mbox_ccb_t uccb_list[MBOX_MAX_USER_CMDS]; 2018c2ecf20Sopenharmony_ci mbox64_t umbox64[MBOX_MAX_USER_CMDS]; 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES]; 2048c2ecf20Sopenharmony_ci uint32_t last_disp; 2058c2ecf20Sopenharmony_ci int hw_error; 2068c2ecf20Sopenharmony_ci int fast_load; 2078c2ecf20Sopenharmony_ci uint8_t channel_class; 2088c2ecf20Sopenharmony_ci struct mutex sysfs_mtx; 2098c2ecf20Sopenharmony_ci uioc_t *sysfs_uioc; 2108c2ecf20Sopenharmony_ci mbox64_t *sysfs_mbox64; 2118c2ecf20Sopenharmony_ci caddr_t sysfs_buffer; 2128c2ecf20Sopenharmony_ci dma_addr_t sysfs_buffer_dma; 2138c2ecf20Sopenharmony_ci wait_queue_head_t sysfs_wait_q; 2148c2ecf20Sopenharmony_ci int random_del_supported; 2158c2ecf20Sopenharmony_ci uint16_t curr_ldmap[MAX_LD_EXTENDED64]; 2168c2ecf20Sopenharmony_ci} mraid_device_t; 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_ci// route to raid device from adapter 2198c2ecf20Sopenharmony_ci#define ADAP2RAIDDEV(adp) ((mraid_device_t *)((adp)->raid_device)) 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci#define MAILBOX_LOCK(rdev) (&(rdev)->mailbox_lock) 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci// Find out if this channel is a RAID or SCSI 2248c2ecf20Sopenharmony_ci#define IS_RAID_CH(rdev, ch) (((rdev)->channel_class >> (ch)) & 0x01) 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci#define RDINDOOR(rdev) readl((rdev)->baseaddr + 0x20) 2288c2ecf20Sopenharmony_ci#define RDOUTDOOR(rdev) readl((rdev)->baseaddr + 0x2C) 2298c2ecf20Sopenharmony_ci#define WRINDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x20) 2308c2ecf20Sopenharmony_ci#define WROUTDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x2C) 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci#endif // _MEGARAID_H_ 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci// vim: set ts=8 sw=8 tw=78: 235