Changeset 5a6cc679 in mainline for uspace/drv/nic/ar9271
- Timestamp:
- 2018-01-31T02:21:24Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0a9cc2
- Parents:
- 132ab5d1
- Location:
- uspace/drv/nic/ar9271
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/ar9271/ar9271.c
r132ab5d1 r5a6cc679 99 99 100 100 /* Callback when new device is to be controlled by this driver. */ 101 static int ar9271_add_device(ddf_dev_t *);101 static errno_t ar9271_add_device(ddf_dev_t *); 102 102 103 103 /* IEEE 802.11 callbacks */ 104 static int ar9271_ieee80211_start(ieee80211_dev_t *);105 static int ar9271_ieee80211_tx_handler(ieee80211_dev_t *, void *, size_t);106 static int ar9271_ieee80211_set_freq(ieee80211_dev_t *, uint16_t);107 static int ar9271_ieee80211_bssid_change(ieee80211_dev_t *, bool);108 static int ar9271_ieee80211_key_config(ieee80211_dev_t *, ieee80211_key_config_t *,104 static errno_t ar9271_ieee80211_start(ieee80211_dev_t *); 105 static errno_t ar9271_ieee80211_tx_handler(ieee80211_dev_t *, void *, size_t); 106 static errno_t ar9271_ieee80211_set_freq(ieee80211_dev_t *, uint16_t); 107 static errno_t ar9271_ieee80211_bssid_change(ieee80211_dev_t *, bool); 108 static errno_t ar9271_ieee80211_key_config(ieee80211_dev_t *, ieee80211_key_config_t *, 109 109 bool); 110 110 … … 128 128 static ieee80211_iface_t ar9271_ieee80211_iface; 129 129 130 static int ar9271_get_device_info(ddf_fun_t *, nic_device_info_t *);131 static int ar9271_get_cable_state(ddf_fun_t *, nic_cable_state_t *);132 static int ar9271_get_operation_mode(ddf_fun_t *, int *, nic_channel_mode_t *,130 static errno_t ar9271_get_device_info(ddf_fun_t *, nic_device_info_t *); 131 static errno_t ar9271_get_cable_state(ddf_fun_t *, nic_cable_state_t *); 132 static errno_t ar9271_get_operation_mode(ddf_fun_t *, int *, nic_channel_mode_t *, 133 133 nic_role_t *); 134 134 … … 144 144 * 145 145 */ 146 static int ar9271_get_device_info(ddf_fun_t *dev, nic_device_info_t *info)146 static errno_t ar9271_get_device_info(ddf_fun_t *dev, nic_device_info_t *info) 147 147 { 148 148 assert(dev); … … 164 164 * 165 165 */ 166 static int ar9271_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)166 static errno_t ar9271_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state) 167 167 { 168 168 *state = NIC_CS_PLUGGED; … … 174 174 * 175 175 */ 176 static int ar9271_get_operation_mode(ddf_fun_t *fun, int *speed,176 static errno_t ar9271_get_operation_mode(ddf_fun_t *fun, int *speed, 177 177 nic_channel_mode_t *duplex, nic_role_t *role) 178 178 { … … 187 187 * 188 188 */ 189 static int ar9271_on_multicast_mode_change(nic_t *nic,189 static errno_t ar9271_on_multicast_mode_change(nic_t *nic, 190 190 nic_multicast_mode_t mode, const nic_address_t *addr, size_t addr_cnt) 191 191 { … … 210 210 * 211 211 */ 212 static int ar9271_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode,212 static errno_t ar9271_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode, 213 213 const nic_address_t *addr, size_t addr_cnt) 214 214 { … … 236 236 * 237 237 */ 238 static int ar9271_on_broadcast_mode_change(nic_t *nic,238 static errno_t ar9271_on_broadcast_mode_change(nic_t *nic, 239 239 nic_broadcast_mode_t mode) 240 240 { … … 258 258 } 259 259 260 static int ar9271_data_polling(void *arg)260 static errno_t ar9271_data_polling(void *arg) 261 261 { 262 262 assert(arg); … … 319 319 * 320 320 */ 321 static int ar9271_ieee80211_set_freq(ieee80211_dev_t *ieee80211_dev,321 static errno_t ar9271_ieee80211_set_freq(ieee80211_dev_t *ieee80211_dev, 322 322 uint16_t freq) 323 323 { … … 330 330 wmi_send_command(ar9271->htc_device, WMI_STOP_RECV, NULL, 0, NULL); 331 331 332 int rc = hw_freq_switch(ar9271, freq);332 errno_t rc = hw_freq_switch(ar9271, freq); 333 333 if (rc != EOK) { 334 334 usb_log_error("Failed to HW switch frequency.\n"); … … 352 352 } 353 353 354 static int ar9271_ieee80211_bssid_change(ieee80211_dev_t *ieee80211_dev,354 static errno_t ar9271_ieee80211_bssid_change(ieee80211_dev_t *ieee80211_dev, 355 355 bool connected) 356 356 { … … 401 401 } 402 402 403 static int ar9271_ieee80211_key_config(ieee80211_dev_t *ieee80211_dev,403 static errno_t ar9271_ieee80211_key_config(ieee80211_dev_t *ieee80211_dev, 404 404 ieee80211_key_config_t *key_conf, bool insert) 405 405 { … … 519 519 } 520 520 521 static int ar9271_ieee80211_tx_handler(ieee80211_dev_t *ieee80211_dev,521 static errno_t ar9271_ieee80211_tx_handler(ieee80211_dev_t *ieee80211_dev, 522 522 void *buffer, size_t buffer_size) 523 523 { … … 608 608 } 609 609 610 static int ar9271_ieee80211_start(ieee80211_dev_t *ieee80211_dev)610 static errno_t ar9271_ieee80211_start(ieee80211_dev_t *ieee80211_dev) 611 611 { 612 612 assert(ieee80211_dev); … … 616 616 wmi_send_command(ar9271->htc_device, WMI_FLUSH_RECV, NULL, 0, NULL); 617 617 618 int rc = hw_reset(ar9271);618 errno_t rc = hw_reset(ar9271); 619 619 if (rc != EOK) { 620 620 usb_log_error("Failed to do HW reset.\n"); … … 666 666 } 667 667 668 static int ar9271_init(ar9271_t *ar9271, usb_device_t *usb_device, const usb_endpoint_description_t **endpoints)668 static errno_t ar9271_init(ar9271_t *ar9271, usb_device_t *usb_device, const usb_endpoint_description_t **endpoints) 669 669 { 670 670 ar9271->starting_up = true; … … 680 680 } 681 681 682 int rc = ath_usb_init(ar9271->ath_device, usb_device, endpoints);682 errno_t rc = ath_usb_init(ar9271->ath_device, usb_device, endpoints); 683 683 if (rc != EOK) { 684 684 free(ar9271->ath_device); … … 737 737 * 738 738 */ 739 static int ar9271_upload_fw(ar9271_t *ar9271)739 static errno_t ar9271_upload_fw(ar9271_t *ar9271) 740 740 { 741 741 usb_device_t *usb_device = ar9271->usb_device; … … 775 775 memcpy(buffer, current_data, chunk_size); 776 776 usb_pipe_t *ctrl_pipe = usb_device_get_default_pipe(usb_device); 777 int rc = usb_control_request_set(ctrl_pipe,777 errno_t rc = usb_control_request_set(ctrl_pipe, 778 778 USB_REQUEST_TYPE_VENDOR, 779 779 USB_REQUEST_RECIPIENT_DEVICE, … … 803 803 */ 804 804 usb_pipe_t *ctrl_pipe = usb_device_get_default_pipe(usb_device); 805 int rc = usb_control_request_set(ctrl_pipe,805 errno_t rc = usb_control_request_set(ctrl_pipe, 806 806 USB_REQUEST_TYPE_VENDOR, 807 807 USB_REQUEST_RECIPIENT_DEVICE, … … 834 834 /* USB framework initialization. */ 835 835 const char *err_msg = NULL; 836 int rc = usb_device_create_ddf(dev, endpoints, &err_msg);836 errno_t rc = usb_device_create_ddf(dev, endpoints, &err_msg); 837 837 if (rc != EOK) { 838 838 usb_log_error("Failed to create USB device: %s, " … … 879 879 * @return EOK if succeed, error code otherwise 880 880 */ 881 static int ar9271_add_device(ddf_dev_t *dev)881 static errno_t ar9271_add_device(ddf_dev_t *dev) 882 882 { 883 883 assert(dev); … … 896 896 897 897 /* Initialize AR9271 HTC services. */ 898 int rc = htc_init(ar9271->htc_device);898 errno_t rc = htc_init(ar9271->htc_device); 899 899 if (rc != EOK) { 900 900 ar9271_delete_dev_data(ar9271); -
uspace/drv/nic/ar9271/ath.h
r132ab5d1 r5a6cc679 40 40 /** Atheros wifi operations. */ 41 41 typedef struct { 42 int (*send_ctrl_message)(struct ath *, void *, size_t);43 int (*read_ctrl_message)(struct ath *, void *, size_t, size_t *);44 int (*send_data_message)(struct ath *, void *, size_t);45 int (*read_data_message)(struct ath *, void *, size_t, size_t *);42 errno_t (*send_ctrl_message)(struct ath *, void *, size_t); 43 errno_t (*read_ctrl_message)(struct ath *, void *, size_t, size_t *); 44 errno_t (*send_data_message)(struct ath *, void *, size_t); 45 errno_t (*read_data_message)(struct ath *, void *, size_t, size_t *); 46 46 } ath_ops_t; 47 47 -
uspace/drv/nic/ar9271/ath_usb.c
r132ab5d1 r5a6cc679 39 39 #include "ath_usb.h" 40 40 41 static int ath_usb_send_ctrl_message(ath_t *, void *, size_t);42 static int ath_usb_read_ctrl_message(ath_t *, void *, size_t, size_t *);43 static int ath_usb_send_data_message(ath_t *, void *, size_t);44 static int ath_usb_read_data_message(ath_t *, void *, size_t, size_t *);41 static errno_t ath_usb_send_ctrl_message(ath_t *, void *, size_t); 42 static errno_t ath_usb_read_ctrl_message(ath_t *, void *, size_t, size_t *); 43 static errno_t ath_usb_send_data_message(ath_t *, void *, size_t); 44 static errno_t ath_usb_read_data_message(ath_t *, void *, size_t, size_t *); 45 45 46 46 static ath_ops_t ath_usb_ops = { … … 59 59 * 60 60 */ 61 int ath_usb_init(ath_t *ath, usb_device_t *usb_device, const usb_endpoint_description_t **endpoints)61 errno_t ath_usb_init(ath_t *ath, usb_device_t *usb_device, const usb_endpoint_description_t **endpoints) 62 62 { 63 63 ath_usb_t *ath_usb = malloc(sizeof(ath_usb_t)); … … 110 110 * 111 111 */ 112 static int ath_usb_send_ctrl_message(ath_t *ath, void *buffer,112 static errno_t ath_usb_send_ctrl_message(ath_t *ath, void *buffer, 113 113 size_t buffer_size) 114 114 { … … 127 127 * 128 128 */ 129 static int ath_usb_read_ctrl_message(ath_t *ath, void *buffer,129 static errno_t ath_usb_read_ctrl_message(ath_t *ath, void *buffer, 130 130 size_t buffer_size, size_t *transferred_size) 131 131 { … … 143 143 * 144 144 */ 145 static int ath_usb_send_data_message(ath_t *ath, void *buffer,145 static errno_t ath_usb_send_data_message(ath_t *ath, void *buffer, 146 146 size_t buffer_size) 147 147 { … … 158 158 159 159 ath_usb_t *ath_usb = (ath_usb_t *) ath->specific_data; 160 int ret_val = usb_pipe_write(ath_usb->output_data_pipe, complete_buffer,161 complete_buffer _size);160 const errno_t ret_val = usb_pipe_write(ath_usb->output_data_pipe, 161 complete_buffer, complete_buffer_size); 162 162 163 163 free(complete_buffer); … … 176 176 * 177 177 */ 178 static int ath_usb_read_data_message(ath_t *ath, void *buffer,178 static errno_t ath_usb_read_data_message(ath_t *ath, void *buffer, 179 179 size_t buffer_size, size_t *transferred_size) 180 180 { -
uspace/drv/nic/ar9271/ath_usb.h
r132ab5d1 r5a6cc679 59 59 } ath_usb_data_header_t; 60 60 61 extern int ath_usb_init(ath_t *, usb_device_t *, const usb_endpoint_description_t **endpoints);61 extern errno_t ath_usb_init(ath_t *, usb_device_t *, const usb_endpoint_description_t **endpoints); 62 62 63 63 #endif /* ATHEROS_ATH_USB_H */ -
uspace/drv/nic/ar9271/htc.c
r132ab5d1 r5a6cc679 66 66 } 67 67 68 int htc_init_new_vif(htc_device_t *htc_device)68 errno_t htc_init_new_vif(htc_device_t *htc_device) 69 69 { 70 70 htc_vif_msg_t vif_msg; … … 153 153 * 154 154 */ 155 int htc_send_control_message(htc_device_t *htc_device, void *buffer,155 errno_t htc_send_control_message(htc_device_t *htc_device, void *buffer, 156 156 size_t buffer_size, uint8_t endpoint_id) 157 157 { … … 176 176 * 177 177 */ 178 int htc_send_data_message(htc_device_t *htc_device, void *buffer,178 errno_t htc_send_data_message(htc_device_t *htc_device, void *buffer, 179 179 size_t buffer_size, uint8_t endpoint_id) 180 180 { … … 199 199 * 200 200 */ 201 int htc_read_data_message(htc_device_t *htc_device, void *buffer,201 errno_t htc_read_data_message(htc_device_t *htc_device, void *buffer, 202 202 size_t buffer_size, size_t *transferred_size) 203 203 { … … 219 219 * 220 220 */ 221 int htc_read_control_message(htc_device_t *htc_device, void *buffer,221 errno_t htc_read_control_message(htc_device_t *htc_device, void *buffer, 222 222 size_t buffer_size, size_t *transferred_size) 223 223 { … … 239 239 * 240 240 */ 241 static int htc_connect_service(htc_device_t *htc_device,241 static errno_t htc_connect_service(htc_device_t *htc_device, 242 242 wmi_services_t service_id, int *response_endpoint_no) 243 243 { … … 261 261 262 262 /* Send HTC message. */ 263 int rc = htc_send_control_message(htc_device, buffer, buffer_size,263 errno_t rc = htc_send_control_message(htc_device, buffer, buffer_size, 264 264 htc_device->endpoints.ctrl_endpoint); 265 265 if (rc != EOK) { … … 312 312 * 313 313 */ 314 static int htc_config_credits(htc_device_t *htc_device)314 static errno_t htc_config_credits(htc_device_t *htc_device) 315 315 { 316 316 size_t buffer_size = sizeof(htc_frame_header_t) + … … 327 327 328 328 /* Send HTC message. */ 329 int rc = htc_send_control_message(htc_device, buffer, buffer_size,329 errno_t rc = htc_send_control_message(htc_device, buffer, buffer_size, 330 330 htc_device->endpoints.ctrl_endpoint); 331 331 if (rc != EOK) { … … 360 360 * 361 361 */ 362 static int htc_complete_setup(htc_device_t *htc_device)362 static errno_t htc_complete_setup(htc_device_t *htc_device) 363 363 { 364 364 size_t buffer_size = sizeof(htc_frame_header_t) + … … 373 373 374 374 /* Send HTC message. */ 375 int rc = htc_send_control_message(htc_device, buffer, buffer_size,375 errno_t rc = htc_send_control_message(htc_device, buffer, buffer_size, 376 376 htc_device->endpoints.ctrl_endpoint); 377 377 if (rc != EOK) … … 394 394 * 395 395 */ 396 static int htc_check_ready(htc_device_t *htc_device)396 static errno_t htc_check_ready(htc_device_t *htc_device) 397 397 { 398 398 size_t buffer_size = htc_device->ath_device->ctrl_response_length; … … 400 400 401 401 /* Read response from device. */ 402 int rc = htc_read_control_message(htc_device, buffer, buffer_size,402 errno_t rc = htc_read_control_message(htc_device, buffer, buffer_size, 403 403 NULL); 404 404 if (rc != EOK) { … … 430 430 * 431 431 */ 432 int htc_device_init(ath_t *ath_device, ieee80211_dev_t *ieee80211_dev,432 errno_t htc_device_init(ath_t *ath_device, ieee80211_dev_t *ieee80211_dev, 433 433 htc_device_t *htc_device) 434 434 { … … 451 451 * 452 452 */ 453 int htc_init(htc_device_t *htc_device)453 errno_t htc_init(htc_device_t *htc_device) 454 454 { 455 455 /* First check ready message in device. */ 456 int rc = htc_check_ready(htc_device);456 errno_t rc = htc_check_ready(htc_device); 457 457 if (rc != EOK) { 458 458 usb_log_error("Device is not in ready state after loading " -
uspace/drv/nic/ar9271/htc.h
r132ab5d1 r5a6cc679 297 297 } __attribute__((packed)) htc_setup_complete_msg_t; 298 298 299 extern int htc_device_init(ath_t *, ieee80211_dev_t *, htc_device_t *);300 extern int htc_init(htc_device_t *);301 extern int htc_init_new_vif(htc_device_t *);302 extern int htc_read_control_message(htc_device_t *, void *, size_t, size_t *);303 extern int htc_read_data_message(htc_device_t *, void *, size_t, size_t *);304 extern int htc_send_control_message(htc_device_t *, void *, size_t, uint8_t);305 extern int htc_send_data_message(htc_device_t *, void *, size_t, uint8_t);299 extern errno_t htc_device_init(ath_t *, ieee80211_dev_t *, htc_device_t *); 300 extern errno_t htc_init(htc_device_t *); 301 extern errno_t htc_init_new_vif(htc_device_t *); 302 extern errno_t htc_read_control_message(htc_device_t *, void *, size_t, size_t *); 303 extern errno_t htc_read_data_message(htc_device_t *, void *, size_t, size_t *); 304 extern errno_t htc_send_control_message(htc_device_t *, void *, size_t, uint8_t); 305 extern errno_t htc_send_data_message(htc_device_t *, void *, size_t, uint8_t); 306 306 307 307 #endif /* ATHEROS_HTC_H */ -
uspace/drv/nic/ar9271/hw.c
r132ab5d1 r5a6cc679 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"); -
uspace/drv/nic/ar9271/hw.h
r132ab5d1 r5a6cc679 41 41 #define HW_WAIT_TIME_US 10 42 42 43 extern int hw_init(ar9271_t *);44 extern int hw_freq_switch(ar9271_t *, uint16_t);45 extern int hw_rx_init(ar9271_t *);46 extern int hw_reset(ar9271_t *);47 extern int hw_set_bssid(ar9271_t *);48 extern int hw_set_rx_filter(ar9271_t *, bool);43 extern errno_t hw_init(ar9271_t *); 44 extern errno_t hw_freq_switch(ar9271_t *, uint16_t); 45 extern errno_t hw_rx_init(ar9271_t *); 46 extern errno_t hw_reset(ar9271_t *); 47 extern errno_t hw_set_bssid(ar9271_t *); 48 extern errno_t hw_set_rx_filter(ar9271_t *, bool); 49 49 50 50 #endif /* ATHEROS_HW_H */ -
uspace/drv/nic/ar9271/wmi.c
r132ab5d1 r5a6cc679 50 50 * 51 51 */ 52 int wmi_reg_read(htc_device_t *htc_device, uint32_t reg_offset, uint32_t *res)52 errno_t wmi_reg_read(htc_device_t *htc_device, uint32_t reg_offset, uint32_t *res) 53 53 { 54 54 uint32_t cmd_value = host2uint32_t_be(reg_offset); … … 57 57 malloc(htc_device->ath_device->ctrl_response_length); 58 58 59 int rc = wmi_send_command(htc_device, WMI_REG_READ,59 errno_t rc = wmi_send_command(htc_device, WMI_REG_READ, 60 60 (uint8_t *) &cmd_value, sizeof(cmd_value), resp_buffer); 61 61 … … 82 82 * 83 83 */ 84 int wmi_reg_write(htc_device_t *htc_device, uint32_t reg_offset, uint32_t val)84 errno_t wmi_reg_write(htc_device_t *htc_device, uint32_t reg_offset, uint32_t val) 85 85 { 86 86 uint32_t cmd_buffer[] = { … … 92 92 malloc(htc_device->ath_device->ctrl_response_length); 93 93 94 int rc = wmi_send_command(htc_device, WMI_REG_WRITE,94 errno_t rc = wmi_send_command(htc_device, WMI_REG_WRITE, 95 95 (uint8_t *) &cmd_buffer, sizeof(cmd_buffer), resp_buffer); 96 96 … … 115 115 * 116 116 */ 117 int wmi_reg_set_clear_bit(htc_device_t *htc_device, uint32_t reg_offset,117 errno_t wmi_reg_set_clear_bit(htc_device_t *htc_device, uint32_t reg_offset, 118 118 uint32_t set_bit, uint32_t clear_bit) 119 119 { 120 120 uint32_t value; 121 121 122 int rc = wmi_reg_read(htc_device, reg_offset, &value);122 errno_t rc = wmi_reg_read(htc_device, reg_offset, &value); 123 123 if (rc != EOK) { 124 124 usb_log_error("Failed to read registry value in RMW " … … 149 149 * 150 150 */ 151 int wmi_reg_set_bit(htc_device_t *htc_device, uint32_t reg_offset,151 errno_t wmi_reg_set_bit(htc_device_t *htc_device, uint32_t reg_offset, 152 152 uint32_t set_bit) 153 153 { … … 164 164 * 165 165 */ 166 int wmi_reg_clear_bit(htc_device_t *htc_device, uint32_t reg_offset,166 errno_t wmi_reg_clear_bit(htc_device_t *htc_device, uint32_t reg_offset, 167 167 uint32_t clear_bit) 168 168 { … … 179 179 * 180 180 */ 181 int wmi_reg_buffer_write(htc_device_t *htc_device, wmi_reg_t *reg_buffer,181 errno_t wmi_reg_buffer_write(htc_device_t *htc_device, wmi_reg_t *reg_buffer, 182 182 size_t elements) 183 183 { … … 198 198 } 199 199 200 int rc = wmi_send_command(htc_device, WMI_REG_WRITE,200 errno_t rc = wmi_send_command(htc_device, WMI_REG_WRITE, 201 201 (uint8_t *) buffer, buffer_size, resp_buffer); 202 202 … … 223 223 * 224 224 */ 225 int wmi_send_command(htc_device_t *htc_device, wmi_command_t command_id,225 errno_t wmi_send_command(htc_device_t *htc_device, wmi_command_t command_id, 226 226 uint8_t *command_buffer, uint32_t command_length, void *response_buffer) 227 227 { … … 242 242 243 243 /* Send message. */ 244 int rc = htc_send_control_message(htc_device, buffer, buffer_size,244 errno_t rc = htc_send_control_message(htc_device, buffer, buffer_size, 245 245 htc_device->endpoints.wmi_endpoint); 246 246 if (rc != EOK) { -
uspace/drv/nic/ar9271/wmi.h
r132ab5d1 r5a6cc679 117 117 } wmi_reg_t; 118 118 119 extern int wmi_reg_read(htc_device_t *, uint32_t, uint32_t *);120 extern int wmi_reg_write(htc_device_t *, uint32_t, uint32_t);121 extern int wmi_reg_set_clear_bit(htc_device_t *, uint32_t, uint32_t, uint32_t);122 extern int wmi_reg_set_bit(htc_device_t *, uint32_t, uint32_t);123 extern int wmi_reg_clear_bit(htc_device_t *, uint32_t, uint32_t);124 extern int wmi_reg_buffer_write(htc_device_t *, wmi_reg_t *, size_t);125 extern int wmi_send_command(htc_device_t *, wmi_command_t, uint8_t *, uint32_t,119 extern errno_t wmi_reg_read(htc_device_t *, uint32_t, uint32_t *); 120 extern errno_t wmi_reg_write(htc_device_t *, uint32_t, uint32_t); 121 extern errno_t wmi_reg_set_clear_bit(htc_device_t *, uint32_t, uint32_t, uint32_t); 122 extern errno_t wmi_reg_set_bit(htc_device_t *, uint32_t, uint32_t); 123 extern errno_t wmi_reg_clear_bit(htc_device_t *, uint32_t, uint32_t); 124 extern errno_t wmi_reg_buffer_write(htc_device_t *, wmi_reg_t *, size_t); 125 extern errno_t wmi_send_command(htc_device_t *, wmi_command_t, uint8_t *, uint32_t, 126 126 void *); 127 127
Note:
See TracChangeset
for help on using the changeset viewer.