Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ath5k: Cleanups v2 + add kerneldoc on all hw functions

No functional changes

Add kernel doc for all ath5k_hw_* functions and strcucts. Also do some cleanup,
rename ath5k_hw_init_beacon to ath5k_hw_init_beacon_timers, remove an unused
variable from ath5k_hw_pcu_init and a few obsolete macros, mostly related to XR.

Signed-off-by: Nick Kossifidis <mickflemm@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Nick Kossifidis and committed by
John W. Linville
c47faa36 1846ac3d

+1945 -726
+56 -30
drivers/net/wireless/ath/ath5k/ani.c
··· 27 27 * or reducing sensitivity as necessary. 28 28 * 29 29 * The parameters are: 30 + * 30 31 * - "noise immunity" 32 + * 31 33 * - "spur immunity" 34 + * 32 35 * - "firstep level" 36 + * 33 37 * - "OFDM weak signal detection" 38 + * 34 39 * - "CCK weak signal detection" 35 40 * 36 41 * Basically we look at the amount of ODFM and CCK timing errors we get and then 37 42 * raise or lower immunity accordingly by setting one or more of these 38 43 * parameters. 44 + * 39 45 * Newer chipsets have PHY error counters in hardware which will generate a MIB 40 46 * interrupt when they overflow. Older hardware has too enable PHY error frames 41 47 * by setting a RX flag and then count every single PHY error. When a specified ··· 51 45 */ 52 46 53 47 54 - /*** ANI parameter control ***/ 48 + /***********************\ 49 + * ANI parameter control * 50 + \***********************/ 55 51 56 52 /** 57 53 * ath5k_ani_set_noise_immunity_level() - Set noise immunity level 58 - * 54 + * @ah: The &struct ath5k_hw 59 55 * @level: level between 0 and @ATH5K_ANI_MAX_NOISE_IMM_LVL 60 56 */ 61 57 void ··· 99 91 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level); 100 92 } 101 93 102 - 103 94 /** 104 95 * ath5k_ani_set_spur_immunity_level() - Set spur immunity level 105 - * 96 + * @ah: The &struct ath5k_hw 106 97 * @level: level between 0 and @max_spur_level (the maximum level is dependent 107 - * on the chip revision). 98 + * on the chip revision). 108 99 */ 109 100 void 110 101 ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level) ··· 124 117 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level); 125 118 } 126 119 127 - 128 120 /** 129 121 * ath5k_ani_set_firstep_level() - Set "firstep" level 130 - * 122 + * @ah: The &struct ath5k_hw 131 123 * @level: level between 0 and @ATH5K_ANI_MAX_FIRSTEP_LVL 132 124 */ 133 125 void ··· 146 140 ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level); 147 141 } 148 142 149 - 150 143 /** 151 - * ath5k_ani_set_ofdm_weak_signal_detection() - Control OFDM weak signal 152 - * detection 153 - * 144 + * ath5k_ani_set_ofdm_weak_signal_detection() - Set OFDM weak signal detection 145 + * @ah: The &struct ath5k_hw 154 146 * @on: turn on or off 155 147 */ 156 148 void ··· 186 182 on ? "on" : "off"); 187 183 } 188 184 189 - 190 185 /** 191 - * ath5k_ani_set_cck_weak_signal_detection() - control CCK weak signal detection 192 - * 186 + * ath5k_ani_set_cck_weak_signal_detection() - Set CCK weak signal detection 187 + * @ah: The &struct ath5k_hw 193 188 * @on: turn on or off 194 189 */ 195 190 void ··· 203 200 } 204 201 205 202 206 - /*** ANI algorithm ***/ 203 + /***************\ 204 + * ANI algorithm * 205 + \***************/ 207 206 208 207 /** 209 208 * ath5k_ani_raise_immunity() - Increase noise immunity 210 - * 209 + * @ah: The &struct ath5k_hw 210 + * @as: The &struct ath5k_ani_state 211 211 * @ofdm_trigger: If this is true we are called because of too many OFDM errors, 212 - * the algorithm will tune more parameters then. 212 + * the algorithm will tune more parameters then. 213 213 * 214 214 * Try to raise noise immunity (=decrease sensitivity) in several steps 215 215 * depending on the average RSSI of the beacons we received. ··· 296 290 */ 297 291 } 298 292 299 - 300 293 /** 301 294 * ath5k_ani_lower_immunity() - Decrease noise immunity 295 + * @ah: The &struct ath5k_hw 296 + * @as: The &struct ath5k_ani_state 302 297 * 303 298 * Try to lower noise immunity (=increase sensitivity) in several steps 304 299 * depending on the average RSSI of the beacons we received. ··· 359 352 } 360 353 } 361 354 362 - 363 355 /** 364 356 * ath5k_hw_ani_get_listen_time() - Update counters and return listening time 357 + * @ah: The &struct ath5k_hw 358 + * @as: The &struct ath5k_ani_state 365 359 * 366 360 * Return an approximation of the time spent "listening" in milliseconds (ms) 367 361 * since the last call of this function. ··· 387 379 return listen; 388 380 } 389 381 390 - 391 382 /** 392 383 * ath5k_ani_save_and_clear_phy_errors() - Clear and save PHY error counters 384 + * @ah: The &struct ath5k_hw 385 + * @as: The &struct ath5k_ani_state 393 386 * 394 387 * Clear the PHY error counters as soon as possible, since this might be called 395 388 * from a MIB interrupt and we want to make sure we don't get interrupted again. ··· 438 429 return 1; 439 430 } 440 431 441 - 442 432 /** 443 433 * ath5k_ani_period_restart() - Restart ANI period 434 + * @ah: The &struct ath5k_hw 435 + * @as: The &struct ath5k_ani_state 444 436 * 445 437 * Just reset counters, so they are clear for the next "ani period". 446 438 */ ··· 458 448 as->listen_time = 0; 459 449 } 460 450 461 - 462 451 /** 463 452 * ath5k_ani_calibration() - The main ANI calibration function 453 + * @ah: The &struct ath5k_hw 464 454 * 465 455 * We count OFDM and CCK errors relative to the time where we did not send or 466 456 * receive ("listen" time) and raise or lower immunity accordingly. ··· 519 509 } 520 510 521 511 522 - /*** INTERRUPT HANDLER ***/ 512 + /*******************\ 513 + * Interrupt handler * 514 + \*******************/ 523 515 524 516 /** 525 517 * ath5k_ani_mib_intr() - Interrupt handler for ANI MIB counters 518 + * @ah: The &struct ath5k_hw 526 519 * 527 520 * Just read & reset the registers quickly, so they don't generate more 528 521 * interrupts, save the counters and schedule the tasklet to decide whether ··· 562 549 tasklet_schedule(&ah->ani_tasklet); 563 550 } 564 551 565 - 566 552 /** 567 - * ath5k_ani_phy_error_report() - Used by older HW to report PHY errors 553 + * ath5k_ani_phy_error_report - Used by older HW to report PHY errors 554 + * 555 + * @ah: The &struct ath5k_hw 556 + * @phyerr: One of enum ath5k_phy_error_code 568 557 * 569 558 * This is used by hardware without PHY error counters to report PHY errors 570 559 * on a frame-by-frame basis, instead of the interrupt. ··· 589 574 } 590 575 591 576 592 - /*** INIT ***/ 577 + /****************\ 578 + * Initialization * 579 + \****************/ 593 580 594 581 /** 595 582 * ath5k_enable_phy_err_counters() - Enable PHY error counters 583 + * @ah: The &struct ath5k_hw 596 584 * 597 585 * Enable PHY error counters for OFDM and CCK timing errors. 598 586 */ ··· 614 596 ath5k_hw_reg_write(ah, 0, AR5K_CCK_FIL_CNT); 615 597 } 616 598 617 - 618 599 /** 619 600 * ath5k_disable_phy_err_counters() - Disable PHY error counters 601 + * @ah: The &struct ath5k_hw 620 602 * 621 603 * Disable PHY error counters for OFDM and CCK timing errors. 622 604 */ ··· 633 615 ath5k_hw_reg_write(ah, 0, AR5K_CCK_FIL_CNT); 634 616 } 635 617 636 - 637 618 /** 638 619 * ath5k_ani_init() - Initialize ANI 639 - * @mode: Which mode to use (auto, manual high, manual low, off) 620 + * @ah: The &struct ath5k_hw 621 + * @mode: One of enum ath5k_ani_mode 640 622 * 641 623 * Initialize ANI according to mode. 642 624 */ ··· 713 695 } 714 696 715 697 716 - /*** DEBUG ***/ 698 + /**************\ 699 + * Debug output * 700 + \**************/ 717 701 718 702 #ifdef CONFIG_ATH5K_DEBUG 719 703 704 + /** 705 + * ath5k_ani_print_counters() - Print ANI counters 706 + * @ah: The &struct ath5k_hw 707 + * 708 + * Used for debugging ANI 709 + */ 720 710 void 721 711 ath5k_ani_print_counters(struct ath5k_hw *ah) 722 712 {
+23 -9
drivers/net/wireless/ath/ath5k/ani.h
··· 40 40 * enum ath5k_ani_mode - mode for ANI / noise sensitivity 41 41 * 42 42 * @ATH5K_ANI_MODE_OFF: Turn ANI off. This can be useful to just stop the ANI 43 - * algorithm after it has been on auto mode. 44 - * ATH5K_ANI_MODE_MANUAL_LOW: Manually set all immunity parameters to low, 45 - * maximizing sensitivity. ANI will not run. 46 - * ATH5K_ANI_MODE_MANUAL_HIGH: Manually set all immunity parameters to high, 47 - * minimizing sensitivity. ANI will not run. 48 - * ATH5K_ANI_MODE_AUTO: Automatically control immunity parameters based on the 49 - * amount of OFDM and CCK frame errors (default). 43 + * algorithm after it has been on auto mode. 44 + * @ATH5K_ANI_MODE_MANUAL_LOW: Manually set all immunity parameters to low, 45 + * maximizing sensitivity. ANI will not run. 46 + * @ATH5K_ANI_MODE_MANUAL_HIGH: Manually set all immunity parameters to high, 47 + * minimizing sensitivity. ANI will not run. 48 + * @ATH5K_ANI_MODE_AUTO: Automatically control immunity parameters based on the 49 + * amount of OFDM and CCK frame errors (default). 50 50 */ 51 51 enum ath5k_ani_mode { 52 52 ATH5K_ANI_MODE_OFF = 0, ··· 58 58 59 59 /** 60 60 * struct ath5k_ani_state - ANI state and associated counters 61 - * 62 - * @max_spur_level: the maximum spur level is chip dependent 61 + * @ani_mode: One of enum ath5k_ani_mode 62 + * @noise_imm_level: Noise immunity level 63 + * @spur_level: Spur immunity level 64 + * @firstep_level: FIRstep level 65 + * @ofdm_weak_sig: OFDM weak signal detection state (on/off) 66 + * @cck_weak_sig: CCK weak signal detection state (on/off) 67 + * @max_spur_level: Max spur immunity level (chip specific) 68 + * @listen_time: Listen time 69 + * @ofdm_errors: OFDM timing error count 70 + * @cck_errors: CCK timing error count 71 + * @last_cc: The &struct ath_cycle_counters (for stats) 72 + * @last_listen: Listen time from previous run (for stats) 73 + * @last_ofdm_errors: OFDM timing error count from previous run (for tats) 74 + * @last_cck_errors: CCK timing error count from previous run (for stats) 75 + * @sum_ofdm_errors: Sum of OFDM timing errors (for stats) 76 + * @sum_cck_errors: Sum of all CCK timing errors (for stats) 63 77 */ 64 78 struct ath5k_ani_state { 65 79 enum ath5k_ani_mode ani_mode;
+366 -165
drivers/net/wireless/ath/ath5k/ath5k.h
··· 261 261 #define AR5K_AGC_SETTLING_TURBO 37 262 262 263 263 264 - /* GENERIC CHIPSET DEFINITIONS */ 265 264 266 - /* MAC Chips */ 265 + /*****************************\ 266 + * GENERIC CHIPSET DEFINITIONS * 267 + \*****************************/ 268 + 269 + /** 270 + * enum ath5k_version - MAC Chips 271 + * @AR5K_AR5210: AR5210 (Crete) 272 + * @AR5K_AR5211: AR5211 (Oahu/Maui) 273 + * @AR5K_AR5212: AR5212 (Venice) and newer 274 + */ 267 275 enum ath5k_version { 268 276 AR5K_AR5210 = 0, 269 277 AR5K_AR5211 = 1, 270 278 AR5K_AR5212 = 2, 271 279 }; 272 280 273 - /* PHY Chips */ 281 + /** 282 + * enum ath5k_radio - PHY Chips 283 + * @AR5K_RF5110: RF5110 (Fez) 284 + * @AR5K_RF5111: RF5111 (Sombrero) 285 + * @AR5K_RF5112: RF2112/5112(A) (Derby/Derby2) 286 + * @AR5K_RF2413: RF2413/2414 (Griffin/Griffin-Lite) 287 + * @AR5K_RF5413: RF5413/5414/5424 (Eagle/Condor) 288 + * @AR5K_RF2316: RF2315/2316 (Cobra SoC) 289 + * @AR5K_RF2317: RF2317 (Spider SoC) 290 + * @AR5K_RF2425: RF2425/2417 (Swan/Nalla) 291 + */ 274 292 enum ath5k_radio { 275 293 AR5K_RF5110 = 0, 276 294 AR5K_RF5111 = 1, ··· 320 302 #define AR5K_SREV_AR5213A 0x59 /* Hainan */ 321 303 #define AR5K_SREV_AR2413 0x78 /* Griffin lite */ 322 304 #define AR5K_SREV_AR2414 0x70 /* Griffin */ 323 - #define AR5K_SREV_AR2315_R6 0x86 /* AP51-Light */ 324 - #define AR5K_SREV_AR2315_R7 0x87 /* AP51-Full */ 305 + #define AR5K_SREV_AR2315_R6 0x86 /* AP51-Light */ 306 + #define AR5K_SREV_AR2315_R7 0x87 /* AP51-Full */ 325 307 #define AR5K_SREV_AR5424 0x90 /* Condor */ 326 - #define AR5K_SREV_AR2317_R1 0x90 /* AP61-Light */ 327 - #define AR5K_SREV_AR2317_R2 0x91 /* AP61-Full */ 308 + #define AR5K_SREV_AR2317_R1 0x90 /* AP61-Light */ 309 + #define AR5K_SREV_AR2317_R2 0x91 /* AP61-Full */ 328 310 #define AR5K_SREV_AR5413 0xa4 /* Eagle lite */ 329 311 #define AR5K_SREV_AR5414 0xa0 /* Eagle */ 330 312 #define AR5K_SREV_AR2415 0xb0 /* Talon */ ··· 361 343 362 344 /* TODO add support to mac80211 for vendor-specific rates and modes */ 363 345 364 - /* 346 + /** 347 + * DOC: Atheros XR 348 + * 365 349 * Some of this information is based on Documentation from: 366 350 * 367 351 * http://madwifi-project.org/wiki/ChipsetFeatures/SuperAG 368 352 * 369 - * Modulation for Atheros' eXtended Range - range enhancing extension that is 370 - * supposed to double the distance an Atheros client device can keep a 371 - * connection with an Atheros access point. This is achieved by increasing 372 - * the receiver sensitivity up to, -105dBm, which is about 20dB above what 373 - * the 802.11 specifications demand. In addition, new (proprietary) data rates 374 - * are introduced: 3, 2, 1, 0.5 and 0.25 MBit/s. 353 + * Atheros' eXtended Range - range enhancing extension is a modulation scheme 354 + * that is supposed to double the link distance between an Atheros XR-enabled 355 + * client device with an Atheros XR-enabled access point. This is achieved 356 + * by increasing the receiver sensitivity up to, -105dBm, which is about 20dB 357 + * above what the 802.11 specifications demand. In addition, new (proprietary) 358 + * data rates are introduced: 3, 2, 1, 0.5 and 0.25 MBit/s. 375 359 * 376 360 * Please note that can you either use XR or TURBO but you cannot use both, 377 361 * they are exclusive. 378 362 * 363 + * Also note that we do not plan to support XR mode at least for now. You can 364 + * get a mode similar to XR by using 5MHz bwmode. 379 365 */ 380 - #define MODULATION_XR 0x00000200 381 - /* 382 - * Modulation for Atheros' Turbo G and Turbo A, its supposed to provide a 383 - * throughput transmission speed up to 40Mbit/s-60Mbit/s at a 108Mbit/s 384 - * signaling rate achieved through the bonding of two 54Mbit/s 802.11g 385 - * channels. To use this feature your Access Point must also support it. 366 + 367 + 368 + /** 369 + * DOC: Atheros SuperAG 370 + * 371 + * In addition to XR we have another modulation scheme called TURBO mode 372 + * that is supposed to provide a throughput transmission speed up to 40Mbit/s 373 + * -60Mbit/s at a 108Mbit/s signaling rate achieved through the bonding of two 374 + * 54Mbit/s 802.11g channels. To use this feature both ends must support it. 386 375 * There is also a distinction between "static" and "dynamic" turbo modes: 387 376 * 388 377 * - Static: is the dumb version: devices set to this mode stick to it until 389 378 * the mode is turned off. 379 + * 390 380 * - Dynamic: is the intelligent version, the network decides itself if it 391 381 * is ok to use turbo. As soon as traffic is detected on adjacent channels 392 382 * (which would get used in turbo mode), or when a non-turbo station joins ··· 408 382 * 409 383 * http://www.pcworld.com/article/id,113428-page,1/article.html 410 384 * 411 - * The channel bonding seems to be driver specific though. In addition to 412 - * deciding what channels will be used, these "Turbo" modes are accomplished 413 - * by also enabling the following features: 385 + * The channel bonding seems to be driver specific though. 386 + * 387 + * In addition to TURBO modes we also have the following features for even 388 + * greater speed-up: 414 389 * 415 390 * - Bursting: allows multiple frames to be sent at once, rather than pausing 416 391 * after each frame. Bursting is a standards-compliant feature that can be 417 392 * used with any Access Point. 393 + * 418 394 * - Fast frames: increases the amount of information that can be sent per 419 395 * frame, also resulting in a reduction of transmission overhead. It is a 420 396 * proprietary feature that needs to be supported by the Access Point. 397 + * 421 398 * - Compression: data frames are compressed in real time using a Lempel Ziv 422 399 * algorithm. This is done transparently. Once this feature is enabled, 423 400 * compression and decompression takes place inside the chipset, without 424 401 * putting additional load on the host CPU. 425 402 * 403 + * As with XR we also don't plan to support SuperAG features for now. You can 404 + * get a mode similar to TURBO by using 40MHz bwmode. 426 405 */ 427 - #define MODULATION_TURBO 0x00000080 428 406 407 + 408 + /** 409 + * enum ath5k_driver_mode - PHY operation mode 410 + * @AR5K_MODE_11A: 802.11a 411 + * @AR5K_MODE_11B: 802.11b 412 + * @AR5K_MODE_11G: 801.11g 413 + * @AR5K_MODE_MAX: Used for boundary checks 414 + * 415 + * Do not change the order here, we use these as 416 + * array indices and it also maps EEPROM structures. 417 + */ 429 418 enum ath5k_driver_mode { 430 419 AR5K_MODE_11A = 0, 431 420 AR5K_MODE_11B = 1, ··· 448 407 AR5K_MODE_MAX = 3 449 408 }; 450 409 410 + /** 411 + * enum ath5k_ant_mode - Antenna operation mode 412 + * @AR5K_ANTMODE_DEFAULT: Default antenna setup 413 + * @AR5K_ANTMODE_FIXED_A: Only antenna A is present 414 + * @AR5K_ANTMODE_FIXED_B: Only antenna B is present 415 + * @AR5K_ANTMODE_SINGLE_AP: STA locked on a single ap 416 + * @AR5K_ANTMODE_SECTOR_AP: AP with tx antenna set on tx desc 417 + * @AR5K_ANTMODE_SECTOR_STA: STA with tx antenna set on tx desc 418 + * @AR5K_ANTMODE_DEBUG: Debug mode -A -> Rx, B-> Tx- 419 + * @AR5K_ANTMODE_MAX: Used for boundary checks 420 + * 421 + * For more infos on antenna control check out phy.c 422 + */ 451 423 enum ath5k_ant_mode { 452 - AR5K_ANTMODE_DEFAULT = 0, /* default antenna setup */ 453 - AR5K_ANTMODE_FIXED_A = 1, /* only antenna A is present */ 454 - AR5K_ANTMODE_FIXED_B = 2, /* only antenna B is present */ 455 - AR5K_ANTMODE_SINGLE_AP = 3, /* sta locked on a single ap */ 456 - AR5K_ANTMODE_SECTOR_AP = 4, /* AP with tx antenna set on tx desc */ 457 - AR5K_ANTMODE_SECTOR_STA = 5, /* STA with tx antenna set on tx desc */ 458 - AR5K_ANTMODE_DEBUG = 6, /* Debug mode -A -> Rx, B-> Tx- */ 424 + AR5K_ANTMODE_DEFAULT = 0, 425 + AR5K_ANTMODE_FIXED_A = 1, 426 + AR5K_ANTMODE_FIXED_B = 2, 427 + AR5K_ANTMODE_SINGLE_AP = 3, 428 + AR5K_ANTMODE_SECTOR_AP = 4, 429 + AR5K_ANTMODE_SECTOR_STA = 5, 430 + AR5K_ANTMODE_DEBUG = 6, 459 431 AR5K_ANTMODE_MAX, 460 432 }; 461 433 434 + /** 435 + * enum ath5k_bw_mode - Bandwidth operation mode 436 + * @AR5K_BWMODE_DEFAULT: 20MHz, default operation 437 + * @AR5K_BWMODE_5MHZ: Quarter rate 438 + * @AR5K_BWMODE_10MHZ: Half rate 439 + * @AR5K_BWMODE_40MHZ: Turbo 440 + */ 462 441 enum ath5k_bw_mode { 463 - AR5K_BWMODE_DEFAULT = 0, /* 20MHz, default operation */ 464 - AR5K_BWMODE_5MHZ = 1, /* Quarter rate */ 465 - AR5K_BWMODE_10MHZ = 2, /* Half rate */ 466 - AR5K_BWMODE_40MHZ = 3 /* Turbo */ 442 + AR5K_BWMODE_DEFAULT = 0, 443 + AR5K_BWMODE_5MHZ = 1, 444 + AR5K_BWMODE_10MHZ = 2, 445 + AR5K_BWMODE_40MHZ = 3 467 446 }; 447 + 448 + 468 449 469 450 /****************\ 470 451 TX DEFINITIONS 471 452 \****************/ 472 453 473 - /* 474 - * TX Status descriptor 454 + /** 455 + * struct ath5k_tx_status - TX Status descriptor 456 + * @ts_seqnum: Sequence number 457 + * @ts_tstamp: Timestamp 458 + * @ts_status: Status code 459 + * @ts_final_idx: Final transmission series index 460 + * @ts_final_retry: Final retry count 461 + * @ts_rssi: RSSI for received ACK 462 + * @ts_shortretry: Short retry count 463 + * @ts_virtcol: Virtual collision count 464 + * @ts_antenna: Antenna used 465 + * 466 + * TX status descriptor gets filled by the hw 467 + * on each transmission attempt. 475 468 */ 476 469 struct ath5k_tx_status { 477 470 u16 ts_seqnum; ··· 528 453 * enum ath5k_tx_queue - Queue types used to classify tx queues. 529 454 * @AR5K_TX_QUEUE_INACTIVE: q is unused -- see ath5k_hw_release_tx_queue 530 455 * @AR5K_TX_QUEUE_DATA: A normal data queue 531 - * @AR5K_TX_QUEUE_XR_DATA: An XR-data queue 532 456 * @AR5K_TX_QUEUE_BEACON: The beacon queue 533 457 * @AR5K_TX_QUEUE_CAB: The after-beacon queue 534 458 * @AR5K_TX_QUEUE_UAPSD: Unscheduled Automatic Power Save Delivery queue ··· 535 461 enum ath5k_tx_queue { 536 462 AR5K_TX_QUEUE_INACTIVE = 0, 537 463 AR5K_TX_QUEUE_DATA, 538 - AR5K_TX_QUEUE_XR_DATA, 539 464 AR5K_TX_QUEUE_BEACON, 540 465 AR5K_TX_QUEUE_CAB, 541 466 AR5K_TX_QUEUE_UAPSD, ··· 543 470 #define AR5K_NUM_TX_QUEUES 10 544 471 #define AR5K_NUM_TX_QUEUES_NOQCU 2 545 472 546 - /* 547 - * Queue syb-types to classify normal data queues. 473 + /** 474 + * enum ath5k_tx_queue_subtype - Queue sub-types to classify normal data queues 475 + * @AR5K_WME_AC_BK: Background traffic 476 + * @AR5K_WME_AC_BE: Best-effort (normal) traffic 477 + * @AR5K_WME_AC_VI: Video traffic 478 + * @AR5K_WME_AC_VO: Voice traffic 479 + * 548 480 * These are the 4 Access Categories as defined in 549 481 * WME spec. 0 is the lowest priority and 4 is the 550 482 * highest. Normal data that hasn't been classified 551 483 * goes to the Best Effort AC. 552 484 */ 553 485 enum ath5k_tx_queue_subtype { 554 - AR5K_WME_AC_BK = 0, /*Background traffic*/ 555 - AR5K_WME_AC_BE, /*Best-effort (normal) traffic*/ 556 - AR5K_WME_AC_VI, /*Video traffic*/ 557 - AR5K_WME_AC_VO, /*Voice traffic*/ 486 + AR5K_WME_AC_BK = 0, 487 + AR5K_WME_AC_BE, 488 + AR5K_WME_AC_VI, 489 + AR5K_WME_AC_VO, 558 490 }; 559 491 560 - /* 561 - * Queue ID numbers as returned by the hw functions, each number 562 - * represents a hw queue. If hw does not support hw queues 492 + /** 493 + * enum ath5k_tx_queue_id - Queue ID numbers as returned by the hw functions 494 + * @AR5K_TX_QUEUE_ID_NOQCU_DATA: Data queue on AR5210 (no QCU available) 495 + * @AR5K_TX_QUEUE_ID_NOQCU_BEACON: Beacon queue on AR5210 (no QCU available) 496 + * @AR5K_TX_QUEUE_ID_DATA_MIN: Data queue min index 497 + * @AR5K_TX_QUEUE_ID_DATA_MAX: Data queue max index 498 + * @AR5K_TX_QUEUE_ID_CAB: Content after beacon queue 499 + * @AR5K_TX_QUEUE_ID_BEACON: Beacon queue 500 + * @AR5K_TX_QUEUE_ID_UAPSD: Urgent Automatic Power Save Delivery, 501 + * @AR5K_TX_QUEUE_ID_XR_DATA: XR Data queue 502 + * 503 + * Each number represents a hw queue. If hw does not support hw queues 563 504 * (eg 5210) all data goes in one queue. These match 564 - * d80211 definitions (net80211/MadWiFi don't use them). 505 + * mac80211 definitions. 565 506 */ 566 507 enum ath5k_tx_queue_id { 567 508 AR5K_TX_QUEUE_ID_NOQCU_DATA = 0, 568 509 AR5K_TX_QUEUE_ID_NOQCU_BEACON = 1, 569 - AR5K_TX_QUEUE_ID_DATA_MIN = 0, /*IEEE80211_TX_QUEUE_DATA0*/ 570 - AR5K_TX_QUEUE_ID_DATA_MAX = 3, /*IEEE80211_TX_QUEUE_DATA3*/ 571 - AR5K_TX_QUEUE_ID_DATA_SVP = 5, /*IEEE80211_TX_QUEUE_SVP - Spectralink Voice Protocol*/ 572 - AR5K_TX_QUEUE_ID_CAB = 6, /*IEEE80211_TX_QUEUE_AFTER_BEACON*/ 573 - AR5K_TX_QUEUE_ID_BEACON = 7, /*IEEE80211_TX_QUEUE_BEACON*/ 510 + AR5K_TX_QUEUE_ID_DATA_MIN = 0, 511 + AR5K_TX_QUEUE_ID_DATA_MAX = 3, 512 + AR5K_TX_QUEUE_ID_CAB = 6, 513 + AR5K_TX_QUEUE_ID_BEACON = 7, 574 514 AR5K_TX_QUEUE_ID_UAPSD = 8, 575 - AR5K_TX_QUEUE_ID_XR_DATA = 9, 576 515 }; 577 516 578 517 /* ··· 605 520 #define AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS 0x1000 /* Disable backoff while bursting */ 606 521 #define AR5K_TXQ_FLAG_COMPRESSION_ENABLE 0x2000 /* Enable hw compression -not implemented-*/ 607 522 608 - /* 609 - * Data transmit queue state. One of these exists for each 610 - * hardware transmit queue. Packets sent to us from above 611 - * are assigned to queues based on their priority. Not all 612 - * devices support a complete set of hardware transmit queues. 613 - * For those devices the array sc_ac2q will map multiple 614 - * priorities to fewer hardware queues (typically all to one 615 - * hardware queue). 523 + /** 524 + * struct ath5k_txq - Transmit queue state 525 + * @qnum: Hardware q number 526 + * @link: Link ptr in last TX desc 527 + * @q: Transmit queue (&struct list_head) 528 + * @lock: Lock on q and link 529 + * @setup: Is the queue configured 530 + * @txq_len:Number of queued buffers 531 + * @txq_max: Max allowed num of queued buffers 532 + * @txq_poll_mark: Used to check if queue got stuck 533 + * @txq_stuck: Queue stuck counter 534 + * 535 + * One of these exists for each hardware transmit queue. 536 + * Packets sent to us from above are assigned to queues based 537 + * on their priority. Not all devices support a complete set 538 + * of hardware transmit queues. For those devices the array 539 + * sc_ac2q will map multiple priorities to fewer hardware queues 540 + * (typically all to one hardware queue). 616 541 */ 617 542 struct ath5k_txq { 618 - unsigned int qnum; /* hardware q number */ 619 - u32 *link; /* link ptr in last TX desc */ 620 - struct list_head q; /* transmit queue */ 621 - spinlock_t lock; /* lock on q and link */ 543 + unsigned int qnum; 544 + u32 *link; 545 + struct list_head q; 546 + spinlock_t lock; 622 547 bool setup; 623 - int txq_len; /* number of queued buffers */ 624 - int txq_max; /* max allowed num of queued buffers */ 548 + int txq_len; 549 + int txq_max; 625 550 bool txq_poll_mark; 626 - unsigned int txq_stuck; /* informational counter */ 551 + unsigned int txq_stuck; 627 552 }; 628 553 629 - /* 630 - * A struct to hold tx queue's parameters 554 + /** 555 + * struct ath5k_txq_info - A struct to hold TX queue's parameters 556 + * @tqi_type: One of enum ath5k_tx_queue 557 + * @tqi_subtype: One of enum ath5k_tx_queue_subtype 558 + * @tqi_flags: TX queue flags (see above) 559 + * @tqi_aifs: Arbitrated Inter-frame Space 560 + * @tqi_cw_min: Minimum Contention Window 561 + * @tqi_cw_max: Maximum Contention Window 562 + * @tqi_cbr_period: Constant bit rate period 563 + * @tqi_ready_time: Time queue waits after an event when RDYTIME is enabled 631 564 */ 632 565 struct ath5k_txq_info { 633 566 enum ath5k_tx_queue tqi_type; 634 567 enum ath5k_tx_queue_subtype tqi_subtype; 635 - u16 tqi_flags; /* Tx queue flags (see above) */ 636 - u8 tqi_aifs; /* Arbitrated Interframe Space */ 637 - u16 tqi_cw_min; /* Minimum Contention Window */ 638 - u16 tqi_cw_max; /* Maximum Contention Window */ 639 - u32 tqi_cbr_period; /* Constant bit rate period */ 568 + u16 tqi_flags; 569 + u8 tqi_aifs; 570 + u16 tqi_cw_min; 571 + u16 tqi_cw_max; 572 + u32 tqi_cbr_period; 640 573 u32 tqi_cbr_overflow_limit; 641 574 u32 tqi_burst_time; 642 - u32 tqi_ready_time; /* Time queue waits after an event */ 575 + u32 tqi_ready_time; 643 576 }; 644 577 645 - /* 646 - * Transmit packet types. 647 - * used on tx control descriptor 578 + /** 579 + * enum ath5k_pkt_type - Transmit packet types 580 + * @AR5K_PKT_TYPE_NORMAL: Normal data 581 + * @AR5K_PKT_TYPE_ATIM: ATIM 582 + * @AR5K_PKT_TYPE_PSPOLL: PS-Poll 583 + * @AR5K_PKT_TYPE_BEACON: Beacon 584 + * @AR5K_PKT_TYPE_PROBE_RESP: Probe response 585 + * @AR5K_PKT_TYPE_PIFS: PIFS 586 + * Used on tx control descriptor 648 587 */ 649 588 enum ath5k_pkt_type { 650 589 AR5K_PKT_TYPE_NORMAL = 0, ··· 691 582 (ah->ah_txpower.txp_rates_power_table[(_r)] & 0x3f) << (_v) \ 692 583 ) 693 584 694 - /* 695 - * DMA size definitions (2^(n+2)) 696 - */ 697 - enum ath5k_dmasize { 698 - AR5K_DMASIZE_4B = 0, 699 - AR5K_DMASIZE_8B, 700 - AR5K_DMASIZE_16B, 701 - AR5K_DMASIZE_32B, 702 - AR5K_DMASIZE_64B, 703 - AR5K_DMASIZE_128B, 704 - AR5K_DMASIZE_256B, 705 - AR5K_DMASIZE_512B 706 - }; 707 585 708 586 709 587 /****************\ 710 588 RX DEFINITIONS 711 589 \****************/ 712 590 713 - /* 714 - * RX Status descriptor 591 + /** 592 + * struct ath5k_rx_status - RX Status descriptor 593 + * @rs_datalen: Data length 594 + * @rs_tstamp: Timestamp 595 + * @rs_status: Status code 596 + * @rs_phyerr: PHY error mask 597 + * @rs_rssi: RSSI in 0.5dbm units 598 + * @rs_keyix: Index to the key used for decrypting 599 + * @rs_rate: Rate used to decode the frame 600 + * @rs_antenna: Antenna used to receive the frame 601 + * @rs_more: Indicates this is a frame fragment (Fast frames) 715 602 */ 716 603 struct ath5k_rx_status { 717 604 u16 rs_datalen; ··· 749 644 #define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10) 750 645 751 646 647 + 752 648 /*******************************\ 753 649 GAIN OPTIMIZATION DEFINITIONS 754 650 \*******************************/ 755 651 652 + /** 653 + * enum ath5k_rfgain - RF Gain optimization engine state 654 + * @AR5K_RFGAIN_INACTIVE: Engine disabled 655 + * @AR5K_RFGAIN_ACTIVE: Probe active 656 + * @AR5K_RFGAIN_READ_REQUESTED: Probe requested 657 + * @AR5K_RFGAIN_NEED_CHANGE: Gain_F needs change 658 + */ 756 659 enum ath5k_rfgain { 757 660 AR5K_RFGAIN_INACTIVE = 0, 758 661 AR5K_RFGAIN_ACTIVE, ··· 768 655 AR5K_RFGAIN_NEED_CHANGE, 769 656 }; 770 657 658 + /** 659 + * struct ath5k_gain - RF Gain optimization engine state data 660 + * @g_step_idx: Current step index 661 + * @g_current: Current gain 662 + * @g_target: Target gain 663 + * @g_low: Low gain boundary 664 + * @g_high: High gain boundary 665 + * @g_f_corr: Gain_F correction 666 + * @g_state: One of enum ath5k_rfgain 667 + */ 771 668 struct ath5k_gain { 772 669 u8 g_step_idx; 773 670 u8 g_current; ··· 788 665 u8 g_state; 789 666 }; 790 667 668 + 669 + 791 670 /********************\ 792 671 COMMON DEFINITIONS 793 672 \********************/ ··· 798 673 #define AR5K_SLOT_TIME_20 880 799 674 #define AR5K_SLOT_TIME_MAX 0xffff 800 675 801 - /* 802 - * The following structure is used to map 2GHz channels to 803 - * 5GHz Atheros channels. 676 + /** 677 + * struct ath5k_athchan_2ghz - 2GHz to 5GHZ map for RF5111 678 + * @a2_flags: Channel flags (internal) 679 + * @a2_athchan: HW channel number (internal) 680 + * 681 + * This structure is used to map 2GHz channels to 682 + * 5GHz Atheros channels on 2111 frequency converter 683 + * that comes together with RF5111 804 684 * TODO: Clean up 805 685 */ 806 686 struct ath5k_athchan_2ghz { ··· 813 683 u16 a2_athchan; 814 684 }; 815 685 686 + /** 687 + * enum ath5k_dmasize - DMA size definitions (2^(n+2)) 688 + * @AR5K_DMASIZE_4B: 4Bytes 689 + * @AR5K_DMASIZE_8B: 8Bytes 690 + * @AR5K_DMASIZE_16B: 16Bytes 691 + * @AR5K_DMASIZE_32B: 32Bytes 692 + * @AR5K_DMASIZE_64B: 64Bytes (Default) 693 + * @AR5K_DMASIZE_128B: 128Bytes 694 + * @AR5K_DMASIZE_256B: 256Bytes 695 + * @AR5K_DMASIZE_512B: 512Bytes 696 + * 697 + * These are used to set DMA burst size on hw 698 + * 699 + * Note: Some platforms can't handle more than 4Bytes 700 + * be careful on embedded boards. 701 + */ 702 + enum ath5k_dmasize { 703 + AR5K_DMASIZE_4B = 0, 704 + AR5K_DMASIZE_8B, 705 + AR5K_DMASIZE_16B, 706 + AR5K_DMASIZE_32B, 707 + AR5K_DMASIZE_64B, 708 + AR5K_DMASIZE_128B, 709 + AR5K_DMASIZE_256B, 710 + AR5K_DMASIZE_512B 711 + }; 712 + 713 + 816 714 817 715 /******************\ 818 716 RATE DEFINITIONS 819 717 \******************/ 820 718 821 719 /** 720 + * DOC: Rate codes 721 + * 822 722 * Seems the ar5xxx hardware supports up to 32 rates, indexed by 1-32. 823 723 * 824 724 * The rate code is used to get the RX rate or set the TX rate on the 825 725 * hardware descriptors. It is also used for internal modulation control 826 726 * and settings. 827 727 * 828 - * This is the hardware rate map we are aware of: 728 + * This is the hardware rate map we are aware of (html unfriendly): 829 729 * 830 - * rate_code 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 831 - * rate_kbps 3000 1000 ? ? ? 2000 500 48000 730 + * Rate code Rate (Kbps) 731 + * --------- ----------- 732 + * 0x01 3000 (XR) 733 + * 0x02 1000 (XR) 734 + * 0x03 250 (XR) 735 + * 0x04 - 05 -Reserved- 736 + * 0x06 2000 (XR) 737 + * 0x07 500 (XR) 738 + * 0x08 48000 (OFDM) 739 + * 0x09 24000 (OFDM) 740 + * 0x0A 12000 (OFDM) 741 + * 0x0B 6000 (OFDM) 742 + * 0x0C 54000 (OFDM) 743 + * 0x0D 36000 (OFDM) 744 + * 0x0E 18000 (OFDM) 745 + * 0x0F 9000 (OFDM) 746 + * 0x10 - 17 -Reserved- 747 + * 0x18 11000L (CCK) 748 + * 0x19 5500L (CCK) 749 + * 0x1A 2000L (CCK) 750 + * 0x1B 1000L (CCK) 751 + * 0x1C 11000S (CCK) 752 + * 0x1D 5500S (CCK) 753 + * 0x1E 2000S (CCK) 754 + * 0x1F -Reserved- 832 755 * 833 - * rate_code 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 834 - * rate_kbps 24000 12000 6000 54000 36000 18000 9000 ? 835 - * 836 - * rate_code 17 18 19 20 21 22 23 24 837 - * rate_kbps ? ? ? ? ? ? ? 11000 838 - * 839 - * rate_code 25 26 27 28 29 30 31 32 840 - * rate_kbps 5500 2000 1000 11000S 5500S 2000S ? ? 841 - * 842 - * "S" indicates CCK rates with short preamble. 756 + * "S" indicates CCK rates with short preamble and "L" with long preamble. 843 757 * 844 758 * AR5211 has different rate codes for CCK (802.11B) rates. It only uses the 845 - * lowest 4 bits, so they are the same as below with a 0xF mask. 759 + * lowest 4 bits, so they are the same as above with a 0xF mask. 846 760 * (0xB, 0xA, 0x9 and 0x8 for 1M, 2M, 5.5M and 11M). 847 761 * We handle this in ath5k_setup_bands(). 848 762 */ ··· 906 732 #define ATH5K_RATE_CODE_36M 0x0D 907 733 #define ATH5K_RATE_CODE_48M 0x08 908 734 #define ATH5K_RATE_CODE_54M 0x0C 909 - /* XR */ 910 - #define ATH5K_RATE_CODE_XR_500K 0x07 911 - #define ATH5K_RATE_CODE_XR_1M 0x02 912 - #define ATH5K_RATE_CODE_XR_2M 0x06 913 - #define ATH5K_RATE_CODE_XR_3M 0x01 914 735 915 - /* adding this flag to rate_code enables short preamble */ 736 + /* Adding this flag to rate_code on B rates 737 + * enables short preamble */ 916 738 #define AR5K_SET_SHORT_PREAMBLE 0x04 917 739 918 740 /* ··· 938 768 939 769 /** 940 770 * enum ath5k_int - Hardware interrupt masks helpers 771 + * @AR5K_INT_RXOK: Frame successfully received 772 + * @AR5K_INT_RXDESC: Request RX descriptor/Read RX descriptor 773 + * @AR5K_INT_RXERR: Frame reception failed 774 + * @AR5K_INT_RXNOFRM: No frame received within a specified time period 775 + * @AR5K_INT_RXEOL: Reached "End Of List", means we need more RX descriptors 776 + * @AR5K_INT_RXORN: Indicates we got RX FIFO overrun. Note that Rx overrun is 777 + * not always fatal, on some chips we can continue operation 778 + * without resetting the card, that's why %AR5K_INT_FATAL is not 779 + * common for all chips. 780 + * @AR5K_INT_RX_ALL: Mask to identify all RX related interrupts 941 781 * 942 - * @AR5K_INT_RX: mask to identify received frame interrupts, of type 943 - * AR5K_ISR_RXOK or AR5K_ISR_RXERR 944 - * @AR5K_INT_RXDESC: Request RX descriptor/Read RX descriptor (?) 945 - * @AR5K_INT_RXNOFRM: No frame received (?) 946 - * @AR5K_INT_RXEOL: received End Of List for VEOL (Virtual End Of List). The 947 - * Queue Control Unit (QCU) signals an EOL interrupt only if a descriptor's 948 - * LinkPtr is NULL. For more details, refer to: 949 - * http://www.freepatentsonline.com/20030225739.html 950 - * @AR5K_INT_RXORN: Indicates we got RX overrun (eg. no more descriptors). 951 - * Note that Rx overrun is not always fatal, on some chips we can continue 952 - * operation without resetting the card, that's why int_fatal is not 953 - * common for all chips. 954 - * @AR5K_INT_TX: mask to identify received frame interrupts, of type 955 - * AR5K_ISR_TXOK or AR5K_ISR_TXERR 956 - * @AR5K_INT_TXDESC: Request TX descriptor/Read TX status descriptor (?) 957 - * @AR5K_INT_TXURN: received when we should increase the TX trigger threshold 958 - * We currently do increments on interrupt by 959 - * (AR5K_TUNE_MAX_TX_FIFO_THRES - current_trigger_level) / 2 782 + * @AR5K_INT_TXOK: Frame transmission success 783 + * @AR5K_INT_TXDESC: Request TX descriptor/Read TX status descriptor 784 + * @AR5K_INT_TXERR: Frame transmission failure 785 + * @AR5K_INT_TXEOL: Received End Of List for VEOL (Virtual End Of List). The 786 + * Queue Control Unit (QCU) signals an EOL interrupt only if a 787 + * descriptor's LinkPtr is NULL. For more details, refer to: 788 + * "http://www.freepatentsonline.com/20030225739.html" 789 + * @AR5K_INT_TXNOFRM: No frame was transmitted within a specified time period 790 + * @AR5K_INT_TXURN: Indicates we got TX FIFO underrun. In such case we should 791 + * increase the TX trigger threshold. 792 + * @AR5K_INT_TX_ALL: Mask to identify all TX related interrupts 793 + * 960 794 * @AR5K_INT_MIB: Indicates the either Management Information Base counters or 961 - * one of the PHY error counters reached the maximum value and should be 962 - * read and cleared. 795 + * one of the PHY error counters reached the maximum value and 796 + * should be read and cleared. 797 + * @AR5K_INT_SWI: Software triggered interrupt. 963 798 * @AR5K_INT_RXPHY: RX PHY Error 964 799 * @AR5K_INT_RXKCM: RX Key cache miss 965 800 * @AR5K_INT_SWBA: SoftWare Beacon Alert - indicates its time to send a 966 - * beacon that must be handled in software. The alternative is if you 967 - * have VEOL support, in that case you let the hardware deal with things. 801 + * beacon that must be handled in software. The alternative is if 802 + * you have VEOL support, in that case you let the hardware deal 803 + * with things. 804 + * @AR5K_INT_BRSSI: Beacon received with an RSSI value below our threshold 968 805 * @AR5K_INT_BMISS: If in STA mode this indicates we have stopped seeing 969 - * beacons from the AP have associated with, we should probably try to 970 - * reassociate. When in IBSS mode this might mean we have not received 971 - * any beacons from any local stations. Note that every station in an 972 - * IBSS schedules to send beacons at the Target Beacon Transmission Time 973 - * (TBTT) with a random backoff. 974 - * @AR5K_INT_BNR: Beacon Not Ready interrupt - ?? 975 - * @AR5K_INT_GPIO: GPIO interrupt is used for RF Kill, disabled for now 976 - * until properly handled 977 - * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by DMA 978 - * errors. These types of errors we can enable seem to be of type 979 - * AR5K_SIMR2_MCABT, AR5K_SIMR2_SSERR and AR5K_SIMR2_DPERR. 806 + * beacons from the AP have associated with, we should probably 807 + * try to reassociate. When in IBSS mode this might mean we have 808 + * not received any beacons from any local stations. Note that 809 + * every station in an IBSS schedules to send beacons at the 810 + * Target Beacon Transmission Time (TBTT) with a random backoff. 811 + * @AR5K_INT_BNR: Beacon queue got triggered (DMA beacon alert) while empty. 812 + * @AR5K_INT_TIM: Beacon with local station's TIM bit set 813 + * @AR5K_INT_DTIM: Beacon with DTIM bit and zero DTIM count received 814 + * @AR5K_INT_DTIM_SYNC: DTIM sync lost 815 + * @AR5K_INT_GPIO: GPIO interrupt is used for RF Kill switches connected to 816 + * our GPIO pins. 817 + * @AR5K_INT_BCN_TIMEOUT: Beacon timeout, we waited after TBTT but got noting 818 + * @AR5K_INT_CAB_TIMEOUT: We waited for CAB traffic after the beacon but got 819 + * nothing or an incomplete CAB frame sequence. 820 + * @AR5K_INT_QCBRORN: A queue got it's CBR counter expired 821 + * @AR5K_INT_QCBRURN: A queue got triggered wile empty 822 + * @AR5K_INT_QTRIG: A queue got triggered 823 + * 824 + * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by bus/DMA 825 + * errors. Indicates we need to reset the card. 980 826 * @AR5K_INT_GLOBAL: Used to clear and set the IER 981 - * @AR5K_INT_NOCARD: signals the card has been removed 982 - * @AR5K_INT_COMMON: common interrupts shared among MACs with the same 983 - * bit value 827 + * @AR5K_INT_NOCARD: Signals the card has been removed 828 + * @AR5K_INT_COMMON: Common interrupts shared among MACs with the same 829 + * bit value 984 830 * 985 831 * These are mapped to take advantage of some common bits 986 832 * between the MACs, to be able to set intr properties ··· 1032 846 AR5K_INT_GPIO = 0x01000000, 1033 847 AR5K_INT_BCN_TIMEOUT = 0x02000000, /* Non common */ 1034 848 AR5K_INT_CAB_TIMEOUT = 0x04000000, /* Non common */ 1035 - AR5K_INT_RX_DOPPLER = 0x08000000, /* Non common */ 1036 - AR5K_INT_QCBRORN = 0x10000000, /* Non common */ 1037 - AR5K_INT_QCBRURN = 0x20000000, /* Non common */ 1038 - AR5K_INT_QTRIG = 0x40000000, /* Non common */ 849 + AR5K_INT_QCBRORN = 0x08000000, /* Non common */ 850 + AR5K_INT_QCBRURN = 0x10000000, /* Non common */ 851 + AR5K_INT_QTRIG = 0x20000000, /* Non common */ 1039 852 AR5K_INT_GLOBAL = 0x80000000, 1040 853 1041 854 AR5K_INT_TX_ALL = AR5K_INT_TXOK ··· 1076 891 AR5K_INT_NOCARD = 0xffffffff 1077 892 }; 1078 893 1079 - /* mask which calibration is active at the moment */ 894 + /** 895 + * enum ath5k_calibration_mask - Mask which calibration is active at the moment 896 + * @AR5K_CALIBRATION_FULL: Full calibration (AGC + SHORT) 897 + * @AR5K_CALIBRATION_SHORT: Short calibration (NF + I/Q) 898 + * @AR5K_CALIBRATION_NF: Noise Floor calibration 899 + * @AR5K_CALIBRATION_ANI: Adaptive Noise Immunity 900 + */ 1080 901 enum ath5k_calibration_mask { 1081 902 AR5K_CALIBRATION_FULL = 0x01, 1082 903 AR5K_CALIBRATION_SHORT = 0x02, ··· 1090 899 AR5K_CALIBRATION_ANI = 0x08, 1091 900 }; 1092 901 1093 - /* 1094 - * Power management 902 + /** 903 + * enum ath5k_power_mode - Power management modes 904 + * @AR5K_PM_UNDEFINED: Undefined 905 + * @AR5K_PM_AUTO: Allow card to sleep if possible 906 + * @AR5K_PM_AWAKE: Force card to wake up 907 + * @AR5K_PM_FULL_SLEEP: Force card to full sleep (DANGEROUS) 908 + * @AR5K_PM_NETWORK_SLEEP: Allow to sleep for a specified duration 909 + * 910 + * Currently only PM_AWAKE is used, FULL_SLEEP and NETWORK_SLEEP/AUTO 911 + * are also known to have problems on some cards. This is not a big 912 + * problem though because we can have almost the same effect as 913 + * FULL_SLEEP by putting card on warm reset (it's almost powered down). 1095 914 */ 1096 915 enum ath5k_power_mode { 1097 916 AR5K_PM_UNDEFINED = 0, ··· 1545 1344 u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah); 1546 1345 void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64); 1547 1346 void ath5k_hw_reset_tsf(struct ath5k_hw *ah); 1548 - void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval); 1347 + void ath5k_hw_init_beacon_timers(struct ath5k_hw *ah, u32 next_beacon, 1348 + u32 interval); 1549 1349 bool ath5k_hw_check_beacon_timers(struct ath5k_hw *ah, int intval); 1550 1350 /* Init function */ 1551 - void ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode, 1552 - u8 mode); 1351 + void ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode); 1553 1352 1554 1353 /* Queue Control Unit, DFS Control Unit Functions */ 1555 1354 int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue,
+3 -6
drivers/net/wireless/ath/ath5k/attach.c
··· 27 27 #include "debug.h" 28 28 29 29 /** 30 - * ath5k_hw_post - Power On Self Test helper function 31 - * 30 + * ath5k_hw_post() - Power On Self Test helper function 32 31 * @ah: The &struct ath5k_hw 33 32 */ 34 33 static int ath5k_hw_post(struct ath5k_hw *ah) ··· 91 92 } 92 93 93 94 /** 94 - * ath5k_hw_init - Check if hw is supported and init the needed structs 95 - * 95 + * ath5k_hw_init() - Check if hw is supported and init the needed structs 96 96 * @ah: The &struct ath5k_hw associated with the device 97 97 * 98 98 * Check if the device is supported, perform a POST and initialize the needed ··· 347 349 } 348 350 349 351 /** 350 - * ath5k_hw_deinit - Free the ath5k_hw struct 351 - * 352 + * ath5k_hw_deinit() - Free the &struct ath5k_hw 352 353 * @ah: The &struct ath5k_hw 353 354 */ 354 355 void ath5k_hw_deinit(struct ath5k_hw *ah)
+1 -2
drivers/net/wireless/ath/ath5k/base.c
··· 183 183 { .bitrate = 540, 184 184 .hw_value = ATH5K_RATE_CODE_54M, 185 185 .flags = 0 }, 186 - /* XR missing */ 187 186 }; 188 187 189 188 static inline u64 ath5k_extend_tsf(struct ath5k_hw *ah, u32 rstamp) ··· 2004 2005 ah->nexttbtt = nexttbtt; 2005 2006 2006 2007 intval |= AR5K_BEACON_ENA; 2007 - ath5k_hw_init_beacon(ah, nexttbtt, intval); 2008 + ath5k_hw_init_beacon_timers(ah, nexttbtt, intval); 2008 2009 2009 2010 /* 2010 2011 * debugging output last in order to preserve the time critical aspect
+170 -47
drivers/net/wireless/ath/ath5k/desc.c
··· 26 26 #include "debug.h" 27 27 28 28 29 + /** 30 + * DOC: Hardware descriptor functions 31 + * 32 + * Here we handle the processing of the low-level hw descriptors 33 + * that hw reads and writes via DMA for each TX and RX attempt (that means 34 + * we can also have descriptors for failed TX/RX tries). We have two kind of 35 + * descriptors for RX and TX, control descriptors tell the hw how to send or 36 + * receive a packet where to read/write it from/to etc and status descriptors 37 + * that contain information about how the packet was sent or received (errors 38 + * included). 39 + * 40 + * Descriptor format is not exactly the same for each MAC chip version so we 41 + * have function pointers on &struct ath5k_hw we initialize at runtime based on 42 + * the chip used. 43 + */ 44 + 45 + 29 46 /************************\ 30 47 * TX Control descriptors * 31 48 \************************/ 32 49 33 - /* 34 - * Initialize the 2-word tx control descriptor on 5210/5211 50 + /** 51 + * ath5k_hw_setup_2word_tx_desc() - Initialize a 2-word tx control descriptor 52 + * @ah: The &struct ath5k_hw 53 + * @desc: The &struct ath5k_desc 54 + * @pkt_len: Frame length in bytes 55 + * @hdr_len: Header length in bytes (only used on AR5210) 56 + * @padsize: Any padding we've added to the frame length 57 + * @type: One of enum ath5k_pkt_type 58 + * @tx_power: Tx power in 0.5dB steps 59 + * @tx_rate0: HW idx for transmission rate 60 + * @tx_tries0: Max number of retransmissions 61 + * @key_index: Index on key table to use for encryption 62 + * @antenna_mode: Which antenna to use (0 for auto) 63 + * @flags: One of AR5K_TXDESC_* flags (desc.h) 64 + * @rtscts_rate: HW idx for RTS/CTS transmission rate 65 + * @rtscts_duration: What to put on duration field on the header of RTS/CTS 66 + * 67 + * Internal function to initialize a 2-Word TX control descriptor 68 + * found on AR5210 and AR5211 MACs chips. 69 + * 70 + * Returns 0 on success or -EINVAL on false input 35 71 */ 36 72 static int 37 - ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, 38 - unsigned int pkt_len, unsigned int hdr_len, int padsize, 39 - enum ath5k_pkt_type type, 40 - unsigned int tx_power, unsigned int tx_rate0, unsigned int tx_tries0, 41 - unsigned int key_index, unsigned int antenna_mode, unsigned int flags, 42 - unsigned int rtscts_rate, unsigned int rtscts_duration) 73 + ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, 74 + struct ath5k_desc *desc, 75 + unsigned int pkt_len, unsigned int hdr_len, 76 + int padsize, 77 + enum ath5k_pkt_type type, 78 + unsigned int tx_power, 79 + unsigned int tx_rate0, unsigned int tx_tries0, 80 + unsigned int key_index, 81 + unsigned int antenna_mode, 82 + unsigned int flags, 83 + unsigned int rtscts_rate, unsigned int rtscts_duration) 43 84 { 44 85 u32 frame_type; 45 86 struct ath5k_hw_2w_tx_ctl *tx_ctl; ··· 213 172 return 0; 214 173 } 215 174 216 - /* 217 - * Initialize the 4-word tx control descriptor on 5212 175 + /** 176 + * ath5k_hw_setup_4word_tx_desc() - Initialize a 4-word tx control descriptor 177 + * @ah: The &struct ath5k_hw 178 + * @desc: The &struct ath5k_desc 179 + * @pkt_len: Frame length in bytes 180 + * @hdr_len: Header length in bytes (only used on AR5210) 181 + * @padsize: Any padding we've added to the frame length 182 + * @type: One of enum ath5k_pkt_type 183 + * @tx_power: Tx power in 0.5dB steps 184 + * @tx_rate0: HW idx for transmission rate 185 + * @tx_tries0: Max number of retransmissions 186 + * @key_index: Index on key table to use for encryption 187 + * @antenna_mode: Which antenna to use (0 for auto) 188 + * @flags: One of AR5K_TXDESC_* flags (desc.h) 189 + * @rtscts_rate: HW idx for RTS/CTS transmission rate 190 + * @rtscts_duration: What to put on duration field on the header of RTS/CTS 191 + * 192 + * Internal function to initialize a 4-Word TX control descriptor 193 + * found on AR5212 and later MACs chips. 194 + * 195 + * Returns 0 on success or -EINVAL on false input 218 196 */ 219 - static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah, 220 - struct ath5k_desc *desc, unsigned int pkt_len, unsigned int hdr_len, 221 - int padsize, 222 - enum ath5k_pkt_type type, unsigned int tx_power, unsigned int tx_rate0, 223 - unsigned int tx_tries0, unsigned int key_index, 224 - unsigned int antenna_mode, unsigned int flags, 225 - unsigned int rtscts_rate, 226 - unsigned int rtscts_duration) 197 + static int 198 + ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah, 199 + struct ath5k_desc *desc, 200 + unsigned int pkt_len, unsigned int hdr_len, 201 + int padsize, 202 + enum ath5k_pkt_type type, 203 + unsigned int tx_power, 204 + unsigned int tx_rate0, unsigned int tx_tries0, 205 + unsigned int key_index, 206 + unsigned int antenna_mode, 207 + unsigned int flags, 208 + unsigned int rtscts_rate, unsigned int rtscts_duration) 227 209 { 228 210 struct ath5k_hw_4w_tx_ctl *tx_ctl; 229 211 unsigned int frame_len; ··· 356 292 return 0; 357 293 } 358 294 359 - /* 360 - * Initialize a 4-word multi rate retry tx control descriptor on 5212 295 + /** 296 + * ath5k_hw_setup_mrr_tx_desc() - Initialize an MRR tx control descriptor 297 + * @ah: The &struct ath5k_hw 298 + * @desc: The &struct ath5k_desc 299 + * @tx_rate1: HW idx for rate used on transmission series 1 300 + * @tx_tries1: Max number of retransmissions for transmission series 1 301 + * @tx_rate2: HW idx for rate used on transmission series 2 302 + * @tx_tries2: Max number of retransmissions for transmission series 2 303 + * @tx_rate3: HW idx for rate used on transmission series 3 304 + * @tx_tries3: Max number of retransmissions for transmission series 3 305 + * 306 + * Multi rate retry (MRR) tx control descriptors are available only on AR5212 307 + * MACs, they are part of the normal 4-word tx control descriptor (see above) 308 + * but we handle them through a separate function for better abstraction. 309 + * 310 + * Returns 0 on success or -EINVAL on invalid input 361 311 */ 362 312 int 363 - ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, 364 - unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2, 365 - u_int tx_tries2, unsigned int tx_rate3, u_int tx_tries3) 313 + ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, 314 + struct ath5k_desc *desc, 315 + u_int tx_rate1, u_int tx_tries1, 316 + u_int tx_rate2, u_int tx_tries2, 317 + u_int tx_rate3, u_int tx_tries3) 366 318 { 367 319 struct ath5k_hw_4w_tx_ctl *tx_ctl; 368 320 ··· 430 350 * TX Status descriptors * 431 351 \***********************/ 432 352 433 - /* 434 - * Process the tx status descriptor on 5210/5211 353 + /** 354 + * ath5k_hw_proc_2word_tx_status() - Process a tx status descriptor on 5210/1 355 + * @ah: The &struct ath5k_hw 356 + * @desc: The &struct ath5k_desc 357 + * @ts: The &struct ath5k_tx_status 435 358 */ 436 - static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah, 437 - struct ath5k_desc *desc, struct ath5k_tx_status *ts) 359 + static int 360 + ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah, 361 + struct ath5k_desc *desc, 362 + struct ath5k_tx_status *ts) 438 363 { 439 364 struct ath5k_hw_2w_tx_ctl *tx_ctl; 440 365 struct ath5k_hw_tx_status *tx_status; ··· 484 399 return 0; 485 400 } 486 401 487 - /* 488 - * Process a tx status descriptor on 5212 402 + /** 403 + * ath5k_hw_proc_4word_tx_status() - Process a tx status descriptor on 5212 404 + * @ah: The &struct ath5k_hw 405 + * @desc: The &struct ath5k_desc 406 + * @ts: The &struct ath5k_tx_status 489 407 */ 490 - static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah, 491 - struct ath5k_desc *desc, struct ath5k_tx_status *ts) 408 + static int 409 + ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah, 410 + struct ath5k_desc *desc, 411 + struct ath5k_tx_status *ts) 492 412 { 493 413 struct ath5k_hw_4w_tx_ctl *tx_ctl; 494 414 struct ath5k_hw_tx_status *tx_status; ··· 550 460 * RX Descriptors * 551 461 \****************/ 552 462 553 - /* 554 - * Initialize an rx control descriptor 463 + /** 464 + * ath5k_hw_setup_rx_desc() - Initialize an rx control descriptor 465 + * @ah: The &struct ath5k_hw 466 + * @desc: The &struct ath5k_desc 467 + * @size: RX buffer length in bytes 468 + * @flags: One of AR5K_RXDESC_* flags 555 469 */ 556 - int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, 557 - u32 size, unsigned int flags) 470 + int 471 + ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, 472 + struct ath5k_desc *desc, 473 + u32 size, unsigned int flags) 558 474 { 559 475 struct ath5k_hw_rx_ctl *rx_ctl; 560 476 ··· 587 491 return 0; 588 492 } 589 493 590 - /* 591 - * Process the rx status descriptor on 5210/5211 494 + /** 495 + * ath5k_hw_proc_5210_rx_status() - Process the rx status descriptor on 5210/1 496 + * @ah: The &struct ath5k_hw 497 + * @desc: The &struct ath5k_desc 498 + * @rs: The &struct ath5k_rx_status 499 + * 500 + * Internal function used to process an RX status descriptor 501 + * on AR5210/5211 MAC. 502 + * 503 + * Returns 0 on success or -EINPROGRESS in case we haven't received the who;e 504 + * frame yet. 592 505 */ 593 - static int ath5k_hw_proc_5210_rx_status(struct ath5k_hw *ah, 594 - struct ath5k_desc *desc, struct ath5k_rx_status *rs) 506 + static int 507 + ath5k_hw_proc_5210_rx_status(struct ath5k_hw *ah, 508 + struct ath5k_desc *desc, 509 + struct ath5k_rx_status *rs) 595 510 { 596 511 struct ath5k_hw_rx_status *rx_status; 597 512 ··· 681 574 return 0; 682 575 } 683 576 684 - /* 685 - * Process the rx status descriptor on 5212 577 + /** 578 + * ath5k_hw_proc_5212_rx_status() - Process the rx status descriptor on 5212 579 + * @ah: The &struct ath5k_hw 580 + * @desc: The &struct ath5k_desc 581 + * @rs: The &struct ath5k_rx_status 582 + * 583 + * Internal function used to process an RX status descriptor 584 + * on AR5212 and later MAC. 585 + * 586 + * Returns 0 on success or -EINPROGRESS in case we haven't received the who;e 587 + * frame yet. 686 588 */ 687 - static int ath5k_hw_proc_5212_rx_status(struct ath5k_hw *ah, 688 - struct ath5k_desc *desc, 689 - struct ath5k_rx_status *rs) 589 + static int 590 + ath5k_hw_proc_5212_rx_status(struct ath5k_hw *ah, 591 + struct ath5k_desc *desc, 592 + struct ath5k_rx_status *rs) 690 593 { 691 594 struct ath5k_hw_rx_status *rx_status; 692 595 u32 rxstat0, rxstat1; ··· 763 646 * Attach * 764 647 \********/ 765 648 766 - /* 767 - * Init function pointers inside ath5k_hw struct 649 + /** 650 + * ath5k_hw_init_desc_functions() - Init function pointers inside ah 651 + * @ah: The &struct ath5k_hw 652 + * 653 + * Maps the internal descriptor functions to the function pointers on ah, used 654 + * from above. This is used as an abstraction layer to handle the various chips 655 + * the same way. 768 656 */ 769 - int ath5k_hw_init_desc_functions(struct ath5k_hw *ah) 657 + int 658 + ath5k_hw_init_desc_functions(struct ath5k_hw *ah) 770 659 { 771 660 if (ah->ah_version == AR5K_AR5212) { 772 661 ah->ah_setup_tx_desc = ath5k_hw_setup_4word_tx_desc;
+83 -41
drivers/net/wireless/ath/ath5k/desc.h
··· 20 20 * RX/TX descriptor structures 21 21 */ 22 22 23 - /* 24 - * Common hardware RX control descriptor 23 + /** 24 + * struct ath5k_hw_rx_ctl - Common hardware RX control descriptor 25 + * @rx_control_0: RX control word 0 26 + * @rx_control_1: RX control word 1 25 27 */ 26 28 struct ath5k_hw_rx_ctl { 27 - u32 rx_control_0; /* RX control word 0 */ 28 - u32 rx_control_1; /* RX control word 1 */ 29 + u32 rx_control_0; 30 + u32 rx_control_1; 29 31 } __packed __aligned(4); 30 32 31 33 /* RX control word 1 fields/flags */ 32 34 #define AR5K_DESC_RX_CTL1_BUF_LEN 0x00000fff /* data buffer length */ 33 35 #define AR5K_DESC_RX_CTL1_INTREQ 0x00002000 /* RX interrupt request */ 34 36 35 - /* 36 - * Common hardware RX status descriptor 37 + /** 38 + * struct ath5k_hw_rx_status - Common hardware RX status descriptor 39 + * @rx_status_0: RX status word 0 40 + * @rx_status_1: RX status word 1 41 + * 37 42 * 5210, 5211 and 5212 differ only in the fields and flags defined below 38 43 */ 39 44 struct ath5k_hw_rx_status { 40 - u32 rx_status_0; /* RX status word 0 */ 41 - u32 rx_status_1; /* RX status word 1 */ 45 + u32 rx_status_0; 46 + u32 rx_status_1; 42 47 } __packed __aligned(4); 43 48 44 49 /* 5210/5211 */ ··· 103 98 104 99 /** 105 100 * enum ath5k_phy_error_code - PHY Error codes 101 + * @AR5K_RX_PHY_ERROR_UNDERRUN: Transmit underrun, [5210] No error 102 + * @AR5K_RX_PHY_ERROR_TIMING: Timing error 103 + * @AR5K_RX_PHY_ERROR_PARITY: Illegal parity 104 + * @AR5K_RX_PHY_ERROR_RATE: Illegal rate 105 + * @AR5K_RX_PHY_ERROR_LENGTH: Illegal length 106 + * @AR5K_RX_PHY_ERROR_RADAR: Radar detect, [5210] 64 QAM rate 107 + * @AR5K_RX_PHY_ERROR_SERVICE: Illegal service 108 + * @AR5K_RX_PHY_ERROR_TOR: Transmit override receive 109 + * @AR5K_RX_PHY_ERROR_OFDM_TIMING: OFDM Timing error [5212+] 110 + * @AR5K_RX_PHY_ERROR_OFDM_SIGNAL_PARITY: OFDM Signal parity error [5212+] 111 + * @AR5K_RX_PHY_ERROR_OFDM_RATE_ILLEGAL: OFDM Illegal rate [5212+] 112 + * @AR5K_RX_PHY_ERROR_OFDM_LENGTH_ILLEGAL: OFDM Illegal length [5212+] 113 + * @AR5K_RX_PHY_ERROR_OFDM_POWER_DROP: OFDM Power drop [5212+] 114 + * @AR5K_RX_PHY_ERROR_OFDM_SERVICE: OFDM Service (?) [5212+] 115 + * @AR5K_RX_PHY_ERROR_OFDM_RESTART: OFDM Restart (?) [5212+] 116 + * @AR5K_RX_PHY_ERROR_CCK_TIMING: CCK Timing error [5212+] 117 + * @AR5K_RX_PHY_ERROR_CCK_HEADER_CRC: Header CRC error [5212+] 118 + * @AR5K_RX_PHY_ERROR_CCK_RATE_ILLEGAL: Illegal rate [5212+] 119 + * @AR5K_RX_PHY_ERROR_CCK_SERVICE: CCK Service (?) [5212+] 120 + * @AR5K_RX_PHY_ERROR_CCK_RESTART: CCK Restart (?) [5212+] 106 121 */ 107 122 enum ath5k_phy_error_code { 108 - AR5K_RX_PHY_ERROR_UNDERRUN = 0, /* Transmit underrun, [5210] No error */ 109 - AR5K_RX_PHY_ERROR_TIMING = 1, /* Timing error */ 110 - AR5K_RX_PHY_ERROR_PARITY = 2, /* Illegal parity */ 111 - AR5K_RX_PHY_ERROR_RATE = 3, /* Illegal rate */ 112 - AR5K_RX_PHY_ERROR_LENGTH = 4, /* Illegal length */ 113 - AR5K_RX_PHY_ERROR_RADAR = 5, /* Radar detect, [5210] 64 QAM rate */ 114 - AR5K_RX_PHY_ERROR_SERVICE = 6, /* Illegal service */ 115 - AR5K_RX_PHY_ERROR_TOR = 7, /* Transmit override receive */ 116 - /* these are specific to the 5212 */ 123 + AR5K_RX_PHY_ERROR_UNDERRUN = 0, 124 + AR5K_RX_PHY_ERROR_TIMING = 1, 125 + AR5K_RX_PHY_ERROR_PARITY = 2, 126 + AR5K_RX_PHY_ERROR_RATE = 3, 127 + AR5K_RX_PHY_ERROR_LENGTH = 4, 128 + AR5K_RX_PHY_ERROR_RADAR = 5, 129 + AR5K_RX_PHY_ERROR_SERVICE = 6, 130 + AR5K_RX_PHY_ERROR_TOR = 7, 117 131 AR5K_RX_PHY_ERROR_OFDM_TIMING = 17, 118 132 AR5K_RX_PHY_ERROR_OFDM_SIGNAL_PARITY = 18, 119 133 AR5K_RX_PHY_ERROR_OFDM_RATE_ILLEGAL = 19, ··· 147 123 AR5K_RX_PHY_ERROR_CCK_RESTART = 31, 148 124 }; 149 125 150 - /* 151 - * 5210/5211 hardware 2-word TX control descriptor 126 + /** 127 + * struct ath5k_hw_2w_tx_ctl - 5210/5211 hardware 2-word TX control descriptor 128 + * @tx_control_0: TX control word 0 129 + * @tx_control_1: TX control word 1 152 130 */ 153 131 struct ath5k_hw_2w_tx_ctl { 154 - u32 tx_control_0; /* TX control word 0 */ 155 - u32 tx_control_1; /* TX control word 1 */ 132 + u32 tx_control_0; 133 + u32 tx_control_1; 156 134 } __packed __aligned(4); 157 135 158 136 /* TX control word 0 fields/flags */ ··· 203 177 #define AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS 4 204 178 #define AR5K_AR5211_TX_DESC_FRAME_TYPE_PRESP 4 205 179 206 - /* 207 - * 5212 hardware 4-word TX control descriptor 180 + /** 181 + * struct ath5k_hw_4w_tx_ctl - 5212 hardware 4-word TX control descriptor 182 + * @tx_control_0: TX control word 0 183 + * @tx_control_1: TX control word 1 184 + * @tx_control_2: TX control word 2 185 + * @tx_control_3: TX control word 3 208 186 */ 209 187 struct ath5k_hw_4w_tx_ctl { 210 - u32 tx_control_0; /* TX control word 0 */ 211 - u32 tx_control_1; /* TX control word 1 */ 212 - u32 tx_control_2; /* TX control word 2 */ 213 - u32 tx_control_3; /* TX control word 3 */ 188 + u32 tx_control_0; 189 + u32 tx_control_1; 190 + u32 tx_control_2; 191 + u32 tx_control_3; 214 192 } __packed __aligned(4); 215 193 216 194 /* TX control word 0 fields/flags */ ··· 268 238 #define AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE 0x01f00000 /* RTS or CTS rate */ 269 239 #define AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE_S 20 270 240 271 - /* 272 - * Common TX status descriptor 241 + /** 242 + * struct ath5k_hw_tx_status - Common TX status descriptor 243 + * @tx_status_0: TX status word 0 244 + * @tx_status_1: TX status word 1 273 245 */ 274 246 struct ath5k_hw_tx_status { 275 - u32 tx_status_0; /* TX status word 0 */ 276 - u32 tx_status_1; /* TX status word 1 */ 247 + u32 tx_status_0; 248 + u32 tx_status_1; 277 249 } __packed __aligned(4); 278 250 279 251 /* TX status word 0 fields/flags */ ··· 308 276 #define AR5K_DESC_TX_STATUS1_COMP_SUCCESS_5212 0x00800000 /* [5212] compression status */ 309 277 #define AR5K_DESC_TX_STATUS1_XMIT_ANTENNA_5212 0x01000000 /* [5212] transmit antenna */ 310 278 311 - /* 312 - * 5210/5211 hardware TX descriptor 279 + /** 280 + * struct ath5k_hw_5210_tx_desc - 5210/5211 hardware TX descriptor 281 + * @tx_ctl: The &struct ath5k_hw_2w_tx_ctl 282 + * @tx_stat: The &struct ath5k_hw_tx_status 313 283 */ 314 284 struct ath5k_hw_5210_tx_desc { 315 285 struct ath5k_hw_2w_tx_ctl tx_ctl; 316 286 struct ath5k_hw_tx_status tx_stat; 317 287 } __packed __aligned(4); 318 288 319 - /* 320 - * 5212 hardware TX descriptor 289 + /** 290 + * struct ath5k_hw_5212_tx_desc - 5212 hardware TX descriptor 291 + * @tx_ctl: The &struct ath5k_hw_4w_tx_ctl 292 + * @tx_stat: The &struct ath5k_hw_tx_status 321 293 */ 322 294 struct ath5k_hw_5212_tx_desc { 323 295 struct ath5k_hw_4w_tx_ctl tx_ctl; 324 296 struct ath5k_hw_tx_status tx_stat; 325 297 } __packed __aligned(4); 326 298 327 - /* 328 - * Common hardware RX descriptor 299 + /** 300 + * struct ath5k_hw_all_rx_desc - Common hardware RX descriptor 301 + * @rx_ctl: The &struct ath5k_hw_rx_ctl 302 + * @rx_stat: The &struct ath5k_hw_rx_status 329 303 */ 330 304 struct ath5k_hw_all_rx_desc { 331 305 struct ath5k_hw_rx_ctl rx_ctl; 332 306 struct ath5k_hw_rx_status rx_stat; 333 307 } __packed __aligned(4); 334 308 335 - /* 336 - * Atheros hardware DMA descriptor 309 + /** 310 + * struct ath5k_desc - Atheros hardware DMA descriptor 311 + * @ds_link: Physical address of the next descriptor 312 + * @ds_data: Physical address of data buffer (skb) 313 + * @ud: Union containing hw_5xxx_tx_desc structs and hw_all_rx_desc 314 + * 337 315 * This is read and written to by the hardware 338 316 */ 339 317 struct ath5k_desc { 340 - u32 ds_link; /* physical address of the next descriptor */ 341 - u32 ds_data; /* physical address of data buffer (skb) */ 318 + u32 ds_link; 319 + u32 ds_data; 342 320 343 321 union { 344 322 struct ath5k_hw_5210_tx_desc ds_tx5210;
+54 -66
drivers/net/wireless/ath/ath5k/dma.c
··· 20 20 * DMA and interrupt masking functions * 21 21 \*************************************/ 22 22 23 - /* 24 - * dma.c - DMA and interrupt masking functions 23 + /** 24 + * DOC: DMA and interrupt masking functions 25 25 * 26 26 * Here we setup descriptor pointers (rxdp/txdp) start/stop dma engine and 27 27 * handle queue setup for 5210 chipset (rest are handled on qcu.c). 28 28 * Also we setup interrupt mask register (IMR) and read the various interrupt 29 29 * status registers (ISR). 30 - * 31 - * TODO: Handle SISR on 5211+ and introduce a function to return the queue 32 - * number that resulted the interrupt. 33 30 */ 34 31 35 32 #include "ath5k.h" ··· 39 42 \*********/ 40 43 41 44 /** 42 - * ath5k_hw_start_rx_dma - Start DMA receive 43 - * 45 + * ath5k_hw_start_rx_dma() - Start DMA receive 44 46 * @ah: The &struct ath5k_hw 45 47 */ 46 - void ath5k_hw_start_rx_dma(struct ath5k_hw *ah) 48 + void 49 + ath5k_hw_start_rx_dma(struct ath5k_hw *ah) 47 50 { 48 51 ath5k_hw_reg_write(ah, AR5K_CR_RXE, AR5K_CR); 49 52 ath5k_hw_reg_read(ah, AR5K_CR); 50 53 } 51 54 52 55 /** 53 - * ath5k_hw_stop_rx_dma - Stop DMA receive 54 - * 56 + * ath5k_hw_stop_rx_dma() - Stop DMA receive 55 57 * @ah: The &struct ath5k_hw 56 58 */ 57 - static int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah) 59 + static int 60 + ath5k_hw_stop_rx_dma(struct ath5k_hw *ah) 58 61 { 59 62 unsigned int i; 60 63 ··· 76 79 } 77 80 78 81 /** 79 - * ath5k_hw_get_rxdp - Get RX Descriptor's address 80 - * 82 + * ath5k_hw_get_rxdp() - Get RX Descriptor's address 81 83 * @ah: The &struct ath5k_hw 82 84 */ 83 - u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah) 85 + u32 86 + ath5k_hw_get_rxdp(struct ath5k_hw *ah) 84 87 { 85 88 return ath5k_hw_reg_read(ah, AR5K_RXDP); 86 89 } 87 90 88 91 /** 89 - * ath5k_hw_set_rxdp - Set RX Descriptor's address 90 - * 92 + * ath5k_hw_set_rxdp() - Set RX Descriptor's address 91 93 * @ah: The &struct ath5k_hw 92 94 * @phys_addr: RX descriptor address 93 95 * 94 96 * Returns -EIO if rx is active 95 97 */ 96 - int ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr) 98 + int 99 + ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr) 97 100 { 98 101 if (ath5k_hw_reg_read(ah, AR5K_CR) & AR5K_CR_RXE) { 99 102 ATH5K_DBG(ah, ATH5K_DEBUG_DMA, ··· 111 114 \**********/ 112 115 113 116 /** 114 - * ath5k_hw_start_tx_dma - Start DMA transmit for a specific queue 115 - * 117 + * ath5k_hw_start_tx_dma() - Start DMA transmit for a specific queue 116 118 * @ah: The &struct ath5k_hw 117 119 * @queue: The hw queue number 118 120 * ··· 124 128 * NOTE: Must be called after setting up tx control descriptor for that 125 129 * queue (see below). 126 130 */ 127 - int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue) 131 + int 132 + ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue) 128 133 { 129 134 u32 tx_queue; 130 135 ··· 174 177 } 175 178 176 179 /** 177 - * ath5k_hw_stop_tx_dma - Stop DMA transmit on a specific queue 178 - * 180 + * ath5k_hw_stop_tx_dma() - Stop DMA transmit on a specific queue 179 181 * @ah: The &struct ath5k_hw 180 182 * @queue: The hw queue number 181 183 * 182 184 * Stop DMA transmit on a specific hw queue and drain queue so we don't 183 185 * have any pending frames. Returns -EBUSY if we still have pending frames, 184 186 * -EINVAL if queue number is out of range or inactive. 185 - * 186 187 */ 187 - static int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue) 188 + static int 189 + ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue) 188 190 { 189 191 unsigned int i = 40; 190 192 u32 tx_queue, pending; ··· 316 320 } 317 321 318 322 /** 319 - * ath5k_hw_stop_beacon_queue - Stop beacon queue 320 - * 321 - * @ah The &struct ath5k_hw 322 - * @queue The queue number 323 + * ath5k_hw_stop_beacon_queue() - Stop beacon queue 324 + * @ah: The &struct ath5k_hw 325 + * @queue: The queue number 323 326 * 324 327 * Returns -EIO if queue didn't stop 325 328 */ 326 - int ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue) 329 + int 330 + ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue) 327 331 { 328 332 int ret; 329 333 ret = ath5k_hw_stop_tx_dma(ah, queue); ··· 336 340 } 337 341 338 342 /** 339 - * ath5k_hw_get_txdp - Get TX Descriptor's address for a specific queue 340 - * 343 + * ath5k_hw_get_txdp() - Get TX Descriptor's address for a specific queue 341 344 * @ah: The &struct ath5k_hw 342 345 * @queue: The hw queue number 343 346 * ··· 347 352 * 348 353 * XXX: Is TXDP read and clear ? 349 354 */ 350 - u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue) 355 + u32 356 + ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue) 351 357 { 352 358 u16 tx_reg; 353 359 ··· 378 382 } 379 383 380 384 /** 381 - * ath5k_hw_set_txdp - Set TX Descriptor's address for a specific queue 382 - * 385 + * ath5k_hw_set_txdp() - Set TX Descriptor's address for a specific queue 383 386 * @ah: The &struct ath5k_hw 384 387 * @queue: The hw queue number 388 + * @phys_addr: The physical address 385 389 * 386 390 * Set TX descriptor's address for a specific queue. For 5210 we ignore 387 391 * the queue number and we use tx queue type since we only have 2 queues ··· 390 394 * Returns -EINVAL if queue type is invalid for 5210 and -EIO if queue is still 391 395 * active. 392 396 */ 393 - int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr) 397 + int 398 + ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr) 394 399 { 395 400 u16 tx_reg; 396 401 ··· 432 435 } 433 436 434 437 /** 435 - * ath5k_hw_update_tx_triglevel - Update tx trigger level 436 - * 438 + * ath5k_hw_update_tx_triglevel() - Update tx trigger level 437 439 * @ah: The &struct ath5k_hw 438 440 * @increase: Flag to force increase of trigger level 439 441 * ··· 440 444 * buffer (aka FIFO threshold) that is used to indicate when PCU flushes 441 445 * the buffer and transmits its data. Lowering this results sending small 442 446 * frames more quickly but can lead to tx underruns, raising it a lot can 443 - * result other problems (i think bmiss is related). Right now we start with 444 - * the lowest possible (64Bytes) and if we get tx underrun we increase it using 445 - * the increase flag. Returns -EIO if we have reached maximum/minimum. 447 + * result other problems. Right now we start with the lowest possible 448 + * (64Bytes) and if we get tx underrun we increase it using the increase 449 + * flag. Returns -EIO if we have reached maximum/minimum. 446 450 * 447 451 * XXX: Link this with tx DMA size ? 448 - * XXX: Use it to save interrupts ? 452 + * XXX2: Use it to save interrupts ? 449 453 */ 450 - int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase) 454 + int 455 + ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase) 451 456 { 452 457 u32 trigger_level, imr; 453 458 int ret = -EIO; ··· 494 497 \*******************/ 495 498 496 499 /** 497 - * ath5k_hw_is_intr_pending - Check if we have pending interrupts 498 - * 500 + * ath5k_hw_is_intr_pending() - Check if we have pending interrupts 499 501 * @ah: The &struct ath5k_hw 500 502 * 501 503 * Check if we have pending interrupts to process. Returns 1 if we 502 504 * have pending interrupts and 0 if we haven't. 503 505 */ 504 - bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah) 506 + bool 507 + ath5k_hw_is_intr_pending(struct ath5k_hw *ah) 505 508 { 506 509 return ath5k_hw_reg_read(ah, AR5K_INTPEND) == 1 ? 1 : 0; 507 510 } 508 511 509 512 /** 510 - * ath5k_hw_get_isr - Get interrupt status 511 - * 513 + * ath5k_hw_get_isr() - Get interrupt status 512 514 * @ah: The @struct ath5k_hw 513 515 * @interrupt_mask: Driver's interrupt mask used to filter out 514 516 * interrupts in sw. ··· 521 525 * NOTE: We do write-to-clear, so the active PISR/SISR bits at the time this 522 526 * function gets called are cleared on return. 523 527 */ 524 - int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) 528 + int 529 + ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) 525 530 { 526 531 u32 data = 0; 527 532 ··· 693 696 if (unlikely(pisr & (AR5K_ISR_HIUERR))) 694 697 *interrupt_mask |= AR5K_INT_FATAL; 695 698 696 - 697 699 /*Beacon Not Ready*/ 698 700 if (unlikely(pisr & (AR5K_ISR_BNR))) 699 701 *interrupt_mask |= AR5K_INT_BNR; 700 - 701 - /* Doppler chirp received */ 702 - if (unlikely(pisr & (AR5K_ISR_RXDOPPLER))) 703 - *interrupt_mask |= AR5K_INT_RX_DOPPLER; 704 702 705 703 /* A queue got CBR overrun */ 706 704 if (unlikely(pisr & (AR5K_ISR_QCBRORN))) { ··· 732 740 } 733 741 734 742 /** 735 - * ath5k_hw_set_imr - Set interrupt mask 736 - * 743 + * ath5k_hw_set_imr() - Set interrupt mask 737 744 * @ah: The &struct ath5k_hw 738 745 * @new_mask: The new interrupt mask to be set 739 746 * ··· 740 749 * ath5k_int bits to hw-specific bits to remove abstraction and writing 741 750 * Interrupt Mask Register. 742 751 */ 743 - enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) 752 + enum ath5k_int 753 + ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) 744 754 { 745 755 enum ath5k_int old_mask, int_mask; 746 756 ··· 794 802 if (new_mask & AR5K_INT_BNR) 795 803 int_mask |= AR5K_INT_BNR; 796 804 797 - /* RX doppler chirp */ 798 - if (new_mask & AR5K_INT_RX_DOPPLER) 799 - int_mask |= AR5K_IMR_RXDOPPLER; 800 - 801 805 /* Note: Per queue interrupt masks 802 806 * are set via ath5k_hw_reset_tx_queue() (qcu.c) */ 803 807 ath5k_hw_reg_write(ah, int_mask, AR5K_PIMR); ··· 832 844 \********************/ 833 845 834 846 /** 835 - * ath5k_hw_dma_init - Initialize DMA unit 836 - * 847 + * ath5k_hw_dma_init() - Initialize DMA unit 837 848 * @ah: The &struct ath5k_hw 838 849 * 839 850 * Set DMA size and pre-enable interrupts ··· 841 854 * 842 855 * XXX: Save/restore RXDP/TXDP registers ? 843 856 */ 844 - void ath5k_hw_dma_init(struct ath5k_hw *ah) 857 + void 858 + ath5k_hw_dma_init(struct ath5k_hw *ah) 845 859 { 846 860 /* 847 861 * Set Rx/Tx DMA Configuration ··· 871 883 } 872 884 873 885 /** 874 - * ath5k_hw_dma_stop - stop DMA unit 875 - * 886 + * ath5k_hw_dma_stop() - stop DMA unit 876 887 * @ah: The &struct ath5k_hw 877 888 * 878 889 * Stop tx/rx DMA and interrupts. Returns ··· 881 894 * stuck frames on tx queues, only a reset 882 895 * can fix that. 883 896 */ 884 - int ath5k_hw_dma_stop(struct ath5k_hw *ah) 897 + int 898 + ath5k_hw_dma_stop(struct ath5k_hw *ah) 885 899 { 886 900 int i, qmax, err; 887 901 err = 0;
+63 -18
drivers/net/wireless/ath/ath5k/gpio.c
··· 24 24 #include "reg.h" 25 25 #include "debug.h" 26 26 27 - /* 28 - * Set led state 27 + 28 + /** 29 + * DOC: GPIO/LED functions 30 + * 31 + * Here we control the 6 bidirectional GPIO pins provided by the hw. 32 + * We can set a GPIO pin to be an input or an output pin on GPIO control 33 + * register and then read or set its status from GPIO data input/output 34 + * registers. 35 + * 36 + * We also control the two LED pins provided by the hw, LED_0 is our 37 + * "power" LED and LED_1 is our "network activity" LED but many scenarios 38 + * are available from hw. Vendors might also provide LEDs connected to the 39 + * GPIO pins, we handle them through the LED subsystem on led.c 29 40 */ 30 - void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state) 41 + 42 + 43 + /** 44 + * ath5k_hw_set_ledstate() - Set led state 45 + * @ah: The &struct ath5k_hw 46 + * @state: One of AR5K_LED_* 47 + * 48 + * Used to set the LED blinking state. This only 49 + * works for the LED connected to the LED_0, LED_1 pins, 50 + * not the GPIO based. 51 + */ 52 + void 53 + ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state) 31 54 { 32 55 u32 led; 33 56 /*5210 has different led mode handling*/ ··· 97 74 AR5K_REG_ENABLE_BITS(ah, AR5K_PCICFG, led_5210); 98 75 } 99 76 100 - /* 101 - * Set GPIO inputs 77 + /** 78 + * ath5k_hw_set_gpio_input() - Set GPIO inputs 79 + * @ah: The &struct ath5k_hw 80 + * @gpio: GPIO pin to set as input 102 81 */ 103 - int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) 82 + int 83 + ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) 104 84 { 105 85 if (gpio >= AR5K_NUM_GPIO) 106 86 return -EINVAL; ··· 115 89 return 0; 116 90 } 117 91 118 - /* 119 - * Set GPIO outputs 92 + /** 93 + * ath5k_hw_set_gpio_output() - Set GPIO outputs 94 + * @ah: The &struct ath5k_hw 95 + * @gpio: The GPIO pin to set as output 120 96 */ 121 - int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) 97 + int 98 + ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) 122 99 { 123 100 if (gpio >= AR5K_NUM_GPIO) 124 101 return -EINVAL; ··· 133 104 return 0; 134 105 } 135 106 136 - /* 137 - * Get GPIO state 107 + /** 108 + * ath5k_hw_get_gpio() - Get GPIO state 109 + * @ah: The &struct ath5k_hw 110 + * @gpio: The GPIO pin to read 138 111 */ 139 - u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio) 112 + u32 113 + ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio) 140 114 { 141 115 if (gpio >= AR5K_NUM_GPIO) 142 116 return 0xffffffff; ··· 149 117 0x1; 150 118 } 151 119 152 - /* 153 - * Set GPIO state 120 + /** 121 + * ath5k_hw_set_gpio() - Set GPIO state 122 + * @ah: The &struct ath5k_hw 123 + * @gpio: The GPIO pin to set 124 + * @val: Value to set (boolean) 154 125 */ 155 - int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val) 126 + int 127 + ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val) 156 128 { 157 129 u32 data; 158 130 ··· 174 138 return 0; 175 139 } 176 140 177 - /* 178 - * Initialize the GPIO interrupt (RFKill switch) 141 + /** 142 + * ath5k_hw_set_gpio_intr() - Initialize the GPIO interrupt (RFKill switch) 143 + * @ah: The &struct ath5k_hw 144 + * @gpio: The GPIO pin to use 145 + * @interrupt_level: True to generate interrupt on active pin (high) 146 + * 147 + * This function is used to set up the GPIO interrupt for the hw RFKill switch. 148 + * That switch is connected to a GPIO pin and it's number is stored on EEPROM. 149 + * It can either open or close the circuit to indicate that we should disable 150 + * RF/Wireless to save power (we also get that from EEPROM). 179 151 */ 180 - void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, 152 + void 153 + ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, 181 154 u32 interrupt_level) 182 155 { 183 156 u32 data;
+54 -21
drivers/net/wireless/ath/ath5k/initvals.c
··· 23 23 #include "reg.h" 24 24 #include "debug.h" 25 25 26 - /* 27 - * Mode-independent initial register writes 26 + /** 27 + * struct ath5k_ini - Mode-independent initial register writes 28 + * @ini_register: Register address 29 + * @ini_value: Default value 30 + * @ini_mode: 0 to write 1 to read (and clear) 28 31 */ 29 - 30 32 struct ath5k_ini { 31 33 u16 ini_register; 32 34 u32 ini_value; 33 35 34 36 enum { 35 37 AR5K_INI_WRITE = 0, /* Default */ 36 - AR5K_INI_READ = 1, /* Cleared on read */ 38 + AR5K_INI_READ = 1, 37 39 } ini_mode; 38 40 }; 39 41 40 - /* 41 - * Mode specific initial register values 42 + /** 43 + * struct ath5k_ini_mode - Mode specific initial register values 44 + * @mode_register: Register address 45 + * @mode_value: Set of values for each enum ath5k_driver_mode 42 46 */ 43 - 44 47 struct ath5k_ini_mode { 45 48 u16 mode_register; 46 49 u32 mode_value[3]; ··· 389 386 390 387 /* Initial mode-specific settings for AR5211 391 388 * 5211 supports OFDM-only g (draft g) but we 392 - * need to test it ! 393 - */ 389 + * need to test it ! */ 394 390 static const struct ath5k_ini_mode ar5211_ini_mode[] = { 395 391 { AR5K_TXCFG, 396 - /* A/XR B G */ 392 + /* A B G */ 397 393 { 0x00000015, 0x0000001d, 0x00000015 } }, 398 394 { AR5K_QUEUE_DFS_LOCAL_IFS(0), 399 395 { 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } }, ··· 462 460 { 0x00000010, 0x00000010, 0x00000010 } }, 463 461 }; 464 462 465 - /* Initial register settings for AR5212 */ 463 + /* Initial register settings for AR5212 and newer chips */ 466 464 static const struct ath5k_ini ar5212_ini_common_start[] = { 467 465 { AR5K_RXDP, 0x00000000 }, 468 466 { AR5K_RXCFG, 0x00000005 }, ··· 726 724 { 0x00000000, 0x00000000, 0x00000108 } }, 727 725 }; 728 726 729 - /* Initial mode-specific settings for AR5212 + RF5111 (Written after ar5212_ini) */ 727 + /* Initial mode-specific settings for AR5212 + RF5111 728 + * (Written after ar5212_ini) */ 730 729 static const struct ath5k_ini_mode rf5111_ini_mode_end[] = { 731 730 { AR5K_TXCFG, 732 731 /* A/XR B G */ ··· 760 757 { 0x1883800a, 0x1873800a, 0x1883800a } }, 761 758 }; 762 759 760 + /* Common for all modes */ 763 761 static const struct ath5k_ini rf5111_ini_common_end[] = { 764 762 { AR5K_DCU_FP, 0x00000000 }, 765 763 { AR5K_PHY_AGC, 0x00000000 }, ··· 778 774 { 0xa23c, 0x13c889af }, 779 775 }; 780 776 781 - /* Initial mode-specific settings for AR5212 + RF5112 (Written after ar5212_ini) */ 777 + 778 + /* Initial mode-specific settings for AR5212 + RF5112 779 + * (Written after ar5212_ini) */ 782 780 static const struct ath5k_ini_mode rf5112_ini_mode_end[] = { 783 781 { AR5K_TXCFG, 784 782 /* A/XR B G */ ··· 831 825 { 0xa23c, 0x13c889af }, 832 826 }; 833 827 834 - /* Initial mode-specific settings for RF5413/5414 (Written after ar5212_ini) */ 828 + 829 + /* Initial mode-specific settings for RF5413/5414 830 + * (Written after ar5212_ini) */ 835 831 static const struct ath5k_ini_mode rf5413_ini_mode_end[] = { 836 832 { AR5K_TXCFG, 837 833 /* A/XR B G */ ··· 971 963 { 0xa384, 0xf3307ff0 }, 972 964 }; 973 965 974 - /* Initial mode-specific settings for RF2413/2414 (Written after ar5212_ini) */ 966 + /* Initial mode-specific settings for RF2413/2414 967 + * (Written after ar5212_ini) */ 975 968 /* XXX: a mode ? */ 976 969 static const struct ath5k_ini_mode rf2413_ini_mode_end[] = { 977 970 { AR5K_TXCFG, ··· 1094 1085 { 0xa384, 0xf3307ff0 }, 1095 1086 }; 1096 1087 1097 - /* Initial mode-specific settings for RF2425 (Written after ar5212_ini) */ 1088 + /* Initial mode-specific settings for RF2425 1089 + * (Written after ar5212_ini) */ 1098 1090 /* XXX: a mode ? */ 1099 1091 static const struct ath5k_ini_mode rf2425_ini_mode_end[] = { 1100 1092 { AR5K_TXCFG, ··· 1367 1357 }; 1368 1358 1369 1359 1370 - /* 1371 - * Write initial register dump 1360 + /** 1361 + * ath5k_hw_ini_registers() - Write initial register dump common for all modes 1362 + * @ah: The &struct ath5k_hw 1363 + * @size: Dump size 1364 + * @ini_regs: The array of &struct ath5k_ini 1365 + * @skip_pcu: Skip PCU registers 1372 1366 */ 1373 - static void ath5k_hw_ini_registers(struct ath5k_hw *ah, unsigned int size, 1367 + static void 1368 + ath5k_hw_ini_registers(struct ath5k_hw *ah, unsigned int size, 1374 1369 const struct ath5k_ini *ini_regs, bool skip_pcu) 1375 1370 { 1376 1371 unsigned int i; ··· 1403 1388 } 1404 1389 } 1405 1390 1406 - static void ath5k_hw_ini_mode_registers(struct ath5k_hw *ah, 1391 + /** 1392 + * ath5k_hw_ini_mode_registers() - Write initial mode-specific register dump 1393 + * @ah: The &struct ath5k_hw 1394 + * @size: Dump size 1395 + * @ini_mode: The array of &struct ath5k_ini_mode 1396 + * @mode: One of enum ath5k_driver_mode 1397 + */ 1398 + static void 1399 + ath5k_hw_ini_mode_registers(struct ath5k_hw *ah, 1407 1400 unsigned int size, const struct ath5k_ini_mode *ini_mode, 1408 1401 u8 mode) 1409 1402 { ··· 1425 1402 1426 1403 } 1427 1404 1428 - int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool skip_pcu) 1405 + /** 1406 + * ath5k_hw_write_initvals() - Write initial chip-specific register dump 1407 + * @ah: The &struct ath5k_hw 1408 + * @mode: One of enum ath5k_driver_mode 1409 + * @skip_pcu: Skip PCU registers 1410 + * 1411 + * Write initial chip-specific register dump, to get the chipset on a 1412 + * clean and ready-to-work state after warm reset. 1413 + */ 1414 + int 1415 + ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool skip_pcu) 1429 1416 { 1430 1417 /* 1431 1418 * Write initial register settings
+147 -75
drivers/net/wireless/ath/ath5k/pcu.c
··· 30 30 #include "reg.h" 31 31 #include "debug.h" 32 32 33 - /* 33 + /** 34 + * DOC: Protocol Control Unit (PCU) functions 35 + * 36 + * Protocol control unit is responsible to maintain various protocol 37 + * properties before a frame is send and after a frame is received to/from 38 + * baseband. To be more specific, PCU handles: 39 + * 40 + * - Buffering of RX and TX frames (after QCU/DCUs) 41 + * 42 + * - Encrypting and decrypting (using the built-in engine) 43 + * 44 + * - Generating ACKs, RTS/CTS frames 45 + * 46 + * - Maintaining TSF 47 + * 48 + * - FCS 49 + * 50 + * - Updating beacon data (with TSF etc) 51 + * 52 + * - Generating virtual CCA 53 + * 54 + * - RX/Multicast filtering 55 + * 56 + * - BSSID filtering 57 + * 58 + * - Various statistics 59 + * 60 + * -Different operating modes: AP, STA, IBSS 61 + * 62 + * Note: Most of these functions can be tweaked/bypassed so you can do 63 + * them on sw above for debugging or research. For more infos check out PCU 64 + * registers on reg.h. 65 + */ 66 + 67 + /** 68 + * DOC: ACK rates 69 + * 34 70 * AR5212+ can use higher rates for ack transmission 35 71 * based on current tx rate instead of the base rate. 36 72 * It does this to better utilize channel usage. 37 - * This is a mapping between G rates (that cover both 73 + * There is a mapping between G rates (that cover both 38 74 * CCK and OFDM) and ack rates that we use when setting 39 75 * rate -> duration table. This mapping is hw-based so 40 76 * don't change anything. ··· 99 63 \*******************/ 100 64 101 65 /** 102 - * ath5k_hw_get_frame_duration - Get tx time of a frame 103 - * 66 + * ath5k_hw_get_frame_duration() - Get tx time of a frame 104 67 * @ah: The &struct ath5k_hw 105 68 * @len: Frame's length in bytes 106 69 * @rate: The @struct ieee80211_rate 70 + * @shortpre: Indicate short preample 107 71 * 108 72 * Calculate tx duration of a frame given it's rate and length 109 73 * It extends ieee80211_generic_frame_duration for non standard 110 74 * bwmodes. 111 75 */ 112 - int ath5k_hw_get_frame_duration(struct ath5k_hw *ah, 76 + int 77 + ath5k_hw_get_frame_duration(struct ath5k_hw *ah, 113 78 int len, struct ieee80211_rate *rate, bool shortpre) 114 79 { 115 80 int sifs, preamble, plcp_bits, sym_time; ··· 166 129 } 167 130 168 131 /** 169 - * ath5k_hw_get_default_slottime - Get the default slot time for current mode 170 - * 132 + * ath5k_hw_get_default_slottime() - Get the default slot time for current mode 171 133 * @ah: The &struct ath5k_hw 172 134 */ 173 - unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah) 135 + unsigned int 136 + ath5k_hw_get_default_slottime(struct ath5k_hw *ah) 174 137 { 175 138 struct ieee80211_channel *channel = ah->ah_current_channel; 176 139 unsigned int slot_time; ··· 197 160 } 198 161 199 162 /** 200 - * ath5k_hw_get_default_sifs - Get the default SIFS for current mode 201 - * 163 + * ath5k_hw_get_default_sifs() - Get the default SIFS for current mode 202 164 * @ah: The &struct ath5k_hw 203 165 */ 204 - unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah) 166 + unsigned int 167 + ath5k_hw_get_default_sifs(struct ath5k_hw *ah) 205 168 { 206 169 struct ieee80211_channel *channel = ah->ah_current_channel; 207 170 unsigned int sifs; ··· 228 191 } 229 192 230 193 /** 231 - * ath5k_hw_update_mib_counters - Update MIB counters (mac layer statistics) 232 - * 194 + * ath5k_hw_update_mib_counters() - Update MIB counters (mac layer statistics) 233 195 * @ah: The &struct ath5k_hw 234 196 * 235 197 * Reads MIB counters from PCU and updates sw statistics. Is called after a 236 198 * MIB interrupt, because one of these counters might have reached their maximum 237 199 * and triggered the MIB interrupt, to let us read and clear the counter. 238 200 * 239 - * Is called in interrupt context! 201 + * NOTE: Is called in interrupt context! 240 202 */ 241 - void ath5k_hw_update_mib_counters(struct ath5k_hw *ah) 203 + void 204 + ath5k_hw_update_mib_counters(struct ath5k_hw *ah) 242 205 { 243 206 struct ath5k_statistics *stats = &ah->stats; 244 207 ··· 256 219 \******************/ 257 220 258 221 /** 259 - * ath5k_hw_write_rate_duration - fill rate code to duration table 260 - * 261 - * @ah: the &struct ath5k_hw 262 - * @mode: one of enum ath5k_driver_mode 222 + * ath5k_hw_write_rate_duration() - Fill rate code to duration table 223 + * @ah: The &struct ath5k_hw 263 224 * 264 225 * Write the rate code to duration table upon hw reset. This is a helper for 265 226 * ath5k_hw_pcu_init(). It seems all this is doing is setting an ACK timeout on ··· 271 236 * that include all OFDM and CCK rates. 272 237 * 273 238 */ 274 - static inline void ath5k_hw_write_rate_duration(struct ath5k_hw *ah) 239 + static inline void 240 + ath5k_hw_write_rate_duration(struct ath5k_hw *ah) 275 241 { 276 242 struct ieee80211_rate *rate; 277 243 unsigned int i; ··· 316 280 } 317 281 318 282 /** 319 - * ath5k_hw_set_ack_timeout - Set ACK timeout on PCU 320 - * 283 + * ath5k_hw_set_ack_timeout() - Set ACK timeout on PCU 321 284 * @ah: The &struct ath5k_hw 322 285 * @timeout: Timeout in usec 323 286 */ 324 - static int ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout) 287 + static int 288 + ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout) 325 289 { 326 290 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_ACK)) 327 291 <= timeout) ··· 334 298 } 335 299 336 300 /** 337 - * ath5k_hw_set_cts_timeout - Set CTS timeout on PCU 338 - * 301 + * ath5k_hw_set_cts_timeout() - Set CTS timeout on PCU 339 302 * @ah: The &struct ath5k_hw 340 303 * @timeout: Timeout in usec 341 304 */ 342 - static int ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout) 305 + static int 306 + ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout) 343 307 { 344 308 if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_CTS)) 345 309 <= timeout) ··· 357 321 \*******************/ 358 322 359 323 /** 360 - * ath5k_hw_set_lladdr - Set station id 361 - * 324 + * ath5k_hw_set_lladdr() - Set station id 362 325 * @ah: The &struct ath5k_hw 363 - * @mac: The card's mac address 326 + * @mac: The card's mac address (array of octets) 364 327 * 365 328 * Set station id on hw using the provided mac address 366 329 */ 367 - int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac) 330 + int 331 + ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac) 368 332 { 369 333 struct ath_common *common = ath5k_hw_common(ah); 370 334 u32 low_id, high_id; ··· 385 349 } 386 350 387 351 /** 388 - * ath5k_hw_set_bssid - Set current BSSID on hw 389 - * 352 + * ath5k_hw_set_bssid() - Set current BSSID on hw 390 353 * @ah: The &struct ath5k_hw 391 354 * 392 355 * Sets the current BSSID and BSSID mask we have from the 393 356 * common struct into the hardware 394 357 */ 395 - void ath5k_hw_set_bssid(struct ath5k_hw *ah) 358 + void 359 + ath5k_hw_set_bssid(struct ath5k_hw *ah) 396 360 { 397 361 struct ath_common *common = ath5k_hw_common(ah); 398 362 u16 tim_offset = 0; ··· 425 389 ath5k_hw_enable_pspoll(ah, NULL, 0); 426 390 } 427 391 428 - void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask) 392 + /** 393 + * ath5k_hw_set_bssid_mask() - Filter out bssids we listen 394 + * @ah: The &struct ath5k_hw 395 + * @mask: The BSSID mask to set (array of octets) 396 + * 397 + * BSSID masking is a method used by AR5212 and newer hardware to inform PCU 398 + * which bits of the interface's MAC address should be looked at when trying 399 + * to decide which packets to ACK. In station mode and AP mode with a single 400 + * BSS every bit matters since we lock to only one BSS. In AP mode with 401 + * multiple BSSes (virtual interfaces) not every bit matters because hw must 402 + * accept frames for all BSSes and so we tweak some bits of our mac address 403 + * in order to have multiple BSSes. 404 + * 405 + * For more information check out ../hw.c of the common ath module. 406 + */ 407 + void 408 + ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask) 429 409 { 430 410 struct ath_common *common = ath5k_hw_common(ah); 431 411 ··· 452 400 ath_hw_setbssidmask(common); 453 401 } 454 402 455 - /* 456 - * Set multicast filter 403 + /** 404 + * ath5k_hw_set_mcast_filter() - Set multicast filter 405 + * @ah: The &struct ath5k_hw 406 + * @filter0: Lower 32bits of muticast filter 407 + * @filter1: Higher 16bits of multicast filter 457 408 */ 458 - void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1) 409 + void 410 + ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1) 459 411 { 460 412 ath5k_hw_reg_write(ah, filter0, AR5K_MCAST_FILTER0); 461 413 ath5k_hw_reg_write(ah, filter1, AR5K_MCAST_FILTER1); 462 414 } 463 415 464 416 /** 465 - * ath5k_hw_get_rx_filter - Get current rx filter 466 - * 417 + * ath5k_hw_get_rx_filter() - Get current rx filter 467 418 * @ah: The &struct ath5k_hw 468 419 * 469 420 * Returns the RX filter by reading rx filter and ··· 475 420 * and pass to the driver. For a list of frame types 476 421 * check out reg.h. 477 422 */ 478 - u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah) 423 + u32 424 + ath5k_hw_get_rx_filter(struct ath5k_hw *ah) 479 425 { 480 426 u32 data, filter = 0; 481 427 ··· 496 440 } 497 441 498 442 /** 499 - * ath5k_hw_set_rx_filter - Set rx filter 500 - * 443 + * ath5k_hw_set_rx_filter() - Set rx filter 501 444 * @ah: The &struct ath5k_hw 502 445 * @filter: RX filter mask (see reg.h) 503 446 * ··· 504 449 * register on 5212 and newer chips so that we have proper PHY 505 450 * error reporting. 506 451 */ 507 - void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter) 452 + void 453 + ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter) 508 454 { 509 455 u32 data = 0; 510 456 ··· 549 493 #define ATH5K_MAX_TSF_READ 10 550 494 551 495 /** 552 - * ath5k_hw_get_tsf64 - Get the full 64bit TSF 553 - * 496 + * ath5k_hw_get_tsf64() - Get the full 64bit TSF 554 497 * @ah: The &struct ath5k_hw 555 498 * 556 499 * Returns the current TSF 557 500 */ 558 - u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah) 501 + u64 502 + ath5k_hw_get_tsf64(struct ath5k_hw *ah) 559 503 { 560 504 u32 tsf_lower, tsf_upper1, tsf_upper2; 561 505 int i; ··· 592 536 return ((u64)tsf_upper1 << 32) | tsf_lower; 593 537 } 594 538 539 + #undef ATH5K_MAX_TSF_READ 540 + 595 541 /** 596 - * ath5k_hw_set_tsf64 - Set a new 64bit TSF 597 - * 542 + * ath5k_hw_set_tsf64() - Set a new 64bit TSF 598 543 * @ah: The &struct ath5k_hw 599 544 * @tsf64: The new 64bit TSF 600 545 * 601 546 * Sets the new TSF 602 547 */ 603 - void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64) 548 + void 549 + ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64) 604 550 { 605 551 ath5k_hw_reg_write(ah, tsf64 & 0xffffffff, AR5K_TSF_L32); 606 552 ath5k_hw_reg_write(ah, (tsf64 >> 32) & 0xffffffff, AR5K_TSF_U32); 607 553 } 608 554 609 555 /** 610 - * ath5k_hw_reset_tsf - Force a TSF reset 611 - * 556 + * ath5k_hw_reset_tsf() - Force a TSF reset 612 557 * @ah: The &struct ath5k_hw 613 558 * 614 559 * Forces a TSF reset on PCU 615 560 */ 616 - void ath5k_hw_reset_tsf(struct ath5k_hw *ah) 561 + void 562 + ath5k_hw_reset_tsf(struct ath5k_hw *ah) 617 563 { 618 564 u32 val; 619 565 ··· 631 573 ath5k_hw_reg_write(ah, val, AR5K_BEACON); 632 574 } 633 575 634 - /* 635 - * Initialize beacon timers 576 + /** 577 + * ath5k_hw_init_beacon_timers() - Initialize beacon timers 578 + * @ah: The &struct ath5k_hw 579 + * @next_beacon: Next TBTT 580 + * @interval: Current beacon interval 581 + * 582 + * This function is used to initialize beacon timers based on current 583 + * operation mode and settings. 636 584 */ 637 - void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval) 585 + void 586 + ath5k_hw_init_beacon_timers(struct ath5k_hw *ah, u32 next_beacon, u32 interval) 638 587 { 639 588 u32 timer1, timer2, timer3; 640 589 ··· 720 655 } 721 656 722 657 /** 723 - * ath5k_check_timer_win - Check if timer B is timer A + window 724 - * 658 + * ath5k_check_timer_win() - Check if timer B is timer A + window 725 659 * @a: timer a (before b) 726 660 * @b: timer b (after a) 727 661 * @window: difference between a and b ··· 750 686 } 751 687 752 688 /** 753 - * ath5k_hw_check_beacon_timers - Check if the beacon timers are correct 754 - * 689 + * ath5k_hw_check_beacon_timers() - Check if the beacon timers are correct 755 690 * @ah: The &struct ath5k_hw 756 691 * @intval: beacon interval 757 692 * 758 - * This is a workaround for IBSS mode: 693 + * This is a workaround for IBSS mode 759 694 * 760 695 * The need for this function arises from the fact that we have 4 separate 761 696 * HW timer registers (TIMER0 - TIMER3), which are closely related to the ··· 809 746 } 810 747 811 748 /** 812 - * ath5k_hw_set_coverage_class - Set IEEE 802.11 coverage class 813 - * 749 + * ath5k_hw_set_coverage_class() - Set IEEE 802.11 coverage class 814 750 * @ah: The &struct ath5k_hw 815 751 * @coverage_class: IEEE 802.11 coverage class number 816 752 * 817 753 * Sets IFS intervals and ACK/CTS timeouts for given coverage class. 818 754 */ 819 - void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class) 755 + void 756 + ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class) 820 757 { 821 758 /* As defined by IEEE 802.11-2007 17.3.8.6 */ 822 759 int slot_time = ath5k_hw_get_default_slottime(ah) + 3 * coverage_class; ··· 835 772 \***************************/ 836 773 837 774 /** 838 - * ath5k_hw_start_rx_pcu - Start RX engine 839 - * 775 + * ath5k_hw_start_rx_pcu() - Start RX engine 840 776 * @ah: The &struct ath5k_hw 841 777 * 842 778 * Starts RX engine on PCU so that hw can process RXed frames ··· 843 781 * 844 782 * NOTE: RX DMA should be already enabled using ath5k_hw_start_rx_dma 845 783 */ 846 - void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah) 784 + void 785 + ath5k_hw_start_rx_pcu(struct ath5k_hw *ah) 847 786 { 848 787 AR5K_REG_DISABLE_BITS(ah, AR5K_DIAG_SW, AR5K_DIAG_SW_DIS_RX); 849 788 } 850 789 851 790 /** 852 - * at5k_hw_stop_rx_pcu - Stop RX engine 853 - * 791 + * at5k_hw_stop_rx_pcu() - Stop RX engine 854 792 * @ah: The &struct ath5k_hw 855 793 * 856 794 * Stops RX engine on PCU 857 795 */ 858 - void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah) 796 + void 797 + ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah) 859 798 { 860 799 AR5K_REG_ENABLE_BITS(ah, AR5K_DIAG_SW, AR5K_DIAG_SW_DIS_RX); 861 800 } 862 801 863 802 /** 864 - * ath5k_hw_set_opmode - Set PCU operating mode 865 - * 803 + * ath5k_hw_set_opmode() - Set PCU operating mode 866 804 * @ah: The &struct ath5k_hw 867 - * @op_mode: &enum nl80211_iftype operating mode 805 + * @op_mode: One of enum nl80211_iftype 868 806 * 869 807 * Configure PCU for the various operating modes (AP/STA etc) 870 808 */ 871 - int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype op_mode) 809 + int 810 + ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype op_mode) 872 811 { 873 812 struct ath_common *common = ath5k_hw_common(ah); 874 813 u32 pcu_reg, beacon_reg, low_id, high_id; ··· 936 873 return 0; 937 874 } 938 875 939 - void ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode, 940 - u8 mode) 876 + /** 877 + * ath5k_hw_pcu_init() - Initialize PCU 878 + * @ah: The &struct ath5k_hw 879 + * @op_mode: One of enum nl80211_iftype 880 + * @mode: One of enum ath5k_driver_mode 881 + * 882 + * This function is used to initialize PCU by setting current 883 + * operation mode and various other settings. 884 + */ 885 + void 886 + ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode) 941 887 { 942 888 /* Set bssid and bssid mask */ 943 889 ath5k_hw_set_bssid(ah);
+607 -143
drivers/net/wireless/ath/ath5k/phy.c
··· 1 1 /* 2 - * PHY functions 3 - * 4 2 * Copyright (c) 2004-2007 Reyk Floeter <reyk@openbsd.org> 5 3 * Copyright (c) 2006-2009 Nick Kossifidis <mickflemm@gmail.com> 6 4 * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com> ··· 18 20 * 19 21 */ 20 22 23 + /***********************\ 24 + * PHY related functions * 25 + \***********************/ 26 + 21 27 #include <linux/delay.h> 22 28 #include <linux/slab.h> 23 29 #include <asm/unaligned.h> ··· 33 31 #include "../regd.h" 34 32 35 33 34 + /** 35 + * DOC: PHY related functions 36 + * 37 + * Here we handle the low-level functions related to baseband 38 + * and analog frontend (RF) parts. This is by far the most complex 39 + * part of the hw code so make sure you know what you are doing. 40 + * 41 + * Here is a list of what this is all about: 42 + * 43 + * - Channel setting/switching 44 + * 45 + * - Automatic Gain Control (AGC) calibration 46 + * 47 + * - Noise Floor calibration 48 + * 49 + * - I/Q imbalance calibration (QAM correction) 50 + * 51 + * - Calibration due to thermal changes (gain_F) 52 + * 53 + * - Spur noise mitigation 54 + * 55 + * - RF/PHY initialization for the various operating modes and bwmodes 56 + * 57 + * - Antenna control 58 + * 59 + * - TX power control per channel/rate/packet type 60 + * 61 + * Also have in mind we never got documentation for most of these 62 + * functions, what we have comes mostly from Atheros's code, reverse 63 + * engineering and patent docs/presentations etc. 64 + */ 65 + 66 + 36 67 /******************\ 37 68 * Helper functions * 38 69 \******************/ 39 70 40 - /* 41 - * Get the PHY Chip revision 71 + /** 72 + * ath5k_hw_radio_revision() - Get the PHY Chip revision 73 + * @ah: The &struct ath5k_hw 74 + * @band: One of enum ieee80211_band 75 + * 76 + * Returns the revision number of a 2GHz, 5GHz or single chip 77 + * radio. 42 78 */ 43 - u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, enum ieee80211_band band) 79 + u16 80 + ath5k_hw_radio_revision(struct ath5k_hw *ah, enum ieee80211_band band) 44 81 { 45 82 unsigned int i; 46 83 u32 srev; ··· 122 81 return ret; 123 82 } 124 83 125 - /* 126 - * Check if a channel is supported 84 + /** 85 + * ath5k_channel_ok() - Check if a channel is supported by the hw 86 + * @ah: The &struct ath5k_hw 87 + * @channel: The &struct ieee80211_channel 88 + * 89 + * Note: We don't do any regulatory domain checks here, it's just 90 + * a sanity check. 127 91 */ 128 - bool ath5k_channel_ok(struct ath5k_hw *ah, struct ieee80211_channel *channel) 92 + bool 93 + ath5k_channel_ok(struct ath5k_hw *ah, struct ieee80211_channel *channel) 129 94 { 130 95 u16 freq = channel->center_freq; 131 96 ··· 148 101 return false; 149 102 } 150 103 151 - bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah, 104 + /** 105 + * ath5k_hw_chan_has_spur_noise() - Check if channel is sensitive to spur noise 106 + * @ah: The &struct ath5k_hw 107 + * @channel: The &struct ieee80211_channel 108 + */ 109 + bool 110 + ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah, 152 111 struct ieee80211_channel *channel) 153 112 { 154 113 u8 refclk_freq; ··· 175 122 return false; 176 123 } 177 124 178 - /* 179 - * Used to modify RF Banks before writing them to AR5K_RF_BUFFER 125 + /** 126 + * ath5k_hw_rfb_op() - Perform an operation on the given RF Buffer 127 + * @ah: The &struct ath5k_hw 128 + * @rf_regs: The struct ath5k_rf_reg 129 + * @val: New value 130 + * @reg_id: RF register ID 131 + * @set: Indicate we need to swap data 132 + * 133 + * This is an internal function used to modify RF Banks before 134 + * writing them to AR5K_RF_BUFFER. Check out rfbuffer.h for more 135 + * infos. 180 136 */ 181 - static unsigned int ath5k_hw_rfb_op(struct ath5k_hw *ah, 182 - const struct ath5k_rf_reg *rf_regs, 137 + static unsigned int 138 + ath5k_hw_rfb_op(struct ath5k_hw *ah, const struct ath5k_rf_reg *rf_regs, 183 139 u32 val, u8 reg_id, bool set) 184 140 { 185 141 const struct ath5k_rf_reg *rfreg = NULL; ··· 266 204 } 267 205 268 206 /** 269 - * ath5k_hw_write_ofdm_timings - set OFDM timings on AR5212 270 - * 207 + * ath5k_hw_write_ofdm_timings() - set OFDM timings on AR5212 271 208 * @ah: the &struct ath5k_hw 272 209 * @channel: the currently set channel upon reset 273 210 * ··· 277 216 * mantissa and provide these values on hw. 278 217 * 279 218 * For more infos i think this patent is related 280 - * http://www.freepatentsonline.com/7184495.html 219 + * "http://www.freepatentsonline.com/7184495.html" 281 220 */ 282 - static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah, 283 - struct ieee80211_channel *channel) 221 + static inline int 222 + ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah, 223 + struct ieee80211_channel *channel) 284 224 { 285 225 /* Get exponent and mantissa and set it */ 286 226 u32 coef_scaled, coef_exp, coef_man, ··· 340 278 return 0; 341 279 } 342 280 281 + /** 282 + * ath5k_hw_phy_disable() - Disable PHY 283 + * @ah: The &struct ath5k_hw 284 + */ 343 285 int ath5k_hw_phy_disable(struct ath5k_hw *ah) 344 286 { 345 287 /*Just a try M.F.*/ ··· 352 286 return 0; 353 287 } 354 288 355 - /* 356 - * Wait for synth to settle 289 + /** 290 + * ath5k_hw_wait_for_synth() - Wait for synth to settle 291 + * @ah: The &struct ath5k_hw 292 + * @channel: The &struct ieee80211_channel 357 293 */ 358 - static void ath5k_hw_wait_for_synth(struct ath5k_hw *ah, 294 + static void 295 + ath5k_hw_wait_for_synth(struct ath5k_hw *ah, 359 296 struct ieee80211_channel *channel) 360 297 { 361 298 /* ··· 388 319 * RF Gain optimization * 389 320 \**********************/ 390 321 391 - /* 322 + /** 323 + * DOC: RF Gain optimization 324 + * 392 325 * This code is used to optimize RF gain on different environments 393 326 * (temperature mostly) based on feedback from a power detector. 394 327 * ··· 399 328 * no gain optimization ladder-. 400 329 * 401 330 * For more infos check out this patent doc 402 - * http://www.freepatentsonline.com/7400691.html 331 + * "http://www.freepatentsonline.com/7400691.html" 403 332 * 404 333 * This paper describes power drops as seen on the receiver due to 405 334 * probe packets 406 - * http://www.cnri.dit.ie/publications/ICT08%20-%20Practical%20Issues 407 - * %20of%20Power%20Control.pdf 335 + * "http://www.cnri.dit.ie/publications/ICT08%20-%20Practical%20Issues 336 + * %20of%20Power%20Control.pdf" 408 337 * 409 338 * And this is the MadWiFi bug entry related to the above 410 - * http://madwifi-project.org/ticket/1659 339 + * "http://madwifi-project.org/ticket/1659" 411 340 * with various measurements and diagrams 412 341 */ 413 342 414 - /* Initialize ah_gain during attach */ 343 + /** 344 + * ath5k_hw_rfgain_opt_init() - Initialize ah_gain during attach 345 + * @ah: The &struct ath5k_hw 346 + */ 415 347 int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah) 416 348 { 417 349 /* Initialize the gain optimization values */ ··· 438 364 return 0; 439 365 } 440 366 441 - /* Schedule a gain probe check on the next transmitted packet. 367 + /** 368 + * ath5k_hw_request_rfgain_probe() - Request a PAPD probe packet 369 + * @ah: The &struct ath5k_hw 370 + * 371 + * Schedules a gain probe check on the next transmitted packet. 442 372 * That means our next packet is going to be sent with lower 443 373 * tx power and a Peak to Average Power Detector (PAPD) will try 444 374 * to measure the gain. ··· 451 373 * just after we enable the probe so that we don't mess with 452 374 * standard traffic. 453 375 */ 454 - static void ath5k_hw_request_rfgain_probe(struct ath5k_hw *ah) 376 + static void 377 + ath5k_hw_request_rfgain_probe(struct ath5k_hw *ah) 455 378 { 456 379 457 380 /* Skip if gain calibration is inactive or ··· 470 391 471 392 } 472 393 473 - /* Calculate gain_F measurement correction 474 - * based on the current step for RF5112 rev. 2 */ 475 - static u32 ath5k_hw_rf_gainf_corr(struct ath5k_hw *ah) 394 + /** 395 + * ath5k_hw_rf_gainf_corr() - Calculate Gain_F measurement correction 396 + * @ah: The &struct ath5k_hw 397 + * 398 + * Calculate Gain_F measurement correction 399 + * based on the current step for RF5112 rev. 2 400 + */ 401 + static u32 402 + ath5k_hw_rf_gainf_corr(struct ath5k_hw *ah) 476 403 { 477 404 u32 mix, step; 478 405 u32 *rf; ··· 531 446 return ah->ah_gain.g_f_corr; 532 447 } 533 448 534 - /* Check if current gain_F measurement is in the range of our 449 + /** 450 + * ath5k_hw_rf_check_gainf_readback() - Validate Gain_F feedback from detector 451 + * @ah: The &struct ath5k_hw 452 + * 453 + * Check if current gain_F measurement is in the range of our 535 454 * power detector windows. If we get a measurement outside range 536 455 * we know it's not accurate (detectors can't measure anything outside 537 - * their detection window) so we must ignore it */ 538 - static bool ath5k_hw_rf_check_gainf_readback(struct ath5k_hw *ah) 456 + * their detection window) so we must ignore it. 457 + * 458 + * Returns true if readback was O.K. or false on failure 459 + */ 460 + static bool 461 + ath5k_hw_rf_check_gainf_readback(struct ath5k_hw *ah) 539 462 { 540 463 const struct ath5k_rf_reg *rf_regs; 541 464 u32 step, mix_ovr, level[4]; ··· 595 502 ah->ah_gain.g_current <= level[3]); 596 503 } 597 504 598 - /* Perform gain_F adjustment by choosing the right set 599 - * of parameters from RF gain optimization ladder */ 600 - static s8 ath5k_hw_rf_gainf_adjust(struct ath5k_hw *ah) 505 + /** 506 + * ath5k_hw_rf_gainf_adjust() - Perform Gain_F adjustment 507 + * @ah: The &struct ath5k_hw 508 + * 509 + * Choose the right target gain based on current gain 510 + * and RF gain optimization ladder 511 + */ 512 + static s8 513 + ath5k_hw_rf_gainf_adjust(struct ath5k_hw *ah) 601 514 { 602 515 const struct ath5k_gain_opt *go; 603 516 const struct ath5k_gain_opt_step *g_step; ··· 667 568 return ret; 668 569 } 669 570 670 - /* Main callback for thermal RF gain calibration engine 571 + /** 572 + * ath5k_hw_gainf_calibrate() - Do a gain_F calibration 573 + * @ah: The &struct ath5k_hw 574 + * 575 + * Main callback for thermal RF gain calibration engine 671 576 * Check for a new gain reading and schedule an adjustment 672 577 * if needed. 578 + * 579 + * Returns one of enum ath5k_rfgain codes 673 580 */ 674 - enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah) 581 + enum ath5k_rfgain 582 + ath5k_hw_gainf_calibrate(struct ath5k_hw *ah) 675 583 { 676 584 u32 data, type; 677 585 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; ··· 738 632 return ah->ah_gain.g_state; 739 633 } 740 634 741 - /* Write initial RF gain table to set the RF sensitivity 742 - * this one works on all RF chips and has nothing to do 743 - * with gain_F calibration */ 744 - static int ath5k_hw_rfgain_init(struct ath5k_hw *ah, enum ieee80211_band band) 635 + /** 636 + * ath5k_hw_rfgain_init() - Write initial RF gain settings to hw 637 + * @ah: The &struct ath5k_hw 638 + * @band: One of enum ieee80211_band 639 + * 640 + * Write initial RF gain table to set the RF sensitivity. 641 + * 642 + * NOTE: This one works on all RF chips and has nothing to do 643 + * with Gain_F calibration 644 + */ 645 + static int 646 + ath5k_hw_rfgain_init(struct ath5k_hw *ah, enum ieee80211_band band) 745 647 { 746 648 const struct ath5k_ini_rfgain *ath5k_rfg; 747 649 unsigned int i, size, index; ··· 796 682 } 797 683 798 684 799 - 800 685 /********************\ 801 686 * RF Registers setup * 802 687 \********************/ 803 688 804 - /* 805 - * Setup RF registers by writing RF buffer on hw 689 + /** 690 + * ath5k_hw_rfregs_init() - Initialize RF register settings 691 + * @ah: The &struct ath5k_hw 692 + * @channel: The &struct ieee80211_channel 693 + * @mode: One of enum ath5k_driver_mode 694 + * 695 + * Setup RF registers by writing RF buffer on hw. For 696 + * more infos on this, check out rfbuffer.h 806 697 */ 807 - static int ath5k_hw_rfregs_init(struct ath5k_hw *ah, 808 - struct ieee80211_channel *channel, unsigned int mode) 698 + static int 699 + ath5k_hw_rfregs_init(struct ath5k_hw *ah, 700 + struct ieee80211_channel *channel, 701 + unsigned int mode) 809 702 { 810 703 const struct ath5k_rf_reg *rf_regs; 811 704 const struct ath5k_ini_rfbuffer *ini_rfb; ··· 1170 1049 PHY/RF channel functions 1171 1050 \**************************/ 1172 1051 1173 - /* 1174 - * Conversion needed for RF5110 1052 + /** 1053 + * ath5k_hw_rf5110_chan2athchan() - Convert channel freq on RF5110 1054 + * @channel: The &struct ieee80211_channel 1055 + * 1056 + * Map channel frequency to IEEE channel number and convert it 1057 + * to an internal channel value used by the RF5110 chipset. 1175 1058 */ 1176 - static u32 ath5k_hw_rf5110_chan2athchan(struct ieee80211_channel *channel) 1059 + static u32 1060 + ath5k_hw_rf5110_chan2athchan(struct ieee80211_channel *channel) 1177 1061 { 1178 1062 u32 athchan; 1179 1063 1180 - /* 1181 - * Convert IEEE channel/MHz to an internal channel value used 1182 - * by the AR5210 chipset. This has not been verified with 1183 - * newer chipsets like the AR5212A who have a completely 1184 - * different RF/PHY part. 1185 - */ 1186 1064 athchan = (ath5k_hw_bitswap( 1187 1065 (ieee80211_frequency_to_channel( 1188 1066 channel->center_freq) - 24) / 2, 5) ··· 1189 1069 return athchan; 1190 1070 } 1191 1071 1192 - /* 1193 - * Set channel on RF5110 1072 + /** 1073 + * ath5k_hw_rf5110_channel() - Set channel frequency on RF5110 1074 + * @ah: The &struct ath5k_hw 1075 + * @channel: The &struct ieee80211_channel 1194 1076 */ 1195 - static int ath5k_hw_rf5110_channel(struct ath5k_hw *ah, 1077 + static int 1078 + ath5k_hw_rf5110_channel(struct ath5k_hw *ah, 1196 1079 struct ieee80211_channel *channel) 1197 1080 { 1198 1081 u32 data; ··· 1211 1088 return 0; 1212 1089 } 1213 1090 1214 - /* 1215 - * Conversion needed for 5111 1091 + /** 1092 + * ath5k_hw_rf5111_chan2athchan() - Handle 2GHz channels on RF5111/2111 1093 + * @ieee: IEEE channel number 1094 + * @athchan: The &struct ath5k_athchan_2ghz 1095 + * 1096 + * In order to enable the RF2111 frequency converter on RF5111/2111 setups 1097 + * we need to add some offsets and extra flags to the data values we pass 1098 + * on to the PHY. So for every 2GHz channel this function gets called 1099 + * to do the conversion. 1216 1100 */ 1217 - static int ath5k_hw_rf5111_chan2athchan(unsigned int ieee, 1101 + static int 1102 + ath5k_hw_rf5111_chan2athchan(unsigned int ieee, 1218 1103 struct ath5k_athchan_2ghz *athchan) 1219 1104 { 1220 1105 int channel; ··· 1248 1117 return 0; 1249 1118 } 1250 1119 1251 - /* 1252 - * Set channel on 5111 1120 + /** 1121 + * ath5k_hw_rf5111_channel() - Set channel frequency on RF5111/2111 1122 + * @ah: The &struct ath5k_hw 1123 + * @channel: The &struct ieee80211_channel 1253 1124 */ 1254 - static int ath5k_hw_rf5111_channel(struct ath5k_hw *ah, 1125 + static int 1126 + ath5k_hw_rf5111_channel(struct ath5k_hw *ah, 1255 1127 struct ieee80211_channel *channel) 1256 1128 { 1257 1129 struct ath5k_athchan_2ghz ath5k_channel_2ghz; ··· 1299 1165 return 0; 1300 1166 } 1301 1167 1302 - /* 1303 - * Set channel on 5112 and newer 1168 + /** 1169 + * ath5k_hw_rf5112_channel() - Set channel frequency on 5112 and newer 1170 + * @ah: The &struct ath5k_hw 1171 + * @channel: The &struct ieee80211_channel 1172 + * 1173 + * On RF5112/2112 and newer we don't need to do any conversion. 1174 + * We pass the frequency value after a few modifications to the 1175 + * chip directly. 1176 + * 1177 + * NOTE: Make sure channel frequency given is within our range or else 1178 + * we might damage the chip ! Use ath5k_channel_ok before calling this one. 1304 1179 */ 1305 - static int ath5k_hw_rf5112_channel(struct ath5k_hw *ah, 1180 + static int 1181 + ath5k_hw_rf5112_channel(struct ath5k_hw *ah, 1306 1182 struct ieee80211_channel *channel) 1307 1183 { 1308 1184 u32 data, data0, data1, data2; ··· 1321 1177 data = data0 = data1 = data2 = 0; 1322 1178 c = channel->center_freq; 1323 1179 1180 + /* My guess based on code: 1181 + * 2GHz RF has 2 synth modes, one with a Local Oscillator 1182 + * at 2224Hz and one with a LO at 2192Hz. IF is 1520Hz 1183 + * (3040/2). data0 is used to set the PLL divider and data1 1184 + * selects synth mode. */ 1324 1185 if (c < 4800) { 1186 + /* Channel 14 and all frequencies with 2Hz spacing 1187 + * below/above (non-standard channels) */ 1325 1188 if (!((c - 2224) % 5)) { 1189 + /* Same as (c - 2224) / 5 */ 1326 1190 data0 = ((2 * (c - 704)) - 3040) / 10; 1327 1191 data1 = 1; 1192 + /* Channel 1 and all frequencies with 5Hz spacing 1193 + * below/above (standard channels without channel 14) */ 1328 1194 } else if (!((c - 2192) % 5)) { 1195 + /* Same as (c - 2192) / 5 */ 1329 1196 data0 = ((2 * (c - 672)) - 3040) / 10; 1330 1197 data1 = 0; 1331 1198 } else 1332 1199 return -EINVAL; 1333 1200 1334 1201 data0 = ath5k_hw_bitswap((data0 << 2) & 0xff, 8); 1202 + /* This is more complex, we have a single synthesizer with 1203 + * 4 reference clock settings (?) based on frequency spacing 1204 + * and set using data2. LO is at 4800Hz and data0 is again used 1205 + * to set some divider. 1206 + * 1207 + * NOTE: There is an old atheros presentation at Stanford 1208 + * that mentions a method called dual direct conversion 1209 + * with 1GHz sliding IF for RF5110. Maybe that's what we 1210 + * have here, or an updated version. */ 1335 1211 } else if ((c % 5) != 2 || c > 5435) { 1336 1212 if (!(c % 20) && c >= 5120) { 1337 1213 data0 = ath5k_hw_bitswap(((c - 4800) / 20 << 2), 8); ··· 1377 1213 return 0; 1378 1214 } 1379 1215 1380 - /* 1381 - * Set the channel on the RF2425 1216 + /** 1217 + * ath5k_hw_rf2425_channel() - Set channel frequency on RF2425 1218 + * @ah: The &struct ath5k_hw 1219 + * @channel: The &struct ieee80211_channel 1220 + * 1221 + * AR2425/2417 have a different 2GHz RF so code changes 1222 + * a little bit from RF5112. 1382 1223 */ 1383 - static int ath5k_hw_rf2425_channel(struct ath5k_hw *ah, 1224 + static int 1225 + ath5k_hw_rf2425_channel(struct ath5k_hw *ah, 1384 1226 struct ieee80211_channel *channel) 1385 1227 { 1386 1228 u32 data, data0, data2; ··· 1422 1252 return 0; 1423 1253 } 1424 1254 1425 - /* 1426 - * Set a channel on the radio chip 1255 + /** 1256 + * ath5k_hw_channel() - Set a channel on the radio chip 1257 + * @ah: The &struct ath5k_hw 1258 + * @channel: The &struct ieee80211_channel 1259 + * 1260 + * This is the main function called to set a channel on the 1261 + * radio chip based on the radio chip version. 1427 1262 */ 1428 - static int ath5k_hw_channel(struct ath5k_hw *ah, 1263 + static int 1264 + ath5k_hw_channel(struct ath5k_hw *ah, 1429 1265 struct ieee80211_channel *channel) 1430 1266 { 1431 1267 int ret; ··· 1483 1307 return 0; 1484 1308 } 1485 1309 1310 + 1486 1311 /*****************\ 1487 1312 PHY calibration 1488 1313 \*****************/ 1489 1314 1490 - static s32 ath5k_hw_read_measured_noise_floor(struct ath5k_hw *ah) 1315 + /** 1316 + * DOC: PHY Calibration routines 1317 + * 1318 + * Noise floor calibration: When we tell the hardware to 1319 + * perform a noise floor calibration by setting the 1320 + * AR5K_PHY_AGCCTL_NF bit on AR5K_PHY_AGCCTL, it will periodically 1321 + * sample-and-hold the minimum noise level seen at the antennas. 1322 + * This value is then stored in a ring buffer of recently measured 1323 + * noise floor values so we have a moving window of the last few 1324 + * samples. The median of the values in the history is then loaded 1325 + * into the hardware for its own use for RSSI and CCA measurements. 1326 + * This type of calibration doesn't interfere with traffic. 1327 + * 1328 + * AGC calibration: When we tell the hardware to perform 1329 + * an AGC (Automatic Gain Control) calibration by setting the 1330 + * AR5K_PHY_AGCCTL_CAL, hw disconnects the antennas and does 1331 + * a calibration on the DC offsets of ADCs. During this period 1332 + * rx/tx gets disabled so we have to deal with it on the driver 1333 + * part. 1334 + * 1335 + * I/Q calibration: When we tell the hardware to perform 1336 + * an I/Q calibration, it tries to correct I/Q imbalance and 1337 + * fix QAM constellation by sampling data from rxed frames. 1338 + * It doesn't interfere with traffic. 1339 + * 1340 + * For more infos on AGC and I/Q calibration check out patent doc 1341 + * #03/094463. 1342 + */ 1343 + 1344 + /** 1345 + * ath5k_hw_read_measured_noise_floor() - Read measured NF from hw 1346 + * @ah: The &struct ath5k_hw 1347 + */ 1348 + static s32 1349 + ath5k_hw_read_measured_noise_floor(struct ath5k_hw *ah) 1491 1350 { 1492 1351 s32 val; 1493 1352 ··· 1530 1319 return sign_extend32(AR5K_REG_MS(val, AR5K_PHY_NF_MINCCA_PWR), 8); 1531 1320 } 1532 1321 1533 - void ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah) 1322 + /** 1323 + * ath5k_hw_init_nfcal_hist() - Initialize NF calibration history buffer 1324 + * @ah: The &struct ath5k_hw 1325 + */ 1326 + void 1327 + ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah) 1534 1328 { 1535 1329 int i; 1536 1330 ··· 1544 1328 ah->ah_nfcal_hist.nfval[i] = AR5K_TUNE_CCA_MAX_GOOD_VALUE; 1545 1329 } 1546 1330 1331 + /** 1332 + * ath5k_hw_update_nfcal_hist() - Update NF calibration history buffer 1333 + * @ah: The &struct ath5k_hw 1334 + * @noise_floor: The NF we got from hw 1335 + */ 1547 1336 static void ath5k_hw_update_nfcal_hist(struct ath5k_hw *ah, s16 noise_floor) 1548 1337 { 1549 1338 struct ath5k_nfcal_hist *hist = &ah->ah_nfcal_hist; ··· 1556 1335 hist->nfval[hist->index] = noise_floor; 1557 1336 } 1558 1337 1559 - static s16 ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah) 1338 + /** 1339 + * ath5k_hw_get_median_noise_floor() - Get median NF from history buffer 1340 + * @ah: The &struct ath5k_hw 1341 + */ 1342 + static s16 1343 + ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah) 1560 1344 { 1561 1345 s16 sort[ATH5K_NF_CAL_HIST_MAX]; 1562 1346 s16 tmp; ··· 1584 1358 return sort[(ATH5K_NF_CAL_HIST_MAX - 1) / 2]; 1585 1359 } 1586 1360 1587 - /* 1588 - * When we tell the hardware to perform a noise floor calibration 1589 - * by setting the AR5K_PHY_AGCCTL_NF bit, it will periodically 1590 - * sample-and-hold the minimum noise level seen at the antennas. 1591 - * This value is then stored in a ring buffer of recently measured 1592 - * noise floor values so we have a moving window of the last few 1593 - * samples. 1361 + /** 1362 + * ath5k_hw_update_noise_floor() - Update NF on hardware 1363 + * @ah: The &struct ath5k_hw 1594 1364 * 1595 - * The median of the values in the history is then loaded into the 1596 - * hardware for its own use for RSSI and CCA measurements. 1365 + * This is the main function we call to perform a NF calibration, 1366 + * it reads NF from hardware, calculates the median and updates 1367 + * NF on hw. 1597 1368 */ 1598 - void ath5k_hw_update_noise_floor(struct ath5k_hw *ah) 1369 + void 1370 + ath5k_hw_update_noise_floor(struct ath5k_hw *ah) 1599 1371 { 1600 1372 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; 1601 1373 u32 val; ··· 1660 1436 "noise floor calibrated: %d\n", nf); 1661 1437 } 1662 1438 1663 - /* 1664 - * Perform a PHY calibration on RF5110 1665 - * -Fix BPSK/QAM Constellation (I/Q correction) 1439 + /** 1440 + * ath5k_hw_rf5110_calibrate() - Perform a PHY calibration on RF5110 1441 + * @ah: The &struct ath5k_hw 1442 + * @channel: The &struct ieee80211_channel 1443 + * 1444 + * Do a complete PHY calibration (AGC + NF + I/Q) on RF5110 1666 1445 */ 1667 - static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah, 1446 + static int 1447 + ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah, 1668 1448 struct ieee80211_channel *channel) 1669 1449 { 1670 1450 u32 phy_sig, phy_agc, phy_sat, beacon; ··· 1763 1535 return 0; 1764 1536 } 1765 1537 1766 - /* 1767 - * Perform I/Q calibration on RF5111/5112 and newer chips 1538 + /** 1539 + * ath5k_hw_rf511x_iq_calibrate() - Perform I/Q calibration on RF5111 and newer 1540 + * @ah: The &struct ath5k_hw 1768 1541 */ 1769 1542 static int 1770 1543 ath5k_hw_rf511x_iq_calibrate(struct ath5k_hw *ah) ··· 1839 1610 return 0; 1840 1611 } 1841 1612 1842 - /* 1843 - * Perform a PHY calibration 1613 + /** 1614 + * ath5k_hw_phy_calibrate() - Perform a PHY calibration 1615 + * @ah: The &struct ath5k_hw 1616 + * @channel: The &struct ieee80211_channel 1617 + * 1618 + * The main function we call from above to perform 1619 + * a short or full PHY calibration based on RF chip 1620 + * and current channel 1844 1621 */ 1845 - int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, 1622 + int 1623 + ath5k_hw_phy_calibrate(struct ath5k_hw *ah, 1846 1624 struct ieee80211_channel *channel) 1847 1625 { 1848 1626 int ret; ··· 1904 1668 * Spur mitigation functions * 1905 1669 \***************************/ 1906 1670 1671 + /** 1672 + * ath5k_hw_set_spur_mitigation_filter() - Configure SPUR filter 1673 + * @ah: The &struct ath5k_hw 1674 + * @channel: The &struct ieee80211_channel 1675 + * 1676 + * This function gets called during PHY initialization to 1677 + * configure the spur filter for the given channel. Spur is noise 1678 + * generated due to "reflection" effects, for more information on this 1679 + * method check out patent US7643810 1680 + */ 1907 1681 static void 1908 1682 ath5k_hw_set_spur_mitigation_filter(struct ath5k_hw *ah, 1909 1683 struct ieee80211_channel *channel) ··· 2153 1907 * Antenna control * 2154 1908 \*****************/ 2155 1909 2156 - static void /*TODO:Boundary check*/ 1910 + /** 1911 + * DOC: Antenna control 1912 + * 1913 + * Hw supports up to 14 antennas ! I haven't found any card that implements 1914 + * that. The maximum number of antennas I've seen is up to 4 (2 for 2GHz and 2 1915 + * for 5GHz). Antenna 1 (MAIN) should be omnidirectional, 2 (AUX) 1916 + * omnidirectional or sectorial and antennas 3-14 sectorial (or directional). 1917 + * 1918 + * We can have a single antenna for RX and multiple antennas for TX. 1919 + * RX antenna is our "default" antenna (usually antenna 1) set on 1920 + * DEFAULT_ANTENNA register and TX antenna is set on each TX control descriptor 1921 + * (0 for automatic selection, 1 - 14 antenna number). 1922 + * 1923 + * We can let hw do all the work doing fast antenna diversity for both 1924 + * tx and rx or we can do things manually. Here are the options we have 1925 + * (all are bits of STA_ID1 register): 1926 + * 1927 + * AR5K_STA_ID1_DEFAULT_ANTENNA -> When 0 is set as the TX antenna on TX 1928 + * control descriptor, use the default antenna to transmit or else use the last 1929 + * antenna on which we received an ACK. 1930 + * 1931 + * AR5K_STA_ID1_DESC_ANTENNA -> Update default antenna after each TX frame to 1932 + * the antenna on which we got the ACK for that frame. 1933 + * 1934 + * AR5K_STA_ID1_RTS_DEF_ANTENNA -> Use default antenna for RTS or else use the 1935 + * one on the TX descriptor. 1936 + * 1937 + * AR5K_STA_ID1_SELFGEN_DEF_ANT -> Use default antenna for self generated frames 1938 + * (ACKs etc), or else use current antenna (the one we just used for TX). 1939 + * 1940 + * Using the above we support the following scenarios: 1941 + * 1942 + * AR5K_ANTMODE_DEFAULT -> Hw handles antenna diversity etc automatically 1943 + * 1944 + * AR5K_ANTMODE_FIXED_A -> Only antenna A (MAIN) is present 1945 + * 1946 + * AR5K_ANTMODE_FIXED_B -> Only antenna B (AUX) is present 1947 + * 1948 + * AR5K_ANTMODE_SINGLE_AP -> Sta locked on a single ap 1949 + * 1950 + * AR5K_ANTMODE_SECTOR_AP -> AP with tx antenna set on tx desc 1951 + * 1952 + * AR5K_ANTMODE_SECTOR_STA -> STA with tx antenna set on tx desc 1953 + * 1954 + * AR5K_ANTMODE_DEBUG Debug mode -A -> Rx, B-> Tx- 1955 + * 1956 + * Also note that when setting antenna to F on tx descriptor card inverts 1957 + * current tx antenna. 1958 + */ 1959 + 1960 + /** 1961 + * ath5k_hw_set_def_antenna() - Set default rx antenna on AR5211/5212 and newer 1962 + * @ah: The &struct ath5k_hw 1963 + * @ant: Antenna number 1964 + */ 1965 + static void 2157 1966 ath5k_hw_set_def_antenna(struct ath5k_hw *ah, u8 ant) 2158 1967 { 2159 1968 if (ah->ah_version != AR5K_AR5210) 2160 1969 ath5k_hw_reg_write(ah, ant & 0x7, AR5K_DEFAULT_ANTENNA); 2161 1970 } 2162 1971 2163 - /* 2164 - * Enable/disable fast rx antenna diversity 1972 + /** 1973 + * ath5k_hw_set_fast_div() - Enable/disable fast rx antenna diversity 1974 + * @ah: The &struct ath5k_hw 1975 + * @ee_mode: One of enum ath5k_driver_mode 1976 + * @enable: True to enable, false to disable 2165 1977 */ 2166 1978 static void 2167 1979 ath5k_hw_set_fast_div(struct ath5k_hw *ah, u8 ee_mode, bool enable) ··· 2259 1955 } 2260 1956 } 2261 1957 1958 + /** 1959 + * ath5k_hw_set_antenna_switch() - Set up antenna switch table 1960 + * @ah: The &struct ath5k_hw 1961 + * @ee_mode: One of enum ath5k_driver_mode 1962 + * 1963 + * Switch table comes from EEPROM and includes information on controlling 1964 + * the 2 antenna RX attenuators 1965 + */ 2262 1966 void 2263 1967 ath5k_hw_set_antenna_switch(struct ath5k_hw *ah, u8 ee_mode) 2264 1968 { ··· 2298 1986 AR5K_PHY_ANT_SWITCH_TABLE_1); 2299 1987 } 2300 1988 2301 - /* 2302 - * Set antenna operating mode 1989 + /** 1990 + * ath5k_hw_set_antenna_mode() - Set antenna operating mode 1991 + * @ah: The &struct ath5k_hw 1992 + * @ant_mode: One of enum ath5k_ant_mode 2303 1993 */ 2304 1994 void 2305 1995 ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode) ··· 2424 2110 * Helper functions 2425 2111 */ 2426 2112 2427 - /* 2428 - * Do linear interpolation between two given (x, y) points 2113 + /** 2114 + * ath5k_get_interpolated_value() - Get interpolated Y val between two points 2115 + * @target: X value of the middle point 2116 + * @x_left: X value of the left point 2117 + * @x_right: X value of the right point 2118 + * @y_left: Y value of the left point 2119 + * @y_right: Y value of the right point 2429 2120 */ 2430 2121 static s16 2431 2122 ath5k_get_interpolated_value(s16 target, s16 x_left, s16 x_right, ··· 2457 2138 return result; 2458 2139 } 2459 2140 2460 - /* 2461 - * Find vertical boundary (min pwr) for the linear PCDAC curve. 2141 + /** 2142 + * ath5k_get_linear_pcdac_min() - Find vertical boundary (min pwr) for the 2143 + * linear PCDAC curve 2144 + * @stepL: Left array with y values (pcdac steps) 2145 + * @stepR: Right array with y values (pcdac steps) 2146 + * @pwrL: Left array with x values (power steps) 2147 + * @pwrR: Right array with x values (power steps) 2462 2148 * 2463 2149 * Since we have the top of the curve and we draw the line below 2464 2150 * until we reach 1 (1 pcdac step) we need to know which point 2465 - * (x value) that is so that we don't go below y axis and have negative 2466 - * pcdac values when creating the curve, or fill the table with zeroes. 2151 + * (x value) that is so that we don't go below x axis and have negative 2152 + * pcdac values when creating the curve, or fill the table with zeros. 2467 2153 */ 2468 2154 static s16 2469 2155 ath5k_get_linear_pcdac_min(const u8 *stepL, const u8 *stepR, ··· 2514 2190 return max(min_pwrL, min_pwrR); 2515 2191 } 2516 2192 2517 - /* 2193 + /** 2194 + * ath5k_create_power_curve() - Create a Power to PDADC or PCDAC curve 2195 + * @pmin: Minimum power value (xmin) 2196 + * @pmax: Maximum power value (xmax) 2197 + * @pwr: Array of power steps (x values) 2198 + * @vpd: Array of matching PCDAC/PDADC steps (y values) 2199 + * @num_points: Number of provided points 2200 + * @vpd_table: Array to fill with the full PCDAC/PDADC values (y values) 2201 + * @type: One of enum ath5k_powertable_type (eeprom.h) 2202 + * 2518 2203 * Interpolate (pwr,vpd) points to create a Power to PDADC or a 2519 2204 * Power to PCDAC curve. 2520 2205 * ··· 2581 2248 } 2582 2249 } 2583 2250 2584 - /* 2251 + /** 2252 + * ath5k_get_chan_pcal_surrounding_piers() - Get surrounding calibration piers 2253 + * for a given channel. 2254 + * @ah: The &struct ath5k_hw 2255 + * @channel: The &struct ieee80211_channel 2256 + * @pcinfo_l: The &struct ath5k_chan_pcal_info to put the left cal. pier 2257 + * @pcinfo_r: The &struct ath5k_chan_pcal_info to put the right cal. pier 2258 + * 2585 2259 * Get the surrounding per-channel power calibration piers 2586 2260 * for a given frequency so that we can interpolate between 2587 2261 * them and come up with an appropriate dataset for our current ··· 2671 2331 *pcinfo_r = &pcinfo[idx_r]; 2672 2332 } 2673 2333 2674 - /* 2334 + /** 2335 + * ath5k_get_rate_pcal_data() - Get the interpolated per-rate power 2336 + * calibration data 2337 + * @ah: The &struct ath5k_hw *ah, 2338 + * @channel: The &struct ieee80211_channel 2339 + * @rates: The &struct ath5k_rate_pcal_info to fill 2340 + * 2675 2341 * Get the surrounding per-rate power calibration data 2676 2342 * for a given frequency and interpolate between power 2677 2343 * values to set max target power supported by hw for 2678 - * each rate. 2344 + * each rate on this frequency. 2679 2345 */ 2680 2346 static void 2681 2347 ath5k_get_rate_pcal_data(struct ath5k_hw *ah, ··· 2769 2423 rpinfo[idx_r].target_power_54); 2770 2424 } 2771 2425 2772 - /* 2426 + /** 2427 + * ath5k_get_max_ctl_power() - Get max edge power for a given frequency 2428 + * @ah: the &struct ath5k_hw 2429 + * @channel: The &struct ieee80211_channel 2430 + * 2773 2431 * Get the max edge power for this channel if 2774 2432 * we have such data from EEPROM's Conformance Test 2775 2433 * Limits (CTL), and limit max power if needed. ··· 2853 2503 * Power to PCDAC table functions 2854 2504 */ 2855 2505 2856 - /* 2857 - * Fill Power to PCDAC table on RF5111 2506 + /** 2507 + * DOC: Power to PCDAC table functions 2508 + * 2509 + * For RF5111 we have an XPD -eXternal Power Detector- curve 2510 + * for each calibrated channel. Each curve has 0,5dB Power steps 2511 + * on x axis and PCDAC steps (offsets) on y axis and looks like an 2512 + * exponential function. To recreate the curve we read 11 points 2513 + * from eeprom (eeprom.c) and interpolate here. 2514 + * 2515 + * For RF5112 we have 4 XPD -eXternal Power Detector- curves 2516 + * for each calibrated channel on 0, -6, -12 and -18dBm but we only 2517 + * use the higher (3) and the lower (0) curves. Each curve again has 0.5dB 2518 + * power steps on x axis and PCDAC steps on y axis and looks like a 2519 + * linear function. To recreate the curve and pass the power values 2520 + * on hw, we get 4 points for xpd 0 (lower gain -> max power) 2521 + * and 3 points for xpd 3 (higher gain -> lower power) from eeprom (eeprom.c) 2522 + * and interpolate here. 2523 + * 2524 + * For a given channel we get the calibrated points (piers) for it or 2525 + * -if we don't have calibration data for this specific channel- from the 2526 + * available surrounding channels we have calibration data for, after we do a 2527 + * linear interpolation between them. Then since we have our calibrated points 2528 + * for this channel, we do again a linear interpolation between them to get the 2529 + * whole curve. 2530 + * 2531 + * We finally write the Y values of the curve(s) (the PCDAC values) on hw 2532 + */ 2533 + 2534 + /** 2535 + * ath5k_fill_pwr_to_pcdac_table() - Fill Power to PCDAC table on RF5111 2536 + * @ah: The &struct ath5k_hw 2537 + * @table_min: Minimum power (x min) 2538 + * @table_max: Maximum power (x max) 2858 2539 * 2859 2540 * No further processing is needed for RF5111, the only thing we have to 2860 2541 * do is fill the values below and above calibration range since eeprom data ··· 2926 2545 2927 2546 } 2928 2547 2929 - /* 2930 - * Combine available XPD Curves and fill Linear Power to PCDAC table 2931 - * on RF5112 2548 + /** 2549 + * ath5k_combine_linear_pcdac_curves() - Combine available PCDAC Curves 2550 + * @ah: The &struct ath5k_hw 2551 + * @table_min: Minimum power (x min) 2552 + * @table_max: Maximum power (x max) 2553 + * @pdcurves: Number of pd curves 2932 2554 * 2555 + * Combine available XPD Curves and fill Linear Power to PCDAC table on RF5112 2933 2556 * RFX112 can have up to 2 curves (one for low txpower range and one for 2934 2557 * higher txpower range). We need to put them both on pcdac_out and place 2935 2558 * them in the correct location. In case we only have one curve available ··· 3035 2650 } 3036 2651 } 3037 2652 3038 - /* Write PCDAC values on hw */ 2653 + /** 2654 + * ath5k_write_pcdac_table() - Write the PCDAC values on hw 2655 + * @ah: The &struct ath5k_hw 2656 + */ 3039 2657 static void 3040 2658 ath5k_write_pcdac_table(struct ath5k_hw *ah) 3041 2659 { ··· 3061 2673 * Power to PDADC table functions 3062 2674 */ 3063 2675 3064 - /* 3065 - * Set the gain boundaries and create final Power to PDADC table 2676 + /** 2677 + * DOC: Power to PDADC table functions 3066 2678 * 2679 + * For RF2413 and later we have a Power to PDADC table (Power Detector) 2680 + * instead of a PCDAC (Power Control) and 4 pd gain curves for each 2681 + * calibrated channel. Each curve has power on x axis in 0.5 db steps and 2682 + * PDADC steps on y axis and looks like an exponential function like the 2683 + * RF5111 curve. 2684 + * 2685 + * To recreate the curves we read the points from eeprom (eeprom.c) 2686 + * and interpolate here. Note that in most cases only 2 (higher and lower) 2687 + * curves are used (like RF5112) but vendors have the opportunity to include 2688 + * all 4 curves on eeprom. The final curve (higher power) has an extra 2689 + * point for better accuracy like RF5112. 2690 + * 2691 + * The process is similar to what we do above for RF5111/5112 2692 + */ 2693 + 2694 + /** 2695 + * ath5k_combine_pwr_to_pdadc_curves() - Combine the various PDADC curves 2696 + * @ah: The &struct ath5k_hw 2697 + * @pwr_min: Minimum power (x min) 2698 + * @pwr_max: Maximum power (x max) 2699 + * @pdcurves: Number of available curves 2700 + * 2701 + * Combine the various pd curves and create the final Power to PDADC table 3067 2702 * We can have up to 4 pd curves, we need to do a similar process 3068 2703 * as we do for RF5112. This time we don't have an edge_flag but we 3069 2704 * set the gain boundaries on a separate register. ··· 3210 2799 3211 2800 } 3212 2801 3213 - /* Write PDADC values on hw */ 2802 + /** 2803 + * ath5k_write_pwr_to_pdadc_table() - Write the PDADC values on hw 2804 + * @ah: The &struct ath5k_hw 2805 + * @ee_mode: One of enum ath5k_driver_mode 2806 + */ 3214 2807 static void 3215 2808 ath5k_write_pwr_to_pdadc_table(struct ath5k_hw *ah, u8 ee_mode) 3216 2809 { ··· 3271 2856 * Common code for PCDAC/PDADC tables 3272 2857 */ 3273 2858 3274 - /* 2859 + /** 2860 + * ath5k_setup_channel_powertable() - Set up power table for this channel 2861 + * @ah: The &struct ath5k_hw 2862 + * @channel: The &struct ieee80211_channel 2863 + * @ee_mode: One of enum ath5k_driver_mode 2864 + * @type: One of enum ath5k_powertable_type (eeprom.h) 2865 + * 3275 2866 * This is the main function that uses all of the above 3276 2867 * to set PCDAC/PDADC table on hw for the current channel. 3277 2868 * This table is used for tx power calibration on the baseband, ··· 3475 3054 return 0; 3476 3055 } 3477 3056 3478 - /* Write power table for current channel to hw */ 3057 + /** 3058 + * ath5k_write_channel_powertable() - Set power table for current channel on hw 3059 + * @ah: The &struct ath5k_hw 3060 + * @ee_mode: One of enum ath5k_driver_mode 3061 + * @type: One of enum ath5k_powertable_type (eeprom.h) 3062 + */ 3479 3063 static void 3480 3064 ath5k_write_channel_powertable(struct ath5k_hw *ah, u8 ee_mode, u8 type) 3481 3065 { ··· 3490 3064 ath5k_write_pcdac_table(ah); 3491 3065 } 3492 3066 3493 - /* 3494 - * Per-rate tx power setting 3495 - * 3496 - * This is the code that sets the desired tx power (below 3497 - * maximum) on hw for each rate (we also have TPC that sets 3498 - * power per packet). We do that by providing an index on the 3499 - * PCDAC/PDADC table we set up. 3500 - */ 3501 3067 3502 - /* 3503 - * Set rate power table 3068 + /** 3069 + * DOC: Per-rate tx power setting 3070 + * 3071 + * This is the code that sets the desired tx power limit (below 3072 + * maximum) on hw for each rate (we also have TPC that sets 3073 + * power per packet type). We do that by providing an index on the 3074 + * PCDAC/PDADC table we set up above, for each rate. 3504 3075 * 3505 3076 * For now we only limit txpower based on maximum tx power 3506 - * supported by hw (what's inside rate_info). We need to limit 3507 - * this even more, based on regulatory domain etc. 3077 + * supported by hw (what's inside rate_info) + conformance test 3078 + * limits. We need to limit this even more, based on regulatory domain 3079 + * etc to be safe. Normally this is done from above so we don't care 3080 + * here, all we care is that the tx power we set will be O.K. 3081 + * for the hw (e.g. won't create noise on PA etc). 3508 3082 * 3509 - * Rate power table contains indices to PCDAC/PDADC table (0.5dB steps) 3510 - * and is indexed as follows: 3083 + * Rate power table contains indices to PCDAC/PDADC table (0.5dB steps - 3084 + * x values) and is indexed as follows: 3511 3085 * rates[0] - rates[7] -> OFDM rates 3512 3086 * rates[8] - rates[14] -> CCK rates 3513 3087 * rates[15] -> XR rates (they all have the same power) 3088 + */ 3089 + 3090 + /** 3091 + * ath5k_setup_rate_powertable() - Set up rate power table for a given tx power 3092 + * @ah: The &struct ath5k_hw 3093 + * @max_pwr: The maximum tx power requested in 0.5dB steps 3094 + * @rate_info: The &struct ath5k_rate_pcal_info to fill 3095 + * @ee_mode: One of enum ath5k_driver_mode 3514 3096 */ 3515 3097 static void 3516 3098 ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr, ··· 3590 3156 } 3591 3157 3592 3158 3593 - /* 3594 - * Set transmission power 3159 + /** 3160 + * ath5k_hw_txpower() - Set transmission power limit for a given channel 3161 + * @ah: The &struct ath5k_hw 3162 + * @channel: The &struct ieee80211_channel 3163 + * @txpower: Requested tx power in 0.5dB steps 3164 + * 3165 + * Combines all of the above to set the requested tx power limit 3166 + * on hw. 3595 3167 */ 3596 3168 static int 3597 3169 ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, ··· 3715 3275 return 0; 3716 3276 } 3717 3277 3718 - int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) 3278 + /** 3279 + * ath5k_hw_set_txpower_limit() - Set txpower limit for the current channel 3280 + * @ah: The &struct ath5k_hw 3281 + * @txpower: The requested tx power limit in 0.5dB steps 3282 + * 3283 + * This function provides access to ath5k_hw_txpower to the driver in 3284 + * case user or an application changes it while PHY is running. 3285 + */ 3286 + int 3287 + ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) 3719 3288 { 3720 3289 ATH5K_DBG(ah, ATH5K_DEBUG_TXPOWER, 3721 3290 "changing txpower to %d\n", txpower); ··· 3732 3283 return ath5k_hw_txpower(ah, ah->ah_current_channel, txpower); 3733 3284 } 3734 3285 3286 + 3735 3287 /*************\ 3736 3288 Init function 3737 3289 \*************/ 3738 3290 3739 - int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, 3291 + /** 3292 + * ath5k_hw_phy_init() - Initialize PHY 3293 + * @ah: The &struct ath5k_hw 3294 + * @channel: The @struct ieee80211_channel 3295 + * @mode: One of enum ath5k_driver_mode 3296 + * @fast: Try a fast channel switch instead 3297 + * 3298 + * This is the main function used during reset to initialize PHY 3299 + * or do a fast channel change if possible. 3300 + * 3301 + * NOTE: Do not call this one from the driver, it assumes PHY is in a 3302 + * warm reset state ! 3303 + */ 3304 + int 3305 + ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, 3740 3306 u8 mode, bool fast) 3741 3307 { 3742 3308 struct ieee80211_channel *curr_channel;
+92 -32
drivers/net/wireless/ath/ath5k/qcu.c
··· 17 17 */ 18 18 19 19 /********************************************\ 20 - Queue Control Unit, DFS Control Unit Functions 20 + Queue Control Unit, DCF Control Unit Functions 21 21 \********************************************/ 22 22 23 23 #include "ath5k.h" 24 24 #include "reg.h" 25 25 #include "debug.h" 26 26 27 + /** 28 + * DOC: Queue Control Unit (QCU)/DCF Control Unit (DCU) functions 29 + * 30 + * Here we setup parameters for the 12 available TX queues. Note that 31 + * on the various registers we can usually only map the first 10 of them so 32 + * basically we have 10 queues to play with. Each queue has a matching 33 + * QCU that controls when the queue will get triggered and multiple QCUs 34 + * can be mapped to a single DCU that controls the various DFS parameters 35 + * for the various queues. In our setup we have a 1:1 mapping between QCUs 36 + * and DCUs allowing us to have different DFS settings for each queue. 37 + * 38 + * When a frame goes into a TX queue, QCU decides when it'll trigger a 39 + * transmission based on various criteria (such as how many data we have inside 40 + * it's buffer or -if it's a beacon queue- if it's time to fire up the queue 41 + * based on TSF etc), DCU adds backoff, IFSes etc and then a scheduler 42 + * (arbitrator) decides the priority of each QCU based on it's configuration 43 + * (e.g. beacons are always transmitted when they leave DCU bypassing all other 44 + * frames from other queues waiting to be transmitted). After a frame leaves 45 + * the DCU it goes to PCU for further processing and then to PHY for 46 + * the actual transmission. 47 + */ 48 + 27 49 28 50 /******************\ 29 51 * Helper functions * 30 52 \******************/ 31 53 32 - /* 33 - * Get number of pending frames 34 - * for a specific queue [5211+] 54 + /** 55 + * ath5k_hw_num_tx_pending() - Get number of pending frames for a given queue 56 + * @ah: The &struct ath5k_hw 57 + * @queue: The hw queue number 35 58 */ 36 - u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue) 59 + u32 60 + ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue) 37 61 { 38 62 u32 pending; 39 63 AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num); ··· 82 58 return pending; 83 59 } 84 60 85 - /* 86 - * Set a transmit queue inactive 61 + /** 62 + * ath5k_hw_release_tx_queue() - Set a transmit queue inactive 63 + * @ah: The &struct ath5k_hw 64 + * @queue: The hw queue number 87 65 */ 88 - void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue) 66 + void 67 + ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue) 89 68 { 90 69 if (WARN_ON(queue >= ah->ah_capabilities.cap_queues.q_tx_num)) 91 70 return; ··· 99 72 AR5K_Q_DISABLE_BITS(ah->ah_txq_status, queue); 100 73 } 101 74 102 - /* 75 + /** 76 + * ath5k_cw_validate() - Make sure the given cw is valid 77 + * @cw_req: The contention window value to check 78 + * 103 79 * Make sure cw is a power of 2 minus 1 and smaller than 1024 104 80 */ 105 - static u16 ath5k_cw_validate(u16 cw_req) 81 + static u16 82 + ath5k_cw_validate(u16 cw_req) 106 83 { 107 84 u32 cw = 1; 108 85 cw_req = min(cw_req, (u16)1023); ··· 117 86 return cw; 118 87 } 119 88 120 - /* 121 - * Get properties for a transmit queue 89 + /** 90 + * ath5k_hw_get_tx_queueprops() - Get properties for a transmit queue 91 + * @ah: The &struct ath5k_hw 92 + * @queue: The hw queue number 93 + * @queue_info: The &struct ath5k_txq_info to fill 122 94 */ 123 - int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, 95 + int 96 + ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, 124 97 struct ath5k_txq_info *queue_info) 125 98 { 126 99 memcpy(queue_info, &ah->ah_txq[queue], sizeof(struct ath5k_txq_info)); 127 100 return 0; 128 101 } 129 102 130 - /* 131 - * Set properties for a transmit queue 103 + /** 104 + * ath5k_hw_set_tx_queueprops() - Set properties for a transmit queue 105 + * @ah: The &struct ath5k_hw 106 + * @queue: The hw queue number 107 + * @qinfo: The &struct ath5k_txq_info to use 108 + * 109 + * Returns 0 on success or -EIO if queue is inactive 132 110 */ 133 - int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue, 111 + int 112 + ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue, 134 113 const struct ath5k_txq_info *qinfo) 135 114 { 136 115 struct ath5k_txq_info *qi; ··· 180 139 return 0; 181 140 } 182 141 183 - /* 184 - * Initialize a transmit queue 142 + /** 143 + * ath5k_hw_setup_tx_queue() - Initialize a transmit queue 144 + * @ah: The &struct ath5k_hw 145 + * @queue_type: One of enum ath5k_tx_queue 146 + * @queue_info: The &struct ath5k_txq_info to use 147 + * 148 + * Returns 0 on success, -EINVAL on invalid arguments 185 149 */ 186 - int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type, 150 + int 151 + ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type, 187 152 struct ath5k_txq_info *queue_info) 188 153 { 189 154 unsigned int queue; ··· 264 217 * Single QCU/DCU initialization * 265 218 \*******************************/ 266 219 267 - /* 268 - * Set tx retry limits on DCU 220 + /** 221 + * ath5k_hw_set_tx_retry_limits() - Set tx retry limits on DCU 222 + * @ah: The &struct ath5k_hw 223 + * @queue: The hw queue number 224 + * 225 + * This function is used when initializing a queue, to set 226 + * retry limits based on ah->ah_retry_* and the chipset used. 269 227 */ 270 - void ath5k_hw_set_tx_retry_limits(struct ath5k_hw *ah, 228 + void 229 + ath5k_hw_set_tx_retry_limits(struct ath5k_hw *ah, 271 230 unsigned int queue) 272 231 { 273 232 /* Single data queue on AR5210 */ ··· 308 255 } 309 256 310 257 /** 311 - * ath5k_hw_reset_tx_queue - Initialize a single hw queue 312 - * 313 - * @ah The &struct ath5k_hw 314 - * @queue The hw queue number 258 + * ath5k_hw_reset_tx_queue() - Initialize a single hw queue 259 + * @ah: The &struct ath5k_hw 260 + * @queue: The hw queue number 315 261 * 316 262 * Set DFS properties for the given transmit queue on DCU 317 263 * and configures all queue-specific parameters. 318 264 */ 319 - int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue) 265 + int 266 + ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue) 320 267 { 321 268 struct ath5k_txq_info *tq = &ah->ah_txq[queue]; 322 269 ··· 544 491 \**************************/ 545 492 546 493 /** 547 - * ath5k_hw_set_ifs_intervals - Set global inter-frame spaces on DCU 548 - * 549 - * @ah The &struct ath5k_hw 550 - * @slot_time Slot time in us 494 + * ath5k_hw_set_ifs_intervals() - Set global inter-frame spaces on DCU 495 + * @ah: The &struct ath5k_hw 496 + * @slot_time: Slot time in us 551 497 * 552 498 * Sets the global IFS intervals on DCU (also works on AR5210) for 553 499 * the given slot time and the current bwmode. ··· 649 597 } 650 598 651 599 652 - int ath5k_hw_init_queues(struct ath5k_hw *ah) 600 + /** 601 + * ath5k_hw_init_queues() - Initialize tx queues 602 + * @ah: The &struct ath5k_hw 603 + * 604 + * Initializes all tx queues based on information on 605 + * ah->ah_txq* set by the driver 606 + */ 607 + int 608 + ath5k_hw_init_queues(struct ath5k_hw *ah) 653 609 { 654 610 int i, ret; 655 611
+164 -52
drivers/net/wireless/ath/ath5k/reset.c
··· 19 19 * 20 20 */ 21 21 22 - /*****************************\ 23 - Reset functions and helpers 24 - \*****************************/ 22 + /****************************\ 23 + Reset function and helpers 24 + \****************************/ 25 25 26 26 #include <asm/unaligned.h> 27 27 ··· 33 33 #include "debug.h" 34 34 35 35 36 + /** 37 + * DOC: Reset function and helpers 38 + * 39 + * Here we implement the main reset routine, used to bring the card 40 + * to a working state and ready to receive. We also handle routines 41 + * that don't fit on other places such as clock, sleep and power control 42 + */ 43 + 44 + 36 45 /******************\ 37 46 * Helper functions * 38 47 \******************/ 39 48 40 - /* 41 - * Check if a register write has been completed 49 + /** 50 + * ath5k_hw_register_timeout() - Poll a register for a flag/field change 51 + * @ah: The &struct ath5k_hw 52 + * @reg: The register to read 53 + * @flag: The flag/field to check on the register 54 + * @val: The field value we expect (if we check a field) 55 + * @is_set: Instead of checking if the flag got cleared, check if it got set 56 + * 57 + * Some registers contain flags that indicate that an operation is 58 + * running. We use this function to poll these registers and check 59 + * if these flags get cleared. We also use it to poll a register 60 + * field (containing multiple flags) until it gets a specific value. 61 + * 62 + * Returns -EAGAIN if we exceeded AR5K_TUNE_REGISTER_TIMEOUT * 15us or 0 42 63 */ 43 - int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val, 64 + int 65 + ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val, 44 66 bool is_set) 45 67 { 46 68 int i; ··· 86 64 \*************************/ 87 65 88 66 /** 89 - * ath5k_hw_htoclock - Translate usec to hw clock units 90 - * 67 + * ath5k_hw_htoclock() - Translate usec to hw clock units 91 68 * @ah: The &struct ath5k_hw 92 69 * @usec: value in microseconds 70 + * 71 + * Translate usecs to hw clock units based on the current 72 + * hw clock rate. 73 + * 74 + * Returns number of clock units 93 75 */ 94 - unsigned int ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec) 76 + unsigned int 77 + ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec) 95 78 { 96 79 struct ath_common *common = ath5k_hw_common(ah); 97 80 return usec * common->clockrate; 98 81 } 99 82 100 83 /** 101 - * ath5k_hw_clocktoh - Translate hw clock units to usec 84 + * ath5k_hw_clocktoh() - Translate hw clock units to usec 85 + * @ah: The &struct ath5k_hw 102 86 * @clock: value in hw clock units 87 + * 88 + * Translate hw clock units to usecs based on the current 89 + * hw clock rate. 90 + * 91 + * Returns number of usecs 103 92 */ 104 - unsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock) 93 + unsigned int 94 + ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock) 105 95 { 106 96 struct ath_common *common = ath5k_hw_common(ah); 107 97 return clock / common->clockrate; 108 98 } 109 99 110 100 /** 111 - * ath5k_hw_init_core_clock - Initialize core clock 101 + * ath5k_hw_init_core_clock() - Initialize core clock 102 + * @ah: The &struct ath5k_hw 112 103 * 113 - * @ah The &struct ath5k_hw 114 - * 115 - * Initialize core clock parameters (usec, usec32, latencies etc). 104 + * Initialize core clock parameters (usec, usec32, latencies etc), 105 + * based on current bwmode and chipset properties. 116 106 */ 117 - static void ath5k_hw_init_core_clock(struct ath5k_hw *ah) 107 + static void 108 + ath5k_hw_init_core_clock(struct ath5k_hw *ah) 118 109 { 119 110 struct ieee80211_channel *channel = ah->ah_current_channel; 120 111 struct ath_common *common = ath5k_hw_common(ah); ··· 262 227 } 263 228 } 264 229 265 - /* 230 + /** 231 + * ath5k_hw_set_sleep_clock() - Setup sleep clock operation 232 + * @ah: The &struct ath5k_hw 233 + * @enable: Enable sleep clock operation (false to disable) 234 + * 266 235 * If there is an external 32KHz crystal available, use it 267 236 * as ref. clock instead of 32/40MHz clock and baseband clocks 268 237 * to save power during sleep or restore normal 32/40MHz 269 238 * operation. 270 239 * 271 - * XXX: When operating on 32KHz certain PHY registers (27 - 31, 272 - * 123 - 127) require delay on access. 240 + * NOTE: When operating on 32KHz certain PHY registers (27 - 31, 241 + * 123 - 127) require delay on access. 273 242 */ 274 - static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) 243 + static void 244 + ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) 275 245 { 276 246 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; 277 247 u32 scal, spending, sclock; ··· 380 340 * Reset/Sleep control * 381 341 \*********************/ 382 342 383 - /* 384 - * Reset chipset 343 + /** 344 + * ath5k_hw_nic_reset() - Reset the various chipset units 345 + * @ah: The &struct ath5k_hw 346 + * @val: Mask to indicate what units to reset 347 + * 348 + * To reset the various chipset units we need to write 349 + * the mask to AR5K_RESET_CTL and poll the register until 350 + * all flags are cleared. 351 + * 352 + * Returns 0 if we are O.K. or -EAGAIN (from athk5_hw_register_timeout) 385 353 */ 386 - static int ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val) 354 + static int 355 + ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val) 387 356 { 388 357 int ret; 389 358 u32 mask = val ? val : ~0U; ··· 431 382 return ret; 432 383 } 433 384 434 - /* 435 - * Reset AHB chipset 436 - * AR5K_RESET_CTL_PCU flag resets WMAC 437 - * AR5K_RESET_CTL_BASEBAND flag resets WBB 385 + /** 386 + * ath5k_hw_wisoc_reset() - Reset AHB chipset 387 + * @ah: The &struct ath5k_hw 388 + * @flags: Mask to indicate what units to reset 389 + * 390 + * Same as ath5k_hw_nic_reset but for AHB based devices 391 + * 392 + * Returns 0 if we are O.K. or -EAGAIN (from athk5_hw_register_timeout) 438 393 */ 439 - static int ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags) 394 + static int 395 + ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags) 440 396 { 441 397 u32 mask = flags ? flags : ~0U; 442 398 u32 __iomem *reg; ··· 493 439 return 0; 494 440 } 495 441 496 - 497 - /* 498 - * Sleep control 442 + /** 443 + * ath5k_hw_set_power_mode() - Set power mode 444 + * @ah: The &struct ath5k_hw 445 + * @mode: One of enum ath5k_power_mode 446 + * @set_chip: Set to true to write sleep control register 447 + * @sleep_duration: How much time the device is allowed to sleep 448 + * when sleep logic is enabled (in 128 microsecond increments). 449 + * 450 + * This function is used to configure sleep policy and allowed 451 + * sleep modes. For more information check out the sleep control 452 + * register on reg.h and STA_ID1. 453 + * 454 + * Returns 0 on success, -EIO if chip didn't wake up or -EINVAL if an invalid 455 + * mode is requested. 499 456 */ 500 - static int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, 457 + static int 458 + ath5k_hw_set_power_mode(struct ath5k_hw *ah, enum ath5k_power_mode mode, 501 459 bool set_chip, u16 sleep_duration) 502 460 { 503 461 unsigned int i; ··· 589 523 return 0; 590 524 } 591 525 592 - /* 593 - * Put device on hold 526 + /** 527 + * ath5k_hw_on_hold() - Put device on hold 528 + * @ah: The &struct ath5k_hw 594 529 * 595 - * Put MAC and Baseband on warm reset and 596 - * keep that state (don't clean sleep control 597 - * register). After this MAC and Baseband are 598 - * disabled and a full reset is needed to come 599 - * back. This way we save as much power as possible 530 + * Put MAC and Baseband on warm reset and keep that state 531 + * (don't clean sleep control register). After this MAC 532 + * and Baseband are disabled and a full reset is needed 533 + * to come back. This way we save as much power as possible 600 534 * without putting the card on full sleep. 535 + * 536 + * Returns 0 on success or -EIO on error 601 537 */ 602 - int ath5k_hw_on_hold(struct ath5k_hw *ah) 538 + int 539 + ath5k_hw_on_hold(struct ath5k_hw *ah) 603 540 { 604 541 struct pci_dev *pdev = ah->pdev; 605 542 u32 bus_flags; ··· 612 543 return 0; 613 544 614 545 /* Make sure device is awake */ 615 - ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); 546 + ret = ath5k_hw_set_power_mode(ah, AR5K_PM_AWAKE, true, 0); 616 547 if (ret) { 617 548 ATH5K_ERR(ah, "failed to wakeup the MAC Chip\n"); 618 549 return ret; ··· 644 575 } 645 576 646 577 /* ...wakeup again!*/ 647 - ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); 578 + ret = ath5k_hw_set_power_mode(ah, AR5K_PM_AWAKE, true, 0); 648 579 if (ret) { 649 580 ATH5K_ERR(ah, "failed to put device on hold\n"); 650 581 return ret; ··· 653 584 return ret; 654 585 } 655 586 656 - /* 587 + /** 588 + * ath5k_hw_nic_wakeup() - Force card out of sleep 589 + * @ah: The &struct ath5k_hw 590 + * @channel: The &struct ieee80211_channel 591 + * 657 592 * Bring up MAC + PHY Chips and program PLL 658 - * Channel is NULL for the initial wakeup. 593 + * NOTE: Channel is NULL for the initial wakeup. 594 + * 595 + * Returns 0 on success, -EIO on hw failure or -EINVAL for false channel infos 659 596 */ 660 - int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel) 597 + int 598 + ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel) 661 599 { 662 600 struct pci_dev *pdev = ah->pdev; 663 601 u32 turbo, mode, clock, bus_flags; ··· 676 600 677 601 if ((ath5k_get_bus_type(ah) != ATH_AHB) || channel) { 678 602 /* Wakeup the device */ 679 - ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); 603 + ret = ath5k_hw_set_power_mode(ah, AR5K_PM_AWAKE, true, 0); 680 604 if (ret) { 681 605 ATH5K_ERR(ah, "failed to wakeup the MAC Chip\n"); 682 606 return ret; ··· 713 637 } 714 638 715 639 /* ...wakeup again!...*/ 716 - ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); 640 + ret = ath5k_hw_set_power_mode(ah, AR5K_PM_AWAKE, true, 0); 717 641 if (ret) { 718 642 ATH5K_ERR(ah, "failed to resume the MAC Chip\n"); 719 643 return ret; ··· 831 755 * Post-initvals register modifications * 832 756 \**************************************/ 833 757 834 - /* TODO: Half/Quarter rate */ 835 - static void ath5k_hw_tweak_initval_settings(struct ath5k_hw *ah, 758 + /** 759 + * ath5k_hw_tweak_initval_settings() - Tweak initial settings 760 + * @ah: The &struct ath5k_hw 761 + * @channel: The &struct ieee80211_channel 762 + * 763 + * Some settings are not handled on initvals, e.g. bwmode 764 + * settings, some phy settings, workarounds etc that in general 765 + * don't fit anywhere else or are too small to introduce a separate 766 + * function for each one. So we have this function to handle 767 + * them all during reset and complete card's initialization. 768 + */ 769 + static void 770 + ath5k_hw_tweak_initval_settings(struct ath5k_hw *ah, 836 771 struct ieee80211_channel *channel) 837 772 { 838 773 if (ah->ah_version == AR5K_AR5212 && ··· 962 875 } 963 876 } 964 877 965 - static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah, 878 + /** 879 + * ath5k_hw_commit_eeprom_settings() - Commit settings from EEPROM 880 + * @ah: The &struct ath5k_hw 881 + * @channel: The &struct ieee80211_channel 882 + * 883 + * Use settings stored on EEPROM to properly initialize the card 884 + * based on various infos and per-mode calibration data. 885 + */ 886 + static void 887 + ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah, 966 888 struct ieee80211_channel *channel) 967 889 { 968 890 struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; ··· 1125 1029 * Main reset function * 1126 1030 \*********************/ 1127 1031 1128 - int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, 1032 + /** 1033 + * ath5k_hw_reset() - The main reset function 1034 + * @ah: The &struct ath5k_hw 1035 + * @op_mode: One of enum nl80211_iftype 1036 + * @channel: The &struct ieee80211_channel 1037 + * @fast: Enable fast channel switching 1038 + * @skip_pcu: Skip pcu initialization 1039 + * 1040 + * This is the function we call each time we want to (re)initialize the 1041 + * card and pass new settings to hw. We also call it when hw runs into 1042 + * trouble to make it come back to a working state. 1043 + * 1044 + * Returns 0 on success, -EINVAL on false op_mode or channel infos, or -EIO 1045 + * on failure. 1046 + */ 1047 + int 1048 + ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, 1129 1049 struct ieee80211_channel *channel, bool fast, bool skip_pcu) 1130 1050 { 1131 1051 u32 s_seq[10], s_led[3], tsf_up, tsf_lo; ··· 1354 1242 /* 1355 1243 * Initialize PCU 1356 1244 */ 1357 - ath5k_hw_pcu_init(ah, op_mode, mode); 1245 + ath5k_hw_pcu_init(ah, op_mode); 1358 1246 1359 1247 /* 1360 1248 * Initialize PHY
+42 -17
drivers/net/wireless/ath/ath5k/rfbuffer.h
··· 18 18 */ 19 19 20 20 21 - /* 21 + /** 22 + * DOC: RF Buffer registers 23 + * 22 24 * There are some special registers on the RF chip 23 25 * that control various operation settings related mostly to 24 26 * the analog parts (channel, gain adjustment etc). ··· 46 44 */ 47 45 48 46 49 - /* 47 + /** 48 + * struct ath5k_ini_rfbuffer - Initial RF Buffer settings 49 + * @rfb_bank: RF Bank number 50 + * @rfb_ctrl_register: RF Buffer control register 51 + * @rfb_mode_data: RF Buffer data for each mode 52 + * 50 53 * Struct to hold default mode specific RF 51 - * register values (RF Banks) 54 + * register values (RF Banks) for each chip. 52 55 */ 53 56 struct ath5k_ini_rfbuffer { 54 - u8 rfb_bank; /* RF Bank number */ 55 - u16 rfb_ctrl_register; /* RF Buffer control register */ 56 - u32 rfb_mode_data[3]; /* RF Buffer data for each mode */ 57 + u8 rfb_bank; 58 + u16 rfb_ctrl_register; 59 + u32 rfb_mode_data[3]; 57 60 }; 58 61 59 - /* 62 + /** 63 + * struct ath5k_rfb_field - An RF Buffer field (register/value) 64 + * @len: Field length 65 + * @pos: Offset on the raw packet 66 + * @col: Used for shifting 67 + * 60 68 * Struct to hold RF Buffer field 61 69 * infos used to access certain RF 62 70 * analog registers 63 71 */ 64 72 struct ath5k_rfb_field { 65 - u8 len; /* Field length */ 66 - u16 pos; /* Offset on the raw packet */ 67 - u8 col; /* Column -used for shifting */ 73 + u8 len; 74 + u16 pos; 75 + u8 col; 68 76 }; 69 77 70 - /* 71 - * RF analog register definition 78 + /** 79 + * struct ath5k_rf_reg - RF analog register definition 80 + * @bank: RF Buffer Bank number 81 + * @index: Register's index on ath5k_rf_regx_idx 82 + * @field: The &struct ath5k_rfb_field 83 + * 84 + * We use this struct to define the set of RF registers 85 + * on each chip that we want to tweak. Some RF registers 86 + * are common between different chip versions so this saves 87 + * us space and complexity because we can refer to an rf 88 + * register by it's index no matter what chip we work with 89 + * as long as it has that register. 72 90 */ 73 91 struct ath5k_rf_reg { 74 - u8 bank; /* RF Buffer Bank number */ 75 - u8 index; /* Register's index on rf_regs_idx */ 76 - struct ath5k_rfb_field field; /* RF Buffer field for this register */ 92 + u8 bank; 93 + u8 index; 94 + struct ath5k_rfb_field field; 77 95 }; 78 96 79 - /* Map RF registers to indexes 97 + /** 98 + * enum ath5k_rf_regs_idx - Map RF registers to indexes 99 + * 80 100 * We do this to handle common bits and make our 81 101 * life easier by using an index for each register 82 - * instead of a full rfb_field */ 102 + * instead of a full rfb_field 103 + */ 83 104 enum ath5k_rf_regs_idx { 84 105 /* BANK 2 */ 85 106 AR5K_RF_TURBO = 0,
+20 -2
drivers/net/wireless/ath/ath5k/rfgain.h
··· 18 18 * 19 19 */ 20 20 21 - /* 21 + /** 22 + * struct ath5k_ini_rfgain - RF Gain table 23 + * @rfg_register: RF Gain register address 24 + * @rfg_value: Register value for 5 and 2GHz 25 + * 22 26 * Mode-specific RF Gain table (64bytes) for RF5111/5112 23 27 * (RF5110 only comes with AR5210 and only supports a/turbo a mode so initial 24 28 * RF Gain values are included in AR5K_AR5210_INI) 25 29 */ 26 30 struct ath5k_ini_rfgain { 27 - u16 rfg_register; /* RF Gain register address */ 31 + u16 rfg_register; 28 32 u32 rfg_value[2]; /* [freq (see below)] */ 29 33 }; 30 34 ··· 459 455 #define AR5K_GAIN_CHECK_ADJUST(_g) \ 460 456 ((_g)->g_current <= (_g)->g_low || (_g)->g_current >= (_g)->g_high) 461 457 458 + /** 459 + * struct ath5k_gain_opt_step - An RF gain optimization step 460 + * @gos_param: Set of parameters 461 + * @gos_gain: Gain 462 + */ 462 463 struct ath5k_gain_opt_step { 463 464 s8 gos_param[AR5K_GAIN_CRN_MAX_FIX_BITS]; 464 465 s8 gos_gain; 465 466 }; 466 467 468 + /** 469 + * struct ath5k_gain_opt - RF Gain optimization ladder 470 + * @go_default: The default step 471 + * @go_steps_count: How many optimization steps 472 + * @go_step: Array of &struct ath5k_gain_opt_step 473 + */ 467 474 struct ath5k_gain_opt { 468 475 u8 go_default; 469 476 u8 go_steps_count; 470 477 const struct ath5k_gain_opt_step go_step[AR5K_GAIN_STEP_COUNT]; 471 478 }; 472 479 480 + 473 481 /* 482 + * RF5111 474 483 * Parameters on gos_param: 475 484 * 1) Tx clip PHY register 476 485 * 2) PWD 90 RF register ··· 507 490 }; 508 491 509 492 /* 493 + * RF5112 510 494 * Parameters on gos_param: 511 495 * 1) Mixgain ovr RF register 512 496 * 2) PWD 138 RF register