/*
* Copyright (c) 2009 Paul Fleischer
* All rights reserved.
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the company nor the name of the author may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Registers accessible on the DM9000, extracted from pp. 11-12 from
* the data sheet
*/
/*
* There are two interesting addresses for the DM9000 (at least in
* the context of the FriendlyARM MINI2440) The I/O or register select
* address, which is the base address. The DATA address, which is
* located at offset 4 from the base address.
*
* Chances are that this will not work generally, as it really depends
* on how the address lines are mapped from the CPU to the DM9000.
* But for now it is a good starting point.
*/
#define DM9000_IOSIZE 4
#define DM9000_NCR 0x00 /* "network" control */
#define DM9000_NCR_RST (1<<0) /* reset chip, self clear */
#define DM9000_NCR_LBK_MASK (0x06) /* loopback test selection */
#define DM9000_NCR_LBK_SHIFT (1)
#define DM9000_NCR_LBK_NORMAL (0<<1) /* normal operation */
#define DM9000_NCR_LBK_MAC_INTERNAL (1<<1) /* MAC loopback */
#define DM9000_NCR_LBK_INT_PHY (2<<1) /* PHY loopback */
#define DM9000_NCR_FDX (1<<3) /* use full-duplex, RO when int PHY */
#define DM9000_NCR_FCOL (1<<4) /* force coll. mode. test only */
#define DM9000_NCR_WAKEEN (1<<6) /* wakeup event enable */
#define DM9000_NCR_EXY_PHY (1<<7) /* select ext. PHY, immune SW reset */
#define DM9000_NSR 0x01 /* "network" status */
#define DM9000_NSR_RXOV (1<<1) /* receive overflow detected */
#define DM9000_NSR_TX1END (1<<2) /* transmit 1 completed, W1C */
#define DM9000_NSR_TX2END (1<<3) /* transmit 2 completed, W1C */
#define DM9000_NSR_WAKEST (1<<5) /* wakeup event, W1C */
#define DM9000_NSR_LINKST (1<<6) /* link is up */
#define DM9000_NSR_SPEED (1<<7) /* 1: 100Mbps, 0: 10Mbps */
#define DM9000_TCR 0x02 /* Tx control */
#define DM9000_TCR_TXREQ (1<<0) /* request to start Tx, self clear */
#define DM9000_TCR_CRC_DIS1 (1<<1) /* disable PAD op on Tx1 */
#define DM9000_TCR_PAD_DIS1 (1<<2) /* disable CRC append on Tx1 */
#define DM9000_TCR_CRC_DIS2 (1<<3) /* disable PAD op on Tx2 */
#define DM9000_TCR_PAD_DIS2 (1<<4) /* disable CRC append on Tx2 */
#define DM9000_TCR_EXCECM (1<<5) /* allow infinite colli. retries */
#define DM9000_TCR_TJDIS (1<<6) /* disable xmit jabber, otherwise on */
#define DM9000_TSR1 0x03 /* transmit completion status 1 */
#define DM9000_TSR2 0x04 /* transmit completion status 2 */
#define DM9000_TSR_EC (1<<2) /* aborted after 16 collision */
#define DM9000_TSR_COL (1<<3) /* collision detected while xmit */
#define DM9000_TSR_LCOL (1<<4) /* out of window "late" collision */
#define DM9000_TSR_NC (1<<5) /* no carrier signal found */
#define DM9000_TSR_CLOSS (1<<6) /* loss of carrier */
#define DM9000_TSR_TJTO (1<<7) /* Tx jabber time out */
#define DM9000_RCR 0x05 /* Rx control */
#define DM9000_RCR_RXEN (1<<0) /* activate Rx */
#define DM9000_RCR_PRMSC (1<<1) /* enable promisc mode */
#define DM9000_RCR_RUNT (1<<2) /* accept damaged runt frame */
#define DM9000_RCR_ALL (1<<3) /* accept all multicast */
#define DM9000_RCR_DIS_CRC (1<<4) /* drop bad CRC frame */
#define DM9000_RCR_DIS_LONG (1<<5) /* drop too long frame >1522 */
#define DM9000_RCR_WTDIS (1<<6) /* disable >2048 Rx detect timer */
#define DM9000_RSR 0x06 /* Rx status */
#define DM9000_RSR_FOE (1<<0) /* Rx FIFO overflow detected */
#define DM9000_RSR_CE (1<<1) /* CRC error found */
#define DM9000_RSR_AE (1<<2) /* tail not ended in byte boundary */
#define DM9000_RSR_PLE (1<<3) /* physical layer error */
#define DM9000_RSR_RWTO (1<<4) /* >2048 condition detected */
#define DM9000_RSR_LCS (1<<5) /* late colli. detected */
#define DM9000_RSR_MF (1<<6) /* mcast/bcast frame received */
#define DM9000_RSR_RF (1<<7) /* damaged runt frame received <64 */
#define DM9000_ROCR 0x07 /* receive overflow counter */
/* 7: OVF detected, 6:0 statistic counter */
#define DM9000_BPTR 0x08 /* back pressure threshold */
/* 7:4 back pressure high watermark (3 def), 3:0 jam pattern time (7 def) */
#define DM9000_FCTR 0x09 /* flow control threshold */
/* 7:4 Rx FIFO high w.m. (3 def), low w.m. (8 def) */
#define DM9000_FCR 0x0A /* Rx flow control */
#define DM9000_FCR_FLCE (1<<0) /* flow control enable */
#define DM9000_FCR_RXPCS (1<<1) /* Rx PAUSE current status */
#define DM9000_FCR_RXPS (1<<2) /* Rx PAUSE status, latched R2C */
#define DM9000_FCR_BKPM (1<<3) /* HDX back pressure for my frames */
#define DM9000_FCR_BKPA (1<<4) /* HDX back pressure for any frames */
#define DM9000_FCR_TXPEN (1<<5) /* activate auto PAUSE operation */
#define DM9000_FCR_TXPF (1<<6) /* Tx PAUSE packet (when full) */
#define DM9000_FCR_TXP0 (1<<7) /* Tx PAUSE packet (when empty) */
#define DM9000_EPCR 0x0B /* EEPROM / PHY control */
#define DM9000_EPCR_ERRE (1<<0) /* operation in progress, busy bit */
#define DM9000_EPCR_ERPRW (1<<1) /* instruct to write, not SC */
#define DM9000_EPCR_ERPRR (1<<2) /* instruct to read, not SC */
#define DM9000_EPCR_EPOS_EEPROM (0<<3) /* EEPROM operation */
#define DM9000_EPCR_EPOS_PHY (1<<3) /* PHY operation */
#define DM9000_EPCR_WEP (1<<4) /* EEPROM write enable */
#define DM9000_EPCR_REEP (1<<5) /* reload EEPROM contents, not SC */
#define DM9000_EPAR 0x0C /* EEPROM / PHY address */
#define DM9000_EPAR_EROA_MASK 0x3F /* 7:6 (!!) PHY id, 5:0 addr/reg */
#define DM9000_EPAR_INT_PHY 0x40 /* EPAR[7:6] = 01 for internal PHY */
#define DM9000_EPDRL 0x0D /* EEPROM / PHY data 7:0 */
#define DM9000_EPDRH 0x0E /* EEPROM / PHY data 15:8 */
#define DM9000_WCR 0x0F /* wakeup control and status */
#define DM9000_MAGIC (1<<0) /* magic frame arrived */
#define DM9000_SAMPLE (1<<1) /* sample frame arrived */
#define DM9000_LINK (1<<2) /* link change / status change found */
#define DM9000_MAGICEN (1<<3) /* enable magic frame event detect */
#define DM9000_SMAPLEEN (1<<4) /* enable sample frame event detect */
#define DM9000_LINKEN (1<<5) /* enable link change event detect */
#define DM9000_PAB0 0x10 /* my station address 7:0 */
#define DM9000_PAB1 0x11
#define DM9000_PAB2 0x12
#define DM9000_PAB3 0x13
#define DM9000_PAB4 0x14
#define DM9000_PAB5 0x15 /* my station address 47:40 */