162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * 440SPe's XOR engines support header file
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * 2006-2009 (C) DENX Software Engineering.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Author: Yuri Tikhonov <yur@emcraft.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#ifndef _PPC440SPE_XOR_H
1162306a36Sopenharmony_ci#define _PPC440SPE_XOR_H
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <linux/types.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/* Number of XOR engines available on the contoller */
1662306a36Sopenharmony_ci#define XOR_ENGINES_NUM		1
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci/* Number of operands supported in the h/w */
1962306a36Sopenharmony_ci#define XOR_MAX_OPS		16
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci/*
2262306a36Sopenharmony_ci * XOR Command Block Control Register bits
2362306a36Sopenharmony_ci */
2462306a36Sopenharmony_ci#define XOR_CBCR_LNK_BIT        (1<<31) /* link present */
2562306a36Sopenharmony_ci#define XOR_CBCR_TGT_BIT        (1<<30) /* target present */
2662306a36Sopenharmony_ci#define XOR_CBCR_CBCE_BIT       (1<<29) /* command block compete enable */
2762306a36Sopenharmony_ci#define XOR_CBCR_RNZE_BIT       (1<<28) /* result not zero enable */
2862306a36Sopenharmony_ci#define XOR_CBCR_XNOR_BIT       (1<<15) /* XOR/XNOR */
2962306a36Sopenharmony_ci#define XOR_CDCR_OAC_MSK        (0x7F)  /* operand address count */
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci/*
3262306a36Sopenharmony_ci * XORCore Status Register bits
3362306a36Sopenharmony_ci */
3462306a36Sopenharmony_ci#define XOR_SR_XCP_BIT		(1<<31)	/* core processing */
3562306a36Sopenharmony_ci#define XOR_SR_ICB_BIT		(1<<17)	/* invalid CB */
3662306a36Sopenharmony_ci#define XOR_SR_IC_BIT		(1<<16)	/* invalid command */
3762306a36Sopenharmony_ci#define XOR_SR_IPE_BIT		(1<<15)	/* internal parity error */
3862306a36Sopenharmony_ci#define XOR_SR_RNZ_BIT		(1<<2)	/* result not Zero */
3962306a36Sopenharmony_ci#define XOR_SR_CBC_BIT		(1<<1)	/* CB complete */
4062306a36Sopenharmony_ci#define XOR_SR_CBLC_BIT		(1<<0)	/* CB list complete */
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/*
4362306a36Sopenharmony_ci * XORCore Control Set and Reset Register bits
4462306a36Sopenharmony_ci */
4562306a36Sopenharmony_ci#define XOR_CRSR_XASR_BIT	(1<<31)	/* soft reset */
4662306a36Sopenharmony_ci#define XOR_CRSR_XAE_BIT	(1<<30)	/* enable */
4762306a36Sopenharmony_ci#define XOR_CRSR_RCBE_BIT	(1<<29)	/* refetch CB enable */
4862306a36Sopenharmony_ci#define XOR_CRSR_PAUS_BIT	(1<<28)	/* pause */
4962306a36Sopenharmony_ci#define XOR_CRSR_64BA_BIT	(1<<27) /* 64/32 CB format */
5062306a36Sopenharmony_ci#define XOR_CRSR_CLP_BIT	(1<<25)	/* continue list processing */
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/*
5362306a36Sopenharmony_ci * XORCore Interrupt Enable Register
5462306a36Sopenharmony_ci */
5562306a36Sopenharmony_ci#define XOR_IE_ICBIE_BIT	(1<<17)	/* Invalid Command Block IRQ Enable */
5662306a36Sopenharmony_ci#define XOR_IE_ICIE_BIT		(1<<16)	/* Invalid Command IRQ Enable */
5762306a36Sopenharmony_ci#define XOR_IE_RPTIE_BIT	(1<<14)	/* Read PLB Timeout Error IRQ Enable */
5862306a36Sopenharmony_ci#define XOR_IE_CBCIE_BIT	(1<<1)	/* CB complete interrupt enable */
5962306a36Sopenharmony_ci#define XOR_IE_CBLCI_BIT	(1<<0)	/* CB list complete interrupt enable */
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci/*
6262306a36Sopenharmony_ci * XOR Accelerator engine Command Block Type
6362306a36Sopenharmony_ci */
6462306a36Sopenharmony_cistruct xor_cb {
6562306a36Sopenharmony_ci	/*
6662306a36Sopenharmony_ci	 * Basic 64-bit format XOR CB (Table 19-1, p.463, 440spe_um_1_22.pdf)
6762306a36Sopenharmony_ci	 */
6862306a36Sopenharmony_ci	u32	cbc;		/* control */
6962306a36Sopenharmony_ci	u32	cbbc;		/* byte count */
7062306a36Sopenharmony_ci	u32	cbs;		/* status */
7162306a36Sopenharmony_ci	u8	pad0[4];	/* reserved */
7262306a36Sopenharmony_ci	u32	cbtah;		/* target address high */
7362306a36Sopenharmony_ci	u32	cbtal;		/* target address low */
7462306a36Sopenharmony_ci	u32	cblah;		/* link address high */
7562306a36Sopenharmony_ci	u32	cblal;		/* link address low */
7662306a36Sopenharmony_ci	struct {
7762306a36Sopenharmony_ci		u32 h;
7862306a36Sopenharmony_ci		u32 l;
7962306a36Sopenharmony_ci	} __attribute__ ((packed)) ops[16];
8062306a36Sopenharmony_ci} __attribute__ ((packed));
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci/*
8362306a36Sopenharmony_ci * XOR hardware registers Table 19-3, UM 1.22
8462306a36Sopenharmony_ci */
8562306a36Sopenharmony_cistruct xor_regs {
8662306a36Sopenharmony_ci	u32	op_ar[16][2];	/* operand address[0]-high,[1]-low registers */
8762306a36Sopenharmony_ci	u8	pad0[352];	/* reserved */
8862306a36Sopenharmony_ci	u32	cbcr;		/* CB control register */
8962306a36Sopenharmony_ci	u32	cbbcr;		/* CB byte count register */
9062306a36Sopenharmony_ci	u32	cbsr;		/* CB status register */
9162306a36Sopenharmony_ci	u8	pad1[4];	/* reserved */
9262306a36Sopenharmony_ci	u32	cbtahr;		/* operand target address high register */
9362306a36Sopenharmony_ci	u32	cbtalr;		/* operand target address low register */
9462306a36Sopenharmony_ci	u32	cblahr;		/* CB link address high register */
9562306a36Sopenharmony_ci	u32	cblalr;		/* CB link address low register */
9662306a36Sopenharmony_ci	u32	crsr;		/* control set register */
9762306a36Sopenharmony_ci	u32	crrr;		/* control reset register */
9862306a36Sopenharmony_ci	u32	ccbahr;		/* current CB address high register */
9962306a36Sopenharmony_ci	u32	ccbalr;		/* current CB address low register */
10062306a36Sopenharmony_ci	u32	plbr;		/* PLB configuration register */
10162306a36Sopenharmony_ci	u32	ier;		/* interrupt enable register */
10262306a36Sopenharmony_ci	u32	pecr;		/* parity error count register */
10362306a36Sopenharmony_ci	u32	sr;		/* status register */
10462306a36Sopenharmony_ci	u32	revidr;		/* revision ID register */
10562306a36Sopenharmony_ci};
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci#endif /* _PPC440SPE_XOR_H */
108