Changeset 4daee7a in mainline


Ignore:
Timestamp:
2012-12-16T16:26:30Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8de2cca
Parents:
f29931c
Message:

ohci, libusbhost: Move root hub registration to libusbhost.

Root hub controlled by generic usb hub driver is the way mentioned in the specs.

Location:
uspace
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    rf29931c r4daee7a  
    135135
    136136        return EOK;
    137 }
    138 
    139 /** Announce OHCI root hub to the DDF
    140  *
    141  * @param[in] instance OHCI driver intance
    142  * @param[in] hub_fun DDF fuction representing OHCI root hub
    143  * @return Error code
    144  */
    145 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
    146 {
    147         assert(instance);
    148         assert(hub_fun);
    149 
    150         /* Try to get address 1 for root hub. */
    151         instance->rh.address = 1;
    152         int ret = usb_device_manager_request_address(
    153             &instance->generic.dev_manager, &instance->rh.address, false,
    154             USB_SPEED_FULL);
    155         if (ret != EOK) {
    156                 usb_log_error("Failed to get OHCI root hub address: %s\n",
    157                     str_error(ret));
    158                 return ret;
    159         }
    160 
    161 #define CHECK_RET_UNREG_RETURN(ret, message...) \
    162 if (ret != EOK) { \
    163         usb_log_error(message); \
    164         usb_endpoint_manager_remove_ep( \
    165             &instance->generic.ep_manager, instance->rh.address, 0, \
    166             USB_DIRECTION_BOTH, NULL, NULL); \
    167         usb_device_manager_release_address( \
    168             &instance->generic.dev_manager, instance->rh.address); \
    169         return ret; \
    170 } else (void)0
    171 
    172         ret = usb_endpoint_manager_add_ep(
    173             &instance->generic.ep_manager, instance->rh.address, 0,
    174             USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64,
    175             0, NULL, NULL);
    176         CHECK_RET_UNREG_RETURN(ret,
    177             "Failed to register root hub control endpoint: %s.\n",
    178             str_error(ret));
    179 
    180         ret = ddf_fun_add_match_id(hub_fun, "usb&class=hub", 100);
    181         CHECK_RET_UNREG_RETURN(ret,
    182             "Failed to add root hub match-id: %s.\n", str_error(ret));
    183 
    184         ret = ddf_fun_bind(hub_fun);
    185         CHECK_RET_UNREG_RETURN(ret,
    186             "Failed to bind root hub function: %s.\n", str_error(ret));
    187 
    188         ret = usb_device_manager_bind_address(&instance->generic.dev_manager,
    189             instance->rh.address, ddf_fun_get_handle(hub_fun));
    190         if (ret != EOK)
    191                 usb_log_warning("Failed to bind root hub address: %s.\n",
    192                     str_error(ret));
    193 
    194         return EOK;
    195 #undef CHECK_RET_RELEASE
    196137}
    197138
  • uspace/drv/bus/usb/ohci/ohci.c

    rf29931c r4daee7a  
    248248            "Failed to add OHCI to HC class: %s.\n", str_error(ret));
    249249
    250         ret = hc_register_hub(hc, instance->rh_fun);
     250        ret = hcd_register_hub(&hc->generic, &hc->rh.address, instance->rh_fun);
    251251        CHECK_RET_FINI_RETURN(ret,
    252252            "Failed to register OHCI root hub: %s.\n", str_error(ret));
  • uspace/lib/usbhost/Makefile

    rf29931c r4daee7a  
    3636SOURCES = \
    3737        src/endpoint.c \
     38        src/hcd.c \
    3839        src/iface.c \
    3940        src/usb_device_manager.c \
  • uspace/lib/usbhost/include/usb/host/hcd.h

    rf29931c r4daee7a  
    7474 */
    7575static inline void hcd_init(hcd_t *hcd, usb_speed_t max_speed, size_t bandwidth,
    76     size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t))
     76    bw_count_func_t bw_count)
    7777{
    7878        assert(hcd);
     
    8383        hcd->ep_add_hook = NULL;
    8484        hcd->ep_remove_hook = NULL;
     85}
     86
     87static inline void hcd_set_implementation(hcd_t *hcd, void *data,
     88    schedule_hook_t schedule, ep_add_hook_t add_hook, ep_remove_hook_t rem_hook)
     89{
     90        assert(hcd);
     91        hcd->private_data = data;
     92        hcd->schedule = schedule;
     93        hcd->ep_add_hook = add_hook;
     94        hcd->ep_remove_hook = rem_hook;
     95
    8596}
    8697
     
    98109}
    99110
     111int hcd_register_hub(hcd_t *instance, usb_address_t *address, ddf_fun_t *hub_fun);
     112
     113
    100114/** Data retrieve wrapper.
    101115 * @param fun ddf function, non-null.
     
    107121}
    108122
     123
    109124extern usbhc_iface_t hcd_iface;
    110125
Note: See TracChangeset for help on using the changeset viewer.