/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */

#ifndef __AX_DEFS_H__
#define __AX_DEFS_H__

//
// ASIX AX88772 USB to 10/100 Fast Ethernet/HomePNA Controller Definitions
//

// USB address
#define AX88772_VENDOR_ID 0b95
#define AX88772_PRODUCT_ID 7720
#define AX88772_LANGUAGE_ENGLISH   0x904

#define AX_DEV0 "/dev/usb/oh0/0b95/7720"

// EEPROM Flag
#define AX88772_FLAG_SP                    0x1  // 1=self-power, 0=bus-power
#define AX88772_FLAG_RWU                   0x4  // remote wakeup
#define AX88772_FLAG_DCK                  0x10  // disabled chirp k
#define AX88772_FLAG_SCPR                 0x20  // 1=PRL+PRTE of sw reset reg control phy
                                                // 0=PRTE control phy
#define AX88772_FLAG_RDCE                 0x40  // CRC dropped before forwarding on RX
#define AX88772_FLAG_TACE                 0x80  // append CRC on TX
#define AX88772_FLAG_CEM                 0x100  // capture effective mode
#define AX88772_FLAG_TDPE                0x200  // test debug port enable

// Interrupt endpoint
#define AX88772_INTR_PPLS                  0x1  // primary PHY link status, 1=up
#define AX88772_INTR_SPLS                  0x2  // 2nd-ary PHY link status, 1=up
#define AX88772_INTR_FLE                   0x4  // bulk out length error
#define AX88772_INTR_MDINT                 0x8  // MDINT input pin (1=hi, 0=lo)

// Serial Management Status reg (0x09, read only)
#define AX88772_SERIAL_REG_HOSTEN          0x1  // 1=sw owns PHY i/f, 0=hw (0)

// Rx Control reg (0xf read only, 0x10 write only)
#define AX88772_RX_CONTROL_REG_PRO         0x1  // Promiscous mode (0)
#define AX88772_RX_CONTROL_REG_AMALL       0x2  // all mcast mode (0)
#define AX88772_RX_CONTROL_REG_SEP         0x4  // save err pkt (0)
#define AX88772_RX_CONTROL_REG_AB          0x8  // bcast mode (1)
#define AX88772_RX_CONTROL_REG_AM         0x10  // mcast match DA (1)
#define AX88772_RX_CONTROL_REG_AP         0x20  // filter unicast packets (0)
#define AX88772_RX_CONTROL_REG_SO         0x80  // start op (0)
#define AX88772_RX_CONTROL_REG_MFB_MASK  0x300  // max frame burst size (3)
#define AX88772_RX_CONTROL_REG_MFB_2K    0x000  // max frame burst size
#define AX88772_RX_CONTROL_REG_MFB_4K    0x100  // max frame burst size
#define AX88772_RX_CONTROL_REG_MFB_8K    0x200  // max frame burst size
#define AX88772_RX_CONTROL_REG_MFB_16K   0x300  // max frame burst size (default)

#define AX88772_RX_CONTROL_REG_DEFAULT  0x0318  // max frame burst size (default)

// Medium Status reg (0x1a, read only), Medium Mode reg (0x1b, write only)
#define AX88772_MEDIUM_REG_FD               0x2  // 1=full 0=half (1)
#define AX88772_MEDIUM_REG_RFC             0x10  // enable rx pause frame (1)
#define AX88772_MEDIUM_REG_TFC             0x20  // enable tx pause frame (1)
#define AX88772_MEDIUM_REG_PF              0x80  // 1=pause frame id'd on length/type
                                                 // 0=length/type+DA dest Addr (0)
#define AX88772_MEDIUM_REG_RE             0x100  // rx enable (0)
#define AX88772_MEDIUM_REG_PS             0x200  // 1=port speed 100, 0=10Mbps (1)
#define AX88772_MEDIUM_REG_SBP            0x800  // 1 and TFC=1 continous back pressure
                                                 // if rx buffer full in Half Duplex mode,
                                                 // 0 only intermittent when rx full (0)
#define AX88772_MEDIUM_REG_SM            0x1000  // super MAC support (0)

#define AX88772_MEDIUM_REG_DEFAULT       0x0236  // default setting after reset

// Monitor Mode reg (0x1d, write only)
#define AX88772_MONITOR_REG_MOM             0x1  // all pkts checked, but not buffered (0)
#define AX88772_MONITOR_REG_RWLU            0x2  // remote wakeup trigger by ethernet link-up (0)
#define AX88772_MONITOR_REG_RWMP            0x4  // remote wakeup trigger by magic packet (0)

// Software Reset reg (0x20, write only)
#define AX88772_RESET_REG_RR               0x1  // clr frame length error bulk in (0)
#define AX88772_RESET_REG_RT               0x2  // clr frame length error bulk out (0)
#define AX88772_RESET_REG_PRTE             0x4  // ext phy reset pin tri-state enab (1)
#define AX88772_RESET_REG_PRL              0x8  // ext phy reset pin lvl (1)
#define AX88772_RESET_REG_BZ              0x10  // force bulk in to ret 0 len pkt (0) 
#define AX88772_RESET_REG_IPRL            0x20  // 0=int phy reset (0)
#define AX88772_RESET_REG_IPPD            0x40  // int phy power down (1)

