Changeset 7813516 in mainline


Ignore:
Timestamp:
2014-01-01T01:19:10Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7191992
Parents:
d1df381
Message:

uhci,ohci,ehci: Use all hw resources to initialize HC

Location:
uspace/drv/bus/usb
Files:
9 edited

Legend:

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

    rd1df381 r7813516  
    9494                return ret;
    9595        }
    96         addr_range_t regs = hw_res.mem_ranges.ranges[0];
    9796
    9897        /* Initialize generic HCD driver */
     
    127126
    128127        /* Initialize EHCI HC */
    129         ret = hc_init(hc, &regs, interrupts);
     128        ret = hc_init(hc, &hw_res, interrupts);
    130129        hw_res_list_parsed_clean(&hw_res);
    131130        if (ret != EOK) {
  • uspace/drv/bus/usb/ehci/hc.c

    rd1df381 r7813516  
    157157 * @return Error code
    158158 */
    159 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
    160 {
    161         assert(instance);
    162 
    163         int ret = pio_enable_range(regs, (void **) &instance->caps);
     159int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts)
     160{
     161        assert(instance);
     162        assert(hw_res);
     163        if (hw_res->mem_ranges.count != 1 ||
     164            hw_res->mem_ranges.ranges[0].size <
     165                (sizeof(ehci_caps_regs_t) + sizeof(ehci_regs_t)))
     166            return EINVAL;
     167
     168        int ret = pio_enable_range(&hw_res->mem_ranges.ranges[0],
     169            (void **)&instance->caps);
    164170        if (ret != EOK) {
    165171                usb_log_error("Failed to gain access to device registers: %s.\n",
     
    167173                return ret;
    168174        }
     175        usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.\n",
     176            hw_res->mem_ranges.ranges[0].address.absolute,
     177            hw_res->mem_ranges.ranges[0].size);
    169178        instance->registers =
    170179            (void*)instance->caps + EHCI_RD8(instance->caps->caplength);
     
    194203        return EOK;
    195204}
     205
     206/** Safely dispose host controller internal structures
     207 *
     208 * @param[in] instance Host controller structure to use.
     209 */
     210void hc_fini(hc_t *instance)
     211{
     212        assert(instance);
     213        /* TODO: implement*/
     214};
    196215
    197216void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
  • uspace/drv/bus/usb/ehci/hc.h

    rd1df381 r7813516  
    7676int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res);
    7777int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
    78 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts);
    79 
    80 /** Safely dispose host controller internal structures
    81  *
    82  * @param[in] instance Host controller structure to use.
    83  */
    84 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ };
     78int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts);
     79void hc_fini(hc_t *instance);
    8580
    8681void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep);
  • uspace/drv/bus/usb/ohci/hc.c

    rd1df381 r7813516  
    148148 *
    149149 * @param[in] instance Memory place for the structure.
    150  * @param[in] regs Device's I/O registers range.
     150 * @param[in] regs Device's resources
    151151 * @param[in] interrupts True if w interrupts should be used
    152152 * @return Error code
    153153 */
    154 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
    155 {
    156         assert(instance);
    157 
    158         int ret = pio_enable_range(regs, (void **) &instance->registers);
     154int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts)
     155{
     156        assert(instance);
     157        assert(hw_res);
     158        if (hw_res->mem_ranges.count != 1 ||
     159            hw_res->mem_ranges.ranges[0].size < sizeof(ohci_regs_t))
     160            return EINVAL;
     161
     162        int ret = pio_enable_range(&hw_res->mem_ranges.ranges[0],
     163            (void **) &instance->registers);
    159164        if (ret != EOK) {
    160                 usb_log_error("Failed to gain access to device registers: %s.\n",
     165                usb_log_error("Failed to gain access to registers: %s.\n",
    161166                    str_error(ret));
    162167                return ret;
    163168        }
     169        usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.\n",
     170            hw_res->mem_ranges.ranges[0].address.absolute,
     171            hw_res->mem_ranges.ranges[0].size);
    164172
    165173        list_initialize(&instance->pending_batches);
     
    186194        return EOK;
    187195}
     196
     197/** Safely dispose host controller internal structures
     198 *
     199 * @param[in] instance Host controller structure to use.
     200 */
     201void hc_fini(hc_t *instance)
     202{
     203        assert(instance);
     204        /* TODO: implement*/
     205};
    188206
    189207void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep)
  • uspace/drv/bus/usb/ohci/hc.h

    rd1df381 r7813516  
    7777int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res);
    7878int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
    79 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts);
    80 
    81 /** Safely dispose host controller internal structures
    82  *
    83  * @param[in] instance Host controller structure to use.
    84  */
    85 static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ };
     79int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts);
     80void hc_fini(hc_t *instance);
    8681
    8782void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep);
  • uspace/drv/bus/usb/ohci/ohci.c

    rd1df381 r7813516  
    8787        hw_res_list_parsed_t hw_res;
    8888        int ret = hcd_ddf_get_registers(device, &hw_res);
    89         if (ret != EOK ||
    90             hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) {
     89        if (ret != EOK) {
    9190                usb_log_error("Failed to get register memory addresses "
    9291                    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
     
    9493                return ret;
    9594        }
    96         addr_range_t regs = hw_res.mem_ranges.ranges[0];
    9795
    9896        /* Initialize generic HCD driver */
     
    127125
    128126        /* Initialize OHCI HC */
    129         ret = hc_init(hc, &regs, interrupts);
     127        ret = hc_init(hc, &hw_res, interrupts);
    130128        hw_res_list_parsed_clean(&hw_res);
    131129        if (ret != EOK) {
  • uspace/drv/bus/usb/uhci/hc.c

    rd1df381 r7813516  
    212212 * interrupt fibrils.
    213213 */
    214 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
    215 {
    216         assert(instance);
    217         assert(regs);
    218         assert(regs->size >= sizeof(uhci_regs_t));
     214int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interrupts)
     215{
     216        assert(instance);
     217        assert(hw_res);
     218        if (hw_res->io_ranges.count != 1 ||
     219            hw_res->io_ranges.ranges[0].size < sizeof(uhci_regs_t))
     220            return EINVAL;
    219221
    220222        instance->hw_interrupts = interrupts;
     
    222224
    223225        /* allow access to hc control registers */
    224         uhci_regs_t *io;
    225         int ret = pio_enable_range(regs, (void **) &io);
     226        int ret = pio_enable_range(&hw_res->io_ranges.ranges[0],
     227            (void **) &instance->registers);
    226228        if (ret != EOK) {
    227                 usb_log_error("Failed to gain access to registers at %p: %s.\n",
    228                     io, str_error(ret));
     229                usb_log_error("Failed to gain access to registers: %s.\n",
     230                    str_error(ret));
    229231                return ret;
    230232        }
    231         instance->registers = io;
    232 
    233         usb_log_debug(
    234             "Device registers at %p (%zuB) accessible.\n", io, regs->size);
     233
     234        usb_log_debug("Device registers at %" PRIx64 " (%zuB) accessible.\n",
     235            hw_res->io_ranges.ranges[0].address.absolute,
     236            hw_res->io_ranges.ranges[0].size);
    235237
    236238        ret = hc_init_mem_structures(instance);
     
    253255
    254256        return EOK;
     257}
     258
     259/** Safely dispose host controller internal structures
     260 *
     261 * @param[in] instance Host controller structure to use.
     262 */
     263void hc_fini(hc_t *instance)
     264{
     265        assert(instance);
     266        //TODO Implement
    255267}
    256268
  • uspace/drv/bus/usb/uhci/hc.h

    rd1df381 r7813516  
    129129int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res);
    130130void hc_interrupt(hc_t *instance, uint16_t status);
    131 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts);
     131int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interupts);
     132void hc_fini(hc_t *instance);
    132133int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
    133134
    134 /** Safely dispose host controller internal structures
    135  *
    136  * @param[in] instance Host controller structure to use.
    137  */
    138 static inline void hc_fini(hc_t *instance) {} /* TODO: implement*/
    139135#endif
    140136
  • uspace/drv/bus/usb/uhci/uhci.c

    rd1df381 r7813516  
    8989        hw_res_list_parsed_t hw_res;
    9090        int ret = hcd_ddf_get_registers(device, &hw_res);
    91         if (ret != EOK ||
    92             hw_res.irqs.count != 1 || hw_res.io_ranges.count != 1) {
     91        if (ret != EOK) {
    9392                usb_log_error("Failed to get register memory addresses "
    9493                    "for %" PRIun ": %s.\n", ddf_dev_get_handle(device),
     
    9695                return ret;
    9796        }
    98         addr_range_t regs = hw_res.io_ranges.ranges[0];
    9997
    10098        ret = hcd_ddf_setup_hc(device, USB_SPEED_FULL,
     
    125123        }
    126124
    127         ret = hc_init(hc, &regs, interrupts);
     125        ret = hc_init(hc, &hw_res, interrupts);
    128126        hw_res_list_parsed_clean(&hw_res);
    129127        if (ret != EOK) {
    130128                usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(ret));
    131129                goto irq_unregister;
    132                 // TODO This is unfortunate, we have neither legacy nor real USB
    133130        }
    134131
Note: See TracChangeset for help on using the changeset viewer.