Changeset c8bb7090 in mainline


Ignore:
Timestamp:
2017-07-16T17:24:42Z (7 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
37789b5f
Parents:
fe5db713
Message:

Corrected cstyle.

Location:
uspace/drv/bus/usb/xhci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/Makefile

    rfe5db713 rc8bb7090  
    4747        scratchpad.c \
    4848        commands.c \
    49     rh.c \
     49        rh.c \
    5050        main.c
    5151
  • uspace/drv/bus/usb/xhci/rh.c

    rfe5db713 rc8bb7090  
    3939#include "debug.h"
    4040#include "hc.h"
     41#include "hw_struct/trb.h"
    4142#include "rh.h"
    4243
    43 #include "hw_struct/trb.h"
     44static int handle_connected_device(xhci_hc_t* hc, xhci_port_regs_t* regs, uint8_t port_id)
     45{
     46        uint8_t link_state = XHCI_REG_RD(regs, XHCI_PORT_PLS);
     47        if (link_state == 0) {
     48                // USB3 is automatically advance to enabled   
     49                uint8_t port_speed = XHCI_REG_RD(regs, XHCI_PORT_PS);
     50                usb_log_debug2("Detected new device on port %u, port speed id %u.", port_id, port_speed);
     51                // TODO: Assign device slot (specification 4.3.2)
     52        } else if (link_state == 5) {
     53                // USB 3 failed to enable
     54                usb_log_debug("USB 3 port couldn't be enabled.");
     55        } else if (link_state == 7) {
     56                usb_log_debug("USB 2 device attached, issuing reset.");
     57                xhci_reset_hub_port(hc, port_id);
     58        }
    4459
    45 static int handle_connected_device(xhci_hc_t* hc, xhci_port_regs_t* regs, uint8_t port_id) {
    46     uint8_t link_state = XHCI_REG_RD(regs, XHCI_PORT_PLS);
    47     if(link_state == 0) {
    48         // USB3 is automatically advance to enabled   
    49         uint8_t port_speed = XHCI_REG_RD(regs, XHCI_PORT_PS);
    50         usb_log_debug2("Detected new device on port %u, port speed id %u.", port_id, port_speed);
    51         // TODO: Assign device slot (specification 4.3.2)
    52     }
    53     else if(link_state == 5) {
    54         // USB 3 failed to enable
    55         usb_log_debug("USB 3 port couldn't be enabled.");
    56     }
    57     else if(link_state == 7) {
    58         usb_log_debug("USB 2 device attached, issuing reset.");
    59         xhci_reset_hub_port(hc, port_id);
    60     }
    61 
    62     return EOK;
     60        return EOK;
    6361}
    6462
    65 int xhci_handle_port_status_change_event(xhci_hc_t *hc, xhci_trb_t *trb) {
    66     uint8_t port_id = xhci_get_hub_port(trb);
    67     usb_log_debug("Port status change event detected for port %u.", port_id);
    68     xhci_port_regs_t* regs = &hc->op_regs->portrs[port_id];
     63int xhci_handle_port_status_change_event(xhci_hc_t *hc, xhci_trb_t *trb)
     64{
     65        uint8_t port_id = xhci_get_hub_port(trb);
     66        usb_log_debug("Port status change event detected for port %u.", port_id);
     67        xhci_port_regs_t* regs = &hc->op_regs->portrs[port_id];
    6968
    70     // Port reset change
    71     if(XHCI_REG_RD(regs, XHCI_PORT_PRC)) {
    72         // Clear the flag
    73         XHCI_REG_WR(regs, XHCI_PORT_PRC, 1);
     69        // Port reset change
     70        if (XHCI_REG_RD(regs, XHCI_PORT_PRC)) {
     71                // Clear the flag
     72                XHCI_REG_WR(regs, XHCI_PORT_PRC, 1);
    7473
    75         uint8_t port_speed = XHCI_REG_RD(regs, XHCI_PORT_PS);
    76         usb_log_debug2("Detected port reset on port %u, port speed id %u.", port_id, port_speed);
    77         // TODO: Assign device slot (specification 4.3.2)
    78     }
     74                uint8_t port_speed = XHCI_REG_RD(regs, XHCI_PORT_PS);
     75                usb_log_debug2("Detected port reset on port %u, port speed id %u.", port_id, port_speed);
     76                // TODO: Assign device slot (specification 4.3.2)
     77        }
    7978
    80     // Connection status change
    81     if(XHCI_REG_RD(regs, XHCI_PORT_CSC)) {
    82         XHCI_REG_WR(regs, XHCI_PORT_CSC, 1);
     79        // Connection status change
     80        if (XHCI_REG_RD(regs, XHCI_PORT_CSC)) {
     81                XHCI_REG_WR(regs, XHCI_PORT_CSC, 1);
    8382
    84         if(XHCI_REG_RD(regs, XHCI_PORT_CCS) == 1) {
    85             handle_connected_device(hc, regs, port_id);
    86         }
    87         else {
    88             // Device disconnected
    89         }
    90     }
    91     return EOK;
     83                if (XHCI_REG_RD(regs, XHCI_PORT_CCS) == 1) {
     84                        handle_connected_device(hc, regs, port_id);
     85                } else {
     86                        // Device disconnected
     87                }
     88        }
     89
     90        return EOK;
    9291}
    9392
    94 int xhci_get_hub_port(xhci_trb_t *trb) {
    95     assert(trb);
    96     uint8_t port_id = XHCI_QWORD_EXTRACT(trb->parameter, 63, 56);
    97     return port_id;   
     93int xhci_get_hub_port(xhci_trb_t *trb)
     94{
     95        assert(trb);
     96        uint8_t port_id = XHCI_QWORD_EXTRACT(trb->parameter, 63, 56);
     97
     98        return port_id;   
    9899}
    99100
    100 int xhci_reset_hub_port(xhci_hc_t* hc, uint8_t port) {
    101     usb_log_debug2("Resetting port %u.", port);
    102     xhci_port_regs_t regs = hc->op_regs->portrs[port];
    103     XHCI_REG_WR(&regs, XHCI_PORT_PR, 1);
    104     return EOK;
     101int xhci_reset_hub_port(xhci_hc_t* hc, uint8_t port)
     102{
     103        usb_log_debug2("Resetting port %u.", port);
     104        xhci_port_regs_t regs = hc->op_regs->portrs[port];
     105        XHCI_REG_WR(&regs, XHCI_PORT_PR, 1);
     106
     107        return EOK;
    105108}
    106109
     110
     111/**
     112 * @}
     113 */
  • uspace/drv/bus/usb/xhci/rh.h

    rfe5db713 rc8bb7090  
    4242
    4343#endif
     44
     45/**
     46 * @}
     47 */
Note: See TracChangeset for help on using the changeset viewer.