Changeset e05d6c3 in mainline for uspace/drv


Ignore:
Timestamp:
2011-04-15T07:45:26Z (15 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3a85a2b
Parents:
a39cfb8 (diff), e583fd4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge with usb/development

Location:
uspace/drv
Files:
16 edited

Legend:

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

    ra39cfb8 re05d6c3  
    161161                        usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
    162162                            instance, i, data->tds[i]->status);
     163                        /* Make sure TD queue is empty (one TD),
     164                         * ED should be marked as halted */
     165                        data->ed->td_tail =
     166                            (data->ed->td_head & ED_TDTAIL_PTR_MASK);
     167                        ++i;
    163168                        break;
    164169                }
     
    169174        assert(hcd_ep);
    170175        hcd_ep->td = data->tds[i];
     176        /* Clear possible ED HALT */
     177        data->ed->td_head &= ~ED_TDHEAD_HALTED_FLAG;
     178        uint32_t pa = addr_to_phys(hcd_ep->td);
     179        assert(pa == (data->ed->td_head & ED_TDHEAD_PTR_MASK));
     180        assert(pa == (data->ed->td_tail & ED_TDTAIL_PTR_MASK));
    171181
    172182        return true;
  • uspace/drv/ohci/hcd_endpoint.c

    ra39cfb8 re05d6c3  
    3535#include "hcd_endpoint.h"
    3636
     37static void hcd_ep_toggle_set(void *hcd_ep, int toggle)
     38{
     39        hcd_endpoint_t *instance = hcd_ep;
     40        assert(instance);
     41        assert(instance->ed);
     42        ed_toggle_set(instance->ed, toggle);
     43}
     44static int hcd_ep_toggle_get(void *hcd_ep)
     45{
     46        hcd_endpoint_t *instance = hcd_ep;
     47        assert(instance);
     48        assert(instance->ed);
     49        return ed_toggle_get(instance->ed);
     50}
     51
     52
    3753hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep)
    3854{
     
    5773        ed_init(hcd_ep->ed, ep);
    5874        ed_set_td(hcd_ep->ed, hcd_ep->td);
    59         endpoint_set_hc_data(ep, hcd_ep, NULL, NULL);
     75        endpoint_set_hc_data(ep, hcd_ep, hcd_ep_toggle_get, hcd_ep_toggle_set);
    6076
    6177        return hcd_ep;
  • uspace/drv/ohci/hw_struct/endpoint_descriptor.h

    ra39cfb8 re05d6c3  
    7373#define ED_TDHEAD_ZERO_SHIFT (2)
    7474#define ED_TDHEAD_TOGGLE_CARRY (0x2)
     75#define ED_TDHEAD_HALTED_FLAG (0x1)
    7576
    7677        volatile uint32_t next;
     
    106107        instance->next = pa;
    107108}
     109
     110static inline int ed_toggle_get(ed_t *instance)
     111{
     112        assert(instance);
     113        return (instance->td_head & ED_TDHEAD_TOGGLE_CARRY) ? 1 : 0;
     114}
     115
     116static inline void ed_toggle_set(ed_t *instance, int toggle)
     117{
     118        assert(instance);
     119        assert(toggle == 0 || toggle == 1);
     120        if (toggle == 1) {
     121                instance->td_head |= ED_TDHEAD_TOGGLE_CARRY;
     122        } else {
     123                /* clear halted flag when reseting toggle */
     124                instance->td_head &= ~ED_TDHEAD_TOGGLE_CARRY;
     125                instance->td_head &= ~ED_TDHEAD_HALTED_FLAG;
     126        }
     127}
    108128#endif
    109129/**
  • uspace/drv/ohci/ohci_regs.h

    ra39cfb8 re05d6c3  
    5555#define C_HCFS_MASK        (0x3) /* Host controller functional state */
    5656#define C_HCFS_RESET       (0x0)
    57 #define C_HCFS_OPERATIONAL (0x1)
    58 #define C_HCFS_RESUME      (0x2)
     57#define C_HCFS_RESUME      (0x1)
     58#define C_HCFS_OPERATIONAL (0x2)
    5959#define C_HCFS_SUSPEND     (0x3)
    6060#define C_HCFS_SHIFT       (6)
  • uspace/drv/ohci/root_hub.h

    ra39cfb8 re05d6c3  
    5454        /** hubs descriptors */
    5555        usb_device_descriptors_t descriptors;
     56        /** interrupt transfer waiting for an actual interrupt to occur */
     57        usb_transfer_batch_t * unfinished_interrupt_transfer;
    5658} rh_t;
    5759
  • uspace/drv/uhci-hcd/hc.c

    ra39cfb8 re05d6c3  
    247247{
    248248        assert(instance);
    249 #define CHECK_RET_CLEAR_RETURN(ret, message...) \
     249#define SETUP_TRANSFER_LIST(type, name) \
     250do { \
     251        int ret = transfer_list_init(&instance->transfers_##type, name); \
    250252        if (ret != EOK) { \
    251                 usb_log_error(message); \
     253                usb_log_error("Failed(%d) to setup %s transfer list: %s.\n", \
     254                    ret, name, str_error(ret)); \
    252255                transfer_list_fini(&instance->transfers_bulk_full); \
    253256                transfer_list_fini(&instance->transfers_control_full); \
     
    255258                transfer_list_fini(&instance->transfers_interrupt); \
    256259                return ret; \
    257         } else (void) 0
    258 
    259         /* initialize TODO: check errors */
    260         int ret;
    261         ret = transfer_list_init(&instance->transfers_bulk_full, "BULK_FULL");
    262         CHECK_RET_CLEAR_RETURN(ret, "Failed to init BULK list.");
    263 
    264         ret = transfer_list_init(
    265             &instance->transfers_control_full, "CONTROL_FULL");
    266         CHECK_RET_CLEAR_RETURN(ret, "Failed to init CONTROL FULL list.");
    267 
    268         ret = transfer_list_init(
    269             &instance->transfers_control_slow, "CONTROL_SLOW");
    270         CHECK_RET_CLEAR_RETURN(ret, "Failed to init CONTROL SLOW list.");
    271 
    272         ret = transfer_list_init(&instance->transfers_interrupt, "INTERRUPT");
    273         CHECK_RET_CLEAR_RETURN(ret, "Failed to init INTERRUPT list.");
    274 
     260        } \
     261} while (0)
     262
     263        SETUP_TRANSFER_LIST(bulk_full, "BULK FULL");
     264        SETUP_TRANSFER_LIST(control_full, "CONTROL FULL");
     265        SETUP_TRANSFER_LIST(control_slow, "CONTROL LOW");
     266        SETUP_TRANSFER_LIST(interrupt, "INTERRUPT");
     267#undef SETUP_TRANSFER_LIST
     268        /* Connect lists into one schedule */
    275269        transfer_list_set_next(&instance->transfers_control_full,
    276270                &instance->transfers_bulk_full);
     
    337331        assert(instance);
    338332//      status |= 1; //Uncomment to work around qemu hang
    339         /* TODO: Resume interrupts are not supported */
    340333        /* Lower 2 bits are transaction error and transaction complete */
    341         if (status & 0x3) {
     334        if (status & (UHCI_STATUS_INTERRUPT | UHCI_STATUS_ERROR_INTERRUPT)) {
    342335                LIST_INITIALIZE(done);
    343336                transfer_list_remove_finished(
     
    358351                }
    359352        }
    360         /* bits 4 and 5 indicate hc error */
    361         if (status & 0x18) {
     353        /* Resume interrupts are not supported */
     354
     355        /* Bits 4 and 5 indicate hc error */
     356        if (status & (UHCI_STATUS_PROCESS_ERROR | UHCI_STATUS_SYSTEM_ERROR)) {
    362357                usb_log_error("UHCI hardware failure!.\n");
    363358                ++instance->hw_failures;
     
    389384
    390385        while (1) {
    391                 /* read and ack interrupts */
     386                /* Readd and clear status register */
    392387                uint16_t status = pio_read_16(&instance->registers->usbsts);
    393                 pio_write_16(&instance->registers->usbsts, 0x1f);
     388                pio_write_16(&instance->registers->usbsts, status);
    394389                if (status != 0)
    395390                        usb_log_debug2("UHCI status: %x.\n", status);
    396391                hc_interrupt(instance, status);
    397                 async_usleep(UHCI_CLEANER_TIMEOUT);
     392                async_usleep(UHCI_INT_EMULATOR_TIMEOUT);
    398393        }
    399394        return EOK;
  • uspace/drv/uhci-hcd/hc.h

    ra39cfb8 re05d6c3  
    8888
    8989#define UHCI_FRAME_LIST_COUNT 1024
    90 #define UHCI_CLEANER_TIMEOUT 10000
     90#define UHCI_INT_EMULATOR_TIMEOUT 10000
    9191#define UHCI_DEBUGER_TIMEOUT 5000000
    9292#define UHCI_ALLOWED_HW_FAIL 5
  • uspace/drv/uhci-hcd/main.c

    ra39cfb8 re05d6c3  
    7878        device->driver_data = uhci;
    7979
    80         usb_log_info("Controlling new UHCI device `%s'.\n", device->name);
     80        usb_log_info("Controlling new UHCI device '%s'.\n", device->name);
    8181
    8282        return EOK;
  • uspace/drv/uhci-rhd/port.c

    ra39cfb8 re05d6c3  
    6868 * @return Error code. (Always EOK)
    6969 */
    70 static inline void uhci_port_write_status(
    71     uhci_port_t *port, port_status_t value)
    72 {
    73         assert(port);
    74         pio_write_16(port->address, value);
     70static inline void uhci_port_write_status(uhci_port_t *port, port_status_t val)
     71{
     72        assert(port);
     73        pio_write_16(port->address, val);
    7574}
    7675/*----------------------------------------------------------------------------*/
     
    101100        port->rh = rh;
    102101
    103         int rc = usb_hc_connection_initialize_from_device(
    104             &port->hc_connection, rh);
    105         if (rc != EOK) {
     102        int ret =
     103            usb_hc_connection_initialize_from_device(&port->hc_connection, rh);
     104        if (ret != EOK) {
    106105                usb_log_error("Failed to initialize connection to HC.");
    107                 return rc;
     106                return ret;
    108107        }
    109108
     
    238237        /* Enable the port. */
    239238        uhci_port_set_enabled(port, true);
    240 
    241239        return EOK;
    242240}
     
    271269        usb_log_info("New device at port %u, address %d (handle %llu).\n",
    272270            port->number, dev_addr, port->attached_device);
    273 
    274271        return EOK;
    275272}
     
    313310        /* Write new value. */
    314311        uhci_port_write_status(port, port_status);
     312
     313        /* Wait for port to become enabled */
     314        do {
     315                async_usleep(1000);
     316                port_status = uhci_port_read_status(port);
     317        } while ((port_status & STATUS_CONNECTED) &&
     318            !(port_status & STATUS_ENABLED));
    315319
    316320        usb_log_debug("%s: %sabled port.\n",
  • uspace/drv/uhci-rhd/port.h

    ra39cfb8 re05d6c3  
    5454#define STATUS_SUSPEND   (1 << 12)
    5555
     56/** UHCI port structure */
    5657typedef struct uhci_port
    5758{
  • uspace/drv/uhci-rhd/root_hub.c

    ra39cfb8 re05d6c3  
    3333 */
    3434#include <errno.h>
     35#include <str_error.h>
    3536#include <ddi.h>
    3637#include <usb/debug.h>
     
    4344 * @param[in] addr Address of I/O registers.
    4445 * @param[in] size Size of available I/O space.
    45  * @param[in] rh Pointer to ddf instance of the root hub driver.
     46 * @param[in] rh Pointer to DDF instance of the root hub driver.
    4647 * @return Error code.
    4748 */
     
    5859        if (ret < 0) {
    5960                usb_log_error(
    60                     "Failed(%d) to gain access to port registers at %p\n",
    61                     ret, regs);
     61                    "Failed(%d) to gain access to port registers at %p: %s.\n",
     62                    ret, regs, str_error(ret));
    6263                return ret;
    6364        }
     
    6667        unsigned i = 0;
    6768        for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
    68                 /* NOTE: mind pointer arithmetics here */
    6969                ret = uhci_port_init(
    70                     &instance->ports[i], regs + i, i, ROOT_HUB_WAIT_USEC, rh);
     70                    &instance->ports[i], &regs[i], i, ROOT_HUB_WAIT_USEC, rh);
    7171                if (ret != EOK) {
    7272                        unsigned j = 0;
  • uspace/drv/uhci-rhd/root_hub.h

    ra39cfb8 re05d6c3  
    4242#define ROOT_HUB_WAIT_USEC 250000 /* 250 miliseconds */
    4343
     44/** UHCI root hub drvier structure */
    4445typedef struct root_hub {
     46        /** Ports provided by the hub */
    4547        uhci_port_t ports[UHCI_ROOT_HUB_PORT_COUNT];
    46         devman_handle_t hc_handle;
    4748} uhci_root_hub_t;
    4849
    4950int uhci_root_hub_init(
    50   uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh);
     51    uhci_root_hub_t *instance, void *addr, size_t size, ddf_dev_t *rh);
    5152
    5253void uhci_root_hub_fini(uhci_root_hub_t *instance);
  • uspace/drv/usbhid/main.c

    ra39cfb8 re05d6c3  
    4242
    4343#include <usb/devdrv.h>
     44#include <usb/devpoll.h>
    4445
    4546#include "usbhid.h"
  • uspace/drv/usbhub/usbhub.c

    ra39cfb8 re05d6c3  
    4545#include <usb/request.h>
    4646#include <usb/classes/hub.h>
     47#include <usb/devpoll.h>
    4748#include <stdio.h>
    4849
  • uspace/drv/usbkbd/main.c

    ra39cfb8 re05d6c3  
    4242
    4343#include <usb/devdrv.h>
     44#include <usb/devpoll.h>
    4445
    4546#include "kbddev.h"
  • uspace/drv/usbmouse/main.c

    ra39cfb8 re05d6c3  
    3636#include "mouse.h"
    3737#include <usb/debug.h>
     38#include <usb/devpoll.h>
    3839#include <errno.h>
    3940#include <str_error.h>
Note: See TracChangeset for help on using the changeset viewer.