Changes in uspace/drv/bus/usb/ehci/res.c [7de1988c:cffa14e6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ehci/res.c
r7de1988c rcffa14e6 71 71 * 72 72 * @param[in] dev Device asking for the addresses. 73 * @param[out] mem_regs_p Pointer to the register range. 73 * @param[out] mem_reg_address Base address of the memory range. 74 * @param[out] mem_reg_size Size of the memory range. 74 75 * @param[out] irq_no IRQ assigned to the device. 75 76 * @return Error code. 76 77 */ 77 78 int get_my_registers(ddf_dev_t *dev, 78 addr_range_t *mem_regs_p, int *irq_no)79 uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no) 79 80 { 80 81 assert(dev); … … 98 99 } 99 100 100 if (mem_regs_p) 101 *mem_regs_p = hw_res.mem_ranges.ranges[0]; 101 if (mem_reg_address) 102 *mem_reg_address = hw_res.mem_ranges.ranges[0].address; 103 if (mem_reg_size) 104 *mem_reg_size = hw_res.mem_ranges.ranges[0].size; 102 105 if (irq_no) 103 106 *irq_no = hw_res.irqs.irqs[0]; … … 142 145 return ENOMEM; 143 146 147 #define CHECK_RET_HANGUP_RETURN(ret, message...) \ 148 if (ret != EOK) { \ 149 usb_log_error(message); \ 150 async_hangup(parent_sess); \ 151 return ret; \ 152 } else (void)0 153 144 154 /* Read the first EEC. i.e. Legacy Support register */ 145 155 uint32_t usblegsup; 146 int r c= pci_config_space_read_32(parent_sess,156 int ret = pci_config_space_read_32(parent_sess, 147 157 eecp + USBLEGSUP_OFFSET, &usblegsup); 148 if (rc != EOK) { 149 usb_log_error("Failed to read USBLEGSUP: %s.\n", 150 str_error(rc)); 151 goto error; 152 } 153 158 CHECK_RET_HANGUP_RETURN(ret, 159 "Failed to read USBLEGSUP: %s.\n", str_error(ret)); 154 160 usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup); 155 161 … … 157 163 * byte. (OS Control semaphore)*/ 158 164 usb_log_debug("Requesting OS control.\n"); 159 r c= pci_config_space_write_8(parent_sess,165 ret = pci_config_space_write_8(parent_sess, 160 166 eecp + USBLEGSUP_OFFSET + 3, 1); 161 if (rc != EOK) { 162 usb_log_error("Failed to request OS EHCI control: %s.\n", 163 str_error(rc)); 164 goto error; 165 } 167 CHECK_RET_HANGUP_RETURN(ret, "Failed to request OS EHCI control: %s.\n", 168 str_error(ret)); 166 169 167 170 size_t wait = 0; 168 171 /* Wait for BIOS to release control. */ 169 r c= pci_config_space_read_32(172 ret = pci_config_space_read_32( 170 173 parent_sess, eecp + USBLEGSUP_OFFSET, &usblegsup); 171 if (rc != EOK) {172 usb_log_error("Failed reading PCI config space: %s.\n",173 str_error(rc));174 goto error;175 }176 177 174 while ((wait < DEFAULT_WAIT) && (usblegsup & USBLEGSUP_BIOS_CONTROL)) { 178 175 async_usleep(WAIT_STEP); 179 r c= pci_config_space_read_32(parent_sess,176 ret = pci_config_space_read_32(parent_sess, 180 177 eecp + USBLEGSUP_OFFSET, &usblegsup); 181 if (rc != EOK) {182 usb_log_error("Failed reading PCI config space: %s.\n",183 str_error(rc));184 goto error;185 }186 178 wait += WAIT_STEP; 187 179 } … … 196 188 usb_log_warning( "BIOS failed to release control after " 197 189 "%zu usecs, force it.\n", wait); 198 r c= pci_config_space_write_32(parent_sess,190 ret = pci_config_space_write_32(parent_sess, 199 191 eecp + USBLEGSUP_OFFSET, USBLEGSUP_OS_CONTROL); 200 if (rc != EOK) { 201 usb_log_error("Failed to force OS control: " 202 "%s.\n", str_error(rc)); 203 goto error; 204 } 205 192 CHECK_RET_HANGUP_RETURN(ret, "Failed to force OS control: " 193 "%s.\n", str_error(ret)); 206 194 /* 207 195 * Check capability type here, value of 01h identifies the capability … … 213 201 /* Read the second EEC Legacy Support and Control register */ 214 202 uint32_t usblegctlsts; 215 r c= pci_config_space_read_32(parent_sess,203 ret = pci_config_space_read_32(parent_sess, 216 204 eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts); 217 if (rc != EOK) { 218 usb_log_error("Failed to get USBLEGCTLSTS: %s.\n", 219 str_error(rc)); 220 goto error; 221 } 222 205 CHECK_RET_HANGUP_RETURN(ret, "Failed to get USBLEGCTLSTS: %s.\n", 206 str_error(ret)); 223 207 usb_log_debug("USBLEGCTLSTS: %" PRIx32 ".\n", usblegctlsts); 224 208 /* … … 227 211 * interfering. NOTE: Three upper bits are WC 228 212 */ 229 r c= pci_config_space_write_32(parent_sess,213 ret = pci_config_space_write_32(parent_sess, 230 214 eecp + USBLEGCTLSTS_OFFSET, 0xe0000000); 231 if (rc != EOK) { 232 usb_log_error("Failed(%d) zero USBLEGCTLSTS.\n", rc); 233 goto error; 234 } 235 215 CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) zero USBLEGCTLSTS.\n", ret); 236 216 udelay(10); 237 r c= pci_config_space_read_32(parent_sess,217 ret = pci_config_space_read_32(parent_sess, 238 218 eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts); 239 if (rc != EOK) { 240 usb_log_error("Failed to get USBLEGCTLSTS 2: %s.\n", 241 str_error(rc)); 242 goto error; 243 } 244 219 CHECK_RET_HANGUP_RETURN(ret, "Failed to get USBLEGCTLSTS 2: %s.\n", 220 str_error(ret)); 245 221 usb_log_debug("Zeroed USBLEGCTLSTS: %" PRIx32 ".\n", 246 222 usblegctlsts); … … 248 224 249 225 /* Read again Legacy Support register */ 250 r c= pci_config_space_read_32(parent_sess,226 ret = pci_config_space_read_32(parent_sess, 251 227 eecp + USBLEGSUP_OFFSET, &usblegsup); 252 if (rc != EOK) { 253 usb_log_error("Failed to read USBLEGSUP: %s.\n", 254 str_error(rc)); 255 goto error; 256 } 257 228 CHECK_RET_HANGUP_RETURN(ret, "Failed to read USBLEGSUP: %s.\n", 229 str_error(ret)); 258 230 usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup); 259 231 async_hangup(parent_sess); 260 232 return EOK; 261 error: 262 async_hangup(parent_sess); 263 return rc; 233 #undef CHECK_RET_HANGUP_RETURN 264 234 } 265 235 266 int disable_legacy(ddf_dev_t *device, addr_range_t *reg_range)236 int disable_legacy(ddf_dev_t *device, uintptr_t reg_base, size_t reg_size) 267 237 { 268 238 assert(device); 269 239 usb_log_debug("Disabling EHCI legacy support.\n"); 270 240 241 #define CHECK_RET_RETURN(ret, message...) \ 242 if (ret != EOK) { \ 243 usb_log_error(message); \ 244 return ret; \ 245 } else (void)0 246 271 247 /* Map EHCI registers */ 272 248 void *regs = NULL; 273 int rc = pio_enable_range(reg_range, ®s); 274 if (rc != EOK) { 275 usb_log_error("Failed to map registers %p: %s.\n", 276 RNGABSPTR(*reg_range), str_error(rc)); 277 return rc; 278 } 249 int ret = pio_enable((void*)reg_base, reg_size, ®s); 250 CHECK_RET_RETURN(ret, "Failed to map registers %p: %s.\n", 251 (void *) reg_base, str_error(ret)); 279 252 280 253 usb_log_debug2("Registers mapped at: %p.\n", regs); … … 290 263 usb_log_debug("Value of EECP: %x.\n", eecp); 291 264 292 rc = disable_extended_caps(device, eecp); 293 if (rc != EOK) { 294 usb_log_error("Failed to disable extended capabilities: %s.\n", 295 str_error(rc)); 296 return rc; 297 } 265 ret = disable_extended_caps(device, eecp); 266 CHECK_RET_RETURN(ret, "Failed to disable extended capabilities: %s.\n", 267 str_error(ret)); 268 269 #undef CHECK_RET_RETURN 298 270 299 271 /* … … 334 306 usbcmd, *usbcmd, usbsts, *usbsts, usbint, *usbint, usbconf,*usbconf); 335 307 336 return r c;308 return ret; 337 309 } 338 310
Note:
See TracChangeset
for help on using the changeset viewer.