Changeset df6ded8 in mainline for uspace/drv/bus/usb/ehci/hw_struct


Ignore:
Timestamp:
2018-02-28T16:37:50Z (8 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
Location:
uspace/drv/bus/usb/ehci/hw_struct
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/hw_struct/iso_transfer_descriptor.h

    rf5e5f73 rdf6ded8  
    7272        /* 64 bit struct only */
    7373        volatile uint32_t extended_bp[7];
    74 } itd_t;
     74} __attribute__((packed, aligned(32))) itd_t;
    7575#endif
    7676/**
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.c

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2013 Jan Vesely
     3 * Copyright (c) 2018 Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    3738#include <mem.h>
    3839#include <macros.h>
     40#include <usb/host/bus.h>
    3941
    4042#include "mem_access.h"
     
    6365                return;
    6466        }
    65         assert(ep->speed < ARRAY_SIZE(speed));
     67        assert(ep->device->speed < ARRAY_SIZE(speed));
    6668        EHCI_MEM32_WR(instance->ep_char,
    67             QH_EP_CHAR_ADDR_SET(ep->address) |
     69            QH_EP_CHAR_ADDR_SET(ep->device->address) |
    6870            QH_EP_CHAR_EP_SET(ep->endpoint) |
    69             speed[ep->speed] |
    70             QH_EP_CHAR_MAX_LENGTH_SET(ep->max_packet_size)
    71         );
     71            speed[ep->device->speed] |
     72            QH_EP_CHAR_MAX_LENGTH_SET(ep->max_packet_size));
    7273        if (ep->transfer_type == USB_TRANSFER_CONTROL) {
    73                 if (ep->speed != USB_SPEED_HIGH)
     74                if (ep->device->speed != USB_SPEED_HIGH)
    7475                        EHCI_MEM32_SET(instance->ep_char, QH_EP_CHAR_C_FLAG);
    7576                /* Let BULK and INT use queue head managed toggle,
     
    7879        }
    7980        uint32_t ep_cap = QH_EP_CAP_C_MASK_SET(3 << 2) |
    80                     QH_EP_CAP_MULTI_SET(ep->packets);
    81         if (ep->speed != USB_SPEED_HIGH) {
     81            QH_EP_CAP_MULTI_SET(ep->packets_per_uframe);
     82        if (usb_speed_is_11(ep->device->speed)) {
     83                assert(ep->device->tt.dev != NULL);
    8284                ep_cap |=
    83                     QH_EP_CAP_TT_PORT_SET(ep->tt.port) |
    84                     QH_EP_CAP_TT_ADDR_SET(ep->tt.address);
     85                    QH_EP_CAP_TT_PORT_SET(ep->device->tt.port) |
     86                    QH_EP_CAP_TT_ADDR_SET(ep->device->tt.dev->address);
    8587        }
    8688        if (ep->transfer_type == USB_TRANSFER_INTERRUPT) {
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.h

    rf5e5f73 rdf6ded8  
    143143        /* 64 bit struct only */
    144144        volatile uint32_t extended_bp[5];
    145 } qh_t;
     145} __attribute__((packed, aligned(32))) qh_t;
    146146
    147147static inline void qh_append_qh(qh_t *qh, const qh_t *next)
     
    193193}
    194194
    195 static inline void qh_set_next_td(qh_t *qh, td_t *td)
     195static inline void qh_set_next_td(qh_t *qh, uintptr_t td)
    196196{
    197197        assert(qh);
    198198        assert(td);
    199         EHCI_MEM32_WR(qh->next, LINK_POINTER_TD(addr_to_phys(td)));
     199        EHCI_MEM32_WR(qh->next, LINK_POINTER_TD(td));
    200200}
    201201
  • uspace/drv/bus/usb/ehci/hw_struct/split_iso_transfer_descriptor.h

    rf5e5f73 rdf6ded8  
    8989        /* 64 bit struct only */
    9090        volatile uint32_t extended_bp[2];
    91 } sitd_t;
     91} __attribute__((packed, aligned(32))) sitd_t;
    9292#endif
    9393/**
  • uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.c

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2014 Jan Vesely
     3 * Copyright (c) 2018 Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    3940
    4041#include <usb/usb.h>
    41 #include <usb/host/utils/malloc32.h>
    4242
    4343#include "mem_access.h"
     
    7070};
    7171
     72#include <usb/debug.h>
     73
    7274/**
    7375 * Initialize EHCI TD.
    7476 * @param instance TD structure to initialize.
    75  * @param next Next TD in ED list.
     77 * @param next_phys Next TD in ED list.
    7678 * @param direction Used to determine PID, BOTH means setup PID.
    7779 * @param buffer Pointer to the first byte of transferred data.
     
    8082 *        any other value means that ED toggle will be used.
    8183 */
    82 void td_init(td_t *instance, const td_t *next,
    83     usb_direction_t direction, const void *buffer, size_t size, int toggle,
    84     bool ioc)
     84void td_init(td_t *instance, uintptr_t next_phys, uintptr_t buffer,
     85    usb_direction_t direction, size_t size, int toggle, bool ioc)
    8586{
    8687        assert(instance);
     
    9899        }
    99100
    100         if (buffer != NULL) {
     101        if (buffer != 0) {
    101102                assert(size != 0);
    102103                for (unsigned i = 0; (i < ARRAY_SIZE(instance->buffer_pointer))
    103104                    && size; ++i) {
    104                         const uintptr_t page =
    105                             (addr_to_phys(buffer) & TD_BUFFER_POINTER_MASK);
    106                         const size_t offset =
    107                             ((uintptr_t)buffer & TD_BUFFER_POINTER_OFFSET_MASK);
     105                        const uintptr_t offset = buffer & TD_BUFFER_POINTER_OFFSET_MASK;
    108106                        assert(offset == 0 || i == 0);
    109                         size -= min((4096 - offset), size);
    110                         buffer += min((4096 - offset), size);
    111                         EHCI_MEM32_WR(instance->buffer_pointer[i],
    112                             page | offset);
     107                        const size_t this_size = min(size, 4096 - offset);
     108                        EHCI_MEM32_WR(instance->buffer_pointer[i], buffer);
     109                        size -= this_size;
     110                        buffer += this_size;
    113111                }
    114112        }
    115113
    116         EHCI_MEM32_WR(instance->next, next ?
    117             LINK_POINTER_TD(addr_to_phys(next)) : LINK_POINTER_TERM);
     114        EHCI_MEM32_WR(instance->next, next_phys ?
     115            LINK_POINTER_TD(next_phys) : LINK_POINTER_TERM);
    118116
    119117        EHCI_MEM32_WR(instance->alternate, LINK_POINTER_TERM);
  • uspace/drv/bus/usb/ehci/hw_struct/transfer_descriptor.h

    rf5e5f73 rdf6ded8  
    3737#include <stddef.h>
    3838#include <stdint.h>
     39#include <macros.h>
    3940#include "link_pointer.h"
    4041#include "mem_access.h"
     
    7576        /* 64 bit struct only */
    7677        volatile uint32_t extended_bp[5];
    77 } td_t;
     78
     79} __attribute__((packed,aligned(32))) td_t;
     80
     81static_assert(sizeof(td_t) % 32 == 0);
    7882
    7983static inline bool td_active(const td_t *td)
     
    9296errno_t td_error(const td_t *td);
    9397
    94 void td_init(td_t *td, const td_t *next, usb_direction_t dir, const void * buf,
     98void td_init(td_t *td, uintptr_t next_phys, uintptr_t buf, usb_direction_t dir,
    9599    size_t buf_size, int toggle, bool ioc);
    96100
Note: See TracChangeset for help on using the changeset viewer.