Changes in / [ef521d4:66b3e0b] in mainline
- Location:
- uspace/drv/bus/usb/ar9271
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ar9271/ar9271.c
ref521d4 r66b3e0b 267 267 assert(addr); 268 268 269 // TODO 269 fibril_mutex_lock(&ar9271->htc_device->rx_lock); 270 271 uint32_t *mac0_dest = (uint32_t *)(addr->address); 272 uint16_t *mac4_dest = (uint16_t *)(addr->address + 4); 273 274 void *ar9271_mac_addr = 0; 275 276 /* Read MAC address from the i/o (4byte + 2byte reads) */ 277 // TODO: Now just testing register address 278 /* 279 usb_log_info("Trying to get some testing register from device.\n"); 280 281 uint32_t result; 282 int rc = wmi_reg_read(ar9271->usb_device, 283 0x50040, 284 //AR9271_MAC_REG_OFFSET | AR9271_MAC_PCU_STA_ADDR_L32, 285 &result); 286 if(rc != EOK) { 287 usb_log_info("Failed to read registry value. Error: %d\n", rc); 288 return rc; 289 } 290 291 usb_log_info("Registry value: %x\n", result); 292 */ 293 294 fibril_mutex_unlock(&ar9271->htc_device->rx_lock); 270 295 } 271 296 … … 492 517 nic_t *nic = nic_get_from_ddf_dev(dev); 493 518 494 /* TODO: Report HW address here. */ 519 /* 520 nic_address_t addr; 521 ar9271_hw_get_addr(ar9271, &addr); 522 rc = nic_report_address(nic, &addr); 523 524 usb_log_info("Reported address.\n"); 525 */ 495 526 496 527 /* Create AR9271 function.*/ -
uspace/drv/bus/usb/ar9271/htc.c
ref521d4 r66b3e0b 50 50 static inline uint8_t wmi_service_to_download_pipe(wmi_services_t service_id) 51 51 { 52 return (service_id == WMI_CONTROL_SERVICE) ? 3 : 2; 52 switch(service_id) { 53 case WMI_CONTROL_SERVICE: 54 return 3; 55 default: 56 return 2; 57 } 53 58 } 54 59 … … 62 67 static inline uint8_t wmi_service_to_upload_pipe(wmi_services_t service_id) 63 68 { 64 return (service_id == WMI_CONTROL_SERVICE) ? 4 : 1; 69 switch(service_id) { 70 case WMI_CONTROL_SERVICE: 71 return 4; 72 default: 73 return 1; 74 } 65 75 } 66 76 … … 116 126 * @param response_endpoint_no HTC endpoint to be used for this service. 117 127 * 118 * @return EOK if succeed, EINVAL when failed to connect service, 119 * negative error code otherwise. 128 * @return EOK if succeed, negative error code otherwise. 120 129 */ 121 130 static int htc_connect_service(htc_device_t *htc_device, … … 143 152 htc_device->endpoints.ctrl_endpoint); 144 153 if(rc != EOK) { 145 free(buffer);146 154 usb_log_error("Failed to send HTC message. Error: %d\n", rc); 147 155 return rc; … … 156 164 rc = htc_read_message(htc_device, buffer, buffer_size, NULL); 157 165 if(rc != EOK) { 158 free(buffer);159 166 usb_log_error("Failed to receive HTC service connect response. " 160 167 "Error: %d\n", rc); … … 169 176 if(response_message->status == HTC_SERVICE_SUCCESS) { 170 177 *response_endpoint_no = response_message->endpoint_id; 171 r c =EOK;178 return EOK; 172 179 } else { 173 180 usb_log_error("Failed to connect HTC service. " 174 181 "Message status: %d\n", response_message->status); 175 r c = EINVAL;182 return rc; 176 183 } 177 178 free(buffer);179 180 return rc;181 184 } 182 185 … … 190 193 static int htc_config_credits(htc_device_t *htc_device) 191 194 { 192 size_t buffer_size = sizeof(htc_frame_header_t) + 193 sizeof(htc_config_msg_t); 195 size_t buffer_size = sizeof(htc_frame_header_t) + 50; 194 196 void *buffer = malloc(buffer_size); 195 197 htc_config_msg_t *config_message = (htc_config_msg_t *) … … 202 204 config_message->pipe_id = 1; 203 205 204 /* Send HTC message. */205 206 int rc = htc_send_message(htc_device, buffer, buffer_size, 206 207 htc_device->endpoints.ctrl_endpoint); 207 208 if(rc != EOK) { 208 free(buffer);209 209 usb_log_error("Failed to send HTC config message. " 210 210 "Error: %d\n", rc); … … 222 222 usb_log_error("Failed to receive HTC config response message. " 223 223 "Error: %d\n", rc); 224 } 225 226 free(buffer); 224 return rc; 225 } 227 226 228 227 return rc; … … 238 237 static int htc_complete_setup(htc_device_t *htc_device) 239 238 { 240 size_t buffer_size = sizeof(htc_frame_header_t) + 241 sizeof(htc_setup_complete_msg_t); 239 size_t buffer_size = sizeof(htc_frame_header_t) + 50; 242 240 void *buffer = malloc(buffer_size); 243 241 htc_setup_complete_msg_t *complete_message = … … 248 246 host2uint16_t_be(HTC_MESSAGE_SETUP_COMPLETE); 249 247 250 /* Send HTC message. */251 248 int rc = htc_send_message(htc_device, buffer, buffer_size, 252 249 htc_device->endpoints.ctrl_endpoint); … … 254 251 usb_log_error("Failed to send HTC setup complete message. " 255 252 "Error: %d\n", rc); 256 } 257 258 free(buffer); 253 return rc; 254 } 259 255 260 256 return rc; … … 267 263 * @param htc_device HTC device structure. 268 264 * 269 * @return EOK if succeed, EINVAL if response error, negative error code 270 * otherwise. 265 * @return EOK if succeed, negative error code otherwise. 271 266 */ 272 267 static int htc_check_ready(htc_device_t *htc_device) … … 275 270 void *buffer = malloc(buffer_size); 276 271 277 /* Read response from device. */278 272 int rc = htc_read_message(htc_device, buffer, buffer_size, NULL); 279 273 if(rc != EOK) { 280 free(buffer);281 274 usb_log_error("Failed to receive HTC check ready message. " 282 275 "Error: %d\n", rc); … … 287 280 sizeof(htc_frame_header_t)); 288 281 if(uint16_t_be2host(*message_id) == HTC_MESSAGE_READY) { 289 r c =EOK;282 return EOK; 290 283 } else { 291 rc = EINVAL; 292 } 293 294 free(buffer); 295 296 return rc; 284 return EINVAL; 285 } 297 286 } 298 287 -
uspace/drv/bus/usb/ar9271/hw.c
ref521d4 r66b3e0b 128 128 } 129 129 130 /* TODO: Finish HW init. */131 132 130 return EOK; 133 131 } -
uspace/drv/bus/usb/ar9271/wmi.c
ref521d4 r66b3e0b 163 163 host2uint16_t_be(++htc_device->sequence_number); 164 164 165 /* Send message. */166 165 int rc = htc_send_message(htc_device, buffer, buffer_size, 167 166 htc_device->endpoints.wmi_endpoint); 168 167 if(rc != EOK) { 169 free(buffer);170 168 usb_log_error("Failed to send WMI message. Error: %d\n", rc); 171 return rc;172 169 } 173 170 … … 177 174 buffer = malloc(buffer_size); 178 175 179 /* Read response. */180 176 rc = htc_read_message(htc_device, buffer, buffer_size, NULL); 181 177 if(rc != EOK) {
Note:
See TracChangeset
for help on using the changeset viewer.