#ifndef __DM9601_H__
#define __DM9601_H__
#define NCR 0x00U
#define NSR 0x01U
#define TCR 0x02U
#define TSR1 0x03U
#define TSR2 0x04U
#define RCR 0x05U
#define RSR 0x06U
#define ROCR 0x07U
#define BPTR 0x08U
#define FCTR 0x09U
#define FCR 0x0aU
#define EPCR 0x0bU
#define EPAR 0x0cU
#define EPDR 0x0dU
#define WCR 0x0fU
#define PAR 0x10U
#define MAR 0x16U
#define GPCR 0x1eU
#define GPR 0x1fU
#define VID 0x28U
#define PID 0x2aU
#define CHIPR 0x2cU
#define USBDA 0xf0U
#define RXC 0xf1U
#define TUSC 0xf2U
#define USBC 0xf4U
#define NCR_EXT_PHY 0x80U
#define NCR_WAKEEN 0x40U
#define NCR_FCOL 0x10U
#define NCR_FDX 0x08U
#define NCR_LBK 0x06U
#define NCR_LBK_SHIFT 1
#define NCR_LBK_NORMAL (0U << NCR_LBK_SHIFT)
#define NCR_LBK_MAC (1U << NCR_LBK_SHIFT)
#define NCR_LBK_PHY_D (2U << NCR_LBK_SHIFT)
#define NCR_LBK_PHY_A (3U << NCR_LBK_SHIFT)
#define NCR_RST 0x01U
#define NCR_BITS \
"\020" \
"\010EXT_PHY" \
"\007WAKEEN" \
"\005FCOL" \
"\004FDX" \
"\001RST"
#define NSR_SPEED 0x80U
#define NSR_LINKST 0x40U
#define NSR_WAKEST 0x20U
#define NSR_TXFULL 0x10U
#define NSR_TX2END 0x08U
#define NSR_TX1END 0x04U
#define NSR_RXOV 0x02U
#define NSR_RXRDY 0x01U
#define NSR_BITS \
"\020" \
"\010SPEED_10" \
"\007LINKST_UP" \
"\006WAKEST" \
"\005TXFULL" \
"\004TX2END" \
"\003TX1END" \
"\002RXOV" \
"\001RXRDY"
#define TCR_TJDIS 0x40U
#define TCR_EXCEDM 0x20U
#define TCR_PAD_DIS2 0x10U
#define TCR_CRC_DIS2 0x08U
#define TCR_PAD_DIS1 0x04U
#define TCR_CRC_DIS1 0x02U
#define TCR_BITS \
"\020" \
"\007TJDIS" \
"\006EXCEDM" \
"\005PAD_DIS2" \
"\004CRC_DIS2" \
"\003PAD_DIS1" \
"\002CRC_DIS1"
#define TSR_TJTO 0x80U
#define TSR_LC 0x40U
#define TSR_NC 0x20U
#define TSR_LATEC 0x10U
#define TSR_COL 0x08U
#define TSR_EL 0x04U
#define TSR_BITS \
"\020" \
"\010TJTO" \
"\007LC" \
"\006NC" \
"\005LATEC" \
"\004COL" \
"\003EL"
#define RCR_WTDIS 0x40U
#define RCR_DIS_LONG 0x20U
#define RCR_DIS_CRC 0x10U
#define RCR_ALL 0x08U
#define RCR_RUNT 0x04U
#define RCR_PRMSC 0x02U
#define RCR_RXEN 0x01U
#define RCR_BITS \
"\020" \
"\007WTDIS" \
"\006DIS_LONG" \
"\005DIS_CRC" \
"\004ALL" \
"\003RUNT" \
"\002PRMSC" \
"\001RXEN"
#define RSR_RF 0x80U
#define RSR_MF 0x40U
#define RSR_LCS 0x20U
#define RSR_RWTO 0x10U
#define RSR_PLE 0x08U
#define RSR_AE 0x04U
#define RSR_CE 0x02U
#define RSR_FOE 0x01U
#define RSR_BITS \
"\020" \
"\010RF" \
"\007MF" \
"\006LCS" \
"\005RWTO" \
"\004PLE" \
"\003AE" \
"\002CE" \
"\001FOE"
#define ROCR_RXFU 0x80U
#define ROCR_ROC 0x7fU
#define ROCR_BITS \
"\020" \
"\010RXFU"
#define BPTR_BPHW 0xf0U
#define BPTR_BPHW_SHIFT 4
#define BPTR_BPHW_UNIT 1024U
#define BPTR_BPHW_DEFAULT (3 << BPTR_BPHW_SHIFT)
#define BPTR_JPT 0x0fU
#define BPTR_JPT_SHIFT 0
#define BPTR_JPT_5us (0U << BPTR_JPT_SHIFT)
#define BPTR_JPT_10us (1U << BPTR_JPT_SHIFT)
#define BPTR_JPT_15us (2U << BPTR_JPT_SHIFT)
#define BPTR_JPT_25us (3U << BPTR_JPT_SHIFT)
#define BPTR_JPT_50us (4U << BPTR_JPT_SHIFT)
#define BPTR_JPT_100us (5U << BPTR_JPT_SHIFT)
#define BPTR_JPT_150us (6U << BPTR_JPT_SHIFT)
#define BPTR_JPT_200us (7U << BPTR_JPT_SHIFT)
#define BPTR_JPT_250us (8U << BPTR_JPT_SHIFT)
#define BPTR_JPT_300us (9U << BPTR_JPT_SHIFT)
#define BPTR_JPT_350us (10U << BPTR_JPT_SHIFT)
#define BPTR_JPT_400us (11U << BPTR_JPT_SHIFT)
#define BPTR_JPT_450us (12U << BPTR_JPT_SHIFT)
#define BPTR_JPT_500us (13U << BPTR_JPT_SHIFT)
#define BPTR_JPT_550us (14U << BPTR_JPT_SHIFT)
#define BPTR_JPT_600us (15U << BPTR_JPT_SHIFT)
#define FCTR_HWOT 0xf0U
#define FCTR_HWOT_SHIFT 4
#define FCTR_HWOT_UNIT 1024U
#define FCTR_LWOT 0x0fU
#define FCTR_LWOT_SHIFT 0
#define FCTR_LWOT_UNIT 1024U
#define FCR_TXPO 0x80U
#define FCR_TXPF 0x40U
#define FCR_TXPEN 0x20U
#define FCR_BKPA 0x10U
#define FCR_BKPM 0x08U
#define FCR_BKPS 0x04U
#define FCR_RXPCS 0x02U
#define FCR_FLCE 0x01U
#define FCR_BITS \
"\020" \
"\000TXPO" \
"\000TXPF" \
"\000TXPEN" \
"\000BKPA" \
"\000BKPM" \
"\000BKPS" \
"\000RXPCS" \
"\000FLCE"
#define EPCR_REEP 0x20U
#define EPCR_WEP 0x10U
#define EPCR_EPOS 0x08U
#define EPCR_ERPRR 0x04U
#define EPCR_ERPRW 0x02U
#define EPCR_ERRE 0x01U
#define EPCR_BITS \
"\020" \
"\005REEP" \
"\004WEP" \
"\003EPOS" \
"\002ERPRR" \
"\001ERPRW" \
"\000ERRE"
#define EPAR_PHYADR 0xc0U
#define EPAR_PHYADR_SHIFT 6
#define EPAR_EROA 0x3fU
#define EPAR_EROA_SHIFT 0
#define WCR_LINKEN 0x20U
#define WCR_SAMPLEEN 0x10U
#define WCR_MAGICEN 0x08U
#define WCR_LINKST 0x04U
#define WCR_SAMPLEST 0x02U
#define WCR_MAGICST 0x01U
#define WCR_BITS \
"\020" \
"\000LINKEN" \
"\000SAMPLEEN" \
"\000MAGICEN" \
"\000LINKST" \
"\000SAMPLEST" \
"\000MAGICST"
#define GPCR_GEPCTRL 0x7f
#define GPCR_OUT(n) (1U << (n))
#define GPCR_BITS \
"\020" \
"\006OUT5" \
"\005OUT4" \
"\004OUT3" \
"\003OUT2" \
"\002OUT1" \
"\001OUT0"
#define GPR_GEPIO5 0x20U
#define GPR_GEPIO4 0x10U
#define GPR_GEPIO3 0x08U
#define GPR_GEPIO2 0x04U
#define GPR_GEPIO1 0x02U
#define GPR_GEPIO0 0x01U
#define GPR_BITS \
"\020" \
"\006GEPIO5" \
"\005GEPIO4" \
"\004GEPIO3" \
"\003GEPIO2" \
"\002GEPIO1" \
"\001GEPIO0"
#define USBDA_USBFA 0x3fU
#define USBDA_USBFA_SHIFT 0
#define TUSR_RXFAULT 0x80U
#define TUSR_SUSFLAG 0x40U
#define TUSR_EP1RDY 0x20U
#define TUSR_SRAM 0x18U
#define TUSR_SRAM_SHIFT 3
#define TUSR_SRAM_32K (0U << TUSR_SRAM_SHIFT)
#define TUSR_SRAM_48K (1U << TUSR_SRAM_SHIFT)
#define TUSR_SRAM_16K (2U << TUSR_SRAM_SHIFT)
#define TUSR_SRAM_64K (3U << TUSR_SRAM_SHIFT)
#define TUSR_TXC2 0x04U
#define TUSR_TXC1 0x02U
#define TUSR_TXC0 0x01U
#define TUSR_BITS \
"\020" \
"\010RXFAULT" \
"\007SUSFLAG" \
"\006EP1RDY" \
"\003TXC2" \
"\002TXC1" \
"\001TXC0"
#define USBC_EP3ACK 0x20U
#define USBC_EP3NACK 0x10U
#define USBC_MEMTST 0x01U
#define TX_HEADER_SIZE 2
#define RX_HEADER_SIZE 3
struct intr_msg {
uint8_t im_nsr;
uint8_t im_tsr1;
uint8_t im_tsr2;
uint8_t im_rsr;
uint8_t im_rocr;
uint8_t im_rxc;
uint8_t im_txc;
uint8_t im_gpr;
};
#endif