Changeset df6ded8 in mainline for uspace/drv/bus/usb/vhc/hub/hub.c


Ignore:
Timestamp:
2018-02-28T16:37:50Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1b20da0
Parents:
f5e5f73 (diff), b2dca8de (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.
git-author:
Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
git-committer:
Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
Message:

Merge github.com:helenos-xhci-team/helenos

This commit merges support for USB 3 and generally refactors, fixes,
extends and cleans up the existing USB framework.

Notable additions and features:

  • new host controller driver has been implemented to control various xHC models (among others, NEC Renesas uPD720200)
  • isochronous data transfer mode
  • support for explicit USB device removal
  • USB tablet driver
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/vhc/hub/hub.c

    rf5e5f73 rdf6ded8  
    6868
    6969/** Convert hub port state to a char. */
    70 char hub_port_state_to_char(hub_port_state_t state) {
     70char hub_port_state_to_char(hub_port_state_t state)
     71{
    7172        switch (state) {
    72                 case HUB_PORT_STATE_NOT_CONFIGURED:
    73                         return '-';
    74                 case HUB_PORT_STATE_POWERED_OFF:
    75                         return 'O';
    76                 case HUB_PORT_STATE_DISCONNECTED:
    77                         return 'X';
    78                 case HUB_PORT_STATE_DISABLED:
    79                         return 'D';
    80                 case HUB_PORT_STATE_RESETTING:
    81                         return 'R';
    82                 case HUB_PORT_STATE_ENABLED:
    83                         return 'E';
    84                 case HUB_PORT_STATE_SUSPENDED:
    85                         return 'S';
    86                 case HUB_PORT_STATE_RESUMING:
    87                         return 'F';
    88                 default:
    89                         return '?';
     73        case HUB_PORT_STATE_NOT_CONFIGURED:
     74                return '-';
     75        case HUB_PORT_STATE_POWERED_OFF:
     76                return 'O';
     77        case HUB_PORT_STATE_DISCONNECTED:
     78                return 'X';
     79        case HUB_PORT_STATE_DISABLED:
     80                return 'D';
     81        case HUB_PORT_STATE_RESETTING:
     82                return 'R';
     83        case HUB_PORT_STATE_ENABLED:
     84                return 'E';
     85        case HUB_PORT_STATE_SUSPENDED:
     86                return 'S';
     87        case HUB_PORT_STATE_RESUMING:
     88                return 'F';
     89        default:
     90                return '?';
    9091        }
    9192}
     
    231232        }
    232233
    233         usb_log_debug("Setting port %zu to state %d.\n", port_index, state);
     234        usb_log_debug("Setting port %zu to state %d.", port_index, state);
    234235
    235236        switch (state) {
    236                 case HUB_PORT_STATE_POWERED_OFF:
    237                         clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
    238                         clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
    239                         clear_port_status_change(port, HUB_STATUS_C_PORT_RESET);
    240                         break;
    241                 case HUB_PORT_STATE_RESUMING:
    242                         port->state = state;
    243                         set_port_state_delayed(hub, port_index,
    244                             10, state, HUB_PORT_STATE_ENABLED);
    245                         break;
    246                 case HUB_PORT_STATE_RESETTING:
    247                         port->state = state;
    248                         set_port_state_delayed(hub, port_index,
    249                             10, state, HUB_PORT_STATE_ENABLED);
    250                         break;
    251                 case HUB_PORT_STATE_ENABLED:
    252                         if (port->state == HUB_PORT_STATE_RESETTING) {
    253                                 set_port_status_change(port, HUB_STATUS_C_PORT_RESET);
    254                         }
    255                         break;
    256                 default:
    257                         break;
     237        case HUB_PORT_STATE_POWERED_OFF:
     238                clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
     239                clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
     240                clear_port_status_change(port, HUB_STATUS_C_PORT_RESET);
     241                break;
     242        case HUB_PORT_STATE_RESUMING:
     243                port->state = state;
     244                set_port_state_delayed(hub, port_index,
     245                    10, state, HUB_PORT_STATE_ENABLED);
     246                break;
     247        case HUB_PORT_STATE_RESETTING:
     248                port->state = state;
     249                set_port_state_delayed(hub, port_index,
     250                    10, state, HUB_PORT_STATE_ENABLED);
     251                break;
     252        case HUB_PORT_STATE_ENABLED:
     253                if (port->state == HUB_PORT_STATE_RESETTING) {
     254                        set_port_status_change(port, HUB_STATUS_C_PORT_RESET);
     255                }
     256                break;
     257        default:
     258                break;
    258259        }
    259260
     
    336337        }
    337338
    338         uint32_t status;
    339         status = MAKE_BYTE(
     339        uint32_t status = MAKE_BYTE(
    340340            /* Current connect status. */
    341341            port->connected_device == NULL ? 0 : 1,
     
    344344            /* Suspend. */
    345345            (port->state == HUB_PORT_STATE_SUSPENDED)
    346                 || (port->state == HUB_PORT_STATE_RESUMING) ? 1 : 0,
     346            || (port->state == HUB_PORT_STATE_RESUMING) ? 1 : 0,
    347347            /* Over-current. */
    348348            0,
     
    350350            port->state == HUB_PORT_STATE_RESETTING ? 1 : 0,
    351351            /* Reserved. */
    352             0, 0, 0)
    353 
    354             | (MAKE_BYTE(
     352            0, 0, 0);
     353
     354        status |= MAKE_BYTE(
    355355            /* Port power. */
    356356            port->state == HUB_PORT_STATE_POWERED_OFF ? 0 : 1,
     
    359359            /* Reserved. */
    360360            0, 0, 0, 0, 0, 0
    361             )) << 8;
     361            ) << 8;
    362362
    363363        status |= (port->status_change << 16);
     
    423423        uint16_t old_value = port->status_change;
    424424        port->status_change |= change;
    425         usb_log_debug("Changing status change on %zu: %04x => %04x\n",
     425        usb_log_debug("Changing status change on %zu: %04x => %04x",
    426426            port->index,
    427427            (unsigned int) old_value, (unsigned int) port->status_change);
     
    463463static errno_t set_port_state_delayed_fibril(void *arg)
    464464{
    465         struct delay_port_state_change *change
    466             = (struct delay_port_state_change *) arg;
     465        struct delay_port_state_change *change =
     466            (struct delay_port_state_change *) arg;
    467467
    468468        async_usleep(change->delay);
     
    500500    hub_port_state_t old_state, hub_port_state_t new_state)
    501501{
    502         struct delay_port_state_change *change
    503             = malloc(sizeof(struct delay_port_state_change));
     502        struct delay_port_state_change *change =
     503            malloc(sizeof(struct delay_port_state_change));
    504504
    505505        change->hub = hub;
     
    510510        fid_t fibril = fibril_create(set_port_state_delayed_fibril, change);
    511511        if (fibril == 0) {
    512                 printf("Failed to create fibril\n");
     512                usb_log_error("Failed to create fibril.");
    513513                free(change);
    514514                return;
Note: See TracChangeset for help on using the changeset viewer.