xref: /linux/drivers/net/ethernet/microchip/enc28j60_hw.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2580416e6SJeff Kirsher /*
3580416e6SJeff Kirsher  * enc28j60_hw.h: EDTP FrameThrower style enc28j60 registers
4580416e6SJeff Kirsher  *
5580416e6SJeff Kirsher  * $Id: enc28j60_hw.h,v 1.9 2007/12/14 11:59:16 claudio Exp $
6580416e6SJeff Kirsher  */
7580416e6SJeff Kirsher 
8580416e6SJeff Kirsher #ifndef _ENC28J60_HW_H
9580416e6SJeff Kirsher #define _ENC28J60_HW_H
10580416e6SJeff Kirsher 
11580416e6SJeff Kirsher /*
12580416e6SJeff Kirsher  * ENC28J60 Control Registers
13580416e6SJeff Kirsher  * Control register definitions are a combination of address,
14580416e6SJeff Kirsher  * bank number, and Ethernet/MAC/PHY indicator bits.
15580416e6SJeff Kirsher  * - Register address	(bits 0-4)
16580416e6SJeff Kirsher  * - Bank number	(bits 5-6)
17580416e6SJeff Kirsher  * - MAC/MII indicator	(bit 7)
18580416e6SJeff Kirsher  */
19580416e6SJeff Kirsher #define ADDR_MASK	0x1F
20580416e6SJeff Kirsher #define BANK_MASK	0x60
21580416e6SJeff Kirsher #define SPRD_MASK	0x80
22580416e6SJeff Kirsher /* All-bank registers */
23580416e6SJeff Kirsher #define EIE		0x1B
24580416e6SJeff Kirsher #define EIR		0x1C
25580416e6SJeff Kirsher #define ESTAT		0x1D
26580416e6SJeff Kirsher #define ECON2		0x1E
27580416e6SJeff Kirsher #define ECON1		0x1F
28580416e6SJeff Kirsher /* Bank 0 registers */
29580416e6SJeff Kirsher #define ERDPTL		(0x00|0x00)
30580416e6SJeff Kirsher #define ERDPTH		(0x01|0x00)
31580416e6SJeff Kirsher #define EWRPTL		(0x02|0x00)
32580416e6SJeff Kirsher #define EWRPTH		(0x03|0x00)
33580416e6SJeff Kirsher #define ETXSTL		(0x04|0x00)
34580416e6SJeff Kirsher #define ETXSTH		(0x05|0x00)
35580416e6SJeff Kirsher #define ETXNDL		(0x06|0x00)
36580416e6SJeff Kirsher #define ETXNDH		(0x07|0x00)
37580416e6SJeff Kirsher #define ERXSTL		(0x08|0x00)
38580416e6SJeff Kirsher #define ERXSTH		(0x09|0x00)
39580416e6SJeff Kirsher #define ERXNDL		(0x0A|0x00)
40580416e6SJeff Kirsher #define ERXNDH		(0x0B|0x00)
41580416e6SJeff Kirsher #define ERXRDPTL	(0x0C|0x00)
42580416e6SJeff Kirsher #define ERXRDPTH	(0x0D|0x00)
43580416e6SJeff Kirsher #define ERXWRPTL	(0x0E|0x00)
44580416e6SJeff Kirsher #define ERXWRPTH	(0x0F|0x00)
45580416e6SJeff Kirsher #define EDMASTL		(0x10|0x00)
46580416e6SJeff Kirsher #define EDMASTH		(0x11|0x00)
47580416e6SJeff Kirsher #define EDMANDL		(0x12|0x00)
48580416e6SJeff Kirsher #define EDMANDH		(0x13|0x00)
49580416e6SJeff Kirsher #define EDMADSTL	(0x14|0x00)
50580416e6SJeff Kirsher #define EDMADSTH	(0x15|0x00)
51580416e6SJeff Kirsher #define EDMACSL		(0x16|0x00)
52580416e6SJeff Kirsher #define EDMACSH		(0x17|0x00)
53580416e6SJeff Kirsher /* Bank 1 registers */
54580416e6SJeff Kirsher #define EHT0		(0x00|0x20)
55580416e6SJeff Kirsher #define EHT1		(0x01|0x20)
56580416e6SJeff Kirsher #define EHT2		(0x02|0x20)
57580416e6SJeff Kirsher #define EHT3		(0x03|0x20)
58580416e6SJeff Kirsher #define EHT4		(0x04|0x20)
59580416e6SJeff Kirsher #define EHT5		(0x05|0x20)
60580416e6SJeff Kirsher #define EHT6		(0x06|0x20)
61580416e6SJeff Kirsher #define EHT7		(0x07|0x20)
62580416e6SJeff Kirsher #define EPMM0		(0x08|0x20)
63580416e6SJeff Kirsher #define EPMM1		(0x09|0x20)
64580416e6SJeff Kirsher #define EPMM2		(0x0A|0x20)
65580416e6SJeff Kirsher #define EPMM3		(0x0B|0x20)
66580416e6SJeff Kirsher #define EPMM4		(0x0C|0x20)
67580416e6SJeff Kirsher #define EPMM5		(0x0D|0x20)
68580416e6SJeff Kirsher #define EPMM6		(0x0E|0x20)
69580416e6SJeff Kirsher #define EPMM7		(0x0F|0x20)
70580416e6SJeff Kirsher #define EPMCSL		(0x10|0x20)
71580416e6SJeff Kirsher #define EPMCSH		(0x11|0x20)
72580416e6SJeff Kirsher #define EPMOL		(0x14|0x20)
73580416e6SJeff Kirsher #define EPMOH		(0x15|0x20)
74580416e6SJeff Kirsher #define EWOLIE		(0x16|0x20)
75580416e6SJeff Kirsher #define EWOLIR		(0x17|0x20)
76580416e6SJeff Kirsher #define ERXFCON		(0x18|0x20)
77580416e6SJeff Kirsher #define EPKTCNT		(0x19|0x20)
78580416e6SJeff Kirsher /* Bank 2 registers */
79580416e6SJeff Kirsher #define MACON1		(0x00|0x40|SPRD_MASK)
80580416e6SJeff Kirsher /* #define MACON2	(0x01|0x40|SPRD_MASK) */
81580416e6SJeff Kirsher #define MACON3		(0x02|0x40|SPRD_MASK)
82580416e6SJeff Kirsher #define MACON4		(0x03|0x40|SPRD_MASK)
83580416e6SJeff Kirsher #define MABBIPG		(0x04|0x40|SPRD_MASK)
84580416e6SJeff Kirsher #define MAIPGL		(0x06|0x40|SPRD_MASK)
85580416e6SJeff Kirsher #define MAIPGH		(0x07|0x40|SPRD_MASK)
86580416e6SJeff Kirsher #define MACLCON1	(0x08|0x40|SPRD_MASK)
87580416e6SJeff Kirsher #define MACLCON2	(0x09|0x40|SPRD_MASK)
88580416e6SJeff Kirsher #define MAMXFLL		(0x0A|0x40|SPRD_MASK)
89580416e6SJeff Kirsher #define MAMXFLH		(0x0B|0x40|SPRD_MASK)
90580416e6SJeff Kirsher #define MAPHSUP		(0x0D|0x40|SPRD_MASK)
91580416e6SJeff Kirsher #define MICON		(0x11|0x40|SPRD_MASK)
92580416e6SJeff Kirsher #define MICMD		(0x12|0x40|SPRD_MASK)
93580416e6SJeff Kirsher #define MIREGADR	(0x14|0x40|SPRD_MASK)
94580416e6SJeff Kirsher #define MIWRL		(0x16|0x40|SPRD_MASK)
95580416e6SJeff Kirsher #define MIWRH		(0x17|0x40|SPRD_MASK)
96580416e6SJeff Kirsher #define MIRDL		(0x18|0x40|SPRD_MASK)
97580416e6SJeff Kirsher #define MIRDH		(0x19|0x40|SPRD_MASK)
98580416e6SJeff Kirsher /* Bank 3 registers */
99580416e6SJeff Kirsher #define MAADR1		(0x00|0x60|SPRD_MASK)
100580416e6SJeff Kirsher #define MAADR0		(0x01|0x60|SPRD_MASK)
101580416e6SJeff Kirsher #define MAADR3		(0x02|0x60|SPRD_MASK)
102580416e6SJeff Kirsher #define MAADR2		(0x03|0x60|SPRD_MASK)
103580416e6SJeff Kirsher #define MAADR5		(0x04|0x60|SPRD_MASK)
104580416e6SJeff Kirsher #define MAADR4		(0x05|0x60|SPRD_MASK)
105580416e6SJeff Kirsher #define EBSTSD		(0x06|0x60)
106580416e6SJeff Kirsher #define EBSTCON		(0x07|0x60)
107580416e6SJeff Kirsher #define EBSTCSL		(0x08|0x60)
108580416e6SJeff Kirsher #define EBSTCSH		(0x09|0x60)
109580416e6SJeff Kirsher #define MISTAT		(0x0A|0x60|SPRD_MASK)
110580416e6SJeff Kirsher #define EREVID		(0x12|0x60)
111580416e6SJeff Kirsher #define ECOCON		(0x15|0x60)
112580416e6SJeff Kirsher #define EFLOCON		(0x17|0x60)
113580416e6SJeff Kirsher #define EPAUSL		(0x18|0x60)
114580416e6SJeff Kirsher #define EPAUSH		(0x19|0x60)
115580416e6SJeff Kirsher /* PHY registers */
116580416e6SJeff Kirsher #define PHCON1		0x00
117580416e6SJeff Kirsher #define PHSTAT1		0x01
118580416e6SJeff Kirsher #define PHHID1		0x02
119580416e6SJeff Kirsher #define PHHID2		0x03
120580416e6SJeff Kirsher #define PHCON2		0x10
121580416e6SJeff Kirsher #define PHSTAT2		0x11
122580416e6SJeff Kirsher #define PHIE		0x12
123580416e6SJeff Kirsher #define PHIR		0x13
124580416e6SJeff Kirsher #define PHLCON		0x14
125580416e6SJeff Kirsher 
126580416e6SJeff Kirsher /* ENC28J60 EIE Register Bit Definitions */
127580416e6SJeff Kirsher #define EIE_INTIE	0x80
128580416e6SJeff Kirsher #define EIE_PKTIE	0x40
129580416e6SJeff Kirsher #define EIE_DMAIE	0x20
130580416e6SJeff Kirsher #define EIE_LINKIE	0x10
131580416e6SJeff Kirsher #define EIE_TXIE	0x08
132580416e6SJeff Kirsher /* #define EIE_WOLIE	0x04 (reserved) */
133580416e6SJeff Kirsher #define EIE_TXERIE	0x02
134580416e6SJeff Kirsher #define EIE_RXERIE	0x01
135580416e6SJeff Kirsher /* ENC28J60 EIR Register Bit Definitions */
136580416e6SJeff Kirsher #define EIR_PKTIF	0x40
137580416e6SJeff Kirsher #define EIR_DMAIF	0x20
138580416e6SJeff Kirsher #define EIR_LINKIF	0x10
139580416e6SJeff Kirsher #define EIR_TXIF	0x08
140580416e6SJeff Kirsher /* #define EIR_WOLIF	0x04 (reserved) */
141580416e6SJeff Kirsher #define EIR_TXERIF	0x02
142580416e6SJeff Kirsher #define EIR_RXERIF	0x01
143580416e6SJeff Kirsher /* ENC28J60 ESTAT Register Bit Definitions */
144580416e6SJeff Kirsher #define ESTAT_INT	0x80
145580416e6SJeff Kirsher #define ESTAT_LATECOL	0x10
146580416e6SJeff Kirsher #define ESTAT_RXBUSY	0x04
147580416e6SJeff Kirsher #define ESTAT_TXABRT	0x02
148580416e6SJeff Kirsher #define ESTAT_CLKRDY	0x01
149580416e6SJeff Kirsher /* ENC28J60 ECON2 Register Bit Definitions */
150580416e6SJeff Kirsher #define ECON2_AUTOINC	0x80
151580416e6SJeff Kirsher #define ECON2_PKTDEC	0x40
152580416e6SJeff Kirsher #define ECON2_PWRSV	0x20
153580416e6SJeff Kirsher #define ECON2_VRPS	0x08
154580416e6SJeff Kirsher /* ENC28J60 ECON1 Register Bit Definitions */
155580416e6SJeff Kirsher #define ECON1_TXRST	0x80
156580416e6SJeff Kirsher #define ECON1_RXRST	0x40
157580416e6SJeff Kirsher #define ECON1_DMAST	0x20
158580416e6SJeff Kirsher #define ECON1_CSUMEN	0x10
159580416e6SJeff Kirsher #define ECON1_TXRTS	0x08
160580416e6SJeff Kirsher #define ECON1_RXEN	0x04
161580416e6SJeff Kirsher #define ECON1_BSEL1	0x02
162580416e6SJeff Kirsher #define ECON1_BSEL0	0x01
163580416e6SJeff Kirsher /* ENC28J60 MACON1 Register Bit Definitions */
164580416e6SJeff Kirsher #define MACON1_LOOPBK	0x10
165580416e6SJeff Kirsher #define MACON1_TXPAUS	0x08
166580416e6SJeff Kirsher #define MACON1_RXPAUS	0x04
167580416e6SJeff Kirsher #define MACON1_PASSALL	0x02
168580416e6SJeff Kirsher #define MACON1_MARXEN	0x01
169580416e6SJeff Kirsher /* ENC28J60 MACON2 Register Bit Definitions */
170580416e6SJeff Kirsher #define MACON2_MARST	0x80
171580416e6SJeff Kirsher #define MACON2_RNDRST	0x40
172580416e6SJeff Kirsher #define MACON2_MARXRST	0x08
173580416e6SJeff Kirsher #define MACON2_RFUNRST	0x04
174580416e6SJeff Kirsher #define MACON2_MATXRST	0x02
175580416e6SJeff Kirsher #define MACON2_TFUNRST	0x01
176580416e6SJeff Kirsher /* ENC28J60 MACON3 Register Bit Definitions */
177580416e6SJeff Kirsher #define MACON3_PADCFG2	0x80
178580416e6SJeff Kirsher #define MACON3_PADCFG1	0x40
179580416e6SJeff Kirsher #define MACON3_PADCFG0	0x20
180580416e6SJeff Kirsher #define MACON3_TXCRCEN	0x10
181580416e6SJeff Kirsher #define MACON3_PHDRLEN	0x08
182580416e6SJeff Kirsher #define MACON3_HFRMLEN	0x04
183580416e6SJeff Kirsher #define MACON3_FRMLNEN	0x02
184580416e6SJeff Kirsher #define MACON3_FULDPX	0x01
185580416e6SJeff Kirsher /* ENC28J60 MICMD Register Bit Definitions */
186580416e6SJeff Kirsher #define MICMD_MIISCAN	0x02
187580416e6SJeff Kirsher #define MICMD_MIIRD	0x01
188580416e6SJeff Kirsher /* ENC28J60 MISTAT Register Bit Definitions */
189580416e6SJeff Kirsher #define MISTAT_NVALID	0x04
190580416e6SJeff Kirsher #define MISTAT_SCAN	0x02
191580416e6SJeff Kirsher #define MISTAT_BUSY	0x01
192580416e6SJeff Kirsher /* ENC28J60 ERXFCON Register Bit Definitions */
193580416e6SJeff Kirsher #define ERXFCON_UCEN	0x80
194580416e6SJeff Kirsher #define ERXFCON_ANDOR	0x40
195580416e6SJeff Kirsher #define ERXFCON_CRCEN	0x20
196580416e6SJeff Kirsher #define ERXFCON_PMEN	0x10
197580416e6SJeff Kirsher #define ERXFCON_MPEN	0x08
198580416e6SJeff Kirsher #define ERXFCON_HTEN	0x04
199580416e6SJeff Kirsher #define ERXFCON_MCEN	0x02
200580416e6SJeff Kirsher #define ERXFCON_BCEN	0x01
201580416e6SJeff Kirsher 
202580416e6SJeff Kirsher /* ENC28J60 PHY PHCON1 Register Bit Definitions */
203580416e6SJeff Kirsher #define PHCON1_PRST	0x8000
204580416e6SJeff Kirsher #define PHCON1_PLOOPBK	0x4000
205580416e6SJeff Kirsher #define PHCON1_PPWRSV	0x0800
206580416e6SJeff Kirsher #define PHCON1_PDPXMD	0x0100
207580416e6SJeff Kirsher /* ENC28J60 PHY PHSTAT1 Register Bit Definitions */
208580416e6SJeff Kirsher #define PHSTAT1_PFDPX	0x1000
209580416e6SJeff Kirsher #define PHSTAT1_PHDPX	0x0800
210580416e6SJeff Kirsher #define PHSTAT1_LLSTAT	0x0004
211580416e6SJeff Kirsher #define PHSTAT1_JBSTAT	0x0002
212580416e6SJeff Kirsher /* ENC28J60 PHY PHSTAT2 Register Bit Definitions */
213580416e6SJeff Kirsher #define PHSTAT2_TXSTAT	(1 << 13)
214580416e6SJeff Kirsher #define PHSTAT2_RXSTAT	(1 << 12)
215580416e6SJeff Kirsher #define PHSTAT2_COLSTAT	(1 << 11)
216580416e6SJeff Kirsher #define PHSTAT2_LSTAT	(1 << 10)
217580416e6SJeff Kirsher #define PHSTAT2_DPXSTAT	(1 << 9)
218580416e6SJeff Kirsher #define PHSTAT2_PLRITY	(1 << 5)
219580416e6SJeff Kirsher /* ENC28J60 PHY PHCON2 Register Bit Definitions */
220580416e6SJeff Kirsher #define PHCON2_FRCLINK	0x4000
221580416e6SJeff Kirsher #define PHCON2_TXDIS	0x2000
222580416e6SJeff Kirsher #define PHCON2_JABBER	0x0400
223580416e6SJeff Kirsher #define PHCON2_HDLDIS	0x0100
224580416e6SJeff Kirsher /* ENC28J60 PHY PHIE Register Bit Definitions */
225580416e6SJeff Kirsher #define PHIE_PLNKIE	(1 << 4)
226580416e6SJeff Kirsher #define PHIE_PGEIE	(1 << 1)
227580416e6SJeff Kirsher /* ENC28J60 PHY PHIR Register Bit Definitions */
228580416e6SJeff Kirsher #define PHIR_PLNKIF	(1 << 4)
229580416e6SJeff Kirsher #define PHIR_PGEIF	(1 << 1)
230580416e6SJeff Kirsher 
231580416e6SJeff Kirsher /* ENC28J60 Packet Control Byte Bit Definitions */
232580416e6SJeff Kirsher #define PKTCTRL_PHUGEEN		0x08
233580416e6SJeff Kirsher #define PKTCTRL_PPADEN		0x04
234580416e6SJeff Kirsher #define PKTCTRL_PCRCEN		0x02
235580416e6SJeff Kirsher #define PKTCTRL_POVERRIDE	0x01
236580416e6SJeff Kirsher 
237580416e6SJeff Kirsher /* ENC28J60 Transmit Status Vector */
238580416e6SJeff Kirsher #define TSV_TXBYTECNT		0
239580416e6SJeff Kirsher #define TSV_TXCOLLISIONCNT	16
240580416e6SJeff Kirsher #define TSV_TXCRCERROR		20
241580416e6SJeff Kirsher #define TSV_TXLENCHKERROR	21
242580416e6SJeff Kirsher #define TSV_TXLENOUTOFRANGE	22
243580416e6SJeff Kirsher #define TSV_TXDONE		23
244580416e6SJeff Kirsher #define TSV_TXMULTICAST		24
245580416e6SJeff Kirsher #define TSV_TXBROADCAST		25
246580416e6SJeff Kirsher #define TSV_TXPACKETDEFER	26
247580416e6SJeff Kirsher #define TSV_TXEXDEFER		27
248580416e6SJeff Kirsher #define TSV_TXEXCOLLISION	28
249580416e6SJeff Kirsher #define TSV_TXLATECOLLISION	29
250580416e6SJeff Kirsher #define TSV_TXGIANT		30
251580416e6SJeff Kirsher #define TSV_TXUNDERRUN		31
252580416e6SJeff Kirsher #define TSV_TOTBYTETXONWIRE	32
253580416e6SJeff Kirsher #define TSV_TXCONTROLFRAME	48
254580416e6SJeff Kirsher #define TSV_TXPAUSEFRAME	49
255580416e6SJeff Kirsher #define TSV_BACKPRESSUREAPP	50
256580416e6SJeff Kirsher #define TSV_TXVLANTAGFRAME	51
257580416e6SJeff Kirsher 
258580416e6SJeff Kirsher #define TSV_SIZE		7
259580416e6SJeff Kirsher #define TSV_BYTEOF(x)		((x) / 8)
260580416e6SJeff Kirsher #define TSV_BITMASK(x)		(1 << ((x) % 8))
261580416e6SJeff Kirsher #define TSV_GETBIT(x, y)	(((x)[TSV_BYTEOF(y)] & TSV_BITMASK(y)) ? 1 : 0)
262580416e6SJeff Kirsher 
263580416e6SJeff Kirsher /* ENC28J60 Receive Status Vector */
264580416e6SJeff Kirsher #define RSV_RXLONGEVDROPEV	16
265580416e6SJeff Kirsher #define RSV_CARRIEREV		18
266580416e6SJeff Kirsher #define RSV_CRCERROR		20
267580416e6SJeff Kirsher #define RSV_LENCHECKERR		21
268580416e6SJeff Kirsher #define RSV_LENOUTOFRANGE	22
269580416e6SJeff Kirsher #define RSV_RXOK		23
270580416e6SJeff Kirsher #define RSV_RXMULTICAST		24
271580416e6SJeff Kirsher #define RSV_RXBROADCAST		25
272580416e6SJeff Kirsher #define RSV_DRIBBLENIBBLE	26
273580416e6SJeff Kirsher #define RSV_RXCONTROLFRAME	27
274580416e6SJeff Kirsher #define RSV_RXPAUSEFRAME	28
275580416e6SJeff Kirsher #define RSV_RXUNKNOWNOPCODE	29
276580416e6SJeff Kirsher #define RSV_RXTYPEVLAN		30
277580416e6SJeff Kirsher 
278580416e6SJeff Kirsher #define RSV_SIZE		6
279580416e6SJeff Kirsher #define RSV_BITMASK(x)		(1 << ((x) - 16))
280580416e6SJeff Kirsher #define RSV_GETBIT(x, y)	(((x) & RSV_BITMASK(y)) ? 1 : 0)
281580416e6SJeff Kirsher 
282580416e6SJeff Kirsher 
283580416e6SJeff Kirsher /* SPI operation codes */
284580416e6SJeff Kirsher #define ENC28J60_READ_CTRL_REG	0x00
285580416e6SJeff Kirsher #define ENC28J60_READ_BUF_MEM	0x3A
286580416e6SJeff Kirsher #define ENC28J60_WRITE_CTRL_REG 0x40
287580416e6SJeff Kirsher #define ENC28J60_WRITE_BUF_MEM	0x7A
288580416e6SJeff Kirsher #define ENC28J60_BIT_FIELD_SET	0x80
289580416e6SJeff Kirsher #define ENC28J60_BIT_FIELD_CLR	0xA0
290580416e6SJeff Kirsher #define ENC28J60_SOFT_RESET	0xFF
291580416e6SJeff Kirsher 
292580416e6SJeff Kirsher 
293580416e6SJeff Kirsher /* buffer boundaries applied to internal 8K ram
294580416e6SJeff Kirsher  * entire available packet buffer space is allocated.
295580416e6SJeff Kirsher  * Give TX buffer space for one full ethernet frame (~1500 bytes)
296580416e6SJeff Kirsher  * receive buffer gets the rest */
297580416e6SJeff Kirsher #define TXSTART_INIT		0x1A00
298580416e6SJeff Kirsher #define TXEND_INIT		0x1FFF
299580416e6SJeff Kirsher 
300580416e6SJeff Kirsher /* Put RX buffer at 0 as suggested by the Errata datasheet */
301580416e6SJeff Kirsher #define RXSTART_INIT		0x0000
302580416e6SJeff Kirsher #define RXEND_INIT		0x19FF
303580416e6SJeff Kirsher 
304580416e6SJeff Kirsher /* maximum ethernet frame length */
305580416e6SJeff Kirsher #define MAX_FRAMELEN		1518
306580416e6SJeff Kirsher 
307580416e6SJeff Kirsher /* Preferred half duplex: LEDA: Link status LEDB: Rx/Tx activity */
308580416e6SJeff Kirsher #define ENC28J60_LAMPS_MODE	0x3476
309580416e6SJeff Kirsher 
310580416e6SJeff Kirsher #endif
311