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