Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-rhd/port.c

    r67352d2 r275bf456  
    4444
    4545#include "port.h"
     46#include "port_status.h"
    4647
    4748static int uhci_port_new_device(uhci_port_t *port, usb_speed_t speed);
     
    6667{
    6768        assert(port);
    68         asprintf(&port->id_string, "Port (%p - %d)", port, number);
    69         if (port->id_string == NULL) {
    70                 return ENOMEM;
    71         }
    7269
    7370        port->address = address;
     
    119116        assert(instance);
    120117
     118        /* Iteration count, for debug purposes only */
     119        unsigned count = 0;
     120
    121121        while (1) {
    122122                async_usleep(instance->wait_period_usec);
    123123
    124124                /* read register value */
    125                 port_status_t port_status = uhci_port_read_status(instance);
    126 
    127                 /* print the value if it's interesting */
    128                 if (port_status & ~STATUS_ALWAYS_ONE)
    129                         uhci_port_print_status(instance, port_status);
     125                port_status_t port_status = port_status_read(instance->address);
     126
     127                /* debug print mutex */
     128                static fibril_mutex_t dbg_mtx =
     129                    FIBRIL_MUTEX_INITIALIZER(dbg_mtx);
     130                fibril_mutex_lock(&dbg_mtx);
     131                usb_log_debug2("Port(%p - %d): Status: %#04x. === %u\n",
     132                  instance->address, instance->number, port_status, count++);
     133//              print_port_status(port_status);
     134                fibril_mutex_unlock(&dbg_mtx);
    130135
    131136                if ((port_status & STATUS_CONNECTED_CHANGED) == 0)
    132137                        continue;
    133138
    134                 usb_log_debug("%s: Connected change detected: %x.\n",
    135                     instance->id_string, port_status);
     139                usb_log_debug("Port(%p - %d): Connected change detected: %x.\n",
     140                    instance->address, instance->number, port_status);
    136141
    137142                int rc =
    138143                    usb_hc_connection_open(&instance->hc_connection);
    139144                if (rc != EOK) {
    140                         usb_log_error("%s: Failed to connect to HC.",
    141                             instance->id_string);
     145                        usb_log_error("Port(%p - %d): Failed to connect to HC.",
     146                            instance->address, instance->number);
    142147                        continue;
    143148                }
     
    145150                /* Remove any old device */
    146151                if (instance->attached_device) {
    147                         usb_log_debug2("%s: Removing device.\n",
    148                             instance->id_string);
     152                        usb_log_debug2("Port(%p - %d): Removing device.\n",
     153                            instance->address, instance->number);
    149154                        uhci_port_remove_device(instance);
    150155                }
     
    158163                } else {
    159164                        /* Write one to WC bits, to ack changes */
    160                         uhci_port_write_status(instance, port_status);
    161                         usb_log_debug("%s: status change ACK.\n",
    162                             instance->id_string);
     165                        port_status_write(instance->address, port_status);
     166                        usb_log_debug("Port(%p - %d): Change status ACK.\n",
     167                            instance->address, instance->number);
    163168                }
    164169
    165170                rc = usb_hc_connection_close(&instance->hc_connection);
    166171                if (rc != EOK) {
    167                         usb_log_error("%s: Failed to disconnect.",
    168                             instance->id_string);
     172                        usb_log_error("Port(%p - %d): Failed to disconnect.",
     173                            instance->address, instance->number);
    169174                }
    170175        }
     
    182187        uhci_port_t *port = (uhci_port_t *) arg;
    183188
    184         usb_log_debug2("%s: new_device_enable_port.\n", port->id_string);
     189        usb_log_debug2("Port(%p - %d): new_device_enable_port.\n",
     190            port->address, port->number);
    185191
    186192        /*
     
    190196        async_usleep(100000);
    191197
    192         /*
    193          * Resets from root ports should be nominally 50ms
     198
     199        /* The hub maintains the reset signal to that port for 10 ms
     200         * (See Section 11.5.1.5)
    194201         */
    195202        {
    196                 usb_log_debug("%s: Reset Signal start.\n", port->id_string);
    197                 port_status_t port_status = uhci_port_read_status(port);
     203                usb_log_debug("Port(%p - %d): Reset Signal start.\n",
     204                    port->address, port->number);
     205                port_status_t port_status =
     206                        port_status_read(port->address);
    198207                port_status |= STATUS_IN_RESET;
    199                 uhci_port_write_status(port, port_status);
    200                 async_usleep(50000);
    201                 port_status = uhci_port_read_status(port);
     208                port_status_write(port->address, port_status);
     209                async_usleep(10000);
     210                port_status = port_status_read(port->address);
    202211                port_status &= ~STATUS_IN_RESET;
    203                 uhci_port_write_status(port, port_status);
    204                 usb_log_debug("%s: Reset Signal stop.\n", port->id_string);
    205         }
    206 
    207         /* the reset recovery time 10ms */
    208         async_usleep(10000);
     212                port_status_write(port->address, port_status);
     213                usb_log_debug("Port(%p - %d): Reset Signal stop.\n",
     214                    port->address, port->number);
     215        }
    209216
    210217        /* Enable the port. */
    211218        uhci_port_set_enabled(port, true);
    212 
    213219        return EOK;
    214220}
     
    227233        assert(usb_hc_connection_is_opened(&port->hc_connection));
    228234
    229         usb_log_info("%s: Detected new device.\n", port->id_string);
     235        usb_log_info("Port(%p-%d): Detected new device.\n",
     236            port->address, port->number);
    230237
    231238        usb_address_t dev_addr;
     
    235242
    236243        if (rc != EOK) {
    237                 usb_log_error("%s: Failed(%d) to add device: %s.\n",
    238                     port->id_string, rc, str_error(rc));
     244                usb_log_error("Port(%p-%d): Failed(%d) to add device: %s.\n",
     245                    port->address, port->number, rc, str_error(rc));
    239246                uhci_port_set_enabled(port, false);
    240247                return rc;
    241248        }
    242249
    243         usb_log_info("%s: New device has address %d (handle %zu).\n",
    244             port->id_string, dev_addr, port->attached_device);
     250        usb_log_info("Port(%p-%d): New device has address %d (handle %zu).\n",
     251            port->address, port->number, dev_addr, port->attached_device);
    245252
    246253        return EOK;
     
    256263int uhci_port_remove_device(uhci_port_t *port)
    257264{
    258         usb_log_error("%s: Don't know how to remove device %d.\n",
    259             port->id_string, (unsigned int)port->attached_device);
     265        usb_log_error("Port(%p-%d): Don't know how to remove device %#x.\n",
     266            port->address, port->number, (unsigned int)port->attached_device);
    260267        return EOK;
    261268}
     
    271278
    272279        /* Read register value */
    273         port_status_t port_status = uhci_port_read_status(port);
     280        port_status_t port_status = port_status_read(port->address);
    274281
    275282        /* Set enabled bit */
     
    281288
    282289        /* Write new value. */
    283         uhci_port_write_status(port, port_status);
    284 
    285         usb_log_info("%s: %sabled port.\n",
    286                 port->id_string, enabled ? "En" : "Dis");
     290        port_status_write(port->address, port_status);
     291
     292        usb_log_info("Port(%p-%d): %sabled port.\n",
     293                port->address, port->number, enabled ? "En" : "Dis");
    287294        return EOK;
    288295}
Note: See TracChangeset for help on using the changeset viewer.