Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b5111c46 in mainline


Ignore:
Timestamp:
2014-07-23T21:38:25Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
ffa96c2
Parents:
87a3df7f
Message:

Convert OHCI and UHCI away from DDF_DATA_IMPLANT.

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

Legend:

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

    r87a3df7f rb5111c46  
    193193        instance->rh.address = 1;
    194194        rc = usb_device_manager_request_address(
    195             &instance->generic.dev_manager, &instance->rh.address, false,
     195            &instance->generic->dev_manager, &instance->rh.address, false,
    196196            USB_SPEED_FULL);
    197197        if (rc != EOK) {
     
    204204
    205205        rc = usb_endpoint_manager_add_ep(
    206             &instance->generic.ep_manager, instance->rh.address, 0,
     206            &instance->generic->ep_manager, instance->rh.address, 0,
    207207            USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64,
    208208            0, NULL, NULL);
     
    231231        fun_bound = true;
    232232
    233         rc = usb_device_manager_bind_address(&instance->generic.dev_manager,
     233        rc = usb_device_manager_bind_address(&instance->generic->dev_manager,
    234234            instance->rh.address, ddf_fun_get_handle(hub_fun));
    235235        if (rc != EOK) {
     
    244244        if (ep_added) {
    245245                usb_endpoint_manager_remove_ep(
    246                     &instance->generic.ep_manager, instance->rh.address, 0,
     246                    &instance->generic->ep_manager, instance->rh.address, 0,
    247247                    USB_DIRECTION_BOTH, NULL, NULL);
    248248        }
    249249        if (addr_reqd) {
    250250                usb_device_manager_release_address(
    251                     &instance->generic.dev_manager, instance->rh.address);
     251                    &instance->generic->dev_manager, instance->rh.address);
    252252        }
    253253        return rc;
     
    257257 *
    258258 * @param[in] instance Memory place for the structure.
     259 * @param[in] HC function node
    259260 * @param[in] regs Device's I/O registers range.
    260261 * @param[in] interrupts True if w interrupts should be used
    261262 * @return Error code
    262263 */
    263 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
     264int hc_init(hc_t *instance, ddf_fun_t *fun, addr_range_t *regs, bool interrupts)
    264265{
    265266        assert(instance);
     
    274275        list_initialize(&instance->pending_batches);
    275276
    276         hcd_init(&instance->generic, USB_SPEED_FULL,
     277        instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t));
     278        if (instance->generic == NULL) {
     279                usb_log_error("Out of memory.\n");
     280                return ENOMEM;
     281        }
     282
     283        hcd_init(instance->generic, USB_SPEED_FULL,
    277284            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    278         instance->generic.private_data = instance;
    279         instance->generic.schedule = hc_schedule;
    280         instance->generic.ep_add_hook = ohci_endpoint_init;
    281         instance->generic.ep_remove_hook = ohci_endpoint_fini;
     285        instance->generic->private_data = instance;
     286        instance->generic->schedule = hc_schedule;
     287        instance->generic->ep_add_hook = ohci_endpoint_init;
     288        instance->generic->ep_remove_hook = ohci_endpoint_fini;
    282289
    283290        rc = hc_init_memory(instance);
  • uspace/drv/bus/usb/ohci/hc.h

    r87a3df7f rb5111c46  
    3535#define DRV_OHCI_HC_H
    3636
     37#include <ddf/driver.h>
    3738#include <ddf/interrupt.h>
    3839#include <fibril.h>
     
    5354typedef struct hc {
    5455        /** Generic USB hc driver */
    55         hcd_t generic;
     56        hcd_t *generic;
    5657
    5758        /** Memory mapped I/O registers area */
     
    7980int hc_register_irq_handler(ddf_dev_t *, addr_range_t *, int,
    8081    interrupt_handler_t);
    81 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
    82 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts);
     82int hc_register_hub(hc_t *, ddf_fun_t *);
     83int hc_init(hc_t *, ddf_fun_t *, addr_range_t *, bool);
    8384
    8485/** Safely dispose host controller internal structures
  • uspace/drv/bus/usb/ohci/ohci.c

    r87a3df7f rb5111c46  
    3434 */
    3535
    36 /* XXX Fix this */
    37 #define _DDF_DATA_IMPLANT
    38 
    3936#include <errno.h>
    4037#include <str_error.h>
     
    165162
    166163        ddf_fun_set_ops(instance->hc_fun, &hc_ops);
    167         ddf_fun_data_implant(instance->hc_fun, &instance->hc);
    168164
    169165        instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh");
     
    214210        }
    215211
    216         rc = hc_init(&instance->hc, &regs, interrupts);
     212        rc = hc_init(&instance->hc, instance->hc_fun, &regs, interrupts);
    217213        if (rc != EOK) {
    218214                usb_log_error("Failed to init ohci_hcd: %s.\n", str_error(rc));
  • uspace/drv/bus/usb/uhci/hc.c

    r87a3df7f rb5111c46  
    230230 *
    231231 * @param[in] instance Memory place to initialize.
     232 * @param[in] HC function node
    232233 * @param[in] regs Range of device's I/O control registers.
    233234 * @param[in] interrupts True if hw interrupts should be used.
     
    238239 * interrupt fibrils.
    239240 */
    240 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts)
     241int hc_init(hc_t *instance, ddf_fun_t *fun, addr_range_t *regs, bool interrupts)
    241242{
    242243        assert(regs->size >= sizeof(uhci_regs_t));
     
    266267        }
    267268
    268         hcd_init(&instance->generic, USB_SPEED_FULL,
     269        instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t));
     270        if (instance->generic == NULL) {
     271                usb_log_error("Out of memory.\n");
     272                return ENOMEM;
     273        }
     274
     275        hcd_init(instance->generic, USB_SPEED_FULL,
    269276            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    270277
    271         instance->generic.private_data = instance;
    272         instance->generic.schedule = hc_schedule;
    273         instance->generic.ep_add_hook = NULL;
     278        instance->generic->private_data = instance;
     279        instance->generic->schedule = hc_schedule;
     280        instance->generic->ep_add_hook = NULL;
    274281
    275282        hc_init_hw(instance);
  • uspace/drv/bus/usb/uhci/hc.h

    r87a3df7f rb5111c46  
    3636#define DRV_UHCI_HC_H
    3737
     38#include <ddf/driver.h>
    3839#include <ddf/interrupt.h>
    3940#include <device/hw_res_parsed.h>
     
    9394typedef struct hc {
    9495        /** Generic HCD driver structure */
    95         hcd_t generic;
     96        hcd_t *generic;
    9697
    9798        /** Addresses of I/O registers */
     
    126127    addr_range_t *);
    127128void hc_interrupt(hc_t *instance, uint16_t status);
    128 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts);
     129int hc_init(hc_t *, ddf_fun_t *, addr_range_t *, bool);
    129130
    130131/** Safely dispose host controller internal structures
  • uspace/drv/bus/usb/uhci/uhci.c

    r87a3df7f rb5111c46  
    3434 */
    3535
    36 /* XXX Fix this */
    37 #define _DDF_DATA_IMPLANT
    38 
    3936#include <errno.h>
    4037#include <stdbool.h>
     
    6259        hc_t hc;
    6360        /** Internal driver's representation of UHCI root hub */
    64         rh_t rh;
     61        rh_t *rh;
    6562} uhci_t;
    6663
     
    186183
    187184        ddf_fun_set_ops(instance->hc_fun, &hc_ops);
    188         ddf_fun_data_implant(instance->hc_fun, &instance->hc.generic);
    189185
    190186        instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh");
     
    196192
    197193        ddf_fun_set_ops(instance->rh_fun, &rh_ops);
    198         ddf_fun_data_implant(instance->rh_fun, &instance->rh);
     194        instance->rh = ddf_fun_data_alloc(instance->rh_fun, sizeof(rh_t));
    199195
    200196        addr_range_t regs;
     
    236232        }
    237233
    238         rc = hc_init(&instance->hc, &regs, interrupts);
     234        rc = hc_init(&instance->hc, instance->hc_fun, &regs, interrupts);
    239235        if (rc != EOK) {
    240236                usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(rc));
     
    260256        }
    261257
    262         rc = rh_init(&instance->rh, instance->rh_fun, &regs, 0x10, 4);
     258        rc = rh_init(instance->rh, instance->rh_fun, &regs, 0x10, 4);
    263259        if (rc != EOK) {
    264260                usb_log_error("Failed to setup UHCI root hub: %s.\n",
Note: See TracChangeset for help on using the changeset viewer.