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