Ignore:
Timestamp:
2018-02-28T16:37:50Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b20da0
Parents:
f5e5f73 (diff), b2dca8de (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
git-committer:
Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
Message:

Merge github.com:helenos-xhci-team/helenos

This commit merges support for USB 3 and generally refactors, fixes,
extends and cleans up the existing USB framework.

Notable additions and features:

  • new host controller driver has been implemented to control various xHC models (among others, NEC Renesas uPD720200)
  • isochronous data transfer mode
  • support for explicit USB device removal
  • USB tablet driver
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/hcd.h

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2011 Jan Vesely
     3 * Copyright (c) 2018 Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    3738#define LIBUSBHOST_HOST_HCD_H
    3839
    39 #include <usb/host/endpoint.h>
    40 #include <usb/host/usb_bus.h>
    41 #include <usb/host/usb_transfer_batch.h>
    42 #include <usb/usb.h>
     40#include <ddf/driver.h>
     41#include <usb/request.h>
    4342
    44 #include <assert.h>
    45 #include <usbhc_iface.h>
    46 #include <stddef.h>
    47 #include <stdint.h>
     43typedef struct hw_resource_list_parsed hw_res_list_parsed_t;
     44typedef struct bus bus_t;
     45typedef struct device device_t;
    4846
    49 typedef struct hcd hcd_t;
     47/* Treat this header as read-only in driver code.
     48 * It could be opaque, but why to complicate matters.
     49 */
     50typedef struct hc_device {
     51        /* Bus instance */
     52        bus_t *bus;
    5053
    51 typedef errno_t (*schedule_hook_t)(hcd_t *, usb_transfer_batch_t *);
    52 typedef errno_t (*ep_add_hook_t)(hcd_t *, endpoint_t *);
    53 typedef void (*ep_remove_hook_t)(hcd_t *, endpoint_t *);
    54 typedef void (*interrupt_hook_t)(hcd_t *, uint32_t);
    55 typedef errno_t (*status_hook_t)(hcd_t *, uint32_t *);
     54        /* Managed DDF device */
     55        ddf_dev_t *ddf_dev;
    5656
    57 typedef struct {
    58         /** Transfer scheduling, implement in device driver. */
    59         schedule_hook_t schedule;
    60         /** Hook called upon registering new endpoint. */
    61         ep_add_hook_t ep_add_hook;
    62         /** Hook called upon removing of an endpoint. */
    63         ep_remove_hook_t ep_remove_hook;
    64         /** Hook to be called on device interrupt, passes ARG1 */
    65         interrupt_hook_t irq_hook;
    66         /** Periodic polling hook */
    67         status_hook_t status_hook;
    68 } hcd_ops_t;
     57        /* Control function */
     58        ddf_fun_t *ctl_fun;
    6959
    70 /** Generic host controller driver structure. */
    71 struct hcd {
    72         /** Endpoint manager. */
    73         usb_bus_t bus;
     60        /* Result of enabling HW IRQs */
     61        int irq_cap;
    7462
    7563        /** Interrupt replacement fibril */
    7664        fid_t polling_fibril;
    7765
    78         /** Driver implementation */
    79         hcd_ops_t ops;
    80         /** Device specific driver data. */
    81         void * driver_data;
    82 };
     66        /* This structure is meant to be extended by driver code. */
     67} hc_device_t;
    8368
    84 extern void hcd_init(hcd_t *, usb_speed_t, size_t, bw_count_func_t);
     69typedef struct hc_driver {
     70        const char *name;
    8571
    86 static inline void hcd_set_implementation(hcd_t *hcd, void *data,
    87     const hcd_ops_t *ops)
     72        /** Size of the device data to be allocated, and passed as the
     73         * hc_device_t. */
     74        size_t hc_device_size;
     75
     76        /** Initialize device structures. */
     77        int (*hc_add)(hc_device_t *, const hw_res_list_parsed_t *);
     78
     79        /** Generate IRQ code to handle interrupts. */
     80        int (*irq_code_gen)(irq_code_t *, hc_device_t *,
     81            const hw_res_list_parsed_t *, int *);
     82
     83        /** Claim device from BIOS. */
     84        int (*claim)(hc_device_t *);
     85
     86        /** Start the host controller. */
     87        int (*start)(hc_device_t *);
     88
     89        /** Setup the virtual roothub. */
     90        int (*setup_root_hub)(hc_device_t *);
     91
     92        /** Stop the host controller (after start has been called) */
     93        int (*stop)(hc_device_t *);
     94
     95        /** HC was asked to be removed (after hc_add has been called) */
     96        int (*hc_remove)(hc_device_t *);
     97
     98        /** HC is gone. */
     99        int (*hc_gone)(hc_device_t *);
     100} hc_driver_t;
     101
     102/* Drivers should call this before leaving hc_add */
     103static inline void hc_device_setup(hc_device_t *hcd, bus_t *bus)
    88104{
    89         assert(hcd);
    90         if (ops) {
    91                 hcd->driver_data = data;
    92                 hcd->ops = *ops;
    93         } else {
    94                 memset(&hcd->ops, 0, sizeof(hcd->ops));
    95         }
     105        hcd->bus = bus;
    96106}
    97107
    98 static inline void * hcd_get_driver_data(hcd_t *hcd)
     108static inline hc_device_t *dev_to_hcd(ddf_dev_t *dev)
    99109{
    100         assert(hcd);
    101         return hcd->driver_data;
     110        return ddf_dev_data_get(dev);
    102111}
    103112
    104 extern errno_t hcd_request_address(hcd_t *, usb_speed_t, usb_address_t *);
    105 
    106 extern errno_t hcd_release_address(hcd_t *, usb_address_t);
    107 
    108 extern errno_t hcd_reserve_default_address(hcd_t *, usb_speed_t);
    109 
    110 static inline errno_t hcd_release_default_address(hcd_t *hcd)
    111 {
    112         return hcd_release_address(hcd, USB_ADDRESS_DEFAULT);
    113 }
    114 
    115 extern errno_t hcd_add_ep(hcd_t *, usb_target_t, usb_direction_t,
    116     usb_transfer_type_t, size_t, unsigned int, size_t, usb_address_t,
    117     unsigned int);
    118 
    119 extern errno_t hcd_remove_ep(hcd_t *, usb_target_t, usb_direction_t);
    120 
    121 extern errno_t hcd_send_batch(hcd_t *, usb_target_t, usb_direction_t, void *,
    122     size_t, uint64_t, usbhc_iface_transfer_in_callback_t,
    123     usbhc_iface_transfer_out_callback_t, void *, const char *);
    124 
    125 extern errno_t hcd_send_batch_sync(hcd_t *, usb_target_t, usb_direction_t,
    126     void *, size_t, uint64_t, const char *, size_t *);
     113extern errno_t hc_driver_main(const hc_driver_t *);
    127114
    128115#endif
Note: See TracChangeset for help on using the changeset viewer.