Changeset 84439d7 in mainline for uspace/lib/usb/include


Ignore:
Timestamp:
2010-12-05T09:34:46Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
75732da
Parents:
56b962d (diff), 35537a7 (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.
Message:

Merge with development/

Location:
uspace/lib/usb/include/usb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/classes/hub.h

    r56b962d r84439d7  
    3636#define LIBUSB_HUB_H_
    3737
    38 /** Hub class request. */
    39 typedef enum {
    40         USB_HUB_REQUEST_GET_STATUS = 0,
    41         USB_HUB_REQUEST_CLEAR_FEATURE = 1,
    42         USB_HUB_REQUEST_GET_STATE = 2,
    43         USB_HUB_REQUEST_SET_FEATURE = 3,
    44         USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
    45         USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
    46         /* USB_HUB_REQUEST_ = , */
    47 } usb_hub_class_request_t;
     38#include <sys/types.h>
     39#include <usb/hcdhubd.h>
     40
    4841
    4942/** Hub class feature selector.
     
    6962} usb_hub_class_feature_t;
    7063
     64
     65/**
     66 *      @brief usb hub descriptor
     67 *
     68 *      For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
     69 */
     70typedef struct hub_descriptor_type{
     71    /** Number of bytes in this descriptor, including this byte */
     72    //uint8_t bDescLength;
     73
     74    /** Descriptor Type, value: 29H for hub descriptor */
     75    //uint8_t bDescriptorType;
     76
     77    /** Number of downstream ports that this hub supports */
     78    uint8_t ports_count;
     79
     80    /**
     81            D1...D0: Logical Power Switching Mode
     82            00: Ganged power switching (all ports’ power at
     83            once)
     84            01: Individual port power switching
     85            1X: Reserved. Used only on 1.0 compliant hubs
     86            that implement no power switching.
     87            D2: Identifies a Compound Device
     88            0: Hub is not part of a compound device
     89            1: Hub is part of a compound device
     90            D4...D3: Over-current Protection Mode
     91            00: Global Over-current Protection. The hub
     92            reports over-current as a summation of all
     93            ports’ current draw, without a breakdown of
     94            individual port over-current status.
     95            01: Individual Port Over-current Protection. The
     96            hub reports over-current on a per-port basis.
     97            Each port has an over-current indicator.
     98            1X: No Over-current Protection. This option is
     99            allowed only for bus-powered hubs that do not
     100            implement over-current protection.
     101            D15...D5:
     102            Reserved
     103     */
     104    uint16_t hub_characteristics;
     105
     106    /**
     107            Time (in 2ms intervals) from the time the power-on
     108            sequence begins on a port until power is good on that
     109            port. The USB System Software uses this value to
     110            determine how long to wait before accessing a
     111            powered-on port.
     112     */
     113    uint8_t pwr_on_2_good_time;
     114
     115    /**
     116            Maximum current requirements of the Hub Controller
     117            electronics in mA.
     118     */
     119    uint8_t current_requirement;
     120
     121    /**
     122            Indicates if a port has a removable device attached.
     123            This field is reported on byte-granularity. Within a
     124            byte, if no port exists for a given location, the field
     125            representing the port characteristics returns 0.
     126            Bit value definition:
     127            0B - Device is removable
     128            1B - Device is non-removable
     129            This is a bitmap corresponding to the individual ports
     130            on the hub:
     131            Bit 0: Reserved for future use
     132            Bit 1: Port 1
     133            Bit 2: Port 2
     134            ....
     135            Bit n: Port n (implementation-dependent, up to a
     136            maximum of 255 ports).
     137     */
     138    uint8_t * devices_removable;
     139
     140    /**
     141            This field exists for reasons of compatibility with
     142            software written for 1.0 compliant devices. All bits in
     143            this field should be set to 1B. This field has one bit for
     144            each port on the hub with additional pad bits, if
     145            necessary, to make the number of bits in the field an
     146            integer multiple of 8.
     147     */
     148    //uint8_t * port_pwr_ctrl_mask;
     149} usb_hub_descriptor_t;
     150
     151
     152
     153/**     @brief usb hub specific request types.
     154 *
     155 *      For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
     156 */
     157typedef enum {
     158    /** This request resets a value reported in the hub status. */
     159    USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
     160    /** This request resets a value reported in the port status. */
     161    USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
     162    /** This is an optional per-port diagnostic request that returns the bus state value, as sampled at the last EOF2 point. */
     163    USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
     164    /** This request returns the hub descriptor. */
     165    USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
     166    /** This request returns the current hub status and the states that have changed since the previous acknowledgment. */
     167    USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
     168    /** This request returns the current port status and the current value of the port status change bits. */
     169    USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
     170    /** This request overwrites the hub descriptor. */
     171    USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
     172    /** This request sets a value reported in the hub status. */
     173    USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
     174    /** This request sets a value reported in the port status. */
     175    USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23
     176} usb_hub_bm_request_type_t;
     177
     178/** @brief hub class request codes*/
     179typedef enum {
     180    /**  */
     181    USB_HUB_REQUEST_GET_STATUS = 0,
     182    /** */
     183    USB_HUB_REQUEST_CLEAR_FEATURE = 1,
     184    /** */
     185    USB_HUB_REQUEST_GET_STATE = 2,
     186    /** */
     187    USB_HUB_REQUEST_SET_FEATURE = 3,
     188    /** */
     189    USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
     190    /** */
     191    USB_HUB_REQUEST_SET_DESCRIPTOR = 7
     192} usb_hub_request_t;
     193
     194/**
     195 *      Maximum size of usb hub descriptor in bytes
     196 */
     197extern size_t USB_HUB_MAX_DESCRIPTOR_SIZE;
     198
     199/**
     200 * @brief create uint8_t array with serialized descriptor
     201 *
     202 * @param descriptor
     203 */
     204void * usb_serialize_hub_descriptor(usb_hub_descriptor_t * descriptor);
     205
     206/**
     207 * @brief create deserialized desriptor structure out of serialized descriptor
     208 *
     209 * The serialized descriptor must be proper usb hub descriptor, otherwise an eerror might occur.
     210 *
     211 * @param sdescriptor serialized descriptor
     212 */
     213usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * sdescriptor);
     214
     215/**
     216 * @brief create hub structure instance
     217 *
     218 * @param device
     219 * @return
     220 */
     221usb_hcd_hub_info_t * usb_create_hub_info(device_t * device);
     222
     223
     224
     225
     226
    71227#endif
    72228/**
  • uspace/lib/usb/include/usb/hcdhubd.h

    r56b962d r84439d7  
    3737
    3838#include <adt/list.h>
     39#include <bool.h>
    3940#include <driver.h>
    4041#include <usb/usb.h>
     
    115116} usb_hcd_transfer_ops_t;
    116117
     118/**
     119 * @brief structure holding information about free and used addresses
     120 *
     121 * This structure should not be used outside usb hcd driver.
     122 * You better consider it to be 'private'.
     123 */
     124typedef struct {
     125        /** lower bound included in the interval */
     126        usb_address_t lower_bound;
     127
     128        /** upper bound, excluded from the interval */
     129        usb_address_t upper_bound;
     130
     131        /** */
     132        link_t link;
     133}usb_address_list_t;
     134
    117135struct usb_hc_device {
    118136        /** Transfer operations. */
     
    130148        /** List of hubs operating from this HC. */
    131149        link_t hubs;
     150
     151        /** Structure with free and used addresses */
     152        link_t addresses;
    132153
    133154        /** Link to other driven HCs. */
     
    145166
    146167int usb_hcd_main(usb_hc_driver_t *);
    147 int usb_hcd_add_root_hub(usb_hc_device_t *dev);
     168int usb_hcd_add_root_hub(device_t *dev);
     169
     170/**
     171 * find first not yet used address on this host controller and use it
     172 * @param this_hcd
     173 * @return number in the range of allowed usb addresses or
     174 *     a negative number if not succesful
     175 */
     176usb_address_t usb_use_free_address(usb_hc_device_t * this_hcd);
     177
     178/**
     179 * @brief free the address in the address space of this hcd.
     180 *
     181 * if address is not used, nothing happens
     182 * @param this_hcd
     183 * @param addr
     184 */
     185void usb_free_used_address(usb_hc_device_t * this_hcd, usb_address_t addr );
    148186
    149187
     
    153191 */
    154192
     193device_t *usb_hc_connect(device_t *);
    155194
    156195int usb_hc_async_interrupt_out(usb_hc_device_t *, usb_target_t,
     
    175214int usb_hc_async_wait_for(usb_handle_t);
    176215
     216int usb_hc_add_child_device(device_t *, const char *, const char *, bool);
    177217
    178218#endif
  • uspace/lib/usb/include/usb/usbdrv.h

    r56b962d r84439d7  
    4141int usb_drv_hc_connect(device_t *, unsigned int);
    4242
     43int usb_drv_reserve_default_address(int);
     44int usb_drv_release_default_address(int);
     45usb_address_t usb_drv_request_address(int);
     46int usb_drv_bind_address(int, usb_address_t, devman_handle_t);
     47int usb_drv_release_address(int, usb_address_t);
     48
    4349usb_address_t usb_drv_get_my_address(int, device_t *);
    4450
     
    4854    void *, size_t, size_t *, usb_handle_t *);
    4955
     56int usb_drv_async_control_write_setup(int, usb_target_t,
     57    void *, size_t, usb_handle_t *);
     58int usb_drv_async_control_write_data(int, usb_target_t,
     59    void *, size_t, usb_handle_t *);
     60int usb_drv_async_control_write_status(int, usb_target_t,
     61    usb_handle_t *);
     62
     63int usb_drv_async_control_read_setup(int, usb_target_t,
     64    void *, size_t, usb_handle_t *);
     65int usb_drv_async_control_read_data(int, usb_target_t,
     66    void *, size_t, size_t *, usb_handle_t *);
     67int usb_drv_async_control_read_status(int, usb_target_t,
     68    usb_handle_t *);
     69
    5070int usb_drv_async_wait_for(usb_handle_t);
    5171
Note: See TracChangeset for help on using the changeset viewer.