18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* drivers/atm/midway.h - Efficient Networks Midway (SAR) description */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci/* Written 1995-1999 by Werner Almesberger, EPFL LRC/ICA */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef DRIVERS_ATM_MIDWAY_H
88c2ecf20Sopenharmony_ci#define DRIVERS_ATM_MIDWAY_H
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define NR_VCI		1024		/* number of VCIs */
128c2ecf20Sopenharmony_ci#define NR_VCI_LD	10		/* log2(NR_VCI) */
138c2ecf20Sopenharmony_ci#define NR_DMA_RX	512		/* RX DMA queue entries */
148c2ecf20Sopenharmony_ci#define NR_DMA_TX	512		/* TX DMA queue entries */
158c2ecf20Sopenharmony_ci#define NR_SERVICE	NR_VCI		/* service list size */
168c2ecf20Sopenharmony_ci#define NR_CHAN		8		/* number of TX channels */
178c2ecf20Sopenharmony_ci#define TS_CLOCK	25000000	/* traffic shaper clock (cell/sec) */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define MAP_MAX_SIZE	0x00400000	/* memory window for max config */
208c2ecf20Sopenharmony_ci#define EPROM_SIZE	0x00010000
218c2ecf20Sopenharmony_ci#define	MEM_VALID	0xffc00000	/* mask base address with this */
228c2ecf20Sopenharmony_ci#define PHY_BASE	0x00020000	/* offset of PHY register are */
238c2ecf20Sopenharmony_ci#define REG_BASE	0x00040000	/* offset of Midway register area */
248c2ecf20Sopenharmony_ci#define RAM_BASE	0x00200000	/* offset of RAM area */
258c2ecf20Sopenharmony_ci#define RAM_INCREMENT	0x00020000	/* probe for RAM every 128kB */
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define MID_VCI_BASE	RAM_BASE
288c2ecf20Sopenharmony_ci#define MID_DMA_RX_BASE	(MID_VCI_BASE+NR_VCI*16)
298c2ecf20Sopenharmony_ci#define MID_DMA_TX_BASE	(MID_DMA_RX_BASE+NR_DMA_RX*8)
308c2ecf20Sopenharmony_ci#define MID_SERVICE_BASE (MID_DMA_TX_BASE+NR_DMA_TX*8)
318c2ecf20Sopenharmony_ci#define MID_FREE_BASE	(MID_SERVICE_BASE+NR_SERVICE*4)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define MAC_LEN 6 /* atm.h */
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci#define MID_MIN_BUF_SIZE (1024)		/*   1 kB is minimum */
368c2ecf20Sopenharmony_ci#define MID_MAX_BUF_SIZE (128*1024)	/* 128 kB is maximum */
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define RX_DESCR_SIZE	1		/* RX PDU descr is 1 longword */
398c2ecf20Sopenharmony_ci#define TX_DESCR_SIZE	2		/* TX PDU descr is 2 longwords */
408c2ecf20Sopenharmony_ci#define AAL5_TRAILER	(ATM_AAL5_TRAILER/4) /* AAL5 trailer is 2 longwords */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci#define TX_GAP		8		/* TX buffer gap (words) */
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci/*
458c2ecf20Sopenharmony_ci * Midway Reset/ID
468c2ecf20Sopenharmony_ci *
478c2ecf20Sopenharmony_ci * All values read-only. Writing to this register resets Midway chip.
488c2ecf20Sopenharmony_ci */
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci#define MID_RES_ID_MCON	0x00		/* Midway Reset/ID */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#define MID_ID		0xf0000000	/* Midway version */
538c2ecf20Sopenharmony_ci#define MID_SHIFT	24
548c2ecf20Sopenharmony_ci#define MID_MOTHER_ID	0x00000700	/* mother board id */
558c2ecf20Sopenharmony_ci#define MID_MOTHER_SHIFT 8
568c2ecf20Sopenharmony_ci#define MID_CON_TI	0x00000080	/* 0: normal ctrl; 1: SABRE */
578c2ecf20Sopenharmony_ci#define MID_CON_SUNI	0x00000040	/* 0: UTOPIA; 1: SUNI */
588c2ecf20Sopenharmony_ci#define MID_CON_V6	0x00000020	/* 0: non-pipel UTOPIA (required iff
598c2ecf20Sopenharmony_ci					   !CON_SUNI; 1: UTOPIA */
608c2ecf20Sopenharmony_ci#define DAUGHTER_ID	0x0000001f	/* daughter board id */
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/*
638c2ecf20Sopenharmony_ci * Interrupt Status Acknowledge, Interrupt Status & Interrupt Enable
648c2ecf20Sopenharmony_ci */
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci#define MID_ISA		0x01		/* Interrupt Status Acknowledge */
678c2ecf20Sopenharmony_ci#define MID_IS		0x02		/* Interrupt Status */
688c2ecf20Sopenharmony_ci#define MID_IE		0x03		/* Interrupt Enable */
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define MID_TX_COMPLETE_7 0x00010000	/* channel N completed a PDU */
718c2ecf20Sopenharmony_ci#define MID_TX_COMPLETE_6 0x00008000	/* transmission */
728c2ecf20Sopenharmony_ci#define MID_TX_COMPLETE_5 0x00004000
738c2ecf20Sopenharmony_ci#define MID_TX_COMPLETE_4 0x00002000
748c2ecf20Sopenharmony_ci#define MID_TX_COMPLETE_3 0x00001000
758c2ecf20Sopenharmony_ci#define MID_TX_COMPLETE_2 0x00000800
768c2ecf20Sopenharmony_ci#define MID_TX_COMPLETE_1 0x00000400
778c2ecf20Sopenharmony_ci#define MID_TX_COMPLETE_0 0x00000200
788c2ecf20Sopenharmony_ci#define MID_TX_COMPLETE	0x0001fe00	/* any TX */
798c2ecf20Sopenharmony_ci#define MID_TX_DMA_OVFL	0x00000100	/* DMA to adapter overflow */
808c2ecf20Sopenharmony_ci#define MID_TX_IDENT_MISM 0x00000080	/* TX: ident mismatch => halted */
818c2ecf20Sopenharmony_ci#define MID_DMA_LERR_ACK 0x00000040	/* LERR - SBus ? */
828c2ecf20Sopenharmony_ci#define MID_DMA_ERR_ACK	0x00000020	/* DMA error */
838c2ecf20Sopenharmony_ci#define	MID_RX_DMA_COMPLETE 0x00000010	/* DMA to host done */
848c2ecf20Sopenharmony_ci#define MID_TX_DMA_COMPLETE 0x00000008	/* DMA from host done */
858c2ecf20Sopenharmony_ci#define MID_SERVICE	0x00000004	/* something in service list */
868c2ecf20Sopenharmony_ci#define MID_SUNI_INT	0x00000002	/* interrupt from SUNI */
878c2ecf20Sopenharmony_ci#define MID_STAT_OVFL	0x00000001	/* statistics overflow */
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/*
908c2ecf20Sopenharmony_ci * Master Control/Status
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci#define MID_MC_S	0x04
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define MID_INT_SELECT	0x000001C0	/* Interrupt level (000: off) */
968c2ecf20Sopenharmony_ci#define MID_INT_SEL_SHIFT 6
978c2ecf20Sopenharmony_ci#define	MID_TX_LOCK_MODE 0x00000020	/* 0: streaming; 1: TX ovfl->lock */
988c2ecf20Sopenharmony_ci#define MID_DMA_ENABLE	0x00000010	/* R: 0: disable; 1: enable
998c2ecf20Sopenharmony_ci					   W: 0: no change; 1: enable */
1008c2ecf20Sopenharmony_ci#define MID_TX_ENABLE	0x00000008	/* R: 0: TX disabled; 1: enabled
1018c2ecf20Sopenharmony_ci					   W: 0: no change; 1: enable */
1028c2ecf20Sopenharmony_ci#define MID_RX_ENABLE	0x00000004	/* like TX */
1038c2ecf20Sopenharmony_ci#define MID_WAIT_1MS	0x00000002	/* R: 0: timer not running; 1: running
1048c2ecf20Sopenharmony_ci					   W: 0: no change; 1: no interrupts
1058c2ecf20Sopenharmony_ci							       for 1 ms */
1068c2ecf20Sopenharmony_ci#define MID_WAIT_500US	0x00000001	/* like WAIT_1MS, but 0.5 ms */
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/*
1098c2ecf20Sopenharmony_ci * Statistics
1108c2ecf20Sopenharmony_ci *
1118c2ecf20Sopenharmony_ci * Cleared when reading.
1128c2ecf20Sopenharmony_ci */
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci#define MID_STAT		0x05
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#define MID_VCI_TRASH	0xFFFF0000	/* trashed cells because of VCI mode */
1178c2ecf20Sopenharmony_ci#define MID_VCI_TRASH_SHIFT 16
1188c2ecf20Sopenharmony_ci#define MID_OVFL_TRASH	0x0000FFFF	/* trashed cells because of overflow */
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci/*
1218c2ecf20Sopenharmony_ci * Address registers
1228c2ecf20Sopenharmony_ci */
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci#define MID_SERV_WRITE	0x06	/* free pos in service area (R, 10 bits) */
1258c2ecf20Sopenharmony_ci#define MID_DMA_ADDR	0x07	/* virtual DMA address (R, 32 bits) */
1268c2ecf20Sopenharmony_ci#define MID_DMA_WR_RX	0x08	/* (RW, 9 bits) */
1278c2ecf20Sopenharmony_ci#define MID_DMA_RD_RX	0x09
1288c2ecf20Sopenharmony_ci#define MID_DMA_WR_TX	0x0A
1298c2ecf20Sopenharmony_ci#define MID_DMA_RD_TX	0x0B
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/*
1328c2ecf20Sopenharmony_ci * Transmit Place Registers (0x10+4*channel)
1338c2ecf20Sopenharmony_ci */
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define MID_TX_PLACE(c)	(0x10+4*(c))
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci#define MID_SIZE	0x00003800	/* size, N*256 x 32 bit */
1388c2ecf20Sopenharmony_ci#define MID_SIZE_SHIFT	11
1398c2ecf20Sopenharmony_ci#define MID_LOCATION	0x000007FF	/* location in adapter memory (word) */
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci#define MID_LOC_SKIP	8		/* 8 bits of location are always zero
1428c2ecf20Sopenharmony_ci					   (applies to all uses of location) */
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci/*
1458c2ecf20Sopenharmony_ci * Transmit ReadPtr Registers (0x11+4*channel)
1468c2ecf20Sopenharmony_ci */
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci#define MID_TX_RDPTR(c)	(0x11+4*(c))
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci#define MID_READ_PTR	0x00007FFF	/* next word for PHY */
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci/*
1538c2ecf20Sopenharmony_ci * Transmit DescrStart Registers (0x12+4*channel)
1548c2ecf20Sopenharmony_ci */
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci#define MID_TX_DESCRSTART(c) (0x12+4*(c))
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci#define MID_DESCR_START	0x00007FFF	/* seg buffer being DMAed */
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci#define ENI155_MAGIC	0xa54b872d
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistruct midway_eprom {
1638c2ecf20Sopenharmony_ci	unsigned char mac[MAC_LEN],inv_mac[MAC_LEN];
1648c2ecf20Sopenharmony_ci	unsigned char pad[36];
1658c2ecf20Sopenharmony_ci	u32 serial,inv_serial;
1668c2ecf20Sopenharmony_ci	u32 magic,inv_magic;
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci/*
1718c2ecf20Sopenharmony_ci * VCI table entry
1728c2ecf20Sopenharmony_ci */
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci#define MID_VCI_IN_SERVICE	0x00000001	/* set if VCI is currently in
1758c2ecf20Sopenharmony_ci						   service list */
1768c2ecf20Sopenharmony_ci#define MID_VCI_SIZE		0x00038000	/* reassembly buffer size,
1778c2ecf20Sopenharmony_ci						   2*<size> kB */
1788c2ecf20Sopenharmony_ci#define MID_VCI_SIZE_SHIFT	15
1798c2ecf20Sopenharmony_ci#define MID_VCI_LOCATION	0x1ffc0000	/* buffer location */
1808c2ecf20Sopenharmony_ci#define MID_VCI_LOCATION_SHIFT	18
1818c2ecf20Sopenharmony_ci#define MID_VCI_PTI_MODE	0x20000000	/* 0: trash, 1: preserve */
1828c2ecf20Sopenharmony_ci#define MID_VCI_MODE		0xc0000000
1838c2ecf20Sopenharmony_ci#define MID_VCI_MODE_SHIFT	30
1848c2ecf20Sopenharmony_ci#define MID_VCI_READ		0x00007fff
1858c2ecf20Sopenharmony_ci#define MID_VCI_READ_SHIFT	0
1868c2ecf20Sopenharmony_ci#define MID_VCI_DESCR		0x7fff0000
1878c2ecf20Sopenharmony_ci#define MID_VCI_DESCR_SHIFT	16
1888c2ecf20Sopenharmony_ci#define MID_VCI_COUNT		0x000007ff
1898c2ecf20Sopenharmony_ci#define MID_VCI_COUNT_SHIFT	0
1908c2ecf20Sopenharmony_ci#define MID_VCI_STATE		0x0000c000
1918c2ecf20Sopenharmony_ci#define MID_VCI_STATE_SHIFT	14
1928c2ecf20Sopenharmony_ci#define MID_VCI_WRITE		0x7fff0000
1938c2ecf20Sopenharmony_ci#define MID_VCI_WRITE_SHIFT	16
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci#define MID_MODE_TRASH	0
1968c2ecf20Sopenharmony_ci#define MID_MODE_RAW	1
1978c2ecf20Sopenharmony_ci#define MID_MODE_AAL5	2
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci/*
2008c2ecf20Sopenharmony_ci * Reassembly buffer descriptor
2018c2ecf20Sopenharmony_ci */
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci#define MID_RED_COUNT		0x000007ff
2048c2ecf20Sopenharmony_ci#define MID_RED_CRC_ERR		0x00000800
2058c2ecf20Sopenharmony_ci#define MID_RED_T		0x00001000
2068c2ecf20Sopenharmony_ci#define MID_RED_CE		0x00010000
2078c2ecf20Sopenharmony_ci#define MID_RED_CLP		0x01000000
2088c2ecf20Sopenharmony_ci#define MID_RED_IDEN		0xfe000000
2098c2ecf20Sopenharmony_ci#define MID_RED_SHIFT		25
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci#define MID_RED_RX_ID		0x1b		/* constant identifier */
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci/*
2148c2ecf20Sopenharmony_ci * Segmentation buffer descriptor
2158c2ecf20Sopenharmony_ci */
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci#define MID_SEG_COUNT		MID_RED_COUNT
2188c2ecf20Sopenharmony_ci#define MID_SEG_RATE		0x01f80000
2198c2ecf20Sopenharmony_ci#define MID_SEG_RATE_SHIFT	19
2208c2ecf20Sopenharmony_ci#define MID_SEG_PR		0x06000000
2218c2ecf20Sopenharmony_ci#define MID_SEG_PR_SHIFT	25
2228c2ecf20Sopenharmony_ci#define MID_SEG_AAL5		0x08000000
2238c2ecf20Sopenharmony_ci#define MID_SEG_ID		0xf0000000
2248c2ecf20Sopenharmony_ci#define MID_SEG_ID_SHIFT	28
2258c2ecf20Sopenharmony_ci#define MID_SEG_MAX_RATE	63
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci#define MID_SEG_CLP		0x00000001
2288c2ecf20Sopenharmony_ci#define MID_SEG_PTI		0x0000000e
2298c2ecf20Sopenharmony_ci#define MID_SEG_PTI_SHIFT	1
2308c2ecf20Sopenharmony_ci#define MID_SEG_VCI		0x00003ff0
2318c2ecf20Sopenharmony_ci#define MID_SEG_VCI_SHIFT	4
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#define MID_SEG_TX_ID		0xb		/* constant identifier */
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_ci/*
2368c2ecf20Sopenharmony_ci * DMA entry
2378c2ecf20Sopenharmony_ci */
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci#define MID_DMA_COUNT		0xffff0000
2408c2ecf20Sopenharmony_ci#define MID_DMA_COUNT_SHIFT	16
2418c2ecf20Sopenharmony_ci#define MID_DMA_END		0x00000020
2428c2ecf20Sopenharmony_ci#define MID_DMA_TYPE		0x0000000f
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci#define MID_DT_JK	0x3
2458c2ecf20Sopenharmony_ci#define MID_DT_WORD	0x0
2468c2ecf20Sopenharmony_ci#define MID_DT_2W	0x7
2478c2ecf20Sopenharmony_ci#define MID_DT_4W	0x4
2488c2ecf20Sopenharmony_ci#define MID_DT_8W	0x5
2498c2ecf20Sopenharmony_ci#define MID_DT_16W	0x6
2508c2ecf20Sopenharmony_ci#define MID_DT_2WM	0xf
2518c2ecf20Sopenharmony_ci#define MID_DT_4WM	0xc
2528c2ecf20Sopenharmony_ci#define MID_DT_8WM	0xd
2538c2ecf20Sopenharmony_ci#define MID_DT_16WM	0xe
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci/* only for RX*/
2568c2ecf20Sopenharmony_ci#define MID_DMA_VCI		0x0000ffc0
2578c2ecf20Sopenharmony_ci#define	MID_DMA_VCI_SHIFT	6
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci/* only for TX */
2608c2ecf20Sopenharmony_ci#define MID_DMA_CHAN		0x000001c0
2618c2ecf20Sopenharmony_ci#define MID_DMA_CHAN_SHIFT	6
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci#define MID_DT_BYTE	0x1
2648c2ecf20Sopenharmony_ci#define MID_DT_HWORD	0x2
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci#endif
267