Changeset 8a64320e in mainline for uspace/drv/nic/ar9271/hw.c
- Timestamp:
- 2015-04-23T23:40:14Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dcba819
- Parents:
- 09044cb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/ar9271/hw.c
r09044cb r8a64320e 38 38 #include <nic.h> 39 39 #include <ieee80211.h> 40 41 40 #include "hw.h" 42 41 #include "wmi.h" 43 42 44 /** 45 * Try to wait for register value repeatedly until timeout is reached. 46 * 43 /** Try to wait for register value repeatedly until timeout is reached. 44 * 47 45 * @param ar9271 Device structure. 48 46 * @param offset Registry offset (address) to be read. 49 * @param mask Mask to apply on read result. 50 * @param value Required value we are waiting for. 51 * 52 * @return EOK if succeed, ETIMEOUT on timeout, negative error code otherwise. 47 * @param mask Mask to apply on read result. 48 * @param value Required value we are waiting for. 49 * 50 * @return EOK if succeed, ETIMEOUT on timeout, 51 * negative error code otherwise. 52 * 53 53 */ 54 54 static int hw_read_wait(ar9271_t *ar9271, uint32_t offset, uint32_t mask, 55 uint32_t value) 56 { 57 uint32_t result; 58 59 for(size_t i = 0; i < HW_WAIT_LOOPS; i++) { 55 uint32_t value) 56 { 57 for (size_t i = 0; i < HW_WAIT_LOOPS; i++) { 60 58 udelay(HW_WAIT_TIME_US); 61 59 60 uint32_t result; 62 61 wmi_reg_read(ar9271->htc_device, offset, &result); 63 if ((result & mask) == value) {62 if ((result & mask) == value) 64 63 return EOK; 65 }66 64 } 67 65 … … 74 72 { 75 73 .offset = AR9271_RTC_FORCE_WAKE, 76 .value = AR9271_RTC_FORCE_WAKE_ENABLE | 77 74 .value = AR9271_RTC_FORCE_WAKE_ENABLE | 75 AR9271_RTC_FORCE_WAKE_ON_INT 78 76 }, 79 77 { … … 88 86 89 87 wmi_reg_buffer_write(ar9271->htc_device, buffer, 90 88 sizeof(buffer) / sizeof(wmi_reg_t)); 91 89 92 90 udelay(2); … … 95 93 wmi_reg_write(ar9271->htc_device, AR9271_RTC_RESET, 1); 96 94 97 int rc = hw_read_wait(ar9271, 98 AR9271_RTC_STATUS,99 AR9271_RTC_STATUS_MASK,100 101 if (rc != EOK) {95 int rc = hw_read_wait(ar9271, 96 AR9271_RTC_STATUS, 97 AR9271_RTC_STATUS_MASK, 98 AR9271_RTC_STATUS_ON); 99 if (rc != EOK) { 102 100 usb_log_error("Failed to wait for RTC wake up register.\n"); 103 101 return rc; … … 111 109 uint32_t reset_value = AR9271_RTC_RC_MAC_WARM; 112 110 113 if (cold) {111 if (cold) 114 112 reset_value |= AR9271_RTC_RC_MAC_COLD; 115 }116 113 117 114 wmi_reg_t buffer[] = { 118 115 { 119 116 .offset = AR9271_RTC_FORCE_WAKE, 120 .value = AR9271_RTC_FORCE_WAKE_ENABLE | 121 117 .value = AR9271_RTC_FORCE_WAKE_ENABLE | 118 AR9271_RTC_FORCE_WAKE_ON_INT 122 119 }, 123 120 { … … 131 128 }; 132 129 133 wmi_reg_buffer_write(ar9271->htc_device, buffer, 134 130 wmi_reg_buffer_write(ar9271->htc_device, buffer, 131 sizeof(buffer) / sizeof(wmi_reg_t)); 135 132 136 133 udelay(100); … … 139 136 140 137 int rc = hw_read_wait(ar9271, AR9271_RTC_RC, AR9271_RTC_RC_MASK, 0); 141 if (rc != EOK) {138 if (rc != EOK) { 142 139 usb_log_error("Failed to wait for RTC RC register.\n"); 143 140 return rc; … … 145 142 146 143 wmi_reg_write(ar9271->htc_device, AR9271_RC, 0); 147 wmi_reg_clear_bit(ar9271->htc_device, AR9271_STATION_ID1, 148 144 wmi_reg_clear_bit(ar9271->htc_device, AR9271_STATION_ID1, 145 AR9271_STATION_ID1_POWER_SAVING); 149 146 150 147 return EOK; … … 156 153 nic_address_t ar9271_address; 157 154 158 for(int i = 0; i < 3; i++) { 159 wmi_reg_read(ar9271->htc_device, 160 AR9271_EEPROM_MAC_ADDR_START + i*4, 161 &value); 155 for (unsigned int i = 0; i < 3; i++) { 156 wmi_reg_read(ar9271->htc_device, 157 AR9271_EEPROM_MAC_ADDR_START + i * 4, &value); 162 158 163 159 uint16_t two_bytes = uint16_t_be2host(value); … … 169 165 170 166 int rc = nic_report_address(nic, &ar9271_address); 171 if (rc != EOK) {167 if (rc != EOK) { 172 168 usb_log_error("Failed to report NIC HW address.\n"); 173 169 return rc; … … 179 175 static int hw_gpio_set_output(ar9271_t *ar9271, uint32_t gpio, uint32_t type) 180 176 { 181 uint32_t address , gpio_shift, temp;182 183 if (gpio > 11) {177 uint32_t address; 178 179 if (gpio > 11) 184 180 address = AR9271_GPIO_OUT_MUX3; 185 } else if(gpio > 5) {181 else if (gpio > 5) 186 182 address = AR9271_GPIO_OUT_MUX2; 187 } else {183 else 188 184 address = AR9271_GPIO_OUT_MUX1; 189 }190 191 gpio_shift = (gpio % 6) * 5;192 185 186 uint32_t gpio_shift = (gpio % 6) * 5; 187 188 uint32_t temp; 193 189 wmi_reg_read(ar9271->htc_device, address, &temp); 194 195 temp = ((temp & 0x1 F0) << 1) | (temp & ~0x1F0);190 191 temp = ((temp & 0x1f0) << 1) | (temp & ~0x1f0); 196 192 temp &= ~(0x1f << gpio_shift); 197 193 temp |= (type << gpio_shift); 198 194 199 195 wmi_reg_write(ar9271->htc_device, address, temp); 200 196 … … 202 198 203 199 wmi_reg_set_clear_bit(ar9271->htc_device, AR9271_GPIO_OE_OUT, 204 AR9271_GPIO_OE_OUT_ALWAYS << gpio_shift,205 200 AR9271_GPIO_OE_OUT_ALWAYS << gpio_shift, 201 AR9271_GPIO_OE_OUT_ALWAYS << gpio_shift); 206 202 207 203 return EOK; … … 211 207 { 212 208 wmi_reg_set_clear_bit(ar9271->htc_device, AR9271_GPIO_IN_OUT, 213 (~value & 1) << gpio, 1 << gpio); 214 return EOK; 215 } 216 217 /** 218 * Hardware init procedure of AR9271 device. 219 * 209 (~value & 1) << gpio, 1 << gpio); 210 return EOK; 211 } 212 213 /**Hardware init procedure of AR9271 device. 214 * 220 215 * @param ar9271 Device structure. 221 * 216 * 222 217 * @return EOK if succeed, negative error code otherwise. 218 * 223 219 */ 224 220 static int hw_init_proc(ar9271_t *ar9271) 225 221 { 226 222 int rc = hw_reset_power_on(ar9271); 227 if (rc != EOK) {223 if (rc != EOK) { 228 224 usb_log_error("Failed to HW reset power on.\n"); 229 225 return rc; … … 231 227 232 228 rc = hw_set_reset(ar9271, false); 233 if (rc != EOK) {229 if (rc != EOK) { 234 230 usb_log_error("Failed to HW warm reset.\n"); 235 231 return rc; … … 237 233 238 234 rc = hw_addr_init(ar9271); 239 if (rc != EOK) {235 if (rc != EOK) { 240 236 usb_log_error("Failed to init HW addr.\n"); 241 237 return rc; … … 247 243 static int hw_init_led(ar9271_t *ar9271) 248 244 { 249 int rc = hw_gpio_set_output(ar9271, AR9271_LED_PIN, 250 251 if (rc != EOK) {245 int rc = hw_gpio_set_output(ar9271, AR9271_LED_PIN, 246 AR9271_GPIO_OUT_MUX_AS_OUT); 247 if (rc != EOK) { 252 248 usb_log_error("Failed to set led GPIO to output.\n"); 253 249 return rc; … … 255 251 256 252 rc = hw_gpio_set_value(ar9271, AR9271_LED_PIN, 0); 257 if (rc != EOK) {253 if (rc != EOK) { 258 254 usb_log_error("Failed to init bring up GPIO led.\n"); 259 255 return rc; … … 271 267 } 272 268 273 static int hw_set_operating_mode(ar9271_t *ar9271, 274 269 static int hw_set_operating_mode(ar9271_t *ar9271, 270 ieee80211_operating_mode_t op_mode) 275 271 { 276 272 uint32_t set_bit = 0x10000000; 277 273 278 274 switch(op_mode) { 279 280 281 282 283 284 285 286 287 288 289 275 case IEEE80211_OPMODE_ADHOC: 276 set_bit |= AR9271_OPMODE_ADHOC_MASK; 277 wmi_reg_set_bit(ar9271->htc_device, AR9271_CONFIG, 278 AR9271_CONFIG_ADHOC); 279 break; 280 case IEEE80211_OPMODE_MESH: 281 case IEEE80211_OPMODE_AP: 282 set_bit |= AR9271_OPMODE_STATION_AP_MASK; 283 case IEEE80211_OPMODE_STATION: 284 wmi_reg_clear_bit(ar9271->htc_device, AR9271_CONFIG, 285 AR9271_CONFIG_ADHOC); 290 286 } 291 287 292 288 wmi_reg_set_clear_bit(ar9271->htc_device, AR9271_STATION_ID1, 293 set_bit, 294 AR9271_OPMODE_STATION_AP_MASK | AR9271_OPMODE_ADHOC_MASK); 289 set_bit, AR9271_OPMODE_STATION_AP_MASK | AR9271_OPMODE_ADHOC_MASK); 295 290 296 291 ieee80211_report_current_op_mode(ar9271->ieee80211_dev, op_mode); … … 302 297 { 303 298 int rc = hw_set_operating_mode(ar9271, IEEE80211_OPMODE_STATION); 304 if (rc != EOK) {299 if (rc != EOK) { 305 300 usb_log_error("Failed to set opmode to station.\n"); 306 301 return rc; … … 314 309 uint32_t value; 315 310 wmi_reg_read(ar9271->htc_device, AR9271_PHY_CAL, &value); 316 value &= 0xFFFFFE00; 317 value |= (((uint32_t) AR9271_CALIB_NOMINAL_VALUE_2GHZ << 1) & 0x1FF); 311 312 value &= 0xfffffe00; 313 value |= (((uint32_t) AR9271_CALIB_NOMINAL_VALUE_2GHZ << 1) & 0x1ff); 314 318 315 wmi_reg_write(ar9271->htc_device, AR9271_PHY_CAL, value); 319 316 320 wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 321 322 323 wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 324 325 326 wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 327 328 329 int rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL, 330 331 if (rc != EOK) {317 wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 318 AR9271_AGC_CONTROL_NF_CALIB_EN); 319 320 wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 321 AR9271_AGC_CONTROL_NF_NOT_UPDATE); 322 323 wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 324 AR9271_AGC_CONTROL_NF_CALIB); 325 326 int rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL, 327 AR9271_AGC_CONTROL_NF_CALIB, 0); 328 if (rc != EOK) { 332 329 usb_log_error("Failed to wait for NF calibration.\n"); 333 330 return rc; 334 331 } 335 332 336 wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 337 338 339 wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 340 341 342 wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 343 333 wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 334 AR9271_AGC_CONTROL_NF_CALIB_EN); 335 336 wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 337 AR9271_AGC_CONTROL_NF_NOT_UPDATE); 338 339 wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 340 AR9271_AGC_CONTROL_NF_CALIB); 344 341 345 342 return EOK; … … 349 346 { 350 347 /* Not supported channel frequency. */ 351 if (freq < IEEE80211_FIRST_FREQ || freq > IEEE80211_MAX_FREQ) {348 if ((freq < IEEE80211_FIRST_FREQ) || (freq > IEEE80211_MAX_FREQ)) 352 349 return EINVAL; 353 }354 350 355 351 /* Not supported channel frequency. */ 356 if ((freq - IEEE80211_FIRST_FREQ) % IEEE80211_CHANNEL_GAP != 0) {352 if ((freq - IEEE80211_FIRST_FREQ) % IEEE80211_CHANNEL_GAP != 0) 357 353 return EINVAL; 358 }359 354 360 355 uint32_t tx_control; 361 356 wmi_reg_read(ar9271->htc_device, AR9271_PHY_CCK_TX_CTRL, &tx_control); 362 357 wmi_reg_write(ar9271->htc_device, AR9271_PHY_CCK_TX_CTRL, 363 358 tx_control & ~AR9271_PHY_CCK_TX_CTRL_JAPAN); 364 359 365 360 /* Some magic here. */ 366 361 uint32_t synth_ctl; 367 362 wmi_reg_read(ar9271->htc_device, AR9271_PHY_SYNTH_CONTROL, &synth_ctl); 368 synth_ctl &= 0x C0000000;363 synth_ctl &= 0xc0000000; 369 364 uint32_t channel_select = (freq * 0x10000) / 15; 370 365 synth_ctl = synth_ctl | (1 << 29) | (1 << 28) | channel_select; … … 382 377 383 378 int rc = hw_read_wait(ar9271, AR9271_PHY_RFBUS_GRANT, 0x1, 0x1); 384 if (rc != EOK) {379 if (rc != EOK) { 385 380 usb_log_error("Failed to kill RF bus.\n"); 386 381 return rc; … … 388 383 389 384 rc = hw_set_freq(ar9271, freq); 390 if (rc != EOK) {385 if (rc != EOK) { 391 386 usb_log_error("Failed to HW set frequency.\n"); 392 387 return rc; … … 394 389 395 390 rc = hw_activate_phy(ar9271); 396 if (rc != EOK) {391 if (rc != EOK) { 397 392 usb_log_error("Failed to activate physical layer.\n"); 398 393 return rc; … … 403 398 404 399 rc = hw_noise_floor_calibration(ar9271); 405 if (rc != EOK) {400 if (rc != EOK) { 406 401 usb_log_error("Failed to do NF calibration.\n"); 407 402 return rc; … … 413 408 int hw_set_rx_filter(ar9271_t *ar9271, bool assoc) 414 409 { 415 uint32_t filter_bits;416 417 410 uint32_t additional_bits = 0; 418 411 419 if (assoc) {412 if (assoc) 420 413 additional_bits |= AR9271_RX_FILTER_MYBEACON; 421 } else {414 else 422 415 additional_bits |= AR9271_RX_FILTER_BEACON; 423 }424 425 filter_bits = AR9271_RX_FILTER_UNI | AR9271_RX_FILTER_MULTI |426 AR9271_RX_FILTER_BROAD |additional_bits;416 417 uint32_t filter_bits = AR9271_RX_FILTER_UNI | 418 AR9271_RX_FILTER_MULTI | AR9271_RX_FILTER_BROAD | 419 additional_bits; 427 420 428 421 wmi_reg_write(ar9271->htc_device, AR9271_RX_FILTER, filter_bits); … … 441 434 uint16_t *last_2bytes = (uint16_t *) &bssid.address[4]; 442 435 443 wmi_reg_write(ar9271->htc_device, AR9271_BSSID0, 444 445 446 wmi_reg_write(ar9271->htc_device, AR9271_BSSID1, 447 uint16_t_le2host(*last_2bytes) |448 ((ieee80211_get_aid(ieee80211_dev) & 0x3FFF) << 16));436 wmi_reg_write(ar9271->htc_device, AR9271_BSSID0, 437 uint32_t_le2host(*first_4bytes)); 438 439 wmi_reg_write(ar9271->htc_device, AR9271_BSSID1, 440 uint16_t_le2host(*last_2bytes) | 441 ((ieee80211_get_aid(ieee80211_dev) & 0x3fff) << 16)); 449 442 450 443 return EOK; … … 453 446 int hw_rx_init(ar9271_t *ar9271) 454 447 { 455 wmi_reg_write(ar9271->htc_device, AR9271_COMMAND, 456 448 wmi_reg_write(ar9271->htc_device, AR9271_COMMAND, 449 AR9271_COMMAND_RX_ENABLE); 457 450 458 451 int rc = hw_set_rx_filter(ar9271, false); 459 if (rc != EOK) {452 if (rc != EOK) { 460 453 usb_log_error("Failed to set RX filtering.\n"); 461 454 return rc; … … 473 466 static int hw_init_pll(ar9271_t *ar9271) 474 467 { 475 uint32_t pll;476 477 468 /* Some magic here (set for 2GHz channels). But VERY important :-) */ 478 pll = (0x5 << 10) | 0x2C;469 uint32_t pll = (0x5 << 10) | 0x2c; 479 470 480 471 wmi_reg_write(ar9271->htc_device, AR9271_RTC_PLL_CONTROL, pll); 481 472 482 473 wmi_reg_write(ar9271->htc_device, AR9271_RTC_SLEEP_CLOCK, 483 474 AR9271_RTC_SLEEP_CLOCK_FORCE_DERIVED); 484 475 wmi_reg_set_bit(ar9271->htc_device, AR9271_RTC_FORCE_WAKE, 485 476 AR9271_RTC_FORCE_WAKE_ENABLE); 486 477 487 478 return EOK; … … 490 481 static void hw_set_init_values(ar9271_t *ar9271) 491 482 { 492 uint32_t reg_offset, reg_value; 493 494 int size = ARRAY_SIZE(ar9271_2g_mode_array); 495 496 for(int i = 0; i < size; i++) { 483 uint32_t reg_offset; 484 uint32_t reg_value; 485 486 size_t size = ARRAY_SIZE(ar9271_2g_mode_array); 487 488 for (size_t i = 0; i < size; i++) { 497 489 reg_offset = ar9271_2g_mode_array[i][0]; 498 490 reg_value = ar9271_2g_mode_array[i][1]; … … 502 494 size = ARRAY_SIZE(ar9271_2g_tx_array); 503 495 504 for (int i = 0; i < size; i++) {496 for (size_t i = 0; i < size; i++) { 505 497 reg_offset = ar9271_2g_tx_array[i][0]; 506 498 reg_value = ar9271_2g_tx_array[i][1]; … … 510 502 size = ARRAY_SIZE(ar9271_init_array); 511 503 512 for (int i = 0; i < size; i++) {504 for (size_t i = 0; i < size; i++) { 513 505 reg_offset = ar9271_init_array[i][0]; 514 506 reg_value = ar9271_init_array[i][1]; … … 520 512 { 521 513 wmi_reg_set_bit(ar9271->htc_device, AR9271_CARRIER_LEAK_CONTROL, 522 514 AR9271_CARRIER_LEAK_CALIB); 523 515 wmi_reg_clear_bit(ar9271->htc_device, AR9271_ADC_CONTROL, 524 516 AR9271_ADC_CONTROL_OFF_PWDADC); 525 517 wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 526 518 AR9271_AGC_CONTROL_TX_CALIB); 527 519 wmi_reg_set_bit(ar9271->htc_device, AR9271_PHY_TPCRG1, 528 520 AR9271_PHY_TPCRG1_PD_CALIB); 529 521 wmi_reg_set_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 530 531 532 int rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL, 533 534 if (rc != EOK) {522 AR9271_AGC_CONTROL_CALIB); 523 524 int rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL, 525 AR9271_AGC_CONTROL_CALIB, 0); 526 if (rc != EOK) { 535 527 usb_log_error("Failed to wait on calibrate completion.\n"); 536 528 return rc; … … 538 530 539 531 wmi_reg_set_bit(ar9271->htc_device, AR9271_ADC_CONTROL, 540 532 AR9271_ADC_CONTROL_OFF_PWDADC); 541 533 wmi_reg_clear_bit(ar9271->htc_device, AR9271_CARRIER_LEAK_CONTROL, 542 534 AR9271_CARRIER_LEAK_CALIB); 543 535 wmi_reg_clear_bit(ar9271->htc_device, AR9271_AGC_CONTROL, 544 545 546 return EOK; 547 } 548 549 int hw_reset(ar9271_t *ar9271) 536 AR9271_AGC_CONTROL_TX_CALIB); 537 538 return EOK; 539 } 540 541 int hw_reset(ar9271_t *ar9271) 550 542 { 551 543 /* Set physical layer as deactivated. */ … … 553 545 554 546 if(ar9271->starting_up) { 555 wmi_reg_write(ar9271->htc_device, 556 557 558 547 wmi_reg_write(ar9271->htc_device, 548 AR9271_RESET_POWER_DOWN_CONTROL, 549 AR9271_RADIO_RF_RESET); 550 559 551 udelay(50); 560 552 } … … 563 555 uint32_t config_reg; 564 556 wmi_reg_read(ar9271->htc_device, AR9271_COMMAND, &config_reg); 565 if (config_reg & AR9271_COMMAND_RX_ENABLE) {557 if (config_reg & AR9271_COMMAND_RX_ENABLE) 566 558 hw_set_reset(ar9271, true); 567 }568 559 569 560 int rc = hw_init_pll(ar9271); 570 if (rc != EOK) {561 if (rc != EOK) { 571 562 usb_log_error("Failed to init PLL.\n"); 572 563 return rc; … … 575 566 udelay(500); 576 567 577 wmi_reg_write(ar9271->htc_device, AR9271_CLOCK_CONTROL, 578 568 wmi_reg_write(ar9271->htc_device, AR9271_CLOCK_CONTROL, 569 AR9271_MAX_CPU_CLOCK); 579 570 580 571 udelay(100); 581 572 582 if (ar9271->starting_up) {583 wmi_reg_write(ar9271->htc_device, 584 585 586 573 if (ar9271->starting_up) { 574 wmi_reg_write(ar9271->htc_device, 575 AR9271_RESET_POWER_DOWN_CONTROL, 576 AR9271_GATE_MAC_CONTROL); 577 587 578 udelay(50); 588 579 } … … 591 582 592 583 /* Set physical layer mode. */ 593 wmi_reg_write(ar9271->htc_device, AR9271_PHY_MODE, 594 584 wmi_reg_write(ar9271->htc_device, AR9271_PHY_MODE, 585 AR9271_PHY_MODE_DYNAMIC); 595 586 596 587 /* Reset device operating mode. */ 597 588 rc = hw_reset_operating_mode(ar9271); 598 if (rc != EOK) {589 if (rc != EOK) { 599 590 usb_log_error("Failed to reset operating mode.\n"); 600 591 return rc; … … 603 594 /* Set initial channel frequency. */ 604 595 rc = hw_set_freq(ar9271, IEEE80211_FIRST_FREQ); 605 if (rc != EOK) {596 if (rc != EOK) { 606 597 usb_log_error("Failed to set channel.\n"); 607 598 return rc; … … 609 600 610 601 /* Initialize transmission queues. */ 611 for(int i = 0; i < AR9271_QUEUES_COUNT; i++) { 612 wmi_reg_write(ar9271->htc_device, 613 AR9271_QUEUE_BASE_MASK + (i << 2), 614 1 << i); 602 for (unsigned int i = 0; i < AR9271_QUEUES_COUNT; i++) { 603 wmi_reg_write(ar9271->htc_device, 604 AR9271_QUEUE_BASE_MASK + (i << 2), 1 << i); 615 605 } 616 606 617 607 /* Activate physical layer. */ 618 608 rc = hw_activate_phy(ar9271); 619 if (rc != EOK) {609 if (rc != EOK) { 620 610 usb_log_error("Failed to activate physical layer.\n"); 621 611 return rc; … … 624 614 /* Calibration. */ 625 615 rc = hw_calibration(ar9271); 626 if (rc != EOK) {616 if (rc != EOK) { 627 617 usb_log_error("Failed to calibrate device.\n"); 628 618 return rc; … … 630 620 631 621 rc = hw_noise_floor_calibration(ar9271); 632 if (rc != EOK) {622 if (rc != EOK) { 633 623 usb_log_error("Failed to calibrate noise floor.\n"); 634 624 return rc; … … 641 631 } 642 632 643 /** 644 * Initialize hardware of AR9271 device. 645 * 633 /** Initialize hardware of AR9271 device. 634 * 646 635 * @param ar9271 Device structure. 647 * 636 * 648 637 * @return EOK if succeed, negative error code otherwise. 649 638 */ … … 651 640 { 652 641 int rc = hw_init_proc(ar9271); 653 if (rc != EOK) {642 if (rc != EOK) { 654 643 usb_log_error("Failed to HW reset device.\n"); 655 644 return rc; … … 657 646 658 647 rc = hw_init_led(ar9271); 659 if (rc != EOK) {648 if (rc != EOK) { 660 649 usb_log_error("Failed to HW init led.\n"); 661 650 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.