Changeset b7fd2a0 in mainline for uspace/drv/nic/ar9271/hw.c
- Timestamp:
- 2018-01-13T03:10:29Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a53ed3a
- Parents:
- 36f0738
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/ar9271/hw.c
r36f0738 rb7fd2a0 52 52 * 53 53 */ 54 static int hw_read_wait(ar9271_t *ar9271, uint32_t offset, uint32_t mask,54 static errno_t hw_read_wait(ar9271_t *ar9271, uint32_t offset, uint32_t mask, 55 55 uint32_t value) 56 56 { … … 67 67 } 68 68 69 static int hw_reset_power_on(ar9271_t *ar9271)69 static errno_t hw_reset_power_on(ar9271_t *ar9271) 70 70 { 71 71 wmi_reg_t buffer[] = { … … 93 93 wmi_reg_write(ar9271->htc_device, AR9271_RTC_RESET, 1); 94 94 95 int rc = hw_read_wait(ar9271,95 errno_t rc = hw_read_wait(ar9271, 96 96 AR9271_RTC_STATUS, 97 97 AR9271_RTC_STATUS_MASK, … … 105 105 } 106 106 107 static int hw_set_reset(ar9271_t *ar9271, bool cold)107 static errno_t hw_set_reset(ar9271_t *ar9271, bool cold) 108 108 { 109 109 uint32_t reset_value = AR9271_RTC_RC_MAC_WARM; … … 135 135 wmi_reg_write(ar9271->htc_device, AR9271_RTC_RC, 0); 136 136 137 int rc = hw_read_wait(ar9271, AR9271_RTC_RC, AR9271_RTC_RC_MASK, 0);137 errno_t rc = hw_read_wait(ar9271, AR9271_RTC_RC, AR9271_RTC_RC_MASK, 0); 138 138 if (rc != EOK) { 139 139 usb_log_error("Failed to wait for RTC RC register.\n"); … … 148 148 } 149 149 150 static int hw_addr_init(ar9271_t *ar9271)150 static errno_t hw_addr_init(ar9271_t *ar9271) 151 151 { 152 152 uint32_t value; … … 164 164 nic_t *nic = nic_get_from_ddf_dev(ar9271->ddf_dev); 165 165 166 int rc = nic_report_address(nic, &ar9271_address);166 errno_t rc = nic_report_address(nic, &ar9271_address); 167 167 if (rc != EOK) { 168 168 usb_log_error("Failed to report NIC HW address.\n"); … … 173 173 } 174 174 175 static int hw_gpio_set_output(ar9271_t *ar9271, uint32_t gpio, uint32_t type)175 static errno_t hw_gpio_set_output(ar9271_t *ar9271, uint32_t gpio, uint32_t type) 176 176 { 177 177 uint32_t address; … … 204 204 } 205 205 206 static int hw_gpio_set_value(ar9271_t *ar9271, uint32_t gpio, uint32_t value)206 static errno_t hw_gpio_set_value(ar9271_t *ar9271, uint32_t gpio, uint32_t value) 207 207 { 208 208 wmi_reg_set_clear_bit(ar9271->htc_device, AR9271_GPIO_IN_OUT, … … 218 218 * 219 219 */ 220 static int hw_init_proc(ar9271_t *ar9271)221 { 222 int rc = hw_reset_power_on(ar9271);220 static errno_t hw_init_proc(ar9271_t *ar9271) 221 { 222 errno_t rc = hw_reset_power_on(ar9271); 223 223 if (rc != EOK) { 224 224 usb_log_error("Failed to HW reset power on.\n"); … … 241 241 } 242 242 243 static int hw_init_led(ar9271_t *ar9271)244 { 245 int rc = hw_gpio_set_output(ar9271, AR9271_LED_PIN,243 static errno_t hw_init_led(ar9271_t *ar9271) 244 { 245 errno_t rc = hw_gpio_set_output(ar9271, AR9271_LED_PIN, 246 246 AR9271_GPIO_OUT_MUX_AS_OUT); 247 247 if (rc != EOK) { … … 259 259 } 260 260 261 static int hw_activate_phy(ar9271_t *ar9271)261 static errno_t hw_activate_phy(ar9271_t *ar9271) 262 262 { 263 263 wmi_reg_write(ar9271->htc_device, AR9271_PHY_ACTIVE, 1); … … 267 267 } 268 268 269 static int hw_set_operating_mode(ar9271_t *ar9271,269 static errno_t hw_set_operating_mode(ar9271_t *ar9271, 270 270 ieee80211_operating_mode_t op_mode) 271 271 { … … 295 295 } 296 296 297 static int hw_reset_operating_mode(ar9271_t *ar9271)298 { 299 int rc = hw_set_operating_mode(ar9271, IEEE80211_OPMODE_STATION);297 static errno_t hw_reset_operating_mode(ar9271_t *ar9271) 298 { 299 errno_t rc = hw_set_operating_mode(ar9271, IEEE80211_OPMODE_STATION); 300 300 if (rc != EOK) { 301 301 usb_log_error("Failed to set opmode to station.\n"); … … 306 306 } 307 307 308 static int hw_noise_floor_calibration(ar9271_t *ar9271)308 static errno_t hw_noise_floor_calibration(ar9271_t *ar9271) 309 309 { 310 310 uint32_t value; … … 325 325 AR9271_AGC_CONTROL_NF_CALIB); 326 326 327 int rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL,327 errno_t rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL, 328 328 AR9271_AGC_CONTROL_NF_CALIB, 0); 329 329 if (rc != EOK) { … … 344 344 } 345 345 346 static int hw_set_freq(ar9271_t *ar9271, uint16_t freq)346 static errno_t hw_set_freq(ar9271_t *ar9271, uint16_t freq) 347 347 { 348 348 /* Not supported channel frequency. */ … … 373 373 } 374 374 375 int hw_freq_switch(ar9271_t *ar9271, uint16_t freq)375 errno_t hw_freq_switch(ar9271_t *ar9271, uint16_t freq) 376 376 { 377 377 wmi_reg_write(ar9271->htc_device, AR9271_PHY_RFBUS_KILL, 0x1); 378 378 379 int rc = hw_read_wait(ar9271, AR9271_PHY_RFBUS_GRANT, 0x1, 0x1);379 errno_t rc = hw_read_wait(ar9271, AR9271_PHY_RFBUS_GRANT, 0x1, 0x1); 380 380 if (rc != EOK) { 381 381 usb_log_error("Failed to kill RF bus.\n"); … … 407 407 } 408 408 409 int hw_set_rx_filter(ar9271_t *ar9271, bool assoc)409 errno_t hw_set_rx_filter(ar9271_t *ar9271, bool assoc) 410 410 { 411 411 uint32_t additional_bits = 0; … … 425 425 } 426 426 427 int hw_set_bssid(ar9271_t *ar9271)427 errno_t hw_set_bssid(ar9271_t *ar9271) 428 428 { 429 429 ieee80211_dev_t *ieee80211_dev = ar9271->ieee80211_dev; … … 445 445 } 446 446 447 int hw_rx_init(ar9271_t *ar9271)447 errno_t hw_rx_init(ar9271_t *ar9271) 448 448 { 449 449 wmi_reg_write(ar9271->htc_device, AR9271_COMMAND, 450 450 AR9271_COMMAND_RX_ENABLE); 451 451 452 int rc = hw_set_rx_filter(ar9271, false);452 errno_t rc = hw_set_rx_filter(ar9271, false); 453 453 if (rc != EOK) { 454 454 usb_log_error("Failed to set RX filtering.\n"); … … 465 465 } 466 466 467 static int hw_init_pll(ar9271_t *ar9271)467 static errno_t hw_init_pll(ar9271_t *ar9271) 468 468 { 469 469 /* Some magic here (set for 2GHz channels). But VERY important :-) */ … … 510 510 } 511 511 512 static int hw_calibration(ar9271_t *ar9271)512 static errno_t hw_calibration(ar9271_t *ar9271) 513 513 { 514 514 wmi_reg_set_bit(ar9271->htc_device, AR9271_CARRIER_LEAK_CONTROL, … … 523 523 AR9271_AGC_CONTROL_CALIB); 524 524 525 int rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL,525 errno_t rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL, 526 526 AR9271_AGC_CONTROL_CALIB, 0); 527 527 if (rc != EOK) { … … 540 540 } 541 541 542 int hw_reset(ar9271_t *ar9271)542 errno_t hw_reset(ar9271_t *ar9271) 543 543 { 544 544 /* Set physical layer as deactivated. */ … … 559 559 hw_set_reset(ar9271, true); 560 560 561 int rc = hw_init_pll(ar9271);561 errno_t rc = hw_init_pll(ar9271); 562 562 if (rc != EOK) { 563 563 usb_log_error("Failed to init PLL.\n"); … … 638 638 * @return EOK if succeed, error code otherwise. 639 639 */ 640 int hw_init(ar9271_t *ar9271)641 { 642 int rc = hw_init_proc(ar9271);640 errno_t hw_init(ar9271_t *ar9271) 641 { 642 errno_t rc = hw_init_proc(ar9271); 643 643 if (rc != EOK) { 644 644 usb_log_error("Failed to HW reset device.\n");
Note:
See TracChangeset
for help on using the changeset viewer.