18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: BSD-3-Clause */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Freescale SEC (talitos) device register and descriptor header defines 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2006-2011 Freescale Semiconductor, Inc. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#define TALITOS_TIMEOUT 100000 98c2ecf20Sopenharmony_ci#define TALITOS1_MAX_DATA_LEN 32768 108c2ecf20Sopenharmony_ci#define TALITOS2_MAX_DATA_LEN 65535 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#define DESC_TYPE(desc_hdr) ((be32_to_cpu(desc_hdr) >> 3) & 0x1f) 138c2ecf20Sopenharmony_ci#define PRIMARY_EU(desc_hdr) ((be32_to_cpu(desc_hdr) >> 28) & 0xf) 148c2ecf20Sopenharmony_ci#define SECONDARY_EU(desc_hdr) ((be32_to_cpu(desc_hdr) >> 16) & 0xf) 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* descriptor pointer entry */ 178c2ecf20Sopenharmony_cistruct talitos_ptr { 188c2ecf20Sopenharmony_ci union { 198c2ecf20Sopenharmony_ci struct { /* SEC2 format */ 208c2ecf20Sopenharmony_ci __be16 len; /* length */ 218c2ecf20Sopenharmony_ci u8 j_extent; /* jump to sg link table and/or extent*/ 228c2ecf20Sopenharmony_ci u8 eptr; /* extended address */ 238c2ecf20Sopenharmony_ci }; 248c2ecf20Sopenharmony_ci struct { /* SEC1 format */ 258c2ecf20Sopenharmony_ci __be16 res; 268c2ecf20Sopenharmony_ci __be16 len1; /* length */ 278c2ecf20Sopenharmony_ci }; 288c2ecf20Sopenharmony_ci }; 298c2ecf20Sopenharmony_ci __be32 ptr; /* address */ 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* descriptor */ 338c2ecf20Sopenharmony_cistruct talitos_desc { 348c2ecf20Sopenharmony_ci __be32 hdr; /* header high bits */ 358c2ecf20Sopenharmony_ci union { 368c2ecf20Sopenharmony_ci __be32 hdr_lo; /* header low bits */ 378c2ecf20Sopenharmony_ci __be32 hdr1; /* header for SEC1 */ 388c2ecf20Sopenharmony_ci }; 398c2ecf20Sopenharmony_ci struct talitos_ptr ptr[7]; /* ptr/len pair array */ 408c2ecf20Sopenharmony_ci __be32 next_desc; /* next descriptor (SEC1) */ 418c2ecf20Sopenharmony_ci}; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#define TALITOS_DESC_SIZE (sizeof(struct talitos_desc) - sizeof(__be32)) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * talitos_edesc - s/w-extended descriptor 478c2ecf20Sopenharmony_ci * @src_nents: number of segments in input scatterlist 488c2ecf20Sopenharmony_ci * @dst_nents: number of segments in output scatterlist 498c2ecf20Sopenharmony_ci * @iv_dma: dma address of iv for checking continuity and link table 508c2ecf20Sopenharmony_ci * @dma_len: length of dma mapped link_tbl space 518c2ecf20Sopenharmony_ci * @dma_link_tbl: bus physical address of link_tbl/buf 528c2ecf20Sopenharmony_ci * @desc: h/w descriptor 538c2ecf20Sopenharmony_ci * @link_tbl: input and output h/w link tables (if {src,dst}_nents > 1) (SEC2) 548c2ecf20Sopenharmony_ci * @buf: input and output buffeur (if {src,dst}_nents > 1) (SEC1) 558c2ecf20Sopenharmony_ci * 568c2ecf20Sopenharmony_ci * if decrypting (with authcheck), or either one of src_nents or dst_nents 578c2ecf20Sopenharmony_ci * is greater than 1, an integrity check value is concatenated to the end 588c2ecf20Sopenharmony_ci * of link_tbl data 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_cistruct talitos_edesc { 618c2ecf20Sopenharmony_ci int src_nents; 628c2ecf20Sopenharmony_ci int dst_nents; 638c2ecf20Sopenharmony_ci dma_addr_t iv_dma; 648c2ecf20Sopenharmony_ci int dma_len; 658c2ecf20Sopenharmony_ci dma_addr_t dma_link_tbl; 668c2ecf20Sopenharmony_ci struct talitos_desc desc; 678c2ecf20Sopenharmony_ci union { 688c2ecf20Sopenharmony_ci struct talitos_ptr link_tbl[0]; 698c2ecf20Sopenharmony_ci u8 buf[0]; 708c2ecf20Sopenharmony_ci }; 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/** 748c2ecf20Sopenharmony_ci * talitos_request - descriptor submission request 758c2ecf20Sopenharmony_ci * @desc: descriptor pointer (kernel virtual) 768c2ecf20Sopenharmony_ci * @dma_desc: descriptor's physical bus address 778c2ecf20Sopenharmony_ci * @callback: whom to call when descriptor processing is done 788c2ecf20Sopenharmony_ci * @context: caller context (optional) 798c2ecf20Sopenharmony_ci */ 808c2ecf20Sopenharmony_cistruct talitos_request { 818c2ecf20Sopenharmony_ci struct talitos_desc *desc; 828c2ecf20Sopenharmony_ci dma_addr_t dma_desc; 838c2ecf20Sopenharmony_ci void (*callback) (struct device *dev, struct talitos_desc *desc, 848c2ecf20Sopenharmony_ci void *context, int error); 858c2ecf20Sopenharmony_ci void *context; 868c2ecf20Sopenharmony_ci}; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* per-channel fifo management */ 898c2ecf20Sopenharmony_cistruct talitos_channel { 908c2ecf20Sopenharmony_ci void __iomem *reg; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci /* request fifo */ 938c2ecf20Sopenharmony_ci struct talitos_request *fifo; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci /* number of requests pending in channel h/w fifo */ 968c2ecf20Sopenharmony_ci atomic_t submit_count ____cacheline_aligned; 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci /* request submission (head) lock */ 998c2ecf20Sopenharmony_ci spinlock_t head_lock ____cacheline_aligned; 1008c2ecf20Sopenharmony_ci /* index to next free descriptor request */ 1018c2ecf20Sopenharmony_ci int head; 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci /* request release (tail) lock */ 1048c2ecf20Sopenharmony_ci spinlock_t tail_lock ____cacheline_aligned; 1058c2ecf20Sopenharmony_ci /* index to next in-progress/done descriptor request */ 1068c2ecf20Sopenharmony_ci int tail; 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_cistruct talitos_private { 1108c2ecf20Sopenharmony_ci struct device *dev; 1118c2ecf20Sopenharmony_ci struct platform_device *ofdev; 1128c2ecf20Sopenharmony_ci void __iomem *reg; 1138c2ecf20Sopenharmony_ci void __iomem *reg_deu; 1148c2ecf20Sopenharmony_ci void __iomem *reg_aesu; 1158c2ecf20Sopenharmony_ci void __iomem *reg_mdeu; 1168c2ecf20Sopenharmony_ci void __iomem *reg_afeu; 1178c2ecf20Sopenharmony_ci void __iomem *reg_rngu; 1188c2ecf20Sopenharmony_ci void __iomem *reg_pkeu; 1198c2ecf20Sopenharmony_ci void __iomem *reg_keu; 1208c2ecf20Sopenharmony_ci void __iomem *reg_crcu; 1218c2ecf20Sopenharmony_ci int irq[2]; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci /* SEC global registers lock */ 1248c2ecf20Sopenharmony_ci spinlock_t reg_lock ____cacheline_aligned; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci /* SEC version geometry (from device tree node) */ 1278c2ecf20Sopenharmony_ci unsigned int num_channels; 1288c2ecf20Sopenharmony_ci unsigned int chfifo_len; 1298c2ecf20Sopenharmony_ci unsigned int exec_units; 1308c2ecf20Sopenharmony_ci unsigned int desc_types; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci /* SEC Compatibility info */ 1338c2ecf20Sopenharmony_ci unsigned long features; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_ci /* 1368c2ecf20Sopenharmony_ci * length of the request fifo 1378c2ecf20Sopenharmony_ci * fifo_len is chfifo_len rounded up to next power of 2 1388c2ecf20Sopenharmony_ci * so we can use bitwise ops to wrap 1398c2ecf20Sopenharmony_ci */ 1408c2ecf20Sopenharmony_ci unsigned int fifo_len; 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci struct talitos_channel *chan; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci /* next channel to be assigned next incoming descriptor */ 1458c2ecf20Sopenharmony_ci atomic_t last_chan ____cacheline_aligned; 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci /* request callback tasklet */ 1488c2ecf20Sopenharmony_ci struct tasklet_struct done_task[2]; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci /* list of registered algorithms */ 1518c2ecf20Sopenharmony_ci struct list_head alg_list; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci /* hwrng device */ 1548c2ecf20Sopenharmony_ci struct hwrng rng; 1558c2ecf20Sopenharmony_ci bool rng_registered; 1568c2ecf20Sopenharmony_ci}; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci/* .features flag */ 1598c2ecf20Sopenharmony_ci#define TALITOS_FTR_SRC_LINK_TBL_LEN_INCLUDES_EXTENT 0x00000001 1608c2ecf20Sopenharmony_ci#define TALITOS_FTR_HW_AUTH_CHECK 0x00000002 1618c2ecf20Sopenharmony_ci#define TALITOS_FTR_SHA224_HWINIT 0x00000004 1628c2ecf20Sopenharmony_ci#define TALITOS_FTR_HMAC_OK 0x00000008 1638c2ecf20Sopenharmony_ci#define TALITOS_FTR_SEC1 0x00000010 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci/* 1668c2ecf20Sopenharmony_ci * If both CONFIG_CRYPTO_DEV_TALITOS1 and CONFIG_CRYPTO_DEV_TALITOS2 are 1678c2ecf20Sopenharmony_ci * defined, we check the features which are set according to the device tree. 1688c2ecf20Sopenharmony_ci * Otherwise, we answer true or false directly 1698c2ecf20Sopenharmony_ci */ 1708c2ecf20Sopenharmony_cistatic inline bool has_ftr_sec1(struct talitos_private *priv) 1718c2ecf20Sopenharmony_ci{ 1728c2ecf20Sopenharmony_ci if (IS_ENABLED(CONFIG_CRYPTO_DEV_TALITOS1) && 1738c2ecf20Sopenharmony_ci IS_ENABLED(CONFIG_CRYPTO_DEV_TALITOS2)) 1748c2ecf20Sopenharmony_ci return priv->features & TALITOS_FTR_SEC1; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci return IS_ENABLED(CONFIG_CRYPTO_DEV_TALITOS1); 1778c2ecf20Sopenharmony_ci} 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci/* 1808c2ecf20Sopenharmony_ci * TALITOS_xxx_LO addresses point to the low data bits (32-63) of the register 1818c2ecf20Sopenharmony_ci */ 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci#define ISR1_FORMAT(x) (((x) << 28) | ((x) << 16)) 1848c2ecf20Sopenharmony_ci#define ISR2_FORMAT(x) (((x) << 4) | (x)) 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci/* global register offset addresses */ 1878c2ecf20Sopenharmony_ci#define TALITOS_MCR 0x1030 /* master control register */ 1888c2ecf20Sopenharmony_ci#define TALITOS_MCR_RCA0 (1 << 15) /* remap channel 0 */ 1898c2ecf20Sopenharmony_ci#define TALITOS_MCR_RCA1 (1 << 14) /* remap channel 1 */ 1908c2ecf20Sopenharmony_ci#define TALITOS_MCR_RCA2 (1 << 13) /* remap channel 2 */ 1918c2ecf20Sopenharmony_ci#define TALITOS_MCR_RCA3 (1 << 12) /* remap channel 3 */ 1928c2ecf20Sopenharmony_ci#define TALITOS1_MCR_SWR 0x1000000 /* s/w reset */ 1938c2ecf20Sopenharmony_ci#define TALITOS2_MCR_SWR 0x1 /* s/w reset */ 1948c2ecf20Sopenharmony_ci#define TALITOS_MCR_LO 0x1034 1958c2ecf20Sopenharmony_ci#define TALITOS_IMR 0x1008 /* interrupt mask register */ 1968c2ecf20Sopenharmony_ci/* enable channel IRQs */ 1978c2ecf20Sopenharmony_ci#define TALITOS1_IMR_INIT ISR1_FORMAT(0xf) 1988c2ecf20Sopenharmony_ci#define TALITOS1_IMR_DONE ISR1_FORMAT(0x5) /* done IRQs */ 1998c2ecf20Sopenharmony_ci/* enable channel IRQs */ 2008c2ecf20Sopenharmony_ci#define TALITOS2_IMR_INIT (ISR2_FORMAT(0xf) | 0x10000) 2018c2ecf20Sopenharmony_ci#define TALITOS2_IMR_DONE ISR1_FORMAT(0x5) /* done IRQs */ 2028c2ecf20Sopenharmony_ci#define TALITOS_IMR_LO 0x100C 2038c2ecf20Sopenharmony_ci#define TALITOS1_IMR_LO_INIT 0x2000000 /* allow RNGU error IRQs */ 2048c2ecf20Sopenharmony_ci#define TALITOS2_IMR_LO_INIT 0x20000 /* allow RNGU error IRQs */ 2058c2ecf20Sopenharmony_ci#define TALITOS_ISR 0x1010 /* interrupt status register */ 2068c2ecf20Sopenharmony_ci#define TALITOS1_ISR_4CHERR ISR1_FORMAT(0xa) /* 4 ch errors mask */ 2078c2ecf20Sopenharmony_ci#define TALITOS1_ISR_4CHDONE ISR1_FORMAT(0x5) /* 4 ch done mask */ 2088c2ecf20Sopenharmony_ci#define TALITOS1_ISR_CH_0_ERR (2 << 28) /* ch 0 errors mask */ 2098c2ecf20Sopenharmony_ci#define TALITOS1_ISR_CH_0_DONE (1 << 28) /* ch 0 done mask */ 2108c2ecf20Sopenharmony_ci#define TALITOS1_ISR_TEA_ERR 0x00000040 2118c2ecf20Sopenharmony_ci#define TALITOS2_ISR_4CHERR ISR2_FORMAT(0xa) /* 4 ch errors mask */ 2128c2ecf20Sopenharmony_ci#define TALITOS2_ISR_4CHDONE ISR2_FORMAT(0x5) /* 4 ch done mask */ 2138c2ecf20Sopenharmony_ci#define TALITOS2_ISR_CH_0_ERR 2 /* ch 0 errors mask */ 2148c2ecf20Sopenharmony_ci#define TALITOS2_ISR_CH_0_DONE 1 /* ch 0 done mask */ 2158c2ecf20Sopenharmony_ci#define TALITOS2_ISR_CH_0_2_ERR ISR2_FORMAT(0x2) /* ch 0, 2 err mask */ 2168c2ecf20Sopenharmony_ci#define TALITOS2_ISR_CH_0_2_DONE ISR2_FORMAT(0x1) /* ch 0, 2 done mask */ 2178c2ecf20Sopenharmony_ci#define TALITOS2_ISR_CH_1_3_ERR ISR2_FORMAT(0x8) /* ch 1, 3 err mask */ 2188c2ecf20Sopenharmony_ci#define TALITOS2_ISR_CH_1_3_DONE ISR2_FORMAT(0x4) /* ch 1, 3 done mask */ 2198c2ecf20Sopenharmony_ci#define TALITOS_ISR_LO 0x1014 2208c2ecf20Sopenharmony_ci#define TALITOS_ICR 0x1018 /* interrupt clear register */ 2218c2ecf20Sopenharmony_ci#define TALITOS_ICR_LO 0x101C 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci/* channel register address stride */ 2248c2ecf20Sopenharmony_ci#define TALITOS_CH_BASE_OFFSET 0x1000 /* default channel map base */ 2258c2ecf20Sopenharmony_ci#define TALITOS1_CH_STRIDE 0x1000 2268c2ecf20Sopenharmony_ci#define TALITOS2_CH_STRIDE 0x100 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci/* channel configuration register */ 2298c2ecf20Sopenharmony_ci#define TALITOS_CCCR 0x8 2308c2ecf20Sopenharmony_ci#define TALITOS2_CCCR_CONT 0x2 /* channel continue on SEC2 */ 2318c2ecf20Sopenharmony_ci#define TALITOS2_CCCR_RESET 0x1 /* channel reset on SEC2 */ 2328c2ecf20Sopenharmony_ci#define TALITOS_CCCR_LO 0xc 2338c2ecf20Sopenharmony_ci#define TALITOS_CCCR_LO_IWSE 0x80 /* chan. ICCR writeback enab. */ 2348c2ecf20Sopenharmony_ci#define TALITOS_CCCR_LO_EAE 0x20 /* extended address enable */ 2358c2ecf20Sopenharmony_ci#define TALITOS_CCCR_LO_CDWE 0x10 /* chan. done writeback enab. */ 2368c2ecf20Sopenharmony_ci#define TALITOS_CCCR_LO_NE 0x8 /* fetch next descriptor enab. */ 2378c2ecf20Sopenharmony_ci#define TALITOS_CCCR_LO_NT 0x4 /* notification type */ 2388c2ecf20Sopenharmony_ci#define TALITOS_CCCR_LO_CDIE 0x2 /* channel done IRQ enable */ 2398c2ecf20Sopenharmony_ci#define TALITOS1_CCCR_LO_RESET 0x1 /* channel reset on SEC1 */ 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci/* CCPSR: channel pointer status register */ 2428c2ecf20Sopenharmony_ci#define TALITOS_CCPSR 0x10 2438c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO 0x14 2448c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_DOF 0x8000 /* double FF write oflow error */ 2458c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_SOF 0x4000 /* single FF write oflow error */ 2468c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_MDTE 0x2000 /* master data transfer error */ 2478c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_SGDLZ 0x1000 /* s/g data len zero error */ 2488c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_FPZ 0x0800 /* fetch ptr zero error */ 2498c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_IDH 0x0400 /* illegal desc hdr error */ 2508c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_IEU 0x0200 /* invalid EU error */ 2518c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_EU 0x0100 /* EU error detected */ 2528c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_GB 0x0080 /* gather boundary error */ 2538c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_GRL 0x0040 /* gather return/length error */ 2548c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_SB 0x0020 /* scatter boundary error */ 2558c2ecf20Sopenharmony_ci#define TALITOS_CCPSR_LO_SRL 0x0010 /* scatter return/length error */ 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci/* channel fetch fifo register */ 2588c2ecf20Sopenharmony_ci#define TALITOS_FF 0x48 2598c2ecf20Sopenharmony_ci#define TALITOS_FF_LO 0x4c 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci/* current descriptor pointer register */ 2628c2ecf20Sopenharmony_ci#define TALITOS_CDPR 0x40 2638c2ecf20Sopenharmony_ci#define TALITOS_CDPR_LO 0x44 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci/* descriptor buffer register */ 2668c2ecf20Sopenharmony_ci#define TALITOS_DESCBUF 0x80 2678c2ecf20Sopenharmony_ci#define TALITOS_DESCBUF_LO 0x84 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci/* gather link table */ 2708c2ecf20Sopenharmony_ci#define TALITOS_GATHER 0xc0 2718c2ecf20Sopenharmony_ci#define TALITOS_GATHER_LO 0xc4 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci/* scatter link table */ 2748c2ecf20Sopenharmony_ci#define TALITOS_SCATTER 0xe0 2758c2ecf20Sopenharmony_ci#define TALITOS_SCATTER_LO 0xe4 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci/* execution unit registers base */ 2788c2ecf20Sopenharmony_ci#define TALITOS2_DEU 0x2000 2798c2ecf20Sopenharmony_ci#define TALITOS2_AESU 0x4000 2808c2ecf20Sopenharmony_ci#define TALITOS2_MDEU 0x6000 2818c2ecf20Sopenharmony_ci#define TALITOS2_AFEU 0x8000 2828c2ecf20Sopenharmony_ci#define TALITOS2_RNGU 0xa000 2838c2ecf20Sopenharmony_ci#define TALITOS2_PKEU 0xc000 2848c2ecf20Sopenharmony_ci#define TALITOS2_KEU 0xe000 2858c2ecf20Sopenharmony_ci#define TALITOS2_CRCU 0xf000 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci#define TALITOS12_AESU 0x4000 2888c2ecf20Sopenharmony_ci#define TALITOS12_DEU 0x5000 2898c2ecf20Sopenharmony_ci#define TALITOS12_MDEU 0x6000 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci#define TALITOS10_AFEU 0x8000 2928c2ecf20Sopenharmony_ci#define TALITOS10_DEU 0xa000 2938c2ecf20Sopenharmony_ci#define TALITOS10_MDEU 0xc000 2948c2ecf20Sopenharmony_ci#define TALITOS10_RNGU 0xe000 2958c2ecf20Sopenharmony_ci#define TALITOS10_PKEU 0x10000 2968c2ecf20Sopenharmony_ci#define TALITOS10_AESU 0x12000 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci/* execution unit interrupt status registers */ 2998c2ecf20Sopenharmony_ci#define TALITOS_EUDSR 0x10 /* data size */ 3008c2ecf20Sopenharmony_ci#define TALITOS_EUDSR_LO 0x14 3018c2ecf20Sopenharmony_ci#define TALITOS_EURCR 0x18 /* reset control*/ 3028c2ecf20Sopenharmony_ci#define TALITOS_EURCR_LO 0x1c 3038c2ecf20Sopenharmony_ci#define TALITOS_EUSR 0x28 /* rng status */ 3048c2ecf20Sopenharmony_ci#define TALITOS_EUSR_LO 0x2c 3058c2ecf20Sopenharmony_ci#define TALITOS_EUISR 0x30 3068c2ecf20Sopenharmony_ci#define TALITOS_EUISR_LO 0x34 3078c2ecf20Sopenharmony_ci#define TALITOS_EUICR 0x38 /* int. control */ 3088c2ecf20Sopenharmony_ci#define TALITOS_EUICR_LO 0x3c 3098c2ecf20Sopenharmony_ci#define TALITOS_EU_FIFO 0x800 /* output FIFO */ 3108c2ecf20Sopenharmony_ci#define TALITOS_EU_FIFO_LO 0x804 /* output FIFO */ 3118c2ecf20Sopenharmony_ci/* DES unit */ 3128c2ecf20Sopenharmony_ci#define TALITOS1_DEUICR_KPE 0x00200000 /* Key Parity Error */ 3138c2ecf20Sopenharmony_ci/* message digest unit */ 3148c2ecf20Sopenharmony_ci#define TALITOS_MDEUICR_LO_ICE 0x4000 /* integrity check IRQ enable */ 3158c2ecf20Sopenharmony_ci/* random number unit */ 3168c2ecf20Sopenharmony_ci#define TALITOS_RNGUSR_LO_RD 0x1 /* reset done */ 3178c2ecf20Sopenharmony_ci#define TALITOS_RNGUSR_LO_OFL 0xff0000/* output FIFO length */ 3188c2ecf20Sopenharmony_ci#define TALITOS_RNGURCR_LO_SR 0x1 /* software reset */ 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci#define TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256 0x28 3218c2ecf20Sopenharmony_ci#define TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512 0x48 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci/* 3248c2ecf20Sopenharmony_ci * talitos descriptor header (hdr) bits 3258c2ecf20Sopenharmony_ci */ 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci/* written back when done */ 3288c2ecf20Sopenharmony_ci#define DESC_HDR_DONE cpu_to_be32(0xff000000) 3298c2ecf20Sopenharmony_ci#define DESC_HDR_LO_ICCR1_MASK cpu_to_be32(0x00180000) 3308c2ecf20Sopenharmony_ci#define DESC_HDR_LO_ICCR1_PASS cpu_to_be32(0x00080000) 3318c2ecf20Sopenharmony_ci#define DESC_HDR_LO_ICCR1_FAIL cpu_to_be32(0x00100000) 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_ci/* primary execution unit select */ 3348c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_MASK cpu_to_be32(0xf0000000) 3358c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_AFEU cpu_to_be32(0x10000000) 3368c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_DEU cpu_to_be32(0x20000000) 3378c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_MDEUA cpu_to_be32(0x30000000) 3388c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_MDEUB cpu_to_be32(0xb0000000) 3398c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_RNG cpu_to_be32(0x40000000) 3408c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_PKEU cpu_to_be32(0x50000000) 3418c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_AESU cpu_to_be32(0x60000000) 3428c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_KEU cpu_to_be32(0x70000000) 3438c2ecf20Sopenharmony_ci#define DESC_HDR_SEL0_CRCU cpu_to_be32(0x80000000) 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci/* primary execution unit mode (MODE0) and derivatives */ 3468c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_ENCRYPT cpu_to_be32(0x00100000) 3478c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_AESU_MASK cpu_to_be32(0x00600000) 3488c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_AESU_CBC cpu_to_be32(0x00200000) 3498c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_AESU_CTR cpu_to_be32(0x00600000) 3508c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_DEU_CBC cpu_to_be32(0x00400000) 3518c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_DEU_3DES cpu_to_be32(0x00200000) 3528c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_CONT cpu_to_be32(0x08000000) 3538c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_INIT cpu_to_be32(0x01000000) 3548c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_HMAC cpu_to_be32(0x00800000) 3558c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_PAD cpu_to_be32(0x00400000) 3568c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA224 cpu_to_be32(0x00300000) 3578c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_MD5 cpu_to_be32(0x00200000) 3588c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA256 cpu_to_be32(0x00100000) 3598c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA1 cpu_to_be32(0x00000000) 3608c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEUB_SHA384 cpu_to_be32(0x00000000) 3618c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEUB_SHA512 cpu_to_be32(0x00200000) 3628c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_MD5_HMAC (DESC_HDR_MODE0_MDEU_MD5 | \ 3638c2ecf20Sopenharmony_ci DESC_HDR_MODE0_MDEU_HMAC) 3648c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA256_HMAC (DESC_HDR_MODE0_MDEU_SHA256 | \ 3658c2ecf20Sopenharmony_ci DESC_HDR_MODE0_MDEU_HMAC) 3668c2ecf20Sopenharmony_ci#define DESC_HDR_MODE0_MDEU_SHA1_HMAC (DESC_HDR_MODE0_MDEU_SHA1 | \ 3678c2ecf20Sopenharmony_ci DESC_HDR_MODE0_MDEU_HMAC) 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci/* secondary execution unit select (SEL1) */ 3708c2ecf20Sopenharmony_ci#define DESC_HDR_SEL1_MASK cpu_to_be32(0x000f0000) 3718c2ecf20Sopenharmony_ci#define DESC_HDR_SEL1_MDEUA cpu_to_be32(0x00030000) 3728c2ecf20Sopenharmony_ci#define DESC_HDR_SEL1_MDEUB cpu_to_be32(0x000b0000) 3738c2ecf20Sopenharmony_ci#define DESC_HDR_SEL1_CRCU cpu_to_be32(0x00080000) 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci/* secondary execution unit mode (MODE1) and derivatives */ 3768c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_CICV cpu_to_be32(0x00004000) 3778c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_INIT cpu_to_be32(0x00001000) 3788c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_HMAC cpu_to_be32(0x00000800) 3798c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_PAD cpu_to_be32(0x00000400) 3808c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA224 cpu_to_be32(0x00000300) 3818c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_MD5 cpu_to_be32(0x00000200) 3828c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA256 cpu_to_be32(0x00000100) 3838c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA1 cpu_to_be32(0x00000000) 3848c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEUB_SHA384 cpu_to_be32(0x00000000) 3858c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEUB_SHA512 cpu_to_be32(0x00000200) 3868c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_MD5_HMAC (DESC_HDR_MODE1_MDEU_MD5 | \ 3878c2ecf20Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 3888c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA256_HMAC (DESC_HDR_MODE1_MDEU_SHA256 | \ 3898c2ecf20Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 3908c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA1_HMAC (DESC_HDR_MODE1_MDEU_SHA1 | \ 3918c2ecf20Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 3928c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEU_SHA224_HMAC (DESC_HDR_MODE1_MDEU_SHA224 | \ 3938c2ecf20Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 3948c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEUB_SHA384_HMAC (DESC_HDR_MODE1_MDEUB_SHA384 | \ 3958c2ecf20Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 3968c2ecf20Sopenharmony_ci#define DESC_HDR_MODE1_MDEUB_SHA512_HMAC (DESC_HDR_MODE1_MDEUB_SHA512 | \ 3978c2ecf20Sopenharmony_ci DESC_HDR_MODE1_MDEU_HMAC) 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci/* direction of overall data flow (DIR) */ 4008c2ecf20Sopenharmony_ci#define DESC_HDR_DIR_INBOUND cpu_to_be32(0x00000002) 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_ci/* request done notification (DN) */ 4038c2ecf20Sopenharmony_ci#define DESC_HDR_DONE_NOTIFY cpu_to_be32(0x00000001) 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ci/* descriptor types */ 4068c2ecf20Sopenharmony_ci#define DESC_HDR_TYPE_AESU_CTR_NONSNOOP cpu_to_be32(0 << 3) 4078c2ecf20Sopenharmony_ci#define DESC_HDR_TYPE_IPSEC_ESP cpu_to_be32(1 << 3) 4088c2ecf20Sopenharmony_ci#define DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU cpu_to_be32(2 << 3) 4098c2ecf20Sopenharmony_ci#define DESC_HDR_TYPE_HMAC_SNOOP_NO_AFEU cpu_to_be32(4 << 3) 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci/* link table extent field bits */ 4128c2ecf20Sopenharmony_ci#define DESC_PTR_LNKTBL_JUMP 0x80 4138c2ecf20Sopenharmony_ci#define DESC_PTR_LNKTBL_RET 0x02 4148c2ecf20Sopenharmony_ci#define DESC_PTR_LNKTBL_NEXT 0x01 415