[41b96b4] | 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 | /** @addtogroup drvusbohcihc
|
---|
| 29 | * @{
|
---|
| 30 | */
|
---|
| 31 | /** @file
|
---|
| 32 | * @brief OHCI Host controller driver routines
|
---|
| 33 | */
|
---|
| 34 | #include <errno.h>
|
---|
| 35 | #include <str_error.h>
|
---|
| 36 | #include <adt/list.h>
|
---|
| 37 | #include <libarch/ddi.h>
|
---|
| 38 |
|
---|
| 39 | #include <usb/debug.h>
|
---|
| 40 | #include <usb/usb.h>
|
---|
| 41 | #include <usb/ddfiface.h>
|
---|
[ff582d47] | 42 | #include <usb/usbdevice.h>
|
---|
[41b96b4] | 43 |
|
---|
[bab71635] | 44 | #include "hc.h"
|
---|
[41b96b4] | 45 |
|
---|
[7d6a676] | 46 | static int interrupt_emulator(hc_t *instance);
|
---|
[2c617b0] | 47 | static void hc_gain_control(hc_t *instance);
|
---|
| 48 | static void hc_init_hw(hc_t *instance);
|
---|
[6b6e3ed3] | 49 | static int hc_init_transfer_lists(hc_t *instance);
|
---|
[344925c] | 50 | static int hc_init_memory(hc_t *instance);
|
---|
[a6d1bc1] | 51 | /*----------------------------------------------------------------------------*/
|
---|
[53f1c87] | 52 | int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
|
---|
| 53 | {
|
---|
| 54 | assert(instance);
|
---|
| 55 | assert(hub_fun);
|
---|
| 56 |
|
---|
| 57 | usb_address_t hub_address =
|
---|
| 58 | device_keeper_get_free_address(&instance->manager, USB_SPEED_FULL);
|
---|
| 59 | instance->rh.address = hub_address;
|
---|
| 60 | usb_device_keeper_bind(
|
---|
| 61 | &instance->manager, hub_address, hub_fun->handle);
|
---|
| 62 |
|
---|
[6bec59b] | 63 | endpoint_t *ep = malloc(sizeof(endpoint_t));
|
---|
| 64 | assert(ep);
|
---|
| 65 | int ret = endpoint_init(ep, hub_address, 0, USB_DIRECTION_BOTH,
|
---|
| 66 | USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64);
|
---|
| 67 | assert(ret == EOK);
|
---|
| 68 | ret = usb_endpoint_manager_register_ep(&instance->ep_manager, ep, 0);
|
---|
| 69 | assert(ret == EOK);
|
---|
| 70 |
|
---|
[53f1c87] | 71 | char *match_str = NULL;
|
---|
[6bec59b] | 72 | ret = asprintf(&match_str, "usb&class=hub");
|
---|
| 73 | // ret = (match_str == NULL) ? ret : EOK;
|
---|
[53f1c87] | 74 | if (ret < 0) {
|
---|
[6bec59b] | 75 | usb_log_error(
|
---|
| 76 | "Failed(%d) to create root hub match-id string.\n", ret);
|
---|
[53f1c87] | 77 | return ret;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | ret = ddf_fun_add_match_id(hub_fun, match_str, 100);
|
---|
| 81 | if (ret != EOK) {
|
---|
| 82 | usb_log_error("Failed add create root hub match-id.\n");
|
---|
| 83 | }
|
---|
| 84 | return ret;
|
---|
| 85 | }
|
---|
| 86 | /*----------------------------------------------------------------------------*/
|
---|
[a6d1bc1] | 87 | int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev,
|
---|
[e7bc999] | 88 | uintptr_t regs, size_t reg_size, bool interrupts)
|
---|
[41b96b4] | 89 | {
|
---|
| 90 | assert(instance);
|
---|
[ff582d47] | 91 | int ret = EOK;
|
---|
[c2be0e5] | 92 | #define CHECK_RET_RETURN(ret, message...) \
|
---|
| 93 | if (ret != EOK) { \
|
---|
| 94 | usb_log_error(message); \
|
---|
| 95 | return ret; \
|
---|
| 96 | } else (void)0
|
---|
[ff582d47] | 97 |
|
---|
| 98 | ret = pio_enable((void*)regs, reg_size, (void**)&instance->registers);
|
---|
[c2be0e5] | 99 | CHECK_RET_RETURN(ret,
|
---|
| 100 | "Failed(%d) to gain access to device registers: %s.\n",
|
---|
| 101 | ret, str_error(ret));
|
---|
| 102 |
|
---|
[ff582d47] | 103 | instance->ddf_instance = fun;
|
---|
[68b5ed6e] | 104 | usb_device_keeper_init(&instance->manager);
|
---|
[5876d36] | 105 | ret = usb_endpoint_manager_init(&instance->ep_manager,
|
---|
| 106 | BANDWIDTH_AVAILABLE_USB11);
|
---|
| 107 | CHECK_RET_RETURN(ret, "Failed to initialize endpoint manager: %s.\n",
|
---|
[c2be0e5] | 108 | ret, str_error(ret));
|
---|
[e7bc999] | 109 |
|
---|
[2c617b0] | 110 | hc_gain_control(instance);
|
---|
[8790650] | 111 | ret = hc_init_memory(instance);
|
---|
| 112 | CHECK_RET_RETURN(ret, "Failed to create OHCI memory structures:%s.\n",
|
---|
| 113 | ret, str_error(ret));
|
---|
| 114 | hc_init_hw(instance);
|
---|
[aa9ccf7] | 115 | fibril_mutex_initialize(&instance->guard);
|
---|
[2c617b0] | 116 |
|
---|
[a6d1bc1] | 117 | rh_init(&instance->rh, dev, instance->registers);
|
---|
[ff582d47] | 118 |
|
---|
[ff0e354] | 119 | if (!interrupts) {
|
---|
| 120 | instance->interrupt_emulator =
|
---|
| 121 | fibril_create((int(*)(void*))interrupt_emulator, instance);
|
---|
| 122 | fibril_add_ready(instance->interrupt_emulator);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
[8627377] | 125 | return EOK;
|
---|
[a6d1bc1] | 126 | }
|
---|
| 127 | /*----------------------------------------------------------------------------*/
|
---|
[1387692] | 128 | int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch)
|
---|
[41b96b4] | 129 | {
|
---|
| 130 | assert(instance);
|
---|
| 131 | assert(batch);
|
---|
[9ff5ff82] | 132 |
|
---|
| 133 | /* check for root hub communication */
|
---|
[41b96b4] | 134 | if (batch->target.address == instance->rh.address) {
|
---|
[2bf8f8c] | 135 | return rh_request(&instance->rh, batch);
|
---|
[41b96b4] | 136 | }
|
---|
[9ff5ff82] | 137 |
|
---|
[aa9ccf7] | 138 | fibril_mutex_lock(&instance->guard);
|
---|
[9ff5ff82] | 139 | switch (batch->transfer_type) {
|
---|
| 140 | case USB_TRANSFER_CONTROL:
|
---|
[8790650] | 141 | instance->registers->control &= ~C_CLE;
|
---|
[78d4e1f] | 142 | transfer_list_add_batch(
|
---|
| 143 | instance->transfers[batch->transfer_type], batch);
|
---|
[9ff5ff82] | 144 | instance->registers->command_status |= CS_CLF;
|
---|
[78d4e1f] | 145 | usb_log_debug2("Set CS control transfer filled: %x.\n",
|
---|
[8790650] | 146 | instance->registers->command_status);
|
---|
[78d4e1f] | 147 | instance->registers->control_current = 0;
|
---|
[8790650] | 148 | instance->registers->control |= C_CLE;
|
---|
[9ff5ff82] | 149 | break;
|
---|
| 150 | case USB_TRANSFER_BULK:
|
---|
[c6fe469] | 151 | instance->registers->control &= ~C_BLE;
|
---|
| 152 | transfer_list_add_batch(
|
---|
| 153 | instance->transfers[batch->transfer_type], batch);
|
---|
[9ff5ff82] | 154 | instance->registers->command_status |= CS_BLF;
|
---|
[8790650] | 155 | usb_log_debug2("Set bulk transfer filled: %x.\n",
|
---|
| 156 | instance->registers->command_status);
|
---|
[c6fe469] | 157 | instance->registers->control |= C_BLE;
|
---|
| 158 | break;
|
---|
| 159 | case USB_TRANSFER_INTERRUPT:
|
---|
| 160 | case USB_TRANSFER_ISOCHRONOUS:
|
---|
[aa9ccf7] | 161 | instance->registers->control &= (~C_PLE & ~C_IE);
|
---|
[c6fe469] | 162 | transfer_list_add_batch(
|
---|
| 163 | instance->transfers[batch->transfer_type], batch);
|
---|
[aa9ccf7] | 164 | instance->registers->control |= C_PLE | C_IE;
|
---|
| 165 | usb_log_debug2("Added periodic transfer: %x.\n",
|
---|
| 166 | instance->registers->periodic_current);
|
---|
[9ff5ff82] | 167 | break;
|
---|
| 168 | default:
|
---|
| 169 | break;
|
---|
| 170 | }
|
---|
[aa9ccf7] | 171 | fibril_mutex_unlock(&instance->guard);
|
---|
[4c28d17] | 172 | return EOK;
|
---|
[41b96b4] | 173 | }
|
---|
| 174 | /*----------------------------------------------------------------------------*/
|
---|
[7d6a676] | 175 | void hc_interrupt(hc_t *instance, uint32_t status)
|
---|
[41b96b4] | 176 | {
|
---|
| 177 | assert(instance);
|
---|
[eaf1e3d] | 178 | if ((status & ~IS_SF) == 0) /* ignore sof status */
|
---|
| 179 | return;
|
---|
[7d6a676] | 180 | if (status & IS_RHSC)
|
---|
| 181 | rh_interrupt(&instance->rh);
|
---|
| 182 |
|
---|
[eaf1e3d] | 183 | usb_log_debug("OHCI interrupt: %x.\n", status);
|
---|
| 184 |
|
---|
| 185 | if (status & IS_WDH) {
|
---|
[aa9ccf7] | 186 | fibril_mutex_lock(&instance->guard);
|
---|
| 187 | usb_log_debug2("HCCA: %p-%p(%p).\n", instance->hcca,
|
---|
| 188 | instance->registers->hcca, addr_to_phys(instance->hcca));
|
---|
| 189 | usb_log_debug2("Periodic current: %p.\n",
|
---|
| 190 | instance->registers->periodic_current);
|
---|
[eaf1e3d] | 191 | LIST_INITIALIZE(done);
|
---|
| 192 | transfer_list_remove_finished(
|
---|
| 193 | &instance->transfers_interrupt, &done);
|
---|
| 194 | transfer_list_remove_finished(
|
---|
| 195 | &instance->transfers_isochronous, &done);
|
---|
| 196 | transfer_list_remove_finished(
|
---|
| 197 | &instance->transfers_control, &done);
|
---|
| 198 | transfer_list_remove_finished(
|
---|
| 199 | &instance->transfers_bulk, &done);
|
---|
| 200 |
|
---|
| 201 | while (!list_empty(&done)) {
|
---|
| 202 | link_t *item = done.next;
|
---|
| 203 | list_remove(item);
|
---|
| 204 | usb_transfer_batch_t *batch =
|
---|
| 205 | list_get_instance(item, usb_transfer_batch_t, link);
|
---|
| 206 | usb_transfer_batch_finish(batch);
|
---|
| 207 | }
|
---|
[aa9ccf7] | 208 | fibril_mutex_unlock(&instance->guard);
|
---|
[4c28d17] | 209 | }
|
---|
[41b96b4] | 210 | }
|
---|
[7d6a676] | 211 | /*----------------------------------------------------------------------------*/
|
---|
[53f1c87] | 212 | int interrupt_emulator(hc_t *instance)
|
---|
[7d6a676] | 213 | {
|
---|
| 214 | assert(instance);
|
---|
| 215 | usb_log_info("Started interrupt emulator.\n");
|
---|
| 216 | while (1) {
|
---|
[2c617b0] | 217 | const uint32_t status = instance->registers->interrupt_status;
|
---|
[7d6a676] | 218 | instance->registers->interrupt_status = status;
|
---|
| 219 | hc_interrupt(instance, status);
|
---|
[aa9ccf7] | 220 | async_usleep(50000);
|
---|
[7d6a676] | 221 | }
|
---|
| 222 | return EOK;
|
---|
| 223 | }
|
---|
[2c617b0] | 224 | /*----------------------------------------------------------------------------*/
|
---|
| 225 | void hc_gain_control(hc_t *instance)
|
---|
| 226 | {
|
---|
| 227 | assert(instance);
|
---|
[112d159] | 228 | /* Turn off legacy emulation */
|
---|
| 229 | volatile uint32_t *ohci_emulation_reg =
|
---|
| 230 | (uint32_t*)((char*)instance->registers + 0x100);
|
---|
| 231 | usb_log_debug("OHCI legacy register %p: %x.\n",
|
---|
| 232 | ohci_emulation_reg, *ohci_emulation_reg);
|
---|
| 233 | *ohci_emulation_reg = 0;
|
---|
| 234 |
|
---|
[2c617b0] | 235 | /* Interrupt routing enabled => smm driver is active */
|
---|
| 236 | if (instance->registers->control & C_IR) {
|
---|
[112d159] | 237 | usb_log_debug("SMM driver: request ownership change.\n");
|
---|
[2c617b0] | 238 | instance->registers->command_status |= CS_OCR;
|
---|
| 239 | while (instance->registers->control & C_IR) {
|
---|
| 240 | async_usleep(1000);
|
---|
| 241 | }
|
---|
[112d159] | 242 | usb_log_info("SMM driver: Ownership taken.\n");
|
---|
[2c617b0] | 243 | return;
|
---|
| 244 | }
|
---|
| 245 |
|
---|
| 246 | const unsigned hc_status =
|
---|
| 247 | (instance->registers->control >> C_HCFS_SHIFT) & C_HCFS_MASK;
|
---|
| 248 | /* Interrupt routing disabled && status != USB_RESET => BIOS active */
|
---|
| 249 | if (hc_status != C_HCFS_RESET) {
|
---|
[112d159] | 250 | usb_log_debug("BIOS driver found.\n");
|
---|
[2c617b0] | 251 | if (hc_status == C_HCFS_OPERATIONAL) {
|
---|
[112d159] | 252 | usb_log_info("BIOS driver: HC operational.\n");
|
---|
[2c617b0] | 253 | return;
|
---|
| 254 | }
|
---|
| 255 | /* HC is suspended assert resume for 20ms */
|
---|
| 256 | instance->registers->control &= (C_HCFS_RESUME << C_HCFS_SHIFT);
|
---|
| 257 | async_usleep(20000);
|
---|
[112d159] | 258 | usb_log_info("BIOS driver: HC resumed.\n");
|
---|
[2c617b0] | 259 | return;
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | /* HC is in reset (hw startup) => no other driver
|
---|
| 263 | * maintain reset for at least the time specified in USB spec (50 ms)*/
|
---|
[112d159] | 264 | usb_log_info("HC found in reset.\n");
|
---|
[2c617b0] | 265 | async_usleep(50000);
|
---|
| 266 | }
|
---|
| 267 | /*----------------------------------------------------------------------------*/
|
---|
| 268 | void hc_init_hw(hc_t *instance)
|
---|
| 269 | {
|
---|
[112d159] | 270 | /* OHCI guide page 42 */
|
---|
[2c617b0] | 271 | assert(instance);
|
---|
[112d159] | 272 | usb_log_debug2("Started hc initialization routine.\n");
|
---|
| 273 |
|
---|
| 274 | /* Save contents of fm_interval register */
|
---|
[2c617b0] | 275 | const uint32_t fm_interval = instance->registers->fm_interval;
|
---|
[112d159] | 276 | usb_log_debug2("Old value of HcFmInterval: %x.\n", fm_interval);
|
---|
[344925c] | 277 |
|
---|
[112d159] | 278 | /* Reset hc */
|
---|
| 279 | usb_log_debug2("HC reset.\n");
|
---|
| 280 | size_t time = 0;
|
---|
[2c617b0] | 281 | instance->registers->command_status = CS_HCR;
|
---|
[112d159] | 282 | while (instance->registers->command_status & CS_HCR) {
|
---|
| 283 | async_usleep(10);
|
---|
| 284 | time += 10;
|
---|
| 285 | }
|
---|
| 286 | usb_log_debug2("HC reset complete in %zu us.\n", time);
|
---|
[344925c] | 287 |
|
---|
[112d159] | 288 | /* Restore fm_interval */
|
---|
[2c617b0] | 289 | instance->registers->fm_interval = fm_interval;
|
---|
| 290 | assert((instance->registers->command_status & CS_HCR) == 0);
|
---|
[344925c] | 291 |
|
---|
[2c617b0] | 292 | /* hc is now in suspend state */
|
---|
[112d159] | 293 | usb_log_debug2("HC should be in suspend state(%x).\n",
|
---|
| 294 | instance->registers->control);
|
---|
[344925c] | 295 |
|
---|
[78d4e1f] | 296 | /* Use HCCA */
|
---|
| 297 | instance->registers->hcca = addr_to_phys(instance->hcca);
|
---|
| 298 |
|
---|
| 299 | /* Use queues */
|
---|
| 300 | instance->registers->bulk_head = instance->transfers_bulk.list_head_pa;
|
---|
| 301 | usb_log_debug2("Bulk HEAD set to: %p(%p).\n",
|
---|
| 302 | instance->transfers_bulk.list_head,
|
---|
| 303 | instance->transfers_bulk.list_head_pa);
|
---|
| 304 |
|
---|
| 305 | instance->registers->control_head =
|
---|
| 306 | instance->transfers_control.list_head_pa;
|
---|
| 307 | usb_log_debug2("Control HEAD set to: %p(%p).\n",
|
---|
| 308 | instance->transfers_control.list_head,
|
---|
| 309 | instance->transfers_control.list_head_pa);
|
---|
| 310 |
|
---|
[112d159] | 311 | /* Enable queues */
|
---|
[344925c] | 312 | instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE);
|
---|
[112d159] | 313 | usb_log_debug2("All queues enabled(%x).\n",
|
---|
| 314 | instance->registers->control);
|
---|
| 315 |
|
---|
| 316 | /* Disable interrupts */
|
---|
| 317 | instance->registers->interrupt_disable = I_SF | I_OC;
|
---|
| 318 | usb_log_debug2("Disabling interrupts: %x.\n",
|
---|
| 319 | instance->registers->interrupt_disable);
|
---|
| 320 | instance->registers->interrupt_disable = I_MI;
|
---|
| 321 | usb_log_debug2("Enabled interrupts: %x.\n",
|
---|
| 322 | instance->registers->interrupt_enable);
|
---|
| 323 |
|
---|
| 324 | /* Set periodic start to 90% */
|
---|
| 325 | uint32_t frame_length = ((fm_interval >> FMI_FI_SHIFT) & FMI_FI_MASK);
|
---|
| 326 | instance->registers->periodic_start = (frame_length / 10) * 9;
|
---|
| 327 | usb_log_debug2("All periodic start set to: %x(%u - 90%% of %d).\n",
|
---|
| 328 | instance->registers->periodic_start,
|
---|
| 329 | instance->registers->periodic_start, frame_length);
|
---|
[2c617b0] | 330 |
|
---|
| 331 | instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT);
|
---|
[112d159] | 332 | usb_log_info("OHCI HC up and running(%x).\n",
|
---|
| 333 | instance->registers->control);
|
---|
[2c617b0] | 334 | }
|
---|
[6b6e3ed3] | 335 | /*----------------------------------------------------------------------------*/
|
---|
| 336 | int hc_init_transfer_lists(hc_t *instance)
|
---|
| 337 | {
|
---|
| 338 | assert(instance);
|
---|
[344925c] | 339 |
|
---|
| 340 | #define SETUP_TRANSFER_LIST(type, name) \
|
---|
| 341 | do { \
|
---|
| 342 | int ret = transfer_list_init(&instance->type, name); \
|
---|
[6b6e3ed3] | 343 | if (ret != EOK) { \
|
---|
[344925c] | 344 | usb_log_error("Failed(%d) to setup %s transfer list.\n", \
|
---|
| 345 | ret, name); \
|
---|
[6b6e3ed3] | 346 | transfer_list_fini(&instance->transfers_isochronous); \
|
---|
| 347 | transfer_list_fini(&instance->transfers_interrupt); \
|
---|
| 348 | transfer_list_fini(&instance->transfers_control); \
|
---|
| 349 | transfer_list_fini(&instance->transfers_bulk); \
|
---|
[344925c] | 350 | } \
|
---|
| 351 | } while (0)
|
---|
[6b6e3ed3] | 352 |
|
---|
[344925c] | 353 | SETUP_TRANSFER_LIST(transfers_isochronous, "ISOCHRONOUS");
|
---|
| 354 | SETUP_TRANSFER_LIST(transfers_interrupt, "INTERRUPT");
|
---|
| 355 | SETUP_TRANSFER_LIST(transfers_control, "CONTROL");
|
---|
| 356 | SETUP_TRANSFER_LIST(transfers_bulk, "BULK");
|
---|
[aa9ccf7] | 357 | #undef SETUP_TRANSFER_LIST
|
---|
[6b6e3ed3] | 358 | transfer_list_set_next(&instance->transfers_interrupt,
|
---|
[344925c] | 359 | &instance->transfers_isochronous);
|
---|
[6b6e3ed3] | 360 |
|
---|
| 361 | /* Assign pointers to be used during scheduling */
|
---|
| 362 | instance->transfers[USB_TRANSFER_INTERRUPT] =
|
---|
| 363 | &instance->transfers_interrupt;
|
---|
| 364 | instance->transfers[USB_TRANSFER_ISOCHRONOUS] =
|
---|
| 365 | &instance->transfers_interrupt;
|
---|
| 366 | instance->transfers[USB_TRANSFER_CONTROL] =
|
---|
| 367 | &instance->transfers_control;
|
---|
| 368 | instance->transfers[USB_TRANSFER_BULK] =
|
---|
| 369 | &instance->transfers_bulk;
|
---|
| 370 |
|
---|
| 371 | return EOK;
|
---|
| 372 | }
|
---|
[344925c] | 373 | /*----------------------------------------------------------------------------*/
|
---|
| 374 | int hc_init_memory(hc_t *instance)
|
---|
| 375 | {
|
---|
| 376 | assert(instance);
|
---|
[8790650] | 377 | /* Init queues */
|
---|
[344925c] | 378 | hc_init_transfer_lists(instance);
|
---|
| 379 |
|
---|
[8790650] | 380 | /*Init HCCA */
|
---|
[344925c] | 381 | instance->hcca = malloc32(sizeof(hcca_t));
|
---|
| 382 | if (instance->hcca == NULL)
|
---|
| 383 | return ENOMEM;
|
---|
| 384 | bzero(instance->hcca, sizeof(hcca_t));
|
---|
[78d4e1f] | 385 | usb_log_debug2("OHCI HCCA initialized at %p.\n", instance->hcca);
|
---|
[344925c] | 386 |
|
---|
| 387 | unsigned i = 0;
|
---|
| 388 | for (; i < 32; ++i) {
|
---|
| 389 | instance->hcca->int_ep[i] =
|
---|
| 390 | instance->transfers_interrupt.list_head_pa;
|
---|
| 391 | }
|
---|
[8790650] | 392 | usb_log_debug2("Interrupt HEADs set to: %p(%p).\n",
|
---|
| 393 | instance->transfers_interrupt.list_head,
|
---|
| 394 | instance->transfers_interrupt.list_head_pa);
|
---|
[344925c] | 395 |
|
---|
| 396 | return EOK;
|
---|
| 397 | }
|
---|
[41b96b4] | 398 | /**
|
---|
| 399 | * @}
|
---|
| 400 | */
|
---|