source: mainline/uspace/drv/bus/usb/ehci/hc.c@ 36e8a0c8

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 36e8a0c8 was 129b821f, checked in by Ondřej Hlavatý <aearsis@…>, 8 years ago

usbhub: be aware of its own speed

This resulted in a bunch of changes just because the roothubs in older
HC's are virtual, and need to be aware of their own speed too.

  • Property mode set to 100644
File size: 15.6 KB
RevLine 
[6297465]1/*
2 * Copyright (c) 2011 Jan Vesely
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup drvusbehcihc
30 * @{
31 */
32/** @file
33 * @brief EHCI Host controller driver routines
34 */
35
36#include <assert.h>
37#include <async.h>
38#include <errno.h>
39#include <macros.h>
40#include <mem.h>
41#include <stdlib.h>
[8d2dd7f2]42#include <stdint.h>
[6297465]43#include <str_error.h>
44
45#include <usb/debug.h>
46#include <usb/usb.h>
[c6f82e5]47#include <usb/host/utility.h>
[6297465]48
[e9c5bd9]49#include "ehci_batch.h"
[6297465]50
51#include "hc.h"
52
53#define EHCI_USED_INTERRUPTS \
[bfff7fd]54 (USB_INTR_IRQ_FLAG | USB_INTR_ERR_IRQ_FLAG | USB_INTR_PORT_CHANGE_FLAG | \
55 USB_INTR_ASYNC_ADVANCE_FLAG | USB_INTR_HOST_ERR_FLAG)
[6297465]56
57static const irq_pio_range_t ehci_pio_ranges[] = {
58 {
59 .base = 0,
60 .size = sizeof(ehci_regs_t)
61 }
62};
63
64static const irq_cmd_t ehci_irq_commands[] = {
65 {
66 .cmd = CMD_PIO_READ_32,
67 .dstarg = 1,
68 .addr = NULL
69 },
70 {
71 .cmd = CMD_AND,
72 .srcarg = 1,
73 .dstarg = 2,
74 .value = 0
75 },
76 {
77 .cmd = CMD_PREDICATE,
78 .srcarg = 2,
79 .value = 2
80 },
81 {
82 .cmd = CMD_PIO_WRITE_A_32,
83 .srcarg = 1,
84 .addr = NULL
85 },
86 {
87 .cmd = CMD_ACCEPT
88 }
89};
90
91static int hc_init_memory(hc_t *instance);
92
93/** Generate IRQ code.
94 * @param[out] ranges PIO ranges buffer.
[ba4a03a5]95 * @param[in] hw_res Device's resources.
[6297465]96 *
97 * @return Error code.
98 */
[32fb6bce]99int hc_gen_irq_code(irq_code_t *code, hc_device_t *hcd, const hw_res_list_parsed_t *hw_res)
[6297465]100{
101 assert(code);
[ba4a03a5]102 assert(hw_res);
[32fb6bce]103 hc_t *instance = hcd_to_hc(hcd);
[e4d7363]104
[ba4a03a5]105 if (hw_res->irqs.count != 1 || hw_res->mem_ranges.count != 1)
106 return EINVAL;
107
108 addr_range_t regs = hw_res->mem_ranges.ranges[0];
109
110 if (RNGSZ(regs) < sizeof(ehci_regs_t))
[6297465]111 return EOVERFLOW;
112
113 code->ranges = malloc(sizeof(ehci_pio_ranges));
114 if (code->ranges == NULL)
115 return ENOMEM;
116
117 code->cmds = malloc(sizeof(ehci_irq_commands));
118 if (code->cmds == NULL) {
119 free(code->ranges);
120 return ENOMEM;
121 }
122
123 code->rangecount = ARRAY_SIZE(ehci_pio_ranges);
124 code->cmdcount = ARRAY_SIZE(ehci_irq_commands);
125
126 memcpy(code->ranges, ehci_pio_ranges, sizeof(ehci_pio_ranges));
[ba4a03a5]127 code->ranges[0].base = RNGABS(regs);
[6297465]128
129 memcpy(code->cmds, ehci_irq_commands, sizeof(ehci_irq_commands));
[dca8fe5]130
[d09d108]131 ehci_regs_t *registers =
132 (ehci_regs_t *)(RNGABSPTR(regs) + EHCI_RD8(instance->caps->caplength));
133 code->cmds[0].addr = (void *) &registers->usbsts;
134 code->cmds[3].addr = (void *) &registers->usbsts;
[6297465]135 EHCI_WR(code->cmds[1].value, EHCI_USED_INTERRUPTS);
136
[a1732929]137 usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.",
[ba4a03a5]138 RNGABSPTR(regs), RNGSZ(regs), hw_res->irqs.irqs[0]);
139
140 return hw_res->irqs.irqs[0];
[6297465]141}
142
143/** Initialize EHCI hc driver structure
144 *
145 * @param[in] instance Memory place for the structure.
146 * @param[in] regs Device's I/O registers range.
147 * @param[in] interrupts True if w interrupts should be used
148 * @return Error code
149 */
[32fb6bce]150int hc_add(hc_device_t *hcd, const hw_res_list_parsed_t *hw_res)
[6297465]151{
[32fb6bce]152 hc_t *instance = hcd_to_hc(hcd);
[7813516]153 assert(hw_res);
154 if (hw_res->mem_ranges.count != 1 ||
155 hw_res->mem_ranges.ranges[0].size <
156 (sizeof(ehci_caps_regs_t) + sizeof(ehci_regs_t)))
157 return EINVAL;
[6297465]158
[7813516]159 int ret = pio_enable_range(&hw_res->mem_ranges.ranges[0],
160 (void **)&instance->caps);
[6297465]161 if (ret != EOK) {
[05b51e37]162 usb_log_error("HC(%p): Failed to gain access to device "
[a1732929]163 "registers: %s.", instance, str_error(ret));
[6297465]164 return ret;
165 }
[e4d7363]166
[05b51e37]167 usb_log_info("HC(%p): Device registers at %"PRIx64" (%zuB) accessible.",
168 instance, hw_res->mem_ranges.ranges[0].address.absolute,
[7813516]169 hw_res->mem_ranges.ranges[0].size);
[6297465]170 instance->registers =
171 (void*)instance->caps + EHCI_RD8(instance->caps->caplength);
[05b51e37]172 usb_log_info("HC(%p): Device control registers at %" PRIx64, instance,
[d97f91f]173 hw_res->mem_ranges.ranges[0].address.absolute
174 + EHCI_RD8(instance->caps->caplength));
[6297465]175
[8ad2b0a]176 list_initialize(&instance->pending_endpoints);
[6297465]177 fibril_mutex_initialize(&instance->guard);
[763dbcb]178 fibril_condvar_initialize(&instance->async_doorbell);
[6297465]179
180 ret = hc_init_memory(instance);
181 if (ret != EOK) {
[05b51e37]182 usb_log_error("HC(%p): Failed to create EHCI memory structures:"
183 " %s.", instance, str_error(ret));
[6297465]184 return ret;
185 }
186
[05b51e37]187 usb_log_info("HC(%p): Initializing RH(%p).", instance, &instance->rh);
[6297465]188 ehci_rh_init(
189 &instance->rh, instance->caps, instance->registers, "ehci rh");
190
[32fb6bce]191 ehci_bus_init(&instance->bus, instance);
192 hc_device_setup(hcd, (bus_t *) &instance->bus);
[6297465]193 return EOK;
194}
195
[7813516]196/** Safely dispose host controller internal structures
197 *
198 * @param[in] instance Host controller structure to use.
199 */
[35c37fc]200int hc_gone(hc_device_t *hcd)
[7813516]201{
[35c37fc]202 hc_t *hc = hcd_to_hc(hcd);
203 endpoint_list_fini(&hc->async_list);
204 endpoint_list_fini(&hc->int_list);
205 dma_buffer_free(&hc->dma_buffer);
[32fb6bce]206 return EOK;
[7813516]207};
208
[6297465]209void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
210{
[5f5321ee]211 assert(instance);
212 assert(ep);
213 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep);
[a1732929]214 usb_log_debug("HC(%p) enqueue EP(%d:%d:%s:%s)", instance,
[a5b3de6]215 ep->device->address, ep->endpoint,
[92900e2]216 usb_str_transfer_type_short(ep->transfer_type),
217 usb_str_direction(ep->direction));
[5f5321ee]218 switch (ep->transfer_type)
219 {
220 case USB_TRANSFER_CONTROL:
221 case USB_TRANSFER_BULK:
222 endpoint_list_append_ep(&instance->async_list, ehci_ep);
223 break;
224 case USB_TRANSFER_INTERRUPT:
225 endpoint_list_append_ep(&instance->int_list, ehci_ep);
226 break;
227 case USB_TRANSFER_ISOCHRONOUS:
228 /* NOT SUPPORTED */
229 break;
230 }
[6297465]231}
232
233void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep)
234{
[763dbcb]235 assert(instance);
236 assert(ep);
237 ehci_endpoint_t *ehci_ep = ehci_endpoint_get(ep);
[a1732929]238 usb_log_debug("HC(%p) dequeue EP(?:%d:%s:%s)", instance,
[306a36d]239 ep->endpoint,
[92900e2]240 usb_str_transfer_type_short(ep->transfer_type),
241 usb_str_direction(ep->direction));
[763dbcb]242 switch (ep->transfer_type)
243 {
244 case USB_TRANSFER_INTERRUPT:
[ce735cc2]245 endpoint_list_remove_ep(&instance->int_list, ehci_ep);
[763dbcb]246 /* Fall through */
247 case USB_TRANSFER_ISOCHRONOUS:
248 /* NOT SUPPORTED */
249 return;
250 case USB_TRANSFER_CONTROL:
251 case USB_TRANSFER_BULK:
252 endpoint_list_remove_ep(&instance->async_list, ehci_ep);
253 break;
254 }
255 fibril_mutex_lock(&instance->guard);
[05b51e37]256 usb_log_debug("HC(%p): Waiting for doorbell", instance);
[1803b7d]257 EHCI_SET(instance->registers->usbcmd, USB_CMD_IRQ_ASYNC_DOORBELL);
[763dbcb]258 fibril_condvar_wait(&instance->async_doorbell, &instance->guard);
[05b51e37]259 usb_log_debug2("HC(%p): Got doorbell", instance);
[763dbcb]260 fibril_mutex_unlock(&instance->guard);
[6297465]261}
262
[32fb6bce]263int ehci_hc_status(bus_t *bus_base, uint32_t *status)
[c9e954c]264{
[32fb6bce]265 assert(bus_base);
[c9e954c]266 assert(status);
[32fb6bce]267
268 ehci_bus_t *bus = (ehci_bus_t *) bus_base;
269 hc_t *hc = bus->hc;
270 assert(hc);
271
[c9e954c]272 *status = 0;
[32fb6bce]273 if (hc->registers) {
274 *status = EHCI_RD(hc->registers->usbsts);
275 EHCI_WR(hc->registers->usbsts, *status);
[c9e954c]276 }
[32fb6bce]277 usb_log_debug2("HC(%p): Read status: %x", hc, *status);
[c9e954c]278 return EOK;
279}
280
[6297465]281/** Add USB transfer to the schedule.
282 *
[c9e954c]283 * @param[in] hcd HCD driver structure.
[6297465]284 * @param[in] batch Batch representing the transfer.
285 * @return Error code.
286 */
[32fb6bce]287int ehci_hc_schedule(usb_transfer_batch_t *batch)
[6297465]288{
[32fb6bce]289 assert(batch);
290
291 ehci_bus_t *bus = (ehci_bus_t *) endpoint_get_bus(batch->ep);
292 hc_t *hc = bus->hc;
293 assert(hc);
[6297465]294
295 /* Check for root hub communication */
[32fb6bce]296 if (batch->target.address == ehci_rh_get_address(&hc->rh)) {
[05b51e37]297 usb_log_debug("HC(%p): Scheduling BATCH(%p) for RH(%p)",
[32fb6bce]298 hc, batch, &hc->rh);
299 return ehci_rh_schedule(&hc->rh, batch);
[6297465]300 }
[5fd9c30]301
[8ad2b0a]302 endpoint_t * const ep = batch->ep;
303 ehci_endpoint_t * const ehci_ep = ehci_endpoint_get(ep);
304
305 /* creating local reference */
306 endpoint_add_ref(ep);
[5fd9c30]307
[8ad2b0a]308 fibril_mutex_lock(&ep->guard);
309 endpoint_activate_locked(ep, batch);
310
311 ehci_transfer_batch_t *ehci_batch = ehci_transfer_batch_get(batch);
[5fd9c30]312 const int err = ehci_transfer_batch_prepare(ehci_batch);
[8ad2b0a]313 if (err) {
314 endpoint_deactivate_locked(ep);
315 fibril_mutex_unlock(&ep->guard);
316 /* dropping local reference */
317 endpoint_del_ref(ep);
[5fd9c30]318 return err;
[8ad2b0a]319 }
[e9c5bd9]320
[32fb6bce]321 usb_log_debug("HC(%p): Committing BATCH(%p)", hc, batch);
[e9c5bd9]322 ehci_transfer_batch_commit(ehci_batch);
[8ad2b0a]323 fibril_mutex_unlock(&ep->guard);
324
325 /* Enqueue endpoint to the checked list */
326 fibril_mutex_lock(&hc->guard);
327 usb_log_debug2("HC(%p): Appending BATCH(%p)", hc, batch);
[e9c5bd9]328
[8ad2b0a]329 /* local reference -> pending list reference */
330 list_append(&ehci_ep->pending_link, &hc->pending_endpoints);
[32fb6bce]331 fibril_mutex_unlock(&hc->guard);
[8ad2b0a]332
[e9c5bd9]333 return EOK;
[6297465]334}
335
336/** Interrupt handling routine
337 *
[c9e954c]338 * @param[in] hcd HCD driver structure.
[6297465]339 * @param[in] status Value of the status register at the time of interrupt.
340 */
[32fb6bce]341void ehci_hc_interrupt(bus_t *bus_base, uint32_t status)
[6297465]342{
[32fb6bce]343 assert(bus_base);
344
345 ehci_bus_t *bus = (ehci_bus_t *) bus_base;
346 hc_t *hc = bus->hc;
347 assert(hc);
[07645906]348
[32fb6bce]349 usb_log_debug2("HC(%p): Interrupt: %"PRIx32, hc, status);
[6297465]350 if (status & USB_STS_PORT_CHANGE_FLAG) {
[32fb6bce]351 ehci_rh_interrupt(&hc->rh);
[6297465]352 }
[07645906]353
[580b330]354 if (status & USB_STS_IRQ_ASYNC_ADVANCE_FLAG) {
[32fb6bce]355 fibril_mutex_lock(&hc->guard);
356 usb_log_debug2("HC(%p): Signaling doorbell", hc);
357 fibril_condvar_broadcast(&hc->async_doorbell);
358 fibril_mutex_unlock(&hc->guard);
[763dbcb]359 }
[07645906]360
[e9c5bd9]361 if (status & (USB_STS_IRQ_FLAG | USB_STS_ERR_IRQ_FLAG)) {
[8ad2b0a]362
363 LIST_INITIALIZE(completed);
364
[32fb6bce]365 fibril_mutex_lock(&hc->guard);
[e9c5bd9]366
[8ad2b0a]367 usb_log_debug2("HC(%p): Scanning %lu pending endpoints", hc,
368 list_count(&hc->pending_endpoints));
369 list_foreach_safe(hc->pending_endpoints, current, next) {
370 ehci_endpoint_t *ep
371 = list_get_instance(current, ehci_endpoint_t, pending_link);
372
373 fibril_mutex_lock(&ep->base.guard);
374 ehci_transfer_batch_t *batch
375 = ehci_transfer_batch_get(ep->base.active_batch);
376 assert(batch);
[e9c5bd9]377
[5fd9c30]378 if (ehci_transfer_batch_check_completed(batch)) {
[8ad2b0a]379 endpoint_deactivate_locked(&ep->base);
[e9c5bd9]380 list_remove(current);
[8ad2b0a]381 endpoint_del_ref(&ep->base);
[c6f82e5]382 hc_reset_toggles(&batch->base, &ehci_ep_toggle_reset);
[5fd9c30]383 usb_transfer_batch_finish(&batch->base);
[e9c5bd9]384 }
[8ad2b0a]385 fibril_mutex_unlock(&ep->base.guard);
[e9c5bd9]386 }
[32fb6bce]387 fibril_mutex_unlock(&hc->guard);
[8ad2b0a]388
389
[e9c5bd9]390 }
391
[07645906]392 if (status & USB_STS_HOST_ERROR_FLAG) {
[32fb6bce]393 usb_log_fatal("HCD(%p): HOST SYSTEM ERROR!", hc);
[07645906]394 //TODO do something here
395 }
[6297465]396}
397
398/** EHCI hw initialization routine.
399 *
400 * @param[in] instance EHCI hc driver structure.
401 */
[32fb6bce]402int hc_start(hc_device_t *hcd)
[6297465]403{
[32fb6bce]404 hc_t *instance = hcd_to_hc(hcd);
[e4d7363]405 usb_log_debug("HC(%p): Starting HW.", instance);
406
[3eb0c85]407 /* Turn off the HC if it's running, Reseting a running device is
[478e243]408 * undefined */
409 if (!(EHCI_RD(instance->registers->usbsts) & USB_STS_HC_HALTED_FLAG)) {
410 /* disable all interrupts */
411 EHCI_WR(instance->registers->usbintr, 0);
412 /* ack all interrupts */
413 EHCI_WR(instance->registers->usbsts, 0x3f);
414 /* Stop HC hw */
415 EHCI_WR(instance->registers->usbcmd, 0);
416 /* Wait until hc is halted */
417 while ((EHCI_RD(instance->registers->usbsts) & USB_STS_HC_HALTED_FLAG) == 0) {
418 async_usleep(1);
419 }
[05b51e37]420 usb_log_info("HC(%p): EHCI turned off.", instance);
[478e243]421 } else {
[05b51e37]422 usb_log_info("HC(%p): EHCI was not running.", instance);
[478e243]423 }
424
425 /* Hw initialization sequence, see page 53 (pdf 63) */
426 EHCI_SET(instance->registers->usbcmd, USB_CMD_HC_RESET_FLAG);
[05b51e37]427 usb_log_info("HC(%p): Waiting for HW reset.", instance);
[478e243]428 while (EHCI_RD(instance->registers->usbcmd) & USB_CMD_HC_RESET_FLAG) {
429 async_usleep(1);
430 }
[05b51e37]431 usb_log_debug("HC(%p): HW reset OK.", instance);
432
[763dbcb]433 /* Use the lowest 4G segment */
[478e243]434 EHCI_WR(instance->registers->ctrldssegment, 0);
[3eb0c85]435
436 /* Enable periodic list */
[35c37fc]437 assert(instance->periodic_list);
[50362c6]438 uintptr_t phys_base =
[35c37fc]439 addr_to_phys((void*)instance->periodic_list);
[478e243]440 assert((phys_base & USB_PERIODIC_LIST_BASE_MASK) == phys_base);
441 EHCI_WR(instance->registers->periodiclistbase, phys_base);
[44b9b44]442 EHCI_SET(instance->registers->usbcmd, USB_CMD_PERIODIC_SCHEDULE_FLAG);
[05b51e37]443 usb_log_debug("HC(%p): Enabled periodic list.", instance);
[478e243]444
[763dbcb]445
[0a751aa]446 /* Enable Async schedule */
[50362c6]447 phys_base = addr_to_phys((void*)instance->async_list.list_head);
448 assert((phys_base & USB_ASYNCLIST_MASK) == phys_base);
449 EHCI_WR(instance->registers->asynclistaddr, phys_base);
[0a751aa]450 EHCI_SET(instance->registers->usbcmd, USB_CMD_ASYNC_SCHEDULE_FLAG);
[05b51e37]451 usb_log_debug("HC(%p): Enabled async list.", instance);
[44b9b44]452
[3eb0c85]453 /* Start hc and get all ports */
[44b9b44]454 EHCI_SET(instance->registers->usbcmd, USB_CMD_RUN_FLAG);
455 EHCI_SET(instance->registers->configflag, USB_CONFIG_FLAG_FLAG);
[05b51e37]456 usb_log_debug("HC(%p): HW started.", instance);
457
[a1732929]458 usb_log_debug2("HC(%p): Registers: "
459 "\tUSBCMD(%p): %x(0x00080000 = at least 1ms between interrupts)"
460 "\tUSBSTS(%p): %x(0x00001000 = HC halted)"
461 "\tUSBINT(%p): %x(0x0 = no interrupts)."
462 "\tCONFIG(%p): %x(0x0 = ports controlled by companion hc).",
[05b51e37]463 instance,
[615abda]464 &instance->registers->usbcmd, EHCI_RD(instance->registers->usbcmd),
465 &instance->registers->usbsts, EHCI_RD(instance->registers->usbsts),
466 &instance->registers->usbintr, EHCI_RD(instance->registers->usbintr),
467 &instance->registers->configflag, EHCI_RD(instance->registers->configflag));
[495547d]468 /* Clear and Enable interrupts */
469 EHCI_WR(instance->registers->usbsts, EHCI_RD(instance->registers->usbsts));
470 EHCI_WR(instance->registers->usbintr, EHCI_USED_INTERRUPTS);
[e4d7363]471
472 return EOK;
[6297465]473}
474
[129b821f]475/**
476 * Setup roothub as a virtual hub.
477 */
478int hc_setup_roothub(hc_device_t *hcd)
479{
480 return hc_setup_virtual_root_hub(hcd, USB_SPEED_HIGH);
481}
482
[6297465]483/** Initialize memory structures used by the EHCI hcd.
484 *
485 * @param[in] instance EHCI hc driver structure.
486 * @return Error code.
487 */
488int hc_init_memory(hc_t *instance)
489{
[478e243]490 assert(instance);
[05b51e37]491 usb_log_debug2("HC(%p): Initializing Async list(%p).", instance,
492 &instance->async_list);
[5f5321ee]493 int ret = endpoint_list_init(&instance->async_list, "ASYNC");
494 if (ret != EOK) {
[05b51e37]495 usb_log_error("HC(%p): Failed to setup ASYNC list: %s",
496 instance, str_error(ret));
[5f5321ee]497 return ret;
498 }
[50362c6]499 /* Specs say "Software must set queue head horizontal pointer T-bits to
500 * a zero for queue heads in the asynchronous schedule" (4.4.0).
501 * So we must maintain circular buffer (all horizontal pointers
502 * have to be valid */
503 endpoint_list_chain(&instance->async_list, &instance->async_list);
[5f5321ee]504
[05b51e37]505 usb_log_debug2("HC(%p): Initializing Interrupt list (%p).", instance,
506 &instance->int_list);
[5f5321ee]507 ret = endpoint_list_init(&instance->int_list, "INT");
508 if (ret != EOK) {
[05b51e37]509 usb_log_error("HC(%p): Failed to setup INT list: %s",
510 instance, str_error(ret));
[5f5321ee]511 endpoint_list_fini(&instance->async_list);
512 return ret;
513 }
[478e243]514
515 /* Take 1024 periodic list heads, we ignore low mem options */
[35c37fc]516 if (dma_buffer_alloc(&instance->dma_buffer, PAGE_SIZE)) {
[05b51e37]517 usb_log_error("HC(%p): Failed to get ISO schedule page.",
518 instance);
[5f5321ee]519 endpoint_list_fini(&instance->async_list);
520 endpoint_list_fini(&instance->int_list);
[478e243]521 return ENOMEM;
[5f5321ee]522 }
[35c37fc]523 instance->periodic_list = instance->dma_buffer.virt;
[05b51e37]524
525 usb_log_debug2("HC(%p): Initializing Periodic list.", instance);
[35c37fc]526 for (unsigned i = 0; i < PAGE_SIZE/sizeof(link_pointer_t); ++i)
[478e243]527 {
528 /* Disable everything for now */
[35c37fc]529 instance->periodic_list[i] =
[50362c6]530 LINK_POINTER_QH(addr_to_phys(instance->int_list.list_head));
[478e243]531 }
[6297465]532 return EOK;
533}
534
535/**
536 * @}
537 */
Note: See TracBrowser for help on using the repository browser.