Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2022 Davicom Semiconductor,Inc.
0004  * Davicom DM9051 SPI Fast Ethernet Linux driver
0005  */
0006 
0007 #ifndef _DM9051_H_
0008 #define _DM9051_H_
0009 
0010 #include <linux/bits.h>
0011 #include <linux/netdevice.h>
0012 #include <linux/types.h>
0013 
0014 #define DM9051_ID       0x9051
0015 
0016 #define DM9051_NCR      0x00
0017 #define DM9051_NSR      0x01
0018 #define DM9051_TCR      0x02
0019 #define DM9051_RCR      0x05
0020 #define DM9051_BPTR     0x08
0021 #define DM9051_FCR      0x0A
0022 #define DM9051_EPCR     0x0B
0023 #define DM9051_EPAR     0x0C
0024 #define DM9051_EPDRL        0x0D
0025 #define DM9051_EPDRH        0x0E
0026 #define DM9051_PAR      0x10
0027 #define DM9051_MAR      0x16
0028 #define DM9051_GPCR     0x1E
0029 #define DM9051_GPR      0x1F
0030 
0031 #define DM9051_VIDL     0x28
0032 #define DM9051_VIDH     0x29
0033 #define DM9051_PIDL     0x2A
0034 #define DM9051_PIDH     0x2B
0035 #define DM9051_SMCR     0x2F
0036 #define DM9051_ATCR     0x30
0037 #define DM9051_SPIBCR       0x38
0038 #define DM9051_INTCR        0x39
0039 #define DM9051_PPCR     0x3D
0040 
0041 #define DM9051_MPCR     0x55
0042 #define DM9051_LMCR     0x57
0043 #define DM9051_MBNDRY       0x5E
0044 
0045 #define DM9051_MRRL     0x74
0046 #define DM9051_MRRH     0x75
0047 #define DM9051_MWRL     0x7A
0048 #define DM9051_MWRH     0x7B
0049 #define DM9051_TXPLL        0x7C
0050 #define DM9051_TXPLH        0x7D
0051 #define DM9051_ISR      0x7E
0052 #define DM9051_IMR      0x7F
0053 
0054 #define DM_SPI_MRCMDX       0x70
0055 #define DM_SPI_MRCMD        0x72
0056 #define DM_SPI_MWCMD        0x78
0057 
0058 #define DM_SPI_WR       0x80
0059 
0060 /* dm9051 Ethernet controller registers bits
0061  */
0062 /* 0x00 */
0063 #define NCR_WAKEEN      BIT(6)
0064 #define NCR_FDX         BIT(3)
0065 #define NCR_RST         BIT(0)
0066 /* 0x01 */
0067 #define NSR_SPEED       BIT(7)
0068 #define NSR_LINKST      BIT(6)
0069 #define NSR_WAKEST      BIT(5)
0070 #define NSR_TX2END      BIT(3)
0071 #define NSR_TX1END      BIT(2)
0072 /* 0x02 */
0073 #define TCR_DIS_JABBER_TIMER    BIT(6) /* for Jabber Packet support */
0074 #define TCR_TXREQ       BIT(0)
0075 /* 0x05 */
0076 #define RCR_DIS_WATCHDOG_TIMER  BIT(6)  /* for Jabber Packet support */
0077 #define RCR_DIS_LONG        BIT(5)
0078 #define RCR_DIS_CRC     BIT(4)
0079 #define RCR_ALL         BIT(3)
0080 #define RCR_PRMSC       BIT(1)
0081 #define RCR_RXEN        BIT(0)
0082 #define RCR_RX_DISABLE      (RCR_DIS_LONG | RCR_DIS_CRC)
0083 /* 0x06 */
0084 #define RSR_RF          BIT(7)
0085 #define RSR_MF          BIT(6)
0086 #define RSR_LCS         BIT(5)
0087 #define RSR_RWTO        BIT(4)
0088 #define RSR_PLE         BIT(3)
0089 #define RSR_AE          BIT(2)
0090 #define RSR_CE          BIT(1)
0091 #define RSR_FOE         BIT(0)
0092 #define RSR_ERR_BITS        (RSR_RF | RSR_LCS | RSR_RWTO | RSR_PLE | \
0093                  RSR_AE | RSR_CE | RSR_FOE)
0094 /* 0x0A */
0095 #define FCR_TXPEN       BIT(5)
0096 #define FCR_BKPM        BIT(3)
0097 #define FCR_FLCE        BIT(0)
0098 #define FCR_RXTX_BITS       (FCR_TXPEN | FCR_BKPM | FCR_FLCE)
0099 /* 0x0B */
0100 #define EPCR_WEP        BIT(4)
0101 #define EPCR_EPOS       BIT(3)
0102 #define EPCR_ERPRR      BIT(2)
0103 #define EPCR_ERPRW      BIT(1)
0104 #define EPCR_ERRE       BIT(0)
0105 /* 0x1E */
0106 #define GPCR_GEP_CNTL       BIT(0)
0107 /* 0x1F */
0108 #define GPR_PHY_OFF     BIT(0)
0109 /* 0x30 */
0110 #define ATCR_AUTO_TX        BIT(7)
0111 /* 0x39 */
0112 #define INTCR_POL_LOW       (1 << 0)
0113 #define INTCR_POL_HIGH      (0 << 0)
0114 /* 0x3D */
0115 /* Pause Packet Control Register - default = 1 */
0116 #define PPCR_PAUSE_COUNT    0x08
0117 /* 0x55 */
0118 #define MPCR_RSTTX      BIT(1)
0119 #define MPCR_RSTRX      BIT(0)
0120 /* 0x57 */
0121 /* LEDMode Control Register - LEDMode1 */
0122 /* Value 0x81 : bit[7] = 1, bit[2] = 0, bit[1:0] = 01b */
0123 #define LMCR_NEWMOD     BIT(7)
0124 #define LMCR_TYPED1     BIT(1)
0125 #define LMCR_TYPED0     BIT(0)
0126 #define LMCR_MODE1      (LMCR_NEWMOD | LMCR_TYPED0)
0127 /* 0x5E */
0128 #define MBNDRY_BYTE     BIT(7)
0129 /* 0xFE */
0130 #define ISR_MBS         BIT(7)
0131 #define ISR_LNKCHG      BIT(5)
0132 #define ISR_ROOS        BIT(3)
0133 #define ISR_ROS         BIT(2)
0134 #define ISR_PTS         BIT(1)
0135 #define ISR_PRS         BIT(0)
0136 #define ISR_CLR_INT     (ISR_LNKCHG | ISR_ROOS | ISR_ROS | \
0137                  ISR_PTS | ISR_PRS)
0138 #define ISR_STOP_MRCMD      (ISR_MBS)
0139 /* 0xFF */
0140 #define IMR_PAR         BIT(7)
0141 #define IMR_LNKCHGI     BIT(5)
0142 #define IMR_PTM         BIT(1)
0143 #define IMR_PRM         BIT(0)
0144 
0145 /* Const
0146  */
0147 #define DM9051_PHY_ADDR         1   /* PHY id */
0148 #define DM9051_PHY          0x40    /* PHY address 0x01 */
0149 #define DM9051_PKT_RDY          0x01    /* Packet ready to receive */
0150 #define DM9051_PKT_MAX          1536    /* Received packet max size */
0151 #define DM9051_TX_QUE_HI_WATER      50
0152 #define DM9051_TX_QUE_LO_WATER      25
0153 #define DM_EEPROM_MAGIC         0x9051
0154 
0155 #define DM_RXHDR_SIZE           sizeof(struct dm9051_rxhdr)
0156 
0157 static inline struct board_info *to_dm9051_board(struct net_device *ndev)
0158 {
0159     return netdev_priv(ndev);
0160 }
0161 
0162 #endif /* _DM9051_H_ */