Ignore:
Timestamp:
2017-06-22T13:59:15Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e4d7363
Parents:
62ba2cbe
Message:

xhci: event rings && hc initialization (WIP)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/hw_struct/regs.h

    r62ba2cbe rcb89430  
    4343#include "common.h"
    4444
    45 /*
    46  */
    47 
    4845#define XHCI_PIO_CHANGE_UDELAY 5
    49 
    50 #define host2xhci(size, val) host2uint##size##_t_le((val))
    51 #define xhci2host(size, val) uint##size##_t_le2host((val))
    5246
    5347/*
     
    6357#define XHCI_REG_SET(reg_set, reg_spec, value) XHCI_REG_SET_INNER(reg_set, value, reg_spec)
    6458#define XHCI_REG_CLR(reg_set, reg_spec, value) XHCI_REG_CLR_INNER(reg_set, value, reg_spec)
     59#define XHCI_REG_MASK(reg_spec)                XHCI_REG_MASK_INNER(reg_spec)
     60#define XHCI_REG_SHIFT(reg_spec)               XHCI_REG_SHIFT_INNER(reg_spec)
    6561
    6662/*
     
    7874#define XHCI_REG_CLR_INNER(reg_set, value, field, size, type, ...) \
    7975        XHCI_REG_CLR_##type(&(reg_set)->field, value, size, ##__VA_ARGS__)
     76
     77#define XHCI_REG_MASK_INNER(field, size, type, ...) \
     78        XHCI_REG_MASK_##type(size, ##__VA_ARGS__)
     79
     80#define XHCI_REG_SHIFT_INNER(field, size, type, ...) \
     81        XHCI_REG_SHIFT_##type(size, ##__VA_ARGS__)
    8082
    8183/*
     
    8688#define XHCI_REG_SET_FIELD(ptr, value, size) pio_set_##size((ptr), host2xhci(size, value), XHCI_PIO_CHANGE_UDELAY);
    8789#define XHCI_REG_CLR_FIELD(ptr, value, size) pio_clear_##size((ptr), host2xhci(size, value), XHCI_PIO_CHANGE_UDELAY);
     90#define XHCI_REG_MASK_FIELD(size)            (~((uint##size##_t) 0))
     91#define XHCI_REG_SHIFT_FIELD(size)           (0)
    8892
    8993/*
     
    9498#define XHCI_REG_SET_FLAG(ptr, value, size, offset) XHCI_REG_SET_RANGE((ptr), (value), size, (offset), (offset))
    9599#define XHCI_REG_CLR_FLAG(ptr, value, size, offset) XHCI_REG_CLR_RANGE((ptr), (value), size, (offset), (offset))
     100#define XHCI_REG_MASK_FLAG(size, offset)            BIT_V(uint##size##_t, offset)
     101#define XHCI_REG_SHIFT_FLAG(size, offset)           (offset)
    96102
    97103/*
     
    113119        pio_clear_##size((ptr), host2xhci(size, BIT_RANGE_INSERT(uint##size##_t, (hi), (lo), (value))), \
    114120                XHCI_PIO_CHANGE_UDELAY);
     121
     122#define XHCI_REG_MASK_RANGE(size, hi, lo)  BIT_RANGE(uint##size##_t, hi, lo)
     123#define XHCI_REG_SHIFT_RANGE(size, hi, lo) (lo)
    115124
    116125/** HC capability registers: section 5.3 */
     
    215224#define XHCI_CAP_CIC          hccparams2, 32,  FLAG,  5
    216225
     226static inline unsigned xhci_get_max_spbuf(xhci_cap_regs_t *cap_regs) {
     227        return XHCI_REG_RD(cap_regs, XHCI_CAP_MAX_SPBUF_HI) << 5
     228                | XHCI_REG_RD(cap_regs, XHCI_CAP_MAX_SPBUF_LO);
     229}
     230
    217231/**
    218232 * XHCI Port Register Set: section 5.4, table 32
     
    395409#define XHCI_OP_CRCR_LO        crcr_lo, 32, RANGE, 31, 6
    396410#define XHCI_OP_CRCR_HI        crcr_lo, 32, FIELD
     411#define XHCI_OP_DCBAAP_LO    dcbaap_lo, 32, FIELD
     412#define XHCI_OP_DCBAAP_HI    dcbaap_lo, 32, FIELD
     413#define XHCI_OP_MAX_SLOTS_EN    config, 32, RANGE, 7, 0
     414#define XHCI_OP_U3E             config, 32,  FLAG, 8
     415#define XHCI_OP_CIE             config, 32,  FLAG, 9
     416
     417/* Aggregating field to read & write whole status at once */
     418#define XHCI_OP_STATUS          usbsts, 32, RANGE, 12, 0
     419
     420/* RW1C fields in usbsts */
     421#define XHCI_STATUS_ACK_MASK     0x41C
    397422
    398423/**
     
    444469        ioport32_t mfindex;
    445470
    446         PADD32 [5];
    447 
    448         xhci_interrupter_regs_t ir[1024];
     471        PADD32 [7];
     472
     473        xhci_interrupter_regs_t ir [];
    449474} xhci_rt_regs_t;
    450475
     
    452477
    453478/**
    454  * XHCI Doorbel Registers: section 5.6
    455  *
    456  * These registers are write-only, thus convenience macros are useless.
     479 * XHCI Doorbell Registers: section 5.6
     480 *
     481 * These registers are to be written as a whole field.
    457482 */
    458483typedef ioport32_t xhci_doorbell_t;
Note: See TracChangeset for help on using the changeset viewer.