use register::mmio::*;

#[derive(Debug, PartialEq, Copy, Clone)]
pub enum PinGrP {
    Sdmmc1ClkPm0,
    Sdmmc1CmdPm1,
    Sdmmc1Dat3Pm2,
    Sdmmc1Dat2Pm3,
    Sdmmc1Dat1Pm4,
    Sdmmc1Dat0Pm5,
    Sdmmc3ClkPp0 = (0x1c / 4),
    Sdmmc3CmdPp1,
    Sdmmc3Dat0Pp5,
    Sdmmc3Dat1Pp4,
    Sdmmc3Dat2Pp3,
    Sdmmc3Dat3Pp2,
    PexL0RstNPa0 = (0x38 / 4),
    PexL0ClkreqNPa1,
    PexWakeNPa2,
    PexL1RstNPa3,
    PexL1ClkreqNPa4,
    SataLedActivePa5,
    Spi1MosiPc0,
    Spi1MisoPc1,
    Spi1SckPc2,
    Spi1Cs0Pc3,
    Spi1Cs1Pc4,
    Spi2MosiPb4,
    Spi2MisoPb5,
    Spi2SckPb6,
    Spi2Cs0Pb7,
    Spi2Cs1Pdd0,
    Spi4MosiPc7,
    Spi4MisoPd0,
    Spi4SckPc5,
    Spi4Cs0Pc6,
    QspiSckPee0,
    QspiCsNPee1,
    QspiIo0Pee2,
    QspiIo1Pee3,
    QspiIo2Pee4,
    QspiIo3Pee5,
    Dmic1ClkPe0 = (0xa4 / 4),
    Dmic1DatPe1,
    Dmic2ClkPe2,
    Dmic2DatPe3,
    Dmic3ClkPe4,
    Dmic3DatPe5,
    Gen1I2CSclPj1,
    Gen1I2CSdaPj0,
    Gen2I2CSclPj2,
    Gen2I2CSdaPj3,
    Gen3I2CSclPf0,
    Gen3I2CSdaPf1,
    CamI2CSclPs2,
    CamI2CSdaPs3,
    PwrI2CSclPy3,
    PwrI2CSdaPy4,
    Uart1TxPu0,
    Uart1RxPu1,
    Uart1RtsPu2,
    Uart1CtsPu3,
    Uart2TxPg0,
    Uart2RxPg1,
    Uart2RtsPg2,
    Uart2CtsPg3,
    Uart3TxPd1,
    Uart3RxPd2,
    Uart3RtsPd3,
    Uart3CtsPd4,
    Uart4TxPi4,
    Uart4RxPi5,
    Uart4RtsPi6,
    Uart4CtsPi7,
    Dap1FsPb0,
    Dap1DinPb1,
    Dap1DoutPb2,
    Dap1SclkPb3,
    Dap2FsPaa0,
    Dap2DinPaa2,
    Dap2DoutPaa3,
    Dap2SclkPaa1,
    Dap4FsPj4,
    Dap4DinPj5,
    Dap4DoutPj6,
    Dap4SclkPj7,
    Cam1MclkPs0,
    Cam2MclkPs1,
    JtagRtck,
    Clk32KIn,
    Clk32KOutPy5,
    BattBcl,
    ClkReq,
    CpuPwrReq,
    PwrIntN,
    Shutdown,
    CorePwrReq,
    AudMclkPbb0,
    DvfsPwmPbb1,
    DvfsClkPbb2,
    GpioX1AudPbb3,
    GpioX3AudPbb4,
    Pcc7,
    HdmiCecPcc0,
    HdmiIntDpHpdPcc1,
    SpdifOutPcc2,
    SpdifInPcc3,
    UsbVbusEn0Pcc4,
    UsbVbusEn1Pcc5,
    DpHpd0Pcc6,
    WifiEnPh0,
    WifiRstPh1,
    WifiWakeApPh2,
    ApWakeBtPh3,
    BtRstPh4,
    BtWakeApPh5,
    ApWakeNfcPh7,
    NfcEnPi0,
    NfcIntPi1,
    GpsEnPi2,
    GpsRstPi3,
    CamRstPs4,
    CamAfEnPs5,
    CamFlashEnPs6,
    Cam1PwdnPs7,
    Cam2PwdnPt0,
    Cam1StrobePt1,
    LcdTePy2,
    LcdBlPwmPv0,
    LcdBlEnPv1,
    LcdRstPv2,
    LcdGpio1Pv3,
    LcdGpio2Pv4,
    ApReadyPv5,
    TouchRstPv6,
    TouchClkPv7,
    ModemWakeApPx0,
    TouchIntPx1,
    MotionIntPx2,
    AlsProxIntPx3,
    TempAlertPx4,
    ButtonPowerOnPx5,
    ButtonVolUpPx6,
    ButtonVolDownPx7,
    ButtonSlideSwPy0,
    ButtonHomePy1,
    Pa6,
    Pe6,
    Pe7,
    Ph6,
    Pk0,
    Pk1,
    Pk2,
    Pk3,
    Pk4,
    Pk5,
    Pk6,
    Pk7,
    Pl0,
    Pl1,
    Pz0,
    Pz1,
    Pz2,
    Pz3,
    Pz4,
    Pz5,