// Software PHY Select reg (0x21 read only, 0x22 write only)
#define AX88772_PHY_SELECT_REG_PSEL        0x1  // 0/1=manual select ext/int phy
#define AX88772_PHY_SELECT_REG_ASEL        0x2  // 0/1=manual/auto select phy

// PHY register indices
#define AX88772_PHY_REG_BMCR                 0  // basic mode control reg
#define AX88772_PHY_REG_BMSR                 1  // basic mode status reg
#define AX88772_PHY_REG_PHYIDR1              2  // phy identifier reg 1
#define AX88772_PHY_REG_PHYIDR2              3  // phy identifier reg 2
#define AX88772_PHY_REG_ANAR                 4  // Auto neg advertisment reg
#define AX88772_PHY_REG_ANLPAR               5  // auto neg link partner ability
#define AX88772_PHY_REG_ANER                 6  // auto neg expansion reg

// PHY register 0, BMCR
#define AX88772_PHY_REG_BMCR_COLL         0x80  // collision test enabled (0)
#define AX88772_PHY_REG_BMCR_DUPLEX      0x100  // 1=full 0=half (1)
#define AX88772_PHY_REG_BMCR_RST_AN      0x200  // restart auto neg (0)
#define AX88772_PHY_REG_BMCR_ISOLATE     0x400  // isolate 0=normal (0)
#define AX88772_PHY_REG_BMCR_POWER_DN    0x800  // power down 0 = normal (0)
#define AX88772_PHY_REG_BMCR_AN_ENABLE  0x1000  // auto neg enable (1)
#define AX88772_PHY_REG_BMCR_SPEED      0x2000  // speed 1=100Mbps, 0=10Mbit/sec (1)
#define AX88772_PHY_REG_BMCR_LOOPBACK   0x4000  // loopback (0)
#define AX88772_PHY_REG_BMCR_RESET      0x8000  // sw reset (0)

#define AX88772_PHY_REG_BMCR_DEFAULT    0x3100  // default setting after reset

// PHY register 1, BMSR
#define AX88772_PHY_REG_BMSR_EXT_CAP       0x1  // extended capability (1)
#define AX88772_PHY_REG_BMSR_JABBER        0x2  // jabber detect (0)
#define AX88772_PHY_REG_BMSR_LINK_STAT     0x4  // valid link (0)
#define AX88772_PHY_REG_BMSR_AN_CAPABLE    0x8  // auto neg capable (1)
#define AX88772_PHY_REG_BMSR_REM_FAULT    0x10  // remote fault (0)
#define AX88772_PHY_REG_BMSR_AN_COMPLETE  0x20  // auto neg complete (0)
#define AX88772_PHY_REG_BMSR_MF_PREAMBLE  0x40  // preamble suppress (0)
#define AX88772_PHY_REG_BMSR_10_HALF     0x800  // able to do 10 1/2 (1)
#define AX88772_PHY_REG_BMSR_10_FULL    0x1000  // able to do 10 full (1)
#define AX88772_PHY_REG_BMSR_100_HALF   0x2000  // able to do 100 1/2 (1)
#define AX88772_PHY_REG_BMSR_100_FULL   0x4000  // able to do 100 full (1)
#define AX88772_PHY_REG_BMSR_100_T4     0x8000  // able to do T4 (0)

// PHY register 4, ANAR
#define AX88772_PHY_REG_ANAR_10_HD        0x20  // 10 1/2 supported (1)
#define AX88772_PHY_REG_ANAR_10_FD        0x40  // 10 full supported (1)
#define AX88772_PHY_REG_ANAR_100_HD       0x80  // 100 1/2 supported (1)
#define AX88772_PHY_REG_ANAR_100_FD      0x100  // 100 full supported (1)
#define AX88772_PHY_REG_ANAR_T4          0x200  // 100BASE-T4 supported (0)
#define AX88772_PHY_REG_ANAR_PAUSE_EN    0x400  // pause enabled for
                                                //   full duplex links (0)
#define AX88772_PHY_REG_ANAR_RF         0x2000  // remote fault
                                                //   detection supported (0)
#define AX88772_PHY_REG_ANAR_ACK        0x4000  // link partner ack (0)
#define AX88772_PHY_REG_ANAR_NP         0x8000  // next page available (0)

// PHY register 5, ANLPAR
#define AX88772_PHY_REG_ANALPAR_10_HD     0x20  // 1=10 1/2 supported (0)
#define AX88772_PHY_REG_ANALPAR_10_FD     0x40  // 1=10 full supported (0)
#define AX88772_PHY_REG_ANALPAR_100_HD    0x80  // 1=100 1/2 supported (0)
#define AX88772_PHY_REG_ANALPAR_100_FD   0x100  // 1=100 full supported (0)

// PHY register 6, ANER
#define AX88772_PHY_REG_ANER_LP_AN_AB      0x1  // partner capable of AN (0)
#define AX88772_PHY_REG_ANER_AN_PAGE_RX    0x2  // new page received (0)
#define AX88772_PHY_REG_ANER_NP_AB         0x4  // next page enabled (0)
#define AX88772_PHY_REG_ANER_LP_NP_AB      0x8  // partner next page enabled (0)
#define AX88772_PHY_REG_ANER_AN_PDF       0x10  // parallel fault detection (0)

#endif /* __AX_DEFS_H__ */
