162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Stuff for AMCC S5933 PCI Controller
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Author: Michal Dobes <dobes@tesnet.cz>
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Inspirated from general-purpose AMCC S5933 PCI Matchmaker driver
862306a36Sopenharmony_ci * made by Andrea Cisternino  <acister@pcape1.pi.infn.it>
962306a36Sopenharmony_ci * and as result of espionage from MITE code made by David A. Schleef.
1062306a36Sopenharmony_ci * Thanks to AMCC for their on-line documentation and bus master DMA
1162306a36Sopenharmony_ci * example.
1262306a36Sopenharmony_ci */
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#ifndef _AMCC_S5933_H_
1562306a36Sopenharmony_ci#define _AMCC_S5933_H_
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/****************************************************************************/
1862306a36Sopenharmony_ci/* AMCC Operation Register Offsets - PCI                                    */
1962306a36Sopenharmony_ci/****************************************************************************/
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define AMCC_OP_REG_OMB1         0x00
2262306a36Sopenharmony_ci#define AMCC_OP_REG_OMB2         0x04
2362306a36Sopenharmony_ci#define AMCC_OP_REG_OMB3         0x08
2462306a36Sopenharmony_ci#define AMCC_OP_REG_OMB4         0x0c
2562306a36Sopenharmony_ci#define AMCC_OP_REG_IMB1         0x10
2662306a36Sopenharmony_ci#define AMCC_OP_REG_IMB2         0x14
2762306a36Sopenharmony_ci#define AMCC_OP_REG_IMB3         0x18
2862306a36Sopenharmony_ci#define AMCC_OP_REG_IMB4         0x1c
2962306a36Sopenharmony_ci#define AMCC_OP_REG_FIFO         0x20
3062306a36Sopenharmony_ci#define AMCC_OP_REG_MWAR         0x24
3162306a36Sopenharmony_ci#define AMCC_OP_REG_MWTC         0x28
3262306a36Sopenharmony_ci#define AMCC_OP_REG_MRAR         0x2c
3362306a36Sopenharmony_ci#define AMCC_OP_REG_MRTC         0x30
3462306a36Sopenharmony_ci#define AMCC_OP_REG_MBEF         0x34
3562306a36Sopenharmony_ci#define AMCC_OP_REG_INTCSR       0x38
3662306a36Sopenharmony_ci#define  AMCC_OP_REG_INTCSR_SRC  (AMCC_OP_REG_INTCSR + 2)	/* INT source */
3762306a36Sopenharmony_ci#define  AMCC_OP_REG_INTCSR_FEC  (AMCC_OP_REG_INTCSR + 3)	/* FIFO ctrl */
3862306a36Sopenharmony_ci#define AMCC_OP_REG_MCSR         0x3c
3962306a36Sopenharmony_ci#define  AMCC_OP_REG_MCSR_NVDATA (AMCC_OP_REG_MCSR + 2)	/* Data in byte 2 */
4062306a36Sopenharmony_ci#define  AMCC_OP_REG_MCSR_NVCMD  (AMCC_OP_REG_MCSR + 3)	/* Command in byte 3 */
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define AMCC_FIFO_DEPTH_DWORD	8
4362306a36Sopenharmony_ci#define AMCC_FIFO_DEPTH_BYTES	(8 * sizeof(u32))
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/****************************************************************************/
4662306a36Sopenharmony_ci/* AMCC - PCI Interrupt Control/Status Register                            */
4762306a36Sopenharmony_ci/****************************************************************************/
4862306a36Sopenharmony_ci#define INTCSR_OUTBOX_BYTE(x)	((x) & 0x3)
4962306a36Sopenharmony_ci#define INTCSR_OUTBOX_SELECT(x)	(((x) & 0x3) << 2)
5062306a36Sopenharmony_ci#define INTCSR_OUTBOX_EMPTY_INT	0x10	/*  enable outbox empty interrupt */
5162306a36Sopenharmony_ci#define INTCSR_INBOX_BYTE(x)	(((x) & 0x3) << 8)
5262306a36Sopenharmony_ci#define INTCSR_INBOX_SELECT(x)	(((x) & 0x3) << 10)
5362306a36Sopenharmony_ci#define INTCSR_INBOX_FULL_INT	0x1000	/*  enable inbox full interrupt */
5462306a36Sopenharmony_ci/* read, or write clear inbox full interrupt */
5562306a36Sopenharmony_ci#define INTCSR_INBOX_INTR_STATUS	0x20000
5662306a36Sopenharmony_ci/* read only, interrupt asserted */
5762306a36Sopenharmony_ci#define INTCSR_INTR_ASSERTED	0x800000
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci/****************************************************************************/
6062306a36Sopenharmony_ci/* AMCC - PCI non-volatile ram command register (byte 3 of AMCC_OP_REG_MCSR) */
6162306a36Sopenharmony_ci/****************************************************************************/
6262306a36Sopenharmony_ci#define MCSR_NV_LOAD_LOW_ADDR	0x0
6362306a36Sopenharmony_ci#define MCSR_NV_LOAD_HIGH_ADDR	0x20
6462306a36Sopenharmony_ci#define MCSR_NV_WRITE	0x40
6562306a36Sopenharmony_ci#define MCSR_NV_READ	0x60
6662306a36Sopenharmony_ci#define MCSR_NV_MASK	0x60
6762306a36Sopenharmony_ci#define MCSR_NV_ENABLE	0x80
6862306a36Sopenharmony_ci#define MCSR_NV_BUSY	MCSR_NV_ENABLE
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/****************************************************************************/
7162306a36Sopenharmony_ci/* AMCC Operation Registers Size - PCI                                      */
7262306a36Sopenharmony_ci/****************************************************************************/
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define AMCC_OP_REG_SIZE	 64	/* in bytes */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/****************************************************************************/
7762306a36Sopenharmony_ci/* AMCC Operation Register Offsets - Add-on                                 */
7862306a36Sopenharmony_ci/****************************************************************************/
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci#define AMCC_OP_REG_AIMB1         0x00
8162306a36Sopenharmony_ci#define AMCC_OP_REG_AIMB2         0x04
8262306a36Sopenharmony_ci#define AMCC_OP_REG_AIMB3         0x08
8362306a36Sopenharmony_ci#define AMCC_OP_REG_AIMB4         0x0c
8462306a36Sopenharmony_ci#define AMCC_OP_REG_AOMB1         0x10
8562306a36Sopenharmony_ci#define AMCC_OP_REG_AOMB2         0x14
8662306a36Sopenharmony_ci#define AMCC_OP_REG_AOMB3         0x18
8762306a36Sopenharmony_ci#define AMCC_OP_REG_AOMB4         0x1c
8862306a36Sopenharmony_ci#define AMCC_OP_REG_AFIFO         0x20
8962306a36Sopenharmony_ci#define AMCC_OP_REG_AMWAR         0x24
9062306a36Sopenharmony_ci#define AMCC_OP_REG_APTA          0x28
9162306a36Sopenharmony_ci#define AMCC_OP_REG_APTD          0x2c
9262306a36Sopenharmony_ci#define AMCC_OP_REG_AMRAR         0x30
9362306a36Sopenharmony_ci#define AMCC_OP_REG_AMBEF         0x34
9462306a36Sopenharmony_ci#define AMCC_OP_REG_AINT          0x38
9562306a36Sopenharmony_ci#define AMCC_OP_REG_AGCSTS        0x3c
9662306a36Sopenharmony_ci#define AMCC_OP_REG_AMWTC         0x58
9762306a36Sopenharmony_ci#define AMCC_OP_REG_AMRTC         0x5c
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci/****************************************************************************/
10062306a36Sopenharmony_ci/* AMCC - Add-on General Control/Status Register                            */
10162306a36Sopenharmony_ci/****************************************************************************/
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci#define AGCSTS_CONTROL_MASK	0xfffff000
10462306a36Sopenharmony_ci#define  AGCSTS_NV_ACC_MASK	0xe0000000
10562306a36Sopenharmony_ci#define  AGCSTS_RESET_MASK	0x0e000000
10662306a36Sopenharmony_ci#define  AGCSTS_NV_DA_MASK	0x00ff0000
10762306a36Sopenharmony_ci#define  AGCSTS_BIST_MASK	0x0000f000
10862306a36Sopenharmony_ci#define AGCSTS_STATUS_MASK	0x000000ff
10962306a36Sopenharmony_ci#define  AGCSTS_TCZERO_MASK	0x000000c0
11062306a36Sopenharmony_ci#define  AGCSTS_FIFO_ST_MASK	0x0000003f
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci#define AGCSTS_TC_ENABLE	0x10000000
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#define AGCSTS_RESET_MBFLAGS	0x08000000
11562306a36Sopenharmony_ci#define AGCSTS_RESET_P2A_FIFO	0x04000000
11662306a36Sopenharmony_ci#define AGCSTS_RESET_A2P_FIFO	0x02000000
11762306a36Sopenharmony_ci#define AGCSTS_RESET_FIFOS	(AGCSTS_RESET_A2P_FIFO | AGCSTS_RESET_P2A_FIFO)
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci#define AGCSTS_A2P_TCOUNT	0x00000080
12062306a36Sopenharmony_ci#define AGCSTS_P2A_TCOUNT	0x00000040
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci#define AGCSTS_FS_P2A_EMPTY	0x00000020
12362306a36Sopenharmony_ci#define AGCSTS_FS_P2A_HALF	0x00000010
12462306a36Sopenharmony_ci#define AGCSTS_FS_P2A_FULL	0x00000008
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#define AGCSTS_FS_A2P_EMPTY	0x00000004
12762306a36Sopenharmony_ci#define AGCSTS_FS_A2P_HALF	0x00000002
12862306a36Sopenharmony_ci#define AGCSTS_FS_A2P_FULL	0x00000001
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci/****************************************************************************/
13162306a36Sopenharmony_ci/* AMCC - Add-on Interrupt Control/Status Register                            */
13262306a36Sopenharmony_ci/****************************************************************************/
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define AINT_INT_MASK		0x00ff0000
13562306a36Sopenharmony_ci#define AINT_SEL_MASK		0x0000ffff
13662306a36Sopenharmony_ci#define  AINT_IS_ENSEL_MASK	0x00001f1f
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci#define AINT_INT_ASSERTED	0x00800000
13962306a36Sopenharmony_ci#define AINT_BM_ERROR		0x00200000
14062306a36Sopenharmony_ci#define AINT_BIST_INT		0x00100000
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#define AINT_RT_COMPLETE	0x00080000
14362306a36Sopenharmony_ci#define AINT_WT_COMPLETE	0x00040000
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci#define AINT_OUT_MB_INT		0x00020000
14662306a36Sopenharmony_ci#define AINT_IN_MB_INT		0x00010000
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci#define AINT_READ_COMPL		0x00008000
14962306a36Sopenharmony_ci#define AINT_WRITE_COMPL	0x00004000
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci#define AINT_OMB_ENABLE		0x00001000
15262306a36Sopenharmony_ci#define AINT_OMB_SELECT		0x00000c00
15362306a36Sopenharmony_ci#define AINT_OMB_BYTE		0x00000300
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci#define AINT_IMB_ENABLE		0x00000010
15662306a36Sopenharmony_ci#define AINT_IMB_SELECT		0x0000000c
15762306a36Sopenharmony_ci#define AINT_IMB_BYTE		0x00000003
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci/* these are bits from various different registers, needs cleanup XXX */
16062306a36Sopenharmony_ci/* Enable Bus Mastering */
16162306a36Sopenharmony_ci#define EN_A2P_TRANSFERS	0x00000400
16262306a36Sopenharmony_ci/* FIFO Flag Reset */
16362306a36Sopenharmony_ci#define RESET_A2P_FLAGS		0x04000000L
16462306a36Sopenharmony_ci/* FIFO Relative Priority */
16562306a36Sopenharmony_ci#define A2P_HI_PRIORITY		0x00000100L
16662306a36Sopenharmony_ci/* Identify Interrupt Sources */
16762306a36Sopenharmony_ci#define ANY_S593X_INT		0x00800000L
16862306a36Sopenharmony_ci#define READ_TC_INT		0x00080000L
16962306a36Sopenharmony_ci#define WRITE_TC_INT		0x00040000L
17062306a36Sopenharmony_ci#define IN_MB_INT		0x00020000L
17162306a36Sopenharmony_ci#define MASTER_ABORT_INT	0x00100000L
17262306a36Sopenharmony_ci#define TARGET_ABORT_INT	0x00200000L
17362306a36Sopenharmony_ci#define BUS_MASTER_INT		0x00200000L
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci#endif
176