162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * CAAM hardware register-level view
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright 2008-2011 Freescale Semiconductor, Inc.
662306a36Sopenharmony_ci * Copyright 2018, 2023 NXP
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifndef REGS_H
1062306a36Sopenharmony_ci#define REGS_H
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <linux/types.h>
1362306a36Sopenharmony_ci#include <linux/bitops.h>
1462306a36Sopenharmony_ci#include <linux/io.h>
1562306a36Sopenharmony_ci#include <linux/io-64-nonatomic-hi-lo.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/*
1862306a36Sopenharmony_ci * Architecture-specific register access methods
1962306a36Sopenharmony_ci *
2062306a36Sopenharmony_ci * CAAM's bus-addressable registers are 64 bits internally.
2162306a36Sopenharmony_ci * They have been wired to be safely accessible on 32-bit
2262306a36Sopenharmony_ci * architectures, however. Registers were organized such
2362306a36Sopenharmony_ci * that (a) they can be contained in 32 bits, (b) if not, then they
2462306a36Sopenharmony_ci * can be treated as two 32-bit entities, or finally (c) if they
2562306a36Sopenharmony_ci * must be treated as a single 64-bit value, then this can safely
2662306a36Sopenharmony_ci * be done with two 32-bit cycles.
2762306a36Sopenharmony_ci *
2862306a36Sopenharmony_ci * For 32-bit operations on 64-bit values, CAAM follows the same
2962306a36Sopenharmony_ci * 64-bit register access conventions as it's predecessors, in that
3062306a36Sopenharmony_ci * writes are "triggered" by a write to the register at the numerically
3162306a36Sopenharmony_ci * higher address, thus, a full 64-bit write cycle requires a write
3262306a36Sopenharmony_ci * to the lower address, followed by a write to the higher address,
3362306a36Sopenharmony_ci * which will latch/execute the write cycle.
3462306a36Sopenharmony_ci *
3562306a36Sopenharmony_ci * For example, let's assume a SW reset of CAAM through the master
3662306a36Sopenharmony_ci * configuration register.
3762306a36Sopenharmony_ci * - SWRST is in bit 31 of MCFG.
3862306a36Sopenharmony_ci * - MCFG begins at base+0x0000.
3962306a36Sopenharmony_ci * - Bits 63-32 are a 32-bit word at base+0x0000 (numerically-lower)
4062306a36Sopenharmony_ci * - Bits 31-0 are a 32-bit word at base+0x0004 (numerically-higher)
4162306a36Sopenharmony_ci *
4262306a36Sopenharmony_ci * (and on Power, the convention is 0-31, 32-63, I know...)
4362306a36Sopenharmony_ci *
4462306a36Sopenharmony_ci * Assuming a 64-bit write to this MCFG to perform a software reset
4562306a36Sopenharmony_ci * would then require a write of 0 to base+0x0000, followed by a
4662306a36Sopenharmony_ci * write of 0x80000000 to base+0x0004, which would "execute" the
4762306a36Sopenharmony_ci * reset.
4862306a36Sopenharmony_ci *
4962306a36Sopenharmony_ci * Of course, since MCFG 63-32 is all zero, we could cheat and simply
5062306a36Sopenharmony_ci * write 0x8000000 to base+0x0004, and the reset would work fine.
5162306a36Sopenharmony_ci * However, since CAAM does contain some write-and-read-intended
5262306a36Sopenharmony_ci * 64-bit registers, this code defines 64-bit access methods for
5362306a36Sopenharmony_ci * the sake of internal consistency and simplicity, and so that a
5462306a36Sopenharmony_ci * clean transition to 64-bit is possible when it becomes necessary.
5562306a36Sopenharmony_ci *
5662306a36Sopenharmony_ci * There are limitations to this that the developer must recognize.
5762306a36Sopenharmony_ci * 32-bit architectures cannot enforce an atomic-64 operation,
5862306a36Sopenharmony_ci * Therefore:
5962306a36Sopenharmony_ci *
6062306a36Sopenharmony_ci * - On writes, since the HW is assumed to latch the cycle on the
6162306a36Sopenharmony_ci *   write of the higher-numeric-address word, then ordered
6262306a36Sopenharmony_ci *   writes work OK.
6362306a36Sopenharmony_ci *
6462306a36Sopenharmony_ci * - For reads, where a register contains a relevant value of more
6562306a36Sopenharmony_ci *   that 32 bits, the hardware employs logic to latch the other
6662306a36Sopenharmony_ci *   "half" of the data until read, ensuring an accurate value.
6762306a36Sopenharmony_ci *   This is of particular relevance when dealing with CAAM's
6862306a36Sopenharmony_ci *   performance counters.
6962306a36Sopenharmony_ci *
7062306a36Sopenharmony_ci */
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ciextern bool caam_little_end;
7362306a36Sopenharmony_ciextern bool caam_imx;
7462306a36Sopenharmony_ciextern size_t caam_ptr_sz;
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci#define caam_to_cpu(len)						\
7762306a36Sopenharmony_cistatic inline u##len caam##len ## _to_cpu(u##len val)			\
7862306a36Sopenharmony_ci{									\
7962306a36Sopenharmony_ci	if (caam_little_end)						\
8062306a36Sopenharmony_ci		return le##len ## _to_cpu((__force __le##len)val);	\
8162306a36Sopenharmony_ci	else								\
8262306a36Sopenharmony_ci		return be##len ## _to_cpu((__force __be##len)val);	\
8362306a36Sopenharmony_ci}
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define cpu_to_caam(len)					\
8662306a36Sopenharmony_cistatic inline u##len cpu_to_caam##len(u##len val)		\
8762306a36Sopenharmony_ci{								\
8862306a36Sopenharmony_ci	if (caam_little_end)					\
8962306a36Sopenharmony_ci		return (__force u##len)cpu_to_le##len(val);	\
9062306a36Sopenharmony_ci	else							\
9162306a36Sopenharmony_ci		return (__force u##len)cpu_to_be##len(val);	\
9262306a36Sopenharmony_ci}
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_cicaam_to_cpu(16)
9562306a36Sopenharmony_cicaam_to_cpu(32)
9662306a36Sopenharmony_cicaam_to_cpu(64)
9762306a36Sopenharmony_cicpu_to_caam(16)
9862306a36Sopenharmony_cicpu_to_caam(32)
9962306a36Sopenharmony_cicpu_to_caam(64)
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_cistatic inline void wr_reg32(void __iomem *reg, u32 data)
10262306a36Sopenharmony_ci{
10362306a36Sopenharmony_ci	if (caam_little_end)
10462306a36Sopenharmony_ci		iowrite32(data, reg);
10562306a36Sopenharmony_ci	else
10662306a36Sopenharmony_ci		iowrite32be(data, reg);
10762306a36Sopenharmony_ci}
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_cistatic inline u32 rd_reg32(void __iomem *reg)
11062306a36Sopenharmony_ci{
11162306a36Sopenharmony_ci	if (caam_little_end)
11262306a36Sopenharmony_ci		return ioread32(reg);
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci	return ioread32be(reg);
11562306a36Sopenharmony_ci}
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_cistatic inline void clrsetbits_32(void __iomem *reg, u32 clear, u32 set)
11862306a36Sopenharmony_ci{
11962306a36Sopenharmony_ci	if (caam_little_end)
12062306a36Sopenharmony_ci		iowrite32((ioread32(reg) & ~clear) | set, reg);
12162306a36Sopenharmony_ci	else
12262306a36Sopenharmony_ci		iowrite32be((ioread32be(reg) & ~clear) | set, reg);
12362306a36Sopenharmony_ci}
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci/*
12662306a36Sopenharmony_ci * The only users of these wr/rd_reg64 functions is the Job Ring (JR).
12762306a36Sopenharmony_ci * The DMA address registers in the JR are handled differently depending on
12862306a36Sopenharmony_ci * platform:
12962306a36Sopenharmony_ci *
13062306a36Sopenharmony_ci * 1. All BE CAAM platforms and i.MX platforms (LE CAAM):
13162306a36Sopenharmony_ci *
13262306a36Sopenharmony_ci *    base + 0x0000 : most-significant 32 bits
13362306a36Sopenharmony_ci *    base + 0x0004 : least-significant 32 bits
13462306a36Sopenharmony_ci *
13562306a36Sopenharmony_ci * The 32-bit version of this core therefore has to write to base + 0x0004
13662306a36Sopenharmony_ci * to set the 32-bit wide DMA address.
13762306a36Sopenharmony_ci *
13862306a36Sopenharmony_ci * 2. All other LE CAAM platforms (LS1021A etc.)
13962306a36Sopenharmony_ci *    base + 0x0000 : least-significant 32 bits
14062306a36Sopenharmony_ci *    base + 0x0004 : most-significant 32 bits
14162306a36Sopenharmony_ci */
14262306a36Sopenharmony_cistatic inline void wr_reg64(void __iomem *reg, u64 data)
14362306a36Sopenharmony_ci{
14462306a36Sopenharmony_ci	if (caam_little_end) {
14562306a36Sopenharmony_ci		if (caam_imx) {
14662306a36Sopenharmony_ci			iowrite32(data >> 32, (u32 __iomem *)(reg));
14762306a36Sopenharmony_ci			iowrite32(data, (u32 __iomem *)(reg) + 1);
14862306a36Sopenharmony_ci		} else {
14962306a36Sopenharmony_ci			iowrite64(data, reg);
15062306a36Sopenharmony_ci		}
15162306a36Sopenharmony_ci	} else {
15262306a36Sopenharmony_ci		iowrite64be(data, reg);
15362306a36Sopenharmony_ci	}
15462306a36Sopenharmony_ci}
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_cistatic inline u64 rd_reg64(void __iomem *reg)
15762306a36Sopenharmony_ci{
15862306a36Sopenharmony_ci	if (caam_little_end) {
15962306a36Sopenharmony_ci		if (caam_imx) {
16062306a36Sopenharmony_ci			u32 low, high;
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci			high = ioread32(reg);
16362306a36Sopenharmony_ci			low  = ioread32(reg + sizeof(u32));
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci			return low + ((u64)high << 32);
16662306a36Sopenharmony_ci		} else {
16762306a36Sopenharmony_ci			return ioread64(reg);
16862306a36Sopenharmony_ci		}
16962306a36Sopenharmony_ci	} else {
17062306a36Sopenharmony_ci		return ioread64be(reg);
17162306a36Sopenharmony_ci	}
17262306a36Sopenharmony_ci}
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_cistatic inline u64 cpu_to_caam_dma64(dma_addr_t value)
17562306a36Sopenharmony_ci{
17662306a36Sopenharmony_ci	if (caam_imx) {
17762306a36Sopenharmony_ci		u64 ret_val = (u64)cpu_to_caam32(lower_32_bits(value)) << 32;
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci		if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
18062306a36Sopenharmony_ci			ret_val |= (u64)cpu_to_caam32(upper_32_bits(value));
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci		return ret_val;
18362306a36Sopenharmony_ci	}
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci	return cpu_to_caam64(value);
18662306a36Sopenharmony_ci}
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_cistatic inline u64 caam_dma64_to_cpu(u64 value)
18962306a36Sopenharmony_ci{
19062306a36Sopenharmony_ci	if (caam_imx)
19162306a36Sopenharmony_ci		return (((u64)caam32_to_cpu(lower_32_bits(value)) << 32) |
19262306a36Sopenharmony_ci			 (u64)caam32_to_cpu(upper_32_bits(value)));
19362306a36Sopenharmony_ci
19462306a36Sopenharmony_ci	return caam64_to_cpu(value);
19562306a36Sopenharmony_ci}
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_cistatic inline u64 cpu_to_caam_dma(u64 value)
19862306a36Sopenharmony_ci{
19962306a36Sopenharmony_ci	if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
20062306a36Sopenharmony_ci	    caam_ptr_sz == sizeof(u64))
20162306a36Sopenharmony_ci		return cpu_to_caam_dma64(value);
20262306a36Sopenharmony_ci	else
20362306a36Sopenharmony_ci		return cpu_to_caam32(value);
20462306a36Sopenharmony_ci}
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_cistatic inline u64 caam_dma_to_cpu(u64 value)
20762306a36Sopenharmony_ci{
20862306a36Sopenharmony_ci	if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
20962306a36Sopenharmony_ci	    caam_ptr_sz == sizeof(u64))
21062306a36Sopenharmony_ci		return caam_dma64_to_cpu(value);
21162306a36Sopenharmony_ci	else
21262306a36Sopenharmony_ci		return caam32_to_cpu(value);
21362306a36Sopenharmony_ci}
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci/*
21662306a36Sopenharmony_ci * jr_outentry
21762306a36Sopenharmony_ci * Represents each entry in a JobR output ring
21862306a36Sopenharmony_ci */
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_cistatic inline void jr_outentry_get(void *outring, int hw_idx, dma_addr_t *desc,
22162306a36Sopenharmony_ci				   u32 *jrstatus)
22262306a36Sopenharmony_ci{
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci	if (caam_ptr_sz == sizeof(u32)) {
22562306a36Sopenharmony_ci		struct {
22662306a36Sopenharmony_ci			u32 desc;
22762306a36Sopenharmony_ci			u32 jrstatus;
22862306a36Sopenharmony_ci		} __packed *outentry = outring;
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci		*desc = outentry[hw_idx].desc;
23162306a36Sopenharmony_ci		*jrstatus = outentry[hw_idx].jrstatus;
23262306a36Sopenharmony_ci	} else {
23362306a36Sopenharmony_ci		struct {
23462306a36Sopenharmony_ci			dma_addr_t desc;/* Pointer to completed descriptor */
23562306a36Sopenharmony_ci			u32 jrstatus;	/* Status for completed descriptor */
23662306a36Sopenharmony_ci		} __packed *outentry = outring;
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci		*desc = outentry[hw_idx].desc;
23962306a36Sopenharmony_ci		*jrstatus = outentry[hw_idx].jrstatus;
24062306a36Sopenharmony_ci	}
24162306a36Sopenharmony_ci}
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci#define SIZEOF_JR_OUTENTRY	(caam_ptr_sz + sizeof(u32))
24462306a36Sopenharmony_ci
24562306a36Sopenharmony_cistatic inline dma_addr_t jr_outentry_desc(void *outring, int hw_idx)
24662306a36Sopenharmony_ci{
24762306a36Sopenharmony_ci	dma_addr_t desc;
24862306a36Sopenharmony_ci	u32 unused;
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci	jr_outentry_get(outring, hw_idx, &desc, &unused);
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_ci	return desc;
25362306a36Sopenharmony_ci}
25462306a36Sopenharmony_ci
25562306a36Sopenharmony_cistatic inline u32 jr_outentry_jrstatus(void *outring, int hw_idx)
25662306a36Sopenharmony_ci{
25762306a36Sopenharmony_ci	dma_addr_t unused;
25862306a36Sopenharmony_ci	u32 jrstatus;
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci	jr_outentry_get(outring, hw_idx, &unused, &jrstatus);
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci	return jrstatus;
26362306a36Sopenharmony_ci}
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_cistatic inline void jr_inpentry_set(void *inpring, int hw_idx, dma_addr_t val)
26662306a36Sopenharmony_ci{
26762306a36Sopenharmony_ci	if (caam_ptr_sz == sizeof(u32)) {
26862306a36Sopenharmony_ci		u32 *inpentry = inpring;
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci		inpentry[hw_idx] = val;
27162306a36Sopenharmony_ci	} else {
27262306a36Sopenharmony_ci		dma_addr_t *inpentry = inpring;
27362306a36Sopenharmony_ci
27462306a36Sopenharmony_ci		inpentry[hw_idx] = val;
27562306a36Sopenharmony_ci	}
27662306a36Sopenharmony_ci}
27762306a36Sopenharmony_ci
27862306a36Sopenharmony_ci#define SIZEOF_JR_INPENTRY	caam_ptr_sz
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci/* Version registers (Era 10+)	e80-eff */
28262306a36Sopenharmony_cistruct version_regs {
28362306a36Sopenharmony_ci	u32 crca;	/* CRCA_VERSION */
28462306a36Sopenharmony_ci	u32 afha;	/* AFHA_VERSION */
28562306a36Sopenharmony_ci	u32 kfha;	/* KFHA_VERSION */
28662306a36Sopenharmony_ci	u32 pkha;	/* PKHA_VERSION */
28762306a36Sopenharmony_ci	u32 aesa;	/* AESA_VERSION */
28862306a36Sopenharmony_ci	u32 mdha;	/* MDHA_VERSION */
28962306a36Sopenharmony_ci	u32 desa;	/* DESA_VERSION */
29062306a36Sopenharmony_ci	u32 snw8a;	/* SNW8A_VERSION */
29162306a36Sopenharmony_ci	u32 snw9a;	/* SNW9A_VERSION */
29262306a36Sopenharmony_ci	u32 zuce;	/* ZUCE_VERSION */
29362306a36Sopenharmony_ci	u32 zuca;	/* ZUCA_VERSION */
29462306a36Sopenharmony_ci	u32 ccha;	/* CCHA_VERSION */
29562306a36Sopenharmony_ci	u32 ptha;	/* PTHA_VERSION */
29662306a36Sopenharmony_ci	u32 rng;	/* RNG_VERSION */
29762306a36Sopenharmony_ci	u32 trng;	/* TRNG_VERSION */
29862306a36Sopenharmony_ci	u32 aaha;	/* AAHA_VERSION */
29962306a36Sopenharmony_ci	u32 rsvd[10];
30062306a36Sopenharmony_ci	u32 sr;		/* SR_VERSION */
30162306a36Sopenharmony_ci	u32 dma;	/* DMA_VERSION */
30262306a36Sopenharmony_ci	u32 ai;		/* AI_VERSION */
30362306a36Sopenharmony_ci	u32 qi;		/* QI_VERSION */
30462306a36Sopenharmony_ci	u32 jr;		/* JR_VERSION */
30562306a36Sopenharmony_ci	u32 deco;	/* DECO_VERSION */
30662306a36Sopenharmony_ci};
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ci/* Version registers bitfields */
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_ci/* Number of CHAs instantiated */
31162306a36Sopenharmony_ci#define CHA_VER_NUM_MASK	0xffull
31262306a36Sopenharmony_ci/* CHA Miscellaneous Information */
31362306a36Sopenharmony_ci#define CHA_VER_MISC_SHIFT	8
31462306a36Sopenharmony_ci#define CHA_VER_MISC_MASK	(0xffull << CHA_VER_MISC_SHIFT)
31562306a36Sopenharmony_ci/* CHA Revision Number */
31662306a36Sopenharmony_ci#define CHA_VER_REV_SHIFT	16
31762306a36Sopenharmony_ci#define CHA_VER_REV_MASK	(0xffull << CHA_VER_REV_SHIFT)
31862306a36Sopenharmony_ci/* CHA Version ID */
31962306a36Sopenharmony_ci#define CHA_VER_VID_SHIFT	24
32062306a36Sopenharmony_ci#define CHA_VER_VID_MASK	(0xffull << CHA_VER_VID_SHIFT)
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_ci/* CHA Miscellaneous Information - AESA_MISC specific */
32362306a36Sopenharmony_ci#define CHA_VER_MISC_AES_NUM_MASK	GENMASK(7, 0)
32462306a36Sopenharmony_ci#define CHA_VER_MISC_AES_GCM		BIT(1 + CHA_VER_MISC_SHIFT)
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci/* CHA Miscellaneous Information - PKHA_MISC specific */
32762306a36Sopenharmony_ci#define CHA_VER_MISC_PKHA_NO_CRYPT	BIT(7 + CHA_VER_MISC_SHIFT)
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci/*
33062306a36Sopenharmony_ci * caam_perfmon - Performance Monitor/Secure Memory Status/
33162306a36Sopenharmony_ci *                CAAM Global Status/Component Version IDs
33262306a36Sopenharmony_ci *
33362306a36Sopenharmony_ci * Spans f00-fff wherever instantiated
33462306a36Sopenharmony_ci */
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_ci/* Number of DECOs */
33762306a36Sopenharmony_ci#define CHA_NUM_MS_DECONUM_SHIFT	24
33862306a36Sopenharmony_ci#define CHA_NUM_MS_DECONUM_MASK	(0xfull << CHA_NUM_MS_DECONUM_SHIFT)
33962306a36Sopenharmony_ci
34062306a36Sopenharmony_ci/*
34162306a36Sopenharmony_ci * CHA version IDs / instantiation bitfields (< Era 10)
34262306a36Sopenharmony_ci * Defined for use with the cha_id fields in perfmon, but the same shift/mask
34362306a36Sopenharmony_ci * selectors can be used to pull out the number of instantiated blocks within
34462306a36Sopenharmony_ci * cha_num fields in perfmon because the locations are the same.
34562306a36Sopenharmony_ci */
34662306a36Sopenharmony_ci#define CHA_ID_LS_AES_SHIFT	0
34762306a36Sopenharmony_ci#define CHA_ID_LS_AES_MASK	(0xfull << CHA_ID_LS_AES_SHIFT)
34862306a36Sopenharmony_ci
34962306a36Sopenharmony_ci#define CHA_ID_LS_DES_SHIFT	4
35062306a36Sopenharmony_ci#define CHA_ID_LS_DES_MASK	(0xfull << CHA_ID_LS_DES_SHIFT)
35162306a36Sopenharmony_ci
35262306a36Sopenharmony_ci#define CHA_ID_LS_ARC4_SHIFT	8
35362306a36Sopenharmony_ci#define CHA_ID_LS_ARC4_MASK	(0xfull << CHA_ID_LS_ARC4_SHIFT)
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ci#define CHA_ID_LS_MD_SHIFT	12
35662306a36Sopenharmony_ci#define CHA_ID_LS_MD_MASK	(0xfull << CHA_ID_LS_MD_SHIFT)
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_ci#define CHA_ID_LS_RNG_SHIFT	16
35962306a36Sopenharmony_ci#define CHA_ID_LS_RNG_MASK	(0xfull << CHA_ID_LS_RNG_SHIFT)
36062306a36Sopenharmony_ci
36162306a36Sopenharmony_ci#define CHA_ID_LS_SNW8_SHIFT	20
36262306a36Sopenharmony_ci#define CHA_ID_LS_SNW8_MASK	(0xfull << CHA_ID_LS_SNW8_SHIFT)
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci#define CHA_ID_LS_KAS_SHIFT	24
36562306a36Sopenharmony_ci#define CHA_ID_LS_KAS_MASK	(0xfull << CHA_ID_LS_KAS_SHIFT)
36662306a36Sopenharmony_ci
36762306a36Sopenharmony_ci#define CHA_ID_LS_PK_SHIFT	28
36862306a36Sopenharmony_ci#define CHA_ID_LS_PK_MASK	(0xfull << CHA_ID_LS_PK_SHIFT)
36962306a36Sopenharmony_ci
37062306a36Sopenharmony_ci#define CHA_ID_MS_CRC_SHIFT	0
37162306a36Sopenharmony_ci#define CHA_ID_MS_CRC_MASK	(0xfull << CHA_ID_MS_CRC_SHIFT)
37262306a36Sopenharmony_ci
37362306a36Sopenharmony_ci#define CHA_ID_MS_SNW9_SHIFT	4
37462306a36Sopenharmony_ci#define CHA_ID_MS_SNW9_MASK	(0xfull << CHA_ID_MS_SNW9_SHIFT)
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci#define CHA_ID_MS_DECO_SHIFT	24
37762306a36Sopenharmony_ci#define CHA_ID_MS_DECO_MASK	(0xfull << CHA_ID_MS_DECO_SHIFT)
37862306a36Sopenharmony_ci
37962306a36Sopenharmony_ci#define CHA_ID_MS_JR_SHIFT	28
38062306a36Sopenharmony_ci#define CHA_ID_MS_JR_MASK	(0xfull << CHA_ID_MS_JR_SHIFT)
38162306a36Sopenharmony_ci
38262306a36Sopenharmony_ci/* Specific CHA version IDs */
38362306a36Sopenharmony_ci#define CHA_VER_VID_AES_LP	0x3ull
38462306a36Sopenharmony_ci#define CHA_VER_VID_AES_HP	0x4ull
38562306a36Sopenharmony_ci#define CHA_VER_VID_MD_LP256	0x0ull
38662306a36Sopenharmony_ci#define CHA_VER_VID_MD_LP512	0x1ull
38762306a36Sopenharmony_ci#define CHA_VER_VID_MD_HP	0x2ull
38862306a36Sopenharmony_ci
38962306a36Sopenharmony_cistruct sec_vid {
39062306a36Sopenharmony_ci	u16 ip_id;
39162306a36Sopenharmony_ci	u8 maj_rev;
39262306a36Sopenharmony_ci	u8 min_rev;
39362306a36Sopenharmony_ci};
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_cistruct caam_perfmon {
39662306a36Sopenharmony_ci	/* Performance Monitor Registers			f00-f9f */
39762306a36Sopenharmony_ci	u64 req_dequeued;	/* PC_REQ_DEQ - Dequeued Requests	     */
39862306a36Sopenharmony_ci	u64 ob_enc_req;	/* PC_OB_ENC_REQ - Outbound Encrypt Requests */
39962306a36Sopenharmony_ci	u64 ib_dec_req;	/* PC_IB_DEC_REQ - Inbound Decrypt Requests  */
40062306a36Sopenharmony_ci	u64 ob_enc_bytes;	/* PC_OB_ENCRYPT - Outbound Bytes Encrypted  */
40162306a36Sopenharmony_ci	u64 ob_prot_bytes;	/* PC_OB_PROTECT - Outbound Bytes Protected  */
40262306a36Sopenharmony_ci	u64 ib_dec_bytes;	/* PC_IB_DECRYPT - Inbound Bytes Decrypted   */
40362306a36Sopenharmony_ci	u64 ib_valid_bytes;	/* PC_IB_VALIDATED Inbound Bytes Validated   */
40462306a36Sopenharmony_ci	u64 rsvd[13];
40562306a36Sopenharmony_ci
40662306a36Sopenharmony_ci	/* CAAM Hardware Instantiation Parameters		fa0-fbf */
40762306a36Sopenharmony_ci	u32 cha_rev_ms;		/* CRNR - CHA Rev No. Most significant half*/
40862306a36Sopenharmony_ci	u32 cha_rev_ls;		/* CRNR - CHA Rev No. Least significant half*/
40962306a36Sopenharmony_ci#define CTPR_MS_QI_SHIFT	25
41062306a36Sopenharmony_ci#define CTPR_MS_QI_MASK		(0x1ull << CTPR_MS_QI_SHIFT)
41162306a36Sopenharmony_ci#define CTPR_MS_PS		BIT(17)
41262306a36Sopenharmony_ci#define CTPR_MS_DPAA2		BIT(13)
41362306a36Sopenharmony_ci#define CTPR_MS_VIRT_EN_INCL	0x00000001
41462306a36Sopenharmony_ci#define CTPR_MS_VIRT_EN_POR	0x00000002
41562306a36Sopenharmony_ci#define CTPR_MS_PG_SZ_MASK	0x10
41662306a36Sopenharmony_ci#define CTPR_MS_PG_SZ_SHIFT	4
41762306a36Sopenharmony_ci	u32 comp_parms_ms;	/* CTPR - Compile Parameters Register	*/
41862306a36Sopenharmony_ci#define CTPR_LS_BLOB           BIT(1)
41962306a36Sopenharmony_ci	u32 comp_parms_ls;	/* CTPR - Compile Parameters Register	*/
42062306a36Sopenharmony_ci	u64 rsvd1[2];
42162306a36Sopenharmony_ci
42262306a36Sopenharmony_ci	/* CAAM Global Status					fc0-fdf */
42362306a36Sopenharmony_ci	u64 faultaddr;	/* FAR  - Fault Address		*/
42462306a36Sopenharmony_ci	u32 faultliodn;	/* FALR - Fault Address LIODN	*/
42562306a36Sopenharmony_ci	u32 faultdetail;	/* FADR - Fault Addr Detail	*/
42662306a36Sopenharmony_ci	u32 rsvd2;
42762306a36Sopenharmony_ci#define CSTA_PLEND		BIT(10)
42862306a36Sopenharmony_ci#define CSTA_ALT_PLEND		BIT(18)
42962306a36Sopenharmony_ci#define CSTA_MOO		GENMASK(9, 8)
43062306a36Sopenharmony_ci#define CSTA_MOO_SECURE	1
43162306a36Sopenharmony_ci#define CSTA_MOO_TRUSTED	2
43262306a36Sopenharmony_ci	u32 status;		/* CSTA - CAAM Status */
43362306a36Sopenharmony_ci	u64 rsvd3;
43462306a36Sopenharmony_ci
43562306a36Sopenharmony_ci	/* Component Instantiation Parameters			fe0-fff */
43662306a36Sopenharmony_ci	u32 rtic_id;		/* RVID - RTIC Version ID	*/
43762306a36Sopenharmony_ci#define CCBVID_ERA_MASK		0xff000000
43862306a36Sopenharmony_ci#define CCBVID_ERA_SHIFT	24
43962306a36Sopenharmony_ci	u32 ccb_id;		/* CCBVID - CCB Version ID	*/
44062306a36Sopenharmony_ci	u32 cha_id_ms;		/* CHAVID - CHA Version ID Most Significant*/
44162306a36Sopenharmony_ci	u32 cha_id_ls;		/* CHAVID - CHA Version ID Least Significant*/
44262306a36Sopenharmony_ci	u32 cha_num_ms;		/* CHANUM - CHA Number Most Significant	*/
44362306a36Sopenharmony_ci	u32 cha_num_ls;		/* CHANUM - CHA Number Least Significant*/
44462306a36Sopenharmony_ci#define SECVID_MS_IPID_MASK	0xffff0000
44562306a36Sopenharmony_ci#define SECVID_MS_IPID_SHIFT	16
44662306a36Sopenharmony_ci#define SECVID_MS_MAJ_REV_MASK	0x0000ff00
44762306a36Sopenharmony_ci#define SECVID_MS_MAJ_REV_SHIFT	8
44862306a36Sopenharmony_ci	u32 caam_id_ms;		/* CAAMVID - CAAM Version ID MS	*/
44962306a36Sopenharmony_ci	u32 caam_id_ls;		/* CAAMVID - CAAM Version ID LS	*/
45062306a36Sopenharmony_ci};
45162306a36Sopenharmony_ci
45262306a36Sopenharmony_ci/* LIODN programming for DMA configuration */
45362306a36Sopenharmony_ci#define MSTRID_LOCK_LIODN	0x80000000
45462306a36Sopenharmony_ci#define MSTRID_LOCK_MAKETRUSTED	0x00010000	/* only for JR masterid */
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_ci#define MSTRID_LIODN_MASK	0x0fff
45762306a36Sopenharmony_cistruct masterid {
45862306a36Sopenharmony_ci	u32 liodn_ms;	/* lock and make-trusted control bits */
45962306a36Sopenharmony_ci	u32 liodn_ls;	/* LIODN for non-sequence and seq access */
46062306a36Sopenharmony_ci};
46162306a36Sopenharmony_ci
46262306a36Sopenharmony_ci/* RNGB test mode (replicated twice in some configurations) */
46362306a36Sopenharmony_ci/* Padded out to 0x100 */
46462306a36Sopenharmony_cistruct rngtst {
46562306a36Sopenharmony_ci	u32 mode;		/* RTSTMODEx - Test mode */
46662306a36Sopenharmony_ci	u32 rsvd1[3];
46762306a36Sopenharmony_ci	u32 reset;		/* RTSTRESETx - Test reset control */
46862306a36Sopenharmony_ci	u32 rsvd2[3];
46962306a36Sopenharmony_ci	u32 status;		/* RTSTSSTATUSx - Test status */
47062306a36Sopenharmony_ci	u32 rsvd3;
47162306a36Sopenharmony_ci	u32 errstat;		/* RTSTERRSTATx - Test error status */
47262306a36Sopenharmony_ci	u32 rsvd4;
47362306a36Sopenharmony_ci	u32 errctl;		/* RTSTERRCTLx - Test error control */
47462306a36Sopenharmony_ci	u32 rsvd5;
47562306a36Sopenharmony_ci	u32 entropy;		/* RTSTENTROPYx - Test entropy */
47662306a36Sopenharmony_ci	u32 rsvd6[15];
47762306a36Sopenharmony_ci	u32 verifctl;	/* RTSTVERIFCTLx - Test verification control */
47862306a36Sopenharmony_ci	u32 rsvd7;
47962306a36Sopenharmony_ci	u32 verifstat;	/* RTSTVERIFSTATx - Test verification status */
48062306a36Sopenharmony_ci	u32 rsvd8;
48162306a36Sopenharmony_ci	u32 verifdata;	/* RTSTVERIFDx - Test verification data */
48262306a36Sopenharmony_ci	u32 rsvd9;
48362306a36Sopenharmony_ci	u32 xkey;		/* RTSTXKEYx - Test XKEY */
48462306a36Sopenharmony_ci	u32 rsvd10;
48562306a36Sopenharmony_ci	u32 oscctctl;	/* RTSTOSCCTCTLx - Test osc. counter control */
48662306a36Sopenharmony_ci	u32 rsvd11;
48762306a36Sopenharmony_ci	u32 oscct;		/* RTSTOSCCTx - Test oscillator counter */
48862306a36Sopenharmony_ci	u32 rsvd12;
48962306a36Sopenharmony_ci	u32 oscctstat;	/* RTSTODCCTSTATx - Test osc counter status */
49062306a36Sopenharmony_ci	u32 rsvd13[2];
49162306a36Sopenharmony_ci	u32 ofifo[4];	/* RTSTOFIFOx - Test output FIFO */
49262306a36Sopenharmony_ci	u32 rsvd14[15];
49362306a36Sopenharmony_ci};
49462306a36Sopenharmony_ci
49562306a36Sopenharmony_ci/* RNG4 TRNG test registers */
49662306a36Sopenharmony_cistruct rng4tst {
49762306a36Sopenharmony_ci#define RTMCTL_ACC  BIT(5)  /* TRNG access mode */
49862306a36Sopenharmony_ci#define RTMCTL_PRGM BIT(16) /* 1 -> program mode, 0 -> run mode */
49962306a36Sopenharmony_ci#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_SC	0 /* use von Neumann data in
50062306a36Sopenharmony_ci						     both entropy shifter and
50162306a36Sopenharmony_ci						     statistical checker */
50262306a36Sopenharmony_ci#define RTMCTL_SAMP_MODE_RAW_ES_SC		1 /* use raw data in both
50362306a36Sopenharmony_ci						     entropy shifter and
50462306a36Sopenharmony_ci						     statistical checker */
50562306a36Sopenharmony_ci#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_RAW_SC	2 /* use von Neumann data in
50662306a36Sopenharmony_ci						     entropy shifter, raw data
50762306a36Sopenharmony_ci						     in statistical checker */
50862306a36Sopenharmony_ci#define RTMCTL_SAMP_MODE_INVALID		3 /* invalid combination */
50962306a36Sopenharmony_ci	u32 rtmctl;		/* misc. control register */
51062306a36Sopenharmony_ci	u32 rtscmisc;		/* statistical check misc. register */
51162306a36Sopenharmony_ci	u32 rtpkrrng;		/* poker range register */
51262306a36Sopenharmony_ci	union {
51362306a36Sopenharmony_ci		u32 rtpkrmax;	/* PRGM=1: poker max. limit register */
51462306a36Sopenharmony_ci		u32 rtpkrsq;	/* PRGM=0: poker square calc. result register */
51562306a36Sopenharmony_ci	};
51662306a36Sopenharmony_ci#define RTSDCTL_ENT_DLY_SHIFT 16
51762306a36Sopenharmony_ci#define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
51862306a36Sopenharmony_ci#define RTSDCTL_ENT_DLY_MIN 3200
51962306a36Sopenharmony_ci#define RTSDCTL_ENT_DLY_MAX 12800
52062306a36Sopenharmony_ci#define RTSDCTL_SAMP_SIZE_MASK 0xffff
52162306a36Sopenharmony_ci#define RTSDCTL_SAMP_SIZE_VAL 512
52262306a36Sopenharmony_ci	u32 rtsdctl;		/* seed control register */
52362306a36Sopenharmony_ci	union {
52462306a36Sopenharmony_ci		u32 rtsblim;	/* PRGM=1: sparse bit limit register */
52562306a36Sopenharmony_ci		u32 rttotsam;	/* PRGM=0: total samples register */
52662306a36Sopenharmony_ci	};
52762306a36Sopenharmony_ci	u32 rtfrqmin;		/* frequency count min. limit register */
52862306a36Sopenharmony_ci#define RTFRQMAX_DISABLE	(1 << 20)
52962306a36Sopenharmony_ci	union {
53062306a36Sopenharmony_ci		u32 rtfrqmax;	/* PRGM=1: freq. count max. limit register */
53162306a36Sopenharmony_ci		u32 rtfrqcnt;	/* PRGM=0: freq. count register */
53262306a36Sopenharmony_ci	};
53362306a36Sopenharmony_ci	union {
53462306a36Sopenharmony_ci		u32 rtscmc;	/* statistical check run monobit count */
53562306a36Sopenharmony_ci		u32 rtscml;	/* statistical check run monobit limit */
53662306a36Sopenharmony_ci	};
53762306a36Sopenharmony_ci	union {
53862306a36Sopenharmony_ci		u32 rtscrc[6];	/* statistical check run length count */
53962306a36Sopenharmony_ci		u32 rtscrl[6];	/* statistical check run length limit */
54062306a36Sopenharmony_ci	};
54162306a36Sopenharmony_ci	u32 rsvd1[33];
54262306a36Sopenharmony_ci#define RDSTA_SKVT 0x80000000
54362306a36Sopenharmony_ci#define RDSTA_SKVN 0x40000000
54462306a36Sopenharmony_ci#define RDSTA_PR0 BIT(4)
54562306a36Sopenharmony_ci#define RDSTA_PR1 BIT(5)
54662306a36Sopenharmony_ci#define RDSTA_IF0 0x00000001
54762306a36Sopenharmony_ci#define RDSTA_IF1 0x00000002
54862306a36Sopenharmony_ci#define RDSTA_MASK (RDSTA_PR1 | RDSTA_PR0 | RDSTA_IF1 | RDSTA_IF0)
54962306a36Sopenharmony_ci	u32 rdsta;
55062306a36Sopenharmony_ci	u32 rsvd2[15];
55162306a36Sopenharmony_ci};
55262306a36Sopenharmony_ci
55362306a36Sopenharmony_ci/*
55462306a36Sopenharmony_ci * caam_ctrl - basic core configuration
55562306a36Sopenharmony_ci * starts base + 0x0000 padded out to 0x1000
55662306a36Sopenharmony_ci */
55762306a36Sopenharmony_ci
55862306a36Sopenharmony_ci#define KEK_KEY_SIZE		8
55962306a36Sopenharmony_ci#define TKEK_KEY_SIZE		8
56062306a36Sopenharmony_ci#define TDSK_KEY_SIZE		8
56162306a36Sopenharmony_ci
56262306a36Sopenharmony_ci#define DECO_RESET	1	/* Use with DECO reset/availability regs */
56362306a36Sopenharmony_ci#define DECO_RESET_0	(DECO_RESET << 0)
56462306a36Sopenharmony_ci#define DECO_RESET_1	(DECO_RESET << 1)
56562306a36Sopenharmony_ci#define DECO_RESET_2	(DECO_RESET << 2)
56662306a36Sopenharmony_ci#define DECO_RESET_3	(DECO_RESET << 3)
56762306a36Sopenharmony_ci#define DECO_RESET_4	(DECO_RESET << 4)
56862306a36Sopenharmony_ci
56962306a36Sopenharmony_cistruct caam_ctrl {
57062306a36Sopenharmony_ci	/* Basic Configuration Section				000-01f */
57162306a36Sopenharmony_ci	/* Read/Writable					        */
57262306a36Sopenharmony_ci	u32 rsvd1;
57362306a36Sopenharmony_ci	u32 mcr;		/* MCFG      Master Config Register  */
57462306a36Sopenharmony_ci	u32 rsvd2;
57562306a36Sopenharmony_ci	u32 scfgr;		/* SCFGR, Security Config Register */
57662306a36Sopenharmony_ci
57762306a36Sopenharmony_ci	/* Bus Access Configuration Section			010-11f */
57862306a36Sopenharmony_ci	/* Read/Writable                                                */
57962306a36Sopenharmony_ci	struct masterid jr_mid[4];	/* JRxLIODNR - JobR LIODN setup */
58062306a36Sopenharmony_ci	u32 rsvd3[11];
58162306a36Sopenharmony_ci	u32 jrstart;			/* JRSTART - Job Ring Start Register */
58262306a36Sopenharmony_ci	struct masterid rtic_mid[4];	/* RTICxLIODNR - RTIC LIODN setup */
58362306a36Sopenharmony_ci	u32 rsvd4[5];
58462306a36Sopenharmony_ci	u32 deco_rsr;			/* DECORSR - Deco Request Source */
58562306a36Sopenharmony_ci	u32 rsvd11;
58662306a36Sopenharmony_ci	u32 deco_rq;			/* DECORR - DECO Request */
58762306a36Sopenharmony_ci	struct masterid deco_mid[16];	/* DECOxLIODNR - 1 per DECO */
58862306a36Sopenharmony_ci
58962306a36Sopenharmony_ci	/* DECO Availability/Reset Section			120-3ff */
59062306a36Sopenharmony_ci	u32 deco_avail;		/* DAR - DECO availability */
59162306a36Sopenharmony_ci	u32 deco_reset;		/* DRR - DECO reset */
59262306a36Sopenharmony_ci	u32 rsvd6[182];
59362306a36Sopenharmony_ci
59462306a36Sopenharmony_ci	/* Key Encryption/Decryption Configuration              400-5ff */
59562306a36Sopenharmony_ci	/* Read/Writable only while in Non-secure mode                  */
59662306a36Sopenharmony_ci	u32 kek[KEK_KEY_SIZE];	/* JDKEKR - Key Encryption Key */
59762306a36Sopenharmony_ci	u32 tkek[TKEK_KEY_SIZE];	/* TDKEKR - Trusted Desc KEK */
59862306a36Sopenharmony_ci	u32 tdsk[TDSK_KEY_SIZE];	/* TDSKR - Trusted Desc Signing Key */
59962306a36Sopenharmony_ci	u32 rsvd7[32];
60062306a36Sopenharmony_ci	u64 sknonce;			/* SKNR - Secure Key Nonce */
60162306a36Sopenharmony_ci	u32 rsvd8[70];
60262306a36Sopenharmony_ci
60362306a36Sopenharmony_ci	/* RNG Test/Verification/Debug Access                   600-7ff */
60462306a36Sopenharmony_ci	/* (Useful in Test/Debug modes only...)                         */
60562306a36Sopenharmony_ci	union {
60662306a36Sopenharmony_ci		struct rngtst rtst[2];
60762306a36Sopenharmony_ci		struct rng4tst r4tst[2];
60862306a36Sopenharmony_ci	};
60962306a36Sopenharmony_ci
61062306a36Sopenharmony_ci	u32 rsvd9[416];
61162306a36Sopenharmony_ci
61262306a36Sopenharmony_ci	/* Version registers - introduced with era 10		e80-eff */
61362306a36Sopenharmony_ci	struct version_regs vreg;
61462306a36Sopenharmony_ci	/* Performance Monitor                                  f00-fff */
61562306a36Sopenharmony_ci	struct caam_perfmon perfmon;
61662306a36Sopenharmony_ci};
61762306a36Sopenharmony_ci
61862306a36Sopenharmony_ci/*
61962306a36Sopenharmony_ci * Controller master config register defs
62062306a36Sopenharmony_ci */
62162306a36Sopenharmony_ci#define MCFGR_SWRESET		0x80000000 /* software reset */
62262306a36Sopenharmony_ci#define MCFGR_WDENABLE		0x40000000 /* DECO watchdog enable */
62362306a36Sopenharmony_ci#define MCFGR_WDFAIL		0x20000000 /* DECO watchdog force-fail */
62462306a36Sopenharmony_ci#define MCFGR_DMA_RESET		0x10000000
62562306a36Sopenharmony_ci#define MCFGR_LONG_PTR		0x00010000 /* Use >32-bit desc addressing */
62662306a36Sopenharmony_ci#define SCFGR_RDBENABLE		0x00000400
62762306a36Sopenharmony_ci#define SCFGR_VIRT_EN		0x00008000
62862306a36Sopenharmony_ci#define DECORR_RQD0ENABLE	0x00000001 /* Enable DECO0 for direct access */
62962306a36Sopenharmony_ci#define DECORSR_JR0		0x00000001 /* JR to supply TZ, SDID, ICID */
63062306a36Sopenharmony_ci#define DECORSR_VALID		0x80000000
63162306a36Sopenharmony_ci#define DECORR_DEN0		0x00010000 /* DECO0 available for access*/
63262306a36Sopenharmony_ci
63362306a36Sopenharmony_ci/* AXI read cache control */
63462306a36Sopenharmony_ci#define MCFGR_ARCACHE_SHIFT	12
63562306a36Sopenharmony_ci#define MCFGR_ARCACHE_MASK	(0xf << MCFGR_ARCACHE_SHIFT)
63662306a36Sopenharmony_ci#define MCFGR_ARCACHE_BUFF	(0x1 << MCFGR_ARCACHE_SHIFT)
63762306a36Sopenharmony_ci#define MCFGR_ARCACHE_CACH	(0x2 << MCFGR_ARCACHE_SHIFT)
63862306a36Sopenharmony_ci#define MCFGR_ARCACHE_RALL	(0x4 << MCFGR_ARCACHE_SHIFT)
63962306a36Sopenharmony_ci
64062306a36Sopenharmony_ci/* AXI write cache control */
64162306a36Sopenharmony_ci#define MCFGR_AWCACHE_SHIFT	8
64262306a36Sopenharmony_ci#define MCFGR_AWCACHE_MASK	(0xf << MCFGR_AWCACHE_SHIFT)
64362306a36Sopenharmony_ci#define MCFGR_AWCACHE_BUFF	(0x1 << MCFGR_AWCACHE_SHIFT)
64462306a36Sopenharmony_ci#define MCFGR_AWCACHE_CACH	(0x2 << MCFGR_AWCACHE_SHIFT)
64562306a36Sopenharmony_ci#define MCFGR_AWCACHE_WALL	(0x8 << MCFGR_AWCACHE_SHIFT)
64662306a36Sopenharmony_ci
64762306a36Sopenharmony_ci/* AXI pipeline depth */
64862306a36Sopenharmony_ci#define MCFGR_AXIPIPE_SHIFT	4
64962306a36Sopenharmony_ci#define MCFGR_AXIPIPE_MASK	(0xf << MCFGR_AXIPIPE_SHIFT)
65062306a36Sopenharmony_ci
65162306a36Sopenharmony_ci#define MCFGR_AXIPRI		0x00000008 /* Assert AXI priority sideband */
65262306a36Sopenharmony_ci#define MCFGR_LARGE_BURST	0x00000004 /* 128/256-byte burst size */
65362306a36Sopenharmony_ci#define MCFGR_BURST_64		0x00000001 /* 64-byte burst size */
65462306a36Sopenharmony_ci
65562306a36Sopenharmony_ci/* JRSTART register offsets */
65662306a36Sopenharmony_ci#define JRSTART_JR0_START       0x00000001 /* Start Job ring 0 */
65762306a36Sopenharmony_ci#define JRSTART_JR1_START       0x00000002 /* Start Job ring 1 */
65862306a36Sopenharmony_ci#define JRSTART_JR2_START       0x00000004 /* Start Job ring 2 */
65962306a36Sopenharmony_ci#define JRSTART_JR3_START       0x00000008 /* Start Job ring 3 */
66062306a36Sopenharmony_ci
66162306a36Sopenharmony_ci/*
66262306a36Sopenharmony_ci * caam_job_ring - direct job ring setup
66362306a36Sopenharmony_ci * 1-4 possible per instantiation, base + 1000/2000/3000/4000
66462306a36Sopenharmony_ci * Padded out to 0x1000
66562306a36Sopenharmony_ci */
66662306a36Sopenharmony_cistruct caam_job_ring {
66762306a36Sopenharmony_ci	/* Input ring */
66862306a36Sopenharmony_ci	u64 inpring_base;	/* IRBAx -  Input desc ring baseaddr */
66962306a36Sopenharmony_ci	u32 rsvd1;
67062306a36Sopenharmony_ci	u32 inpring_size;	/* IRSx - Input ring size */
67162306a36Sopenharmony_ci	u32 rsvd2;
67262306a36Sopenharmony_ci	u32 inpring_avail;	/* IRSAx - Input ring room remaining */
67362306a36Sopenharmony_ci	u32 rsvd3;
67462306a36Sopenharmony_ci	u32 inpring_jobadd;	/* IRJAx - Input ring jobs added */
67562306a36Sopenharmony_ci
67662306a36Sopenharmony_ci	/* Output Ring */
67762306a36Sopenharmony_ci	u64 outring_base;	/* ORBAx - Output status ring base addr */
67862306a36Sopenharmony_ci	u32 rsvd4;
67962306a36Sopenharmony_ci	u32 outring_size;	/* ORSx - Output ring size */
68062306a36Sopenharmony_ci	u32 rsvd5;
68162306a36Sopenharmony_ci	u32 outring_rmvd;	/* ORJRx - Output ring jobs removed */
68262306a36Sopenharmony_ci	u32 rsvd6;
68362306a36Sopenharmony_ci	u32 outring_used;	/* ORSFx - Output ring slots full */
68462306a36Sopenharmony_ci
68562306a36Sopenharmony_ci	/* Status/Configuration */
68662306a36Sopenharmony_ci	u32 rsvd7;
68762306a36Sopenharmony_ci	u32 jroutstatus;	/* JRSTAx - JobR output status */
68862306a36Sopenharmony_ci	u32 rsvd8;
68962306a36Sopenharmony_ci	u32 jrintstatus;	/* JRINTx - JobR interrupt status */
69062306a36Sopenharmony_ci	u32 rconfig_hi;	/* JRxCFG - Ring configuration */
69162306a36Sopenharmony_ci	u32 rconfig_lo;
69262306a36Sopenharmony_ci
69362306a36Sopenharmony_ci	/* Indices. CAAM maintains as "heads" of each queue */
69462306a36Sopenharmony_ci	u32 rsvd9;
69562306a36Sopenharmony_ci	u32 inp_rdidx;	/* IRRIx - Input ring read index */
69662306a36Sopenharmony_ci	u32 rsvd10;
69762306a36Sopenharmony_ci	u32 out_wtidx;	/* ORWIx - Output ring write index */
69862306a36Sopenharmony_ci
69962306a36Sopenharmony_ci	/* Command/control */
70062306a36Sopenharmony_ci	u32 rsvd11;
70162306a36Sopenharmony_ci	u32 jrcommand;	/* JRCRx - JobR command */
70262306a36Sopenharmony_ci
70362306a36Sopenharmony_ci	u32 rsvd12[900];
70462306a36Sopenharmony_ci
70562306a36Sopenharmony_ci	/* Version registers - introduced with era 10           e80-eff */
70662306a36Sopenharmony_ci	struct version_regs vreg;
70762306a36Sopenharmony_ci	/* Performance Monitor                                  f00-fff */
70862306a36Sopenharmony_ci	struct caam_perfmon perfmon;
70962306a36Sopenharmony_ci};
71062306a36Sopenharmony_ci
71162306a36Sopenharmony_ci#define JR_RINGSIZE_MASK	0x03ff
71262306a36Sopenharmony_ci/*
71362306a36Sopenharmony_ci * jrstatus - Job Ring Output Status
71462306a36Sopenharmony_ci * All values in lo word
71562306a36Sopenharmony_ci * Also note, same values written out as status through QI
71662306a36Sopenharmony_ci * in the command/status field of a frame descriptor
71762306a36Sopenharmony_ci */
71862306a36Sopenharmony_ci#define JRSTA_SSRC_SHIFT            28
71962306a36Sopenharmony_ci#define JRSTA_SSRC_MASK             0xf0000000
72062306a36Sopenharmony_ci
72162306a36Sopenharmony_ci#define JRSTA_SSRC_NONE             0x00000000
72262306a36Sopenharmony_ci#define JRSTA_SSRC_CCB_ERROR        0x20000000
72362306a36Sopenharmony_ci#define JRSTA_SSRC_JUMP_HALT_USER   0x30000000
72462306a36Sopenharmony_ci#define JRSTA_SSRC_DECO             0x40000000
72562306a36Sopenharmony_ci#define JRSTA_SSRC_QI               0x50000000
72662306a36Sopenharmony_ci#define JRSTA_SSRC_JRERROR          0x60000000
72762306a36Sopenharmony_ci#define JRSTA_SSRC_JUMP_HALT_CC     0x70000000
72862306a36Sopenharmony_ci
72962306a36Sopenharmony_ci#define JRSTA_DECOERR_JUMP          0x08000000
73062306a36Sopenharmony_ci#define JRSTA_DECOERR_INDEX_SHIFT   8
73162306a36Sopenharmony_ci#define JRSTA_DECOERR_INDEX_MASK    0xff00
73262306a36Sopenharmony_ci#define JRSTA_DECOERR_ERROR_MASK    0x00ff
73362306a36Sopenharmony_ci
73462306a36Sopenharmony_ci#define JRSTA_DECOERR_NONE          0x00
73562306a36Sopenharmony_ci#define JRSTA_DECOERR_LINKLEN       0x01
73662306a36Sopenharmony_ci#define JRSTA_DECOERR_LINKPTR       0x02
73762306a36Sopenharmony_ci#define JRSTA_DECOERR_JRCTRL        0x03
73862306a36Sopenharmony_ci#define JRSTA_DECOERR_DESCCMD       0x04
73962306a36Sopenharmony_ci#define JRSTA_DECOERR_ORDER         0x05
74062306a36Sopenharmony_ci#define JRSTA_DECOERR_KEYCMD        0x06
74162306a36Sopenharmony_ci#define JRSTA_DECOERR_LOADCMD       0x07
74262306a36Sopenharmony_ci#define JRSTA_DECOERR_STORECMD      0x08
74362306a36Sopenharmony_ci#define JRSTA_DECOERR_OPCMD         0x09
74462306a36Sopenharmony_ci#define JRSTA_DECOERR_FIFOLDCMD     0x0a
74562306a36Sopenharmony_ci#define JRSTA_DECOERR_FIFOSTCMD     0x0b
74662306a36Sopenharmony_ci#define JRSTA_DECOERR_MOVECMD       0x0c
74762306a36Sopenharmony_ci#define JRSTA_DECOERR_JUMPCMD       0x0d
74862306a36Sopenharmony_ci#define JRSTA_DECOERR_MATHCMD       0x0e
74962306a36Sopenharmony_ci#define JRSTA_DECOERR_SHASHCMD      0x0f
75062306a36Sopenharmony_ci#define JRSTA_DECOERR_SEQCMD        0x10
75162306a36Sopenharmony_ci#define JRSTA_DECOERR_DECOINTERNAL  0x11
75262306a36Sopenharmony_ci#define JRSTA_DECOERR_SHDESCHDR     0x12
75362306a36Sopenharmony_ci#define JRSTA_DECOERR_HDRLEN        0x13
75462306a36Sopenharmony_ci#define JRSTA_DECOERR_BURSTER       0x14
75562306a36Sopenharmony_ci#define JRSTA_DECOERR_DESCSIGNATURE 0x15
75662306a36Sopenharmony_ci#define JRSTA_DECOERR_DMA           0x16
75762306a36Sopenharmony_ci#define JRSTA_DECOERR_BURSTFIFO     0x17
75862306a36Sopenharmony_ci#define JRSTA_DECOERR_JRRESET       0x1a
75962306a36Sopenharmony_ci#define JRSTA_DECOERR_JOBFAIL       0x1b
76062306a36Sopenharmony_ci#define JRSTA_DECOERR_DNRERR        0x80
76162306a36Sopenharmony_ci#define JRSTA_DECOERR_UNDEFPCL      0x81
76262306a36Sopenharmony_ci#define JRSTA_DECOERR_PDBERR        0x82
76362306a36Sopenharmony_ci#define JRSTA_DECOERR_ANRPLY_LATE   0x83
76462306a36Sopenharmony_ci#define JRSTA_DECOERR_ANRPLY_REPLAY 0x84
76562306a36Sopenharmony_ci#define JRSTA_DECOERR_SEQOVF        0x85
76662306a36Sopenharmony_ci#define JRSTA_DECOERR_INVSIGN       0x86
76762306a36Sopenharmony_ci#define JRSTA_DECOERR_DSASIGN       0x87
76862306a36Sopenharmony_ci
76962306a36Sopenharmony_ci#define JRSTA_QIERR_ERROR_MASK      0x00ff
77062306a36Sopenharmony_ci
77162306a36Sopenharmony_ci#define JRSTA_CCBERR_JUMP           0x08000000
77262306a36Sopenharmony_ci#define JRSTA_CCBERR_INDEX_MASK     0xff00
77362306a36Sopenharmony_ci#define JRSTA_CCBERR_INDEX_SHIFT    8
77462306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_MASK     0x00f0
77562306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_SHIFT    4
77662306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_MASK     0x000f
77762306a36Sopenharmony_ci
77862306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_AES      (0x01 << JRSTA_CCBERR_CHAID_SHIFT)
77962306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_DES      (0x02 << JRSTA_CCBERR_CHAID_SHIFT)
78062306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_ARC4     (0x03 << JRSTA_CCBERR_CHAID_SHIFT)
78162306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_MD       (0x04 << JRSTA_CCBERR_CHAID_SHIFT)
78262306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_RNG      (0x05 << JRSTA_CCBERR_CHAID_SHIFT)
78362306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_SNOW     (0x06 << JRSTA_CCBERR_CHAID_SHIFT)
78462306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_KASUMI   (0x07 << JRSTA_CCBERR_CHAID_SHIFT)
78562306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_PK       (0x08 << JRSTA_CCBERR_CHAID_SHIFT)
78662306a36Sopenharmony_ci#define JRSTA_CCBERR_CHAID_CRC      (0x09 << JRSTA_CCBERR_CHAID_SHIFT)
78762306a36Sopenharmony_ci
78862306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_NONE     0x00
78962306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_MODE     0x01
79062306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_DATASIZ  0x02
79162306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_KEYSIZ   0x03
79262306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_PKAMEMSZ 0x04
79362306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_PKBMEMSZ 0x05
79462306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_SEQUENCE 0x06
79562306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_PKDIVZRO 0x07
79662306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_PKMODEVN 0x08
79762306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_KEYPARIT 0x09
79862306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_ICVCHK   0x0a
79962306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_HARDWARE 0x0b
80062306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_CCMAAD   0x0c
80162306a36Sopenharmony_ci#define JRSTA_CCBERR_ERRID_INVCHA   0x0f
80262306a36Sopenharmony_ci
80362306a36Sopenharmony_ci#define JRINT_ERR_INDEX_MASK        0x3fff0000
80462306a36Sopenharmony_ci#define JRINT_ERR_INDEX_SHIFT       16
80562306a36Sopenharmony_ci#define JRINT_ERR_TYPE_MASK         0xf00
80662306a36Sopenharmony_ci#define JRINT_ERR_TYPE_SHIFT        8
80762306a36Sopenharmony_ci#define JRINT_ERR_HALT_MASK         0xc
80862306a36Sopenharmony_ci#define JRINT_ERR_HALT_SHIFT        2
80962306a36Sopenharmony_ci#define JRINT_ERR_HALT_INPROGRESS   0x4
81062306a36Sopenharmony_ci#define JRINT_ERR_HALT_COMPLETE     0x8
81162306a36Sopenharmony_ci#define JRINT_JR_ERROR              0x02
81262306a36Sopenharmony_ci#define JRINT_JR_INT                0x01
81362306a36Sopenharmony_ci
81462306a36Sopenharmony_ci#define JRINT_ERR_TYPE_WRITE        1
81562306a36Sopenharmony_ci#define JRINT_ERR_TYPE_BAD_INPADDR  3
81662306a36Sopenharmony_ci#define JRINT_ERR_TYPE_BAD_OUTADDR  4
81762306a36Sopenharmony_ci#define JRINT_ERR_TYPE_INV_INPWRT   5
81862306a36Sopenharmony_ci#define JRINT_ERR_TYPE_INV_OUTWRT   6
81962306a36Sopenharmony_ci#define JRINT_ERR_TYPE_RESET        7
82062306a36Sopenharmony_ci#define JRINT_ERR_TYPE_REMOVE_OFL   8
82162306a36Sopenharmony_ci#define JRINT_ERR_TYPE_ADD_OFL      9
82262306a36Sopenharmony_ci
82362306a36Sopenharmony_ci#define JRCFG_SOE		0x04
82462306a36Sopenharmony_ci#define JRCFG_ICEN		0x02
82562306a36Sopenharmony_ci#define JRCFG_IMSK		0x01
82662306a36Sopenharmony_ci#define JRCFG_ICDCT_SHIFT	8
82762306a36Sopenharmony_ci#define JRCFG_ICTT_SHIFT	16
82862306a36Sopenharmony_ci
82962306a36Sopenharmony_ci#define JRCR_RESET                  0x01
83062306a36Sopenharmony_ci
83162306a36Sopenharmony_ci/*
83262306a36Sopenharmony_ci * caam_assurance - Assurance Controller View
83362306a36Sopenharmony_ci * base + 0x6000 padded out to 0x1000
83462306a36Sopenharmony_ci */
83562306a36Sopenharmony_ci
83662306a36Sopenharmony_cistruct rtic_element {
83762306a36Sopenharmony_ci	u64 address;
83862306a36Sopenharmony_ci	u32 rsvd;
83962306a36Sopenharmony_ci	u32 length;
84062306a36Sopenharmony_ci};
84162306a36Sopenharmony_ci
84262306a36Sopenharmony_cistruct rtic_block {
84362306a36Sopenharmony_ci	struct rtic_element element[2];
84462306a36Sopenharmony_ci};
84562306a36Sopenharmony_ci
84662306a36Sopenharmony_cistruct rtic_memhash {
84762306a36Sopenharmony_ci	u32 memhash_be[32];
84862306a36Sopenharmony_ci	u32 memhash_le[32];
84962306a36Sopenharmony_ci};
85062306a36Sopenharmony_ci
85162306a36Sopenharmony_cistruct caam_assurance {
85262306a36Sopenharmony_ci    /* Status/Command/Watchdog */
85362306a36Sopenharmony_ci	u32 rsvd1;
85462306a36Sopenharmony_ci	u32 status;		/* RSTA - Status */
85562306a36Sopenharmony_ci	u32 rsvd2;
85662306a36Sopenharmony_ci	u32 cmd;		/* RCMD - Command */
85762306a36Sopenharmony_ci	u32 rsvd3;
85862306a36Sopenharmony_ci	u32 ctrl;		/* RCTL - Control */
85962306a36Sopenharmony_ci	u32 rsvd4;
86062306a36Sopenharmony_ci	u32 throttle;	/* RTHR - Throttle */
86162306a36Sopenharmony_ci	u32 rsvd5[2];
86262306a36Sopenharmony_ci	u64 watchdog;	/* RWDOG - Watchdog Timer */
86362306a36Sopenharmony_ci	u32 rsvd6;
86462306a36Sopenharmony_ci	u32 rend;		/* REND - Endian corrections */
86562306a36Sopenharmony_ci	u32 rsvd7[50];
86662306a36Sopenharmony_ci
86762306a36Sopenharmony_ci	/* Block access/configuration @ 100/110/120/130 */
86862306a36Sopenharmony_ci	struct rtic_block memblk[4];	/* Memory Blocks A-D */
86962306a36Sopenharmony_ci	u32 rsvd8[32];
87062306a36Sopenharmony_ci
87162306a36Sopenharmony_ci	/* Block hashes @ 200/300/400/500 */
87262306a36Sopenharmony_ci	struct rtic_memhash hash[4];	/* Block hash values A-D */
87362306a36Sopenharmony_ci	u32 rsvd_3[640];
87462306a36Sopenharmony_ci};
87562306a36Sopenharmony_ci
87662306a36Sopenharmony_ci/*
87762306a36Sopenharmony_ci * caam_queue_if - QI configuration and control
87862306a36Sopenharmony_ci * starts base + 0x7000, padded out to 0x1000 long
87962306a36Sopenharmony_ci */
88062306a36Sopenharmony_ci
88162306a36Sopenharmony_cistruct caam_queue_if {
88262306a36Sopenharmony_ci	u32 qi_control_hi;	/* QICTL  - QI Control */
88362306a36Sopenharmony_ci	u32 qi_control_lo;
88462306a36Sopenharmony_ci	u32 rsvd1;
88562306a36Sopenharmony_ci	u32 qi_status;	/* QISTA  - QI Status */
88662306a36Sopenharmony_ci	u32 qi_deq_cfg_hi;	/* QIDQC  - QI Dequeue Configuration */
88762306a36Sopenharmony_ci	u32 qi_deq_cfg_lo;
88862306a36Sopenharmony_ci	u32 qi_enq_cfg_hi;	/* QISEQC - QI Enqueue Command     */
88962306a36Sopenharmony_ci	u32 qi_enq_cfg_lo;
89062306a36Sopenharmony_ci	u32 rsvd2[1016];
89162306a36Sopenharmony_ci};
89262306a36Sopenharmony_ci
89362306a36Sopenharmony_ci/* QI control bits - low word */
89462306a36Sopenharmony_ci#define QICTL_DQEN      0x01              /* Enable frame pop          */
89562306a36Sopenharmony_ci#define QICTL_STOP      0x02              /* Stop dequeue/enqueue      */
89662306a36Sopenharmony_ci#define QICTL_SOE       0x04              /* Stop on error             */
89762306a36Sopenharmony_ci
89862306a36Sopenharmony_ci/* QI control bits - high word */
89962306a36Sopenharmony_ci#define QICTL_MBSI	0x01
90062306a36Sopenharmony_ci#define QICTL_MHWSI	0x02
90162306a36Sopenharmony_ci#define QICTL_MWSI	0x04
90262306a36Sopenharmony_ci#define QICTL_MDWSI	0x08
90362306a36Sopenharmony_ci#define QICTL_CBSI	0x10		/* CtrlDataByteSwapInput     */
90462306a36Sopenharmony_ci#define QICTL_CHWSI	0x20		/* CtrlDataHalfSwapInput     */
90562306a36Sopenharmony_ci#define QICTL_CWSI	0x40		/* CtrlDataWordSwapInput     */
90662306a36Sopenharmony_ci#define QICTL_CDWSI	0x80		/* CtrlDataDWordSwapInput    */
90762306a36Sopenharmony_ci#define QICTL_MBSO	0x0100
90862306a36Sopenharmony_ci#define QICTL_MHWSO	0x0200
90962306a36Sopenharmony_ci#define QICTL_MWSO	0x0400
91062306a36Sopenharmony_ci#define QICTL_MDWSO	0x0800
91162306a36Sopenharmony_ci#define QICTL_CBSO	0x1000		/* CtrlDataByteSwapOutput    */
91262306a36Sopenharmony_ci#define QICTL_CHWSO	0x2000		/* CtrlDataHalfSwapOutput    */
91362306a36Sopenharmony_ci#define QICTL_CWSO	0x4000		/* CtrlDataWordSwapOutput    */
91462306a36Sopenharmony_ci#define QICTL_CDWSO     0x8000		/* CtrlDataDWordSwapOutput   */
91562306a36Sopenharmony_ci#define QICTL_DMBS	0x010000
91662306a36Sopenharmony_ci#define QICTL_EPO	0x020000
91762306a36Sopenharmony_ci
91862306a36Sopenharmony_ci/* QI status bits */
91962306a36Sopenharmony_ci#define QISTA_PHRDERR   0x01              /* PreHeader Read Error      */
92062306a36Sopenharmony_ci#define QISTA_CFRDERR   0x02              /* Compound Frame Read Error */
92162306a36Sopenharmony_ci#define QISTA_OFWRERR   0x04              /* Output Frame Read Error   */
92262306a36Sopenharmony_ci#define QISTA_BPDERR    0x08              /* Buffer Pool Depleted      */
92362306a36Sopenharmony_ci#define QISTA_BTSERR    0x10              /* Buffer Undersize          */
92462306a36Sopenharmony_ci#define QISTA_CFWRERR   0x20              /* Compound Frame Write Err  */
92562306a36Sopenharmony_ci#define QISTA_STOPD     0x80000000        /* QI Stopped (see QICTL)    */
92662306a36Sopenharmony_ci
92762306a36Sopenharmony_ci/* deco_sg_table - DECO view of scatter/gather table */
92862306a36Sopenharmony_cistruct deco_sg_table {
92962306a36Sopenharmony_ci	u64 addr;		/* Segment Address */
93062306a36Sopenharmony_ci	u32 elen;		/* E, F bits + 30-bit length */
93162306a36Sopenharmony_ci	u32 bpid_offset;	/* Buffer Pool ID + 16-bit length */
93262306a36Sopenharmony_ci};
93362306a36Sopenharmony_ci
93462306a36Sopenharmony_ci/*
93562306a36Sopenharmony_ci * caam_deco - descriptor controller - CHA cluster block
93662306a36Sopenharmony_ci *
93762306a36Sopenharmony_ci * Only accessible when direct DECO access is turned on
93862306a36Sopenharmony_ci * (done in DECORR, via MID programmed in DECOxMID
93962306a36Sopenharmony_ci *
94062306a36Sopenharmony_ci * 5 typical, base + 0x8000/9000/a000/b000
94162306a36Sopenharmony_ci * Padded out to 0x1000 long
94262306a36Sopenharmony_ci */
94362306a36Sopenharmony_cistruct caam_deco {
94462306a36Sopenharmony_ci	u32 rsvd1;
94562306a36Sopenharmony_ci	u32 cls1_mode;	/* CxC1MR -  Class 1 Mode */
94662306a36Sopenharmony_ci	u32 rsvd2;
94762306a36Sopenharmony_ci	u32 cls1_keysize;	/* CxC1KSR - Class 1 Key Size */
94862306a36Sopenharmony_ci	u32 cls1_datasize_hi;	/* CxC1DSR - Class 1 Data Size */
94962306a36Sopenharmony_ci	u32 cls1_datasize_lo;
95062306a36Sopenharmony_ci	u32 rsvd3;
95162306a36Sopenharmony_ci	u32 cls1_icvsize;	/* CxC1ICVSR - Class 1 ICV size */
95262306a36Sopenharmony_ci	u32 rsvd4[5];
95362306a36Sopenharmony_ci	u32 cha_ctrl;	/* CCTLR - CHA control */
95462306a36Sopenharmony_ci	u32 rsvd5;
95562306a36Sopenharmony_ci	u32 irq_crtl;	/* CxCIRQ - CCB interrupt done/error/clear */
95662306a36Sopenharmony_ci	u32 rsvd6;
95762306a36Sopenharmony_ci	u32 clr_written;	/* CxCWR - Clear-Written */
95862306a36Sopenharmony_ci	u32 ccb_status_hi;	/* CxCSTA - CCB Status/Error */
95962306a36Sopenharmony_ci	u32 ccb_status_lo;
96062306a36Sopenharmony_ci	u32 rsvd7[3];
96162306a36Sopenharmony_ci	u32 aad_size;	/* CxAADSZR - Current AAD Size */
96262306a36Sopenharmony_ci	u32 rsvd8;
96362306a36Sopenharmony_ci	u32 cls1_iv_size;	/* CxC1IVSZR - Current Class 1 IV Size */
96462306a36Sopenharmony_ci	u32 rsvd9[7];
96562306a36Sopenharmony_ci	u32 pkha_a_size;	/* PKASZRx - Size of PKHA A */
96662306a36Sopenharmony_ci	u32 rsvd10;
96762306a36Sopenharmony_ci	u32 pkha_b_size;	/* PKBSZRx - Size of PKHA B */
96862306a36Sopenharmony_ci	u32 rsvd11;
96962306a36Sopenharmony_ci	u32 pkha_n_size;	/* PKNSZRx - Size of PKHA N */
97062306a36Sopenharmony_ci	u32 rsvd12;
97162306a36Sopenharmony_ci	u32 pkha_e_size;	/* PKESZRx - Size of PKHA E */
97262306a36Sopenharmony_ci	u32 rsvd13[24];
97362306a36Sopenharmony_ci	u32 cls1_ctx[16];	/* CxC1CTXR - Class 1 Context @100 */
97462306a36Sopenharmony_ci	u32 rsvd14[48];
97562306a36Sopenharmony_ci	u32 cls1_key[8];	/* CxC1KEYR - Class 1 Key @200 */
97662306a36Sopenharmony_ci	u32 rsvd15[121];
97762306a36Sopenharmony_ci	u32 cls2_mode;	/* CxC2MR - Class 2 Mode */
97862306a36Sopenharmony_ci	u32 rsvd16;
97962306a36Sopenharmony_ci	u32 cls2_keysize;	/* CxX2KSR - Class 2 Key Size */
98062306a36Sopenharmony_ci	u32 cls2_datasize_hi;	/* CxC2DSR - Class 2 Data Size */
98162306a36Sopenharmony_ci	u32 cls2_datasize_lo;
98262306a36Sopenharmony_ci	u32 rsvd17;
98362306a36Sopenharmony_ci	u32 cls2_icvsize;	/* CxC2ICVSZR - Class 2 ICV Size */
98462306a36Sopenharmony_ci	u32 rsvd18[56];
98562306a36Sopenharmony_ci	u32 cls2_ctx[18];	/* CxC2CTXR - Class 2 Context @500 */
98662306a36Sopenharmony_ci	u32 rsvd19[46];
98762306a36Sopenharmony_ci	u32 cls2_key[32];	/* CxC2KEYR - Class2 Key @600 */
98862306a36Sopenharmony_ci	u32 rsvd20[84];
98962306a36Sopenharmony_ci	u32 inp_infofifo_hi;	/* CxIFIFO - Input Info FIFO @7d0 */
99062306a36Sopenharmony_ci	u32 inp_infofifo_lo;
99162306a36Sopenharmony_ci	u32 rsvd21[2];
99262306a36Sopenharmony_ci	u64 inp_datafifo;	/* CxDFIFO - Input Data FIFO */
99362306a36Sopenharmony_ci	u32 rsvd22[2];
99462306a36Sopenharmony_ci	u64 out_datafifo;	/* CxOFIFO - Output Data FIFO */
99562306a36Sopenharmony_ci	u32 rsvd23[2];
99662306a36Sopenharmony_ci	u32 jr_ctl_hi;	/* CxJRR - JobR Control Register      @800 */
99762306a36Sopenharmony_ci	u32 jr_ctl_lo;
99862306a36Sopenharmony_ci	u64 jr_descaddr;	/* CxDADR - JobR Descriptor Address */
99962306a36Sopenharmony_ci#define DECO_OP_STATUS_HI_ERR_MASK 0xF00000FF
100062306a36Sopenharmony_ci	u32 op_status_hi;	/* DxOPSTA - DECO Operation Status */
100162306a36Sopenharmony_ci	u32 op_status_lo;
100262306a36Sopenharmony_ci	u32 rsvd24[2];
100362306a36Sopenharmony_ci	u32 liodn;		/* DxLSR - DECO LIODN Status - non-seq */
100462306a36Sopenharmony_ci	u32 td_liodn;	/* DxLSR - DECO LIODN Status - trustdesc */
100562306a36Sopenharmony_ci	u32 rsvd26[6];
100662306a36Sopenharmony_ci	u64 math[4];		/* DxMTH - Math register */
100762306a36Sopenharmony_ci	u32 rsvd27[8];
100862306a36Sopenharmony_ci	struct deco_sg_table gthr_tbl[4];	/* DxGTR - Gather Tables */
100962306a36Sopenharmony_ci	u32 rsvd28[16];
101062306a36Sopenharmony_ci	struct deco_sg_table sctr_tbl[4];	/* DxSTR - Scatter Tables */
101162306a36Sopenharmony_ci	u32 rsvd29[48];
101262306a36Sopenharmony_ci	u32 descbuf[64];	/* DxDESB - Descriptor buffer */
101362306a36Sopenharmony_ci	u32 rscvd30[193];
101462306a36Sopenharmony_ci#define DESC_DBG_DECO_STAT_VALID	0x80000000
101562306a36Sopenharmony_ci#define DESC_DBG_DECO_STAT_MASK		0x00F00000
101662306a36Sopenharmony_ci#define DESC_DBG_DECO_STAT_SHIFT	20
101762306a36Sopenharmony_ci	u32 desc_dbg;		/* DxDDR - DECO Debug Register */
101862306a36Sopenharmony_ci	u32 rsvd31[13];
101962306a36Sopenharmony_ci#define DESC_DER_DECO_STAT_MASK		0x000F0000
102062306a36Sopenharmony_ci#define DESC_DER_DECO_STAT_SHIFT	16
102162306a36Sopenharmony_ci	u32 dbg_exec;		/* DxDER - DECO Debug Exec Register */
102262306a36Sopenharmony_ci	u32 rsvd32[112];
102362306a36Sopenharmony_ci};
102462306a36Sopenharmony_ci
102562306a36Sopenharmony_ci#define DECO_STAT_HOST_ERR	0xD
102662306a36Sopenharmony_ci
102762306a36Sopenharmony_ci#define DECO_JQCR_WHL		0x20000000
102862306a36Sopenharmony_ci#define DECO_JQCR_FOUR		0x10000000
102962306a36Sopenharmony_ci
103062306a36Sopenharmony_ci#define JR_BLOCK_NUMBER		1
103162306a36Sopenharmony_ci#define ASSURE_BLOCK_NUMBER	6
103262306a36Sopenharmony_ci#define QI_BLOCK_NUMBER		7
103362306a36Sopenharmony_ci#define DECO_BLOCK_NUMBER	8
103462306a36Sopenharmony_ci#define PG_SIZE_4K		0x1000
103562306a36Sopenharmony_ci#define PG_SIZE_64K		0x10000
103662306a36Sopenharmony_ci#endif /* REGS_H */
1037