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

Changeset e26a9d95 in mainline


Ignore:
Timestamp:
2014-01-18T17:14:42Z (8 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
3e200736
Parents:
19b3cc6
Message:

libusbhost: Add status hook.

Implement in UHCI, OHCI

Location:
uspace
Files:
9 edited

Legend:

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

    r19b3cc6 re26a9d95  
    6464                return ENOMEM;
    6565
    66         const int ret =  hc_init(instance, res, irq);
     66        const int ret = hc_init(instance, res, irq);
    6767        if (ret == EOK)
    6868                hcd_set_implementation(hcd, instance, hc_schedule,
    69                     NULL, NULL, ehci_interrupt);
     69                    NULL, NULL, ehci_interrupt, NULL);
    7070        return ret;
    7171}
     
    7878
    7979        free(hcd->driver.data);
    80         hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL);
     80        hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL, NULL);
    8181}
    8282
  • uspace/drv/bus/usb/ohci/hc.c

    r19b3cc6 re26a9d95  
    273273}
    274274
     275int hc_status(hcd_t *hcd, uint32_t *status)
     276{
     277        assert(hcd);
     278        assert(status);
     279        hc_t *instance = hcd->driver.data;
     280        assert(instance);
     281
     282        async_usleep(10000);
     283        if (instance->registers){
     284                *status = OHCI_RD(instance->registers->interrupt_status);
     285                OHCI_WR(instance->registers->interrupt_status, *status);
     286        }
     287        return EOK;
     288}
     289
    275290/** Add USB transfer to the schedule.
    276291 *
  • uspace/drv/bus/usb/ohci/hc.h

    r19b3cc6 re26a9d95  
    8383void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep);
    8484int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
     85int hc_status(hcd_t *hcd, uint32_t *status);
    8586
    8687void hc_interrupt(hc_t *instance, uint32_t status);
  • uspace/drv/bus/usb/ohci/main.c

    r19b3cc6 re26a9d95  
    6666        if (ret == EOK)
    6767                hcd_set_implementation(hcd, instance, hc_schedule,
    68                     ohci_endpoint_init, ohci_endpoint_fini, ohci_interrupt);
     68                    ohci_endpoint_init, ohci_endpoint_fini, ohci_interrupt,
     69                    hc_status);
    6970        return ret;
    7071}
     
    7778
    7879        free(hcd->driver.data);
    79         hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL);
     80        hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL, NULL);
    8081}
    8182
  • uspace/drv/bus/usb/uhci/hc.c

    r19b3cc6 re26a9d95  
    412412}
    413413
     414int hc_status(hcd_t *hcd, uint32_t *status)
     415{
     416        assert(hcd);
     417        assert(status);
     418        hc_t *instance = hcd->driver.data;
     419        assert(instance);
     420
     421        *status = 0;
     422        if (instance->registers) {
     423                uint16_t s = pio_read_16(&instance->registers->usbsts);
     424                pio_write_16(&instance->registers->usbsts, s);
     425                *status = s;
     426        }
     427        return EOK;
     428}
     429
    414430/** Schedule batch for execution.
    415431 *
  • uspace/drv/bus/usb/uhci/hc.h

    r19b3cc6 re26a9d95  
    127127} hc_t;
    128128
    129 int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res);
    130 void hc_interrupt(hc_t *instance, uint16_t status);
    131129int hc_init(hc_t *instance, const hw_res_list_parsed_t *hw_res, bool interupts);
    132130void hc_fini(hc_t *instance);
     131int hc_gen_irq_code(irq_code_t *code, const hw_res_list_parsed_t *hw_res);
     132
     133void hc_interrupt(hc_t *instance, uint16_t status);
     134int hc_status(hcd_t *hcd, uint32_t *status);
    133135int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
    134136
  • uspace/drv/bus/usb/uhci/main.c

    r19b3cc6 re26a9d95  
    6868        if (ret == EOK)
    6969                hcd_set_implementation(hcd, instance, hc_schedule, NULL, NULL,
    70                     uhci_interrupt);
     70                    uhci_interrupt, hc_status);
    7171        return ret;
    7272}
     
    7979
    8080        free(hcd->driver.data);
    81         hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL);
     81        hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL, NULL);
    8282}
    8383
  • uspace/drv/bus/usb/vhc/main.c

    r19b3cc6 re26a9d95  
    9595        }
    9696
    97         hcd_set_implementation(dev_to_hcd(dev), data, vhc_schedule, NULL, NULL, NULL);
     97        hcd_set_implementation(dev_to_hcd(dev), data, vhc_schedule, NULL, NULL, NULL, NULL);
    9898
    9999        /* Add virtual hub device */
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r19b3cc6 re26a9d95  
    5252typedef void (*ep_remove_hook_t)(hcd_t *, endpoint_t *);
    5353typedef void (*interrupt_hook_t)(hcd_t *, uint32_t);
     54typedef int (*status_hook_t)(hcd_t *, uint32_t *);
    5455
    5556typedef struct {
     
    6465        /** Hook to be called on device interrupt, passes ARG1 */
    6566        interrupt_hook_t irq_hook;
     67        /** Periodic polling hook */
     68        status_hook_t status_hook;
    6669} hc_driver_t;
    6770
     
    8083static inline void hcd_set_implementation(hcd_t *hcd, void *data,
    8184    schedule_hook_t schedule, ep_add_hook_t add_hook, ep_remove_hook_t rem_hook,
    82     interrupt_hook_t irq_hook)
     85    interrupt_hook_t irq_hook, status_hook_t status_hook)
    8386{
    8487        assert(hcd);
     
    8891        hcd->driver.ep_remove_hook = rem_hook;
    8992        hcd->driver.irq_hook = irq_hook;
     93        hcd->driver.status_hook = status_hook;
    9094}
    9195
Note: See TracChangeset for help on using the changeset viewer.