18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Faraday FTMAC100 10/100 Ethernet
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * (C) Copyright 2009-2011 Faraday Technology
68c2ecf20Sopenharmony_ci * Po-Yu Chuang <ratbert@faraday-tech.com>
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef __FTMAC100_H
108c2ecf20Sopenharmony_ci#define __FTMAC100_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_ISR		0x00
138c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_IMR		0x04
148c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_MAC_MADR	0x08
158c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_MAC_LADR	0x0c
168c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_MAHT0		0x10
178c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_MAHT1		0x14
188c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_TXPD		0x18
198c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_RXPD		0x1c
208c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_TXR_BADR	0x20
218c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_RXR_BADR	0x24
228c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_ITC		0x28
238c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_APTC		0x2c
248c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_DBLAC		0x30
258c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_MACCR		0x88
268c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_MACSR		0x8c
278c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_PHYCR		0x90
288c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_PHYWDATA	0x94
298c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_FCR		0x98
308c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_BPR		0x9c
318c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_TS		0xc4
328c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_DMAFIFOS	0xc8
338c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_TM		0xcc
348c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_TX_MCOL_SCOL	0xd4
358c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_RPF_AEP		0xd8
368c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_XM_PG		0xdc
378c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_RUNT_TLCC	0xe0
388c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_CRCER_FTL	0xe4
398c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_RLC_RCC		0xe8
408c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_BROC		0xec
418c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_MULCA		0xf0
428c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_RP		0xf4
438c2ecf20Sopenharmony_ci#define	FTMAC100_OFFSET_XP		0xf8
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/*
468c2ecf20Sopenharmony_ci * Interrupt status register & interrupt mask register
478c2ecf20Sopenharmony_ci */
488c2ecf20Sopenharmony_ci#define	FTMAC100_INT_RPKT_FINISH	(1 << 0)
498c2ecf20Sopenharmony_ci#define	FTMAC100_INT_NORXBUF		(1 << 1)
508c2ecf20Sopenharmony_ci#define	FTMAC100_INT_XPKT_FINISH	(1 << 2)
518c2ecf20Sopenharmony_ci#define	FTMAC100_INT_NOTXBUF		(1 << 3)
528c2ecf20Sopenharmony_ci#define	FTMAC100_INT_XPKT_OK		(1 << 4)
538c2ecf20Sopenharmony_ci#define	FTMAC100_INT_XPKT_LOST		(1 << 5)
548c2ecf20Sopenharmony_ci#define	FTMAC100_INT_RPKT_SAV		(1 << 6)
558c2ecf20Sopenharmony_ci#define	FTMAC100_INT_RPKT_LOST		(1 << 7)
568c2ecf20Sopenharmony_ci#define	FTMAC100_INT_AHB_ERR		(1 << 8)
578c2ecf20Sopenharmony_ci#define	FTMAC100_INT_PHYSTS_CHG		(1 << 9)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/*
608c2ecf20Sopenharmony_ci * Interrupt timer control register
618c2ecf20Sopenharmony_ci */
628c2ecf20Sopenharmony_ci#define FTMAC100_ITC_RXINT_CNT(x)	(((x) & 0xf) << 0)
638c2ecf20Sopenharmony_ci#define FTMAC100_ITC_RXINT_THR(x)	(((x) & 0x7) << 4)
648c2ecf20Sopenharmony_ci#define FTMAC100_ITC_RXINT_TIME_SEL	(1 << 7)
658c2ecf20Sopenharmony_ci#define FTMAC100_ITC_TXINT_CNT(x)	(((x) & 0xf) << 8)
668c2ecf20Sopenharmony_ci#define FTMAC100_ITC_TXINT_THR(x)	(((x) & 0x7) << 12)
678c2ecf20Sopenharmony_ci#define FTMAC100_ITC_TXINT_TIME_SEL	(1 << 15)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci/*
708c2ecf20Sopenharmony_ci * Automatic polling timer control register
718c2ecf20Sopenharmony_ci */
728c2ecf20Sopenharmony_ci#define	FTMAC100_APTC_RXPOLL_CNT(x)	(((x) & 0xf) << 0)
738c2ecf20Sopenharmony_ci#define	FTMAC100_APTC_RXPOLL_TIME_SEL	(1 << 4)
748c2ecf20Sopenharmony_ci#define	FTMAC100_APTC_TXPOLL_CNT(x)	(((x) & 0xf) << 8)
758c2ecf20Sopenharmony_ci#define	FTMAC100_APTC_TXPOLL_TIME_SEL	(1 << 12)
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/*
788c2ecf20Sopenharmony_ci * DMA burst length and arbitration control register
798c2ecf20Sopenharmony_ci */
808c2ecf20Sopenharmony_ci#define FTMAC100_DBLAC_INCR4_EN		(1 << 0)
818c2ecf20Sopenharmony_ci#define FTMAC100_DBLAC_INCR8_EN		(1 << 1)
828c2ecf20Sopenharmony_ci#define FTMAC100_DBLAC_INCR16_EN	(1 << 2)
838c2ecf20Sopenharmony_ci#define FTMAC100_DBLAC_RXFIFO_LTHR(x)	(((x) & 0x7) << 3)
848c2ecf20Sopenharmony_ci#define FTMAC100_DBLAC_RXFIFO_HTHR(x)	(((x) & 0x7) << 6)
858c2ecf20Sopenharmony_ci#define FTMAC100_DBLAC_RX_THR_EN	(1 << 9)
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci/*
888c2ecf20Sopenharmony_ci * MAC control register
898c2ecf20Sopenharmony_ci */
908c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_XDMA_EN		(1 << 0)
918c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_RDMA_EN		(1 << 1)
928c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_SW_RST		(1 << 2)
938c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_LOOP_EN		(1 << 3)
948c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_CRC_DIS		(1 << 4)
958c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_XMT_EN		(1 << 5)
968c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_ENRX_IN_HALFTX	(1 << 6)
978c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_RCV_EN		(1 << 8)
988c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_HT_MULTI_EN	(1 << 9)
998c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_RX_RUNT		(1 << 10)
1008c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_RX_FTL		(1 << 11)
1018c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_RCV_ALL		(1 << 12)
1028c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_CRC_APD		(1 << 14)
1038c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_FULLDUP		(1 << 15)
1048c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_RX_MULTIPKT	(1 << 16)
1058c2ecf20Sopenharmony_ci#define	FTMAC100_MACCR_RX_BROADPKT	(1 << 17)
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci/*
1088c2ecf20Sopenharmony_ci * PHY control register
1098c2ecf20Sopenharmony_ci */
1108c2ecf20Sopenharmony_ci#define FTMAC100_PHYCR_MIIRDATA		0xffff
1118c2ecf20Sopenharmony_ci#define FTMAC100_PHYCR_PHYAD(x)		(((x) & 0x1f) << 16)
1128c2ecf20Sopenharmony_ci#define FTMAC100_PHYCR_REGAD(x)		(((x) & 0x1f) << 21)
1138c2ecf20Sopenharmony_ci#define FTMAC100_PHYCR_MIIRD		(1 << 26)
1148c2ecf20Sopenharmony_ci#define FTMAC100_PHYCR_MIIWR		(1 << 27)
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci/*
1178c2ecf20Sopenharmony_ci * PHY write data register
1188c2ecf20Sopenharmony_ci */
1198c2ecf20Sopenharmony_ci#define FTMAC100_PHYWDATA_MIIWDATA(x)	((x) & 0xffff)
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci/*
1228c2ecf20Sopenharmony_ci * Transmit descriptor, aligned to 16 bytes
1238c2ecf20Sopenharmony_ci */
1248c2ecf20Sopenharmony_cistruct ftmac100_txdes {
1258c2ecf20Sopenharmony_ci	unsigned int	txdes0;
1268c2ecf20Sopenharmony_ci	unsigned int	txdes1;
1278c2ecf20Sopenharmony_ci	unsigned int	txdes2;	/* TXBUF_BADR */
1288c2ecf20Sopenharmony_ci	unsigned int	txdes3;	/* not used by HW */
1298c2ecf20Sopenharmony_ci} __attribute__ ((aligned(16)));
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#define	FTMAC100_TXDES0_TXPKT_LATECOL	(1 << 0)
1328c2ecf20Sopenharmony_ci#define	FTMAC100_TXDES0_TXPKT_EXSCOL	(1 << 1)
1338c2ecf20Sopenharmony_ci#define	FTMAC100_TXDES0_TXDMA_OWN	(1 << 31)
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define	FTMAC100_TXDES1_TXBUF_SIZE(x)	((x) & 0x7ff)
1368c2ecf20Sopenharmony_ci#define	FTMAC100_TXDES1_LTS		(1 << 27)
1378c2ecf20Sopenharmony_ci#define	FTMAC100_TXDES1_FTS		(1 << 28)
1388c2ecf20Sopenharmony_ci#define	FTMAC100_TXDES1_TX2FIC		(1 << 29)
1398c2ecf20Sopenharmony_ci#define	FTMAC100_TXDES1_TXIC		(1 << 30)
1408c2ecf20Sopenharmony_ci#define	FTMAC100_TXDES1_EDOTR		(1 << 31)
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci/*
1438c2ecf20Sopenharmony_ci * Receive descriptor, aligned to 16 bytes
1448c2ecf20Sopenharmony_ci */
1458c2ecf20Sopenharmony_cistruct ftmac100_rxdes {
1468c2ecf20Sopenharmony_ci	unsigned int	rxdes0;
1478c2ecf20Sopenharmony_ci	unsigned int	rxdes1;
1488c2ecf20Sopenharmony_ci	unsigned int	rxdes2;	/* RXBUF_BADR */
1498c2ecf20Sopenharmony_ci	unsigned int	rxdes3;	/* not used by HW */
1508c2ecf20Sopenharmony_ci} __attribute__ ((aligned(16)));
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_RFL		0x7ff
1538c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_MULTICAST	(1 << 16)
1548c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_BROADCAST	(1 << 17)
1558c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_RX_ERR		(1 << 18)
1568c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_CRC_ERR		(1 << 19)
1578c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_FTL		(1 << 20)
1588c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_RUNT		(1 << 21)
1598c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_RX_ODD_NB	(1 << 22)
1608c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_LRS		(1 << 28)
1618c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_FRS		(1 << 29)
1628c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES0_RXDMA_OWN	(1 << 31)
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES1_RXBUF_SIZE(x)	((x) & 0x7ff)
1658c2ecf20Sopenharmony_ci#define	FTMAC100_RXDES1_EDORR		(1 << 31)
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ci#endif /* __FTMAC100_H */
168