#ifndef _PCIC_REG_H
#define _PCIC_REG_H
#ifdef __cplusplus
extern "C" {
#endif
#define PCIC_MAX_CONTROLLERS 4
#define PCIC_SOCKETS 2
#define PCIC_MEMWINDOWS 5
#define PCIC_IOWINDOWS 2
#define PCIC_NUMWINDOWS ((PCIC_MEMWINDOWS + PCIC_IOWINDOWS) * PCIC_SOCKETS)
#define PCIC_NUMWINSOCK (PCIC_MEMWINDOWS+PCIC_IOWINDOWS)
#define PCIC_INDEX_REG0 0x3e0
#define PCIC_INDEX_REG1 0x3e2
#define PCIC_BASE0 0x00
#define PCIC_BASE1 0x80
#define PCIC_SOCKET_0 0x00
#define PCIC_SOCKET_1 0x40
#define PCIC_DATA_REG0 (PCIC_INDEX_REG0+1)
#define PCIC_DATA_REG1 (PCIC_INDEX_REG1+1)
#define PCIC_CHIP_REVISION 0x00
#define PCIC_INTERFACE_STATUS 0x01
#define PCIC_POWER_CONTROL 0x02
#define PCIC_CARD_STATUS_CHANGE 0x04
#define PCIC_MAPPING_ENABLE 0x06
#define PCIC_CARD_DETECT 0x16
#define PCIC_MISC_CTL_1 0x16
#define PCIC_GLOBAL_CONTROL 0x1e
#define PCIC_MISC_CTL_2 0x1e
#define PCIC_CHIP_INFO 0x1f
#define PCIC_INTERRUPT 0x03
#define PCIC_MANAGEMENT_INT 0x05
#define PCIC_IO_CONTROL 0x07
#define PCIC_IO_ADDR_0_STARTLOW 0x08
#define PCIC_IO_ADDR_0_STARTHI 0x09
#define PCIC_IO_ADDR_0_STOPLOW 0x0a
#define PCIC_IO_ADDR_0_STOPHI 0x0b
#define PCIC_IO_OFFSET_LOW 0x36
#define PCIC_IO_OFFSET_HI 0x37
#define PCIC_IO_OFFSET_OFFSET 2
#define PCIC_IO_ADDR_1_OFFSET 5
#define PCIC_IO_WIN_MASK 0xf
#define PCIC_SYSMEM_0_STARTLOW 0x10
#define PCIC_SYSMEM_0_STARTHI 0x11
#define PCIC_SYSMEM_0_STOPLOW 0x12
#define PCIC_SYSMEM_0_STOPHI 0x13
#define PCIC_CARDMEM_0_LOW 0x14
#define PCIC_CARDMEM_0_HI 0x15
#define PCIC_SYSMEM_1_STARTLOW 0x18
#define PCIC_SYSMEM_1_STARTHI 0x19
#define PCIC_SYSMEM_1_STOPLOW 0x1a
#define PCIC_SYSMEM_1_STOPHI 0x1b
#define PCIC_CARDMEM_1_LOW 0x1c
#define PCIC_CARDMEM_1_HI 0x1d
#define PCIC_MEM_1_OFFSET 8
#define PCIC_MEM_2_OFFSET 16
#define PCIC_MEM_3_OFFSET 24
#define PCIC_MEM_4_OFFSET 32
#define PCIC_IO_OFFSET 4
#define PCIC_TIME_SETUP_0 0x3A
#define PCIC_TIME_SETUP_1 0x3D
#define PCIC_TIME_COMMAND_0 0x3B
#define PCIC_TIME_COMMAND_1 0x3E
#define PCIC_TIME_RECOVER_0 0x3C
#define PCIC_TIME_RECOVER_1 0x3F
#define PCIC_ATA_CONTROL 0x26
#define PCIC_FIFO_CONTROL 0x17
#define PCIC_CL_EXINDEX 0x2e
#define PCIC_CL_EXDATA 0x2f
#define PCIC_CLEXT_SCRATCH 0x00
#define PCIC_CLEXT_DMASK_0 0x01
#define PCIC_CLEXT_EXT_CTL_1 0x03
#define PCIC_CLEXT_MMAP0_UA 0x05
#define PCIC_CLEXT_MMAP1_UA 0x06
#define PCIC_CLEXT_MMAP2_UA 0x07
#define PCIC_CLEXT_MMAP3_UA 0x08
#define PCIC_CLEXT_MMAP4_UA 0x09
#define PCIC_CLEXT_EXDATA 0x0a
#define PCIC_CLEXT_EXT_CTL_2 0x0b
#define PCIC_CLEXT_MISC_CTL_3 0x25
#define PCIC_CLEXT_SMB_CTL 0x26
#define PCIC_CBCLEXT_MMAP0_UA 0x40
#define PCIC_CBCLEXT_MMAP1_UA 0x41
#define PCIC_CBCLEXT_MMAP2_UA 0x42
#define PCIC_CBCLEXT_MMAP3_UA 0x43
#define PCIC_CBCLEXT_MMAP4_UA 0x44
#define PCIC_CBCLEXT_MMAP5_UA 0x45
#define PCIC_CLEXT_MISC_CTL_3_REV_MASK 0xf0
#define PCIC_CLEXT_IRQ_LVL_MODE 0x08
#define PCIC_CLEXT_SMI_LVL_MODE 0x00
#define PCIC_CL_LP_DYN_MODE 0x02
#define PCIC_CL_TIMER_CLK_DIV 0x10
#define PCIC_CLEXT_INT_PC_PCI 0x00
#define PCIC_CLEXT_INT_EXT_HW 0x01
#define PCIC_CLEXT_INT_PCI_WAY 0x10
#define PCIC_CLEXT_INT_PCI 0x03
#define PCIC_CLEXT_PWR_EXT_HW 0x00
#define PCIC_CLEXT_PWR_RESERVED 0x04
#define PCIC_CLEXT_PWR_TI 0x80
#define PCIC_CLEXT_PWR_SMB 0xc0
#define PCIC_82092_PCICON 0x40
#define PCIC_82092_PCICLK_25MHZ 0x01
#define PCIC_82092_SLOT_CONFIG 0x06
#define PCIC_82092_2_SOCKETS 0x00
#define PCIC_82092_1_SOCKET 0x02
#define PCIC_82092_4_SOCKETS 0x04
#define PCIC_82092_EN_TIMING 0x20
#define PCIC_82092_PWB 0x08
#define PCIC_82092_RPFB 0x10
#define PCIC_82092_PPIRR 0x50
#define PCIC_82092_SMI_CTL(sock, state) (state << (sock * 2))
#define PCIC_82092_IRQ_CTL(sock, state) (state << ((sock * 2) + 1))
#define PCIC_82092_CTL_SMI 0x01
#define PCIC_82092_CTL_IRQ 0x02
#define PCIC_82092_INT_DISABLE 0x00
#define PCIC_82092_INT_ENABLE 0x01
#define PCIC_82092_CPAGE 0x26
#define PCIC_REV_ID_MASK 0xc0
#define PCIC_REV_ID_IO 0x00
#define PCIC_REV_ID_MEM 0x40
#define PCIC_REV_ID_BOTH 0x80
#define PCIC_ISTAT_CD_MASK 0xC
#define PCIC_CD_PRESENT_OK 0xC
#define PCIC_CD_NOTPRESENT 0x0
#define PCIC_CD_NOTSEATED_1 0x8
#define PCIC_CD1 0x8
#define PCIC_CD_NOTSEATED_2 0x4
#define PCIC_CD2 0x4
#define PCIC_WRITE_PROTECT 0x10
#define PCIC_READY 0x20
#define PCIC_POWER_ON 0x40
#define PCIC_VPP_VALID 0x80
#define PCIC_BVD1 0x1
#define PCIC_BVD2 0x2
#define SYSMEM_LOW(x) (((uint32_t)(x)>>12)&0xFF)
#define SYSMEM_HIGH(x) (((uint32_t)(x)>>20)&0xF)
#define SYSMEM_EXT(x) (((uint32_t)(x)>>24)&0xFF)
#define SYSMEM_WINDOW(x) (1<<(x))
#define SYSMEM_ZERO_WAIT 0x40
#define SYSMEM_DATA_16 0x80
#define SYSMEM_MEM16 0x20
#define SYSMEM_CLTIMER_SET_0 0x00
#define SYSMEM_CLTIMER_SET_1 0x80
#define SYSMEM_82092_600NS 0x0110
#define SYSMEM_82092_250NS 0x0101
#define SYSMEM_82092_200NS 0x0100
#define SYSMEM_82092_150NS 0x0011
#define SYSMEM_82092_100NS 0x0010
#define SYSMEM_82092_80NS 0x0001
#define DEFAULT_AM_ADDR 0xd0000
#define CARDMEM_REG_ACTIVE 0x40
#define CARDMEM_WRITE_PROTECT 0x80
#define CARDMEM_LOW(x) (((uint32_t)((x))>>12)&0xFF)
#define CARDMEM_HIGH(x) (((uint32_t)((x))>>20)&0x3F)
#define POWER_CARD_ENABLE 0x10
#define POWER_3VCARD_ENABLE 0x18
#define POWER_OUTPUT_ENABLE 0x80
#define POWER_VPP_VCC_ENABLE 0x01
#define POWER_VPP_12V_ENABLE 0x02
#define PCIC_INTR_ENABLE 0x10
#define PCIC_IO_CARD 0x20
#define PCIC_RESET 0x40
#define PCIC_INTR_MASK 0x0f
#define PCIC_CD_DETECT 0x08
#define PCIC_RD_DETECT 0x04
#define PCIC_BW_DETECT 0x02
#define PCIC_BD_DETECT 0x01
#define PCIC_CHANGE_MASK 0x0f
#define PCIC_CD_ENABLE 0x08
#define PCIC_RD_ENABLE 0x04
#define PCIC_BW_ENABLE 0x02
#define PCIC_BD_ENABLE 0x01
#define PCIC_GPI_CHANGE 0x10
#define PCIC_CHANGE_DEFAULT (PCIC_CD_ENABLE|PCIC_RD_ENABLE|\
PCIC_BW_ENABLE|PCIC_BD_ENABLE)
#define PCIC_GPI_ENABLE 0x04
#define PCIC_GPI_TRANSITION 0x08
#define PCIC_16MDI 0x01
#define PCIC_SOFT_CD_INTR 0x20
#define PCIC_MC_5VDETECT 0x01
#define PCIC_MC_3VCC 0x02
#define PCIC_MC_PULSE_SMI 0x04
#define PCIC_MC_PULSE_IRQ 0x08
#define PCIC_MC_SPEAKER_ENB 0x10
#define PCIC_MC_INPACK_ENB 0x80
#define PCIC_GC_POWERDOWN 0x01
#define PCIC_GC_LEVELMODE 0x02
#define PCIC_GC_CSC_WRITE 0x04
#define PCIC_GC_IRQ1_PULSE 0x08
#define PCIC_MC_BYPASS_FS 0x01
#define PCIC_MC_LOWPOWER 0x02
#define PCIC_MC_SUSPEND 0x04
#define PCIC_5V_CORE 0x08
#define PCIC_LED_ENABLE 0x10
#define PCIC_THREESTATE 0x20
#define PCIC_CL_DMA 0x40
#define PCIC_IRQ15_RI_OUT 0x80
#define PCIC_CI_ID 0xc0
#define PCIC_CI_SLOTS 0x20
#define PCIC_VADEM_P1 0x0E
#define PCIC_VADEM_P2 0x37
#define PCIC_VG_VSENSE 0x1f
#define PCIC_VG_VSELECT 0x2f
#define PCIC_VG_CONTROL 0x38
#define PCIC_VG_TIMER 0x39
#define PCIC_VG_DMA 0x3A
#define PCIC_VG_EXT_A 0x3C
#define PCIC_VG_STATUS 0x3E
#define PCIC_V_DMAWSB 0x04
#define PCIC_V_VADEMREV 0x40
#define PCIC_V_UNLOCK 0x80
#define PCIC_VADEM_D3 0x8
#define PCIC_VADEM_365 0x9
#define PCIC_VADEM_465 0x8
#define PCIC_VADEM_468 0xB
#define PCIC_VADEM_469 0xC
#define PCIC_VSEL_EXTENDED 0x10
#define PCIC_VSEL_BUSSEL 0x20
#define PCIC_VC_DELAYENABLE 0x10
#define PCIC_VEXT_CABLEMODE 0x08
#define PCIC_YENTA_MEM_PAGE 0x40
#define PCIC_RF_CHIP_IDENT 0x3A
#define PCIC_RF_296 0x32
#define PCIC_RF_396 0xB2
#define PCIC_RF_MEM_PAGE PCIC_YENTA_MEM_PAGE
#define PCIC_CENTDMA 0x3C
#define PCIC_MULTIFUNC 0x8C
#define PCIC_O2_CTRL1 0xD0
#define PCIC_O2_CTRL2 0xD4
#define PCIC_INTLINE_REG 0x3C
#define PCIC_INTPIN_REG 0x3D
#define PCIC_BRIDGE_CTL_REG 0x3e
#define PCIC_FUN_INT_MOD_ISA 0x80
#define PCIC_BRDGCTL_INTR_MASK 0x80
#define PCIC_GPIO0_REG 0x88
#define PCIC_GPIO1_REG 0x89
#define PCIC_GPIO2_REG 0x8A
#define PCIC_GPIO3_REG 0x8B
#define PCIC_MFROUTE_REG 0x8c
#define PCIC_MFUNC0_MASK 0xF
#define PCIC_MFUNC0_INTA 0x2
#define PCIC_DIAG_REG 0x93
#define PCIC_GPIO_FMASK 0xC0
#define PCIC_GPIO_INTENBL 0x10
#define PCIC_GPIO_DELTA 0x08
#define PCIC_GPIO_DOUT 0x02
#define PCIC_GPIO_DIN 0x01
#define PCIC_GPIO_FOUTPUT 0xC0
#define PCIC_GPIO_FINPUT 0x80
#define PCIC_GPIO2_IS_PCILOCK 0x00
#define PCIC_GPIO3_IS_INTA 0x00
#define PCIC_TI_WINDOW_PAGE 0x3C
#define PCIC_TI_WINDOW_PAGE_PCI 0x40
#define PCIC_DIAG_REG 0x93
#define PCIC_DIAG_CSC 0x20
#define PCIC_DIAG_ASYNC 0x01
#define PCIC_DEVCTL_REG 0x92
#define PCIC_DEVCTL_INTR_MASK 0x06
#define PCIC_DEVCTL_INTR_PCI 0x00
#define PCIC_DEVCTL_INTR_ISA 0x02
#define PCIC_DEVCTL_INTR_SER 0x04
#define PCIC_DEVCTL_INTR_RSVD 0x06
#define PCIC_DEVCTL_3VCAPABLE 0x40
#define PCIC_DEVCTL_INTR_DFLT 0x06
#define PCIC_CRDCTL_REG 0x91
#define PCIC_CRDCTL_RIENABLE 0x80
#define PCIC_CRDCTL_ZVENABLE 0x40
#define PCIC_CRDCTL_PCIINTR 0x20
#define PCIC_CRDCTL_PCICSC 0x10
#define PCIC_CRDCTL_PCIFUNC 0x08
#define PCIC_CRDCTL_SPKR_ENBL 0x02
#define PCIC_CRDCTL_IFG 0x01
#define PCIC_SYSCTL_REG 0x80
#define PCIC_SYSCTL_INTRTIE 0x20
#define PCIC_TOSHIBA_SLOT_CTL_REG 0xa0
#define PCIC_TOSHIBA_SCR_SLOTON 0x80
#define PCIC_TOSHIBA_SCR_SLOTEN 0x40
#define PCIC_TOSHIBA_SCR_PRT_MASK 0xc
#define PCIC_TOSHIBA_SCR_PRT_3E0 0x0
#define PCIC_TOSHIBA_SCR_PRT_3E2 0x4
#define PCIC_TOSHIBA_SCR_PRT_3E4 0x8
#define PCIC_TOSHIBA_SCR_PRT_3E6 0xc
#define PCIC_TOSHIBA_INTR_CTL_REG 0xa1
#define PCIC_TOSHIBA_ICR_PIN_MASK 0x30
#define PCIC_TOSHIBA_ICR_PIN_DISEN 0x0
#define PCIC_TOSHIBA_ICR_PIN_INTA 0x10
#define PCIC_TOSHIBA_ICR_PIN_INTB 0x20
#define PCIC_TOSHIBA_ICR_MOD_CSC 0x4
#define PCIC_TOSHIBA_ICR_MOD_FUN 0x2
#define PCIC_TOSHIBA_ICR_SRC 0x1
#define PCIC_RICOH_MISC_CTL 0x82
#define PCIC_RICOH_SIRQ_EN 0x80
#define PCIC_RICOH_MISC_CTL_2 0xa0
#define PCIC_RICOH_CSC_INT_MOD 0x80
#define PCIC_RICOH_FUN_INT_MOD 0x40
#define PCIC_O2MICRO_MISC_CTL 0x28
#define PCIC_O2MICRO_INT_MOD_MASK 0x300
#define PCIC_O2MICRO_INT_MOD_PCI 0x300
#define PCIC_O2MICRO_ISA_LEGACY 0x800
#define PCIC_SMC_MEM_PAGE 0x40
#define PCIC_IRQ(irq) (1 << (irq))
#define PCIC_IRQ03 PCIC_IRQ(3)
#define PCIC_IRQ04 PCIC_IRQ(4)
#define PCIC_IRQ05 PCIC_IRQ(5)
#define PCIC_IRQ07 PCIC_IRQ(7)
#define PCIC_IRQ09 PCIC_IRQ(9)
#define PCIC_IRQ10 PCIC_IRQ(10)
#define PCIC_IRQ11 PCIC_IRQ(11)
#define PCIC_IRQ12 PCIC_IRQ(12)
#define PCIC_IRQ14 PCIC_IRQ(14)
#define PCIC_IRQ15 PCIC_IRQ(15)
#define PCIC_AVAIL_IRQS (PCIC_IRQ03|PCIC_IRQ04|PCIC_IRQ05|PCIC_IRQ07|\
PCIC_IRQ09|PCIC_IRQ10|PCIC_IRQ11|PCIC_IRQ12|\
PCIC_IRQ14|PCIC_IRQ15)
#define PCIC_PAGE 4096
#define HIGH_BYTE(x) (uchar_t)((((ushort_t)(x)) >> 8) & 0xFF)
#define LOW_BYTE(x) (uchar_t)(((ushort_t)(x)) & 0xFF)
#define PCIC_IO_0_MASK 0x0f
#define PCIC_IO_1_MASK 0xf0
#define IOMEM_WINDOW(x) (1<<((x)+6))
#define IOMEM_16BIT 0x01
#define IOMEM_IOCS16 0x02
#define IOMEM_ZERO_WAIT 0x04
#define IOMEM_CLTIMER_SET_0 0x00
#define IOMEM_CLTIMER_SET_1 0x08
#define IOMEM_WAIT16 0x08
#define IOMEM_SETWIN(w, x) ((x) << ((w)*4))
#define IOMEM_FIRST 0
#define IOMEM_LAST 0xFFFF
#define IOMEM_MIN 1
#define IOMEM_MAX 0x10000
#define IOMEM_GRAN 1
#define IOMEM_DECODE 16
#define MEM_FIRST 0x10000
#define MEM_LAST 0xFFFFF
#define MEM_MIN PCIC_PAGE
#define MEM_MAX 0x10000
#define PAGE_SHIFT 12
#define SYSCLK 120
#define MEM_SPEED_MIN (SYSCLK*2)
#define MEM_SPEED_MAX (SYSCLK*6)
#define CB_R2_OFFSET 0x800
#define CB_CLEXT_OFFSET 0x900
#define CB_CB_OFFSET 0x00
#define CB_STATUS_EVENT 0x00
#define CB_STATUS_MASK 0x04
#define CB_PRESENT_STATE 0x08
#define CB_EVENT_FORCE 0x0c
#define CB_CONTROL 0x10
#define CB_SOCKET_POWER 0x20
#define CB_SZVCTRL 0x20
#define CB_SIMDCTRL 0x24
#define CB_MISCCTRL 0x28
#define BYTE_3(x) ((x)<<24)
#define BYTE_2(x) ((x)<<16)
#define BYTE_1(x) ((x)<<8)
#define BYTE_0(x) (x)
#define CB_SE_POWER_CYCLE BYTE_0(0x08)
#define CB_SE_CCDMASK BYTE_0(0x06)
#define CB_SE_CCD2 BYTE_0(0x04)
#define CB_SE_CCD1 BYTE_0(0x02)
#define CB_SE_CSTSCHG BYTE_0(0x01)
#define CB_SM_POWER_CYCLE BYTE_0(0x08)
#define CB_SM_CCDMASK BYTE_0(0x06)
#define CB_SM_CCD2 BYTE_0(0x04)
#define CB_SM_CCD1 BYTE_0(0x02)
#define CB_SM_CSTSCHG BYTE_0(0x01)
#define CB_PS_CSTSCHG BYTE_0(0x01)
#define CB_PS_CCDMASK BYTE_0(0x06)
#define CB_PS_NCCD1 BYTE_0(0x02)
#define CB_PS_NCCD2 BYTE_0(0x04)
#define CB_PS_POWER_CYCLE BYTE_0(0x08)
#define CB_PS_16BITCARD BYTE_0(0x10)
#define CB_PS_CBCARD BYTE_0(0x20)
#define CB_PS_INTERRUPT BYTE_0(0x40)
#define CB_PS_NOTACARD BYTE_0(0x80)
#define CB_PS_DATALOST BYTE_1(0x01)
#define CB_PS_BADVCC BYTE_1(0x02)
#define CB_PS_50VCARD BYTE_1(0x04)
#define CB_PS_33VCARD BYTE_1(0x08)
#define CB_PS_XVCARD BYTE_1(0x10)
#define CB_PS_YVCARD BYTE_1(0x20)
#define CB_PS_50VSOCKET BYTE_3(0x10)
#define CB_PS_33VSOCKET BYTE_3(0x20)
#define CB_PS_XVSOCKET BYTE_3(0x40)
#define CB_PS_YVSOCKET BYTE_3(0x80)
#define CB_EF_CSTSCHG BYTE_0(0x01)
#define CB_EF_CCD1 BYTE_0(0x02)
#define CB_EF_CCD2 BYTE_0(0x04)
#define CB_EF_POWER_CYCLE BYTE_0(0x08)
#define CB_EF_16BITCARD BYTE_0(0x10)
#define CB_EF_CBCARD BYTE_0(0x20)
#define CB_EF_NOTACARD BYTE_0(0x80)
#define CB_EF_DATALOST BYTE_1(0x01)
#define CB_EF_BADVCC BYTE_1(0x02)
#define CB_EF_50V BYTE_1(0x04)
#define CB_EF_33V BYTE_1(0x08)
#define CB_EF_XV BYTE_1(0x10)
#define CB_EF_YV BYTE_1(0x20)
#define CB_EF_CVTEST BYTE_1(0x40)
#define CB_C_VPPMASK BYTE_0(0x07)
#define CB_C_VCCMASK BYTE_0(0x70)
#define CB_C_VPP0V BYTE_0(0x00)
#define CB_C_VPP12V BYTE_0(0x01)
#define CB_C_VPPVCC BYTE_0(0x03)
#define CB_C_VCC0V BYTE_0(0x00)
#define CB_C_VCC50V BYTE_0(0x20)
#define CB_C_VCC33V BYTE_0(0x30)
#ifdef __cplusplus
}
#endif
#endif