162306a36Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Freescale SEC (talitos) device register and descriptor header defines 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Copyright (c) 2006-2011 Freescale Semiconductor, Inc. 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#define TALITOS_TIMEOUT 100000 962306a36Sopenharmony_ci#define TALITOS1_MAX_DATA_LEN 32768 1062306a36Sopenharmony_ci#define TALITOS2_MAX_DATA_LEN 65535 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#define DESC_TYPE(desc_hdr) ((be32_to_cpu(desc_hdr) >> 3) & 0x1f) 1362306a36Sopenharmony_ci#define PRIMARY_EU(desc_hdr) ((be32_to_cpu(desc_hdr) >> 28) & 0xf) 1462306a36Sopenharmony_ci#define SECONDARY_EU(desc_hdr) ((be32_to_cpu(desc_hdr) >> 16) & 0xf) 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* descriptor pointer entry */ 1762306a36Sopenharmony_cistruct talitos_ptr { 1862306a36Sopenharmony_ci union { 1962306a36Sopenharmony_ci struct { /* SEC2 format */ 2062306a36Sopenharmony_ci __be16 len; /* length */ 2162306a36Sopenharmony_ci u8 j_extent; /* jump to sg link table and/or extent*/ 2262306a36Sopenharmony_ci u8 eptr; /* extended address */ 2362306a36Sopenharmony_ci }; 2462306a36Sopenharmony_ci struct { /* SEC1 format */ 2562306a36Sopenharmony_ci __be16 res; 2662306a36Sopenharmony_ci __be16 len1; /* length */ 2762306a36Sopenharmony_ci }; 2862306a36Sopenharmony_ci }; 2962306a36Sopenharmony_ci __be32 ptr; /* address */ 3062306a36Sopenharmony_ci}; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci/* descriptor */ 3362306a36Sopenharmony_cistruct talitos_desc { 3462306a36Sopenharmony_ci __be32 hdr; /* header high bits */ 3562306a36Sopenharmony_ci union { 3662306a36Sopenharmony_ci __be32 hdr_lo; /* header low bits */ 3762306a36Sopenharmony_ci __be32 hdr1; /* header for SEC1 */ 3862306a36Sopenharmony_ci }; 3962306a36Sopenharmony_ci struct talitos_ptr ptr[7]; /* ptr/len pair array */ 4062306a36Sopenharmony_ci __be32 next_desc; /* next descriptor (SEC1) */ 4162306a36Sopenharmony_ci}; 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define TALITOS_DESC_SIZE (sizeof(struct talitos_desc) - sizeof(__be32)) 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci/* 4662306a36Sopenharmony_ci * talitos_edesc - s/w-extended descriptor 4762306a36Sopenharmony_ci * @src_nents: number of segments in input scatterlist 4862306a36Sopenharmony_ci * @dst_nents: number of segments in output scatterlist 4962306a36Sopenharmony_ci * @iv_dma: dma address of iv for checking continuity and link table 5062306a36Sopenharmony_ci * @dma_len: length of dma mapped link_tbl space 5162306a36Sopenharmony_ci * @dma_link_tbl: bus physical address of link_tbl/buf 5262306a36Sopenharmony_ci * @desc: h/w descriptor 5362306a36Sopenharmony_ci * @link_tbl: input and output h/w link tables (if {src,dst}_nents > 1) (SEC2) 5462306a36Sopenharmony_ci * @buf: input and output buffeur (if {src,dst}_nents > 1) (SEC1) 5562306a36Sopenharmony_ci * 5662306a36Sopenharmony_ci * if decrypting (with authcheck), or either one of src_nents or dst_nents 5762306a36Sopenharmony_ci * is greater than 1, an integrity check value is concatenated to the end 5862306a36Sopenharmony_ci * of link_tbl data 5962306a36Sopenharmony_ci */ 6062306a36Sopenharmony_cistruct talitos_edesc { 6162306a36Sopenharmony_ci int src_nents; 6262306a36Sopenharmony_ci int dst_nents; 6362306a36Sopenharmony_ci dma_addr_t iv_dma; 6462306a36Sopenharmony_ci int dma_len; 6562306a36Sopenharmony_ci dma_addr_t dma_link_tbl; 6662306a36Sopenharmony_ci struct talitos_desc desc; 6762306a36Sopenharmony_ci union { 6862306a36Sopenharmony_ci DECLARE_FLEX_ARRAY(struct talitos_ptr, link_tbl); 6962306a36Sopenharmony_ci DECLARE_FLEX_ARRAY(u8, buf); 7062306a36Sopenharmony_ci }; 7162306a36Sopenharmony_ci}; 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci/** 7462306a36Sopenharmony_ci * talitos_request - descriptor submission request 7562306a36Sopenharmony_ci * @desc: descriptor pointer (kernel virtual) 7662306a36Sopenharmony_ci * @dma_desc: descriptor's physical bus address 7762306a36Sopenharmony_ci * @callback: whom to call when descriptor processing is done 7862306a36Sopenharmony_ci * @context: caller context (optional) 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_cistruct talitos_request { 8162306a36Sopenharmony_ci struct talitos_desc *desc; 8262306a36Sopenharmony_ci dma_addr_t dma_desc; 8362306a36Sopenharmony_ci void (*callback) (struct device *dev, struct talitos_desc *desc, 8462306a36Sopenharmony_ci void *context, int error); 8562306a36Sopenharmony_ci void *context; 8662306a36Sopenharmony_ci}; 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci/* per-channel fifo management */ 8962306a36Sopenharmony_cistruct talitos_channel { 9062306a36Sopenharmony_ci void __iomem *reg; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci /* request fifo */ 9362306a36Sopenharmony_ci struct talitos_request *fifo; 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci /* number of requests pending in channel h/w fifo */ 9662306a36Sopenharmony_ci atomic_t submit_count ____cacheline_aligned; 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci /* request submission (head) lock */ 9962306a36Sopenharmony_ci spinlock_t head_lock ____cacheline_aligned; 10062306a36Sopenharmony_ci /* index to next free descriptor request */ 10162306a36Sopenharmony_ci int head; 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci /* request release (tail) lock */ 10462306a36Sopenharmony_ci spinlock_t tail_lock ____cacheline_aligned; 10562306a36Sopenharmony_ci /* index to next in-progress/done descriptor request */ 10662306a36Sopenharmony_ci int tail; 10762306a36Sopenharmony_ci}; 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_cistruct talitos_private { 11062306a36Sopenharmony_ci struct device *dev; 11162306a36Sopenharmony_ci struct platform_device *ofdev; 11262306a36Sopenharmony_ci void __iomem *reg; 11362306a36Sopenharmony_ci void __iomem *reg_deu; 11462306a36Sopenharmony_ci void __iomem *reg_aesu; 11562306a36Sopenharmony_ci void __iomem *reg_mdeu; 11662306a36Sopenharmony_ci void __iomem *reg_afeu; 11762306a36Sopenharmony_ci void __iomem *reg_rngu; 11862306a36Sopenharmony_ci void __iomem *reg_pkeu; 11962306a36Sopenharmony_ci void __iomem *reg_keu; 12062306a36Sopenharmony_ci void __iomem *reg_crcu; 12162306a36Sopenharmony_ci int irq[2]; 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci /* SEC global registers lock */ 12462306a36Sopenharmony_ci spinlock_t reg_lock ____cacheline_aligned; 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci /* SEC version geometry (from device tree node) */ 12762306a36Sopenharmony_ci unsigned int num_channels; 12862306a36Sopenharmony_ci unsigned int chfifo_len; 12962306a36Sopenharmony_ci unsigned int exec_units; 13062306a36Sopenharmony_ci unsigned int desc_types; 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci /* SEC Compatibility info */ 13362306a36Sopenharmony_ci unsigned long features; 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci /* 13662306a36Sopenharmony_ci * length of the request fifo 13762306a36Sopenharmony_ci * fifo_len is chfifo_len rounded up to next power of 2 13862306a36Sopenharmony_ci * so we can use bitwise ops to wrap 13962306a36Sopenharmony_ci */ 14062306a36Sopenharmony_ci unsigned int fifo_len; 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci struct talitos_channel *chan; 14362306a36Sopenharmony_ci 14462306a36Sopenharmony_ci /* next channel to be assigned next incoming descriptor */ 14562306a36Sopenharmony_ci atomic_t last_chan ____cacheline_aligned; 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ci /* request callback tasklet */ 14862306a36Sopenharmony_ci struct tasklet_struct done_task[2]; 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci /* list of registered algorithms */ 15162306a36Sopenharmony_ci struct list_head alg_list; 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci /* hwrng device */ 15462306a36Sopenharmony_ci struct hwrng rng; 15562306a36Sopenharmony_ci bool rng_registered; 15662306a36Sopenharmony_ci}; 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci/* .features flag */ 15962306a36Sopenharmony_ci#define TALITOS_FTR_SRC_LINK_TBL_LEN_INCLUDES_EXTENT 0x00000001 16062306a36Sopenharmony_ci#define TALITOS_FTR_HW_AUTH_CHECK 0x00000002 16162306a36Sopenharmony_ci#define TALITOS_FTR_SHA224_HWINIT 0x00000004 16262306a36Sopenharmony_ci#define TALITOS_FTR_HMAC_OK 0x00000008 16362306a36Sopenharmony_ci#define TALITOS_FTR_SEC1 0x00000010 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ci/* 16662306a36Sopenharmony_ci * If both CONFIG_CRYPTO_DEV_TALITOS1 and CONFIG_CRYPTO_DEV_TALITOS2 are 16762306a36Sopenharmony_ci * defined, we check the features which are set according to the device tree. 16862306a36Sopenharmony_ci * Otherwise, we answer true or false directly 16962306a36Sopenharmony_ci */ 17062306a36Sopenharmony_cistatic inline bool has_ftr_sec1(struct talitos_private *priv) 17162306a36Sopenharmony_ci{ 17262306a36Sopenharmony_ci if (IS_ENABLED(CONFIG_CRYPTO_DEV_TALITOS1) && 17362306a36Sopenharmony_ci IS_ENABLED(CONFIG_CRYPTO_DEV_TALITOS2)) 17462306a36Sopenharmony_ci return priv->features & TALITOS_FTR_SEC1; 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci return IS_ENABLED(CONFIG_CRYPTO_DEV_TALITOS1); 17762306a36Sopenharmony_ci} 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci/* 18062306a36Sopenharmony_ci * TALITOS_xxx_LO addresses point to the low data bits (32-63) of the register 18162306a36Sopenharmony_ci */ 18262306a36Sopenharmony_ci 18362306a36Sopenharmony_ci#define ISR1_FORMAT(x) (((x) << 28) | ((x) << 16)) 18462306a36Sopenharmony_ci#define ISR2_FORMAT(x) (((x) << 4) | (x)) 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci/* global register offset addresses */ 18762306a36Sopenharmony_ci#define TALITOS_MCR 0x1030 /* master control register */ 18862306a36Sopenharmony_ci#define TALITOS_MCR_RCA0 (1 << 15) /* remap channel 0 */ 18962306a36Sopenharmony_ci#define TALITOS_MCR_RCA1 (1 << 14) /* remap channel 1 */ 19062306a36Sopenharmony_ci#define TALITOS_MCR_RCA2 (1 << 13) /* remap channel 2 */ 19162306a36Sopenharmony_ci#define TALITOS_MCR_RCA3 (1 << 12) /* remap channel 3 */ 19262306a36Sopenharmony_ci#define TALITOS1_MCR_SWR 0x1000000 /* s/w reset */ 19362306a36Sopenharmony_ci#define TALITOS2_MCR_SWR 0x1 /* s/w reset */ 19462306a36Sopenharmony_ci#define TALITOS_MCR_LO 0x1034 19562306a36Sopenharmony_ci#define TALITOS_IMR 0x1008 /* interrupt mask register */ 19662306a36Sopenharmony_ci/* enable channel IRQs */ 19762306a36Sopenharmony_ci#define TALITOS1_IMR_INIT ISR1_FORMAT(0xf) 19862306a36Sopenharmony_ci#define TALITOS1_IMR_DONE ISR1_FORMAT(0x5) /* done IRQs */ 19962306a36Sopenharmony_ci/* enable channel IRQs */ 20062306a36Sopenharmony_ci#define TALITOS2_IMR_INIT (ISR2_FORMAT(0xf) | 0x10000) 20162306a36Sopenharmony_ci#define TALITOS2_IMR_DONE ISR1_FORMAT(0x5) /* done IRQs */ 20262306a36Sopenharmony_ci#define TALITOS_IMR_LO 0x100C 20362306a36Sopenharmony_ci#define TALITOS1_IMR_LO_INIT 0x2000000 /* allow RNGU error IRQs */ 20462306a36Sopenharmony_ci#define TALITOS2_IMR_LO_INIT 0x20000 /* allow RNGU error IRQs */ 20562306a36Sopenharmony_ci#define TALITOS_ISR 0x1010 /* interrupt status register */ 20662306a36Sopenharmony_ci#define TALITOS1_ISR_4CHERR ISR1_FORMAT(0xa) /* 4 ch errors mask */ 20762306a36Sopenharmony_ci#define TALITOS1_ISR_4CHDONE ISR1_FORMAT(0x5) /* 4 ch done mask */ 20862306a36Sopenharmony_ci#define TALITOS1_ISR_CH_0_ERR (2 << 28) /* ch 0 errors mask */ 20962306a36Sopenharmony_ci#define TALITOS1_ISR_CH_0_DONE (1 << 28) /* ch 0 done mask */ 21062306a36Sopenharmony_ci#define TALITOS1_ISR_TEA_ERR 0x00000040 21162306a36Sopenharmony_ci#define TALITOS2_ISR_4CHERR ISR2_FORMAT(0xa) /* 4 ch errors mask */ 21262306a36Sopenharmony_ci#define TALITOS2_ISR_4CHDONE ISR2_FORMAT(0x5) /* 4 ch done mask */ 21362306a36Sopenharmony_ci#define TALITOS2_ISR_CH_0_ERR 2 /* ch 0 errors mask */ 21462306a36Sopenharmony_ci#define TALITOS2_ISR_CH_0_DONE 1 /* ch 0 done mask */ 21562306a36Sopenharmony_ci#define TALITOS2_ISR_CH_0_2_ERR ISR2_FORMAT(0x2) /* ch 0, 2 err mask */ 21662306a36Sopenharmony_ci#define TALITOS2_ISR_CH_0_2_DONE ISR2_FORMAT(0x1) /* ch 0, 2 done mask */ 21762306a36Sopenharmony_ci#define TALITOS2_ISR_CH_1_3_ERR ISR2_FORMAT(0x8) /* ch 1, 3 err mask */ 21862306a36Sopenharmony_ci#define TALITOS2_ISR_CH_1_3_DONE ISR2_FORMAT(0x4) /* ch 1, 3 done mask */ 21962306a36Sopenharmony_ci#define TALITOS_ISR_LO 0x1014 22062306a36Sopenharmony_ci#define TALITOS_ICR 0x1018 /* interrupt clear register */ 22162306a36Sopenharmony_ci#define TALITOS_ICR_LO 0x101C 22262306a36Sopenharmony_ci 22362306a36Sopenharmony_ci/* channel register address stride */ 22462306a36Sopenharmony_ci#define TALITOS_CH_BASE_OFFSET 0x1000 /* default channel map base */ 22562306a36Sopenharmony_ci#define TALITOS1_CH_STRIDE 0x1000 22662306a36Sopenharmony_ci#define TALITOS2_CH_STRIDE 0x100 22762306a36Sopenharmony_ci 22862306a36Sopenharmony_ci/* channel configuration register */ 22962306a36Sopenharmony_ci#define TALITOS_CCCR 0x8 23062306a36Sopenharmony_ci#define TALITOS2_CCCR_CONT 0x2 /* channel continue on SEC2 */ 23162306a36Sopenharmony_ci#define TALITOS2_CCCR_RESET 0x1 /* channel reset on SEC2 */ 23262306a36Sopenharmony_ci#define TALITOS_CCCR_LO 0xc 23362306a36Sopenharmony_ci#define TALITOS_CCCR_LO_IWSE 0x80 /* chan. ICCR writeback enab. */ 23462306a36Sopenharmony_ci#define TALITOS_CCCR_LO_EAE 0x20 /* extended address enable */ 23562306a36Sopenharmony_ci#define TALITOS_CCCR_LO_CDWE 0x10 /* chan. done writeback enab. */ 23662306a36Sopenharmony_ci#define TALITOS_CCCR_LO_NE 0x8 /* fetch next descriptor enab. */ 23762306a36Sopenharmony_ci#define TALITOS_CCCR_LO_NT 0x4 /* notification type */ 23862306a36Sopenharmony_ci#define TALITOS_CCCR_LO_CDIE 0x2 /* channel done IRQ enable */ 23962306a36Sopenharmony_ci#define TALITOS1_CCCR_LO_RESET 0x1 /* channel reset on SEC1 */ 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci/* CCPSR: channel pointer status register */ 24262306a36Sopenharmony_ci#define TALITOS_CCPSR 0x10 24362306a36Sopenharmony_ci#define TALITOS_CCPSR_LO 0x14 24462306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_DOF 0x8000 /* double FF write oflow error */ 24562306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_SOF 0x4000 /* single FF write oflow error */ 24662306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_MDTE 0x2000 /* master data transfer error */ 24762306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_SGDLZ 0x1000 /* s/g data len zero error */ 24862306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_FPZ 0x0800 /* fetch ptr zero error */ 24962306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_IDH 0x0400 /* illegal desc hdr error */ 25062306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_IEU 0x0200 /* invalid EU error */ 25162306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_EU 0x0100 /* EU error detected */ 25262306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_GB 0x0080 /* gather boundary error */ 25362306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_GRL 0x0040 /* gather return/length error */ 25462306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_SB 0x0020 /* scatter boundary error */ 25562306a36Sopenharmony_ci#define TALITOS_CCPSR_LO_SRL 0x0010 /* scatter return/length error */ 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci/* channel fetch fifo register */ 25862306a36Sopenharmony_ci#define TALITOS_FF 0x48 25962306a36Sopenharmony_ci#define TALITOS_FF_LO 0x4c 26062306a36Sopenharmony_ci 26162306a36Sopenharmony_ci/* current descriptor pointer register */ 26262306a36Sopenharmony_ci#define TALITOS_CDPR 0x40 26362306a36Sopenharmony_ci#define TALITOS_CDPR_LO 0x44 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci/* descriptor buffer register */ 26662306a36Sopenharmony_ci#define TALITOS_DESCBUF 0x80 26762306a36Sopenharmony_ci#define TALITOS_DESCBUF_LO 0x84 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_ci/* gather link table */ 27062306a36Sopenharmony_ci#define TALITOS_GATHER 0xc0 27162306a36Sopenharmony_ci#define TALITOS_GATHER_LO 0xc4 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci/* scatter link table */ 27462306a36Sopenharmony_ci#define TALITOS_SCATTER 0xe0 27562306a36Sopenharmony_ci#define TALITOS_SCATTER_LO 0xe4 27662306a36Sopenharmony_ci 27762306a36Sopenharmony_ci/* execution unit registers base */ 27862306a36Sopenharmony_ci#define TALITOS2_DEU 0x2000 27962306a36Sopenharmony_ci#define TALITOS2_AESU 0x4000 28062306a36Sopenharmony_ci#define TALITOS2_MDEU 0x6000 28162306a36Sopenharmony_ci#define TALITOS2_AFEU 0x8000 28262306a36Sopenharmony_ci#define TALITOS2_RNGU 0xa000 28362306a36Sopenharmony_ci#define TALITOS2_PKEU 0xc000 28462306a36Sopenharmony_ci#define TALITOS2_KEU 0xe000 28562306a36Sopenharmony_ci#define TALITOS2_CRCU 0xf000 28662306a36Sopenharmony_ci 28762306a36Sopenharmony_ci#define TALITOS12_AESU 0x4000 28862306a36Sopenharmony_ci#define TALITOS12_DEU 0x5000 28962306a36Sopenharmony_ci#define TALITOS12_MDEU 0x6000 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci#define TALITOS10_AFEU 0x8000 29262306a36Sopenharmony_ci#define TALITOS10_DEU 0xa000 29362306a36Sopenharmony_ci#define TALITOS10_MDEU 0xc000 29462306a36Sopenharmony_ci#define TALITOS10_RNGU 0xe000 29562306a36Sopenharmony_ci#define TALITOS10_PKEU 0x10000 29662306a36Sopenharmony_ci#define TALITOS10_AESU 0x12000 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci/* execution unit interrupt status registers */ 29962306a36Sopenharmony_ci#define TALITOS_EUDSR 0x10 /* data size */ 30062306a36Sopenharmony_ci#define TALITOS_EUDSR_LO 0x14 30162306a36Sopenharmony_ci#define TALITOS_EURCR 0x18 /* reset control*/ 30262306a36Sopenharmony_ci#define TALITOS_EURCR_LO 0x1c 30362306a36Sopenharmony_ci#define TALITOS_EUSR 0x28 /* rng status */ 30462306a36Sopenharmony_ci#define TALITOS_EUSR_LO 0x2c 30562306a36Sopenharmony_ci#define TALITOS_EUISR 0x30 30662306a36Sopenharmony_ci#define TALITOS_EUISR_LO 0x34 30762306a36Sopenharmony_ci#define TALITOS_EUICR 0x38 /* int. control */ 30862306a36Sopenharmony_ci#define TALITOS_EUICR_LO 0x3c 30962306a36Sopenharmony_ci#define TALITOS_EU_FIFO 0x800 /* output FIFO */ 31062306a36Sopenharmony_ci#define TALITOS_EU_FIFO_LO 0x804 /* output FIFO */ 31162306a36Sopenharmony_ci/* DES unit */ 31262306a36Sopenharmony_ci#define TALITOS1_DEUICR_KPE 0x00200000 /* Key Parity Error */ 31362306a36Sopenharmony_ci/* message digest unit */ 31462306a36Sopenharmony_ci#define TALITOS_MDEUICR_LO_ICE 0x4000 /* integrity check IRQ enable */ 31562306a36Sopenharmony_ci/* random number unit */ 31662306a36Sopenharmony_ci#define TALITOS_RNGUSR_LO_RD 0x1 /* reset done */ 31762306a36Sopenharmony_ci#define TALITOS_RNGUSR_LO_OFL 0xff0000/* output FIFO length */ 31862306a36Sopenharmony_ci#define TALITOS_RNGURCR_LO_SR 0x1 /* software reset */ 31962306a36Sopenharmony_ci 32062306a36Sopenharmony_ci#define TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256 0x28 32162306a36Sopenharmony_ci#define TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512 0x48 32262306a36Sopenharmony_ci 32362306a36Sopenharmony_ci/* 32462306a36Sopenharmony_ci * talitos descriptor header (hdr) bits 32562306a36Sopenharmony_ci */ 32662306a36Sopenharmony_ci 32762306a36Sopenharmony_ci/* written back when done */ 32862306a36Sopenharmony_ci#define DESC_HDR_DONE cpu_to_be32(0xff000000) 32962306a36Sopenharmony_ci#define DESC_HDR_LO_ICCR1_MASK cpu_to_be32(0x00180000) 33062306a36Sopenharmony_ci#define DESC_HDR_LO_ICCR1_PASS cpu_to_be32(0x00080000) 33162306a36Sopenharmony_ci#define DESC_HDR_LO_ICCR1_FAIL cpu_to_be32(0x00100000) 33262306a36Sopenharmony_ci 33362306a36Sopenharmony_ci/* primary execution unit select */ 33462306a36Sopenharmony_ci#define DESC_HDR_SEL0_MASK cpu_to_be32(0xf0000000) 33562306a36Sopenharmony_ci#define DESC_HDR_SEL0_AFEU cpu_to_be32(0x10000000) 33662306a36Sopenharmony_ci#define DESC_HDR_SEL0_DEU cpu_to_be32(0x20000000) 33762306a36Sopenharmony_ci#define DESC_HDR_SEL0_MDEUA cpu_to_be32(0x30000000) 33862306a36Sopenharmony_ci#define DESC_HDR_SEL0_MDEUB cpu_to_be32(0xb0000000) 33962306a36Sopenharmony_ci#define DESC_HDR_SEL0_RNG cpu_to_be32(0x40000000) 34062306a36Sopenharmony_ci#define DESC_HDR_SEL0_PKEU cpu_to_be32(0x50000000) 34162306a36Sopenharmony_ci#define DESC_HDR_SEL0_AESU cpu_to_be32(0x60000000) 34262306a36Sopenharmony_ci#define DESC_HDR_SEL0_KEU cpu_to_be32(0x70000000) 34362306a36Sopenharmony_ci#define DESC_HDR_SEL0_CRCU cpu_to_be32(0x80000000) 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ci/* primary execution unit mode (MODE0) and derivatives */ 34662306a36Sopenharmony_ci#define DESC_HDR_MODE0_ENCRYPT cpu_to_be32(0x00100000) 34762306a36Sopenharmony_ci#define DESC_HDR_MODE0_AESU_MASK cpu_to_be32(0x00600000) 34862306a36Sopenharmony_ci#define DESC_HDR_MODE0_AESU_CBC cpu_to_be32(0x00200000) 34962306a36Sopenharmony_ci#define DESC_HDR_MODE0_AESU_CTR cpu_to_be32(0x00600000) 35062306a36Sopenharmony_ci#define DESC_HDR_MODE0_DEU_CBC cpu_to_be32(0x00400000) 35162306a36Sopenharmony_ci#define DESC_HDR_MODE0_DEU_3DES cpu_to_be32(0x00200000) 35262306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_CONT cpu_to_be32(0x08000000) 35362306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_INIT cpu_to_be32(0x01000000) 35462306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_HMAC cpu_to_be32(0x00800000) 35562306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_PAD cpu_to_be32(0x00400000) 35662306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA224 cpu_to_be32(0x00300000) 35762306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_MD5 cpu_to_be32(0x00200000) 35862306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA256 cpu_to_be32(0x00100000) 35962306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA1 cpu_to_be32(0x00000000) 36062306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEUB_SHA384 cpu_to_be32(0x00000000) 36162306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEUB_SHA512 cpu_to_be32(0x00200000) 36262306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_MD5_HMAC (DESC_HDR_MODE0_MDEU_MD5 | \ 36362306a36Sopenharmony_ci DESC_HDR_MODE0_MDEU_HMAC) 36462306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA256_HMAC (DESC_HDR_MODE0_MDEU_SHA256 | \ 36562306a36Sopenharmony_ci DESC_HDR_MODE0_MDEU_HMAC) 36662306a36Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA1_HMAC (DESC_HDR_MODE0_MDEU_SHA1 | \ 36762306a36Sopenharmony_ci DESC_HDR_MODE0_MDEU_HMAC) 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ci/* secondary execution unit select (SEL1) */ 37062306a36Sopenharmony_ci#define DESC_HDR_SEL1_MASK cpu_to_be32(0x000f0000) 37162306a36Sopenharmony_ci#define DESC_HDR_SEL1_MDEUA cpu_to_be32(0x00030000) 37262306a36Sopenharmony_ci#define DESC_HDR_SEL1_MDEUB cpu_to_be32(0x000b0000) 37362306a36Sopenharmony_ci#define DESC_HDR_SEL1_CRCU cpu_to_be32(0x00080000) 37462306a36Sopenharmony_ci 37562306a36Sopenharmony_ci/* secondary execution unit mode (MODE1) and derivatives */ 37662306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_CICV cpu_to_be32(0x00004000) 37762306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_INIT cpu_to_be32(0x00001000) 37862306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_HMAC cpu_to_be32(0x00000800) 37962306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_PAD cpu_to_be32(0x00000400) 38062306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA224 cpu_to_be32(0x00000300) 38162306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_MD5 cpu_to_be32(0x00000200) 38262306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA256 cpu_to_be32(0x00000100) 38362306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA1 cpu_to_be32(0x00000000) 38462306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEUB_SHA384 cpu_to_be32(0x00000000) 38562306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEUB_SHA512 cpu_to_be32(0x00000200) 38662306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_MD5_HMAC (DESC_HDR_MODE1_MDEU_MD5 | \ 38762306a36Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 38862306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA256_HMAC (DESC_HDR_MODE1_MDEU_SHA256 | \ 38962306a36Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 39062306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA1_HMAC (DESC_HDR_MODE1_MDEU_SHA1 | \ 39162306a36Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 39262306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA224_HMAC (DESC_HDR_MODE1_MDEU_SHA224 | \ 39362306a36Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 39462306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEUB_SHA384_HMAC (DESC_HDR_MODE1_MDEUB_SHA384 | \ 39562306a36Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 39662306a36Sopenharmony_ci#define DESC_HDR_MODE1_MDEUB_SHA512_HMAC (DESC_HDR_MODE1_MDEUB_SHA512 | \ 39762306a36Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_ci/* direction of overall data flow (DIR) */ 40062306a36Sopenharmony_ci#define DESC_HDR_DIR_INBOUND cpu_to_be32(0x00000002) 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_ci/* request done notification (DN) */ 40362306a36Sopenharmony_ci#define DESC_HDR_DONE_NOTIFY cpu_to_be32(0x00000001) 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci/* descriptor types */ 40662306a36Sopenharmony_ci#define DESC_HDR_TYPE_AESU_CTR_NONSNOOP cpu_to_be32(0 << 3) 40762306a36Sopenharmony_ci#define DESC_HDR_TYPE_IPSEC_ESP cpu_to_be32(1 << 3) 40862306a36Sopenharmony_ci#define DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU cpu_to_be32(2 << 3) 40962306a36Sopenharmony_ci#define DESC_HDR_TYPE_HMAC_SNOOP_NO_AFEU cpu_to_be32(4 << 3) 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci/* link table extent field bits */ 41262306a36Sopenharmony_ci#define DESC_PTR_LNKTBL_JUMP 0x80 41362306a36Sopenharmony_ci#define DESC_PTR_LNKTBL_RET 0x02 41462306a36Sopenharmony_ci#define DESC_PTR_LNKTBL_NEXT 0x01 415