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

Changeset 26858040 in mainline


Ignore:
Timestamp:
2011-07-12T18:53:14Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
408d3c9
Parents:
dfe4955
Message:

UHCI: Remove old way of generating irq code. Reshuffle initialization.

Location:
uspace/drv/bus/usb/uhci
Files:
2 edited

Legend:

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

    rdfe4955 r26858040  
    126126        uhci_regs_t *io;
    127127        ret = pio_enable(regs, reg_size, (void **)&io);
    128         CHECK_RET_RETURN(ret,
    129             "Failed(%d) to gain access to registers at %p: %s.\n",
    130             ret, io, str_error(ret));
     128        CHECK_RET_RETURN(ret, "Failed to gain access to registers at %p: %s.\n",
     129            io, str_error(ret));
    131130        instance->registers = io;
    132         usb_log_debug("Device registers at %p (%zuB) accessible.\n",
    133             io, reg_size);
     131        usb_log_debug(
     132            "Device registers at %p (%zuB) accessible.\n", io, reg_size);
    134133
    135134        ret = hc_init_mem_structures(instance);
    136135        CHECK_RET_RETURN(ret,
    137             "Failed(%d) to initialize UHCI memory structures: %s.\n",
    138             ret, str_error(ret));
     136            "Failed to initialize UHCI memory structures: %s.\n",
     137            str_error(ret));
    139138
    140139        hc_init_hw(instance);
     
    162161        /* Reset everything, who knows what touched it before us */
    163162        pio_write_16(&registers->usbcmd, UHCI_CMD_GLOBAL_RESET);
    164         async_usleep(10000); /* 10ms according to USB spec */
     163        async_usleep(50000); /* 50ms according to USB spec(root hub reset) */
    165164        pio_write_16(&registers->usbcmd, 0);
    166165
    167         /* Reset hc, all states and counters */
     166        /* Reset hc, all states and counters. Hope that hw is not broken */
    168167        pio_write_16(&registers->usbcmd, UHCI_CMD_HCRESET);
    169168        do { async_usleep(10); }
     
    183182        }
    184183
    185         const uint16_t status = pio_read_16(&registers->usbcmd);
    186         if (status != 0)
    187                 usb_log_warning("Previous command value: %x.\n", status);
     184        const uint16_t cmd = pio_read_16(&registers->usbcmd);
     185        if (cmd != 0)
     186                usb_log_warning("Previous command value: %x.\n", cmd);
    188187
    189188        /* Start the hc with large(64B) packet FSBR */
     
    212211        } else (void) 0
    213212
    214         /* Init interrupt code */
    215         instance->interrupt_code.cmds = instance->interrupt_commands;
    216         {
    217                 /* Read status register */
    218                 instance->interrupt_commands[0].cmd = CMD_PIO_READ_16;
    219                 instance->interrupt_commands[0].dstarg = 1;
    220                 instance->interrupt_commands[0].addr =
    221                     &instance->registers->usbsts;
    222 
    223                 /* Test whether we are the interrupt cause */
    224                 instance->interrupt_commands[1].cmd = CMD_BTEST;
    225                 instance->interrupt_commands[1].value =
    226                     UHCI_STATUS_USED_INTERRUPTS | UHCI_STATUS_NM_INTERRUPTS;
    227                 instance->interrupt_commands[1].srcarg = 1;
    228                 instance->interrupt_commands[1].dstarg = 2;
    229 
    230                 /* Predicate cleaning and accepting */
    231                 instance->interrupt_commands[2].cmd = CMD_PREDICATE;
    232                 instance->interrupt_commands[2].value = 2;
    233                 instance->interrupt_commands[2].srcarg = 2;
    234 
    235                 /* Write clean status register */
    236                 instance->interrupt_commands[3].cmd = CMD_PIO_WRITE_A_16;
    237                 instance->interrupt_commands[3].srcarg = 1;
    238                 instance->interrupt_commands[3].addr =
    239                     &instance->registers->usbsts;
    240 
    241                 /* Accept interrupt */
    242                 instance->interrupt_commands[4].cmd = CMD_ACCEPT;
    243 
    244                 instance->interrupt_code.cmdcount = UHCI_NEEDED_IRQ_COMMANDS;
    245         }
    246 
    247213        /* Init transfer lists */
    248214        int ret = hc_init_transfer_lists(instance);
    249         CHECK_RET_RETURN(ret, "Failed to init transfer lists.\n");
     215        CHECK_RET_RETURN(ret, "Failed to initialize transfer lists.\n");
    250216        usb_log_debug("Initialized transfer lists.\n");
    251 
    252         /* Init USB frame list page*/
    253         instance->frame_list = get_page();
    254         ret = instance->frame_list ? EOK : ENOMEM;
    255         CHECK_RET_RETURN(ret, "Failed to get frame list page.\n");
    256         usb_log_debug("Initialized frame list at %p.\n", instance->frame_list);
    257 
    258         /* Set all frames to point to the first queue head */
    259         const uint32_t queue = LINK_POINTER_QH(
    260                 addr_to_phys(instance->transfers_interrupt.queue_head));
    261 
    262         unsigned i = 0;
    263         for(; i < UHCI_FRAME_LIST_COUNT; ++i) {
    264                 instance->frame_list[i] = queue;
    265         }
    266217
    267218        /* Init device keeper */
    268219        usb_device_keeper_init(&instance->manager);
    269         usb_log_debug("Initialized device manager.\n");
     220        usb_log_debug("Initialized device keeper.\n");
    270221
    271222        ret = usb_endpoint_manager_init(&instance->ep_manager,
     
    274225            str_error(ret));
    275226
     227        /* Init USB frame list page*/
     228        instance->frame_list = get_page();
     229        if (!instance->frame_list) {
     230                usb_log_error("Failed to get frame list page.\n");
     231                usb_endpoint_manager_destroy(&instance->ep_manager);
     232                return ENOMEM;
     233        }
     234        usb_log_debug("Initialized frame list at %p.\n", instance->frame_list);
     235
     236        /* Set all frames to point to the first queue head */
     237        const uint32_t queue = LINK_POINTER_QH(
     238                addr_to_phys(instance->transfers_interrupt.queue_head));
     239        unsigned i = 0;
     240        for(; i < UHCI_FRAME_LIST_COUNT; ++i) {
     241                instance->frame_list[i] = queue;
     242        }
     243
    276244        return EOK;
    277245#undef CHECK_RET_RETURN
     
    294262        int ret = transfer_list_init(&instance->transfers_##type, name); \
    295263        if (ret != EOK) { \
    296                 usb_log_error("Failed(%d) to setup %s transfer list: %s.\n", \
    297                     ret, name, str_error(ret)); \
     264                usb_log_error("Failed to setup %s transfer list: %s.\n", \
     265                    name, str_error(ret)); \
    298266                transfer_list_fini(&instance->transfers_bulk_full); \
    299267                transfer_list_fini(&instance->transfers_control_full); \
  • uspace/drv/bus/usb/uhci/hc.h

    rdfe4955 r26858040  
    116116        /** Pointer table to the above lists, helps during scheduling */
    117117        transfer_list_t *transfers[2][4];
    118 
    119         /** Code to be executed in kernel interrupt handler */
    120         irq_code_t interrupt_code;
    121 
    122         /** Commands that form interrupt code */
    123         irq_cmd_t interrupt_commands[UHCI_NEEDED_IRQ_COMMANDS];
    124 
    125118        /** Fibril periodically checking status register*/
    126119        fid_t interrupt_emulator;
    127 
    128120        /** Indicator of hw interrupts availability */
    129121        bool hw_interrupts;
Note: See TracChangeset for help on using the changeset viewer.