Changes in uspace/drv/ohci/hc.c [9ff5ff82:049eb87] in mainline


Ignore:
File:
1 edited

Legend:

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

    r9ff5ff82 r049eb87  
    4747static void hc_gain_control(hc_t *instance);
    4848static void hc_init_hw(hc_t *instance);
    49 static int hc_init_transfer_lists(hc_t *instance);
    50 static int hc_init_memory(hc_t *instance);
    5149/*----------------------------------------------------------------------------*/
    5250int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun)
     
    6159            &instance->manager, hub_address, hub_fun->handle);
    6260
    63         endpoint_t *ep = malloc(sizeof(endpoint_t));
    64         assert(ep);
    65         int ret = endpoint_init(ep, hub_address, 0, USB_DIRECTION_BOTH,
    66             USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64);
    67         assert(ret == EOK);
    68         ret = usb_endpoint_manager_register_ep(&instance->ep_manager, ep, 0);
    69         assert(ret == EOK);
    70 
    7161        char *match_str = NULL;
    72         ret = asprintf(&match_str, "usb&class=hub");
    73 //      ret = (match_str == NULL) ? ret : EOK;
     62        int ret = asprintf(&match_str, "usb&class=hub");
     63        ret = (match_str == NULL) ? ret : EOK;
    7464        if (ret < 0) {
    75                 usb_log_error(
    76                     "Failed(%d) to create root hub match-id string.\n", ret);
     65                usb_log_error("Failed to create root hub match-id string.\n");
    7766                return ret;
    7867        }
     
    118107        rh_init(&instance->rh, dev, instance->registers);
    119108
    120         hc_init_memory(instance);
    121109        hc_init_hw(instance);
    122110
     
    129117        assert(instance);
    130118        assert(batch);
    131 
    132         /* check for root hub communication */
    133119        if (batch->target.address == instance->rh.address) {
    134120                return rh_request(&instance->rh, batch);
    135121        }
    136 
    137         transfer_list_add_batch(
    138             instance->transfers[batch->transfer_type], batch);
    139 
    140         switch (batch->transfer_type) {
    141         case USB_TRANSFER_CONTROL:
    142                 instance->registers->command_status |= CS_CLF;
    143                 break;
    144         case USB_TRANSFER_BULK:
    145                 instance->registers->command_status |= CS_BLF;
    146                 break;
    147         default:
    148                 break;
    149         }
    150         return EOK;
     122        /* TODO: implement */
     123        return ENOTSUP;
    151124}
    152125/*----------------------------------------------------------------------------*/
     
    161134        usb_log_info("OHCI interrupt: %x.\n", status);
    162135
    163         LIST_INITIALIZE(done);
    164         transfer_list_remove_finished(&instance->transfers_interrupt, &done);
    165         transfer_list_remove_finished(&instance->transfers_isochronous, &done);
    166         transfer_list_remove_finished(&instance->transfers_control, &done);
    167         transfer_list_remove_finished(&instance->transfers_bulk, &done);
    168 
    169         while (!list_empty(&done)) {
    170                 link_t *item = done.next;
    171                 list_remove(item);
    172                 usb_transfer_batch_t *batch =
    173                     list_get_instance(item, usb_transfer_batch_t, link);
    174                 usb_transfer_batch_finish(batch);
    175         }
     136        /* TODO: Check for further interrupt causes */
     137        /* TODO: implement */
    176138}
    177139/*----------------------------------------------------------------------------*/
     
    235197        assert(instance);
    236198        const uint32_t fm_interval = instance->registers->fm_interval;
    237 
    238         /* reset hc */
    239199        instance->registers->command_status = CS_HCR;
    240200        async_usleep(10);
    241 
    242         /* restore fm_interval */
    243201        instance->registers->fm_interval = fm_interval;
    244202        assert((instance->registers->command_status & CS_HCR) == 0);
    245 
    246203        /* hc is now in suspend state */
    247 
    248         /* enable queues */
    249         instance->registers->control |= (C_PLE | C_IE | C_CLE | C_BLE);
     204        /* TODO: init HCCA block */
     205        /* TODO: init queues */
     206        /* TODO: enable queues */
    250207        /* TODO: enable interrupts */
    251         /* set periodic start to 90% */
    252         instance->registers->periodic_start = (fm_interval / 10) * 9;
     208        /* TODO: set periodic start to 90% */
    253209
    254210        instance->registers->control &= (C_HCFS_OPERATIONAL << C_HCFS_SHIFT);
    255211        usb_log_info("OHCI HC up and running.\n");
    256212}
    257 /*----------------------------------------------------------------------------*/
    258 int hc_init_transfer_lists(hc_t *instance)
    259 {
    260         assert(instance);
    261 
    262 #define SETUP_TRANSFER_LIST(type, name) \
    263 do { \
    264         int ret = transfer_list_init(&instance->type, name); \
    265         if (ret != EOK) { \
    266                 usb_log_error("Failed(%d) to setup %s transfer list.\n", \
    267                     ret, name); \
    268                 transfer_list_fini(&instance->transfers_isochronous); \
    269                 transfer_list_fini(&instance->transfers_interrupt); \
    270                 transfer_list_fini(&instance->transfers_control); \
    271                 transfer_list_fini(&instance->transfers_bulk); \
    272         } \
    273 } while (0)
    274 
    275         SETUP_TRANSFER_LIST(transfers_isochronous, "ISOCHRONOUS");
    276         SETUP_TRANSFER_LIST(transfers_interrupt, "INTERRUPT");
    277         SETUP_TRANSFER_LIST(transfers_control, "CONTROL");
    278         SETUP_TRANSFER_LIST(transfers_bulk, "BULK");
    279 
    280         transfer_list_set_next(&instance->transfers_interrupt,
    281             &instance->transfers_isochronous);
    282 
    283         /* Assign pointers to be used during scheduling */
    284         instance->transfers[USB_TRANSFER_INTERRUPT] =
    285           &instance->transfers_interrupt;
    286         instance->transfers[USB_TRANSFER_ISOCHRONOUS] =
    287           &instance->transfers_interrupt;
    288         instance->transfers[USB_TRANSFER_CONTROL] =
    289           &instance->transfers_control;
    290         instance->transfers[USB_TRANSFER_BULK] =
    291           &instance->transfers_bulk;
    292 
    293         return EOK;
    294 #undef CHECK_RET_CLEAR_RETURN
    295 }
    296 /*----------------------------------------------------------------------------*/
    297 int hc_init_memory(hc_t *instance)
    298 {
    299         assert(instance);
    300         /* init queues */
    301         hc_init_transfer_lists(instance);
    302 
    303         /* init HCCA */
    304         instance->hcca = malloc32(sizeof(hcca_t));
    305         if (instance->hcca == NULL)
    306                 return ENOMEM;
    307         bzero(instance->hcca, sizeof(hcca_t));
    308         instance->registers->hcca = addr_to_phys(instance->hcca);
    309 
    310         /* use queues */
    311         instance->registers->bulk_head = instance->transfers_bulk.list_head_pa;
    312         instance->registers->control_head =
    313             instance->transfers_control.list_head_pa;
    314 
    315         unsigned i = 0;
    316         for (; i < 32; ++i) {
    317                 instance->hcca->int_ep[i] =
    318                     instance->transfers_interrupt.list_head_pa;
    319         }
    320 
    321         return EOK;
    322 }
    323213/**
    324214 * @}
Note: See TracChangeset for help on using the changeset viewer.