Changeset 7c3fb9b in mainline for uspace/drv/bus/usb


Ignore:
Timestamp:
2018-05-17T08:29:01Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6ff23ff
Parents:
fac0ac7
git-author:
Jiri Svoboda <jiri@…> (2018-05-16 17:28:17)
git-committer:
Jiri Svoboda <jiri@…> (2018-05-17 08:29:01)
Message:

Fix block comment formatting (ccheck).

Location:
uspace/drv/bus/usb
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/ehci_batch.c

    rfac0ac7 r7c3fb9b  
    4747#include "ehci_bus.h"
    4848
    49 /* The buffer pointer list in the qTD is long enough to support a maximum
     49/*
     50 * The buffer pointer list in the qTD is long enough to support a maximum
    5051 * transfer size of 20K bytes. This case occurs when all five buffer pointers
    5152 * are used and the first offset is zero. A qTD handles a 16Kbyte buffer
    52  * with any starting buffer alignment. EHCI specs p. 87 (pdf p. 97) */
     53 * with any starting buffer alignment. EHCI specs p. 87 (pdf p. 97)
     54 */
    5355#define EHCI_TD_MAX_TRANSFER   (16 * 1024)
    5456
     
    177179                return false;
    178180
    179         /* Now we may be sure that either the ED is inactive because of errors
    180          * or all transfer descriptors completed successfully */
     181        /*
     182         * Now we may be sure that either the ED is inactive because of errors
     183         * or all transfer descriptors completed successfully
     184         */
    181185
    182186        /* Assume all data got through */
     
    192196                ehci_batch->base.error = td_error(&ehci_batch->tds[i]);
    193197                if (ehci_batch->base.error == EOK) {
    194                         /* If the TD got all its data through, it will report
     198                        /*
     199                         * If the TD got all its data through, it will report
    195200                         * 0 bytes remain, the sole exception is INPUT with
    196201                         * data rounding flag (short), i.e. every INPUT.
  • uspace/drv/bus/usb/ehci/ehci_rh.c

    rfac0ac7 r7c3fb9b  
    7272        instance->hub_descriptor.header.descriptor_type = USB_DESCTYPE_HUB;
    7373        instance->hub_descriptor.header.port_count = instance->port_count;
    74         /* Bits 0,1 indicate power switching mode
     74        /*
     75         * Bits 0,1 indicate power switching mode
    7576         * Bit 2 indicates device type (compound device)
    76          * Bits 3,4 indicate over-current protection mode */
     77         * Bits 3,4 indicate over-current protection mode
     78         */
    7779        instance->hub_descriptor.header.characteristics = 0 |
    7880            ((hcs & EHCI_CAPS_HCS_PPC_FLAG) ? 0x09 : 0x12) |
     
    313315            EHCI2USB(reg, USB_PORTSC_OC_CHANGE_FLAG, USB_HUB_PORT_STATUS_C_OC) |
    314316            (hub->reset_flag[port] ? USB_HUB_PORT_STATUS_C_RESET : 0));
    315         /* Note feature numbers for test and indicator feature do not
    316          * correspond to the port status bit locations */
     317        /*
     318         * Note feature numbers for test and indicator feature do not
     319         * correspond to the port status bit locations
     320         */
    317321        usb_log_debug2("RH(%p-%u) port status: %" PRIx32 "(%" PRIx32 ")", hub, port,
    318322            status, reg);
     
    340344        }
    341345        usb_log_debug("RH(%p-%u): Reset complete", job->hub, job->port);
    342         /* Handle port ownership, if the port is not enabled
    343          * after reset it's a full speed device */
     346        /*
     347         * Handle port ownership, if the port is not enabled
     348         * after reset it's a full speed device
     349         */
    344350        if (!(EHCI_RD(job->hub->registers->portsc[job->port]) &
    345351            USB_PORTSC_ENABLED_FLAG)) {
  • uspace/drv/bus/usb/ehci/hc.c

    rfac0ac7 r7c3fb9b  
    395395        usb_log_debug("HC(%p): Starting HW.", instance);
    396396
    397         /* Turn off the HC if it's running, Reseting a running device is
    398          * undefined */
     397        /*
     398         * Turn off the HC if it's running, Reseting a running device is
     399         * undefined
     400         */
    399401        if (!(EHCI_RD(instance->registers->usbsts) & USB_STS_HC_HALTED_FLAG)) {
    400402                /* disable all interrupts */
     
    487489                return ret;
    488490        }
    489         /* Specs say "Software must set queue head horizontal pointer T-bits to
     491        /*
     492         * Specs say "Software must set queue head horizontal pointer T-bits to
    490493         * a zero for queue heads in the asynchronous schedule" (4.4.0).
    491494         * So we must maintain circular buffer (all horizontal pointers
    492          * have to be valid */
     495         * have to be valid
     496         */
    493497        endpoint_list_chain(&instance->async_list, &instance->async_list);
    494498
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.c

    rfac0ac7 r7c3fb9b  
    6161        EHCI_MEM32_WR(instance->alternate, LINK_POINTER_TERM);
    6262        if (ep == NULL) {
    63                 /* Mark as halted and list head,
    64                  * used by endpoint lists as dummy */
     63                /*
     64                 * Mark as halted and list head,
     65                 * used by endpoint lists as dummy
     66                 */
    6567                EHCI_MEM32_WR(instance->ep_char, QH_EP_CHAR_H_FLAG);
    6668                EHCI_MEM32_WR(instance->status, QH_STATUS_HALTED_FLAG);
     
    7678                if (ep->device->speed != USB_SPEED_HIGH)
    7779                        EHCI_MEM32_SET(instance->ep_char, QH_EP_CHAR_C_FLAG);
    78                 /* Let BULK and INT use queue head managed toggle,
    79                  * CONTROL needs special toggle handling anyway */
     80                /*
     81                 * Let BULK and INT use queue head managed toggle,
     82                 * CONTROL needs special toggle handling anyway
     83                 */
    8084                EHCI_MEM32_SET(instance->ep_char, QH_EP_CHAR_DTC_FLAG);
    8185        }
     
    96100        EHCI_MEM32_WR(instance->ep_cap, ep_cap);
    97101
    98         /* The rest of the fields are transfer working area, it should be ok to
    99          * leave it NULL */
     102        /*
     103         * The rest of the fields are transfer working area, it should be ok to
     104         * leave it NULL
     105         */
    100106}
    101107
  • uspace/drv/bus/usb/ehci/res.c

    rfac0ac7 r7c3fb9b  
    8080        usb_log_debug2("USBLEGSUP: %" PRIx32 ".", usblegsup);
    8181
    82         /* Request control from firmware/BIOS by writing 1 to highest
    83          * byte. (OS Control semaphore)*/
     82        /*
     83         * Request control from firmware/BIOS by writing 1 to highest
     84         * byte. (OS Control semaphore)
     85         */
    8486        usb_log_debug("Requesting OS control.");
    8587        ret = pci_config_space_write_8(parent_sess,
     
    187189        usb_log_debug2("Value of hcc params register: %x.", hcc_params);
    188190
    189         /* Read value of EHCI Extended Capabilities Pointer
    190          * position of EEC registers (points to PCI config space) */
     191        /*
     192         * Read value of EHCI Extended Capabilities Pointer
     193         * position of EEC registers (points to PCI config space)
     194         */
    191195        const uint32_t eecp =
    192196            (hcc_params >> EHCI_CAPS_HCC_EECP_SHIFT) & EHCI_CAPS_HCC_EECP_MASK;
  • uspace/drv/bus/usb/ohci/hc.c

    rfac0ac7 r7c3fb9b  
    400400        usb_log_debug("Requesting OHCI control.");
    401401        if (OHCI_RD(instance->registers->revision) & R_LEGACY_FLAG) {
    402                 /* Turn off legacy emulation, it should be enough to zero
     402                /*
     403                 * Turn off legacy emulation, it should be enough to zero
    403404                 * the lowest bit, but it caused problems. Thus clear all
    404405                 * except GateA20 (causes restart on some hw).
     
    447448        }
    448449
    449         /* HC is in reset (hw startup) => no other driver
    450          * maintain reset for at least the time specified in USB spec (50 ms)*/
     450        /*
     451         * HC is in reset (hw startup) => no other driver
     452         * maintain reset for at least the time specified in USB spec (50 ms)
     453         */
    451454        usb_log_debug("Host controller found in reset state.");
    452455        async_usleep(50000);
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c

    rfac0ac7 r7c3fb9b  
    6969
    7070        if (ep == NULL) {
    71                 /* Mark as dead, used for dummy EDs at the beginning of
    72                  * endpoint lists. */
     71                /*
     72                 * Mark as dead, used for dummy EDs at the beginning of
     73                 * endpoint lists.
     74                 */
    7375                OHCI_MEM32_WR(instance->status, ED_STATUS_K_FLAG);
    7476                return;
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.h

    rfac0ac7 r7c3fb9b  
    5151 * OHCI Endpoint Descriptor representation.
    5252 *
    53  * See OHCI spec. Chapter 4.2, page 16 (pdf page 30) for details */
     53 * See OHCI spec. Chapter 4.2, page 16 (pdf page 30) for details
     54 */
    5455typedef struct ed {
    5556        /**
  • uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.h

    rfac0ac7 r7c3fb9b  
    4444#include "completion_codes.h"
    4545
    46 /* OHCI TDs can handle up to 8KB buffers, however, it can use max 2 pages.
     46/*
     47 * OHCI TDs can handle up to 8KB buffers, however, it can use max 2 pages.
    4748 * Using 4KB buffers guarantees the page count condition.
    48  * (OHCI assumes 4KB pages) */
     49 * (OHCI assumes 4KB pages)
     50 */
    4951#define OHCI_TD_MAX_TRANSFER (4 * 1024)
    5052
     
    7678        /**
    7779         * Current buffer pointer.
    78          * Phys address of the first byte to be transferred. */
     80         * Phys address of the first byte to be transferred.
     81         */
    7982        volatile uint32_t cbp;
    8083
     
    105108        const int cc = (OHCI_MEM32_RD(instance->status) >> TD_STATUS_CC_SHIFT) &
    106109            TD_STATUS_CC_MASK;
    107         /* This value is changed on transfer completion,
     110        /*
     111         * This value is changed on transfer completion,
    108112         * either to CC_NOERROR or and error code.
    109          * See OHCI spec 4.3.1.3.5 p. 23 (pdf 37) */
     113         * See OHCI spec 4.3.1.3.5 p. 23 (pdf 37)
     114         */
    110115        if (cc != CC_NOACCESS1 && cc != CC_NOACCESS2) {
    111116                return true;
  • uspace/drv/bus/usb/ohci/ohci_batch.c

    rfac0ac7 r7c3fb9b  
    163163                return false;
    164164
    165         /* Now we may be sure that either the ED is inactive because of errors
    166          * or all transfer descriptors completed successfully */
     165        /*
     166         * Now we may be sure that either the ED is inactive because of errors
     167         * or all transfer descriptors completed successfully
     168         */
    167169
    168170        /* Assume all data got through */
     
    178180                usb_batch->error = td_error(ohci_batch->tds[i]);
    179181                if (usb_batch->error == EOK) {
    180                         /* If the TD got all its data through, it will report
     182                        /*
     183                         * If the TD got all its data through, it will report
    181184                         * 0 bytes remain, the sole exception is INPUT with
    182185                         * data rounding flag (short), i.e. every INPUT.
     
    199202                        assert((ohci_ep->ed->td_head & ED_TDHEAD_HALTED_FLAG) != 0);
    200203
    201                         /* We don't care where the processing stopped, we just
     204                        /*
     205                         * We don't care where the processing stopped, we just
    202206                         * need to make sure it's not using any of the TDs owned
    203207                         * by the transfer.
  • uspace/drv/bus/usb/uhci/hw_struct/queue_head.h

    rfac0ac7 r7c3fb9b  
    7878static inline void qh_set_next_qh(qh_t *instance, qh_t *next)
    7979{
    80         /* Physical address has to be below 4GB,
     80        /*
     81         * Physical address has to be below 4GB,
    8182         * it is an UHCI limitation and malloc32
    82          * should guarantee this */
     83         * should guarantee this
     84         */
    8385        const uint32_t pa = addr_to_phys(next);
    8486        if (pa) {
     
    98100static inline void qh_set_element_td(qh_t *instance, td_t *td)
    99101{
    100         /* Physical address has to be below 4GB,
     102        /*
     103         * Physical address has to be below 4GB,
    101104         * it is an UHCI limitation and malloc32
    102          * should guarantee this */
     105         * should guarantee this
     106         */
    103107        const uint32_t pa = addr_to_phys(td);
    104108        if (pa) {
  • uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c

    rfac0ac7 r7c3fb9b  
    127127                return EIO;
    128128
    129         /* CRC or timeout error, like device not present or bad data,
    130          * it won't be reported unless err count reached zero */
     129        /*
     130         * CRC or timeout error, like device not present or bad data,
     131         * it won't be reported unless err count reached zero
     132         */
    131133        if ((instance->status & TD_STATUS_ERROR_CRC) != 0)
    132134                return EBADCHECKSUM;
     
    144146                return EIO;
    145147
    146         /* Stall might represent err count reaching zero or stall response from
    147          * the device. If err count reached zero, one of the above is reported*/
     148        /*
     149         * Stall might represent err count reaching zero or stall response from
     150         * the device. If err count reached zero, one of the above is reported
     151         */
    148152        if ((instance->status & TD_STATUS_ERROR_STALLED) != 0)
    149153                return ESTALL;
  • uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h

    rfac0ac7 r7c3fb9b  
    9090        volatile uint32_t buffer_ptr;
    9191
    92         /* According to UHCI design guide, there is 16 bytes of
     92        /*
     93         * According to UHCI design guide, there is 16 bytes of
    9394         * data available here.
    9495         * According to Linux kernel the hardware does not care,
  • uspace/drv/bus/usb/uhci/main.c

    rfac0ac7 r7c3fb9b  
    7676                return ENOMEM;
    7777
    78         /* See UHCI design guide page 45 for these values.
    79          * Write all WC bits in USB legacy register */
     78        /*
     79         * See UHCI design guide page 45 for these values.
     80         * Write all WC bits in USB legacy register
     81         */
    8082        return pci_config_space_write_16(parent_sess, 0xc0, 0xaf00);
    8183}
  • uspace/drv/bus/usb/uhci/uhci_batch.c

    rfac0ac7 r7c3fb9b  
    8787}
    8888
    89 /* Prepares batch for commiting.
     89/*
     90 * Prepares batch for committing.
    9091 *
    9192 * Determines the number of needed transfer descriptors (TDs).
  • uspace/drv/bus/usb/uhci/uhci_rh.c

    rfac0ac7 r7c3fb9b  
    153153        while ((port_status = pio_read_16(port)) & STATUS_IN_RESET)
    154154                ;
    155         /* PIO delay, should not be longer than 3ms as the device might
    156          * enter suspend state. */
     155        /*
     156         * PIO delay, should not be longer than 3ms as the device might
     157         * enter suspend state.
     158         */
    157159        udelay(10);
    158         /* Drop ConnectionChange as some UHCI hw
    159          * sets this bit after reset, that is incorrect */
     160        /*
     161         * Drop ConnectionChange as some UHCI hw
     162         * sets this bit after reset, that is incorrect
     163         */
    160164        port_status &= ~STATUS_WC_BITS;
    161165        pio_write_16(port, port_status | STATUS_ENABLED | STATUS_CONNECTED_CHANGED);
     
    376380                RH_DEBUG(hub, port, "Set port change flag (status %" PRIx16
    377381                    ")", status);
    378                 /* These are voluntary and don't have to be set
    379                  * there is no way we could do it on UHCI anyway */
     382                /*
     383                 * These are voluntary and don't have to be set
     384                 * there is no way we could do it on UHCI anyway
     385                 */
    380386                break;
    381387        default:
     
    459465                CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_CLEAR_FEATURE),
    460466                .name = "ClearHubFeature",
    461                 /* Hub features are overcurrent and supply good,
    462                  * this request may only clear changes that we never report*/
     467                /*
     468                 * Hub features are overcurrent and supply good,
     469                 * this request may only clear changes that we never report
     470                 */
    463471                .callback = req_nop,
    464472        },
     
    471479                CLASS_REQ_IN(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_GET_STATUS),
    472480                .name = "GetHubStatus",
    473                 /* UHCI can't report OC condition or,
    474                  * lose power source */
     481                /*
     482                 * UHCI can't report OC condition or,
     483                 * lose power source
     484                 */
    475485                .callback = virthub_base_get_null_status,
    476486        },
     
    483493                CLASS_REQ_OUT(USB_REQUEST_RECIPIENT_DEVICE, USB_HUB_REQUEST_SET_FEATURE),
    484494                .name = "SetHubFeature",
    485                 /* Hub features are overcurrent and supply good,
    486                  * this request may only set changes that we never report*/
     495                /*
     496                 * Hub features are overcurrent and supply good,
     497                 * this request may only set changes that we never report
     498                 */
    487499                .callback = req_nop,
    488500        },
  • uspace/drv/bus/usb/usbhub/port.c

    rfac0ac7 r7c3fb9b  
    236236        const bool overcurrent = !!(status & USB_HUB_PORT_STATUS_OC);
    237237
    238         /* According to the USB specs:
     238        /*
     239         * According to the USB specs:
    239240         * 11.13.5 Over-current Reporting and Recovery
    240241         * Hub device is responsible for putting port in power off
    241242         * mode. USB system software is responsible for powering port
    242          * back on when the over-current condition is gone */
     243         * back on when the over-current condition is gone
     244         */
    243245
    244246        usb_port_disabled(&port->base, &remove_device);
  • uspace/drv/bus/usb/usbhub/usbhub.c

    rfac0ac7 r7c3fb9b  
    460460        }
    461461
    462         /* Set configuration. Use the configuration that was in
    463          * usb_device->descriptors.configuration i.e. The first one. */
     462        /*
     463         * Set configuration. Use the configuration that was in
     464         * usb_device->descriptors.configuration i.e. The first one.
     465         */
    464466        errno_t opResult = usb_request_set_configuration(
    465467            usb_device_get_default_pipe(usb_device),
     
    593595        assert(status);
    594596
    595         /* USB hub specific GET_PORT_STATUS request. See USB Spec 11.16.2.6
     597        /*
     598         * USB hub specific GET_PORT_STATUS request. See USB Spec 11.16.2.6
    596599         * Generic GET_STATUS request cannot be used because of the difference
    597          * in status data size (2B vs. 4B)*/
     600         * in status data size (2B vs. 4B)
     601         */
    598602        const usb_device_request_setup_packet_t request = {
    599603                .request_type = USB_HUB_REQ_TYPE_GET_PORT_STATUS,
     
    635639        usb_hub_status_t status;
    636640        size_t rcvd_size;
    637         /* NOTE: We can't use standard USB GET_STATUS request, because
    638          * hubs reply is 4byte instead of 2 */
     641        /*
     642         * NOTE: We can't use standard USB GET_STATUS request, because
     643         * hubs reply is 4byte instead of 2
     644         */
    639645        const errno_t opResult = usb_pipe_control_read(control_pipe,
    640646            &get_hub_status_request, sizeof(get_hub_status_request),
     
    666672
    667673        if (status & USB_HUB_STATUS_C_LOCAL_POWER) {
    668                 /* NOTE: Handling this is more complicated.
     674                /*
     675                 * NOTE: Handling this is more complicated.
    669676                 * If the transition is from bus power to local power, all
    670677                 * is good and we may signal the parent hub that we don't
  • uspace/drv/bus/usb/usbmid/explore.c

    rfac0ac7 r7c3fb9b  
    8585            usb_dp_get_nested_descriptor(&parser, &data, config_descriptor);
    8686
    87         /* Walk all descriptors nested in the current configuration decriptor;
    88          * i.e. all interface descriptors. */
     87        /*
     88         * Walk all descriptors nested in the current configuration decriptor;
     89         * i.e. all interface descriptors.
     90         */
    8991        for (; interface_ptr != NULL;
    9092            interface_ptr = usb_dp_get_sibling_descriptor(
     
    99101                /* Skip alternate interfaces. */
    100102                if (interface_in_list(list, interface->interface_number)) {
    101                         /* TODO: add the alternatives and create match ids
    102                          * for them. */
     103                        /*
     104                         * TODO: add the alternatives and create match ids
     105                         * for them.
     106                         */
    103107                        continue;
    104108                }
  • uspace/drv/bus/usb/xhci/commands.c

    rfac0ac7 r7c3fb9b  
    358358
    359359        if (code == XHCI_TRBC_COMMAND_RING_STOPPED) {
    360                 /* This can either mean that the ring is being stopped, or
     360                /*
     361                 * This can either mean that the ring is being stopped, or
    361362                 * a command was aborted. In either way, wake threads waiting
    362363                 * on stopped_cv.
     
    671672
    672673        if (XHCI_REG_RD(hc->op_regs, XHCI_OP_CRR)) {
    673                 /* 4.6.1.2, implementation note
     674                /*
     675                 * 4.6.1.2, implementation note
    674676                 * Assume there are larger problems with HC and
    675677                 * reset it.
     
    720722                    &cmd->_header.completed_mtx, XHCI_COMMAND_TIMEOUT);
    721723
    722                 /* The waiting timed out. Current command (not necessarily
     724                /*
     725                 * The waiting timed out. Current command (not necessarily
    723726                 * ours) is probably blocked.
    724727                 */
  • uspace/drv/bus/usb/xhci/hc.c

    rfac0ac7 r7c3fb9b  
    534534        joinable_fibril_join(hc->event_worker);
    535535
    536         /* Then, disconnect all roothub devices, which shall trigger
    537          * disconnection of everything */
     536        /*
     537         * Then, disconnect all roothub devices, which shall trigger
     538         * disconnection of everything
     539         */
    538540        xhci_rh_stop(&hc->rh);
    539541}
     
    576578                XHCI_REG_WR(hc->rt_regs->ir, XHCI_INTR_IP, 1);
    577579
    578                 /* interrupt handler expects status from irq_commands, which is
    579                  * in xhci order. */
     580                /*
     581                 * interrupt handler expects status from irq_commands, which is
     582                 * in xhci order.
     583                 */
    580584                *status = host2xhci(32, *status);
    581585        }
     
    873877        xhci_endpoint_t *ep0 = xhci_endpoint_get(dev->base.endpoints[0]);
    874878
    875         /* Although we have the precise PSIV value on devices of tier 1,
    876          * we have to rely on reverse mapping on others. */
     879        /*
     880         * Although we have the precise PSIV value on devices of tier 1,
     881         * we have to rely on reverse mapping on others.
     882         */
    877883        if (!usb_speed_to_psiv[dev->base.speed]) {
    878884                usb_log_error("Device reported an USB speed (%s) that cannot be mapped "
  • uspace/drv/bus/usb/xhci/hw_struct/regs.h

    rfac0ac7 r7c3fb9b  
    368368        ioport32_t dnctrl;
    369369
    370         /*          3  2  1   0
     370        /*
     371         *          3  2  1   0
    371372         *  3:0 - CRR CA CS RCS
    372373         * 64:6 - Command Ring Pointer
  • uspace/drv/bus/usb/xhci/rh.c

    rfac0ac7 r7c3fb9b  
    291291        joinable_fibril_start(rh->event_worker);
    292292
    293         /* The reset changed status of all ports, and SW originated reason does
     293        /*
     294         * The reset changed status of all ports, and SW originated reason does
    294295         * not cause an interrupt.
    295296         */
Note: See TracChangeset for help on using the changeset viewer.