1*4882a593Smuzhiyun #ifndef CS8900_H 2*4882a593Smuzhiyun #define CS8900_H 3*4882a593Smuzhiyun /* 4*4882a593Smuzhiyun * Cirrus Logic CS8900A Ethernet 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * (C) 2009 Ben Warren , biggerbadderben@gmail.com 7*4882a593Smuzhiyun * Converted to use CONFIG_NET_MULTI API 8*4882a593Smuzhiyun * 9*4882a593Smuzhiyun * (C) Copyright 2002 10*4882a593Smuzhiyun * Sysgo Real-Time Solutions, GmbH <www.elinos.com> 11*4882a593Smuzhiyun * Marius Groeger <mgroeger@sysgo.de> 12*4882a593Smuzhiyun * 13*4882a593Smuzhiyun * Copyright (C) 1999 Ben Williamson <benw@pobox.com> 14*4882a593Smuzhiyun * 15*4882a593Smuzhiyun * This program is loaded into SRAM in bootstrap mode, where it waits 16*4882a593Smuzhiyun * for commands on UART1 to read and write memory, jump to code etc. 17*4882a593Smuzhiyun * A design goal for this program is to be entirely independent of the 18*4882a593Smuzhiyun * target board. Anything with a CL-PS7111 or EP7211 should be able to run 19*4882a593Smuzhiyun * this code in bootstrap mode. All the board specifics can be handled on 20*4882a593Smuzhiyun * the host. 21*4882a593Smuzhiyun * 22*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+ 23*4882a593Smuzhiyun */ 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun #include <asm/types.h> 26*4882a593Smuzhiyun #include <config.h> 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun #define CS8900_DRIVERNAME "CS8900" 29*4882a593Smuzhiyun /* although the registers are 16 bit, they are 32-bit aligned on the 30*4882a593Smuzhiyun EDB7111. so we have to read them as 32-bit registers and ignore the 31*4882a593Smuzhiyun upper 16-bits. i'm not sure if this holds for the EDB7211. */ 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun #ifdef CONFIG_CS8900_BUS16 34*4882a593Smuzhiyun /* 16 bit aligned registers, 16 bit wide */ 35*4882a593Smuzhiyun #define CS8900_REG u16 36*4882a593Smuzhiyun #elif defined(CONFIG_CS8900_BUS32) 37*4882a593Smuzhiyun /* 32 bit aligned registers, 16 bit wide (we ignore upper 16 bits) */ 38*4882a593Smuzhiyun #define CS8900_REG u32 39*4882a593Smuzhiyun #else 40*4882a593Smuzhiyun #error unknown bussize ... 41*4882a593Smuzhiyun #endif 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun struct cs8900_regs { 44*4882a593Smuzhiyun CS8900_REG rtdata; 45*4882a593Smuzhiyun CS8900_REG pad0; 46*4882a593Smuzhiyun CS8900_REG txcmd; 47*4882a593Smuzhiyun CS8900_REG txlen; 48*4882a593Smuzhiyun CS8900_REG isq; 49*4882a593Smuzhiyun CS8900_REG pptr; 50*4882a593Smuzhiyun CS8900_REG pdata; 51*4882a593Smuzhiyun }; 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun struct cs8900_priv { 54*4882a593Smuzhiyun struct cs8900_regs *regs; 55*4882a593Smuzhiyun }; 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun #define ISQ_RxEvent 0x04 58*4882a593Smuzhiyun #define ISQ_TxEvent 0x08 59*4882a593Smuzhiyun #define ISQ_BufEvent 0x0C 60*4882a593Smuzhiyun #define ISQ_RxMissEvent 0x10 61*4882a593Smuzhiyun #define ISQ_TxColEvent 0x12 62*4882a593Smuzhiyun #define ISQ_EventMask 0x3F 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun /* packet page register offsets */ 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun /* bus interface registers */ 67*4882a593Smuzhiyun #define PP_ChipID 0x0000 /* Chip identifier - must be 0x630E */ 68*4882a593Smuzhiyun #define PP_ChipRev 0x0002 /* Chip revision, model codes */ 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun #define PP_IntReg 0x0022 /* Interrupt configuration */ 71*4882a593Smuzhiyun #define PP_IntReg_IRQ0 0x0000 /* Use INTR0 pin */ 72*4882a593Smuzhiyun #define PP_IntReg_IRQ1 0x0001 /* Use INTR1 pin */ 73*4882a593Smuzhiyun #define PP_IntReg_IRQ2 0x0002 /* Use INTR2 pin */ 74*4882a593Smuzhiyun #define PP_IntReg_IRQ3 0x0003 /* Use INTR3 pin */ 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun /* status and control registers */ 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun #define PP_RxCFG 0x0102 /* Receiver configuration */ 79*4882a593Smuzhiyun #define PP_RxCFG_Skip1 0x0040 /* Skip (i.e. discard) current frame */ 80*4882a593Smuzhiyun #define PP_RxCFG_Stream 0x0080 /* Enable streaming mode */ 81*4882a593Smuzhiyun #define PP_RxCFG_RxOK 0x0100 /* RxOK interrupt enable */ 82*4882a593Smuzhiyun #define PP_RxCFG_RxDMAonly 0x0200 /* Use RxDMA for all frames */ 83*4882a593Smuzhiyun #define PP_RxCFG_AutoRxDMA 0x0400 /* Select RxDMA automatically */ 84*4882a593Smuzhiyun #define PP_RxCFG_BufferCRC 0x0800 /* Include CRC characters in frame */ 85*4882a593Smuzhiyun #define PP_RxCFG_CRC 0x1000 /* Enable interrupt on CRC error */ 86*4882a593Smuzhiyun #define PP_RxCFG_RUNT 0x2000 /* Enable interrupt on RUNT frames */ 87*4882a593Smuzhiyun #define PP_RxCFG_EXTRA 0x4000 /* Enable interrupt on frames with extra data */ 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun #define PP_RxCTL 0x0104 /* Receiver control */ 90*4882a593Smuzhiyun #define PP_RxCTL_IAHash 0x0040 /* Accept frames that match hash */ 91*4882a593Smuzhiyun #define PP_RxCTL_Promiscuous 0x0080 /* Accept any frame */ 92*4882a593Smuzhiyun #define PP_RxCTL_RxOK 0x0100 /* Accept well formed frames */ 93*4882a593Smuzhiyun #define PP_RxCTL_Multicast 0x0200 /* Accept multicast frames */ 94*4882a593Smuzhiyun #define PP_RxCTL_IA 0x0400 /* Accept frame that matches IA */ 95*4882a593Smuzhiyun #define PP_RxCTL_Broadcast 0x0800 /* Accept broadcast frames */ 96*4882a593Smuzhiyun #define PP_RxCTL_CRC 0x1000 /* Accept frames with bad CRC */ 97*4882a593Smuzhiyun #define PP_RxCTL_RUNT 0x2000 /* Accept runt frames */ 98*4882a593Smuzhiyun #define PP_RxCTL_EXTRA 0x4000 /* Accept frames that are too long */ 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun #define PP_TxCFG 0x0106 /* Transmit configuration */ 101*4882a593Smuzhiyun #define PP_TxCFG_CRS 0x0040 /* Enable interrupt on loss of carrier */ 102*4882a593Smuzhiyun #define PP_TxCFG_SQE 0x0080 /* Enable interrupt on Signal Quality Error */ 103*4882a593Smuzhiyun #define PP_TxCFG_TxOK 0x0100 /* Enable interrupt on successful xmits */ 104*4882a593Smuzhiyun #define PP_TxCFG_Late 0x0200 /* Enable interrupt on "out of window" */ 105*4882a593Smuzhiyun #define PP_TxCFG_Jabber 0x0400 /* Enable interrupt on jabber detect */ 106*4882a593Smuzhiyun #define PP_TxCFG_Collision 0x0800 /* Enable interrupt if collision */ 107*4882a593Smuzhiyun #define PP_TxCFG_16Collisions 0x8000 /* Enable interrupt if > 16 collisions */ 108*4882a593Smuzhiyun 109*4882a593Smuzhiyun #define PP_TxCmd 0x0108 /* Transmit command status */ 110*4882a593Smuzhiyun #define PP_TxCmd_TxStart_5 0x0000 /* Start after 5 bytes in buffer */ 111*4882a593Smuzhiyun #define PP_TxCmd_TxStart_381 0x0040 /* Start after 381 bytes in buffer */ 112*4882a593Smuzhiyun #define PP_TxCmd_TxStart_1021 0x0080 /* Start after 1021 bytes in buffer */ 113*4882a593Smuzhiyun #define PP_TxCmd_TxStart_Full 0x00C0 /* Start after all bytes loaded */ 114*4882a593Smuzhiyun #define PP_TxCmd_Force 0x0100 /* Discard any pending packets */ 115*4882a593Smuzhiyun #define PP_TxCmd_OneCollision 0x0200 /* Abort after a single collision */ 116*4882a593Smuzhiyun #define PP_TxCmd_NoCRC 0x1000 /* Do not add CRC */ 117*4882a593Smuzhiyun #define PP_TxCmd_NoPad 0x2000 /* Do not pad short packets */ 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun #define PP_BufCFG 0x010A /* Buffer configuration */ 120*4882a593Smuzhiyun #define PP_BufCFG_SWI 0x0040 /* Force interrupt via software */ 121*4882a593Smuzhiyun #define PP_BufCFG_RxDMA 0x0080 /* Enable interrupt on Rx DMA */ 122*4882a593Smuzhiyun #define PP_BufCFG_TxRDY 0x0100 /* Enable interrupt when ready for Tx */ 123*4882a593Smuzhiyun #define PP_BufCFG_TxUE 0x0200 /* Enable interrupt in Tx underrun */ 124*4882a593Smuzhiyun #define PP_BufCFG_RxMiss 0x0400 /* Enable interrupt on missed Rx packets */ 125*4882a593Smuzhiyun #define PP_BufCFG_Rx128 0x0800 /* Enable Rx interrupt after 128 bytes */ 126*4882a593Smuzhiyun #define PP_BufCFG_TxCol 0x1000 /* Enable int on Tx collision ctr overflow */ 127*4882a593Smuzhiyun #define PP_BufCFG_Miss 0x2000 /* Enable int on Rx miss ctr overflow */ 128*4882a593Smuzhiyun #define PP_BufCFG_RxDest 0x8000 /* Enable int on Rx dest addr match */ 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun #define PP_LineCTL 0x0112 /* Line control */ 131*4882a593Smuzhiyun #define PP_LineCTL_Rx 0x0040 /* Enable receiver */ 132*4882a593Smuzhiyun #define PP_LineCTL_Tx 0x0080 /* Enable transmitter */ 133*4882a593Smuzhiyun #define PP_LineCTL_AUIonly 0x0100 /* AUI interface only */ 134*4882a593Smuzhiyun #define PP_LineCTL_AutoAUI10BT 0x0200 /* Autodetect AUI or 10BaseT interface */ 135*4882a593Smuzhiyun #define PP_LineCTL_ModBackoffE 0x0800 /* Enable modified backoff algorithm */ 136*4882a593Smuzhiyun #define PP_LineCTL_PolarityDis 0x1000 /* Disable Rx polarity autodetect */ 137*4882a593Smuzhiyun #define PP_LineCTL_2partDefDis 0x2000 /* Disable two-part defferal */ 138*4882a593Smuzhiyun #define PP_LineCTL_LoRxSquelch 0x4000 /* Reduce receiver squelch threshold */ 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun #define PP_SelfCTL 0x0114 /* Chip self control */ 141*4882a593Smuzhiyun #define PP_SelfCTL_Reset 0x0040 /* Self-clearing reset */ 142*4882a593Smuzhiyun #define PP_SelfCTL_SWSuspend 0x0100 /* Initiate suspend mode */ 143*4882a593Smuzhiyun #define PP_SelfCTL_HWSleepE 0x0200 /* Enable SLEEP input */ 144*4882a593Smuzhiyun #define PP_SelfCTL_HWStandbyE 0x0400 /* Enable standby mode */ 145*4882a593Smuzhiyun #define PP_SelfCTL_HC0E 0x1000 /* use HCB0 for LINK LED */ 146*4882a593Smuzhiyun #define PP_SelfCTL_HC1E 0x2000 /* use HCB1 for BSTATUS LED */ 147*4882a593Smuzhiyun #define PP_SelfCTL_HCB0 0x4000 /* control LINK LED if HC0E set */ 148*4882a593Smuzhiyun #define PP_SelfCTL_HCB1 0x8000 /* control BSTATUS LED if HC1E set */ 149*4882a593Smuzhiyun 150*4882a593Smuzhiyun #define PP_BusCTL 0x0116 /* Bus control */ 151*4882a593Smuzhiyun #define PP_BusCTL_ResetRxDMA 0x0040 /* Reset RxDMA pointer */ 152*4882a593Smuzhiyun #define PP_BusCTL_DMAextend 0x0100 /* Extend DMA cycle */ 153*4882a593Smuzhiyun #define PP_BusCTL_UseSA 0x0200 /* Assert MEMCS16 on address decode */ 154*4882a593Smuzhiyun #define PP_BusCTL_MemoryE 0x0400 /* Enable memory mode */ 155*4882a593Smuzhiyun #define PP_BusCTL_DMAburst 0x0800 /* Limit DMA access burst */ 156*4882a593Smuzhiyun #define PP_BusCTL_IOCHRDYE 0x1000 /* Set IOCHRDY high impedence */ 157*4882a593Smuzhiyun #define PP_BusCTL_RxDMAsize 0x2000 /* Set DMA buffer size 64KB */ 158*4882a593Smuzhiyun #define PP_BusCTL_EnableIRQ 0x8000 /* Generate interrupt on interrupt event */ 159*4882a593Smuzhiyun 160*4882a593Smuzhiyun #define PP_TestCTL 0x0118 /* Test control */ 161*4882a593Smuzhiyun #define PP_TestCTL_DisableLT 0x0080 /* Disable link status */ 162*4882a593Smuzhiyun #define PP_TestCTL_ENDECloop 0x0200 /* Internal loopback */ 163*4882a593Smuzhiyun #define PP_TestCTL_AUIloop 0x0400 /* AUI loopback */ 164*4882a593Smuzhiyun #define PP_TestCTL_DisBackoff 0x0800 /* Disable backoff algorithm */ 165*4882a593Smuzhiyun #define PP_TestCTL_FDX 0x4000 /* Enable full duplex mode */ 166*4882a593Smuzhiyun 167*4882a593Smuzhiyun #define PP_ISQ 0x0120 /* Interrupt Status Queue */ 168*4882a593Smuzhiyun 169*4882a593Smuzhiyun #define PP_RER 0x0124 /* Receive event */ 170*4882a593Smuzhiyun #define PP_RER_IAHash 0x0040 /* Frame hash match */ 171*4882a593Smuzhiyun #define PP_RER_Dribble 0x0080 /* Frame had 1-7 extra bits after last byte */ 172*4882a593Smuzhiyun #define PP_RER_RxOK 0x0100 /* Frame received with no errors */ 173*4882a593Smuzhiyun #define PP_RER_Hashed 0x0200 /* Frame address hashed OK */ 174*4882a593Smuzhiyun #define PP_RER_IA 0x0400 /* Frame address matched IA */ 175*4882a593Smuzhiyun #define PP_RER_Broadcast 0x0800 /* Broadcast frame */ 176*4882a593Smuzhiyun #define PP_RER_CRC 0x1000 /* Frame had CRC error */ 177*4882a593Smuzhiyun #define PP_RER_RUNT 0x2000 /* Runt frame */ 178*4882a593Smuzhiyun #define PP_RER_EXTRA 0x4000 /* Frame was too long */ 179*4882a593Smuzhiyun 180*4882a593Smuzhiyun #define PP_TER 0x0128 /* Transmit event */ 181*4882a593Smuzhiyun #define PP_TER_CRS 0x0040 /* Carrier lost */ 182*4882a593Smuzhiyun #define PP_TER_SQE 0x0080 /* Signal Quality Error */ 183*4882a593Smuzhiyun #define PP_TER_TxOK 0x0100 /* Packet sent without error */ 184*4882a593Smuzhiyun #define PP_TER_Late 0x0200 /* Out of window */ 185*4882a593Smuzhiyun #define PP_TER_Jabber 0x0400 /* Stuck transmit? */ 186*4882a593Smuzhiyun #define PP_TER_NumCollisions 0x7800 /* Number of collisions */ 187*4882a593Smuzhiyun #define PP_TER_16Collisions 0x8000 /* > 16 collisions */ 188*4882a593Smuzhiyun 189*4882a593Smuzhiyun #define PP_BER 0x012C /* Buffer event */ 190*4882a593Smuzhiyun #define PP_BER_SWint 0x0040 /* Software interrupt */ 191*4882a593Smuzhiyun #define PP_BER_RxDMAFrame 0x0080 /* Received framed DMAed */ 192*4882a593Smuzhiyun #define PP_BER_Rdy4Tx 0x0100 /* Ready for transmission */ 193*4882a593Smuzhiyun #define PP_BER_TxUnderrun 0x0200 /* Transmit underrun */ 194*4882a593Smuzhiyun #define PP_BER_RxMiss 0x0400 /* Received frame missed */ 195*4882a593Smuzhiyun #define PP_BER_Rx128 0x0800 /* 128 bytes received */ 196*4882a593Smuzhiyun #define PP_BER_RxDest 0x8000 /* Received framed passed address filter */ 197*4882a593Smuzhiyun 198*4882a593Smuzhiyun #define PP_RxMiss 0x0130 /* Receiver miss counter */ 199*4882a593Smuzhiyun 200*4882a593Smuzhiyun #define PP_TxCol 0x0132 /* Transmit collision counter */ 201*4882a593Smuzhiyun 202*4882a593Smuzhiyun #define PP_LineSTAT 0x0134 /* Line status */ 203*4882a593Smuzhiyun #define PP_LineSTAT_LinkOK 0x0080 /* Line is connected and working */ 204*4882a593Smuzhiyun #define PP_LineSTAT_AUI 0x0100 /* Connected via AUI */ 205*4882a593Smuzhiyun #define PP_LineSTAT_10BT 0x0200 /* Connected via twisted pair */ 206*4882a593Smuzhiyun #define PP_LineSTAT_Polarity 0x1000 /* Line polarity OK (10BT only) */ 207*4882a593Smuzhiyun #define PP_LineSTAT_CRS 0x4000 /* Frame being received */ 208*4882a593Smuzhiyun 209*4882a593Smuzhiyun #define PP_SelfSTAT 0x0136 /* Chip self status */ 210*4882a593Smuzhiyun #define PP_SelfSTAT_33VActive 0x0040 /* supply voltage is 3.3V */ 211*4882a593Smuzhiyun #define PP_SelfSTAT_InitD 0x0080 /* Chip initialization complete */ 212*4882a593Smuzhiyun #define PP_SelfSTAT_SIBSY 0x0100 /* EEPROM is busy */ 213*4882a593Smuzhiyun #define PP_SelfSTAT_EEPROM 0x0200 /* EEPROM present */ 214*4882a593Smuzhiyun #define PP_SelfSTAT_EEPROM_OK 0x0400 /* EEPROM checks out */ 215*4882a593Smuzhiyun #define PP_SelfSTAT_ELPresent 0x0800 /* External address latch logic available */ 216*4882a593Smuzhiyun #define PP_SelfSTAT_EEsize 0x1000 /* Size of EEPROM */ 217*4882a593Smuzhiyun 218*4882a593Smuzhiyun #define PP_BusSTAT 0x0138 /* Bus status */ 219*4882a593Smuzhiyun #define PP_BusSTAT_TxBid 0x0080 /* Tx error */ 220*4882a593Smuzhiyun #define PP_BusSTAT_TxRDY 0x0100 /* Ready for Tx data */ 221*4882a593Smuzhiyun 222*4882a593Smuzhiyun #define PP_TDR 0x013C /* AUI Time Domain Reflectometer */ 223*4882a593Smuzhiyun 224*4882a593Smuzhiyun /* initiate transmit registers */ 225*4882a593Smuzhiyun 226*4882a593Smuzhiyun #define PP_TxCommand 0x0144 /* Tx Command */ 227*4882a593Smuzhiyun #define PP_TxLength 0x0146 /* Tx Length */ 228*4882a593Smuzhiyun 229*4882a593Smuzhiyun 230*4882a593Smuzhiyun /* address filter registers */ 231*4882a593Smuzhiyun 232*4882a593Smuzhiyun #define PP_LAF 0x0150 /* Logical address filter (6 bytes) */ 233*4882a593Smuzhiyun #define PP_IA 0x0158 /* Individual address (MAC) */ 234*4882a593Smuzhiyun 235*4882a593Smuzhiyun /* EEPROM Kram */ 236*4882a593Smuzhiyun #define SI_BUSY 0x0100 237*4882a593Smuzhiyun #define PP_EECMD 0x0040 /* NVR Interface Command register */ 238*4882a593Smuzhiyun #define PP_EEData 0x0042 /* NVR Interface Data Register */ 239*4882a593Smuzhiyun #define EEPROM_WRITE_EN 0x00F0 240*4882a593Smuzhiyun #define EEPROM_WRITE_DIS 0x0000 241*4882a593Smuzhiyun #define EEPROM_WRITE_CMD 0x0100 242*4882a593Smuzhiyun #define EEPROM_READ_CMD 0x0200 243*4882a593Smuzhiyun #define EEPROM_ERASE_CMD 0x0300 244*4882a593Smuzhiyun 245*4882a593Smuzhiyun /* Exported functions */ 246*4882a593Smuzhiyun int cs8900_e2prom_read(struct eth_device *dev, uchar, ushort *); 247*4882a593Smuzhiyun int cs8900_e2prom_write(struct eth_device *dev, uchar, ushort); 248*4882a593Smuzhiyun 249*4882a593Smuzhiyun #endif /* CS8900_H */ 250