162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Linux MegaRAID device driver 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright (c) 2003-2004 LSI Logic Corporation. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * FILE : megaraid_mbox.h 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#ifndef _MEGARAID_H_ 1262306a36Sopenharmony_ci#define _MEGARAID_H_ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include "mega_common.h" 1662306a36Sopenharmony_ci#include "mbox_defs.h" 1762306a36Sopenharmony_ci#include "megaraid_ioctl.h" 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define MEGARAID_VERSION "2.20.5.1" 2162306a36Sopenharmony_ci#define MEGARAID_EXT_VERSION "(Release Date: Thu Nov 16 15:32:35 EST 2006)" 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci/* 2562306a36Sopenharmony_ci * Define some PCI values here until they are put in the kernel 2662306a36Sopenharmony_ci */ 2762306a36Sopenharmony_ci#define PCI_DEVICE_ID_PERC4_DI_DISCOVERY 0x000E 2862306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4_DI_DISCOVERY 0x0123 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define PCI_DEVICE_ID_PERC4_SC 0x1960 3162306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4_SC 0x0520 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#define PCI_DEVICE_ID_PERC4_DC 0x1960 3462306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4_DC 0x0518 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci#define PCI_DEVICE_ID_VERDE 0x0407 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#define PCI_DEVICE_ID_PERC4_DI_EVERGLADES 0x000F 3962306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4_DI_EVERGLADES 0x014A 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_SI_BIGBEND 0x0013 4262306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_SI_BIGBEND 0x016c 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_DI_KOBUK 0x0013 4562306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_DI_KOBUK 0x016d 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_DI_CORVETTE 0x0013 4862306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_DI_CORVETTE 0x016e 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_DI_EXPEDITION 0x0013 5162306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_DI_EXPEDITION 0x016f 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci#define PCI_DEVICE_ID_PERC4E_DI_GUADALUPE 0x0013 5462306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC4E_DI_GUADALUPE 0x0170 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#define PCI_DEVICE_ID_DOBSON 0x0408 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SCSI_320_0 0x1960 5962306a36Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_0 0xA520 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SCSI_320_1 0x1960 6262306a36Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_1 0x0520 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SCSI_320_2 0x1960 6562306a36Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SCSI_320_2 0x0518 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_I4_133_RAID 0x1960 6862306a36Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_I4_133_RAID 0x0522 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SATA_150_4 0x1960 7162306a36Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SATA_150_4 0x4523 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#define PCI_DEVICE_ID_MEGARAID_SATA_150_6 0x1960 7462306a36Sopenharmony_ci#define PCI_SUBSYS_ID_MEGARAID_SATA_150_6 0x0523 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#define PCI_DEVICE_ID_LINDSAY 0x0409 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci#define PCI_DEVICE_ID_INTEL_RAID_SRCS16 0x1960 7962306a36Sopenharmony_ci#define PCI_SUBSYS_ID_INTEL_RAID_SRCS16 0x0523 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define PCI_DEVICE_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x1960 8262306a36Sopenharmony_ci#define PCI_SUBSYS_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK 0x0520 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC3_QC 0x0471 8562306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC3_DC 0x0493 8662306a36Sopenharmony_ci#define PCI_SUBSYS_ID_PERC3_SC 0x0475 8762306a36Sopenharmony_ci#define PCI_SUBSYS_ID_CERC_ATA100_4CH 0x0511 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define MBOX_MAX_SCSI_CMDS 128 // number of cmds reserved for kernel 9162306a36Sopenharmony_ci#define MBOX_MAX_USER_CMDS 32 // number of cmds for applications 9262306a36Sopenharmony_ci#define MBOX_DEF_CMD_PER_LUN 64 // default commands per lun 9362306a36Sopenharmony_ci#define MBOX_DEFAULT_SG_SIZE 26 // default sg size supported by all fw 9462306a36Sopenharmony_ci#define MBOX_MAX_SG_SIZE 32 // maximum scatter-gather list size 9562306a36Sopenharmony_ci#define MBOX_MAX_SECTORS 128 // maximum sectors per IO 9662306a36Sopenharmony_ci#define MBOX_TIMEOUT 30 // timeout value for internal cmds 9762306a36Sopenharmony_ci#define MBOX_BUSY_WAIT 10 // max usec to wait for busy mailbox 9862306a36Sopenharmony_ci#define MBOX_RESET_WAIT 180 // wait these many seconds in reset 9962306a36Sopenharmony_ci#define MBOX_RESET_EXT_WAIT 120 // extended wait reset 10062306a36Sopenharmony_ci#define MBOX_SYNC_WAIT_CNT 0xFFFF // wait loop index for synchronous mode 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci#define MBOX_SYNC_DELAY_200 200 // 200 micro-seconds 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci/* 10562306a36Sopenharmony_ci * maximum transfer that can happen through the firmware commands issued 10662306a36Sopenharmony_ci * internnaly from the driver. 10762306a36Sopenharmony_ci */ 10862306a36Sopenharmony_ci#define MBOX_IBUF_SIZE 4096 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci/** 11262306a36Sopenharmony_ci * mbox_ccb_t - command control block specific to mailbox based controllers 11362306a36Sopenharmony_ci * @raw_mbox : raw mailbox pointer 11462306a36Sopenharmony_ci * @mbox : mailbox 11562306a36Sopenharmony_ci * @mbox64 : extended mailbox 11662306a36Sopenharmony_ci * @mbox_dma_h : mailbox dma address 11762306a36Sopenharmony_ci * @sgl64 : 64-bit scatter-gather list 11862306a36Sopenharmony_ci * @sgl32 : 32-bit scatter-gather list 11962306a36Sopenharmony_ci * @sgl_dma_h : dma handle for the scatter-gather list 12062306a36Sopenharmony_ci * @pthru : passthru structure 12162306a36Sopenharmony_ci * @pthru_dma_h : dma handle for the passthru structure 12262306a36Sopenharmony_ci * @epthru : extended passthru structure 12362306a36Sopenharmony_ci * @epthru_dma_h : dma handle for extended passthru structure 12462306a36Sopenharmony_ci * @buf_dma_h : dma handle for buffers w/o sg list 12562306a36Sopenharmony_ci * 12662306a36Sopenharmony_ci * command control block specific to the mailbox based controllers 12762306a36Sopenharmony_ci */ 12862306a36Sopenharmony_citypedef struct { 12962306a36Sopenharmony_ci uint8_t *raw_mbox; 13062306a36Sopenharmony_ci mbox_t *mbox; 13162306a36Sopenharmony_ci mbox64_t *mbox64; 13262306a36Sopenharmony_ci dma_addr_t mbox_dma_h; 13362306a36Sopenharmony_ci mbox_sgl64 *sgl64; 13462306a36Sopenharmony_ci mbox_sgl32 *sgl32; 13562306a36Sopenharmony_ci dma_addr_t sgl_dma_h; 13662306a36Sopenharmony_ci mraid_passthru_t *pthru; 13762306a36Sopenharmony_ci dma_addr_t pthru_dma_h; 13862306a36Sopenharmony_ci mraid_epassthru_t *epthru; 13962306a36Sopenharmony_ci dma_addr_t epthru_dma_h; 14062306a36Sopenharmony_ci dma_addr_t buf_dma_h; 14162306a36Sopenharmony_ci} mbox_ccb_t; 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci/** 14562306a36Sopenharmony_ci * mraid_device_t - adapter soft state structure for mailbox controllers 14662306a36Sopenharmony_ci * @una_mbox64 : 64-bit mbox - unaligned 14762306a36Sopenharmony_ci * @una_mbox64_dma : mbox dma addr - unaligned 14862306a36Sopenharmony_ci * @mbox : 32-bit mbox - aligned 14962306a36Sopenharmony_ci * @mbox64 : 64-bit mbox - aligned 15062306a36Sopenharmony_ci * @mbox_dma : mbox dma addr - aligned 15162306a36Sopenharmony_ci * @mailbox_lock : exclusion lock for the mailbox 15262306a36Sopenharmony_ci * @baseport : base port of hba memory 15362306a36Sopenharmony_ci * @baseaddr : mapped addr of hba memory 15462306a36Sopenharmony_ci * @mbox_pool : pool of mailboxes 15562306a36Sopenharmony_ci * @mbox_pool_handle : handle for the mailbox pool memory 15662306a36Sopenharmony_ci * @epthru_pool : a pool for extended passthru commands 15762306a36Sopenharmony_ci * @epthru_pool_handle : handle to the pool above 15862306a36Sopenharmony_ci * @sg_pool : pool of scatter-gather lists for this driver 15962306a36Sopenharmony_ci * @sg_pool_handle : handle to the pool above 16062306a36Sopenharmony_ci * @ccb_list : list of our command control blocks 16162306a36Sopenharmony_ci * @uccb_list : list of cmd control blocks for mgmt module 16262306a36Sopenharmony_ci * @umbox64 : array of mailbox for user commands (cmm) 16362306a36Sopenharmony_ci * @pdrv_state : array for state of each physical drive. 16462306a36Sopenharmony_ci * @last_disp : flag used to show device scanning 16562306a36Sopenharmony_ci * @hw_error : set if FW not responding 16662306a36Sopenharmony_ci * @fast_load : If set, skip physical device scanning 16762306a36Sopenharmony_ci * @channel_class : channel class, RAID or SCSI 16862306a36Sopenharmony_ci * @sysfs_mtx : mutex to serialize access to sysfs res. 16962306a36Sopenharmony_ci * @sysfs_uioc : management packet to issue FW calls from sysfs 17062306a36Sopenharmony_ci * @sysfs_mbox64 : mailbox packet to issue FW calls from sysfs 17162306a36Sopenharmony_ci * @sysfs_buffer : data buffer for FW commands issued from sysfs 17262306a36Sopenharmony_ci * @sysfs_buffer_dma : DMA buffer for FW commands issued from sysfs 17362306a36Sopenharmony_ci * @sysfs_wait_q : wait queue for sysfs operations 17462306a36Sopenharmony_ci * @random_del_supported : set if the random deletion is supported 17562306a36Sopenharmony_ci * @curr_ldmap : current LDID map 17662306a36Sopenharmony_ci * 17762306a36Sopenharmony_ci * Initialization structure for mailbox controllers: memory based and IO based 17862306a36Sopenharmony_ci * All the fields in this structure are LLD specific and may be discovered at 17962306a36Sopenharmony_ci * init() or start() time. 18062306a36Sopenharmony_ci * 18162306a36Sopenharmony_ci * NOTE: The fields of this structures are placed to minimize cache misses 18262306a36Sopenharmony_ci */ 18362306a36Sopenharmony_ci#define MAX_LD_EXTENDED64 64 18462306a36Sopenharmony_citypedef struct { 18562306a36Sopenharmony_ci mbox64_t *una_mbox64; 18662306a36Sopenharmony_ci dma_addr_t una_mbox64_dma; 18762306a36Sopenharmony_ci mbox_t *mbox; 18862306a36Sopenharmony_ci mbox64_t *mbox64; 18962306a36Sopenharmony_ci dma_addr_t mbox_dma; 19062306a36Sopenharmony_ci spinlock_t mailbox_lock; 19162306a36Sopenharmony_ci unsigned long baseport; 19262306a36Sopenharmony_ci void __iomem * baseaddr; 19362306a36Sopenharmony_ci struct mraid_pci_blk mbox_pool[MBOX_MAX_SCSI_CMDS]; 19462306a36Sopenharmony_ci struct dma_pool *mbox_pool_handle; 19562306a36Sopenharmony_ci struct mraid_pci_blk epthru_pool[MBOX_MAX_SCSI_CMDS]; 19662306a36Sopenharmony_ci struct dma_pool *epthru_pool_handle; 19762306a36Sopenharmony_ci struct mraid_pci_blk sg_pool[MBOX_MAX_SCSI_CMDS]; 19862306a36Sopenharmony_ci struct dma_pool *sg_pool_handle; 19962306a36Sopenharmony_ci mbox_ccb_t ccb_list[MBOX_MAX_SCSI_CMDS]; 20062306a36Sopenharmony_ci mbox_ccb_t uccb_list[MBOX_MAX_USER_CMDS]; 20162306a36Sopenharmony_ci mbox64_t umbox64[MBOX_MAX_USER_CMDS]; 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci uint8_t pdrv_state[MBOX_MAX_PHYSICAL_DRIVES]; 20462306a36Sopenharmony_ci uint32_t last_disp; 20562306a36Sopenharmony_ci int hw_error; 20662306a36Sopenharmony_ci int fast_load; 20762306a36Sopenharmony_ci uint8_t channel_class; 20862306a36Sopenharmony_ci struct mutex sysfs_mtx; 20962306a36Sopenharmony_ci uioc_t *sysfs_uioc; 21062306a36Sopenharmony_ci mbox64_t *sysfs_mbox64; 21162306a36Sopenharmony_ci caddr_t sysfs_buffer; 21262306a36Sopenharmony_ci dma_addr_t sysfs_buffer_dma; 21362306a36Sopenharmony_ci wait_queue_head_t sysfs_wait_q; 21462306a36Sopenharmony_ci int random_del_supported; 21562306a36Sopenharmony_ci uint16_t curr_ldmap[MAX_LD_EXTENDED64]; 21662306a36Sopenharmony_ci} mraid_device_t; 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_ci// route to raid device from adapter 21962306a36Sopenharmony_ci#define ADAP2RAIDDEV(adp) ((mraid_device_t *)((adp)->raid_device)) 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_ci#define MAILBOX_LOCK(rdev) (&(rdev)->mailbox_lock) 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci// Find out if this channel is a RAID or SCSI 22462306a36Sopenharmony_ci#define IS_RAID_CH(rdev, ch) (((rdev)->channel_class >> (ch)) & 0x01) 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_ci#define RDINDOOR(rdev) readl((rdev)->baseaddr + 0x20) 22862306a36Sopenharmony_ci#define RDOUTDOOR(rdev) readl((rdev)->baseaddr + 0x2C) 22962306a36Sopenharmony_ci#define WRINDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x20) 23062306a36Sopenharmony_ci#define WROUTDOOR(rdev, value) writel(value, (rdev)->baseaddr + 0x2C) 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci#endif // _MEGARAID_H_ 233