Changeset 1f5c1e61 in mainline


Ignore:
Timestamp:
2011-02-04T12:37:31Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1669a73
Parents:
5944244
Message:

Separate phones for every root hub port

Add tons of debug output

Location:
uspace/drv/uhci-rhd
Files:
5 edited

Legend:

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

    r5944244 r1f5c1e61  
    102102int main(int argc, char *argv[])
    103103{
    104         usb_log_enable(USB_LOG_LEVEL_INFO, NAME);
     104        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    105105        return driver_main(&uhci_rh_driver);
    106106}
  • 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}
  • uspace/drv/uhci-rhd/port.h

    r5944244 r1f5c1e61  
    5454int uhci_port_init(
    5555  uhci_port_t *port, port_status_t *address, unsigned number,
    56   unsigned usec, device_t *rh);
     56  unsigned usec, device_t *rh, int parent_phone);
    5757
    5858void uhci_port_fini(uhci_port_t *port);
  • uspace/drv/uhci-rhd/port_status.c

    r5944244 r1f5c1e61  
    6464        unsigned i = 0;
    6565        for (;i < sizeof(flags)/sizeof(struct flag_name); ++i) {
    66                 usb_log_debug("\t%s status: %s.\n", flags[i].name,
     66                usb_log_debug2("\t%s status: %s.\n", flags[i].name,
    6767                  value & flags[i].flag ? "YES" : "NO");
    6868        }
  • uspace/drv/uhci-rhd/root_hub.c

    r5944244 r1f5c1e61  
    5353        }
    5454
    55         /* connect to the parent device (HC) */
    56         rh->parent_phone = devman_device_connect(8, 0);
    57         //usb_drv_hc_connect(rh, instance->hc_handle, 0);
    58         if (rh->parent_phone < 0) {
    59                 usb_log_error("Failed to connect to the HC device.\n");
    60                 return rh->parent_phone;
    61         }
    62 
    6355        /* allow access to root hub registers */
    6456        assert(sizeof(port_status_t) * UHCI_ROOT_HUB_PORT_COUNT == size);
     
    7567        unsigned i = 0;
    7668        for (; i < UHCI_ROOT_HUB_PORT_COUNT; ++i) {
     69                /* connect to the parent device (HC) */
     70                int parent_phone = devman_device_connect(instance->hc_handle, 0);
     71                //usb_drv_hc_connect(rh, instance->hc_handle, 0);
     72                if (parent_phone < 0) {
     73                        usb_log_error("Failed to connect to the HC device port %d.\n", i);
     74                        return parent_phone;
     75                }
    7776                /* mind pointer arithmetics */
    7877                int ret = uhci_port_init(
    79                   &instance->ports[i], regs + i, i, ROOT_HUB_WAIT_USEC, rh);
     78                  &instance->ports[i], regs + i, i, ROOT_HUB_WAIT_USEC, rh, parent_phone);
    8079                if (ret != EOK) {
    8180                        unsigned j = 0;
Note: See TracChangeset for help on using the changeset viewer.