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

Changeset 1f5c1e61 in mainline for uspace/drv/uhci-rhd/port.c


Ignore:
Timestamp:
2011-02-04T12:37:31Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial
Children:
1669a73
Parents:
5944244
Message:

Separate phones for every root hub port

Add tons of debug output

File:
1 edited

Legend:

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

    r5944244 r1f5c1e61  
    4848int uhci_port_init(
    4949  uhci_port_t *port, port_status_t *address, unsigned number,
    50   unsigned usec, device_t *rh)
     50  unsigned usec, device_t *rh, int parent_phone)
    5151{
    5252        assert(port);
     
    5656        port->attached_device = 0;
    5757        port->rh = rh;
    58         port->hc_phone = rh->parent_phone;
     58        port->hc_phone = parent_phone;
    5959
    6060        port->checker = fibril_create(uhci_port_check, port);
     
    7171void uhci_port_fini(uhci_port_t *port)
    7272{
     73// TODO: destroy fibril
     74// TODO: hangup phone
    7375//      fibril_teardown(port->checker);
    7476        return;
     
    7779int uhci_port_check(void *port)
    7880{
    79         async_usleep( 1000000 );
    8081        uhci_port_t *port_instance = port;
    8182        assert(port_instance);
     
    114115        usb_log_info("Adding new device on port %d.\n", port->number);
    115116
     117        /* get address of the future device */
     118        const usb_address_t usb_address = usb_drv_request_address(port->hc_phone);
     119
     120        if (usb_address <= 0) {
     121                usb_log_error("Recieved invalid address(%d).\n", usb_address);
     122                return usb_address;
     123        }
     124        usb_log_debug("Sucessfully obtained address %d for port %d.\n",
     125            usb_address, port->number);
    116126
    117127        /* get default address */
    118128        int ret = usb_drv_reserve_default_address(port->hc_phone);
    119129        if (ret != EOK) {
    120                 usb_log_error("Failed to reserve default address.\n");
     130                usb_log_error("Failed to reserve default address on port %d.\n",
     131                    port->number);
     132                int ret2 =
     133                  usb_drv_release_address(port->hc_phone, usb_address);
     134                if (ret2 != EOK) {
     135                        usb_log_fatal("Failed to return requested address on port %d.\n",
     136                           port->number);
     137                        return ret2;
     138                }
     139                usb_log_debug("Successfully returned reserved address on port %d.\n",
     140                        port->number);
    121141                return ret;
    122142        }
    123 
    124         const usb_address_t usb_address = usb_drv_request_address(port->hc_phone);
    125 
    126         if (usb_address <= 0) {
    127                 usb_log_error("Recieved invalid address(%d).\n", usb_address);
    128                 return usb_address;
    129         }
     143        usb_log_debug("Sucessfully obtained default address for port %d.\n",
     144            port->number);
     145
    130146        /*
    131147         * the host then waits for at least 100 ms to allow completion of
     
    140156         * (See Section 11.5.1.5)
    141157         */
    142         port_status_t port_status =
    143                 port_status_read(port->address);
    144         port_status |= STATUS_IN_RESET;
    145         port_status_write(port->address, port_status);
    146         async_usleep(10000);
    147         port_status =
    148                 port_status_read(port->address);
    149         port_status &= ~STATUS_IN_RESET;
    150         port_status_write(port->address, port_status);
     158        {
     159                usb_log_debug("Reset Signal start on port %d.\n",
     160                    port->number);
     161                port_status_t port_status =
     162                        port_status_read(port->address);
     163                port_status |= STATUS_IN_RESET;
     164                port_status_write(port->address, port_status);
     165                async_usleep(10000);
     166                port_status =
     167                        port_status_read(port->address);
     168                port_status &= ~STATUS_IN_RESET;
     169                port_status_write(port->address, port_status);
     170                usb_log_debug("Reset Signal stop on port %d.\n",
     171                    port->number);
     172        }
    151173
    152174        /* assign address to device */
    153175        ret = usb_drv_req_set_address(port->hc_phone, 0, usb_address);
    154 
    155176
    156177        if (ret != EOK) { /* address assigning went wrong */
     
    159180                int release = usb_drv_release_default_address(port->hc_phone);
    160181                if (release != EOK) {
    161                         usb_log_error("Failed to release default address.\n");
     182                        usb_log_error("Failed to release default address on port %d.\n",
     183                            port->number);
    162184                        return release;
    163185                }
     186                usb_log_debug("Sucessfully released default address on port %d.\n",
     187                    port->number);
    164188                return ret;
    165189        }
     190        usb_log_debug("Sucessfully assigned address %d for port %d.\n",
     191            usb_address, port->number);
    166192
    167193        /* release default address */
    168194        ret = usb_drv_release_default_address(port->hc_phone);
    169195        if (ret != EOK) {
    170                 usb_log_error("Failed to release default address.\n");
     196                usb_log_error("Failed to release default address on port %d.\n",
     197                    port->number);
    171198                return ret;
    172199        }
     200        usb_log_debug("Sucessfully released default address on port %d.\n",
     201            port->number);
    173202
    174203        /* communicate and possibly report to devman */
     
    195224        usb_log_error("Don't know how to remove device %#x.\n",
    196225                (unsigned int)port->attached_device);
    197         uhci_port_set_enabled(port, false);
     226//      uhci_port_set_enabled(port, false);
    198227        return EOK;
    199228}
Note: See TracChangeset for help on using the changeset viewer.