source: mainline/uspace/lib/usbhost/src/ddf_helpers.c@ 5dfb70c9

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

usbhost: refactoring

This commit moves interrupt, status and schedule to bus
operations. Then the purpose of hcd_t is better defined, and split into
hc_driver_t and hc_device_t. hc_driver_t is used to wrap driver
implementation by the library (similar to how usb_driver_t is used to
wrap usb device drivers). hc_device_t is used as a parent for hc_t
inside drivers, and is allocated inside the DDF device node.

To support these changes, some local identifiers were renamed, some
functions were moved and/or renamed and their arguments changed. The
most notable one being hcd_send_batch → bus_device_send_batch.

  • Property mode set to 100644
File size: 15.3 KB
RevLine 
[53332b5b]1/*
[d2cfe72]2 * Copyright (c) 2013 Jan Vesely
[53332b5b]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 libusbhost
30 * @{
31 */
32/** @file
33 *
34 */
35
[8d2e251]36#include <adt/list.h>
37#include <assert.h>
38#include <async.h>
39#include <ddf/driver.h>
40#include <ddf/interrupt.h>
41#include <device/hw_res_parsed.h>
[53332b5b]42#include <errno.h>
43#include <str_error.h>
[64fea02]44#include <usb/classes/classes.h>
45#include <usb/debug.h>
46#include <usb/descriptor.h>
47#include <usb/usb.h>
[8d2e251]48#include <usb_iface.h>
[41df71f9]49#include <usbhc_iface.h>
[53332b5b]50
[64fea02]51#include "bus.h"
52
[53332b5b]53#include "ddf_helpers.h"
54
55
[32fb6bce]56static int hcd_ddf_new_device(hc_device_t *hcd, ddf_dev_t *hc, device_t *hub_dev, unsigned port);
[20eaa82]57static int hcd_ddf_remove_device(ddf_dev_t *device, device_t *hub, unsigned port);
[2757247]58
59
60/* DDF INTERFACE */
61
[d2cfe72]62/** Register endpoint interface function.
63 * @param fun DDF function.
[816f5f4]64 * @param endpoint_desc Endpoint description.
[d2cfe72]65 * @return Error code.
66 */
67static int register_endpoint(
[816f5f4]68 ddf_fun_t *fun, usb_endpoint_desc_t *endpoint_desc)
[d2cfe72]69{
70 assert(fun);
[32fb6bce]71 hc_device_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
[20eaa82]72 device_t *dev = ddf_fun_data_get(fun);
[d2cfe72]73 assert(hcd);
[20eaa82]74 assert(hcd->bus);
[d2cfe72]75 assert(dev);
76
[816f5f4]77 usb_log_debug("Register endpoint %d:%d %s-%s %zuB %ums.\n",
78 dev->address, endpoint_desc->endpoint_no,
79 usb_str_transfer_type(endpoint_desc->transfer_type),
80 usb_str_direction(endpoint_desc->direction),
81 endpoint_desc->max_packet_size, endpoint_desc->usb2.polling_interval);
82
[6832245]83 return bus_endpoint_add(dev, endpoint_desc, NULL);
[d2cfe72]84}
85
[816f5f4]86 /** Unregister endpoint interface function.
87 * @param fun DDF function.
88 * @param endpoint_desc Endpoint description.
89 * @return Error code.
90 */
[d2cfe72]91static int unregister_endpoint(
[816f5f4]92 ddf_fun_t *fun, usb_endpoint_desc_t *endpoint_desc)
[d2cfe72]93{
94 assert(fun);
[32fb6bce]95 hc_device_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
[20eaa82]96 device_t *dev = ddf_fun_data_get(fun);
[d2cfe72]97 assert(hcd);
[20eaa82]98 assert(hcd->bus);
[d2cfe72]99 assert(dev);
[816f5f4]100
[20eaa82]101 const usb_target_t target = {{
102 .address = dev->address,
[816f5f4]103 .endpoint = endpoint_desc->endpoint_no
[20eaa82]104 }};
[816f5f4]105
[d2cfe72]106 usb_log_debug("Unregister endpoint %d:%d %s.\n",
[816f5f4]107 dev->address, endpoint_desc->endpoint_no,
108 usb_str_direction(endpoint_desc->direction));
[0206d35]109
[6832245]110 endpoint_t *ep = bus_find_endpoint(dev, target, endpoint_desc->direction);
[0206d35]111 if (!ep)
112 return ENOENT;
113
[6832245]114 return bus_endpoint_remove(ep);
[d2cfe72]115}
116
[56bd6f11]117static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)
118{
119 assert(fun);
[32fb6bce]120 hc_device_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
[20eaa82]121 device_t *dev = ddf_fun_data_get(fun);
[56bd6f11]122 assert(hcd);
[20eaa82]123 assert(hcd->bus);
[56bd6f11]124 assert(dev);
125
126 usb_log_debug("Device %d requested default address at %s speed\n",
127 dev->address, usb_str_speed(speed));
[20eaa82]128 return bus_reserve_default_address(hcd->bus, speed);
[56bd6f11]129}
130
131static int release_default_address(ddf_fun_t *fun)
132{
133 assert(fun);
[32fb6bce]134 hc_device_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
[20eaa82]135 device_t *dev = ddf_fun_data_get(fun);
[56bd6f11]136 assert(hcd);
[20eaa82]137 assert(hcd->bus);
[56bd6f11]138 assert(dev);
139
140 usb_log_debug("Device %d released default address\n", dev->address);
[20eaa82]141 return bus_release_default_address(hcd->bus);
[56bd6f11]142}
143
[0918382f]144static int device_enumerate(ddf_fun_t *fun, unsigned port)
[56bd6f11]145{
146 assert(fun);
[867b375]147 ddf_dev_t *hc = ddf_fun_get_dev(fun);
148 assert(hc);
[32fb6bce]149 hc_device_t *hcd = dev_to_hcd(hc);
[867b375]150 assert(hcd);
[20eaa82]151 device_t *hub = ddf_fun_data_get(fun);
[867b375]152 assert(hub);
153
[0918382f]154 usb_log_debug("Hub %d reported a new USB device on port: %u\n",
[867b375]155 hub->address, port);
156 return hcd_ddf_new_device(hcd, hc, hub, port);
[56bd6f11]157}
158
[0918382f]159static int device_remove(ddf_fun_t *fun, unsigned port)
[56bd6f11]160{
161 assert(fun);
162 ddf_dev_t *ddf_dev = ddf_fun_get_dev(fun);
[20eaa82]163 device_t *dev = ddf_fun_data_get(fun);
[56bd6f11]164 assert(ddf_dev);
165 assert(dev);
[0918382f]166 usb_log_debug("Hub `%s' reported removal of device on port %u\n",
167 ddf_fun_get_name(fun), port);
168 return hcd_ddf_remove_device(ddf_dev, dev, port);
[56bd6f11]169}
170
[3121b5f]171/** Gets handle of the respective device.
[8e4219ab]172 *
[3121b5f]173 * @param[in] fun Device function.
[8e4219ab]174 * @param[out] handle Place to write the handle.
175 * @return Error code.
176 */
[3121b5f]177static int get_my_device_handle(ddf_fun_t *fun, devman_handle_t *handle)
[8e4219ab]178{
179 assert(fun);
180 if (handle)
181 *handle = ddf_fun_get_handle(fun);
182 return EOK;
183}
184
[1845003]185/** Inbound communication interface function.
186 * @param fun DDF function.
187 * @param target Communication target.
188 * @param setup_data Data to use in setup stage (control transfers).
189 * @param data Pointer to data buffer.
190 * @param size Size of the data buffer.
191 * @param callback Function to call on communication end.
192 * @param arg Argument passed to the callback function.
193 * @return Error code.
194 */
[327f147]195static int dev_read(ddf_fun_t *fun, usb_target_t target,
196 uint64_t setup_data, char *data, size_t size,
[41df71f9]197 usbhc_iface_transfer_callback_t callback, void *arg)
[1845003]198{
199 assert(fun);
[20eaa82]200 device_t *dev = ddf_fun_data_get(fun);
201 assert(dev);
[327f147]202
203 target.address = dev->address;
204
[32fb6bce]205 return bus_device_send_batch(dev, target, USB_DIRECTION_IN,
[327f147]206 data, size, setup_data,
207 callback, arg, "READ");
[1845003]208}
209
210/** Outbound communication interface function.
211 * @param fun DDF function.
212 * @param target Communication target.
213 * @param setup_data Data to use in setup stage (control transfers).
214 * @param data Pointer to data buffer.
215 * @param size Size of the data buffer.
216 * @param callback Function to call on communication end.
217 * @param arg Argument passed to the callback function.
218 * @return Error code.
219 */
[327f147]220static int dev_write(ddf_fun_t *fun, usb_target_t target,
221 uint64_t setup_data, const char *data, size_t size,
[41df71f9]222 usbhc_iface_transfer_callback_t callback, void *arg)
[1845003]223{
224 assert(fun);
[20eaa82]225 device_t *dev = ddf_fun_data_get(fun);
226 assert(dev);
[327f147]227
228 target.address = dev->address;
229
[32fb6bce]230 return bus_device_send_batch(dev, target, USB_DIRECTION_OUT,
[327f147]231 (char *) data, size, setup_data,
[1845003]232 callback, arg, "WRITE");
233}
234
[2757247]235/** USB device interface */
[53332b5b]236static usb_iface_t usb_iface = {
[3121b5f]237 .get_my_device_handle = get_my_device_handle,
[41df71f9]238};
[8e4219ab]239
[41df71f9]240/** USB host controller interface */
241static usbhc_iface_t usbhc_iface = {
[56bd6f11]242 .reserve_default_address = reserve_default_address,
243 .release_default_address = release_default_address,
[4b8ecff]244
[56bd6f11]245 .device_enumerate = device_enumerate,
246 .device_remove = device_remove,
[4b8ecff]247
[d2cfe72]248 .register_endpoint = register_endpoint,
249 .unregister_endpoint = unregister_endpoint,
[4b8ecff]250
[1845003]251 .read = dev_read,
252 .write = dev_write,
[53332b5b]253};
[8e4219ab]254
[2757247]255/** Standard USB device interface) */
[53332b5b]256static ddf_dev_ops_t usb_ops = {
257 .interfaces[USB_DEV_IFACE] = &usb_iface,
[41df71f9]258 .interfaces[USBHC_DEV_IFACE] = &usbhc_iface,
[53332b5b]259};
260
[2757247]261
262/* DDF HELPERS */
263
[237df2f]264#define ADD_MATCHID_OR_RETURN(list, sc, str, ...) \
265do { \
266 match_id_t *mid = malloc(sizeof(match_id_t)); \
267 if (!mid) { \
268 clean_match_ids(list); \
269 return ENOMEM; \
270 } \
271 char *id = NULL; \
272 int ret = asprintf(&id, str, ##__VA_ARGS__); \
273 if (ret < 0) { \
274 clean_match_ids(list); \
275 free(mid); \
276 return ENOMEM; \
277 } \
278 mid->score = sc; \
279 mid->id = id; \
280 add_match_id(list, mid); \
281} while (0)
[b995183]282
[237df2f]283/* This is a copy of lib/usbdev/src/recognise.c */
284static int create_match_ids(match_id_list_t *l,
285 usb_standard_device_descriptor_t *d)
286{
287 assert(l);
288 assert(d);
[42bc933]289
[237df2f]290 if (d->vendor_id != 0) {
291 /* First, with release number. */
292 ADD_MATCHID_OR_RETURN(l, 100,
293 "usb&vendor=%#04x&product=%#04x&release=%x.%x",
294 d->vendor_id, d->product_id, (d->device_version >> 8),
295 (d->device_version & 0xff));
[42bc933]296
[0ee999d]297 /* Next, without release number. */
[237df2f]298 ADD_MATCHID_OR_RETURN(l, 90, "usb&vendor=%#04x&product=%#04x",
299 d->vendor_id, d->product_id);
300 }
301
302 /* Class match id */
303 ADD_MATCHID_OR_RETURN(l, 50, "usb&class=%s",
304 usb_str_class(d->device_class));
305
306 /* As a last resort, try fallback driver. */
307 ADD_MATCHID_OR_RETURN(l, 10, "usb&fallback");
308
309 return EOK;
310}
311
[20eaa82]312static int hcd_ddf_remove_device(ddf_dev_t *device, device_t *hub,
[0918382f]313 unsigned port)
[237df2f]314{
315 assert(device);
316
[32fb6bce]317 hc_device_t *hcd = dev_to_hcd(device);
[237df2f]318 assert(hcd);
[20eaa82]319 assert(hcd->bus);
[b995183]320
[14dd4c9]321 fibril_mutex_lock(&hub->guard);
[b995183]322
[20eaa82]323 device_t *victim = NULL;
[b995183]324
[20eaa82]325 list_foreach(hub->devices, link, device_t, it) {
326 if (it->port == port) {
[3f03199]327 victim = it;
[b995183]328 break;
[3f03199]329 }
[b995183]330 }
[9ff59981]331 if (victim) {
[867b375]332 assert(victim->fun);
[20eaa82]333 assert(victim->port == port);
334 assert(victim->hub == hub);
[b995183]335 list_remove(&victim->link);
[14dd4c9]336 fibril_mutex_unlock(&hub->guard);
[e6becb9]337 const int ret = ddf_fun_unbind(victim->fun);
338 if (ret == EOK) {
[6832245]339 bus_device_remove(victim);
[e6becb9]340 ddf_fun_destroy(victim->fun);
341 } else {
[0918382f]342 usb_log_warning("Failed to unbind device `%s': %s\n",
343 ddf_fun_get_name(victim->fun), str_error(ret));
[e6becb9]344 }
[b995183]345 return EOK;
346 }
[9ff59981]347 fibril_mutex_unlock(&hub->guard);
[b995183]348 return ENOENT;
349}
350
[32fb6bce]351device_t *hcd_ddf_fun_create(hc_device_t *hc)
[867b375]352{
353 /* Create DDF function for the new device */
[32fb6bce]354 ddf_fun_t *fun = ddf_fun_create(hc->ddf_dev, fun_inner, NULL);
[867b375]355 if (!fun)
356 return NULL;
357
358 ddf_fun_set_ops(fun, &usb_ops);
359
360 /* Create USB device node for the new device */
[32fb6bce]361 device_t *dev = ddf_fun_data_alloc(fun, hc->bus->device_size);
[20eaa82]362 if (!dev) {
[867b375]363 ddf_fun_destroy(fun);
364 return NULL;
[237df2f]365 }
[2003739]366
[32fb6bce]367 bus_device_init(dev, hc->bus);
[20eaa82]368 dev->fun = fun;
369 return dev;
[867b375]370}
371
[32fb6bce]372void hcd_ddf_fun_destroy(device_t *dev)
[867b375]373{
374 assert(dev);
375 assert(dev->fun);
376 ddf_fun_destroy(dev->fun);
377}
378
[32fb6bce]379int hcd_device_explore(device_t *device)
[867b375]380{
381 int err;
382 match_id_list_t mids;
383 usb_standard_device_descriptor_t desc = { 0 };
384
385 init_match_ids(&mids);
386
[327f147]387 const usb_target_t control_ep = {{
[20eaa82]388 .address = device->address,
[327f147]389 .endpoint = 0,
[20eaa82]390 }};
[867b375]391
[237df2f]392 /* Get std device descriptor */
[2003739]393 const usb_device_request_setup_packet_t get_device_desc =
[237df2f]394 GET_DEVICE_DESC(sizeof(desc));
395
[f29643d5]396 usb_log_debug("Device(%d): Requesting full device descriptor.",
[20eaa82]397 device->address);
[32fb6bce]398 ssize_t got = bus_device_send_batch_sync(device, control_ep, USB_DIRECTION_IN,
[327f147]399 (char *) &desc, sizeof(desc), *(uint64_t *)&get_device_desc,
[237df2f]400 "read device descriptor");
[867b375]401 if (got < 0) {
402 err = got < 0 ? got : EOVERFLOW;
[f29643d5]403 usb_log_error("Device(%d): Failed to set get dev descriptor: %s",
[20eaa82]404 device->address, str_error(err));
[867b375]405 goto out;
[237df2f]406 }
[b995183]407
[237df2f]408 /* Create match ids from the device descriptor */
[20eaa82]409 usb_log_debug("Device(%d): Creating match IDs.", device->address);
[867b375]410 if ((err = create_match_ids(&mids, &desc))) {
[20eaa82]411 usb_log_error("Device(%d): Failed to create match ids: %s", device->address, str_error(err));
[867b375]412 goto out;
413 }
[237df2f]414
[867b375]415 list_foreach(mids.ids, link, const match_id_t, mid) {
[20eaa82]416 ddf_fun_add_match_id(device->fun, mid->id, mid->score);
[237df2f]417 }
418
[867b375]419out:
[237df2f]420 clean_match_ids(&mids);
[867b375]421 return err;
422}
423
[32fb6bce]424static int hcd_ddf_new_device(hc_device_t *hcd, ddf_dev_t *hc, device_t *hub, unsigned port)
[867b375]425{
426 int err;
427 assert(hcd);
[20eaa82]428 assert(hcd->bus);
429 assert(hub);
[867b375]430 assert(hc);
431
[32fb6bce]432 device_t *dev = hcd_ddf_fun_create(hcd);
[20eaa82]433 if (!dev) {
[867b375]434 usb_log_error("Failed to create USB device function.");
[20eaa82]435 return ENOMEM;
[867b375]436 }
437
[20eaa82]438 dev->hub = hub;
439 dev->port = port;
[867b375]440
[6832245]441 if ((err = bus_device_enumerate(dev))) {
[20eaa82]442 usb_log_error("Failed to initialize USB dev memory structures.");
443 return err;
[867b375]444 }
445
[20eaa82]446 /* If the driver didn't name the dev when enumerating,
447 * do it in some generic way.
[867b375]448 */
[20eaa82]449 if (!ddf_fun_get_name(dev->fun)) {
[6832245]450 bus_device_set_default_name(dev);
[867b375]451 }
452
[20eaa82]453 if ((err = ddf_fun_bind(dev->fun))) {
454 usb_log_error("Device(%d): Failed to register: %s.", dev->address, str_error(err));
[867b375]455 goto err_usb_dev;
456 }
457
[20eaa82]458 fibril_mutex_lock(&hub->guard);
459 list_append(&dev->link, &hub->devices);
460 fibril_mutex_unlock(&hub->guard);
[867b375]461
462 return EOK;
463
464err_usb_dev:
[32fb6bce]465 hcd_ddf_fun_destroy(dev);
[867b375]466 return err;
[237df2f]467}
468
469/** Announce root hub to the DDF
470 *
471 * @param[in] device Host controller ddf device
472 * @return Error code
473 */
[32fb6bce]474int hcd_setup_virtual_root_hub(hc_device_t *hcd)
[237df2f]475{
[867b375]476 int err;
477
[237df2f]478 assert(hcd);
479
[20eaa82]480 if ((err = bus_reserve_default_address(hcd->bus, USB_SPEED_MAX))) {
[867b375]481 usb_log_error("Failed to reserve default address for roothub setup: %s", str_error(err));
482 return err;
483 }
484
[32fb6bce]485 device_t *dev = hcd_ddf_fun_create(hcd);
[20eaa82]486 if (!dev) {
[867b375]487 usb_log_error("Failed to create function for the root hub.");
488 goto err_default_address;
489 }
490
[20eaa82]491 ddf_fun_set_name(dev->fun, "roothub");
[867b375]492
[20eaa82]493 /* Assign an address to the device */
[6832245]494 if ((err = bus_device_enumerate(dev))) {
[20eaa82]495 usb_log_error("Failed to enumerate roothub device: %s", str_error(err));
[867b375]496 goto err_usb_dev;
497 }
498
[20eaa82]499 if ((err = ddf_fun_bind(dev->fun))) {
[867b375]500 usb_log_error("Failed to register roothub: %s.", str_error(err));
501 goto err_usb_dev;
502 }
503
[20eaa82]504 bus_release_default_address(hcd->bus);
[867b375]505 return EOK;
506
507err_usb_dev:
[32fb6bce]508 hcd_ddf_fun_destroy(dev);
[867b375]509err_default_address:
[20eaa82]510 bus_release_default_address(hcd->bus);
[867b375]511 return err;
[237df2f]512}
513
[53332b5b]514/** Initialize hc structures.
515 *
516 * @param[in] device DDF instance of the device to use.
[ce33c10]517 * @param[in] max_speed Maximum supported USB speed.
518 * @param[in] bw available bandwidth.
519 * @param[in] bw_count Function to compute required ep bandwidth.
[53332b5b]520 *
[ce33c10]521 * @return Error code.
[2b0929e]522 * This function does all the ddf work for hc driver.
[53332b5b]523 */
[32fb6bce]524int hcd_ddf_setup_hc(ddf_dev_t *device, size_t size)
[53332b5b]525{
[e991937]526 assert(device);
[53332b5b]527
[32fb6bce]528 hc_device_t *instance = ddf_dev_data_alloc(device, size);
[53332b5b]529 if (instance == NULL) {
[2b0929e]530 usb_log_error("Failed to allocate HCD ddf structure.\n");
[53332b5b]531 return ENOMEM;
532 }
[32fb6bce]533 instance->ddf_dev = device;
[53332b5b]534
[e991937]535 int ret = ENOMEM;
536 instance->ctl_fun = ddf_fun_create(device, fun_exposed, "ctl");
537 if (!instance->ctl_fun) {
[cce3228]538 usb_log_error("Failed to create HCD ddf fun.\n");
539 goto err_destroy_fun;
540 }
541
[e991937]542 ret = ddf_fun_bind(instance->ctl_fun);
[cce3228]543 if (ret != EOK) {
[e991937]544 usb_log_error("Failed to bind ctl_fun: %s.\n", str_error(ret));
[cce3228]545 goto err_destroy_fun;
546 }
547
[e991937]548 ret = ddf_fun_add_to_category(instance->ctl_fun, USB_HC_CATEGORY);
[cce3228]549 if (ret != EOK) {
550 usb_log_error("Failed to add fun to category: %s.\n",
551 str_error(ret));
[e991937]552 ddf_fun_unbind(instance->ctl_fun);
[cce3228]553 goto err_destroy_fun;
554 }
[53332b5b]555
556 /* HC should be ok at this point (except it can't do anything) */
557 return EOK;
[cce3228]558
559err_destroy_fun:
[e991937]560 ddf_fun_destroy(instance->ctl_fun);
561 instance->ctl_fun = NULL;
[cce3228]562 return ret;
[53332b5b]563}
564
[32fb6bce]565void hcd_ddf_clean_hc(hc_device_t *hcd)
[e991937]566{
[32fb6bce]567 if (ddf_fun_unbind(hcd->ctl_fun) == EOK)
568 ddf_fun_destroy(hcd->ctl_fun);
[e991937]569}
[57c8fc9]570
[cccd60c3]571/** Call the parent driver with a request to enable interrupt
[57c8fc9]572 *
573 * @param[in] device Device asking for interrupts
[cccd60c3]574 * @param[in] inum Interrupt number
[57c8fc9]575 * @return Error code.
576 */
[32fb6bce]577int hcd_ddf_enable_interrupt(hc_device_t *hcd, int inum)
[57c8fc9]578{
[32fb6bce]579 async_sess_t *parent_sess = ddf_dev_parent_sess_get(hcd->ddf_dev);
[2bdf92a5]580 if (parent_sess == NULL)
581 return EIO;
[57c8fc9]582
[cccd60c3]583 return hw_res_enable_interrupt(parent_sess, inum);
[57c8fc9]584}
585
[32fb6bce]586int hcd_ddf_get_registers(hc_device_t *hcd, hw_res_list_parsed_t *hw_res)
[57c8fc9]587{
[32fb6bce]588 async_sess_t *parent_sess = ddf_dev_parent_sess_get(hcd->ddf_dev);
[2bdf92a5]589 if (parent_sess == NULL)
590 return EIO;
[57c8fc9]591
592 hw_res_list_parsed_init(hw_res);
593 const int ret = hw_res_get_list_parsed(parent_sess, hw_res, 0);
[c898236]594 if (ret != EOK)
595 hw_res_list_parsed_clean(hw_res);
[57c8fc9]596 return ret;
597}
[19d21728]598
[53332b5b]599/**
600 * @}
601 */
Note: See TracBrowser for help on using the repository browser.