1 1.3.6.2 bouyer /* $NetBSD: btlreg.h,v 1.3.6.2 2000/11/20 20:00:33 bouyer Exp $ */ 2 1.3.6.2 bouyer 3 1.3.6.2 bouyer typedef u_int8_t physaddr[4]; 4 1.3.6.2 bouyer typedef u_int8_t physlen[4]; 5 1.3.6.2 bouyer #define ltophys _lto4l 6 1.3.6.2 bouyer #define phystol _4ltol 7 1.3.6.2 bouyer 8 1.3.6.2 bouyer /* 9 1.3.6.2 bouyer * I/O port offsets 10 1.3.6.2 bouyer */ 11 1.3.6.2 bouyer #define BT_CTRL_PORT 0 /* control (wo) */ 12 1.3.6.2 bouyer #define BT_STAT_PORT 0 /* status (ro) */ 13 1.3.6.2 bouyer #define BT_CMD_PORT 1 /* command (wo) */ 14 1.3.6.2 bouyer #define BT_DATA_PORT 1 /* data (ro) */ 15 1.3.6.2 bouyer #define BT_INTR_PORT 2 /* interrupt status (ro) */ 16 1.3.6.2 bouyer 17 1.3.6.2 bouyer /* 18 1.3.6.2 bouyer * BT_CTRL bits 19 1.3.6.2 bouyer */ 20 1.3.6.2 bouyer #define BT_CTRL_HRST 0x80 /* Hardware reset */ 21 1.3.6.2 bouyer #define BT_CTRL_SRST 0x40 /* Software reset */ 22 1.3.6.2 bouyer #define BT_CTRL_IRST 0x20 /* Interrupt reset */ 23 1.3.6.2 bouyer #define BT_CTRL_SCRST 0x10 /* SCSI bus reset */ 24 1.3.6.2 bouyer 25 1.3.6.2 bouyer /* 26 1.3.6.2 bouyer * BT_STAT bits 27 1.3.6.2 bouyer */ 28 1.3.6.2 bouyer #define BT_STAT_STST 0x80 /* Self test in Progress */ 29 1.3.6.2 bouyer #define BT_STAT_DIAGF 0x40 /* Diagnostic Failure */ 30 1.3.6.2 bouyer #define BT_STAT_INIT 0x20 /* Mbx Init required */ 31 1.3.6.2 bouyer #define BT_STAT_IDLE 0x10 /* Host Adapter Idle */ 32 1.3.6.2 bouyer #define BT_STAT_CDF 0x08 /* cmd/data out port full */ 33 1.3.6.2 bouyer #define BT_STAT_DF 0x04 /* Data in port full */ 34 1.3.6.2 bouyer #define BT_STAT_INVDCMD 0x01 /* Invalid command */ 35 1.3.6.2 bouyer 36 1.3.6.2 bouyer /* 37 1.3.6.2 bouyer * BT_CMD opcodes 38 1.3.6.2 bouyer */ 39 1.3.6.2 bouyer #define BT_NOP 0x00 /* No operation */ 40 1.3.6.2 bouyer #define BT_MBX_INIT 0x01 /* Mbx initialization */ 41 1.3.6.2 bouyer #define BT_START_SCSI 0x02 /* start scsi command */ 42 1.3.6.2 bouyer #define BT_INQUIRE_REVISION 0x04 /* Adapter Inquiry */ 43 1.3.6.2 bouyer #define BT_MBO_INTR_EN 0x05 /* Enable MBO available interrupt */ 44 1.3.6.2 bouyer #if 0 45 1.3.6.2 bouyer #define BT_SEL_TIMEOUT_SET 0x06 /* set selection time-out */ 46 1.3.6.2 bouyer #define BT_BUS_ON_TIME_SET 0x07 /* set bus-on time */ 47 1.3.6.2 bouyer #define BT_BUS_OFF_TIME_SET 0x08 /* set bus-off time */ 48 1.3.6.2 bouyer #define BT_SPEED_SET 0x09 /* set transfer speed */ 49 1.3.6.2 bouyer #endif 50 1.3.6.2 bouyer #define BT_INQUIRE_DEVICES 0x0a /* return installed devices 0-7 */ 51 1.3.6.2 bouyer #define BT_INQUIRE_CONFIG 0x0b /* return configuration data */ 52 1.3.6.2 bouyer #define BT_TARGET_EN 0x0c /* enable target mode */ 53 1.3.6.2 bouyer #define BT_INQUIRE_SETUP 0x0d /* return setup data */ 54 1.3.6.2 bouyer #define BT_ECHO 0x1e /* Echo command data */ 55 1.3.6.2 bouyer #define BT_INQUIRE_DEVICES_2 0x23 /* return installed devices 8-15 */ 56 1.3.6.2 bouyer #define BT_MBX_INIT_EXTENDED 0x81 /* Mbx initialization */ 57 1.3.6.2 bouyer #define BT_INQUIRE_REVISION_3 0x84 /* Get 3rd firmware version byte */ 58 1.3.6.2 bouyer #define BT_INQUIRE_REVISION_4 0x85 /* Get 4th firmware version byte */ 59 1.3.6.2 bouyer #define BT_INQUIRE_MODEL 0x8b /* Get hardware ID and revision */ 60 1.3.6.2 bouyer #define BT_INQUIRE_PERIOD 0x8c /* Get synchronous period */ 61 1.3.6.2 bouyer #define BT_INQUIRE_EXTENDED 0x8d /* Adapter Setup Inquiry */ 62 1.3.6.2 bouyer #define BT_ROUND_ROBIN 0x8f /* Enable/Disable(default) round robin */ 63 1.3.6.2 bouyer 64 1.3.6.2 bouyer /* 65 1.3.6.2 bouyer * BT_INTR bits 66 1.3.6.2 bouyer */ 67 1.3.6.2 bouyer #define BT_INTR_ANYINTR 0x80 /* Any interrupt */ 68 1.3.6.2 bouyer #define BT_INTR_SCRD 0x08 /* SCSI reset detected */ 69 1.3.6.2 bouyer #define BT_INTR_HACC 0x04 /* Command complete */ 70 1.3.6.2 bouyer #define BT_INTR_MBOA 0x02 /* MBX out empty */ 71 1.3.6.2 bouyer #define BT_INTR_MBIF 0x01 /* MBX in full */ 72 1.3.6.2 bouyer 73 1.3.6.2 bouyer struct bt_mbx_out { 74 1.3.6.2 bouyer physaddr ccb_addr; 75 1.3.6.2 bouyer u_char dummy[3]; 76 1.3.6.2 bouyer u_char cmd; 77 1.3.6.2 bouyer }; 78 1.3.6.2 bouyer 79 1.3.6.2 bouyer struct bt_mbx_in { 80 1.3.6.2 bouyer physaddr ccb_addr; 81 1.3.6.2 bouyer u_char dummy[3]; 82 1.3.6.2 bouyer u_char stat; 83 1.3.6.2 bouyer }; 84 1.3.6.2 bouyer 85 1.3.6.2 bouyer /* 86 1.3.6.2 bouyer * mbo.cmd values 87 1.3.6.2 bouyer */ 88 1.3.6.2 bouyer #define BT_MBO_FREE 0x0 /* MBO entry is free */ 89 1.3.6.2 bouyer #define BT_MBO_START 0x1 /* MBO activate entry */ 90 1.3.6.2 bouyer #define BT_MBO_ABORT 0x2 /* MBO abort entry */ 91 1.3.6.2 bouyer 92 1.3.6.2 bouyer /* 93 1.3.6.2 bouyer * mbi.stat values 94 1.3.6.2 bouyer */ 95 1.3.6.2 bouyer #define BT_MBI_FREE 0x0 /* MBI entry is free */ 96 1.3.6.2 bouyer #define BT_MBI_OK 0x1 /* completed without error */ 97 1.3.6.2 bouyer #define BT_MBI_ABORT 0x2 /* aborted ccb */ 98 1.3.6.2 bouyer #define BT_MBI_UNKNOWN 0x3 /* Tried to abort invalid CCB */ 99 1.3.6.2 bouyer #define BT_MBI_ERROR 0x4 /* Completed with error */ 100 1.3.6.2 bouyer 101 1.3.6.2 bouyer #if defined(BIG_DMA) 102 1.3.6.2 bouyer #define BT_NSEG 2048 /* Number of scatter gather segments - to much vm */ 103 1.3.6.2 bouyer #else 104 1.3.6.2 bouyer #define BT_NSEG (MAXPHYS / NBPG) 105 1.3.6.2 bouyer #endif /* BIG_DMA */ 106 1.3.6.2 bouyer 107 1.3.6.2 bouyer struct bt_scat_gath { 108 1.3.6.2 bouyer physlen seg_len; 109 1.3.6.2 bouyer physaddr seg_addr; 110 1.3.6.2 bouyer }; 111 1.3.6.2 bouyer 112 1.3.6.2 bouyer struct bt_ccb { 113 1.3.6.2 bouyer u_char opcode; 114 1.3.6.2 bouyer u_char:3, data_in:1, data_out:1,:3; 115 1.3.6.2 bouyer u_char scsi_cmd_length; 116 1.3.6.2 bouyer u_char req_sense_length; 117 1.3.6.2 bouyer /*------------------------------------longword boundary */ 118 1.3.6.2 bouyer physlen data_length; 119 1.3.6.2 bouyer /*------------------------------------longword boundary */ 120 1.3.6.2 bouyer physaddr data_addr; 121 1.3.6.2 bouyer /*------------------------------------longword boundary */ 122 1.3.6.2 bouyer u_char dummy1[2]; 123 1.3.6.2 bouyer u_char host_stat; 124 1.3.6.2 bouyer u_char target_stat; 125 1.3.6.2 bouyer /*------------------------------------longword boundary */ 126 1.3.6.2 bouyer u_char target; 127 1.3.6.2 bouyer u_char lun; 128 1.3.6.2 bouyer struct scsi_generic scsi_cmd; 129 1.3.6.2 bouyer u_char dummy2[1]; 130 1.3.6.2 bouyer u_char link_id; 131 1.3.6.2 bouyer /*------------------------------------longword boundary */ 132 1.3.6.2 bouyer physaddr link_addr; 133 1.3.6.2 bouyer /*------------------------------------longword boundary */ 134 1.3.6.2 bouyer physaddr sense_ptr; 135 1.3.6.2 bouyer /*-----end of HW fields-----------------------longword boundary */ 136 1.3.6.2 bouyer struct scsipi_sense_data scsi_sense; 137 1.3.6.2 bouyer /*------------------------------------longword boundary */ 138 1.3.6.2 bouyer struct bt_scat_gath scat_gath[BT_NSEG]; 139 1.3.6.2 bouyer /*------------------------------------longword boundary */ 140 1.3.6.2 bouyer TAILQ_ENTRY(bt_ccb) chain; 141 1.3.6.2 bouyer struct bt_ccb *nexthash; 142 1.3.6.2 bouyer long hashkey; 143 1.3.6.2 bouyer struct scsipi_xfer *xs; /* the scsi_xfer for this cmd */ 144 1.3.6.2 bouyer int flags; 145 1.3.6.2 bouyer #define CCB_ALLOC 0x01 146 1.3.6.2 bouyer #define CCB_ABORT 0x02 147 1.3.6.2 bouyer #ifdef BTDIAG 148 1.3.6.2 bouyer #define CCB_SENDING 0x04 149 1.3.6.2 bouyer #endif 150 1.3.6.2 bouyer int timeout; 151 1.3.6.2 bouyer }; 152 1.3.6.2 bouyer 153 1.3.6.2 bouyer struct bt_buf { 154 1.3.6.2 bouyer TAILQ_ENTRY(bt_buf) chain; 155 1.3.6.2 bouyer char buf[4096 - 2 * sizeof(struct bt_buf *)]; 156 1.3.6.2 bouyer }; 157 1.3.6.2 bouyer 158 1.3.6.2 bouyer /* 159 1.3.6.2 bouyer * opcode fields 160 1.3.6.2 bouyer */ 161 1.3.6.2 bouyer #define BT_INITIATOR_CCB 0x00 /* SCSI Initiator CCB */ 162 1.3.6.2 bouyer #define BT_TARGET_CCB 0x01 /* SCSI Target CCB */ 163 1.3.6.2 bouyer #define BT_INIT_SCAT_GATH_CCB 0x02 /* SCSI Initiator with scattter gather */ 164 1.3.6.2 bouyer #define BT_RESET_CCB 0x81 /* SCSI Bus reset */ 165 1.3.6.2 bouyer 166 1.3.6.2 bouyer /* 167 1.3.6.2 bouyer * bt_ccb.host_stat values 168 1.3.6.2 bouyer */ 169 1.3.6.2 bouyer #define BT_OK 0x00 /* cmd ok */ 170 1.3.6.2 bouyer #define BT_LINK_OK 0x0a /* Link cmd ok */ 171 1.3.6.2 bouyer #define BT_LINK_IT 0x0b /* Link cmd ok + int */ 172 1.3.6.2 bouyer #define BT_SEL_TIMEOUT 0x11 /* Selection time out */ 173 1.3.6.2 bouyer #define BT_OVER_UNDER 0x12 /* Data over/under run */ 174 1.3.6.2 bouyer #define BT_BUS_FREE 0x13 /* Bus dropped at unexpected time */ 175 1.3.6.2 bouyer #define BT_INV_BUS 0x14 /* Invalid bus phase/sequence */ 176 1.3.6.2 bouyer #define BT_BAD_MBO 0x15 /* Incorrect MBO cmd */ 177 1.3.6.2 bouyer #define BT_BAD_CCB 0x16 /* Incorrect ccb opcode */ 178 1.3.6.2 bouyer #define BT_BAD_LINK 0x17 /* Not same values of LUN for links */ 179 1.3.6.2 bouyer #define BT_INV_TARGET 0x18 /* Invalid target direction */ 180 1.3.6.2 bouyer #define BT_CCB_DUP 0x19 /* Duplicate CCB received */ 181 1.3.6.2 bouyer #define BT_INV_CCB 0x1a /* Invalid CCB or segment list */ 182 1.3.6.2 bouyer 183 1.3.6.2 bouyer struct bt_extended_inquire { 184 1.3.6.2 bouyer struct { 185 1.3.6.2 bouyer u_char opcode; 186 1.3.6.2 bouyer u_char len; 187 1.3.6.2 bouyer } cmd; 188 1.3.6.2 bouyer struct { 189 1.3.6.2 bouyer u_char bus_type; /* Type of bus connected to */ 190 1.3.6.2 bouyer #define BT_BUS_TYPE_24BIT 'A' /* ISA bus */ 191 1.3.6.2 bouyer #define BT_BUS_TYPE_32BIT 'E' /* EISA/VLB/PCI bus */ 192 1.3.6.2 bouyer #define BT_BUS_TYPE_MCA 'M' /* MicroChannel bus */ 193 1.3.6.2 bouyer u_char bios_address; /* Address of adapter BIOS */ 194 1.3.6.2 bouyer u_short max_segment; /* ? */ 195 1.3.6.2 bouyer } reply; 196 1.3.6.2 bouyer }; 197 1.3.6.2 bouyer 198 1.3.6.2 bouyer struct bt_config { 199 1.3.6.2 bouyer struct { 200 1.3.6.2 bouyer u_char opcode; 201 1.3.6.2 bouyer } cmd; 202 1.3.6.2 bouyer struct { 203 1.3.6.2 bouyer u_char chan; 204 1.3.6.2 bouyer u_char intr; 205 1.3.6.2 bouyer u_char scsi_dev:3; 206 1.3.6.2 bouyer u_char :5; 207 1.3.6.2 bouyer } reply; 208 1.3.6.2 bouyer }; 209 1.3.6.2 bouyer 210 1.3.6.2 bouyer struct bt_toggle { 211 1.3.6.2 bouyer struct { 212 1.3.6.2 bouyer u_char opcode; 213 1.3.6.2 bouyer u_char enable; 214 1.3.6.2 bouyer } cmd; 215 1.3.6.2 bouyer }; 216 1.3.6.2 bouyer 217 1.3.6.2 bouyer struct bt_mailbox { 218 1.3.6.2 bouyer struct { 219 1.3.6.2 bouyer u_char opcode; 220 1.3.6.2 bouyer u_char nmbx; 221 1.3.6.2 bouyer physaddr addr; 222 1.3.6.2 bouyer } cmd; 223 1.3.6.2 bouyer }; 224 1.3.6.2 bouyer 225 1.3.6.2 bouyer struct bt_model { 226 1.3.6.2 bouyer struct { 227 1.3.6.2 bouyer u_char opcode; 228 1.3.6.2 bouyer u_char len; 229 1.3.6.2 bouyer } cmd; 230 1.3.6.2 bouyer struct { 231 1.3.6.2 bouyer u_char id[4]; /* i.e bt742a -> '7','4','2','A' */ 232 1.3.6.2 bouyer u_char version[2]; /* i.e Board Revision 'H' -> 'H', 0x00 */ 233 1.3.6.2 bouyer } reply; 234 1.3.6.2 bouyer }; 235 1.3.6.2 bouyer 236 1.3.6.2 bouyer struct bt_revision { 237 1.3.6.2 bouyer struct { 238 1.3.6.2 bouyer u_char opcode; 239 1.3.6.2 bouyer } cmd; 240 1.3.6.2 bouyer struct { 241 1.3.6.2 bouyer u_char board_type; 242 1.3.6.2 bouyer u_char custom_feature; 243 1.3.6.2 bouyer char firm_revision; 244 1.3.6.2 bouyer u_char firm_version; 245 1.3.6.2 bouyer } reply; 246 1.3.6.2 bouyer }; 247 1.3.6.2 bouyer 248 1.3.6.2 bouyer struct bt_digit { 249 1.3.6.2 bouyer struct { 250 1.3.6.2 bouyer u_char opcode; 251 1.3.6.2 bouyer } cmd; 252 1.3.6.2 bouyer struct { 253 1.3.6.2 bouyer u_char digit; 254 1.3.6.2 bouyer } reply; 255 1.3.6.2 bouyer }; 256 1.3.6.2 bouyer 257 1.3.6.2 bouyer struct bt_devices { 258 1.3.6.2 bouyer struct { 259 1.3.6.2 bouyer u_char opcode; 260 1.3.6.2 bouyer } cmd; 261 1.3.6.2 bouyer struct { 262 1.3.6.2 bouyer u_char junk[8]; 263 1.3.6.2 bouyer } reply; 264 1.3.6.2 bouyer }; 265 1.3.6.2 bouyer 266 1.3.6.2 bouyer struct bt_setup { 267 1.3.6.2 bouyer struct { 268 1.3.6.2 bouyer u_char opcode; 269 1.3.6.2 bouyer u_char len; 270 1.3.6.2 bouyer } cmd; 271 1.3.6.2 bouyer struct { 272 1.3.6.2 bouyer u_char sync_neg:1; 273 1.3.6.2 bouyer u_char parity:1; 274 1.3.6.2 bouyer u_char :6; 275 1.3.6.2 bouyer u_char speed; 276 1.3.6.2 bouyer u_char bus_on; 277 1.3.6.2 bouyer u_char bus_off; 278 1.3.6.2 bouyer u_char num_mbx; 279 1.3.6.2 bouyer u_char mbx[3]; /*XXX */ 280 1.3.6.2 bouyer /* doesn't make sense with 32bit addresses */ 281 1.3.6.2 bouyer struct { 282 1.3.6.2 bouyer u_char offset:4; 283 1.3.6.2 bouyer u_char period:3; 284 1.3.6.2 bouyer u_char valid:1; 285 1.3.6.2 bouyer } sync[8]; 286 1.3.6.2 bouyer u_char disc_sts; 287 1.3.6.2 bouyer } reply; 288 1.3.6.2 bouyer }; 289 1.3.6.2 bouyer 290 1.3.6.2 bouyer struct bt_period { 291 1.3.6.2 bouyer struct { 292 1.3.6.2 bouyer u_char opcode; 293 1.3.6.2 bouyer u_char len; 294 1.3.6.2 bouyer } cmd; 295 1.3.6.2 bouyer struct { 296 1.3.6.2 bouyer u_char period[8]; 297 1.3.6.2 bouyer } reply; 298 1.3.6.2 bouyer }; 299 1.3.6.2 bouyer 300 1.3.6.2 bouyer #define INT9 0x01 301 1.3.6.2 bouyer #define INT10 0x02 302 1.3.6.2 bouyer #define INT11 0x04 303 1.3.6.2 bouyer #define INT12 0x08 304 1.3.6.2 bouyer #define INT14 0x20 305 1.3.6.2 bouyer #define INT15 0x40 306 1.3.6.2 bouyer 307 1.3.6.2 bouyer #define EISADMA 0x00 308 1.3.6.2 bouyer #define CHAN0 0x01 309 1.3.6.2 bouyer #define CHAN5 0x20 310 1.3.6.2 bouyer #define CHAN6 0x40 311 1.3.6.2 bouyer #define CHAN7 0x80 312