amrreg.h revision 105419
151974Smsmith/*- 265245Smsmith * Copyright (c) 1999,2000 Michael Smith 365245Smsmith * Copyright (c) 2000 BSDi 451974Smsmith * All rights reserved. 551974Smsmith * 651974Smsmith * Redistribution and use in source and binary forms, with or without 751974Smsmith * modification, are permitted provided that the following conditions 851974Smsmith * are met: 951974Smsmith * 1. Redistributions of source code must retain the above copyright 1051974Smsmith * notice, this list of conditions and the following disclaimer. 1151974Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1251974Smsmith * notice, this list of conditions and the following disclaimer in the 1351974Smsmith * documentation and/or other materials provided with the distribution. 1451974Smsmith * 1551974Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1651974Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1751974Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1851974Smsmith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1951974Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2051974Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2151974Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2251974Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2351974Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2451974Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2551974Smsmith * SUCH DAMAGE. 2651974Smsmith * 27105419Semoore * 3. The party using or redistributing the source code and binary forms 28105419Semoore * agrees to the above disclaimer and the terms and conditions set forth 29105419Semoore * herein. 30105419Semoore * 31105419Semoore * Additional Copyright (c) 2002 by Eric Moore under same license. 32105419Semoore * Additional Copyright (c) 2002 LSI Logic Corporation 33105419Semoore * 3451974Smsmith * $FreeBSD: head/sys/dev/amr/amrreg.h 105419 2002-10-18 21:29:14Z emoore $ 3551974Smsmith */ 3651974Smsmith 3765245Smsmith/******************************************************************************** 3865245Smsmith ******************************************************************************** 3965245Smsmith Driver parameters 4065245Smsmith ******************************************************************************** 4165245Smsmith ********************************************************************************/ 4265245Smsmith 4351974Smsmith/* 4465245Smsmith * We could actually use all 17 segments, but using only 16 means that 4565245Smsmith * each scatter/gather map is 128 bytes in size, and thus we don't have to worry about 4665245Smsmith * maps crossing page boundaries. 4765245Smsmith * 4865245Smsmith * The AMI documentation says that the limit is 26. Unfortunately, there's no way to 4965245Smsmith * cleanly fit more than 16 entries in without a page boundary. But is this a concern, 5065245Smsmith * since we allocate the s/g maps contiguously anyway? 5165245Smsmith */ 5265245Smsmith#define AMR_NSEG 16 5365245Smsmith 5465245Smsmith#define AMR_MAXCMD 255 /* ident = 0 not allowed */ 5565245Smsmith#define AMR_LIMITCMD 120 /* maximum count of outstanding commands */ 5665245Smsmith#define AMR_MAXLD 40 5765245Smsmith 5865245Smsmith#define AMR_MAX_CHANNELS 4 5965245Smsmith#define AMR_MAX_TARGETS 15 6065245Smsmith#define AMR_MAX_LUNS 7 6165245Smsmith#define AMR_MAX_SCSI_CMDS (15 * AMR_MAX_CHANNELS) /* one for every target? */ 6265245Smsmith 6365245Smsmith#define AMR_MAX_CDB_LEN 0x0a 6465245Smsmith#define AMR_MAX_REQ_SENSE_LEN 0x20 6565245Smsmith 6665245Smsmith#define AMR_BLKSIZE 512 /* constant for all controllers */ 6765245Smsmith 6865245Smsmith/* 6965245Smsmith * Perform at-startup board initialisation. 7065245Smsmith * At this point in time, this code doesn't work correctly, so leave it disabled. 7165245Smsmith */ 7265245Smsmith/*#define AMR_BOARD_INIT*/ 7365245Smsmith 7465245Smsmith/******************************************************************************** 7565245Smsmith ******************************************************************************** 7665245Smsmith Interface Magic Numbers 7765245Smsmith ******************************************************************************** 7865245Smsmith ********************************************************************************/ 7965245Smsmith 8065245Smsmith/* 8151974Smsmith * Mailbox commands 8251974Smsmith */ 8365245Smsmith#define AMR_CMD_LREAD 0x01 8465245Smsmith#define AMR_CMD_LWRITE 0x02 8565245Smsmith#define AMR_CMD_PASS 0x03 8665245Smsmith#define AMR_CMD_EXT_ENQUIRY 0x04 8765245Smsmith#define AMR_CMD_ENQUIRY 0x05 8865245Smsmith#define AMR_CMD_FLUSH 0x0a 8965245Smsmith#define AMR_CMD_EXT_ENQUIRY2 0x0c 9051974Smsmith#define AMR_CONFIG_PRODINFO 0x0e 9165245Smsmith#define AMR_CMD_GET_MACHINEID 0x36 9265245Smsmith#define AMR_CMD_GET_INITIATOR 0x7d /* returns one byte */ 9365245Smsmith#define AMR_CMD_CONFIG 0xa1 9465245Smsmith#define AMR_CONFIG_PRODUCT_INFO 0x0e 9565245Smsmith#define AMR_CONFIG_ENQ3 0x0f 9651974Smsmith#define AMR_CONFIG_ENQ3_SOLICITED_NOTIFY 0x01 9751974Smsmith#define AMR_CONFIG_ENQ3_SOLICITED_FULL 0x02 9851974Smsmith#define AMR_CONFIG_ENQ3_UNSOLICITED 0x03 9951974Smsmith 10051974Smsmith/* 10151974Smsmith * Command results 10251974Smsmith */ 10351974Smsmith#define AMR_STATUS_SUCCESS 0x00 10451974Smsmith#define AMR_STATUS_ABORTED 0x02 10551974Smsmith#define AMR_STATUS_FAILED 0x80 10651974Smsmith 10751974Smsmith/* 10865245Smsmith * Physical/logical drive states 10951974Smsmith */ 11065245Smsmith#define AMR_DRV_CURSTATE(x) ((x) & 0x0f) 11165245Smsmith#define AMR_DRV_PREVSTATE(x) (((x) >> 4) & 0x0f) 11265245Smsmith#define AMR_DRV_OFFLINE 0x00 11365245Smsmith#define AMR_DRV_DEGRADED 0x01 11465245Smsmith#define AMR_DRV_OPTIMAL 0x02 11565245Smsmith#define AMR_DRV_ONLINE 0x03 11665245Smsmith#define AMR_DRV_FAILED 0x04 11765245Smsmith#define AMR_DRV_REBUILD 0x05 11865245Smsmith#define AMR_DRV_HOTSPARE 0x06 11951974Smsmith 12051974Smsmith/* 12165245Smsmith * Logical drive properties 12251974Smsmith */ 12365245Smsmith#define AMR_DRV_RAID_MASK 0x0f /* RAID level 0, 1, 3, 5, etc. */ 12465245Smsmith#define AMR_DRV_WRITEBACK 0x10 /* write-back enabled */ 12565245Smsmith#define AMR_DRV_READHEAD 0x20 /* readhead policy enabled */ 12665245Smsmith#define AMR_DRV_ADAPTIVE 0x40 /* adaptive I/O policy enabled */ 12751974Smsmith 12851974Smsmith/* 12965245Smsmith * Battery status 13051974Smsmith */ 13165245Smsmith#define AMR_BATT_MODULE_MISSING 0x01 13265245Smsmith#define AMR_BATT_LOW_VOLTAGE 0x02 13365245Smsmith#define AMR_BATT_TEMP_HIGH 0x04 13465245Smsmith#define AMR_BATT_PACK_MISSING 0x08 13565245Smsmith#define AMR_BATT_CHARGE_MASK 0x30 13665245Smsmith#define AMR_BATT_CHARGE_DONE 0x00 13765245Smsmith#define AMR_BATT_CHARGE_INPROG 0x10 13865245Smsmith#define AMR_BATT_CHARGE_FAIL 0x20 13965245Smsmith#define AMR_BATT_CYCLES_EXCEEDED 0x40 14051974Smsmith 14165245Smsmith 14265245Smsmith/******************************************************************************** 14365245Smsmith ******************************************************************************** 14465245Smsmith 8LD Firmware Interface 14565245Smsmith ******************************************************************************** 14665245Smsmith ********************************************************************************/ 14765245Smsmith 14851974Smsmith/* 14965245Smsmith * Array constraints 15051974Smsmith */ 15151974Smsmith#define AMR_8LD_MAXDRIVES 8 15251974Smsmith#define AMR_8LD_MAXCHAN 5 15351974Smsmith#define AMR_8LD_MAXTARG 15 15451974Smsmith#define AMR_8LD_MAXPHYSDRIVES (AMR_8LD_MAXCHAN * AMR_8LD_MAXTARG) 15551974Smsmith 15665245Smsmith/* 15765245Smsmith * Adapter Info structure 15865245Smsmith */ 15951974Smsmithstruct amr_adapter_info 16051974Smsmith{ 16151974Smsmith u_int8_t aa_maxio; 16251974Smsmith u_int8_t aa_rebuild_rate; 16351974Smsmith u_int8_t aa_maxtargchan; 16451974Smsmith u_int8_t aa_channels; 16551974Smsmith u_int8_t aa_firmware[4]; 16651974Smsmith u_int16_t aa_flashage; 16751974Smsmith u_int8_t aa_chipsetvalue; 16851974Smsmith u_int8_t aa_memorysize; 16951974Smsmith u_int8_t aa_cacheflush; 17051974Smsmith u_int8_t aa_bios[4]; 17165245Smsmith u_int8_t aa_boardtype; 17265245Smsmith u_int8_t aa_scsisensealert; 17365245Smsmith u_int8_t aa_writeconfigcount; 17465245Smsmith u_int8_t aa_driveinsertioncount; 17565245Smsmith u_int8_t aa_inserteddrive; 17665245Smsmith u_int8_t aa_batterystatus; 17765245Smsmith u_int8_t res1; 178103870Salfred} __packed; 17951974Smsmith 18065245Smsmith/* 18165245Smsmith * Logical Drive info structure 18265245Smsmith */ 18351974Smsmithstruct amr_logdrive_info 18451974Smsmith{ 18551974Smsmith u_int8_t al_numdrives; 18651974Smsmith u_int8_t res1[3]; 18751974Smsmith u_int32_t al_size[AMR_8LD_MAXDRIVES]; 18851974Smsmith u_int8_t al_properties[AMR_8LD_MAXDRIVES]; 18951974Smsmith u_int8_t al_state[AMR_8LD_MAXDRIVES]; 190103870Salfred} __packed; 19151974Smsmith 19265245Smsmith/* 19365245Smsmith * Physical Drive info structure 19465245Smsmith */ 19551974Smsmithstruct amr_physdrive_info 19651974Smsmith{ 19765245Smsmith u_int8_t ap_state[AMR_8LD_MAXPHYSDRIVES]; /* low nibble current state, high nibble previous state */ 19865245Smsmith u_int8_t ap_predictivefailure; 199103870Salfred} __packed; 20051974Smsmith 20165245Smsmith/* 20265245Smsmith * Enquiry response structure for AMR_CMD_ENQUIRY, AMR_CMD_EXT_ENQUIRY and 20365245Smsmith * AMR_CMD_EXT_ENQUIRY2. 20465245Smsmith * ENQUIRY EXT_ENQUIRY EXT_ENQUIRY2 20565245Smsmith */ 20651974Smsmithstruct amr_enquiry 20751974Smsmith{ 20865245Smsmith struct amr_adapter_info ae_adapter; /* X X X */ 20965245Smsmith struct amr_logdrive_info ae_ldrv; /* X X X */ 21065245Smsmith struct amr_physdrive_info ae_pdrv; /* X X X */ 21165245Smsmith u_int8_t ae_formatting[AMR_8LD_MAXDRIVES];/* X X */ 21265245Smsmith u_int8_t res1[AMR_8LD_MAXDRIVES]; /* X X */ 21365245Smsmith u_int32_t ae_extlen; /* X */ 21465245Smsmith u_int16_t ae_subsystem; /* X */ 21565245Smsmith u_int16_t ae_subvendor; /* X */ 21665245Smsmith u_int32_t ae_signature; /* X */ 21765245Smsmith#define AMR_SIG_431 0xfffe0001 21865245Smsmith#define AMR_SIG_438 0xfffd0002 21965245Smsmith#define AMR_SIG_762 0xfffc0003 22065245Smsmith#define AMR_SIG_T5 0xfffb0004 22165245Smsmith#define AMR_SIG_466 0xfffa0005 22265245Smsmith#define AMR_SIG_467 0xfff90006 22365245Smsmith#define AMR_SIG_T7 0xfff80007 22465245Smsmith#define AMR_SIG_490 0xfff70008 22565245Smsmith u_int8_t res2[844]; /* X */ 226103870Salfred} __packed; 22751974Smsmith 22865245Smsmith 22965245Smsmith/******************************************************************************** 23065245Smsmith ******************************************************************************** 23165245Smsmith 40LD Firmware Interface 23265245Smsmith ******************************************************************************** 23365245Smsmith ********************************************************************************/ 23465245Smsmith 23565245Smsmith/* 23665245Smsmith * Array constraints 23765245Smsmith */ 23865245Smsmith#define AMR_40LD_MAXDRIVES 40 23965245Smsmith#define AMR_40LD_MAXCHAN 16 24065245Smsmith#define AMR_40LD_MAXTARG 16 24165245Smsmith#define AMR_40LD_MAXPHYSDRIVES 256 24265245Smsmith 24365245Smsmith/* 24465245Smsmith * Product Info structure 24565245Smsmith */ 24651974Smsmithstruct amr_prodinfo 24751974Smsmith{ 24851974Smsmith u_int32_t ap_size; /* current size in bytes (not including resvd) */ 24951974Smsmith u_int32_t ap_configsig; /* default is 0x00282008, indicating 0x28 maximum 25051974Smsmith * logical drives, 0x20 maximum stripes and 0x08 25151974Smsmith * maximum spans */ 25251974Smsmith u_int8_t ap_firmware[16]; /* printable identifiers */ 25351974Smsmith u_int8_t ap_bios[16]; 25451974Smsmith u_int8_t ap_product[80]; 25551974Smsmith u_int8_t ap_maxio; /* maximum number of concurrent commands supported */ 25651974Smsmith u_int8_t ap_nschan; /* number of SCSI channels present */ 25751974Smsmith u_int8_t ap_fcloops; /* number of fibre loops present */ 25851974Smsmith u_int8_t ap_memtype; /* memory type */ 25951974Smsmith u_int32_t ap_signature; 26051974Smsmith u_int16_t ap_memsize; /* onboard memory in MB */ 26151974Smsmith u_int16_t ap_subsystem; /* subsystem identifier */ 26251974Smsmith u_int16_t ap_subvendor; /* subsystem vendor ID */ 26351974Smsmith u_int8_t ap_numnotifyctr; /* number of notify counters */ 264103870Salfred} __packed; 26551974Smsmith 26665245Smsmith/* 26765245Smsmith * Notify structure 26865245Smsmith */ 26965245Smsmithstruct amr_notify 27065245Smsmith{ 27165245Smsmith u_int32_t an_globalcounter; /* change counter */ 27265245Smsmith 27365245Smsmith u_int8_t an_paramcounter; /* parameter change counter */ 27465245Smsmith u_int8_t an_paramid; 27565245Smsmith#define AMR_PARAM_REBUILD_RATE 0x01 /* value = new rebuild rate */ 27665245Smsmith#define AMR_PARAM_FLUSH_INTERVAL 0x02 /* value = new flush interval */ 27765245Smsmith#define AMR_PARAM_SENSE_ALERT 0x03 /* value = last physical drive with check condition set */ 27865245Smsmith#define AMR_PARAM_DRIVE_INSERTED 0x04 /* value = last physical drive inserted */ 27965245Smsmith#define AMR_PARAM_BATTERY_STATUS 0x05 /* value = battery status */ 28065245Smsmith u_int16_t an_paramval; 28165245Smsmith 28265245Smsmith u_int8_t an_writeconfigcounter; /* write config occurred */ 28365245Smsmith u_int8_t res1[3]; 28465245Smsmith 28565245Smsmith u_int8_t an_ldrvopcounter; /* logical drive operation started/completed */ 28665245Smsmith u_int8_t an_ldrvopid; 28765245Smsmith u_int8_t an_ldrvopcmd; 28865245Smsmith#define AMR_LDRVOP_CHECK 0x01 28965245Smsmith#define AMR_LDRVOP_INIT 0x02 29065245Smsmith#define AMR_LDRVOP_REBUILD 0x03 29165245Smsmith u_int8_t an_ldrvopstatus; 29265245Smsmith#define AMR_LDRVOP_SUCCESS 0x00 29365245Smsmith#define AMR_LDRVOP_FAILED 0x01 29465245Smsmith#define AMR_LDRVOP_ABORTED 0x02 29565245Smsmith#define AMR_LDRVOP_CORRECTED 0x03 29665245Smsmith#define AMR_LDRVOP_STARTED 0x04 29765245Smsmith 29865245Smsmith u_int8_t an_ldrvstatecounter; /* logical drive state change occurred */ 29965245Smsmith u_int8_t an_ldrvstateid; 30065245Smsmith u_int8_t an_ldrvstatenew; 30165245Smsmith u_int8_t an_ldrvstateold; 30265245Smsmith 30365245Smsmith u_int8_t an_pdrvstatecounter; /* physical drive state change occurred */ 30465245Smsmith u_int8_t an_pdrvstateid; 30565245Smsmith u_int8_t an_pdrvstatenew; 30665245Smsmith u_int8_t an_pdrvstateold; 30765245Smsmith 30865245Smsmith u_int8_t an_pdrvfmtcounter; 30965245Smsmith u_int8_t an_pdrvfmtid; 31065245Smsmith u_int8_t an_pdrvfmtval; 31165245Smsmith#define AMR_FORMAT_START 0x01 31265245Smsmith#define AMR_FORMAT_COMPLETE 0x02 31365245Smsmith u_int8_t res2; 31465245Smsmith 31565245Smsmith u_int8_t an_targxfercounter; /* scsi xfer rate change */ 31665245Smsmith u_int8_t an_targxferid; 31765245Smsmith u_int8_t an_targxferval; 31865245Smsmith u_int8_t res3; 31965245Smsmith 32065245Smsmith u_int8_t an_fcloopidcounter; /* FC/AL loop ID changed */ 32165245Smsmith u_int8_t an_fcloopidpdrvid; 32265245Smsmith u_int8_t an_fcloopid0; 32365245Smsmith u_int8_t an_fcloopid1; 32465245Smsmith 32565245Smsmith u_int8_t an_fcloopstatecounter; /* FC/AL loop status changed */ 32665245Smsmith u_int8_t an_fcloopstate0; 32765245Smsmith u_int8_t an_fcloopstate1; 32865245Smsmith u_int8_t res4; 329103870Salfred} __packed; 33065245Smsmith 33165245Smsmith/* 33265245Smsmith * Enquiry3 structure 33365245Smsmith */ 33465245Smsmithstruct amr_enquiry3 33565245Smsmith{ 33665245Smsmith u_int32_t ae_datasize; /* valid data size in this structure */ 33765245Smsmith union { /* event notify structure */ 33865245Smsmith struct amr_notify n; 33965245Smsmith u_int8_t pad[0x80]; 34065245Smsmith } ae_notify; 34165245Smsmith u_int8_t ae_rebuildrate; /* current rebuild rate in % */ 34265245Smsmith u_int8_t ae_cacheflush; /* flush interval in seconds */ 34365245Smsmith u_int8_t ae_sensealert; 34465245Smsmith u_int8_t ae_driveinsertcount; /* count of inserted drives */ 34565245Smsmith u_int8_t ae_batterystatus; 34665245Smsmith u_int8_t ae_numldrives; 34765245Smsmith u_int8_t ae_reconstate[AMR_40LD_MAXDRIVES / 8]; /* reconstruction state */ 34865245Smsmith u_int16_t ae_opstatus[AMR_40LD_MAXDRIVES / 8]; /* operation status per drive */ 34965245Smsmith u_int32_t ae_drivesize[AMR_40LD_MAXDRIVES]; /* logical drive size */ 35065245Smsmith u_int8_t ae_driveprop[AMR_40LD_MAXDRIVES]; /* logical drive properties */ 35165245Smsmith u_int8_t ae_drivestate[AMR_40LD_MAXDRIVES]; /* physical drive state */ 35265245Smsmith u_int16_t ae_driveformat[AMR_40LD_MAXPHYSDRIVES]; 35365245Smsmith u_int8_t ae_targxfer[80]; /* physical drive transfer rates */ 35465245Smsmith 35565245Smsmith u_int8_t res1[263]; /* pad to 1024 bytes */ 356103870Salfred} __packed; 35765245Smsmith 35865245Smsmith 35965245Smsmith/******************************************************************************** 36065245Smsmith ******************************************************************************** 36165245Smsmith Mailbox and Command Structures 36265245Smsmith ******************************************************************************** 36365245Smsmith ********************************************************************************/ 36465245Smsmith 36551974Smsmith#define AMR_MBOX_CMDSIZE 0x10 /* portion worth copying for controller */ 36651974Smsmith 36751974Smsmithstruct amr_mailbox 36851974Smsmith{ 36951974Smsmith u_int8_t mb_command; 37051974Smsmith u_int8_t mb_ident; 37151974Smsmith u_int16_t mb_blkcount; 37251974Smsmith u_int32_t mb_lba; 37351974Smsmith u_int32_t mb_physaddr; 37451974Smsmith u_int8_t mb_drive; 37551974Smsmith u_int8_t mb_nsgelem; 37651974Smsmith u_int8_t res1; 37751974Smsmith u_int8_t mb_busy; 37851974Smsmith u_int8_t mb_nstatus; 37951974Smsmith u_int8_t mb_status; 38051974Smsmith u_int8_t mb_completed[46]; 38151974Smsmith u_int8_t mb_poll; 38251974Smsmith u_int8_t mb_ack; 38351974Smsmith u_int8_t res2[16]; 384103870Salfred} __packed; 38551974Smsmith 38651974Smsmithstruct amr_mailbox64 38751974Smsmith{ 38851974Smsmith u_int32_t mb64_segment; /* for 64-bit controllers */ 38951974Smsmith struct amr_mailbox mb; 390103870Salfred} __packed; 39151974Smsmith 39251974Smsmithstruct amr_mailbox_ioctl 39351974Smsmith{ 39451974Smsmith u_int8_t mb_command; 39551974Smsmith u_int8_t mb_ident; 39651974Smsmith u_int8_t mb_channel; 39751974Smsmith u_int8_t mb_param; 39865245Smsmith u_int8_t mb_pad[4]; 39951974Smsmith u_int32_t mb_physaddr; 40051974Smsmith u_int8_t mb_drive; 40151974Smsmith u_int8_t mb_nsgelem; 40265245Smsmith u_int8_t res1; 40351974Smsmith u_int8_t mb_busy; 40451974Smsmith u_int8_t mb_nstatus; 40551974Smsmith u_int8_t mb_completed[46]; 40651974Smsmith u_int8_t mb_poll; 40751974Smsmith u_int8_t mb_ack; 40865245Smsmith u_int8_t res4[16]; 409103870Salfred} __packed; 41051974Smsmith 41151974Smsmithstruct amr_sgentry 41251974Smsmith{ 41351974Smsmith u_int32_t sg_addr; 41451974Smsmith u_int32_t sg_count; 415103870Salfred} __packed; 41651974Smsmith 41765245Smsmithstruct amr_passthrough 41865245Smsmith{ 41965245Smsmith u_int8_t ap_timeout:3; 42065245Smsmith u_int8_t ap_ars:1; 42165245Smsmith u_int8_t ap_dummy:3; 42265245Smsmith u_int8_t ap_islogical:1; 42365245Smsmith u_int8_t ap_logical_drive_no; 42465245Smsmith u_int8_t ap_channel; 42565245Smsmith u_int8_t ap_scsi_id; 42665245Smsmith u_int8_t ap_queue_tag; 42765245Smsmith u_int8_t ap_queue_action; 42865245Smsmith u_int8_t ap_cdb[AMR_MAX_CDB_LEN]; 42965245Smsmith u_int8_t ap_cdb_length; 43065245Smsmith u_int8_t ap_request_sense_length; 43165245Smsmith u_int8_t ap_request_sense_area[AMR_MAX_REQ_SENSE_LEN]; 43265245Smsmith u_int8_t ap_no_sg_elements; 43365245Smsmith u_int8_t ap_scsi_status; 43465245Smsmith u_int32_t ap_data_transfer_address; 43565245Smsmith u_int32_t ap_data_transfer_length; 436103870Salfred} __packed; 43751974Smsmith 43865245Smsmith#ifdef _KERNEL 43965245Smsmith/******************************************************************************** 44065245Smsmith ******************************************************************************** 44165245Smsmith "Quartz" i960 PCI bridge interface 44265245Smsmith ******************************************************************************** 44365245Smsmith ********************************************************************************/ 44465245Smsmith 44565245Smsmith#define AMR_CFG_SIG 0xa0 /* PCI config register for signature */ 44670285Smsmith#define AMR_SIGNATURE_1 0xCCCC /* i960 signature (older adapters) */ 44770285Smsmith#define AMR_SIGNATURE_2 0x3344 /* i960 signature (newer adapters) */ 44865245Smsmith 44965245Smsmith/* 45065245Smsmith * Doorbell registers 45165245Smsmith */ 45265245Smsmith#define AMR_QIDB 0x20 45365245Smsmith#define AMR_QODB 0x2c 45465245Smsmith#define AMR_QIDB_SUBMIT 0x00000001 /* mailbox ready for work */ 45565245Smsmith#define AMR_QIDB_ACK 0x00000002 /* mailbox done */ 45665245Smsmith#define AMR_QODB_READY 0x10001234 /* work ready to be processed */ 45765245Smsmith 45865245Smsmith/* 45965245Smsmith * Initialisation status 46065245Smsmith */ 46165245Smsmith#define AMR_QINIT_SCAN 0x01 /* init scanning drives */ 46265245Smsmith#define AMR_QINIT_SCANINIT 0x02 /* init scanning initialising */ 46365245Smsmith#define AMR_QINIT_FIRMWARE 0x03 /* init firmware initing */ 46465245Smsmith#define AMR_QINIT_INPROG 0xdc /* init in progress */ 46565245Smsmith#define AMR_QINIT_SPINUP 0x2c /* init spinning drives */ 46665245Smsmith#define AMR_QINIT_NOMEM 0xac /* insufficient memory */ 46765245Smsmith#define AMR_QINIT_CACHEFLUSH 0xbc /* init flushing cache */ 46865245Smsmith#define AMR_QINIT_DONE 0x9c /* init successfully done */ 46965245Smsmith 47065245Smsmith/* 47165245Smsmith * I/O primitives 47265245Smsmith */ 47365245Smsmith#define AMR_QPUT_IDB(sc, val) bus_space_write_4(sc->amr_btag, sc->amr_bhandle, AMR_QIDB, val) 47465245Smsmith#define AMR_QGET_IDB(sc) bus_space_read_4 (sc->amr_btag, sc->amr_bhandle, AMR_QIDB) 47565245Smsmith#define AMR_QPUT_ODB(sc, val) bus_space_write_4(sc->amr_btag, sc->amr_bhandle, AMR_QODB, val) 47665245Smsmith#define AMR_QGET_ODB(sc) bus_space_read_4 (sc->amr_btag, sc->amr_bhandle, AMR_QODB) 47765245Smsmith 47865245Smsmith#ifdef AMR_BOARD_INIT 47965245Smsmith#define AMR_QRESET(sc) \ 48065245Smsmith do { \ 48165245Smsmith pci_write_config((sc)->amr_dev, 0x40, pci_read_config((sc)->amr_dev, 0x40, 1) | 0x20, 1); \ 48265245Smsmith pci_write_config((sc)->amr_dev, 0x64, 0x1122, 1); \ 48365245Smsmith } while (0) 48465245Smsmith#define AMR_QGET_INITSTATUS(sc) pci_read_config((sc)->amr_dev, 0x9c, 1) 48565245Smsmith#define AMR_QGET_INITCHAN(sc) pci_read_config((sc)->amr_dev, 0x9f, 1) 48665245Smsmith#define AMR_QGET_INITTARG(sc) pci_read_config((sc)->amr_dev, 0x9e, 1) 48765245Smsmith#endif 48865245Smsmith 48965245Smsmith/******************************************************************************** 49065245Smsmith ******************************************************************************** 49165245Smsmith "Standard" old-style ASIC bridge interface 49265245Smsmith ******************************************************************************** 49365245Smsmith ********************************************************************************/ 49465245Smsmith 49565245Smsmith/* 49665245Smsmith * I/O registers 49765245Smsmith */ 49865245Smsmith#define AMR_SCMD 0x10 /* command/ack register (write) */ 49965245Smsmith#define AMR_SMBOX_BUSY 0x10 /* mailbox status (read) */ 50065245Smsmith#define AMR_STOGGLE 0x11 /* interrupt enable bit here */ 50165245Smsmith#define AMR_SMBOX_0 0x14 /* mailbox physical address low byte */ 50265245Smsmith#define AMR_SMBOX_1 0x15 50365245Smsmith#define AMR_SMBOX_2 0x16 50465245Smsmith#define AMR_SMBOX_3 0x17 /* high byte */ 50565245Smsmith#define AMR_SMBOX_ENABLE 0x18 /* atomic mailbox address enable */ 50665245Smsmith#define AMR_SINTR 0x1a /* interrupt status */ 50765245Smsmith 50865245Smsmith/* 50965245Smsmith * I/O magic numbers 51065245Smsmith */ 51165245Smsmith#define AMR_SCMD_POST 0x10 /* -> SCMD to initiate action on mailbox */ 51265245Smsmith#define AMR_SCMD_ACKINTR 0x08 /* -> SCMD to ack mailbox retrieved */ 51365245Smsmith#define AMR_STOGL_IENABLE 0xc0 /* in STOGGLE */ 51465245Smsmith#define AMR_SINTR_VALID 0x40 /* in SINTR */ 51565245Smsmith#define AMR_SMBOX_BUSYFLAG 0x10 /* in SMBOX_BUSY */ 51665245Smsmith#define AMR_SMBOX_ADDR 0x00 /* -> SMBOX_ENABLE */ 51765245Smsmith 51865245Smsmith/* 51965245Smsmith * Initialisation status 52065245Smsmith */ 52165245Smsmith#define AMR_SINIT_ABEND 0xee /* init abnormal terminated */ 52265245Smsmith#define AMR_SINIT_NOMEM 0xca /* insufficient memory */ 52365245Smsmith#define AMR_SINIT_CACHEFLUSH 0xbb /* firmware flushing cache */ 52465245Smsmith#define AMR_SINIT_INPROG 0x11 /* init in progress */ 52565245Smsmith#define AMR_SINIT_SPINUP 0x22 /* firmware spinning drives */ 52665245Smsmith#define AMR_SINIT_DONE 0x99 /* init successfully done */ 52765245Smsmith 52865245Smsmith/* 52965245Smsmith * I/O primitives 53065245Smsmith */ 53165245Smsmith#define AMR_SPUT_ISTAT(sc, val) bus_space_write_1(sc->amr_btag, sc->amr_bhandle, AMR_SINTR, val) 53265245Smsmith#define AMR_SGET_ISTAT(sc) bus_space_read_1 (sc->amr_btag, sc->amr_bhandle, AMR_SINTR) 53365245Smsmith#define AMR_SACK_INTERRUPT(sc) bus_space_write_1(sc->amr_btag, sc->amr_bhandle, AMR_SCMD, AMR_SCMD_ACKINTR) 53465245Smsmith#define AMR_SPOST_COMMAND(sc) bus_space_write_1(sc->amr_btag, sc->amr_bhandle, AMR_SCMD, AMR_SCMD_POST) 53565245Smsmith#define AMR_SGET_MBSTAT(sc) bus_space_read_1 (sc->amr_btag, sc->amr_bhandle, AMR_SMBOX_BUSY) 53665245Smsmith#define AMR_SENABLE_INTR(sc) \ 53765245Smsmith bus_space_write_1(sc->amr_btag, sc->amr_bhandle, AMR_STOGGLE, \ 53865245Smsmith bus_space_read_1(sc->amr_btag, sc->amr_bhandle, AMR_STOGGLE) | AMR_STOGL_IENABLE) 53965245Smsmith#define AMR_SDISABLE_INTR(sc) \ 54065245Smsmith bus_space_write_1(sc->amr_btag, sc->amr_bhandle, AMR_STOGGLE, \ 54165245Smsmith bus_space_read_1(sc->amr_btag, sc->amr_bhandle, AMR_STOGGLE) & ~AMR_STOGL_IENABLE) 54265245Smsmith#define AMR_SBYTE_SET(sc, reg, val) bus_space_write_1(sc->amr_btag, sc->amr_bhandle, reg, val) 54365245Smsmith 54465245Smsmith#ifdef AMR_BOARD_INIT 54565245Smsmith#define AMR_SRESET(sc) bus_space_write_1(sc->amr_btag, sc->amr_bhandle, 0, 0x80) 54665245Smsmith#define AMR_SGET_INITSTATUS(sc) bus_space_read_1 (sc->amr_btag, sc->amr_bhandle, AMR_SMBOX_ENABLE) 54765245Smsmith#define AMR_SGET_FAILDRIVE(sc) bus_space_read_1 (sc->amr_btag, sc->amr_bhandle, AMR_SMBOX_ENABLE + 1) 54865245Smsmith#define AMR_SGET_INITCHAN(sc) bus_space_read_1 (sc->amr_btag, sc->amr_bhandle, AMR_SMBOX_ENABLE + 2) 54965245Smsmith#define AMR_SGET_INITTARG(sc) bus_space_read_1 (sc->amr_btag, sc->amr_bhandle, AMR_SMBOX_ENABLE + 3) 55065245Smsmith#endif 55165245Smsmith 55287796Sjhb#endif /* _KERNEL */ 553