1 /* 2 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 /* 7 * Copyright (c) 2006 8 * Damien Bergamini <damien.bergamini@free.fr> 9 * 10 * Permission to use, copy, modify, and distribute this software for any 11 * purpose with or without fee is hereby granted, provided that the above 12 * copyright notice and this permission notice appear in all copies. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 21 */ 22 23 #ifndef _WPIREG_H_ 24 #define _WPIREG_H_ 25 26 #pragma ident "%Z%%M% %I% %E% SMI" 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 #define WPI_TX_RING_COUNT 256 33 #define WPI_SVC_RING_COUNT 256 34 #define WPI_CMD_RING_COUNT 256 35 #define WPI_RX_RING_COUNT 64 36 37 /* 38 * Rings must be aligned on a four 4K-pages boundary. 39 * I had a hard time figuring this out. 40 */ 41 #define WPI_RING_DMA_ALIGN 0x4000 42 43 /* 44 * maximum scatter/gather 45 */ 46 #define WPI_MAX_SCATTER 4 47 48 /* 49 * Control and status registers. 50 */ 51 #define WPI_HWCONFIG 0x000 52 #define WPI_INTR 0x008 53 #define WPI_MASK 0x00c 54 #define WPI_INTR_STATUS 0x010 55 #define WPI_GPIO_STATUS 0x018 56 #define WPI_RESET 0x020 57 #define WPI_GPIO_CTL 0x024 58 #define WPI_EEPROM_CTL 0x02c 59 #define WPI_EEPROM_STATUS 0x030 60 #define WPI_UCODE_CLR 0x05c 61 #define WPI_TEMPERATURE 0x060 62 #define WPI_CHICKEN 0x100 63 #define WPI_PLL_CTL 0x20c 64 #define WPI_FW_TARGET 0x410 65 #define WPI_WRITE_MEM_ADDR 0x444 66 #define WPI_READ_MEM_ADDR 0x448 67 #define WPI_WRITE_MEM_DATA 0x44c 68 #define WPI_READ_MEM_DATA 0x450 69 #define WPI_TX_WIDX 0x460 70 #define WPI_TX_CTL(qid) (0x940 + (qid) * 8) 71 #define WPI_TX_BASE(qid) (0x944 + (qid) * 8) 72 #define WPI_TX_DESC(qid) (0x980 + (qid) * 80) 73 #define WPI_RX_CONFIG 0xc00 74 #define WPI_RX_BASE 0xc04 75 #define WPI_RX_WIDX 0xc20 76 #define WPI_RX_RIDX_PTR 0xc24 77 #define WPI_RX_CTL 0xcc0 78 #define WPI_RX_STATUS 0xcc4 79 #define WPI_TX_CONFIG(qid) (0xd00 + (qid) * 32) 80 #define WPI_TX_CREDIT(qid) (0xd04 + (qid) * 32) 81 #define WPI_TX_STATE(qid) (0xd08 + (qid) * 32) 82 #define WPI_TX_BASE_PTR 0xe80 83 #define WPI_MSG_CONFIG 0xe88 84 #define WPI_TX_STATUS 0xe90 85 86 87 /* 88 * NIC internal memory offsets. 89 */ 90 #define WPI_MEM_MODE 0x2e00 91 #define WPI_MEM_RA 0x2e04 92 #define WPI_MEM_TXCFG 0x2e10 93 #define WPI_MEM_MAGIC4 0x2e14 94 #define WPI_MEM_MAGIC5 0x2e20 95 #define WPI_MEM_BYPASS1 0x2e2c 96 #define WPI_MEM_BYPASS2 0x2e30 97 #define WPI_MEM_CLOCK1 0x3004 98 #define WPI_MEM_CLOCK2 0x3008 99 #define WPI_MEM_POWER 0x300c 100 #define WPI_MEM_PCIDEV 0x3010 101 #define WPI_MEM_UCODE_CTL 0x3400 102 #define WPI_MEM_UCODE_SRC 0x3404 103 #define WPI_MEM_UCODE_DST 0x3408 104 #define WPI_MEM_UCODE_SIZE 0x340c 105 #define WPI_MEM_UCODE_BASE 0x3800 106 107 108 /* 109 * possible flags for register WPI_HWCONFIG 110 */ 111 #define WPI_HW_ALM_MB (1 << 8) 112 #define WPI_HW_ALM_MM (1 << 9) 113 #define WPI_HW_SKU_MRC (1 << 10) 114 #define WPI_HW_REV_D (1 << 11) 115 #define WPI_HW_TYPE_B (1 << 12) 116 117 /* 118 * possible flags for registers WPI_READ_MEM_ADDR/WPI_WRITE_MEM_ADDR 119 */ 120 #define WPI_MEM_4 ((sizeof (uint32_t) - 1) << 24) 121 122 /* 123 * possible values for WPI_FW_TARGET 124 */ 125 #define WPI_FW_TEXT 0x00000000 126 #define WPI_FW_DATA 0x00800000 127 128 /* 129 * possible flags for WPI_GPIO_STATUS 130 */ 131 #define WPI_POWERED (1 << 9) 132 133 /* 134 * possible flags for register WPI_RESET 135 */ 136 #define WPI_NEVO_RESET (1 << 0) 137 #define WPI_SW_RESET (1 << 7) 138 #define WPI_MASTER_DISABLED (1 << 8) 139 #define WPI_STOP_MASTER (1 << 9) 140 141 /* 142 * possible flags for register WPI_GPIO_CTL 143 */ 144 #define WPI_GPIO_CLOCK (1 << 0) 145 #define WPI_GPIO_INIT (1 << 2) 146 #define WPI_GPIO_MAC (1 << 3) 147 #define WPI_GPIO_SLEEP (1 << 4) 148 #define WPI_GPIO_PWR_STATUS 0x07000000 149 #define WPI_GPIO_PWR_SLEEP (4 << 24) 150 151 /* 152 * possible flags for register WPI_CHICKEN 153 */ 154 #define WPI_CHICKEN_RXNOLOS (1 << 23) 155 156 /* 157 * possible flags for register WPI_PLL_CTL 158 */ 159 #define WPI_PLL_INIT (1 << 24) 160 161 /* 162 * possible flags for register WPI_UCODE_CLR 163 */ 164 #define WPI_RADIO_OFF (1 << 1) 165 #define WPI_DISABLE_CMD (1 << 2) 166 167 /* 168 * possible flags for WPI_RX_STATUS 169 */ 170 #define WPI_RX_IDLE (1 << 24) 171 172 /* 173 * possible flags for register WPI_UC_CTL 174 */ 175 #define WPI_UC_RUN (1 << 30) 176 177 /* 178 * possible flags for register WPI_INTR_CSR 179 */ 180 #define WPI_ALIVE_INTR (1 << 0) 181 #define WPI_WAKEUP_INTR (1 << 1) 182 #define WPI_SW_ERROR (1 << 25) 183 #define WPI_TX_INTR (1 << 27) 184 #define WPI_HW_ERROR (1 << 29) 185 #define WPI_RX_INTR (((uint32_t)1) << 31) 186 187 #define WPI_INTR_MASK \ 188 (WPI_SW_ERROR | WPI_HW_ERROR | WPI_TX_INTR | WPI_RX_INTR | \ 189 WPI_ALIVE_INTR | WPI_WAKEUP_INTR) 190 191 /* 192 * possible flags for register WPI_TX_STATUS 193 */ 194 #define WPI_TX_IDLE(qid) (1 << ((qid) + 24) | 1 << ((qid) + 16)) 195 196 /* 197 * possible flags for register WPI_EEPROM_CTL 198 */ 199 #define WPI_EEPROM_READY (1 << 0) 200 201 /* 202 * possible flags for register WPI_EEPROM_STATUS 203 */ 204 #define WPI_EEPROM_VERSION 0x00000007 205 #define WPI_EEPROM_LOCKED 0x00000180 206 207 208 typedef struct wpi_shared { 209 uint32_t txbase[8]; 210 uint32_t next; 211 uint32_t reserved[2]; 212 } wpi_shared_t; 213 214 #define WPI_MAX_SEG_LEN 65520 215 typedef struct wpi_tx_desc { 216 uint32_t flags; 217 #define WPI_PAD32(x) (roundup(x, 4) - (x)) 218 219 struct { 220 uint32_t addr; 221 uint32_t len; 222 } segs[WPI_MAX_SCATTER]; 223 uint8_t reserved[28]; 224 } wpi_tx_desc_t; 225 226 typedef struct wpi_tx_stat { 227 uint8_t nrts; 228 uint8_t ntries; 229 uint8_t nkill; 230 uint8_t rate; 231 uint32_t duration; 232 uint32_t status; 233 } wpi_tx_stat_t; 234 235 typedef struct wpi_rx_desc { 236 uint32_t len; 237 uint8_t type; 238 #define WPI_UC_READY 1 239 #define WPI_RX_DONE 27 240 #define WPI_TX_DONE 28 241 #define WPI_START_SCAN 130 242 #define WPI_START_RESULT 131 243 #define WPI_STOP_SCAN 132 244 #define WPI_STATE_CHANGED 161 245 246 uint8_t flags; 247 uint8_t idx; 248 uint8_t qid; 249 } wpi_rx_desc_t; 250 251 typedef struct wpi_rx_stat { 252 uint8_t len; 253 #define WPI_STAT_MAXLEN 20 254 255 uint8_t id; 256 uint8_t rssi; /* received signal strength */ 257 #define WPI_RSSI_OFFSET 95 258 259 uint8_t agc; /* access gain control */ 260 uint16_t signal; 261 uint16_t noise; 262 } wpi_rx_stat_t; 263 264 typedef struct wpi_rx_head { 265 uint16_t chan; 266 uint16_t flags; 267 uint8_t reserved; 268 uint8_t rate; 269 uint16_t len; 270 } wpi_rx_head_t; 271 272 typedef struct wpi_rx_tail { 273 uint32_t flags; 274 #define WPI_RX_NO_CRC_ERR (1 << 0) 275 #define WPI_RX_NO_OVFL_ERR (1 << 1) 276 #define WPI_RX_NOERROR (WPI_RX_NO_CRC_ERR | WPI_RX_NO_OVFL_ERR) 277 278 uint64_t tstamp; 279 uint32_t tbeacon; 280 } wpi_rx_tail_t; 281 282 typedef struct wpi_tx_cmd { 283 uint8_t code; 284 #define WPI_CMD_CONFIGURE 16 285 #define WPI_CMD_ASSOCIATE 17 286 #define WPI_CMD_SET_WME 19 287 #define WPI_CMD_TSF 20 288 #define WPI_CMD_ADD_NODE 24 289 #define WPI_CMD_TX_DATA 28 290 #define WPI_CMD_MRR_SETUP 71 291 #define WPI_CMD_SET_LED 72 292 #define WPI_CMD_SET_POWER_MODE 119 293 #define WPI_CMD_SCAN 128 294 #define WPI_CMD_SET_BEACON 145 295 #define WPI_CMD_BLUETOOTH 155 296 #define WPI_CMD_TXPOWER 176 297 298 uint8_t flags; 299 uint8_t idx; 300 uint8_t qid; 301 uint8_t data[124]; 302 } wpi_tx_cmd_t; 303 304 /* 305 * structure for WPI_CMD_CONFIGURE 306 */ 307 typedef struct wpi_config { 308 uint8_t myaddr[IEEE80211_ADDR_LEN]; 309 uint16_t reserved1; 310 uint8_t bssid[IEEE80211_ADDR_LEN]; 311 uint16_t reserved2; 312 uint32_t reserved3[2]; 313 uint8_t mode; 314 #define WPI_MODE_HOSTAP 1 315 #define WPI_MODE_STA 3 316 #define WPI_MODE_IBSS 4 317 #define WPI_MODE_MONITOR 6 318 319 uint8_t reserved4[3]; 320 uint8_t ofdm_mask; 321 uint8_t cck_mask; 322 uint16_t state; 323 #define WPI_CONFIG_ASSOCIATED 4 324 325 uint32_t flags; 326 #define WPI_CONFIG_24GHZ (1 << 0) 327 #define WPI_CONFIG_CCK (1 << 1) 328 #define WPI_CONFIG_AUTO (1 << 2) 329 #define WPI_CONFIG_SHSLOT (1 << 4) 330 #define WPI_CONFIG_SHPREAMBLE (1 << 5) 331 #define WPI_CONFIG_NODIVERSITY (1 << 7) 332 #define WPI_CONFIG_ANTENNA_A (1 << 8) 333 #define WPI_CONFIG_ANTENNA_B (1 << 9) 334 #define WPI_CONFIG_TSF (1 << 15) 335 336 uint32_t filter; 337 #define WPI_FILTER_PROMISC (1 << 0) 338 #define WPI_FILTER_CTL (1 << 1) 339 #define WPI_FILTER_MULTICAST (1 << 2) 340 #define WPI_FILTER_NODECRYPT (1 << 3) 341 #define WPI_FILTER_BSS (1 << 5) 342 #define WPI_FILTER_BEACON (1 << 6) 343 344 uint8_t chan; 345 uint8_t reserved6[3]; 346 } wpi_config_t; 347 348 /* 349 * structure for command WPI_CMD_ASSOCIATE 350 */ 351 typedef struct wpi_assoc { 352 uint32_t flags; 353 uint32_t filter; 354 uint8_t ofdm_mask; 355 uint8_t cck_mask; 356 uint16_t reserved; 357 } wpi_assoc_t; 358 359 /* 360 * structure for command WPI_CMD_SET_WME 361 */ 362 typedef struct wpi_wme_setup { 363 uint32_t flags; 364 struct { 365 uint16_t cwmin; 366 uint16_t cwmax; 367 uint8_t aifsn; 368 uint8_t reserved; 369 uint16_t txop; 370 } ac[WME_NUM_AC]; 371 } wpi_wme_setup_t; 372 373 /* 374 * structure for command WPI_CMD_TSF 375 */ 376 typedef struct wpi_cmd_tsf { 377 uint64_t tstamp; 378 uint16_t bintval; 379 uint16_t atim; 380 uint32_t binitval; 381 uint16_t lintval; 382 uint16_t reserved; 383 } wpi_cmd_tsf_t; 384 385 /* 386 * structure for WPI_CMD_ADD_NODE 387 */ 388 typedef struct wpi_node { 389 uint8_t control; 390 #define WPI_NODE_UPDATE (1 << 0) 391 392 uint8_t reserved1[3]; 393 uint8_t bssid[IEEE80211_ADDR_LEN]; 394 uint16_t reserved2; 395 uint8_t id; 396 #define WPI_ID_BSS 0 397 #define WPI_ID_BROADCAST 24 398 399 uint8_t sta_mask; 400 uint16_t reserved3; 401 uint16_t key_flags; 402 uint8_t tkip; 403 uint8_t reserved4; 404 uint16_t ttak[5]; 405 uint16_t reserved5; 406 uint8_t key[16]; 407 uint32_t flags; 408 uint32_t mask; 409 uint16_t tid; 410 uint8_t rate; 411 uint8_t reserved6; 412 uint8_t add_imm; 413 uint8_t del_imm; 414 uint16_t add_imm_start; 415 } wpi_node_t; 416 417 /* 418 * structure for command WPI_CMD_TX_DATA 419 */ 420 typedef struct wpi_cmd_data { 421 uint16_t len; 422 uint16_t lnext; 423 uint32_t flags; 424 #define WPI_TX_NEED_RTS (1 << 1) 425 #define WPI_TX_NEED_ACK (1 << 3) 426 #define WPI_TX_FULL_TXOP (1 << 7) 427 #define WPI_TX_BT_DISABLE (1 << 12) 428 #define WPI_TX_AUTO_SEQ (1 << 13) 429 #define WPI_TX_INSERT_TSTAMP (1 << 16) 430 #define WPI_TX_CALIBRATION (1 << 17) 431 432 uint8_t rate; 433 uint8_t id; 434 uint8_t tid; 435 uint8_t security; 436 uint8_t key[16]; 437 uint8_t tkip[8]; 438 uint32_t fnext; 439 uint32_t lifetime; 440 uint8_t ofdm_mask; 441 uint8_t cck_mask; 442 uint8_t rts_ntries; 443 uint8_t data_ntries; 444 uint16_t timeout; 445 uint16_t txop; 446 } wpi_cmd_data_t; 447 448 /* 449 * structure for command WPI_CMD_SET_BEACON 450 */ 451 typedef struct wpi_cmd_beacon { 452 uint16_t len; 453 uint16_t reserved1; 454 uint32_t flags; /* same as wpi_cmd_data */ 455 uint8_t rate; 456 uint8_t id; 457 uint8_t reserved2[30]; 458 uint32_t lifetime; 459 uint8_t ofdm_mask; 460 uint8_t cck_mask; 461 uint16_t reserved3[3]; 462 uint16_t tim; 463 uint8_t timsz; 464 uint8_t reserved4; 465 struct ieee80211_frame wh; 466 } wpi_cmd_beacon_t; 467 468 /* 469 * structure for WPI_CMD_MRR_SETUP 470 */ 471 typedef struct wpi_mrr_setup { 472 uint32_t which; 473 #define WPI_MRR_CTL 0 474 #define WPI_MRR_DATA 1 475 476 struct { 477 uint8_t signal; 478 uint8_t flags; 479 uint8_t ntries; 480 uint8_t next; 481 #define WPI_OFDM6 0 482 #define WPI_OFDM54 7 483 #define WPI_CCK1 8 484 #define WPI_CCK11 11 485 486 } rates[WPI_CCK11 + 1]; 487 } wpi_mrr_setup_t; 488 489 /* 490 * structure for WPI_CMD_SET_LED 491 */ 492 typedef struct wpi_cmd_led { 493 uint32_t unit; /* multiplier (in usecs) */ 494 uint8_t which; 495 #define WPI_LED_ACTIVITY 1 496 #define WPI_LED_LINK 2 497 498 uint8_t off; 499 uint8_t on; 500 uint8_t reserved; 501 } wpi_cmd_led_t; 502 503 /* 504 * structure for WPI_CMD_SET_POWER_MODE 505 */ 506 typedef struct wpi_power { 507 uint32_t flags; 508 uint32_t rx_timeout; 509 uint32_t tx_timeout; 510 uint32_t sleep[5]; 511 } wpi_power_t; 512 513 /* 514 * structure for command WPI_CMD_SCAN 515 */ 516 typedef struct wpi_scan_hdr { 517 uint8_t len; 518 uint8_t first; 519 uint8_t reserved1; 520 uint8_t nchan; 521 uint16_t quiet; 522 uint16_t threshold; 523 uint32_t reserved2[3]; 524 uint32_t filter; 525 uint32_t reserved3; 526 uint16_t pbrlen; 527 uint16_t reserved4; 528 uint32_t magic1; 529 uint8_t rate; 530 uint8_t id; 531 uint16_t reserved5; 532 uint32_t reserved6[7]; 533 uint32_t mask; 534 uint32_t reserved7[2]; 535 uint8_t reserved8; 536 uint8_t esslen; 537 uint8_t essid[134]; 538 539 /* followed by probe request body */ 540 /* followed by nchan x wpi_scan_chan */ 541 } wpi_scan_hdr_t; 542 543 typedef struct wpi_scan_chan { 544 uint8_t flags; 545 uint8_t chan; 546 uint16_t magic; /* XXX */ 547 uint16_t active; /* dwell time */ 548 uint16_t passive; /* dwell time */ 549 } wpi_scan_chan_t; 550 551 /* 552 * structure for WPI_CMD_BLUETOOTH 553 */ 554 typedef struct wpi_bluetooth { 555 uint8_t flags; 556 uint8_t lead; 557 uint8_t kill; 558 uint8_t reserved; 559 uint32_t ack; 560 uint32_t cts; 561 } wpi_bluetooth_t; 562 563 /* 564 * structure for command WPI_CMD_TXPOWER 565 */ 566 typedef struct wpi_txpower { 567 uint32_t reserved1; 568 uint16_t pwr1[14]; 569 uint32_t reserved2[2]; 570 uint16_t pwr2[14]; 571 uint32_t reserved3[2]; 572 } wpi_txpower_t; 573 574 575 /* 576 * firmware image header 577 */ 578 typedef struct wpi_firmware_hdr { 579 uint32_t version; 580 uint32_t textsz; 581 uint32_t datasz; 582 uint32_t bootsz; 583 } wpi_firmware_hdr_t; 584 585 /* 586 * structure for WPI_UC_READY notification 587 */ 588 typedef struct wpi_ucode_info { 589 uint32_t version; 590 uint8_t revision[8]; 591 uint8_t type; 592 uint8_t subtype; 593 uint16_t reserved; 594 uint32_t logptr; 595 uint32_t errorptr; 596 uint32_t timestamp; 597 uint32_t valid; 598 } wpi_ucode_info_t; 599 600 /* 601 * structure for WPI_START_SCAN notification 602 */ 603 typedef struct wpi_start_scan { 604 uint64_t tstamp; 605 uint32_t tbeacon; 606 uint8_t chan; 607 uint8_t band; 608 uint16_t reserved; 609 uint32_t status; 610 } wpi_start_scan_t; 611 612 613 #define WPI_EEPROM_MAC 0x015 614 #define WPI_EEPROM_REVISION 0x035 615 #define WPI_EEPROM_CAPABILITIES 0x045 616 #define WPI_EEPROM_TYPE 0x04a 617 #define WPI_EEPROM_PWR1 0x1ae 618 #define WPI_EEPROM_PWR2 0x1bc 619 620 #define WPI_READ(sc, reg) \ 621 ddi_get32((sc)->sc_handle, (uint32_t *)((sc)->sc_base + (reg))) 622 623 #define WPI_WRITE(sc, reg, val) \ 624 ddi_put32((sc)->sc_handle, (uint32_t *)((sc)->sc_base + (reg)), (val)) 625 626 #define WPI_WRITE_REGION_4(sc, offset, datap, count) { \ 627 uint32_t *p = (datap); \ 628 uint32_t s = (offset); \ 629 uint32_t c = (count); \ 630 while (--c > 0) { \ 631 ddi_put32((sc)->sc_handle, \ 632 (uint32_t *)((sc)->sc_base + s), *p); \ 633 p++; \ 634 s += 4; \ 635 } \ 636 } 637 638 #ifdef __cplusplus 639 } 640 #endif 641 642 #endif /* _WPIREG_H_ */ 643