18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * CAAM hardware register-level view
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2008-2011 Freescale Semiconductor, Inc.
68c2ecf20Sopenharmony_ci * Copyright 2018 NXP
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef REGS_H
108c2ecf20Sopenharmony_ci#define REGS_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/types.h>
138c2ecf20Sopenharmony_ci#include <linux/bitops.h>
148c2ecf20Sopenharmony_ci#include <linux/io.h>
158c2ecf20Sopenharmony_ci#include <linux/io-64-nonatomic-hi-lo.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/*
188c2ecf20Sopenharmony_ci * Architecture-specific register access methods
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * CAAM's bus-addressable registers are 64 bits internally.
218c2ecf20Sopenharmony_ci * They have been wired to be safely accessible on 32-bit
228c2ecf20Sopenharmony_ci * architectures, however. Registers were organized such
238c2ecf20Sopenharmony_ci * that (a) they can be contained in 32 bits, (b) if not, then they
248c2ecf20Sopenharmony_ci * can be treated as two 32-bit entities, or finally (c) if they
258c2ecf20Sopenharmony_ci * must be treated as a single 64-bit value, then this can safely
268c2ecf20Sopenharmony_ci * be done with two 32-bit cycles.
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci * For 32-bit operations on 64-bit values, CAAM follows the same
298c2ecf20Sopenharmony_ci * 64-bit register access conventions as it's predecessors, in that
308c2ecf20Sopenharmony_ci * writes are "triggered" by a write to the register at the numerically
318c2ecf20Sopenharmony_ci * higher address, thus, a full 64-bit write cycle requires a write
328c2ecf20Sopenharmony_ci * to the lower address, followed by a write to the higher address,
338c2ecf20Sopenharmony_ci * which will latch/execute the write cycle.
348c2ecf20Sopenharmony_ci *
358c2ecf20Sopenharmony_ci * For example, let's assume a SW reset of CAAM through the master
368c2ecf20Sopenharmony_ci * configuration register.
378c2ecf20Sopenharmony_ci * - SWRST is in bit 31 of MCFG.
388c2ecf20Sopenharmony_ci * - MCFG begins at base+0x0000.
398c2ecf20Sopenharmony_ci * - Bits 63-32 are a 32-bit word at base+0x0000 (numerically-lower)
408c2ecf20Sopenharmony_ci * - Bits 31-0 are a 32-bit word at base+0x0004 (numerically-higher)
418c2ecf20Sopenharmony_ci *
428c2ecf20Sopenharmony_ci * (and on Power, the convention is 0-31, 32-63, I know...)
438c2ecf20Sopenharmony_ci *
448c2ecf20Sopenharmony_ci * Assuming a 64-bit write to this MCFG to perform a software reset
458c2ecf20Sopenharmony_ci * would then require a write of 0 to base+0x0000, followed by a
468c2ecf20Sopenharmony_ci * write of 0x80000000 to base+0x0004, which would "execute" the
478c2ecf20Sopenharmony_ci * reset.
488c2ecf20Sopenharmony_ci *
498c2ecf20Sopenharmony_ci * Of course, since MCFG 63-32 is all zero, we could cheat and simply
508c2ecf20Sopenharmony_ci * write 0x8000000 to base+0x0004, and the reset would work fine.
518c2ecf20Sopenharmony_ci * However, since CAAM does contain some write-and-read-intended
528c2ecf20Sopenharmony_ci * 64-bit registers, this code defines 64-bit access methods for
538c2ecf20Sopenharmony_ci * the sake of internal consistency and simplicity, and so that a
548c2ecf20Sopenharmony_ci * clean transition to 64-bit is possible when it becomes necessary.
558c2ecf20Sopenharmony_ci *
568c2ecf20Sopenharmony_ci * There are limitations to this that the developer must recognize.
578c2ecf20Sopenharmony_ci * 32-bit architectures cannot enforce an atomic-64 operation,
588c2ecf20Sopenharmony_ci * Therefore:
598c2ecf20Sopenharmony_ci *
608c2ecf20Sopenharmony_ci * - On writes, since the HW is assumed to latch the cycle on the
618c2ecf20Sopenharmony_ci *   write of the higher-numeric-address word, then ordered
628c2ecf20Sopenharmony_ci *   writes work OK.
638c2ecf20Sopenharmony_ci *
648c2ecf20Sopenharmony_ci * - For reads, where a register contains a relevant value of more
658c2ecf20Sopenharmony_ci *   that 32 bits, the hardware employs logic to latch the other
668c2ecf20Sopenharmony_ci *   "half" of the data until read, ensuring an accurate value.
678c2ecf20Sopenharmony_ci *   This is of particular relevance when dealing with CAAM's
688c2ecf20Sopenharmony_ci *   performance counters.
698c2ecf20Sopenharmony_ci *
708c2ecf20Sopenharmony_ci */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ciextern bool caam_little_end;
738c2ecf20Sopenharmony_ciextern bool caam_imx;
748c2ecf20Sopenharmony_ciextern size_t caam_ptr_sz;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#define caam_to_cpu(len)						\
778c2ecf20Sopenharmony_cistatic inline u##len caam##len ## _to_cpu(u##len val)			\
788c2ecf20Sopenharmony_ci{									\
798c2ecf20Sopenharmony_ci	if (caam_little_end)						\
808c2ecf20Sopenharmony_ci		return le##len ## _to_cpu((__force __le##len)val);	\
818c2ecf20Sopenharmony_ci	else								\
828c2ecf20Sopenharmony_ci		return be##len ## _to_cpu((__force __be##len)val);	\
838c2ecf20Sopenharmony_ci}
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define cpu_to_caam(len)					\
868c2ecf20Sopenharmony_cistatic inline u##len cpu_to_caam##len(u##len val)		\
878c2ecf20Sopenharmony_ci{								\
888c2ecf20Sopenharmony_ci	if (caam_little_end)					\
898c2ecf20Sopenharmony_ci		return (__force u##len)cpu_to_le##len(val);	\
908c2ecf20Sopenharmony_ci	else							\
918c2ecf20Sopenharmony_ci		return (__force u##len)cpu_to_be##len(val);	\
928c2ecf20Sopenharmony_ci}
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_cicaam_to_cpu(16)
958c2ecf20Sopenharmony_cicaam_to_cpu(32)
968c2ecf20Sopenharmony_cicaam_to_cpu(64)
978c2ecf20Sopenharmony_cicpu_to_caam(16)
988c2ecf20Sopenharmony_cicpu_to_caam(32)
998c2ecf20Sopenharmony_cicpu_to_caam(64)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_cistatic inline void wr_reg32(void __iomem *reg, u32 data)
1028c2ecf20Sopenharmony_ci{
1038c2ecf20Sopenharmony_ci	if (caam_little_end)
1048c2ecf20Sopenharmony_ci		iowrite32(data, reg);
1058c2ecf20Sopenharmony_ci	else
1068c2ecf20Sopenharmony_ci		iowrite32be(data, reg);
1078c2ecf20Sopenharmony_ci}
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_cistatic inline u32 rd_reg32(void __iomem *reg)
1108c2ecf20Sopenharmony_ci{
1118c2ecf20Sopenharmony_ci	if (caam_little_end)
1128c2ecf20Sopenharmony_ci		return ioread32(reg);
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci	return ioread32be(reg);
1158c2ecf20Sopenharmony_ci}
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_cistatic inline void clrsetbits_32(void __iomem *reg, u32 clear, u32 set)
1188c2ecf20Sopenharmony_ci{
1198c2ecf20Sopenharmony_ci	if (caam_little_end)
1208c2ecf20Sopenharmony_ci		iowrite32((ioread32(reg) & ~clear) | set, reg);
1218c2ecf20Sopenharmony_ci	else
1228c2ecf20Sopenharmony_ci		iowrite32be((ioread32be(reg) & ~clear) | set, reg);
1238c2ecf20Sopenharmony_ci}
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci/*
1268c2ecf20Sopenharmony_ci * The only users of these wr/rd_reg64 functions is the Job Ring (JR).
1278c2ecf20Sopenharmony_ci * The DMA address registers in the JR are handled differently depending on
1288c2ecf20Sopenharmony_ci * platform:
1298c2ecf20Sopenharmony_ci *
1308c2ecf20Sopenharmony_ci * 1. All BE CAAM platforms and i.MX platforms (LE CAAM):
1318c2ecf20Sopenharmony_ci *
1328c2ecf20Sopenharmony_ci *    base + 0x0000 : most-significant 32 bits
1338c2ecf20Sopenharmony_ci *    base + 0x0004 : least-significant 32 bits
1348c2ecf20Sopenharmony_ci *
1358c2ecf20Sopenharmony_ci * The 32-bit version of this core therefore has to write to base + 0x0004
1368c2ecf20Sopenharmony_ci * to set the 32-bit wide DMA address.
1378c2ecf20Sopenharmony_ci *
1388c2ecf20Sopenharmony_ci * 2. All other LE CAAM platforms (LS1021A etc.)
1398c2ecf20Sopenharmony_ci *    base + 0x0000 : least-significant 32 bits
1408c2ecf20Sopenharmony_ci *    base + 0x0004 : most-significant 32 bits
1418c2ecf20Sopenharmony_ci */
1428c2ecf20Sopenharmony_cistatic inline void wr_reg64(void __iomem *reg, u64 data)
1438c2ecf20Sopenharmony_ci{
1448c2ecf20Sopenharmony_ci	if (caam_little_end) {
1458c2ecf20Sopenharmony_ci		if (caam_imx) {
1468c2ecf20Sopenharmony_ci			iowrite32(data >> 32, (u32 __iomem *)(reg));
1478c2ecf20Sopenharmony_ci			iowrite32(data, (u32 __iomem *)(reg) + 1);
1488c2ecf20Sopenharmony_ci		} else {
1498c2ecf20Sopenharmony_ci			iowrite64(data, reg);
1508c2ecf20Sopenharmony_ci		}
1518c2ecf20Sopenharmony_ci	} else {
1528c2ecf20Sopenharmony_ci		iowrite64be(data, reg);
1538c2ecf20Sopenharmony_ci	}
1548c2ecf20Sopenharmony_ci}
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_cistatic inline u64 rd_reg64(void __iomem *reg)
1578c2ecf20Sopenharmony_ci{
1588c2ecf20Sopenharmony_ci	if (caam_little_end) {
1598c2ecf20Sopenharmony_ci		if (caam_imx) {
1608c2ecf20Sopenharmony_ci			u32 low, high;
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci			high = ioread32(reg);
1638c2ecf20Sopenharmony_ci			low  = ioread32(reg + sizeof(u32));
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci			return low + ((u64)high << 32);
1668c2ecf20Sopenharmony_ci		} else {
1678c2ecf20Sopenharmony_ci			return ioread64(reg);
1688c2ecf20Sopenharmony_ci		}
1698c2ecf20Sopenharmony_ci	} else {
1708c2ecf20Sopenharmony_ci		return ioread64be(reg);
1718c2ecf20Sopenharmony_ci	}
1728c2ecf20Sopenharmony_ci}
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_cistatic inline u64 cpu_to_caam_dma64(dma_addr_t value)
1758c2ecf20Sopenharmony_ci{
1768c2ecf20Sopenharmony_ci	if (caam_imx) {
1778c2ecf20Sopenharmony_ci		u64 ret_val = (u64)cpu_to_caam32(lower_32_bits(value)) << 32;
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci		if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
1808c2ecf20Sopenharmony_ci			ret_val |= (u64)cpu_to_caam32(upper_32_bits(value));
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci		return ret_val;
1838c2ecf20Sopenharmony_ci	}
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci	return cpu_to_caam64(value);
1868c2ecf20Sopenharmony_ci}
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_cistatic inline u64 caam_dma64_to_cpu(u64 value)
1898c2ecf20Sopenharmony_ci{
1908c2ecf20Sopenharmony_ci	if (caam_imx)
1918c2ecf20Sopenharmony_ci		return (((u64)caam32_to_cpu(lower_32_bits(value)) << 32) |
1928c2ecf20Sopenharmony_ci			 (u64)caam32_to_cpu(upper_32_bits(value)));
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	return caam64_to_cpu(value);
1958c2ecf20Sopenharmony_ci}
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_cistatic inline u64 cpu_to_caam_dma(u64 value)
1988c2ecf20Sopenharmony_ci{
1998c2ecf20Sopenharmony_ci	if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
2008c2ecf20Sopenharmony_ci	    caam_ptr_sz == sizeof(u64))
2018c2ecf20Sopenharmony_ci		return cpu_to_caam_dma64(value);
2028c2ecf20Sopenharmony_ci	else
2038c2ecf20Sopenharmony_ci		return cpu_to_caam32(value);
2048c2ecf20Sopenharmony_ci}
2058c2ecf20Sopenharmony_ci
2068c2ecf20Sopenharmony_cistatic inline u64 caam_dma_to_cpu(u64 value)
2078c2ecf20Sopenharmony_ci{
2088c2ecf20Sopenharmony_ci	if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
2098c2ecf20Sopenharmony_ci	    caam_ptr_sz == sizeof(u64))
2108c2ecf20Sopenharmony_ci		return caam_dma64_to_cpu(value);
2118c2ecf20Sopenharmony_ci	else
2128c2ecf20Sopenharmony_ci		return caam32_to_cpu(value);
2138c2ecf20Sopenharmony_ci}
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci/*
2168c2ecf20Sopenharmony_ci * jr_outentry
2178c2ecf20Sopenharmony_ci * Represents each entry in a JobR output ring
2188c2ecf20Sopenharmony_ci */
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_cistatic inline void jr_outentry_get(void *outring, int hw_idx, dma_addr_t *desc,
2218c2ecf20Sopenharmony_ci				   u32 *jrstatus)
2228c2ecf20Sopenharmony_ci{
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	if (caam_ptr_sz == sizeof(u32)) {
2258c2ecf20Sopenharmony_ci		struct {
2268c2ecf20Sopenharmony_ci			u32 desc;
2278c2ecf20Sopenharmony_ci			u32 jrstatus;
2288c2ecf20Sopenharmony_ci		} __packed *outentry = outring;
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ci		*desc = outentry[hw_idx].desc;
2318c2ecf20Sopenharmony_ci		*jrstatus = outentry[hw_idx].jrstatus;
2328c2ecf20Sopenharmony_ci	} else {
2338c2ecf20Sopenharmony_ci		struct {
2348c2ecf20Sopenharmony_ci			dma_addr_t desc;/* Pointer to completed descriptor */
2358c2ecf20Sopenharmony_ci			u32 jrstatus;	/* Status for completed descriptor */
2368c2ecf20Sopenharmony_ci		} __packed *outentry = outring;
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci		*desc = outentry[hw_idx].desc;
2398c2ecf20Sopenharmony_ci		*jrstatus = outentry[hw_idx].jrstatus;
2408c2ecf20Sopenharmony_ci	}
2418c2ecf20Sopenharmony_ci}
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci#define SIZEOF_JR_OUTENTRY	(caam_ptr_sz + sizeof(u32))
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_cistatic inline dma_addr_t jr_outentry_desc(void *outring, int hw_idx)
2468c2ecf20Sopenharmony_ci{
2478c2ecf20Sopenharmony_ci	dma_addr_t desc;
2488c2ecf20Sopenharmony_ci	u32 unused;
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci	jr_outentry_get(outring, hw_idx, &desc, &unused);
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci	return desc;
2538c2ecf20Sopenharmony_ci}
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_cistatic inline u32 jr_outentry_jrstatus(void *outring, int hw_idx)
2568c2ecf20Sopenharmony_ci{
2578c2ecf20Sopenharmony_ci	dma_addr_t unused;
2588c2ecf20Sopenharmony_ci	u32 jrstatus;
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci	jr_outentry_get(outring, hw_idx, &unused, &jrstatus);
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci	return jrstatus;
2638c2ecf20Sopenharmony_ci}
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistatic inline void jr_inpentry_set(void *inpring, int hw_idx, dma_addr_t val)
2668c2ecf20Sopenharmony_ci{
2678c2ecf20Sopenharmony_ci	if (caam_ptr_sz == sizeof(u32)) {
2688c2ecf20Sopenharmony_ci		u32 *inpentry = inpring;
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_ci		inpentry[hw_idx] = val;
2718c2ecf20Sopenharmony_ci	} else {
2728c2ecf20Sopenharmony_ci		dma_addr_t *inpentry = inpring;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci		inpentry[hw_idx] = val;
2758c2ecf20Sopenharmony_ci	}
2768c2ecf20Sopenharmony_ci}
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci#define SIZEOF_JR_INPENTRY	caam_ptr_sz
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci/* Version registers (Era 10+)	e80-eff */
2828c2ecf20Sopenharmony_cistruct version_regs {
2838c2ecf20Sopenharmony_ci	u32 crca;	/* CRCA_VERSION */
2848c2ecf20Sopenharmony_ci	u32 afha;	/* AFHA_VERSION */
2858c2ecf20Sopenharmony_ci	u32 kfha;	/* KFHA_VERSION */
2868c2ecf20Sopenharmony_ci	u32 pkha;	/* PKHA_VERSION */
2878c2ecf20Sopenharmony_ci	u32 aesa;	/* AESA_VERSION */
2888c2ecf20Sopenharmony_ci	u32 mdha;	/* MDHA_VERSION */
2898c2ecf20Sopenharmony_ci	u32 desa;	/* DESA_VERSION */
2908c2ecf20Sopenharmony_ci	u32 snw8a;	/* SNW8A_VERSION */
2918c2ecf20Sopenharmony_ci	u32 snw9a;	/* SNW9A_VERSION */
2928c2ecf20Sopenharmony_ci	u32 zuce;	/* ZUCE_VERSION */
2938c2ecf20Sopenharmony_ci	u32 zuca;	/* ZUCA_VERSION */
2948c2ecf20Sopenharmony_ci	u32 ccha;	/* CCHA_VERSION */
2958c2ecf20Sopenharmony_ci	u32 ptha;	/* PTHA_VERSION */
2968c2ecf20Sopenharmony_ci	u32 rng;	/* RNG_VERSION */
2978c2ecf20Sopenharmony_ci	u32 trng;	/* TRNG_VERSION */
2988c2ecf20Sopenharmony_ci	u32 aaha;	/* AAHA_VERSION */
2998c2ecf20Sopenharmony_ci	u32 rsvd[10];
3008c2ecf20Sopenharmony_ci	u32 sr;		/* SR_VERSION */
3018c2ecf20Sopenharmony_ci	u32 dma;	/* DMA_VERSION */
3028c2ecf20Sopenharmony_ci	u32 ai;		/* AI_VERSION */
3038c2ecf20Sopenharmony_ci	u32 qi;		/* QI_VERSION */
3048c2ecf20Sopenharmony_ci	u32 jr;		/* JR_VERSION */
3058c2ecf20Sopenharmony_ci	u32 deco;	/* DECO_VERSION */
3068c2ecf20Sopenharmony_ci};
3078c2ecf20Sopenharmony_ci
3088c2ecf20Sopenharmony_ci/* Version registers bitfields */
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci/* Number of CHAs instantiated */
3118c2ecf20Sopenharmony_ci#define CHA_VER_NUM_MASK	0xffull
3128c2ecf20Sopenharmony_ci/* CHA Miscellaneous Information */
3138c2ecf20Sopenharmony_ci#define CHA_VER_MISC_SHIFT	8
3148c2ecf20Sopenharmony_ci#define CHA_VER_MISC_MASK	(0xffull << CHA_VER_MISC_SHIFT)
3158c2ecf20Sopenharmony_ci/* CHA Revision Number */
3168c2ecf20Sopenharmony_ci#define CHA_VER_REV_SHIFT	16
3178c2ecf20Sopenharmony_ci#define CHA_VER_REV_MASK	(0xffull << CHA_VER_REV_SHIFT)
3188c2ecf20Sopenharmony_ci/* CHA Version ID */
3198c2ecf20Sopenharmony_ci#define CHA_VER_VID_SHIFT	24
3208c2ecf20Sopenharmony_ci#define CHA_VER_VID_MASK	(0xffull << CHA_VER_VID_SHIFT)
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci/* CHA Miscellaneous Information - AESA_MISC specific */
3238c2ecf20Sopenharmony_ci#define CHA_VER_MISC_AES_GCM	BIT(1 + CHA_VER_MISC_SHIFT)
3248c2ecf20Sopenharmony_ci
3258c2ecf20Sopenharmony_ci/* CHA Miscellaneous Information - PKHA_MISC specific */
3268c2ecf20Sopenharmony_ci#define CHA_VER_MISC_PKHA_NO_CRYPT	BIT(7 + CHA_VER_MISC_SHIFT)
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci/*
3298c2ecf20Sopenharmony_ci * caam_perfmon - Performance Monitor/Secure Memory Status/
3308c2ecf20Sopenharmony_ci *                CAAM Global Status/Component Version IDs
3318c2ecf20Sopenharmony_ci *
3328c2ecf20Sopenharmony_ci * Spans f00-fff wherever instantiated
3338c2ecf20Sopenharmony_ci */
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci/* Number of DECOs */
3368c2ecf20Sopenharmony_ci#define CHA_NUM_MS_DECONUM_SHIFT	24
3378c2ecf20Sopenharmony_ci#define CHA_NUM_MS_DECONUM_MASK	(0xfull << CHA_NUM_MS_DECONUM_SHIFT)
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_ci/*
3408c2ecf20Sopenharmony_ci * CHA version IDs / instantiation bitfields (< Era 10)
3418c2ecf20Sopenharmony_ci * Defined for use with the cha_id fields in perfmon, but the same shift/mask
3428c2ecf20Sopenharmony_ci * selectors can be used to pull out the number of instantiated blocks within
3438c2ecf20Sopenharmony_ci * cha_num fields in perfmon because the locations are the same.
3448c2ecf20Sopenharmony_ci */
3458c2ecf20Sopenharmony_ci#define CHA_ID_LS_AES_SHIFT	0
3468c2ecf20Sopenharmony_ci#define CHA_ID_LS_AES_MASK	(0xfull << CHA_ID_LS_AES_SHIFT)
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_ci#define CHA_ID_LS_DES_SHIFT	4
3498c2ecf20Sopenharmony_ci#define CHA_ID_LS_DES_MASK	(0xfull << CHA_ID_LS_DES_SHIFT)
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci#define CHA_ID_LS_ARC4_SHIFT	8
3528c2ecf20Sopenharmony_ci#define CHA_ID_LS_ARC4_MASK	(0xfull << CHA_ID_LS_ARC4_SHIFT)
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci#define CHA_ID_LS_MD_SHIFT	12
3558c2ecf20Sopenharmony_ci#define CHA_ID_LS_MD_MASK	(0xfull << CHA_ID_LS_MD_SHIFT)
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci#define CHA_ID_LS_RNG_SHIFT	16
3588c2ecf20Sopenharmony_ci#define CHA_ID_LS_RNG_MASK	(0xfull << CHA_ID_LS_RNG_SHIFT)
3598c2ecf20Sopenharmony_ci
3608c2ecf20Sopenharmony_ci#define CHA_ID_LS_SNW8_SHIFT	20
3618c2ecf20Sopenharmony_ci#define CHA_ID_LS_SNW8_MASK	(0xfull << CHA_ID_LS_SNW8_SHIFT)
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_ci#define CHA_ID_LS_KAS_SHIFT	24
3648c2ecf20Sopenharmony_ci#define CHA_ID_LS_KAS_MASK	(0xfull << CHA_ID_LS_KAS_SHIFT)
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_ci#define CHA_ID_LS_PK_SHIFT	28
3678c2ecf20Sopenharmony_ci#define CHA_ID_LS_PK_MASK	(0xfull << CHA_ID_LS_PK_SHIFT)
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_ci#define CHA_ID_MS_CRC_SHIFT	0
3708c2ecf20Sopenharmony_ci#define CHA_ID_MS_CRC_MASK	(0xfull << CHA_ID_MS_CRC_SHIFT)
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci#define CHA_ID_MS_SNW9_SHIFT	4
3738c2ecf20Sopenharmony_ci#define CHA_ID_MS_SNW9_MASK	(0xfull << CHA_ID_MS_SNW9_SHIFT)
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci#define CHA_ID_MS_DECO_SHIFT	24
3768c2ecf20Sopenharmony_ci#define CHA_ID_MS_DECO_MASK	(0xfull << CHA_ID_MS_DECO_SHIFT)
3778c2ecf20Sopenharmony_ci
3788c2ecf20Sopenharmony_ci#define CHA_ID_MS_JR_SHIFT	28
3798c2ecf20Sopenharmony_ci#define CHA_ID_MS_JR_MASK	(0xfull << CHA_ID_MS_JR_SHIFT)
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci/* Specific CHA version IDs */
3828c2ecf20Sopenharmony_ci#define CHA_VER_VID_AES_LP	0x3ull
3838c2ecf20Sopenharmony_ci#define CHA_VER_VID_AES_HP	0x4ull
3848c2ecf20Sopenharmony_ci#define CHA_VER_VID_MD_LP256	0x0ull
3858c2ecf20Sopenharmony_ci#define CHA_VER_VID_MD_LP512	0x1ull
3868c2ecf20Sopenharmony_ci#define CHA_VER_VID_MD_HP	0x2ull
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_cistruct sec_vid {
3898c2ecf20Sopenharmony_ci	u16 ip_id;
3908c2ecf20Sopenharmony_ci	u8 maj_rev;
3918c2ecf20Sopenharmony_ci	u8 min_rev;
3928c2ecf20Sopenharmony_ci};
3938c2ecf20Sopenharmony_ci
3948c2ecf20Sopenharmony_cistruct caam_perfmon {
3958c2ecf20Sopenharmony_ci	/* Performance Monitor Registers			f00-f9f */
3968c2ecf20Sopenharmony_ci	u64 req_dequeued;	/* PC_REQ_DEQ - Dequeued Requests	     */
3978c2ecf20Sopenharmony_ci	u64 ob_enc_req;	/* PC_OB_ENC_REQ - Outbound Encrypt Requests */
3988c2ecf20Sopenharmony_ci	u64 ib_dec_req;	/* PC_IB_DEC_REQ - Inbound Decrypt Requests  */
3998c2ecf20Sopenharmony_ci	u64 ob_enc_bytes;	/* PC_OB_ENCRYPT - Outbound Bytes Encrypted  */
4008c2ecf20Sopenharmony_ci	u64 ob_prot_bytes;	/* PC_OB_PROTECT - Outbound Bytes Protected  */
4018c2ecf20Sopenharmony_ci	u64 ib_dec_bytes;	/* PC_IB_DECRYPT - Inbound Bytes Decrypted   */
4028c2ecf20Sopenharmony_ci	u64 ib_valid_bytes;	/* PC_IB_VALIDATED Inbound Bytes Validated   */
4038c2ecf20Sopenharmony_ci	u64 rsvd[13];
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_ci	/* CAAM Hardware Instantiation Parameters		fa0-fbf */
4068c2ecf20Sopenharmony_ci	u32 cha_rev_ms;		/* CRNR - CHA Rev No. Most significant half*/
4078c2ecf20Sopenharmony_ci	u32 cha_rev_ls;		/* CRNR - CHA Rev No. Least significant half*/
4088c2ecf20Sopenharmony_ci#define CTPR_MS_QI_SHIFT	25
4098c2ecf20Sopenharmony_ci#define CTPR_MS_QI_MASK		(0x1ull << CTPR_MS_QI_SHIFT)
4108c2ecf20Sopenharmony_ci#define CTPR_MS_PS		BIT(17)
4118c2ecf20Sopenharmony_ci#define CTPR_MS_DPAA2		BIT(13)
4128c2ecf20Sopenharmony_ci#define CTPR_MS_VIRT_EN_INCL	0x00000001
4138c2ecf20Sopenharmony_ci#define CTPR_MS_VIRT_EN_POR	0x00000002
4148c2ecf20Sopenharmony_ci#define CTPR_MS_PG_SZ_MASK	0x10
4158c2ecf20Sopenharmony_ci#define CTPR_MS_PG_SZ_SHIFT	4
4168c2ecf20Sopenharmony_ci	u32 comp_parms_ms;	/* CTPR - Compile Parameters Register	*/
4178c2ecf20Sopenharmony_ci	u32 comp_parms_ls;	/* CTPR - Compile Parameters Register	*/
4188c2ecf20Sopenharmony_ci	u64 rsvd1[2];
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci	/* CAAM Global Status					fc0-fdf */
4218c2ecf20Sopenharmony_ci	u64 faultaddr;	/* FAR  - Fault Address		*/
4228c2ecf20Sopenharmony_ci	u32 faultliodn;	/* FALR - Fault Address LIODN	*/
4238c2ecf20Sopenharmony_ci	u32 faultdetail;	/* FADR - Fault Addr Detail	*/
4248c2ecf20Sopenharmony_ci	u32 rsvd2;
4258c2ecf20Sopenharmony_ci#define CSTA_PLEND		BIT(10)
4268c2ecf20Sopenharmony_ci#define CSTA_ALT_PLEND		BIT(18)
4278c2ecf20Sopenharmony_ci	u32 status;		/* CSTA - CAAM Status */
4288c2ecf20Sopenharmony_ci	u64 rsvd3;
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci	/* Component Instantiation Parameters			fe0-fff */
4318c2ecf20Sopenharmony_ci	u32 rtic_id;		/* RVID - RTIC Version ID	*/
4328c2ecf20Sopenharmony_ci#define CCBVID_ERA_MASK		0xff000000
4338c2ecf20Sopenharmony_ci#define CCBVID_ERA_SHIFT	24
4348c2ecf20Sopenharmony_ci	u32 ccb_id;		/* CCBVID - CCB Version ID	*/
4358c2ecf20Sopenharmony_ci	u32 cha_id_ms;		/* CHAVID - CHA Version ID Most Significant*/
4368c2ecf20Sopenharmony_ci	u32 cha_id_ls;		/* CHAVID - CHA Version ID Least Significant*/
4378c2ecf20Sopenharmony_ci	u32 cha_num_ms;		/* CHANUM - CHA Number Most Significant	*/
4388c2ecf20Sopenharmony_ci	u32 cha_num_ls;		/* CHANUM - CHA Number Least Significant*/
4398c2ecf20Sopenharmony_ci#define SECVID_MS_IPID_MASK	0xffff0000
4408c2ecf20Sopenharmony_ci#define SECVID_MS_IPID_SHIFT	16
4418c2ecf20Sopenharmony_ci#define SECVID_MS_MAJ_REV_MASK	0x0000ff00
4428c2ecf20Sopenharmony_ci#define SECVID_MS_MAJ_REV_SHIFT	8
4438c2ecf20Sopenharmony_ci	u32 caam_id_ms;		/* CAAMVID - CAAM Version ID MS	*/
4448c2ecf20Sopenharmony_ci	u32 caam_id_ls;		/* CAAMVID - CAAM Version ID LS	*/
4458c2ecf20Sopenharmony_ci};
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ci/* LIODN programming for DMA configuration */
4488c2ecf20Sopenharmony_ci#define MSTRID_LOCK_LIODN	0x80000000
4498c2ecf20Sopenharmony_ci#define MSTRID_LOCK_MAKETRUSTED	0x00010000	/* only for JR masterid */
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci#define MSTRID_LIODN_MASK	0x0fff
4528c2ecf20Sopenharmony_cistruct masterid {
4538c2ecf20Sopenharmony_ci	u32 liodn_ms;	/* lock and make-trusted control bits */
4548c2ecf20Sopenharmony_ci	u32 liodn_ls;	/* LIODN for non-sequence and seq access */
4558c2ecf20Sopenharmony_ci};
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci/* Partition ID for DMA configuration */
4588c2ecf20Sopenharmony_cistruct partid {
4598c2ecf20Sopenharmony_ci	u32 rsvd1;
4608c2ecf20Sopenharmony_ci	u32 pidr;	/* partition ID, DECO */
4618c2ecf20Sopenharmony_ci};
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ci/* RNGB test mode (replicated twice in some configurations) */
4648c2ecf20Sopenharmony_ci/* Padded out to 0x100 */
4658c2ecf20Sopenharmony_cistruct rngtst {
4668c2ecf20Sopenharmony_ci	u32 mode;		/* RTSTMODEx - Test mode */
4678c2ecf20Sopenharmony_ci	u32 rsvd1[3];
4688c2ecf20Sopenharmony_ci	u32 reset;		/* RTSTRESETx - Test reset control */
4698c2ecf20Sopenharmony_ci	u32 rsvd2[3];
4708c2ecf20Sopenharmony_ci	u32 status;		/* RTSTSSTATUSx - Test status */
4718c2ecf20Sopenharmony_ci	u32 rsvd3;
4728c2ecf20Sopenharmony_ci	u32 errstat;		/* RTSTERRSTATx - Test error status */
4738c2ecf20Sopenharmony_ci	u32 rsvd4;
4748c2ecf20Sopenharmony_ci	u32 errctl;		/* RTSTERRCTLx - Test error control */
4758c2ecf20Sopenharmony_ci	u32 rsvd5;
4768c2ecf20Sopenharmony_ci	u32 entropy;		/* RTSTENTROPYx - Test entropy */
4778c2ecf20Sopenharmony_ci	u32 rsvd6[15];
4788c2ecf20Sopenharmony_ci	u32 verifctl;	/* RTSTVERIFCTLx - Test verification control */
4798c2ecf20Sopenharmony_ci	u32 rsvd7;
4808c2ecf20Sopenharmony_ci	u32 verifstat;	/* RTSTVERIFSTATx - Test verification status */
4818c2ecf20Sopenharmony_ci	u32 rsvd8;
4828c2ecf20Sopenharmony_ci	u32 verifdata;	/* RTSTVERIFDx - Test verification data */
4838c2ecf20Sopenharmony_ci	u32 rsvd9;
4848c2ecf20Sopenharmony_ci	u32 xkey;		/* RTSTXKEYx - Test XKEY */
4858c2ecf20Sopenharmony_ci	u32 rsvd10;
4868c2ecf20Sopenharmony_ci	u32 oscctctl;	/* RTSTOSCCTCTLx - Test osc. counter control */
4878c2ecf20Sopenharmony_ci	u32 rsvd11;
4888c2ecf20Sopenharmony_ci	u32 oscct;		/* RTSTOSCCTx - Test oscillator counter */
4898c2ecf20Sopenharmony_ci	u32 rsvd12;
4908c2ecf20Sopenharmony_ci	u32 oscctstat;	/* RTSTODCCTSTATx - Test osc counter status */
4918c2ecf20Sopenharmony_ci	u32 rsvd13[2];
4928c2ecf20Sopenharmony_ci	u32 ofifo[4];	/* RTSTOFIFOx - Test output FIFO */
4938c2ecf20Sopenharmony_ci	u32 rsvd14[15];
4948c2ecf20Sopenharmony_ci};
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_ci/* RNG4 TRNG test registers */
4978c2ecf20Sopenharmony_cistruct rng4tst {
4988c2ecf20Sopenharmony_ci#define RTMCTL_ACC  BIT(5)  /* TRNG access mode */
4998c2ecf20Sopenharmony_ci#define RTMCTL_PRGM BIT(16) /* 1 -> program mode, 0 -> run mode */
5008c2ecf20Sopenharmony_ci#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_SC	0 /* use von Neumann data in
5018c2ecf20Sopenharmony_ci						     both entropy shifter and
5028c2ecf20Sopenharmony_ci						     statistical checker */
5038c2ecf20Sopenharmony_ci#define RTMCTL_SAMP_MODE_RAW_ES_SC		1 /* use raw data in both
5048c2ecf20Sopenharmony_ci						     entropy shifter and
5058c2ecf20Sopenharmony_ci						     statistical checker */
5068c2ecf20Sopenharmony_ci#define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_RAW_SC	2 /* use von Neumann data in
5078c2ecf20Sopenharmony_ci						     entropy shifter, raw data
5088c2ecf20Sopenharmony_ci						     in statistical checker */
5098c2ecf20Sopenharmony_ci#define RTMCTL_SAMP_MODE_INVALID		3 /* invalid combination */
5108c2ecf20Sopenharmony_ci	u32 rtmctl;		/* misc. control register */
5118c2ecf20Sopenharmony_ci	u32 rtscmisc;		/* statistical check misc. register */
5128c2ecf20Sopenharmony_ci	u32 rtpkrrng;		/* poker range register */
5138c2ecf20Sopenharmony_ci	union {
5148c2ecf20Sopenharmony_ci		u32 rtpkrmax;	/* PRGM=1: poker max. limit register */
5158c2ecf20Sopenharmony_ci		u32 rtpkrsq;	/* PRGM=0: poker square calc. result register */
5168c2ecf20Sopenharmony_ci	};
5178c2ecf20Sopenharmony_ci#define RTSDCTL_ENT_DLY_SHIFT 16
5188c2ecf20Sopenharmony_ci#define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
5198c2ecf20Sopenharmony_ci#define RTSDCTL_ENT_DLY_MIN 3200
5208c2ecf20Sopenharmony_ci#define RTSDCTL_ENT_DLY_MAX 12800
5218c2ecf20Sopenharmony_ci	u32 rtsdctl;		/* seed control register */
5228c2ecf20Sopenharmony_ci	union {
5238c2ecf20Sopenharmony_ci		u32 rtsblim;	/* PRGM=1: sparse bit limit register */
5248c2ecf20Sopenharmony_ci		u32 rttotsam;	/* PRGM=0: total samples register */
5258c2ecf20Sopenharmony_ci	};
5268c2ecf20Sopenharmony_ci	u32 rtfrqmin;		/* frequency count min. limit register */
5278c2ecf20Sopenharmony_ci#define RTFRQMAX_DISABLE	(1 << 20)
5288c2ecf20Sopenharmony_ci	union {
5298c2ecf20Sopenharmony_ci		u32 rtfrqmax;	/* PRGM=1: freq. count max. limit register */
5308c2ecf20Sopenharmony_ci		u32 rtfrqcnt;	/* PRGM=0: freq. count register */
5318c2ecf20Sopenharmony_ci	};
5328c2ecf20Sopenharmony_ci	u32 rsvd1[40];
5338c2ecf20Sopenharmony_ci#define RDSTA_SKVT 0x80000000
5348c2ecf20Sopenharmony_ci#define RDSTA_SKVN 0x40000000
5358c2ecf20Sopenharmony_ci#define RDSTA_PR0 BIT(4)
5368c2ecf20Sopenharmony_ci#define RDSTA_PR1 BIT(5)
5378c2ecf20Sopenharmony_ci#define RDSTA_IF0 0x00000001
5388c2ecf20Sopenharmony_ci#define RDSTA_IF1 0x00000002
5398c2ecf20Sopenharmony_ci#define RDSTA_MASK (RDSTA_PR1 | RDSTA_PR0 | RDSTA_IF1 | RDSTA_IF0)
5408c2ecf20Sopenharmony_ci	u32 rdsta;
5418c2ecf20Sopenharmony_ci	u32 rsvd2[15];
5428c2ecf20Sopenharmony_ci};
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_ci/*
5458c2ecf20Sopenharmony_ci * caam_ctrl - basic core configuration
5468c2ecf20Sopenharmony_ci * starts base + 0x0000 padded out to 0x1000
5478c2ecf20Sopenharmony_ci */
5488c2ecf20Sopenharmony_ci
5498c2ecf20Sopenharmony_ci#define KEK_KEY_SIZE		8
5508c2ecf20Sopenharmony_ci#define TKEK_KEY_SIZE		8
5518c2ecf20Sopenharmony_ci#define TDSK_KEY_SIZE		8
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_ci#define DECO_RESET	1	/* Use with DECO reset/availability regs */
5548c2ecf20Sopenharmony_ci#define DECO_RESET_0	(DECO_RESET << 0)
5558c2ecf20Sopenharmony_ci#define DECO_RESET_1	(DECO_RESET << 1)
5568c2ecf20Sopenharmony_ci#define DECO_RESET_2	(DECO_RESET << 2)
5578c2ecf20Sopenharmony_ci#define DECO_RESET_3	(DECO_RESET << 3)
5588c2ecf20Sopenharmony_ci#define DECO_RESET_4	(DECO_RESET << 4)
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_cistruct caam_ctrl {
5618c2ecf20Sopenharmony_ci	/* Basic Configuration Section				000-01f */
5628c2ecf20Sopenharmony_ci	/* Read/Writable					        */
5638c2ecf20Sopenharmony_ci	u32 rsvd1;
5648c2ecf20Sopenharmony_ci	u32 mcr;		/* MCFG      Master Config Register  */
5658c2ecf20Sopenharmony_ci	u32 rsvd2;
5668c2ecf20Sopenharmony_ci	u32 scfgr;		/* SCFGR, Security Config Register */
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci	/* Bus Access Configuration Section			010-11f */
5698c2ecf20Sopenharmony_ci	/* Read/Writable                                                */
5708c2ecf20Sopenharmony_ci	struct masterid jr_mid[4];	/* JRxLIODNR - JobR LIODN setup */
5718c2ecf20Sopenharmony_ci	u32 rsvd3[11];
5728c2ecf20Sopenharmony_ci	u32 jrstart;			/* JRSTART - Job Ring Start Register */
5738c2ecf20Sopenharmony_ci	struct masterid rtic_mid[4];	/* RTICxLIODNR - RTIC LIODN setup */
5748c2ecf20Sopenharmony_ci	u32 rsvd4[5];
5758c2ecf20Sopenharmony_ci	u32 deco_rsr;			/* DECORSR - Deco Request Source */
5768c2ecf20Sopenharmony_ci	u32 rsvd11;
5778c2ecf20Sopenharmony_ci	u32 deco_rq;			/* DECORR - DECO Request */
5788c2ecf20Sopenharmony_ci	struct partid deco_mid[5];	/* DECOxLIODNR - 1 per DECO */
5798c2ecf20Sopenharmony_ci	u32 rsvd5[22];
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_ci	/* DECO Availability/Reset Section			120-3ff */
5828c2ecf20Sopenharmony_ci	u32 deco_avail;		/* DAR - DECO availability */
5838c2ecf20Sopenharmony_ci	u32 deco_reset;		/* DRR - DECO reset */
5848c2ecf20Sopenharmony_ci	u32 rsvd6[182];
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci	/* Key Encryption/Decryption Configuration              400-5ff */
5878c2ecf20Sopenharmony_ci	/* Read/Writable only while in Non-secure mode                  */
5888c2ecf20Sopenharmony_ci	u32 kek[KEK_KEY_SIZE];	/* JDKEKR - Key Encryption Key */
5898c2ecf20Sopenharmony_ci	u32 tkek[TKEK_KEY_SIZE];	/* TDKEKR - Trusted Desc KEK */
5908c2ecf20Sopenharmony_ci	u32 tdsk[TDSK_KEY_SIZE];	/* TDSKR - Trusted Desc Signing Key */
5918c2ecf20Sopenharmony_ci	u32 rsvd7[32];
5928c2ecf20Sopenharmony_ci	u64 sknonce;			/* SKNR - Secure Key Nonce */
5938c2ecf20Sopenharmony_ci	u32 rsvd8[70];
5948c2ecf20Sopenharmony_ci
5958c2ecf20Sopenharmony_ci	/* RNG Test/Verification/Debug Access                   600-7ff */
5968c2ecf20Sopenharmony_ci	/* (Useful in Test/Debug modes only...)                         */
5978c2ecf20Sopenharmony_ci	union {
5988c2ecf20Sopenharmony_ci		struct rngtst rtst[2];
5998c2ecf20Sopenharmony_ci		struct rng4tst r4tst[2];
6008c2ecf20Sopenharmony_ci	};
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci	u32 rsvd9[416];
6038c2ecf20Sopenharmony_ci
6048c2ecf20Sopenharmony_ci	/* Version registers - introduced with era 10		e80-eff */
6058c2ecf20Sopenharmony_ci	struct version_regs vreg;
6068c2ecf20Sopenharmony_ci	/* Performance Monitor                                  f00-fff */
6078c2ecf20Sopenharmony_ci	struct caam_perfmon perfmon;
6088c2ecf20Sopenharmony_ci};
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ci/*
6118c2ecf20Sopenharmony_ci * Controller master config register defs
6128c2ecf20Sopenharmony_ci */
6138c2ecf20Sopenharmony_ci#define MCFGR_SWRESET		0x80000000 /* software reset */
6148c2ecf20Sopenharmony_ci#define MCFGR_WDENABLE		0x40000000 /* DECO watchdog enable */
6158c2ecf20Sopenharmony_ci#define MCFGR_WDFAIL		0x20000000 /* DECO watchdog force-fail */
6168c2ecf20Sopenharmony_ci#define MCFGR_DMA_RESET		0x10000000
6178c2ecf20Sopenharmony_ci#define MCFGR_LONG_PTR		0x00010000 /* Use >32-bit desc addressing */
6188c2ecf20Sopenharmony_ci#define SCFGR_RDBENABLE		0x00000400
6198c2ecf20Sopenharmony_ci#define SCFGR_VIRT_EN		0x00008000
6208c2ecf20Sopenharmony_ci#define DECORR_RQD0ENABLE	0x00000001 /* Enable DECO0 for direct access */
6218c2ecf20Sopenharmony_ci#define DECORSR_JR0		0x00000001 /* JR to supply TZ, SDID, ICID */
6228c2ecf20Sopenharmony_ci#define DECORSR_VALID		0x80000000
6238c2ecf20Sopenharmony_ci#define DECORR_DEN0		0x00010000 /* DECO0 available for access*/
6248c2ecf20Sopenharmony_ci
6258c2ecf20Sopenharmony_ci/* AXI read cache control */
6268c2ecf20Sopenharmony_ci#define MCFGR_ARCACHE_SHIFT	12
6278c2ecf20Sopenharmony_ci#define MCFGR_ARCACHE_MASK	(0xf << MCFGR_ARCACHE_SHIFT)
6288c2ecf20Sopenharmony_ci#define MCFGR_ARCACHE_BUFF	(0x1 << MCFGR_ARCACHE_SHIFT)
6298c2ecf20Sopenharmony_ci#define MCFGR_ARCACHE_CACH	(0x2 << MCFGR_ARCACHE_SHIFT)
6308c2ecf20Sopenharmony_ci#define MCFGR_ARCACHE_RALL	(0x4 << MCFGR_ARCACHE_SHIFT)
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_ci/* AXI write cache control */
6338c2ecf20Sopenharmony_ci#define MCFGR_AWCACHE_SHIFT	8
6348c2ecf20Sopenharmony_ci#define MCFGR_AWCACHE_MASK	(0xf << MCFGR_AWCACHE_SHIFT)
6358c2ecf20Sopenharmony_ci#define MCFGR_AWCACHE_BUFF	(0x1 << MCFGR_AWCACHE_SHIFT)
6368c2ecf20Sopenharmony_ci#define MCFGR_AWCACHE_CACH	(0x2 << MCFGR_AWCACHE_SHIFT)
6378c2ecf20Sopenharmony_ci#define MCFGR_AWCACHE_WALL	(0x8 << MCFGR_AWCACHE_SHIFT)
6388c2ecf20Sopenharmony_ci
6398c2ecf20Sopenharmony_ci/* AXI pipeline depth */
6408c2ecf20Sopenharmony_ci#define MCFGR_AXIPIPE_SHIFT	4
6418c2ecf20Sopenharmony_ci#define MCFGR_AXIPIPE_MASK	(0xf << MCFGR_AXIPIPE_SHIFT)
6428c2ecf20Sopenharmony_ci
6438c2ecf20Sopenharmony_ci#define MCFGR_AXIPRI		0x00000008 /* Assert AXI priority sideband */
6448c2ecf20Sopenharmony_ci#define MCFGR_LARGE_BURST	0x00000004 /* 128/256-byte burst size */
6458c2ecf20Sopenharmony_ci#define MCFGR_BURST_64		0x00000001 /* 64-byte burst size */
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci/* JRSTART register offsets */
6488c2ecf20Sopenharmony_ci#define JRSTART_JR0_START       0x00000001 /* Start Job ring 0 */
6498c2ecf20Sopenharmony_ci#define JRSTART_JR1_START       0x00000002 /* Start Job ring 1 */
6508c2ecf20Sopenharmony_ci#define JRSTART_JR2_START       0x00000004 /* Start Job ring 2 */
6518c2ecf20Sopenharmony_ci#define JRSTART_JR3_START       0x00000008 /* Start Job ring 3 */
6528c2ecf20Sopenharmony_ci
6538c2ecf20Sopenharmony_ci/*
6548c2ecf20Sopenharmony_ci * caam_job_ring - direct job ring setup
6558c2ecf20Sopenharmony_ci * 1-4 possible per instantiation, base + 1000/2000/3000/4000
6568c2ecf20Sopenharmony_ci * Padded out to 0x1000
6578c2ecf20Sopenharmony_ci */
6588c2ecf20Sopenharmony_cistruct caam_job_ring {
6598c2ecf20Sopenharmony_ci	/* Input ring */
6608c2ecf20Sopenharmony_ci	u64 inpring_base;	/* IRBAx -  Input desc ring baseaddr */
6618c2ecf20Sopenharmony_ci	u32 rsvd1;
6628c2ecf20Sopenharmony_ci	u32 inpring_size;	/* IRSx - Input ring size */
6638c2ecf20Sopenharmony_ci	u32 rsvd2;
6648c2ecf20Sopenharmony_ci	u32 inpring_avail;	/* IRSAx - Input ring room remaining */
6658c2ecf20Sopenharmony_ci	u32 rsvd3;
6668c2ecf20Sopenharmony_ci	u32 inpring_jobadd;	/* IRJAx - Input ring jobs added */
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_ci	/* Output Ring */
6698c2ecf20Sopenharmony_ci	u64 outring_base;	/* ORBAx - Output status ring base addr */
6708c2ecf20Sopenharmony_ci	u32 rsvd4;
6718c2ecf20Sopenharmony_ci	u32 outring_size;	/* ORSx - Output ring size */
6728c2ecf20Sopenharmony_ci	u32 rsvd5;
6738c2ecf20Sopenharmony_ci	u32 outring_rmvd;	/* ORJRx - Output ring jobs removed */
6748c2ecf20Sopenharmony_ci	u32 rsvd6;
6758c2ecf20Sopenharmony_ci	u32 outring_used;	/* ORSFx - Output ring slots full */
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci	/* Status/Configuration */
6788c2ecf20Sopenharmony_ci	u32 rsvd7;
6798c2ecf20Sopenharmony_ci	u32 jroutstatus;	/* JRSTAx - JobR output status */
6808c2ecf20Sopenharmony_ci	u32 rsvd8;
6818c2ecf20Sopenharmony_ci	u32 jrintstatus;	/* JRINTx - JobR interrupt status */
6828c2ecf20Sopenharmony_ci	u32 rconfig_hi;	/* JRxCFG - Ring configuration */
6838c2ecf20Sopenharmony_ci	u32 rconfig_lo;
6848c2ecf20Sopenharmony_ci
6858c2ecf20Sopenharmony_ci	/* Indices. CAAM maintains as "heads" of each queue */
6868c2ecf20Sopenharmony_ci	u32 rsvd9;
6878c2ecf20Sopenharmony_ci	u32 inp_rdidx;	/* IRRIx - Input ring read index */
6888c2ecf20Sopenharmony_ci	u32 rsvd10;
6898c2ecf20Sopenharmony_ci	u32 out_wtidx;	/* ORWIx - Output ring write index */
6908c2ecf20Sopenharmony_ci
6918c2ecf20Sopenharmony_ci	/* Command/control */
6928c2ecf20Sopenharmony_ci	u32 rsvd11;
6938c2ecf20Sopenharmony_ci	u32 jrcommand;	/* JRCRx - JobR command */
6948c2ecf20Sopenharmony_ci
6958c2ecf20Sopenharmony_ci	u32 rsvd12[900];
6968c2ecf20Sopenharmony_ci
6978c2ecf20Sopenharmony_ci	/* Version registers - introduced with era 10           e80-eff */
6988c2ecf20Sopenharmony_ci	struct version_regs vreg;
6998c2ecf20Sopenharmony_ci	/* Performance Monitor                                  f00-fff */
7008c2ecf20Sopenharmony_ci	struct caam_perfmon perfmon;
7018c2ecf20Sopenharmony_ci};
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_ci#define JR_RINGSIZE_MASK	0x03ff
7048c2ecf20Sopenharmony_ci/*
7058c2ecf20Sopenharmony_ci * jrstatus - Job Ring Output Status
7068c2ecf20Sopenharmony_ci * All values in lo word
7078c2ecf20Sopenharmony_ci * Also note, same values written out as status through QI
7088c2ecf20Sopenharmony_ci * in the command/status field of a frame descriptor
7098c2ecf20Sopenharmony_ci */
7108c2ecf20Sopenharmony_ci#define JRSTA_SSRC_SHIFT            28
7118c2ecf20Sopenharmony_ci#define JRSTA_SSRC_MASK             0xf0000000
7128c2ecf20Sopenharmony_ci
7138c2ecf20Sopenharmony_ci#define JRSTA_SSRC_NONE             0x00000000
7148c2ecf20Sopenharmony_ci#define JRSTA_SSRC_CCB_ERROR        0x20000000
7158c2ecf20Sopenharmony_ci#define JRSTA_SSRC_JUMP_HALT_USER   0x30000000
7168c2ecf20Sopenharmony_ci#define JRSTA_SSRC_DECO             0x40000000
7178c2ecf20Sopenharmony_ci#define JRSTA_SSRC_QI               0x50000000
7188c2ecf20Sopenharmony_ci#define JRSTA_SSRC_JRERROR          0x60000000
7198c2ecf20Sopenharmony_ci#define JRSTA_SSRC_JUMP_HALT_CC     0x70000000
7208c2ecf20Sopenharmony_ci
7218c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_JUMP          0x08000000
7228c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_INDEX_SHIFT   8
7238c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_INDEX_MASK    0xff00
7248c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_ERROR_MASK    0x00ff
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_NONE          0x00
7278c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_LINKLEN       0x01
7288c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_LINKPTR       0x02
7298c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_JRCTRL        0x03
7308c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_DESCCMD       0x04
7318c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_ORDER         0x05
7328c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_KEYCMD        0x06
7338c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_LOADCMD       0x07
7348c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_STORECMD      0x08
7358c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_OPCMD         0x09
7368c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_FIFOLDCMD     0x0a
7378c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_FIFOSTCMD     0x0b
7388c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_MOVECMD       0x0c
7398c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_JUMPCMD       0x0d
7408c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_MATHCMD       0x0e
7418c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_SHASHCMD      0x0f
7428c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_SEQCMD        0x10
7438c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_DECOINTERNAL  0x11
7448c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_SHDESCHDR     0x12
7458c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_HDRLEN        0x13
7468c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_BURSTER       0x14
7478c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_DESCSIGNATURE 0x15
7488c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_DMA           0x16
7498c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_BURSTFIFO     0x17
7508c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_JRRESET       0x1a
7518c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_JOBFAIL       0x1b
7528c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_DNRERR        0x80
7538c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_UNDEFPCL      0x81
7548c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_PDBERR        0x82
7558c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_ANRPLY_LATE   0x83
7568c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_ANRPLY_REPLAY 0x84
7578c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_SEQOVF        0x85
7588c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_INVSIGN       0x86
7598c2ecf20Sopenharmony_ci#define JRSTA_DECOERR_DSASIGN       0x87
7608c2ecf20Sopenharmony_ci
7618c2ecf20Sopenharmony_ci#define JRSTA_QIERR_ERROR_MASK      0x00ff
7628c2ecf20Sopenharmony_ci
7638c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_JUMP           0x08000000
7648c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_INDEX_MASK     0xff00
7658c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_INDEX_SHIFT    8
7668c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_MASK     0x00f0
7678c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_SHIFT    4
7688c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_MASK     0x000f
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_AES      (0x01 << JRSTA_CCBERR_CHAID_SHIFT)
7718c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_DES      (0x02 << JRSTA_CCBERR_CHAID_SHIFT)
7728c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_ARC4     (0x03 << JRSTA_CCBERR_CHAID_SHIFT)
7738c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_MD       (0x04 << JRSTA_CCBERR_CHAID_SHIFT)
7748c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_RNG      (0x05 << JRSTA_CCBERR_CHAID_SHIFT)
7758c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_SNOW     (0x06 << JRSTA_CCBERR_CHAID_SHIFT)
7768c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_KASUMI   (0x07 << JRSTA_CCBERR_CHAID_SHIFT)
7778c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_PK       (0x08 << JRSTA_CCBERR_CHAID_SHIFT)
7788c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_CHAID_CRC      (0x09 << JRSTA_CCBERR_CHAID_SHIFT)
7798c2ecf20Sopenharmony_ci
7808c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_NONE     0x00
7818c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_MODE     0x01
7828c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_DATASIZ  0x02
7838c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_KEYSIZ   0x03
7848c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_PKAMEMSZ 0x04
7858c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_PKBMEMSZ 0x05
7868c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_SEQUENCE 0x06
7878c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_PKDIVZRO 0x07
7888c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_PKMODEVN 0x08
7898c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_KEYPARIT 0x09
7908c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_ICVCHK   0x0a
7918c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_HARDWARE 0x0b
7928c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_CCMAAD   0x0c
7938c2ecf20Sopenharmony_ci#define JRSTA_CCBERR_ERRID_INVCHA   0x0f
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ci#define JRINT_ERR_INDEX_MASK        0x3fff0000
7968c2ecf20Sopenharmony_ci#define JRINT_ERR_INDEX_SHIFT       16
7978c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_MASK         0xf00
7988c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_SHIFT        8
7998c2ecf20Sopenharmony_ci#define JRINT_ERR_HALT_MASK         0xc
8008c2ecf20Sopenharmony_ci#define JRINT_ERR_HALT_SHIFT        2
8018c2ecf20Sopenharmony_ci#define JRINT_ERR_HALT_INPROGRESS   0x4
8028c2ecf20Sopenharmony_ci#define JRINT_ERR_HALT_COMPLETE     0x8
8038c2ecf20Sopenharmony_ci#define JRINT_JR_ERROR              0x02
8048c2ecf20Sopenharmony_ci#define JRINT_JR_INT                0x01
8058c2ecf20Sopenharmony_ci
8068c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_WRITE        1
8078c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_BAD_INPADDR  3
8088c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_BAD_OUTADDR  4
8098c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_INV_INPWRT   5
8108c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_INV_OUTWRT   6
8118c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_RESET        7
8128c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_REMOVE_OFL   8
8138c2ecf20Sopenharmony_ci#define JRINT_ERR_TYPE_ADD_OFL      9
8148c2ecf20Sopenharmony_ci
8158c2ecf20Sopenharmony_ci#define JRCFG_SOE		0x04
8168c2ecf20Sopenharmony_ci#define JRCFG_ICEN		0x02
8178c2ecf20Sopenharmony_ci#define JRCFG_IMSK		0x01
8188c2ecf20Sopenharmony_ci#define JRCFG_ICDCT_SHIFT	8
8198c2ecf20Sopenharmony_ci#define JRCFG_ICTT_SHIFT	16
8208c2ecf20Sopenharmony_ci
8218c2ecf20Sopenharmony_ci#define JRCR_RESET                  0x01
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_ci/*
8248c2ecf20Sopenharmony_ci * caam_assurance - Assurance Controller View
8258c2ecf20Sopenharmony_ci * base + 0x6000 padded out to 0x1000
8268c2ecf20Sopenharmony_ci */
8278c2ecf20Sopenharmony_ci
8288c2ecf20Sopenharmony_cistruct rtic_element {
8298c2ecf20Sopenharmony_ci	u64 address;
8308c2ecf20Sopenharmony_ci	u32 rsvd;
8318c2ecf20Sopenharmony_ci	u32 length;
8328c2ecf20Sopenharmony_ci};
8338c2ecf20Sopenharmony_ci
8348c2ecf20Sopenharmony_cistruct rtic_block {
8358c2ecf20Sopenharmony_ci	struct rtic_element element[2];
8368c2ecf20Sopenharmony_ci};
8378c2ecf20Sopenharmony_ci
8388c2ecf20Sopenharmony_cistruct rtic_memhash {
8398c2ecf20Sopenharmony_ci	u32 memhash_be[32];
8408c2ecf20Sopenharmony_ci	u32 memhash_le[32];
8418c2ecf20Sopenharmony_ci};
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_cistruct caam_assurance {
8448c2ecf20Sopenharmony_ci    /* Status/Command/Watchdog */
8458c2ecf20Sopenharmony_ci	u32 rsvd1;
8468c2ecf20Sopenharmony_ci	u32 status;		/* RSTA - Status */
8478c2ecf20Sopenharmony_ci	u32 rsvd2;
8488c2ecf20Sopenharmony_ci	u32 cmd;		/* RCMD - Command */
8498c2ecf20Sopenharmony_ci	u32 rsvd3;
8508c2ecf20Sopenharmony_ci	u32 ctrl;		/* RCTL - Control */
8518c2ecf20Sopenharmony_ci	u32 rsvd4;
8528c2ecf20Sopenharmony_ci	u32 throttle;	/* RTHR - Throttle */
8538c2ecf20Sopenharmony_ci	u32 rsvd5[2];
8548c2ecf20Sopenharmony_ci	u64 watchdog;	/* RWDOG - Watchdog Timer */
8558c2ecf20Sopenharmony_ci	u32 rsvd6;
8568c2ecf20Sopenharmony_ci	u32 rend;		/* REND - Endian corrections */
8578c2ecf20Sopenharmony_ci	u32 rsvd7[50];
8588c2ecf20Sopenharmony_ci
8598c2ecf20Sopenharmony_ci	/* Block access/configuration @ 100/110/120/130 */
8608c2ecf20Sopenharmony_ci	struct rtic_block memblk[4];	/* Memory Blocks A-D */
8618c2ecf20Sopenharmony_ci	u32 rsvd8[32];
8628c2ecf20Sopenharmony_ci
8638c2ecf20Sopenharmony_ci	/* Block hashes @ 200/300/400/500 */
8648c2ecf20Sopenharmony_ci	struct rtic_memhash hash[4];	/* Block hash values A-D */
8658c2ecf20Sopenharmony_ci	u32 rsvd_3[640];
8668c2ecf20Sopenharmony_ci};
8678c2ecf20Sopenharmony_ci
8688c2ecf20Sopenharmony_ci/*
8698c2ecf20Sopenharmony_ci * caam_queue_if - QI configuration and control
8708c2ecf20Sopenharmony_ci * starts base + 0x7000, padded out to 0x1000 long
8718c2ecf20Sopenharmony_ci */
8728c2ecf20Sopenharmony_ci
8738c2ecf20Sopenharmony_cistruct caam_queue_if {
8748c2ecf20Sopenharmony_ci	u32 qi_control_hi;	/* QICTL  - QI Control */
8758c2ecf20Sopenharmony_ci	u32 qi_control_lo;
8768c2ecf20Sopenharmony_ci	u32 rsvd1;
8778c2ecf20Sopenharmony_ci	u32 qi_status;	/* QISTA  - QI Status */
8788c2ecf20Sopenharmony_ci	u32 qi_deq_cfg_hi;	/* QIDQC  - QI Dequeue Configuration */
8798c2ecf20Sopenharmony_ci	u32 qi_deq_cfg_lo;
8808c2ecf20Sopenharmony_ci	u32 qi_enq_cfg_hi;	/* QISEQC - QI Enqueue Command     */
8818c2ecf20Sopenharmony_ci	u32 qi_enq_cfg_lo;
8828c2ecf20Sopenharmony_ci	u32 rsvd2[1016];
8838c2ecf20Sopenharmony_ci};
8848c2ecf20Sopenharmony_ci
8858c2ecf20Sopenharmony_ci/* QI control bits - low word */
8868c2ecf20Sopenharmony_ci#define QICTL_DQEN      0x01              /* Enable frame pop          */
8878c2ecf20Sopenharmony_ci#define QICTL_STOP      0x02              /* Stop dequeue/enqueue      */
8888c2ecf20Sopenharmony_ci#define QICTL_SOE       0x04              /* Stop on error             */
8898c2ecf20Sopenharmony_ci
8908c2ecf20Sopenharmony_ci/* QI control bits - high word */
8918c2ecf20Sopenharmony_ci#define QICTL_MBSI	0x01
8928c2ecf20Sopenharmony_ci#define QICTL_MHWSI	0x02
8938c2ecf20Sopenharmony_ci#define QICTL_MWSI	0x04
8948c2ecf20Sopenharmony_ci#define QICTL_MDWSI	0x08
8958c2ecf20Sopenharmony_ci#define QICTL_CBSI	0x10		/* CtrlDataByteSwapInput     */
8968c2ecf20Sopenharmony_ci#define QICTL_CHWSI	0x20		/* CtrlDataHalfSwapInput     */
8978c2ecf20Sopenharmony_ci#define QICTL_CWSI	0x40		/* CtrlDataWordSwapInput     */
8988c2ecf20Sopenharmony_ci#define QICTL_CDWSI	0x80		/* CtrlDataDWordSwapInput    */
8998c2ecf20Sopenharmony_ci#define QICTL_MBSO	0x0100
9008c2ecf20Sopenharmony_ci#define QICTL_MHWSO	0x0200
9018c2ecf20Sopenharmony_ci#define QICTL_MWSO	0x0400
9028c2ecf20Sopenharmony_ci#define QICTL_MDWSO	0x0800
9038c2ecf20Sopenharmony_ci#define QICTL_CBSO	0x1000		/* CtrlDataByteSwapOutput    */
9048c2ecf20Sopenharmony_ci#define QICTL_CHWSO	0x2000		/* CtrlDataHalfSwapOutput    */
9058c2ecf20Sopenharmony_ci#define QICTL_CWSO	0x4000		/* CtrlDataWordSwapOutput    */
9068c2ecf20Sopenharmony_ci#define QICTL_CDWSO     0x8000		/* CtrlDataDWordSwapOutput   */
9078c2ecf20Sopenharmony_ci#define QICTL_DMBS	0x010000
9088c2ecf20Sopenharmony_ci#define QICTL_EPO	0x020000
9098c2ecf20Sopenharmony_ci
9108c2ecf20Sopenharmony_ci/* QI status bits */
9118c2ecf20Sopenharmony_ci#define QISTA_PHRDERR   0x01              /* PreHeader Read Error      */
9128c2ecf20Sopenharmony_ci#define QISTA_CFRDERR   0x02              /* Compound Frame Read Error */
9138c2ecf20Sopenharmony_ci#define QISTA_OFWRERR   0x04              /* Output Frame Read Error   */
9148c2ecf20Sopenharmony_ci#define QISTA_BPDERR    0x08              /* Buffer Pool Depleted      */
9158c2ecf20Sopenharmony_ci#define QISTA_BTSERR    0x10              /* Buffer Undersize          */
9168c2ecf20Sopenharmony_ci#define QISTA_CFWRERR   0x20              /* Compound Frame Write Err  */
9178c2ecf20Sopenharmony_ci#define QISTA_STOPD     0x80000000        /* QI Stopped (see QICTL)    */
9188c2ecf20Sopenharmony_ci
9198c2ecf20Sopenharmony_ci/* deco_sg_table - DECO view of scatter/gather table */
9208c2ecf20Sopenharmony_cistruct deco_sg_table {
9218c2ecf20Sopenharmony_ci	u64 addr;		/* Segment Address */
9228c2ecf20Sopenharmony_ci	u32 elen;		/* E, F bits + 30-bit length */
9238c2ecf20Sopenharmony_ci	u32 bpid_offset;	/* Buffer Pool ID + 16-bit length */
9248c2ecf20Sopenharmony_ci};
9258c2ecf20Sopenharmony_ci
9268c2ecf20Sopenharmony_ci/*
9278c2ecf20Sopenharmony_ci * caam_deco - descriptor controller - CHA cluster block
9288c2ecf20Sopenharmony_ci *
9298c2ecf20Sopenharmony_ci * Only accessible when direct DECO access is turned on
9308c2ecf20Sopenharmony_ci * (done in DECORR, via MID programmed in DECOxMID
9318c2ecf20Sopenharmony_ci *
9328c2ecf20Sopenharmony_ci * 5 typical, base + 0x8000/9000/a000/b000
9338c2ecf20Sopenharmony_ci * Padded out to 0x1000 long
9348c2ecf20Sopenharmony_ci */
9358c2ecf20Sopenharmony_cistruct caam_deco {
9368c2ecf20Sopenharmony_ci	u32 rsvd1;
9378c2ecf20Sopenharmony_ci	u32 cls1_mode;	/* CxC1MR -  Class 1 Mode */
9388c2ecf20Sopenharmony_ci	u32 rsvd2;
9398c2ecf20Sopenharmony_ci	u32 cls1_keysize;	/* CxC1KSR - Class 1 Key Size */
9408c2ecf20Sopenharmony_ci	u32 cls1_datasize_hi;	/* CxC1DSR - Class 1 Data Size */
9418c2ecf20Sopenharmony_ci	u32 cls1_datasize_lo;
9428c2ecf20Sopenharmony_ci	u32 rsvd3;
9438c2ecf20Sopenharmony_ci	u32 cls1_icvsize;	/* CxC1ICVSR - Class 1 ICV size */
9448c2ecf20Sopenharmony_ci	u32 rsvd4[5];
9458c2ecf20Sopenharmony_ci	u32 cha_ctrl;	/* CCTLR - CHA control */
9468c2ecf20Sopenharmony_ci	u32 rsvd5;
9478c2ecf20Sopenharmony_ci	u32 irq_crtl;	/* CxCIRQ - CCB interrupt done/error/clear */
9488c2ecf20Sopenharmony_ci	u32 rsvd6;
9498c2ecf20Sopenharmony_ci	u32 clr_written;	/* CxCWR - Clear-Written */
9508c2ecf20Sopenharmony_ci	u32 ccb_status_hi;	/* CxCSTA - CCB Status/Error */
9518c2ecf20Sopenharmony_ci	u32 ccb_status_lo;
9528c2ecf20Sopenharmony_ci	u32 rsvd7[3];
9538c2ecf20Sopenharmony_ci	u32 aad_size;	/* CxAADSZR - Current AAD Size */
9548c2ecf20Sopenharmony_ci	u32 rsvd8;
9558c2ecf20Sopenharmony_ci	u32 cls1_iv_size;	/* CxC1IVSZR - Current Class 1 IV Size */
9568c2ecf20Sopenharmony_ci	u32 rsvd9[7];
9578c2ecf20Sopenharmony_ci	u32 pkha_a_size;	/* PKASZRx - Size of PKHA A */
9588c2ecf20Sopenharmony_ci	u32 rsvd10;
9598c2ecf20Sopenharmony_ci	u32 pkha_b_size;	/* PKBSZRx - Size of PKHA B */
9608c2ecf20Sopenharmony_ci	u32 rsvd11;
9618c2ecf20Sopenharmony_ci	u32 pkha_n_size;	/* PKNSZRx - Size of PKHA N */
9628c2ecf20Sopenharmony_ci	u32 rsvd12;
9638c2ecf20Sopenharmony_ci	u32 pkha_e_size;	/* PKESZRx - Size of PKHA E */
9648c2ecf20Sopenharmony_ci	u32 rsvd13[24];
9658c2ecf20Sopenharmony_ci	u32 cls1_ctx[16];	/* CxC1CTXR - Class 1 Context @100 */
9668c2ecf20Sopenharmony_ci	u32 rsvd14[48];
9678c2ecf20Sopenharmony_ci	u32 cls1_key[8];	/* CxC1KEYR - Class 1 Key @200 */
9688c2ecf20Sopenharmony_ci	u32 rsvd15[121];
9698c2ecf20Sopenharmony_ci	u32 cls2_mode;	/* CxC2MR - Class 2 Mode */
9708c2ecf20Sopenharmony_ci	u32 rsvd16;
9718c2ecf20Sopenharmony_ci	u32 cls2_keysize;	/* CxX2KSR - Class 2 Key Size */
9728c2ecf20Sopenharmony_ci	u32 cls2_datasize_hi;	/* CxC2DSR - Class 2 Data Size */
9738c2ecf20Sopenharmony_ci	u32 cls2_datasize_lo;
9748c2ecf20Sopenharmony_ci	u32 rsvd17;
9758c2ecf20Sopenharmony_ci	u32 cls2_icvsize;	/* CxC2ICVSZR - Class 2 ICV Size */
9768c2ecf20Sopenharmony_ci	u32 rsvd18[56];
9778c2ecf20Sopenharmony_ci	u32 cls2_ctx[18];	/* CxC2CTXR - Class 2 Context @500 */
9788c2ecf20Sopenharmony_ci	u32 rsvd19[46];
9798c2ecf20Sopenharmony_ci	u32 cls2_key[32];	/* CxC2KEYR - Class2 Key @600 */
9808c2ecf20Sopenharmony_ci	u32 rsvd20[84];
9818c2ecf20Sopenharmony_ci	u32 inp_infofifo_hi;	/* CxIFIFO - Input Info FIFO @7d0 */
9828c2ecf20Sopenharmony_ci	u32 inp_infofifo_lo;
9838c2ecf20Sopenharmony_ci	u32 rsvd21[2];
9848c2ecf20Sopenharmony_ci	u64 inp_datafifo;	/* CxDFIFO - Input Data FIFO */
9858c2ecf20Sopenharmony_ci	u32 rsvd22[2];
9868c2ecf20Sopenharmony_ci	u64 out_datafifo;	/* CxOFIFO - Output Data FIFO */
9878c2ecf20Sopenharmony_ci	u32 rsvd23[2];
9888c2ecf20Sopenharmony_ci	u32 jr_ctl_hi;	/* CxJRR - JobR Control Register      @800 */
9898c2ecf20Sopenharmony_ci	u32 jr_ctl_lo;
9908c2ecf20Sopenharmony_ci	u64 jr_descaddr;	/* CxDADR - JobR Descriptor Address */
9918c2ecf20Sopenharmony_ci#define DECO_OP_STATUS_HI_ERR_MASK 0xF00000FF
9928c2ecf20Sopenharmony_ci	u32 op_status_hi;	/* DxOPSTA - DECO Operation Status */
9938c2ecf20Sopenharmony_ci	u32 op_status_lo;
9948c2ecf20Sopenharmony_ci	u32 rsvd24[2];
9958c2ecf20Sopenharmony_ci	u32 liodn;		/* DxLSR - DECO LIODN Status - non-seq */
9968c2ecf20Sopenharmony_ci	u32 td_liodn;	/* DxLSR - DECO LIODN Status - trustdesc */
9978c2ecf20Sopenharmony_ci	u32 rsvd26[6];
9988c2ecf20Sopenharmony_ci	u64 math[4];		/* DxMTH - Math register */
9998c2ecf20Sopenharmony_ci	u32 rsvd27[8];
10008c2ecf20Sopenharmony_ci	struct deco_sg_table gthr_tbl[4];	/* DxGTR - Gather Tables */
10018c2ecf20Sopenharmony_ci	u32 rsvd28[16];
10028c2ecf20Sopenharmony_ci	struct deco_sg_table sctr_tbl[4];	/* DxSTR - Scatter Tables */
10038c2ecf20Sopenharmony_ci	u32 rsvd29[48];
10048c2ecf20Sopenharmony_ci	u32 descbuf[64];	/* DxDESB - Descriptor buffer */
10058c2ecf20Sopenharmony_ci	u32 rscvd30[193];
10068c2ecf20Sopenharmony_ci#define DESC_DBG_DECO_STAT_VALID	0x80000000
10078c2ecf20Sopenharmony_ci#define DESC_DBG_DECO_STAT_MASK		0x00F00000
10088c2ecf20Sopenharmony_ci#define DESC_DBG_DECO_STAT_SHIFT	20
10098c2ecf20Sopenharmony_ci	u32 desc_dbg;		/* DxDDR - DECO Debug Register */
10108c2ecf20Sopenharmony_ci	u32 rsvd31[13];
10118c2ecf20Sopenharmony_ci#define DESC_DER_DECO_STAT_MASK		0x000F0000
10128c2ecf20Sopenharmony_ci#define DESC_DER_DECO_STAT_SHIFT	16
10138c2ecf20Sopenharmony_ci	u32 dbg_exec;		/* DxDER - DECO Debug Exec Register */
10148c2ecf20Sopenharmony_ci	u32 rsvd32[112];
10158c2ecf20Sopenharmony_ci};
10168c2ecf20Sopenharmony_ci
10178c2ecf20Sopenharmony_ci#define DECO_STAT_HOST_ERR	0xD
10188c2ecf20Sopenharmony_ci
10198c2ecf20Sopenharmony_ci#define DECO_JQCR_WHL		0x20000000
10208c2ecf20Sopenharmony_ci#define DECO_JQCR_FOUR		0x10000000
10218c2ecf20Sopenharmony_ci
10228c2ecf20Sopenharmony_ci#define JR_BLOCK_NUMBER		1
10238c2ecf20Sopenharmony_ci#define ASSURE_BLOCK_NUMBER	6
10248c2ecf20Sopenharmony_ci#define QI_BLOCK_NUMBER		7
10258c2ecf20Sopenharmony_ci#define DECO_BLOCK_NUMBER	8
10268c2ecf20Sopenharmony_ci#define PG_SIZE_4K		0x1000
10278c2ecf20Sopenharmony_ci#define PG_SIZE_64K		0x10000
10288c2ecf20Sopenharmony_ci#endif /* REGS_H */
1029