Changeset 36a4738 in mainline


Ignore:
Timestamp:
2011-02-16T21:30:43Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
30a4301
Parents:
9013ad3
Message:

Add interrupt registration and debug

Location:
uspace/drv/uhci-hcd
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/main.c

    r9013ad3 r36a4738  
    4646#define NAME "uhci-hcd"
    4747
     48static int uhci_add_device(device_t *device);
     49static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle);
     50/*----------------------------------------------------------------------------*/
    4851static int usb_iface_get_hc_handle(device_t *dev, devman_handle_t *handle)
    4952{
     
    5457        return EOK;
    5558}
    56 
     59/*----------------------------------------------------------------------------*/
    5760static usb_iface_t hc_usb_iface = {
    5861        .get_hc_handle = usb_iface_get_hc_handle
    5962};
    60 
     63/*----------------------------------------------------------------------------*/
    6164static device_ops_t uhci_ops = {
    6265        .interfaces[USB_DEV_IFACE] = &hc_usb_iface,
    6366        .interfaces[USBHC_DEV_IFACE] = &uhci_iface
    6467};
    65 
     68/*----------------------------------------------------------------------------*/
     69static driver_ops_t uhci_driver_ops = {
     70        .add_device = uhci_add_device,
     71};
     72/*----------------------------------------------------------------------------*/
     73static driver_t uhci_driver = {
     74        .name = NAME,
     75        .driver_ops = &uhci_driver_ops
     76};
     77/*----------------------------------------------------------------------------*/
     78static void irq_handler(device_t *dev, ipc_callid_t iid, ipc_call_t *call)
     79{
     80        usb_log_error("LOL interrupt %x %x.\n", iid, call);
     81}
     82/*----------------------------------------------------------------------------*/
    6683static int uhci_add_device(device_t *device)
    6784{
     
    7592        int irq;
    7693
    77         int rc = pci_get_my_registers(device,
     94        int ret = pci_get_my_registers(device,
    7895            &io_reg_base, &io_reg_size, &irq);
    7996
    80         if (rc != EOK) {
     97        if (ret != EOK) {
    8198                usb_log_error("Failed(%d) to get I/O registers addresses for device:.\n",
    82                     rc, device->handle);
    83                 return rc;
     99                    ret, device->handle);
     100                return ret;
    84101        }
    85102
     
    89106        uhci_t *uhci_hc = malloc(sizeof(uhci_t));
    90107        if (!uhci_hc) {
    91                 usb_log_error("Failed to allocaete memory for uhci hcd driver.\n");
     108                usb_log_error("Failed to allocate memory for uhci hcd driver.\n");
    92109                return ENOMEM;
    93110        }
    94111
    95         int ret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size);
     112        ret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size);
    96113        if (ret != EOK) {
    97114                usb_log_error("Failed to init uhci-hcd.\n");
     
    100117        device_t *rh;
    101118        ret = setup_root_hub(&rh, device);
    102 
    103119        if (ret != EOK) {
    104120                usb_log_error("Failed to setup uhci root hub.\n");
     
    116132        device->driver_data = uhci_hc;
    117133
     134        ret = register_interrupt_handler(device, irq, irq_handler, NULL);
     135        usb_log_error("registered interrupt handler %d.\n", ret);
     136
    118137        return EOK;
    119138}
    120 
    121 static driver_ops_t uhci_driver_ops = {
    122         .add_device = uhci_add_device,
    123 };
    124 
    125 static driver_t uhci_driver = {
    126         .name = NAME,
    127         .driver_ops = &uhci_driver_ops
    128 };
    129 
     139/*----------------------------------------------------------------------------*/
    130140int main(int argc, char *argv[])
    131141{
    132         /*
    133          * Do some global initializations.
    134          */
    135         sleep(5);
    136         usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
     142        sleep(3);
     143        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    137144
    138145        return driver_main(&uhci_driver);
  • uspace/drv/uhci-hcd/transfer_list.c

    r9013ad3 r36a4738  
    111111        /* I'm the first one here */
    112112        if (batch->link.prev == &instance->batch_list) {
    113                 usb_log_debug("Removing tracer %p was first, next element %x.\n",
     113                usb_log_debug("Removing batch %p was first, next element %x.\n",
    114114                        batch, batch->qh->next_queue);
    115115                instance->queue_head->element = batch->qh->next_queue;
    116116        } else {
    117                 usb_log_debug("Removing tracer %p was NOT first, next element %x.\n",
     117                usb_log_debug("Removing batch %p was NOT first, next element %x.\n",
    118118                        batch, batch->qh->next_queue);
    119119                batch_t *prev = list_get_instance(batch->link.prev, batch_t, link);
  • uspace/drv/uhci-hcd/uhci.c

    r9013ad3 r36a4738  
    8282void uhci_init_hw(uhci_t *instance)
    8383{
    84         const uintptr_t pa = (uintptr_t)addr_to_phys(instance->frame_list);
    85         pio_write_32(&instance->registers->flbaseadd, (uint32_t)pa);
     84        const uint32_t pa = addr_to_phys(instance->frame_list);
     85        pio_write_32(&instance->registers->flbaseadd, pa);
     86
     87        /* enable all interrupts */
     88        pio_write_16(&instance->registers->usbintr,
     89                  UHCI_INTR_CRC | UHCI_INTR_COMPLETE | UHCI_INTR_SHORT_PACKET);
    8690
    8791        /* Start the hc with large(64B) packet FSBR */
     
    206210        assert(instance);
    207211        while (1) {
    208                 uint16_t cmd = pio_read_16(&instance->registers->usbcmd);
    209                 uint16_t sts = pio_read_16(&instance->registers->usbsts);
    210                 usb_log_debug("Command register: %X Status register: %X\n", cmd, sts);
     212                const uint16_t cmd = pio_read_16(&instance->registers->usbcmd);
     213                const uint16_t sts = pio_read_16(&instance->registers->usbsts);
     214                const uint16_t intr = pio_read_16(&instance->registers->usbintr);
     215                usb_log_debug("Command: %X Status: %X Interrupts: %x\n",
     216                    cmd, sts, intr);
    211217
    212218                uintptr_t frame_list = pio_read_32(&instance->registers->flbaseadd);
  • uspace/drv/uhci-hcd/uhci.h

    r9013ad3 r36a4738  
    6666
    6767        uint16_t usbintr;
     68#define UHCI_INTR_SHORT_PACKET (1 << 3)
     69#define UHCI_INTR_COMPLETE (1 << 2)
     70#define UHCI_INTR_RESUME (1 << 1)
     71#define UHCI_INTR_CRC (1 << 0)
     72
    6873        uint16_t frnum;
    6974        uint32_t flbaseadd;
Note: See TracChangeset for help on using the changeset viewer.