    // not expected
    Reserved,
}

#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
pub enum PinFunction {
    Default,
    Aud,
    Bcl,
    Blink,
    Ccla,
    Cec,
    Cldvfs,
    Clk,
    Core,
    Cpu,
    Displaya,
    Displayb,
    Dmic1,
    Dmic2,
    Dmic3,
    Dp,
    Dtv,
    Extperiph3,
    I2C1,
    I2C2,
    I2C3,
    I2Cpmu,
    I2Cvi,
    I2S1,
    I2S2,
    I2S3,
    I2S4A,
    I2S4B,
    I2S5A,
    I2S5B,
    Iqc0,
    Iqc1,
    Jtag,
    Pe,
    Pe0,
    Pe1,
    Pmi,
    Pwm0,
    Pwm1,
    Pwm2,
    Pwm3,
    Qspi,
    Sata,
    Sdmmc1,
    Sdmmc3,
    Shutdown,
    Soc,
    Sor0,
    Sor1,
    Spdif,
    Spi1,
    Spi2,
    Spi3,
    Spi4,
    Sys,
    Touch,
    Uart,
    Uarta,
    Uartb,
    Uartc,
    Uartd,
    Usb,
    Vgp1,
    Vgp2,
    Vgp3,
    Vgp4,
    Vgp5,
    Vgp6,
    Vimclk,
    Vimclk2,
    Rsvd0,
    Rsvd1,
    Rsvd2,
    Rsvd3,

    // not expected
    Reserved,
}

#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
pub enum PinPull {
    Normal,
    Down,
    Up,
}

#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
pub enum PinTristate {
    Normal,
    Tristate,
}

#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
pub enum PinIo {
    Output,
    Input,
    None,
}

#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
pub enum PinLock {
    Default,
    Disable,
    Enable,
}

#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
pub enum PinOd {
    Default,
    Disable,
    Enable,
}

#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
pub enum PinEIoHv {
    Default,
    Normal,
    High,
}

#[derive(Debug)]
pub struct SocPinGrP(PinGrP, [PinFunction; 4]);

