use tock_registers::{register_bitfields, register_structs, registers::ReadOnly};

register_bitfields! {
    u32,
    pub HCSPARAMS1 [
        MaxSlots            OFFSET(0)   NUMBITS(8)  [],
        MaxIntrs            OFFSET(8)   NUMBITS(11) [],
        MaxPorts            OFFSET(24)  NUMBITS(8)  [],
    ],
    pub HCSPARAMS2 [
        IST                 OFFSET(0)   NUMBITS(4)  [],
        ERSTMax             OFFSET(4)   NUMBITS(4)  [],
        MaxScratchpadBufsHi OFFSET(21)  NUMBITS(5)  [],
        ScratchpadRestore   OFFSET(26)  NUMBITS(1)  [],
        MaxScratchpadBufsLo OFFSET(27)  NUMBITS(5)  [],
    ],
    pub HCSPARAMS3 [
        U1ExitLatency       OFFSET(0)   NUMBITS(8)  [],
        U2ExitLatency       OFFSET(16)  NUMBITS(16) [],
    ],
    pub HCCPARAMS1 [
        AC64                OFFSET(0)   NUMBITS(1)  [],
        BNC                 OFFSET(1)   NUMBITS(1)  [],
        CSZ                 OFFSET(2)   NUMBITS(1)  [],
        PPC                 OFFSET(3)   NUMBITS(1)  [],
        PIND                OFFSET(4)   NUMBITS(1)  [],
        LHRC                OFFSET(5)   NUMBITS(1)  [],
        LTC                 OFFSET(6)   NUMBITS(1)  [],
        NSS                 OFFSET(7)   NUMBITS(1)  [],
        PAE                 OFFSET(8)   NUMBITS(1)  [],
        SPC                 OFFSET(9)   NUMBITS(1)  [],
        SEC                 OFFSET(10)  NUMBITS(1)  [],
        CFC                 OFFSET(11)  NUMBITS(1)  [],
        MaxPSASize          OFFSET(12)  NUMBITS(4)  [],
        XECP                OFFSET(16)  NUMBITS(16) [],
    ],
    pub HCCPARAMS2 [
        U3C                 OFFSET(0)   NUMBITS(1)  [],
        CMC                 OFFSET(1)   NUMBITS(1)  [],
        FSC                 OFFSET(2)   NUMBITS(1)  [],
        CTC                 OFFSET(3)   NUMBITS(1)  [],
        LEC                 OFFSET(4)   NUMBITS(1)  [],
        CIC                 OFFSET(5)   NUMBITS(1)  [],
        ETC                 OFFSET(6)   NUMBITS(1)  [],
        ETC_TSC             OFFSET(7)   NUMBITS(1)  [],
        GSC                 OFFSET(8)   NUMBITS(1)  [],
        VTC                 OFFSET(9)   NUMBITS(1)  [],
    ],
}

register_structs! {
    #[allow(non_snake_case)]
    pub CapabilityRegs {
        (0x00 => pub CAPLENGTH: ReadOnly<u8>),
        (0x01 => _0),
        (0x02 => pub HCIVERSION: ReadOnly<u16>),
        (0x04 => pub HCSPARAMS1: ReadOnly<u32, HCSPARAMS1::Register>),
        (0x08 => pub HCSPARAMS2: ReadOnly<u32, HCSPARAMS2::Register>),
        (0x0C => pub HCSPARAMS3: ReadOnly<u32, HCSPARAMS3::Register>),
        (0x10 => pub HCCPARAMS1: ReadOnly<u32, HCCPARAMS1::Register>),
        (0x14 => pub DBOFF: ReadOnly<u32>),
        (0x18 => pub RTSOFF: ReadOnly<u32>),
        (0x1C => pub HCCPARAMS2: ReadOnly<u32, HCCPARAMS2::Register>),
        (0x20 => @END),
    }
}
