162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* drivers/atm/midway.h - Efficient Networks Midway (SAR) description */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci/* Written 1995-1999 by Werner Almesberger, EPFL LRC/ICA */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#ifndef DRIVERS_ATM_MIDWAY_H 862306a36Sopenharmony_ci#define DRIVERS_ATM_MIDWAY_H 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#define NR_VCI 1024 /* number of VCIs */ 1262306a36Sopenharmony_ci#define NR_VCI_LD 10 /* log2(NR_VCI) */ 1362306a36Sopenharmony_ci#define NR_DMA_RX 512 /* RX DMA queue entries */ 1462306a36Sopenharmony_ci#define NR_DMA_TX 512 /* TX DMA queue entries */ 1562306a36Sopenharmony_ci#define NR_SERVICE NR_VCI /* service list size */ 1662306a36Sopenharmony_ci#define NR_CHAN 8 /* number of TX channels */ 1762306a36Sopenharmony_ci#define TS_CLOCK 25000000 /* traffic shaper clock (cell/sec) */ 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define MAP_MAX_SIZE 0x00400000 /* memory window for max config */ 2062306a36Sopenharmony_ci#define EPROM_SIZE 0x00010000 2162306a36Sopenharmony_ci#define MEM_VALID 0xffc00000 /* mask base address with this */ 2262306a36Sopenharmony_ci#define PHY_BASE 0x00020000 /* offset of PHY register are */ 2362306a36Sopenharmony_ci#define REG_BASE 0x00040000 /* offset of Midway register area */ 2462306a36Sopenharmony_ci#define RAM_BASE 0x00200000 /* offset of RAM area */ 2562306a36Sopenharmony_ci#define RAM_INCREMENT 0x00020000 /* probe for RAM every 128kB */ 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define MID_VCI_BASE RAM_BASE 2862306a36Sopenharmony_ci#define MID_DMA_RX_BASE (MID_VCI_BASE+NR_VCI*16) 2962306a36Sopenharmony_ci#define MID_DMA_TX_BASE (MID_DMA_RX_BASE+NR_DMA_RX*8) 3062306a36Sopenharmony_ci#define MID_SERVICE_BASE (MID_DMA_TX_BASE+NR_DMA_TX*8) 3162306a36Sopenharmony_ci#define MID_FREE_BASE (MID_SERVICE_BASE+NR_SERVICE*4) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#define MAC_LEN 6 /* atm.h */ 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#define MID_MIN_BUF_SIZE (1024) /* 1 kB is minimum */ 3662306a36Sopenharmony_ci#define MID_MAX_BUF_SIZE (128*1024) /* 128 kB is maximum */ 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#define RX_DESCR_SIZE 1 /* RX PDU descr is 1 longword */ 3962306a36Sopenharmony_ci#define TX_DESCR_SIZE 2 /* TX PDU descr is 2 longwords */ 4062306a36Sopenharmony_ci#define AAL5_TRAILER (ATM_AAL5_TRAILER/4) /* AAL5 trailer is 2 longwords */ 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define TX_GAP 8 /* TX buffer gap (words) */ 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci/* 4562306a36Sopenharmony_ci * Midway Reset/ID 4662306a36Sopenharmony_ci * 4762306a36Sopenharmony_ci * All values read-only. Writing to this register resets Midway chip. 4862306a36Sopenharmony_ci */ 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci#define MID_RES_ID_MCON 0x00 /* Midway Reset/ID */ 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define MID_ID 0xf0000000 /* Midway version */ 5362306a36Sopenharmony_ci#define MID_SHIFT 24 5462306a36Sopenharmony_ci#define MID_MOTHER_ID 0x00000700 /* mother board id */ 5562306a36Sopenharmony_ci#define MID_MOTHER_SHIFT 8 5662306a36Sopenharmony_ci#define MID_CON_TI 0x00000080 /* 0: normal ctrl; 1: SABRE */ 5762306a36Sopenharmony_ci#define MID_CON_SUNI 0x00000040 /* 0: UTOPIA; 1: SUNI */ 5862306a36Sopenharmony_ci#define MID_CON_V6 0x00000020 /* 0: non-pipel UTOPIA (required iff 5962306a36Sopenharmony_ci !CON_SUNI; 1: UTOPIA */ 6062306a36Sopenharmony_ci#define DAUGHTER_ID 0x0000001f /* daughter board id */ 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* 6362306a36Sopenharmony_ci * Interrupt Status Acknowledge, Interrupt Status & Interrupt Enable 6462306a36Sopenharmony_ci */ 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#define MID_ISA 0x01 /* Interrupt Status Acknowledge */ 6762306a36Sopenharmony_ci#define MID_IS 0x02 /* Interrupt Status */ 6862306a36Sopenharmony_ci#define MID_IE 0x03 /* Interrupt Enable */ 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#define MID_TX_COMPLETE_7 0x00010000 /* channel N completed a PDU */ 7162306a36Sopenharmony_ci#define MID_TX_COMPLETE_6 0x00008000 /* transmission */ 7262306a36Sopenharmony_ci#define MID_TX_COMPLETE_5 0x00004000 7362306a36Sopenharmony_ci#define MID_TX_COMPLETE_4 0x00002000 7462306a36Sopenharmony_ci#define MID_TX_COMPLETE_3 0x00001000 7562306a36Sopenharmony_ci#define MID_TX_COMPLETE_2 0x00000800 7662306a36Sopenharmony_ci#define MID_TX_COMPLETE_1 0x00000400 7762306a36Sopenharmony_ci#define MID_TX_COMPLETE_0 0x00000200 7862306a36Sopenharmony_ci#define MID_TX_COMPLETE 0x0001fe00 /* any TX */ 7962306a36Sopenharmony_ci#define MID_TX_DMA_OVFL 0x00000100 /* DMA to adapter overflow */ 8062306a36Sopenharmony_ci#define MID_TX_IDENT_MISM 0x00000080 /* TX: ident mismatch => halted */ 8162306a36Sopenharmony_ci#define MID_DMA_LERR_ACK 0x00000040 /* LERR - SBus ? */ 8262306a36Sopenharmony_ci#define MID_DMA_ERR_ACK 0x00000020 /* DMA error */ 8362306a36Sopenharmony_ci#define MID_RX_DMA_COMPLETE 0x00000010 /* DMA to host done */ 8462306a36Sopenharmony_ci#define MID_TX_DMA_COMPLETE 0x00000008 /* DMA from host done */ 8562306a36Sopenharmony_ci#define MID_SERVICE 0x00000004 /* something in service list */ 8662306a36Sopenharmony_ci#define MID_SUNI_INT 0x00000002 /* interrupt from SUNI */ 8762306a36Sopenharmony_ci#define MID_STAT_OVFL 0x00000001 /* statistics overflow */ 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci/* 9062306a36Sopenharmony_ci * Master Control/Status 9162306a36Sopenharmony_ci */ 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define MID_MC_S 0x04 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#define MID_INT_SELECT 0x000001C0 /* Interrupt level (000: off) */ 9662306a36Sopenharmony_ci#define MID_INT_SEL_SHIFT 6 9762306a36Sopenharmony_ci#define MID_TX_LOCK_MODE 0x00000020 /* 0: streaming; 1: TX ovfl->lock */ 9862306a36Sopenharmony_ci#define MID_DMA_ENABLE 0x00000010 /* R: 0: disable; 1: enable 9962306a36Sopenharmony_ci W: 0: no change; 1: enable */ 10062306a36Sopenharmony_ci#define MID_TX_ENABLE 0x00000008 /* R: 0: TX disabled; 1: enabled 10162306a36Sopenharmony_ci W: 0: no change; 1: enable */ 10262306a36Sopenharmony_ci#define MID_RX_ENABLE 0x00000004 /* like TX */ 10362306a36Sopenharmony_ci#define MID_WAIT_1MS 0x00000002 /* R: 0: timer not running; 1: running 10462306a36Sopenharmony_ci W: 0: no change; 1: no interrupts 10562306a36Sopenharmony_ci for 1 ms */ 10662306a36Sopenharmony_ci#define MID_WAIT_500US 0x00000001 /* like WAIT_1MS, but 0.5 ms */ 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ci/* 10962306a36Sopenharmony_ci * Statistics 11062306a36Sopenharmony_ci * 11162306a36Sopenharmony_ci * Cleared when reading. 11262306a36Sopenharmony_ci */ 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci#define MID_STAT 0x05 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci#define MID_VCI_TRASH 0xFFFF0000 /* trashed cells because of VCI mode */ 11762306a36Sopenharmony_ci#define MID_VCI_TRASH_SHIFT 16 11862306a36Sopenharmony_ci#define MID_OVFL_TRASH 0x0000FFFF /* trashed cells because of overflow */ 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci/* 12162306a36Sopenharmony_ci * Address registers 12262306a36Sopenharmony_ci */ 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci#define MID_SERV_WRITE 0x06 /* free pos in service area (R, 10 bits) */ 12562306a36Sopenharmony_ci#define MID_DMA_ADDR 0x07 /* virtual DMA address (R, 32 bits) */ 12662306a36Sopenharmony_ci#define MID_DMA_WR_RX 0x08 /* (RW, 9 bits) */ 12762306a36Sopenharmony_ci#define MID_DMA_RD_RX 0x09 12862306a36Sopenharmony_ci#define MID_DMA_WR_TX 0x0A 12962306a36Sopenharmony_ci#define MID_DMA_RD_TX 0x0B 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci/* 13262306a36Sopenharmony_ci * Transmit Place Registers (0x10+4*channel) 13362306a36Sopenharmony_ci */ 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci#define MID_TX_PLACE(c) (0x10+4*(c)) 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci#define MID_SIZE 0x00003800 /* size, N*256 x 32 bit */ 13862306a36Sopenharmony_ci#define MID_SIZE_SHIFT 11 13962306a36Sopenharmony_ci#define MID_LOCATION 0x000007FF /* location in adapter memory (word) */ 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci#define MID_LOC_SKIP 8 /* 8 bits of location are always zero 14262306a36Sopenharmony_ci (applies to all uses of location) */ 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci/* 14562306a36Sopenharmony_ci * Transmit ReadPtr Registers (0x11+4*channel) 14662306a36Sopenharmony_ci */ 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci#define MID_TX_RDPTR(c) (0x11+4*(c)) 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci#define MID_READ_PTR 0x00007FFF /* next word for PHY */ 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci/* 15362306a36Sopenharmony_ci * Transmit DescrStart Registers (0x12+4*channel) 15462306a36Sopenharmony_ci */ 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ci#define MID_TX_DESCRSTART(c) (0x12+4*(c)) 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci#define MID_DESCR_START 0x00007FFF /* seg buffer being DMAed */ 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci#define ENI155_MAGIC 0xa54b872d 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_cistruct midway_eprom { 16362306a36Sopenharmony_ci unsigned char mac[MAC_LEN],inv_mac[MAC_LEN]; 16462306a36Sopenharmony_ci unsigned char pad[36]; 16562306a36Sopenharmony_ci u32 serial,inv_serial; 16662306a36Sopenharmony_ci u32 magic,inv_magic; 16762306a36Sopenharmony_ci}; 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci/* 17162306a36Sopenharmony_ci * VCI table entry 17262306a36Sopenharmony_ci */ 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ci#define MID_VCI_IN_SERVICE 0x00000001 /* set if VCI is currently in 17562306a36Sopenharmony_ci service list */ 17662306a36Sopenharmony_ci#define MID_VCI_SIZE 0x00038000 /* reassembly buffer size, 17762306a36Sopenharmony_ci 2*<size> kB */ 17862306a36Sopenharmony_ci#define MID_VCI_SIZE_SHIFT 15 17962306a36Sopenharmony_ci#define MID_VCI_LOCATION 0x1ffc0000 /* buffer location */ 18062306a36Sopenharmony_ci#define MID_VCI_LOCATION_SHIFT 18 18162306a36Sopenharmony_ci#define MID_VCI_PTI_MODE 0x20000000 /* 0: trash, 1: preserve */ 18262306a36Sopenharmony_ci#define MID_VCI_MODE 0xc0000000 18362306a36Sopenharmony_ci#define MID_VCI_MODE_SHIFT 30 18462306a36Sopenharmony_ci#define MID_VCI_READ 0x00007fff 18562306a36Sopenharmony_ci#define MID_VCI_READ_SHIFT 0 18662306a36Sopenharmony_ci#define MID_VCI_DESCR 0x7fff0000 18762306a36Sopenharmony_ci#define MID_VCI_DESCR_SHIFT 16 18862306a36Sopenharmony_ci#define MID_VCI_COUNT 0x000007ff 18962306a36Sopenharmony_ci#define MID_VCI_COUNT_SHIFT 0 19062306a36Sopenharmony_ci#define MID_VCI_STATE 0x0000c000 19162306a36Sopenharmony_ci#define MID_VCI_STATE_SHIFT 14 19262306a36Sopenharmony_ci#define MID_VCI_WRITE 0x7fff0000 19362306a36Sopenharmony_ci#define MID_VCI_WRITE_SHIFT 16 19462306a36Sopenharmony_ci 19562306a36Sopenharmony_ci#define MID_MODE_TRASH 0 19662306a36Sopenharmony_ci#define MID_MODE_RAW 1 19762306a36Sopenharmony_ci#define MID_MODE_AAL5 2 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci/* 20062306a36Sopenharmony_ci * Reassembly buffer descriptor 20162306a36Sopenharmony_ci */ 20262306a36Sopenharmony_ci 20362306a36Sopenharmony_ci#define MID_RED_COUNT 0x000007ff 20462306a36Sopenharmony_ci#define MID_RED_CRC_ERR 0x00000800 20562306a36Sopenharmony_ci#define MID_RED_T 0x00001000 20662306a36Sopenharmony_ci#define MID_RED_CE 0x00010000 20762306a36Sopenharmony_ci#define MID_RED_CLP 0x01000000 20862306a36Sopenharmony_ci#define MID_RED_IDEN 0xfe000000 20962306a36Sopenharmony_ci#define MID_RED_SHIFT 25 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci#define MID_RED_RX_ID 0x1b /* constant identifier */ 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci/* 21462306a36Sopenharmony_ci * Segmentation buffer descriptor 21562306a36Sopenharmony_ci */ 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci#define MID_SEG_COUNT MID_RED_COUNT 21862306a36Sopenharmony_ci#define MID_SEG_RATE 0x01f80000 21962306a36Sopenharmony_ci#define MID_SEG_RATE_SHIFT 19 22062306a36Sopenharmony_ci#define MID_SEG_PR 0x06000000 22162306a36Sopenharmony_ci#define MID_SEG_PR_SHIFT 25 22262306a36Sopenharmony_ci#define MID_SEG_AAL5 0x08000000 22362306a36Sopenharmony_ci#define MID_SEG_ID 0xf0000000 22462306a36Sopenharmony_ci#define MID_SEG_ID_SHIFT 28 22562306a36Sopenharmony_ci#define MID_SEG_MAX_RATE 63 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_ci#define MID_SEG_CLP 0x00000001 22862306a36Sopenharmony_ci#define MID_SEG_PTI 0x0000000e 22962306a36Sopenharmony_ci#define MID_SEG_PTI_SHIFT 1 23062306a36Sopenharmony_ci#define MID_SEG_VCI 0x00003ff0 23162306a36Sopenharmony_ci#define MID_SEG_VCI_SHIFT 4 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci#define MID_SEG_TX_ID 0xb /* constant identifier */ 23462306a36Sopenharmony_ci 23562306a36Sopenharmony_ci/* 23662306a36Sopenharmony_ci * DMA entry 23762306a36Sopenharmony_ci */ 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ci#define MID_DMA_COUNT 0xffff0000 24062306a36Sopenharmony_ci#define MID_DMA_COUNT_SHIFT 16 24162306a36Sopenharmony_ci#define MID_DMA_END 0x00000020 24262306a36Sopenharmony_ci#define MID_DMA_TYPE 0x0000000f 24362306a36Sopenharmony_ci 24462306a36Sopenharmony_ci#define MID_DT_JK 0x3 24562306a36Sopenharmony_ci#define MID_DT_WORD 0x0 24662306a36Sopenharmony_ci#define MID_DT_2W 0x7 24762306a36Sopenharmony_ci#define MID_DT_4W 0x4 24862306a36Sopenharmony_ci#define MID_DT_8W 0x5 24962306a36Sopenharmony_ci#define MID_DT_16W 0x6 25062306a36Sopenharmony_ci#define MID_DT_2WM 0xf 25162306a36Sopenharmony_ci#define MID_DT_4WM 0xc 25262306a36Sopenharmony_ci#define MID_DT_8WM 0xd 25362306a36Sopenharmony_ci#define MID_DT_16WM 0xe 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci/* only for RX*/ 25662306a36Sopenharmony_ci#define MID_DMA_VCI 0x0000ffc0 25762306a36Sopenharmony_ci#define MID_DMA_VCI_SHIFT 6 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci/* only for TX */ 26062306a36Sopenharmony_ci#define MID_DMA_CHAN 0x000001c0 26162306a36Sopenharmony_ci#define MID_DMA_CHAN_SHIFT 6 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci#define MID_DT_BYTE 0x1 26462306a36Sopenharmony_ci#define MID_DT_HWORD 0x2 26562306a36Sopenharmony_ci 26662306a36Sopenharmony_ci#endif 267