Changeset d37514e in mainline


Ignore:
Timestamp:
2017-10-28T15:41:12Z (6 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c910ecf
Parents:
d46ceb2b
Message:

Routing fun_online and _offline through the USB bus. Added appropriate stubs and ops.

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/bus.c

    rd46ceb2b rd37514e  
    280280}
    281281
     282static int online_device(bus_t *bus_base, hcd_t *hcd, device_t *dev_base)
     283{
     284        int err;
     285
     286        xhci_hc_t *hc = hcd_get_driver_data(hcd);
     287        assert(hc);
     288
     289        xhci_bus_t *bus = bus_to_xhci_bus(bus_base);
     290        assert(bus);
     291
     292        xhci_device_t *dev = xhci_device_get(dev_base);
     293        assert(dev);
     294
     295        // TODO: Prepare the device for use. Reset? Configure?
     296
     297        if ((err = ddf_fun_online(dev_base->fun))) {
     298                return err;
     299        }
     300
     301        return EOK;
     302}
     303
     304static int offline_device(bus_t *bus_base, hcd_t *hcd, device_t *dev_base)
     305{
     306        int err;
     307
     308        xhci_hc_t *hc = hcd_get_driver_data(hcd);
     309        assert(hc);
     310
     311        xhci_bus_t *bus = bus_to_xhci_bus(bus_base);
     312        assert(bus);
     313
     314        xhci_device_t *dev = xhci_device_get(dev_base);
     315        assert(dev);
     316
     317        /* Tear down all drivers working with the device. */
     318        if ((err = ddf_fun_offline(dev_base->fun))) {
     319                return err;
     320        }
     321
     322        // TODO: We want to keep the device addressed. Deconfigure?
     323
     324        return EOK;
     325}
     326
    282327static endpoint_t *create_endpoint(bus_t *base)
    283328{
     
    442487        .remove_device = remove_device,
    443488
     489        .online_device = online_device,
     490        .offline_device = offline_device,
     491
    444492        .create_endpoint = create_endpoint,
    445493        .destroy_endpoint = destroy_endpoint,
  • uspace/drv/bus/usb/xhci/main.c

    rd46ceb2b rd37514e  
    164164}
    165165
     166static int xhci_fun_online(ddf_fun_t *fun)
     167{
     168        return hcd_ddf_device_online(fun);
     169}
     170
     171static int xhci_fun_offline(ddf_fun_t *fun)
     172{
     173        return hcd_ddf_device_offline(fun);
     174}
    166175
    167176static const driver_ops_t xhci_driver_ops = {
    168177        .dev_add = xhci_dev_add,
     178        .fun_online = xhci_fun_online,
     179        .fun_offline = xhci_fun_offline
    169180};
    170181
  • uspace/lib/usbhost/include/usb/host/bus.h

    rd46ceb2b rd37514e  
    8282        int (*remove_device)(bus_t *, hcd_t *, device_t *);
    8383
     84        int (*online_device)(bus_t *, hcd_t *, device_t *);                     /**< Optional */
     85        int (*offline_device)(bus_t *, hcd_t *, device_t *);                    /**< Optional */
     86
    8487        /* The following operations are protected by a bus guard. */
    8588        endpoint_t *(*create_endpoint)(bus_t *);
     
    123126int bus_remove_device(bus_t *, hcd_t *, device_t *);
    124127
     128int bus_online_device(bus_t *, hcd_t *, device_t *);
     129int bus_offline_device(bus_t *, hcd_t *, device_t *);
     130
    125131int bus_add_endpoint(bus_t *, device_t *, const usb_endpoint_desc_t *, endpoint_t **);
    126132endpoint_t *bus_find_endpoint(bus_t *, device_t *, usb_target_t, usb_direction_t);
  • uspace/lib/usbhost/include/usb/host/ddf_helpers.h

    rd46ceb2b rd37514e  
    8585void hcd_ddf_device_destroy(device_t *);
    8686int hcd_ddf_device_explore(hcd_t *, device_t *);
     87int hcd_ddf_device_online(ddf_fun_t *);
     88int hcd_ddf_device_offline(ddf_fun_t *);
    8789
    8890hcd_t *dev_to_hcd(ddf_dev_t *dev);
  • uspace/lib/usbhost/src/bus.c

    rd46ceb2b rd37514e  
    101101}
    102102
     103int bus_online_device(bus_t *bus, hcd_t *hcd, device_t *dev)
     104{
     105        assert(bus);
     106        assert(hcd);
     107        assert(dev);
     108
     109        if (!bus->ops.online_device)
     110                return ENOTSUP;
     111
     112        return bus->ops.online_device(bus, hcd, dev);
     113}
     114
     115int bus_offline_device(bus_t *bus, hcd_t *hcd, device_t *dev)
     116{
     117        assert(bus);
     118        assert(hcd);
     119        assert(dev);
     120
     121        if (!bus->ops.offline_device)
     122                return ENOTSUP;
     123
     124        return bus->ops.offline_device(bus, hcd, dev);
     125}
     126
    103127int bus_add_endpoint(bus_t *bus, device_t *device, const usb_endpoint_desc_t *desc, endpoint_t **out_ep)
    104128{
  • uspace/lib/usbhost/src/ddf_helpers.c

    rd46ceb2b rd37514e  
    448448}
    449449
     450int hcd_ddf_device_online(ddf_fun_t *fun)
     451{
     452        assert(fun);
     453
     454        hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
     455        device_t *dev = ddf_fun_data_get(fun);
     456        assert(dev);
     457        assert(hcd->bus);
     458
     459        usb_log_info("Device(%d): Requested to be brought online.", dev->address);
     460
     461        return bus_online_device(hcd->bus, hcd, dev);
     462}
     463
     464int hcd_ddf_device_offline(ddf_fun_t *fun)
     465{
     466        assert(fun);
     467
     468        hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun));
     469        device_t *dev = ddf_fun_data_get(fun);
     470        assert(dev);
     471        assert(hcd->bus);
     472
     473        usb_log_info("Device(%d): Requested to be taken offline.", dev->address);
     474
     475        return bus_offline_device(hcd->bus, hcd, dev);
     476}
     477
    450478static int hcd_ddf_new_device(hcd_t *hcd, ddf_dev_t *hc, device_t *hub, unsigned port)
    451479{
Note: See TracChangeset for help on using the changeset viewer.