const SOC_GROUPS: [SocPinGrP; 165] = [
    SocPinGrP(
        PinGrP::Sdmmc1ClkPm0,
        [
            PinFunction::Sdmmc1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc1CmdPm1,
        [
            PinFunction::Sdmmc1,
            PinFunction::Spi3,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc1Dat3Pm2,
        [
            PinFunction::Sdmmc1,
            PinFunction::Spi3,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc1Dat2Pm3,
        [
            PinFunction::Sdmmc1,
            PinFunction::Spi3,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc1Dat1Pm4,
        [
            PinFunction::Sdmmc1,
            PinFunction::Spi3,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc1Dat0Pm5,
        [
            PinFunction::Sdmmc1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Reserved,
        [
            PinFunction::Reserved,
            PinFunction::Reserved,
            PinFunction::Reserved,
            PinFunction::Reserved,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc3ClkPp0,
        [
            PinFunction::Sdmmc3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc3CmdPp1,
        [
            PinFunction::Sdmmc3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc3Dat0Pp5,
        [
            PinFunction::Sdmmc3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc3Dat1Pp4,
        [
            PinFunction::Sdmmc3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc3Dat2Pp3,
        [
            PinFunction::Sdmmc3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Sdmmc3Dat3Pp2,
        [
            PinFunction::Sdmmc3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Reserved,
        [
            PinFunction::Reserved,
            PinFunction::Reserved,
            PinFunction::Reserved,
            PinFunction::Reserved,
        ],
    ),
    SocPinGrP(
        PinGrP::PexL0RstNPa0,
        [
            PinFunction::Pe0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::PexL0ClkreqNPa1,
        [
            PinFunction::Pe0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::PexWakeNPa2,
        [
            PinFunction::Pe,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::PexL1RstNPa3,
        [
            PinFunction::Pe1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::PexL1ClkreqNPa4,
        [
            PinFunction::Pe1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::SataLedActivePa5,
        [
            PinFunction::Sata,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi1MosiPc0,
        [
            PinFunction::Spi1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi1MisoPc1,
        [
            PinFunction::Spi1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi1SckPc2,
        [
            PinFunction::Spi1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi1Cs0Pc3,
        [
            PinFunction::Spi1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi1Cs1Pc4,
        [
            PinFunction::Spi1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi2MosiPb4,
        [
            PinFunction::Spi2,
            PinFunction::Dtv,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi2MisoPb5,
        [
            PinFunction::Spi2,
            PinFunction::Dtv,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi2SckPb6,
        [
            PinFunction::Spi2,
            PinFunction::Dtv,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi2Cs0Pb7,
        [
            PinFunction::Spi2,
            PinFunction::Dtv,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi2Cs1Pdd0,
        [
            PinFunction::Spi2,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi4MosiPc7,
        [
            PinFunction::Spi4,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi4MisoPd0,
        [
            PinFunction::Spi4,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi4SckPc5,
        [
            PinFunction::Spi4,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Spi4Cs0Pc6,
        [
            PinFunction::Spi4,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::QspiSckPee0,
        [
            PinFunction::Qspi,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::QspiCsNPee1,
        [
            PinFunction::Qspi,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::QspiIo0Pee2,
        [
            PinFunction::Qspi,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::QspiIo1Pee3,
        [
            PinFunction::Qspi,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::QspiIo2Pee4,
        [
            PinFunction::Qspi,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::QspiIo3Pee5,
        [
            PinFunction::Qspi,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Reserved,
        [
            PinFunction::Reserved,
            PinFunction::Reserved,
            PinFunction::Reserved,
            PinFunction::Reserved,
        ],
    ),
    SocPinGrP(
        PinGrP::Dmic1ClkPe0,
        [
            PinFunction::Dmic1,
            PinFunction::I2S3,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dmic1DatPe1,
        [
            PinFunction::Dmic1,
            PinFunction::I2S3,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dmic2ClkPe2,
        [
            PinFunction::Dmic2,
            PinFunction::I2S3,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dmic2DatPe3,
        [
            PinFunction::Dmic2,
            PinFunction::I2S3,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dmic3ClkPe4,
        [
            PinFunction::Dmic3,
            PinFunction::I2S5A,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dmic3DatPe5,
        [
            PinFunction::Dmic3,
            PinFunction::I2S5A,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Gen1I2CSclPj1,
        [
            PinFunction::I2C1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Gen1I2CSdaPj0,
        [
            PinFunction::I2C1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Gen2I2CSclPj2,
        [
            PinFunction::I2C2,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Gen2I2CSdaPj3,
        [
            PinFunction::I2C2,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Gen3I2CSclPf0,
        [
            PinFunction::I2C3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Gen3I2CSdaPf1,
        [
            PinFunction::I2C3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::CamI2CSclPs2,
        [
            PinFunction::I2C3,
            PinFunction::I2Cvi,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::CamI2CSdaPs3,
        [
            PinFunction::I2C3,
            PinFunction::I2Cvi,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::PwrI2CSclPy3,
        [
            PinFunction::I2Cpmu,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::PwrI2CSdaPy4,
        [
            PinFunction::I2Cpmu,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart1TxPu0,
        [
            PinFunction::Uarta,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart1RxPu1,
        [
            PinFunction::Uarta,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart1RtsPu2,
        [
            PinFunction::Uarta,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart1CtsPu3,
        [
            PinFunction::Uarta,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart2TxPg0,
        [
            PinFunction::Uartb,
            PinFunction::I2S4A,
            PinFunction::Spdif,
            PinFunction::Uart,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart2RxPg1,
        [
            PinFunction::Uartb,
            PinFunction::I2S4A,
            PinFunction::Spdif,
            PinFunction::Uart,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart2RtsPg2,
        [
            PinFunction::Uartb,
            PinFunction::I2S4A,
            PinFunction::Rsvd2,
            PinFunction::Uart,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart2CtsPg3,
        [
            PinFunction::Uartb,
            PinFunction::I2S4A,
            PinFunction::Rsvd2,
            PinFunction::Uart,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart3TxPd1,
        [
            PinFunction::Uartc,
            PinFunction::Spi4,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart3RxPd2,
        [
            PinFunction::Uartc,
            PinFunction::Spi4,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart3RtsPd3,
        [
            PinFunction::Uartc,
            PinFunction::Spi4,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart3CtsPd4,
        [
            PinFunction::Uartc,
            PinFunction::Spi4,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart4TxPi4,
        [
            PinFunction::Uartd,
            PinFunction::Uart,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart4RxPi5,
        [
            PinFunction::Uartd,
            PinFunction::Uart,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart4RtsPi6,
        [
            PinFunction::Uartd,
            PinFunction::Uart,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Uart4CtsPi7,
        [
            PinFunction::Uartd,
            PinFunction::Uart,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap1FsPb0,
        [
            PinFunction::I2S1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap1DinPb1,
        [
            PinFunction::I2S1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap1DoutPb2,
        [
            PinFunction::I2S1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap1SclkPb3,
        [
            PinFunction::I2S1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap2FsPaa0,
        [
            PinFunction::I2S2,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap2DinPaa2,
        [
            PinFunction::I2S2,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap2DoutPaa3,
        [
            PinFunction::I2S2,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap2SclkPaa1,
        [
            PinFunction::I2S2,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap4FsPj4,
        [
            PinFunction::I2S4B,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap4DinPj5,
        [
            PinFunction::I2S4B,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap4DoutPj6,
        [
            PinFunction::I2S4B,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Dap4SclkPj7,
        [
            PinFunction::I2S4B,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Cam1MclkPs0,
        [
            PinFunction::Extperiph3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Cam2MclkPs1,
        [
            PinFunction::Extperiph3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::JtagRtck,
        [
            PinFunction::Jtag,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Clk32KIn,
        [
            PinFunction::Clk,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Clk32KOutPy5,
        [
            PinFunction::Soc,
            PinFunction::Blink,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::BattBcl,
        [
            PinFunction::Bcl,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::ClkReq,
        [
            PinFunction::Sys,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::CpuPwrReq,
        [
            PinFunction::Cpu,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::PwrIntN,
        [
            PinFunction::Pmi,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Shutdown,
        [
            PinFunction::Shutdown,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::CorePwrReq,
        [
            PinFunction::Core,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::AudMclkPbb0,
        [
            PinFunction::Aud,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::DvfsPwmPbb1,
        [
            PinFunction::Rsvd0,
            PinFunction::Cldvfs,
            PinFunction::Spi3,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::DvfsClkPbb2,
        [
            PinFunction::Rsvd0,
            PinFunction::Cldvfs,
            PinFunction::Spi3,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::GpioX1AudPbb3,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Spi3,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::GpioX3AudPbb4,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Spi3,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pcc7,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::HdmiCecPcc0,
        [
            PinFunction::Cec,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::HdmiIntDpHpdPcc1,
        [
            PinFunction::Dp,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::SpdifOutPcc2,
        [
            PinFunction::Spdif,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::SpdifInPcc3,
        [
            PinFunction::Spdif,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::UsbVbusEn0Pcc4,
        [
            PinFunction::Usb,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::UsbVbusEn1Pcc5,
        [
            PinFunction::Usb,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::DpHpd0Pcc6,
        [
            PinFunction::Dp,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::WifiEnPh0,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::WifiRstPh1,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::WifiWakeApPh2,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::ApWakeBtPh3,
        [
            PinFunction::Rsvd0,
            PinFunction::Uartb,
            PinFunction::Spdif,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::BtRstPh4,
        [
            PinFunction::Rsvd0,
            PinFunction::Uartb,
            PinFunction::Spdif,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::BtWakeApPh5,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::ApWakeNfcPh7,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::NfcEnPi0,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::NfcIntPi1,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::GpsEnPi2,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::GpsRstPi3,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::CamRstPs4,
        [
            PinFunction::Vgp1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::CamAfEnPs5,
        [
            PinFunction::Vimclk,
            PinFunction::Vgp2,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::CamFlashEnPs6,
        [
            PinFunction::Vimclk,
            PinFunction::Vgp3,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Cam1PwdnPs7,
        [
            PinFunction::Vgp4,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Cam2PwdnPt0,
        [
            PinFunction::Vgp5,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Cam1StrobePt1,
        [
            PinFunction::Vgp6,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::LcdTePy2,
        [
            PinFunction::Displaya,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::LcdBlPwmPv0,
        [
            PinFunction::Displaya,
            PinFunction::Pwm0,
            PinFunction::Sor0,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::LcdBlEnPv1,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::LcdRstPv2,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::LcdGpio1Pv3,
        [
            PinFunction::Displayb,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::LcdGpio2Pv4,
        [
            PinFunction::Displayb,
            PinFunction::Pwm1,
            PinFunction::Rsvd2,
            PinFunction::Sor1,
        ],
    ),
    SocPinGrP(
        PinGrP::ApReadyPv5,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::TouchRstPv6,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::TouchClkPv7,
        [
            PinFunction::Touch,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::ModemWakeApPx0,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::TouchIntPx1,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::MotionIntPx2,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::AlsProxIntPx3,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::TempAlertPx4,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::ButtonPowerOnPx5,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::ButtonVolUpPx6,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::ButtonVolDownPx7,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::ButtonSlideSwPy0,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::ButtonHomePy1,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pa6,
        [
            PinFunction::Sata,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pe6,
        [
            PinFunction::Rsvd0,
            PinFunction::I2S5A,
            PinFunction::Pwm2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pe7,
        [
            PinFunction::Rsvd0,
            PinFunction::I2S5A,
            PinFunction::Pwm3,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Ph6,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pk0,
        [
            PinFunction::Iqc0,
            PinFunction::I2S5B,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pk1,
        [
            PinFunction::Iqc0,
            PinFunction::I2S5B,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pk2,
        [
            PinFunction::Iqc0,
            PinFunction::I2S5B,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pk3,
        [
            PinFunction::Iqc0,
            PinFunction::I2S5B,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pk4,
        [
            PinFunction::Iqc1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pk5,
        [
            PinFunction::Iqc1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pk6,
        [
            PinFunction::Iqc1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pk7,
        [
            PinFunction::Iqc1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pl0,
        [
            PinFunction::Rsvd0,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pl1,
        [
            PinFunction::Soc,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pz0,
        [
            PinFunction::Vimclk2,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pz1,
        [
            PinFunction::Vimclk2,
            PinFunction::Sdmmc1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pz2,
        [
            PinFunction::Sdmmc3,
            PinFunction::Ccla,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pz3,
        [
            PinFunction::Sdmmc3,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pz4,
        [
            PinFunction::Sdmmc1,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
    SocPinGrP(
        PinGrP::Pz5,
        [
            PinFunction::Soc,
            PinFunction::Rsvd1,
            PinFunction::Rsvd2,
            PinFunction::Rsvd3,
        ],
    ),
];

impl PinGrP {
    #![allow(clippy::too_many_arguments)]
    pub fn config(
        self,
        function: PinFunction,
        pull: PinPull,
        tristate: PinTristate,
        io: PinIo,
        lock: PinLock,
        od: PinOd,
        hv: PinEIoHv,
    ) {
        self.set_function(function);
        self.set_pull_updown(pull);
        self.set_tristate(tristate);
        self.set_io(io);
        self.set_lock(lock);
        self.set_od(od);
        self.set_e_io_hv(hv);
    }

    pub fn set_function(self, function: PinFunction) {
        // avoid setting of reserved pins
        if function == PinFunction::Default
            || function == PinFunction::Reserved
            || self == PinGrP::Reserved
        {
            return;
        }

        let val = self as usize;

        let mux = if function >= PinFunction::Rsvd0 {
            (function as u32 - PinFunction::Rsvd0 as u32) & 3
        } else {
            let mut i: u32 = 0;
            for func in &SOC_GROUPS[val].1 {
                if *func == function {
                    break;
                }
                i += 1;
            }
            i
        };

        if mux > 3 {
            panic!("Invalid mux!!!!");
        }

        let register = unsafe { &(*((0x7000_3000 + (val * 4)) as *const ReadWrite<u32>)) };

        let mut reg_value = register.get();
        reg_value &= !3;
        reg_value |= mux;

        register.set(reg_value);
    }

    pub fn set_pull_updown(self, pull: PinPull) {
        let val = self as usize;
        let pull_val = pull as u32;
        let register = unsafe { &(*((0x7000_3000 + (val * 4)) as *const ReadWrite<u32>)) };

        let mut reg_value = register.get();
        reg_value &= !(3 << 2);
        reg_value |= pull_val << 2;

        register.set(reg_value);
    }

    pub fn set_tristate(self, tristate: PinTristate) {
        let val = self as usize;
        let register = unsafe { &(*((0x7000_3000 + (val * 4)) as *const ReadWrite<u32>)) };

        let mut reg_value = register.get();
        match tristate {
            PinTristate::Normal => {
                reg_value &= !(1 << 4);
            }
            PinTristate::Tristate => {
                reg_value |= 1 << 4;
            }
        }

        register.set(reg_value);
    }

    pub fn set_io(self, io: PinIo) {
        let val = self as usize;
        let register = unsafe { &(*((0x7000_3000 + (val * 4)) as *const ReadWrite<u32>)) };

        let mut reg_value = register.get();
        match io {
            PinIo::Input => {
                reg_value |= 1 << 5;
            }
            _ => {
                reg_value &= !(1 << 5);
            }
        }

        register.set(reg_value);
    }

    pub fn set_lock(self, lock: PinLock) {
        if lock == PinLock::Default {
            return;
        }

        let val = self as usize;
        let register = unsafe { &(*((0x7000_3000 + (val * 4)) as *const ReadWrite<u32>)) };

        let mut reg_value = register.get();
        match lock {
            PinLock::Enable => {
                reg_value |= 1 << 7;
            }
            PinLock::Disable => {
                reg_value &= !(1 << 7);
            }
            _ => panic!(),
        }

        register.set(reg_value);
    }

    pub fn set_od(self, od: PinOd) {
        if od == PinOd::Default {
            return;
        }

        let val = self as usize;
        let register = unsafe { &(*((0x7000_3000 + (val * 4)) as *const ReadWrite<u32>)) };

        let mut reg_value = register.get();
        match od {
            PinOd::Enable => panic!("THIS SHOULD NEVER BE SET"),
            PinOd::Disable => {
                reg_value &= !(1 << 6);
            }
            _ => panic!(),
        }

        register.set(reg_value);
    }

    pub fn set_e_io_hv(self, hv: PinEIoHv) {
        if hv == PinEIoHv::Default {
            return;
        }

        let val = self as usize;
        let register = unsafe { &(*((0x7000_3000 + (val * 4)) as *const ReadWrite<u32>)) };

        let mut reg_value = register.get();
        match hv {
            PinEIoHv::High => {
                reg_value |= 1 << 10;
            }
            PinEIoHv::Normal => {
                reg_value &= !(1 << 10);
            }
            _ => panic!(),
        }

        register.set(reg_value);
    }
}
