0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef REGS_H
0010 #define REGS_H
0011
0012 #include <linux/types.h>
0013 #include <linux/bitops.h>
0014 #include <linux/io.h>
0015 #include <linux/io-64-nonatomic-hi-lo.h>
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 extern bool caam_little_end;
0073 extern bool caam_imx;
0074 extern size_t caam_ptr_sz;
0075
0076 #define caam_to_cpu(len) \
0077 static inline u##len caam##len ## _to_cpu(u##len val) \
0078 { \
0079 if (caam_little_end) \
0080 return le##len ## _to_cpu((__force __le##len)val); \
0081 else \
0082 return be##len ## _to_cpu((__force __be##len)val); \
0083 }
0084
0085 #define cpu_to_caam(len) \
0086 static inline u##len cpu_to_caam##len(u##len val) \
0087 { \
0088 if (caam_little_end) \
0089 return (__force u##len)cpu_to_le##len(val); \
0090 else \
0091 return (__force u##len)cpu_to_be##len(val); \
0092 }
0093
0094 caam_to_cpu(16)
0095 caam_to_cpu(32)
0096 caam_to_cpu(64)
0097 cpu_to_caam(16)
0098 cpu_to_caam(32)
0099 cpu_to_caam(64)
0100
0101 static inline void wr_reg32(void __iomem *reg, u32 data)
0102 {
0103 if (caam_little_end)
0104 iowrite32(data, reg);
0105 else
0106 iowrite32be(data, reg);
0107 }
0108
0109 static inline u32 rd_reg32(void __iomem *reg)
0110 {
0111 if (caam_little_end)
0112 return ioread32(reg);
0113
0114 return ioread32be(reg);
0115 }
0116
0117 static inline void clrsetbits_32(void __iomem *reg, u32 clear, u32 set)
0118 {
0119 if (caam_little_end)
0120 iowrite32((ioread32(reg) & ~clear) | set, reg);
0121 else
0122 iowrite32be((ioread32be(reg) & ~clear) | set, reg);
0123 }
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 static inline void wr_reg64(void __iomem *reg, u64 data)
0143 {
0144 if (caam_little_end) {
0145 if (caam_imx) {
0146 iowrite32(data >> 32, (u32 __iomem *)(reg));
0147 iowrite32(data, (u32 __iomem *)(reg) + 1);
0148 } else {
0149 iowrite64(data, reg);
0150 }
0151 } else {
0152 iowrite64be(data, reg);
0153 }
0154 }
0155
0156 static inline u64 rd_reg64(void __iomem *reg)
0157 {
0158 if (caam_little_end) {
0159 if (caam_imx) {
0160 u32 low, high;
0161
0162 high = ioread32(reg);
0163 low = ioread32(reg + sizeof(u32));
0164
0165 return low + ((u64)high << 32);
0166 } else {
0167 return ioread64(reg);
0168 }
0169 } else {
0170 return ioread64be(reg);
0171 }
0172 }
0173
0174 static inline u64 cpu_to_caam_dma64(dma_addr_t value)
0175 {
0176 if (caam_imx) {
0177 u64 ret_val = (u64)cpu_to_caam32(lower_32_bits(value)) << 32;
0178
0179 if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
0180 ret_val |= (u64)cpu_to_caam32(upper_32_bits(value));
0181
0182 return ret_val;
0183 }
0184
0185 return cpu_to_caam64(value);
0186 }
0187
0188 static inline u64 caam_dma64_to_cpu(u64 value)
0189 {
0190 if (caam_imx)
0191 return (((u64)caam32_to_cpu(lower_32_bits(value)) << 32) |
0192 (u64)caam32_to_cpu(upper_32_bits(value)));
0193
0194 return caam64_to_cpu(value);
0195 }
0196
0197 static inline u64 cpu_to_caam_dma(u64 value)
0198 {
0199 if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
0200 caam_ptr_sz == sizeof(u64))
0201 return cpu_to_caam_dma64(value);
0202 else
0203 return cpu_to_caam32(value);
0204 }
0205
0206 static inline u64 caam_dma_to_cpu(u64 value)
0207 {
0208 if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) &&
0209 caam_ptr_sz == sizeof(u64))
0210 return caam_dma64_to_cpu(value);
0211 else
0212 return caam32_to_cpu(value);
0213 }
0214
0215
0216
0217
0218
0219
0220 static inline void jr_outentry_get(void *outring, int hw_idx, dma_addr_t *desc,
0221 u32 *jrstatus)
0222 {
0223
0224 if (caam_ptr_sz == sizeof(u32)) {
0225 struct {
0226 u32 desc;
0227 u32 jrstatus;
0228 } __packed *outentry = outring;
0229
0230 *desc = outentry[hw_idx].desc;
0231 *jrstatus = outentry[hw_idx].jrstatus;
0232 } else {
0233 struct {
0234 dma_addr_t desc;
0235 u32 jrstatus;
0236 } __packed *outentry = outring;
0237
0238 *desc = outentry[hw_idx].desc;
0239 *jrstatus = outentry[hw_idx].jrstatus;
0240 }
0241 }
0242
0243 #define SIZEOF_JR_OUTENTRY (caam_ptr_sz + sizeof(u32))
0244
0245 static inline dma_addr_t jr_outentry_desc(void *outring, int hw_idx)
0246 {
0247 dma_addr_t desc;
0248 u32 unused;
0249
0250 jr_outentry_get(outring, hw_idx, &desc, &unused);
0251
0252 return desc;
0253 }
0254
0255 static inline u32 jr_outentry_jrstatus(void *outring, int hw_idx)
0256 {
0257 dma_addr_t unused;
0258 u32 jrstatus;
0259
0260 jr_outentry_get(outring, hw_idx, &unused, &jrstatus);
0261
0262 return jrstatus;
0263 }
0264
0265 static inline void jr_inpentry_set(void *inpring, int hw_idx, dma_addr_t val)
0266 {
0267 if (caam_ptr_sz == sizeof(u32)) {
0268 u32 *inpentry = inpring;
0269
0270 inpentry[hw_idx] = val;
0271 } else {
0272 dma_addr_t *inpentry = inpring;
0273
0274 inpentry[hw_idx] = val;
0275 }
0276 }
0277
0278 #define SIZEOF_JR_INPENTRY caam_ptr_sz
0279
0280
0281
0282 struct version_regs {
0283 u32 crca;
0284 u32 afha;
0285 u32 kfha;
0286 u32 pkha;
0287 u32 aesa;
0288 u32 mdha;
0289 u32 desa;
0290 u32 snw8a;
0291 u32 snw9a;
0292 u32 zuce;
0293 u32 zuca;
0294 u32 ccha;
0295 u32 ptha;
0296 u32 rng;
0297 u32 trng;
0298 u32 aaha;
0299 u32 rsvd[10];
0300 u32 sr;
0301 u32 dma;
0302 u32 ai;
0303 u32 qi;
0304 u32 jr;
0305 u32 deco;
0306 };
0307
0308
0309
0310
0311 #define CHA_VER_NUM_MASK 0xffull
0312
0313 #define CHA_VER_MISC_SHIFT 8
0314 #define CHA_VER_MISC_MASK (0xffull << CHA_VER_MISC_SHIFT)
0315
0316 #define CHA_VER_REV_SHIFT 16
0317 #define CHA_VER_REV_MASK (0xffull << CHA_VER_REV_SHIFT)
0318
0319 #define CHA_VER_VID_SHIFT 24
0320 #define CHA_VER_VID_MASK (0xffull << CHA_VER_VID_SHIFT)
0321
0322
0323 #define CHA_VER_MISC_AES_NUM_MASK GENMASK(7, 0)
0324 #define CHA_VER_MISC_AES_GCM BIT(1 + CHA_VER_MISC_SHIFT)
0325
0326
0327 #define CHA_VER_MISC_PKHA_NO_CRYPT BIT(7 + CHA_VER_MISC_SHIFT)
0328
0329
0330
0331
0332
0333
0334
0335
0336
0337 #define CHA_NUM_MS_DECONUM_SHIFT 24
0338 #define CHA_NUM_MS_DECONUM_MASK (0xfull << CHA_NUM_MS_DECONUM_SHIFT)
0339
0340
0341
0342
0343
0344
0345
0346 #define CHA_ID_LS_AES_SHIFT 0
0347 #define CHA_ID_LS_AES_MASK (0xfull << CHA_ID_LS_AES_SHIFT)
0348
0349 #define CHA_ID_LS_DES_SHIFT 4
0350 #define CHA_ID_LS_DES_MASK (0xfull << CHA_ID_LS_DES_SHIFT)
0351
0352 #define CHA_ID_LS_ARC4_SHIFT 8
0353 #define CHA_ID_LS_ARC4_MASK (0xfull << CHA_ID_LS_ARC4_SHIFT)
0354
0355 #define CHA_ID_LS_MD_SHIFT 12
0356 #define CHA_ID_LS_MD_MASK (0xfull << CHA_ID_LS_MD_SHIFT)
0357
0358 #define CHA_ID_LS_RNG_SHIFT 16
0359 #define CHA_ID_LS_RNG_MASK (0xfull << CHA_ID_LS_RNG_SHIFT)
0360
0361 #define CHA_ID_LS_SNW8_SHIFT 20
0362 #define CHA_ID_LS_SNW8_MASK (0xfull << CHA_ID_LS_SNW8_SHIFT)
0363
0364 #define CHA_ID_LS_KAS_SHIFT 24
0365 #define CHA_ID_LS_KAS_MASK (0xfull << CHA_ID_LS_KAS_SHIFT)
0366
0367 #define CHA_ID_LS_PK_SHIFT 28
0368 #define CHA_ID_LS_PK_MASK (0xfull << CHA_ID_LS_PK_SHIFT)
0369
0370 #define CHA_ID_MS_CRC_SHIFT 0
0371 #define CHA_ID_MS_CRC_MASK (0xfull << CHA_ID_MS_CRC_SHIFT)
0372
0373 #define CHA_ID_MS_SNW9_SHIFT 4
0374 #define CHA_ID_MS_SNW9_MASK (0xfull << CHA_ID_MS_SNW9_SHIFT)
0375
0376 #define CHA_ID_MS_DECO_SHIFT 24
0377 #define CHA_ID_MS_DECO_MASK (0xfull << CHA_ID_MS_DECO_SHIFT)
0378
0379 #define CHA_ID_MS_JR_SHIFT 28
0380 #define CHA_ID_MS_JR_MASK (0xfull << CHA_ID_MS_JR_SHIFT)
0381
0382
0383 #define CHA_VER_VID_AES_LP 0x3ull
0384 #define CHA_VER_VID_AES_HP 0x4ull
0385 #define CHA_VER_VID_MD_LP256 0x0ull
0386 #define CHA_VER_VID_MD_LP512 0x1ull
0387 #define CHA_VER_VID_MD_HP 0x2ull
0388
0389 struct sec_vid {
0390 u16 ip_id;
0391 u8 maj_rev;
0392 u8 min_rev;
0393 };
0394
0395 struct caam_perfmon {
0396
0397 u64 req_dequeued;
0398 u64 ob_enc_req;
0399 u64 ib_dec_req;
0400 u64 ob_enc_bytes;
0401 u64 ob_prot_bytes;
0402 u64 ib_dec_bytes;
0403 u64 ib_valid_bytes;
0404 u64 rsvd[13];
0405
0406
0407 u32 cha_rev_ms;
0408 u32 cha_rev_ls;
0409 #define CTPR_MS_QI_SHIFT 25
0410 #define CTPR_MS_QI_MASK (0x1ull << CTPR_MS_QI_SHIFT)
0411 #define CTPR_MS_PS BIT(17)
0412 #define CTPR_MS_DPAA2 BIT(13)
0413 #define CTPR_MS_VIRT_EN_INCL 0x00000001
0414 #define CTPR_MS_VIRT_EN_POR 0x00000002
0415 #define CTPR_MS_PG_SZ_MASK 0x10
0416 #define CTPR_MS_PG_SZ_SHIFT 4
0417 u32 comp_parms_ms;
0418 #define CTPR_LS_BLOB BIT(1)
0419 u32 comp_parms_ls;
0420 u64 rsvd1[2];
0421
0422
0423 u64 faultaddr;
0424 u32 faultliodn;
0425 u32 faultdetail;
0426 u32 rsvd2;
0427 #define CSTA_PLEND BIT(10)
0428 #define CSTA_ALT_PLEND BIT(18)
0429 u32 status;
0430 u64 rsvd3;
0431
0432
0433 u32 rtic_id;
0434 #define CCBVID_ERA_MASK 0xff000000
0435 #define CCBVID_ERA_SHIFT 24
0436 u32 ccb_id;
0437 u32 cha_id_ms;
0438 u32 cha_id_ls;
0439 u32 cha_num_ms;
0440 u32 cha_num_ls;
0441 #define SECVID_MS_IPID_MASK 0xffff0000
0442 #define SECVID_MS_IPID_SHIFT 16
0443 #define SECVID_MS_MAJ_REV_MASK 0x0000ff00
0444 #define SECVID_MS_MAJ_REV_SHIFT 8
0445 u32 caam_id_ms;
0446 u32 caam_id_ls;
0447 };
0448
0449
0450 #define MSTRID_LOCK_LIODN 0x80000000
0451 #define MSTRID_LOCK_MAKETRUSTED 0x00010000
0452
0453 #define MSTRID_LIODN_MASK 0x0fff
0454 struct masterid {
0455 u32 liodn_ms;
0456 u32 liodn_ls;
0457 };
0458
0459
0460 struct partid {
0461 u32 rsvd1;
0462 u32 pidr;
0463 };
0464
0465
0466
0467 struct rngtst {
0468 u32 mode;
0469 u32 rsvd1[3];
0470 u32 reset;
0471 u32 rsvd2[3];
0472 u32 status;
0473 u32 rsvd3;
0474 u32 errstat;
0475 u32 rsvd4;
0476 u32 errctl;
0477 u32 rsvd5;
0478 u32 entropy;
0479 u32 rsvd6[15];
0480 u32 verifctl;
0481 u32 rsvd7;
0482 u32 verifstat;
0483 u32 rsvd8;
0484 u32 verifdata;
0485 u32 rsvd9;
0486 u32 xkey;
0487 u32 rsvd10;
0488 u32 oscctctl;
0489 u32 rsvd11;
0490 u32 oscct;
0491 u32 rsvd12;
0492 u32 oscctstat;
0493 u32 rsvd13[2];
0494 u32 ofifo[4];
0495 u32 rsvd14[15];
0496 };
0497
0498
0499 struct rng4tst {
0500 #define RTMCTL_ACC BIT(5)
0501 #define RTMCTL_PRGM BIT(16)
0502 #define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_SC 0
0503
0504
0505 #define RTMCTL_SAMP_MODE_RAW_ES_SC 1
0506
0507
0508 #define RTMCTL_SAMP_MODE_VON_NEUMANN_ES_RAW_SC 2
0509
0510
0511 #define RTMCTL_SAMP_MODE_INVALID 3
0512 u32 rtmctl;
0513 u32 rtscmisc;
0514 u32 rtpkrrng;
0515 union {
0516 u32 rtpkrmax;
0517 u32 rtpkrsq;
0518 };
0519 #define RTSDCTL_ENT_DLY_SHIFT 16
0520 #define RTSDCTL_ENT_DLY_MASK (0xffff << RTSDCTL_ENT_DLY_SHIFT)
0521 #define RTSDCTL_ENT_DLY_MIN 3200
0522 #define RTSDCTL_ENT_DLY_MAX 12800
0523 u32 rtsdctl;
0524 union {
0525 u32 rtsblim;
0526 u32 rttotsam;
0527 };
0528 u32 rtfrqmin;
0529 #define RTFRQMAX_DISABLE (1 << 20)
0530 union {
0531 u32 rtfrqmax;
0532 u32 rtfrqcnt;
0533 };
0534 u32 rsvd1[40];
0535 #define RDSTA_SKVT 0x80000000
0536 #define RDSTA_SKVN 0x40000000
0537 #define RDSTA_PR0 BIT(4)
0538 #define RDSTA_PR1 BIT(5)
0539 #define RDSTA_IF0 0x00000001
0540 #define RDSTA_IF1 0x00000002
0541 #define RDSTA_MASK (RDSTA_PR1 | RDSTA_PR0 | RDSTA_IF1 | RDSTA_IF0)
0542 u32 rdsta;
0543 u32 rsvd2[15];
0544 };
0545
0546
0547
0548
0549
0550
0551 #define KEK_KEY_SIZE 8
0552 #define TKEK_KEY_SIZE 8
0553 #define TDSK_KEY_SIZE 8
0554
0555 #define DECO_RESET 1
0556 #define DECO_RESET_0 (DECO_RESET << 0)
0557 #define DECO_RESET_1 (DECO_RESET << 1)
0558 #define DECO_RESET_2 (DECO_RESET << 2)
0559 #define DECO_RESET_3 (DECO_RESET << 3)
0560 #define DECO_RESET_4 (DECO_RESET << 4)
0561
0562 struct caam_ctrl {
0563
0564
0565 u32 rsvd1;
0566 u32 mcr;
0567 u32 rsvd2;
0568 u32 scfgr;
0569
0570
0571
0572 struct masterid jr_mid[4];
0573 u32 rsvd3[11];
0574 u32 jrstart;
0575 struct masterid rtic_mid[4];
0576 u32 rsvd4[5];
0577 u32 deco_rsr;
0578 u32 rsvd11;
0579 u32 deco_rq;
0580 struct partid deco_mid[5];
0581 u32 rsvd5[22];
0582
0583
0584 u32 deco_avail;
0585 u32 deco_reset;
0586 u32 rsvd6[182];
0587
0588
0589
0590 u32 kek[KEK_KEY_SIZE];
0591 u32 tkek[TKEK_KEY_SIZE];
0592 u32 tdsk[TDSK_KEY_SIZE];
0593 u32 rsvd7[32];
0594 u64 sknonce;
0595 u32 rsvd8[70];
0596
0597
0598
0599 union {
0600 struct rngtst rtst[2];
0601 struct rng4tst r4tst[2];
0602 };
0603
0604 u32 rsvd9[416];
0605
0606
0607 struct version_regs vreg;
0608
0609 struct caam_perfmon perfmon;
0610 };
0611
0612
0613
0614
0615 #define MCFGR_SWRESET 0x80000000
0616 #define MCFGR_WDENABLE 0x40000000
0617 #define MCFGR_WDFAIL 0x20000000
0618 #define MCFGR_DMA_RESET 0x10000000
0619 #define MCFGR_LONG_PTR 0x00010000
0620 #define SCFGR_RDBENABLE 0x00000400
0621 #define SCFGR_VIRT_EN 0x00008000
0622 #define DECORR_RQD0ENABLE 0x00000001
0623 #define DECORSR_JR0 0x00000001
0624 #define DECORSR_VALID 0x80000000
0625 #define DECORR_DEN0 0x00010000
0626
0627
0628 #define MCFGR_ARCACHE_SHIFT 12
0629 #define MCFGR_ARCACHE_MASK (0xf << MCFGR_ARCACHE_SHIFT)
0630 #define MCFGR_ARCACHE_BUFF (0x1 << MCFGR_ARCACHE_SHIFT)
0631 #define MCFGR_ARCACHE_CACH (0x2 << MCFGR_ARCACHE_SHIFT)
0632 #define MCFGR_ARCACHE_RALL (0x4 << MCFGR_ARCACHE_SHIFT)
0633
0634
0635 #define MCFGR_AWCACHE_SHIFT 8
0636 #define MCFGR_AWCACHE_MASK (0xf << MCFGR_AWCACHE_SHIFT)
0637 #define MCFGR_AWCACHE_BUFF (0x1 << MCFGR_AWCACHE_SHIFT)
0638 #define MCFGR_AWCACHE_CACH (0x2 << MCFGR_AWCACHE_SHIFT)
0639 #define MCFGR_AWCACHE_WALL (0x8 << MCFGR_AWCACHE_SHIFT)
0640
0641
0642 #define MCFGR_AXIPIPE_SHIFT 4
0643 #define MCFGR_AXIPIPE_MASK (0xf << MCFGR_AXIPIPE_SHIFT)
0644
0645 #define MCFGR_AXIPRI 0x00000008
0646 #define MCFGR_LARGE_BURST 0x00000004
0647 #define MCFGR_BURST_64 0x00000001
0648
0649
0650 #define JRSTART_JR0_START 0x00000001
0651 #define JRSTART_JR1_START 0x00000002
0652 #define JRSTART_JR2_START 0x00000004
0653 #define JRSTART_JR3_START 0x00000008
0654
0655
0656
0657
0658
0659
0660 struct caam_job_ring {
0661
0662 u64 inpring_base;
0663 u32 rsvd1;
0664 u32 inpring_size;
0665 u32 rsvd2;
0666 u32 inpring_avail;
0667 u32 rsvd3;
0668 u32 inpring_jobadd;
0669
0670
0671 u64 outring_base;
0672 u32 rsvd4;
0673 u32 outring_size;
0674 u32 rsvd5;
0675 u32 outring_rmvd;
0676 u32 rsvd6;
0677 u32 outring_used;
0678
0679
0680 u32 rsvd7;
0681 u32 jroutstatus;
0682 u32 rsvd8;
0683 u32 jrintstatus;
0684 u32 rconfig_hi;
0685 u32 rconfig_lo;
0686
0687
0688 u32 rsvd9;
0689 u32 inp_rdidx;
0690 u32 rsvd10;
0691 u32 out_wtidx;
0692
0693
0694 u32 rsvd11;
0695 u32 jrcommand;
0696
0697 u32 rsvd12[900];
0698
0699
0700 struct version_regs vreg;
0701
0702 struct caam_perfmon perfmon;
0703 };
0704
0705 #define JR_RINGSIZE_MASK 0x03ff
0706
0707
0708
0709
0710
0711
0712 #define JRSTA_SSRC_SHIFT 28
0713 #define JRSTA_SSRC_MASK 0xf0000000
0714
0715 #define JRSTA_SSRC_NONE 0x00000000
0716 #define JRSTA_SSRC_CCB_ERROR 0x20000000
0717 #define JRSTA_SSRC_JUMP_HALT_USER 0x30000000
0718 #define JRSTA_SSRC_DECO 0x40000000
0719 #define JRSTA_SSRC_QI 0x50000000
0720 #define JRSTA_SSRC_JRERROR 0x60000000
0721 #define JRSTA_SSRC_JUMP_HALT_CC 0x70000000
0722
0723 #define JRSTA_DECOERR_JUMP 0x08000000
0724 #define JRSTA_DECOERR_INDEX_SHIFT 8
0725 #define JRSTA_DECOERR_INDEX_MASK 0xff00
0726 #define JRSTA_DECOERR_ERROR_MASK 0x00ff
0727
0728 #define JRSTA_DECOERR_NONE 0x00
0729 #define JRSTA_DECOERR_LINKLEN 0x01
0730 #define JRSTA_DECOERR_LINKPTR 0x02
0731 #define JRSTA_DECOERR_JRCTRL 0x03
0732 #define JRSTA_DECOERR_DESCCMD 0x04
0733 #define JRSTA_DECOERR_ORDER 0x05
0734 #define JRSTA_DECOERR_KEYCMD 0x06
0735 #define JRSTA_DECOERR_LOADCMD 0x07
0736 #define JRSTA_DECOERR_STORECMD 0x08
0737 #define JRSTA_DECOERR_OPCMD 0x09
0738 #define JRSTA_DECOERR_FIFOLDCMD 0x0a
0739 #define JRSTA_DECOERR_FIFOSTCMD 0x0b
0740 #define JRSTA_DECOERR_MOVECMD 0x0c
0741 #define JRSTA_DECOERR_JUMPCMD 0x0d
0742 #define JRSTA_DECOERR_MATHCMD 0x0e
0743 #define JRSTA_DECOERR_SHASHCMD 0x0f
0744 #define JRSTA_DECOERR_SEQCMD 0x10
0745 #define JRSTA_DECOERR_DECOINTERNAL 0x11
0746 #define JRSTA_DECOERR_SHDESCHDR 0x12
0747 #define JRSTA_DECOERR_HDRLEN 0x13
0748 #define JRSTA_DECOERR_BURSTER 0x14
0749 #define JRSTA_DECOERR_DESCSIGNATURE 0x15
0750 #define JRSTA_DECOERR_DMA 0x16
0751 #define JRSTA_DECOERR_BURSTFIFO 0x17
0752 #define JRSTA_DECOERR_JRRESET 0x1a
0753 #define JRSTA_DECOERR_JOBFAIL 0x1b
0754 #define JRSTA_DECOERR_DNRERR 0x80
0755 #define JRSTA_DECOERR_UNDEFPCL 0x81
0756 #define JRSTA_DECOERR_PDBERR 0x82
0757 #define JRSTA_DECOERR_ANRPLY_LATE 0x83
0758 #define JRSTA_DECOERR_ANRPLY_REPLAY 0x84
0759 #define JRSTA_DECOERR_SEQOVF 0x85
0760 #define JRSTA_DECOERR_INVSIGN 0x86
0761 #define JRSTA_DECOERR_DSASIGN 0x87
0762
0763 #define JRSTA_QIERR_ERROR_MASK 0x00ff
0764
0765 #define JRSTA_CCBERR_JUMP 0x08000000
0766 #define JRSTA_CCBERR_INDEX_MASK 0xff00
0767 #define JRSTA_CCBERR_INDEX_SHIFT 8
0768 #define JRSTA_CCBERR_CHAID_MASK 0x00f0
0769 #define JRSTA_CCBERR_CHAID_SHIFT 4
0770 #define JRSTA_CCBERR_ERRID_MASK 0x000f
0771
0772 #define JRSTA_CCBERR_CHAID_AES (0x01 << JRSTA_CCBERR_CHAID_SHIFT)
0773 #define JRSTA_CCBERR_CHAID_DES (0x02 << JRSTA_CCBERR_CHAID_SHIFT)
0774 #define JRSTA_CCBERR_CHAID_ARC4 (0x03 << JRSTA_CCBERR_CHAID_SHIFT)
0775 #define JRSTA_CCBERR_CHAID_MD (0x04 << JRSTA_CCBERR_CHAID_SHIFT)
0776 #define JRSTA_CCBERR_CHAID_RNG (0x05 << JRSTA_CCBERR_CHAID_SHIFT)
0777 #define JRSTA_CCBERR_CHAID_SNOW (0x06 << JRSTA_CCBERR_CHAID_SHIFT)
0778 #define JRSTA_CCBERR_CHAID_KASUMI (0x07 << JRSTA_CCBERR_CHAID_SHIFT)
0779 #define JRSTA_CCBERR_CHAID_PK (0x08 << JRSTA_CCBERR_CHAID_SHIFT)
0780 #define JRSTA_CCBERR_CHAID_CRC (0x09 << JRSTA_CCBERR_CHAID_SHIFT)
0781
0782 #define JRSTA_CCBERR_ERRID_NONE 0x00
0783 #define JRSTA_CCBERR_ERRID_MODE 0x01
0784 #define JRSTA_CCBERR_ERRID_DATASIZ 0x02
0785 #define JRSTA_CCBERR_ERRID_KEYSIZ 0x03
0786 #define JRSTA_CCBERR_ERRID_PKAMEMSZ 0x04
0787 #define JRSTA_CCBERR_ERRID_PKBMEMSZ 0x05
0788 #define JRSTA_CCBERR_ERRID_SEQUENCE 0x06
0789 #define JRSTA_CCBERR_ERRID_PKDIVZRO 0x07
0790 #define JRSTA_CCBERR_ERRID_PKMODEVN 0x08
0791 #define JRSTA_CCBERR_ERRID_KEYPARIT 0x09
0792 #define JRSTA_CCBERR_ERRID_ICVCHK 0x0a
0793 #define JRSTA_CCBERR_ERRID_HARDWARE 0x0b
0794 #define JRSTA_CCBERR_ERRID_CCMAAD 0x0c
0795 #define JRSTA_CCBERR_ERRID_INVCHA 0x0f
0796
0797 #define JRINT_ERR_INDEX_MASK 0x3fff0000
0798 #define JRINT_ERR_INDEX_SHIFT 16
0799 #define JRINT_ERR_TYPE_MASK 0xf00
0800 #define JRINT_ERR_TYPE_SHIFT 8
0801 #define JRINT_ERR_HALT_MASK 0xc
0802 #define JRINT_ERR_HALT_SHIFT 2
0803 #define JRINT_ERR_HALT_INPROGRESS 0x4
0804 #define JRINT_ERR_HALT_COMPLETE 0x8
0805 #define JRINT_JR_ERROR 0x02
0806 #define JRINT_JR_INT 0x01
0807
0808 #define JRINT_ERR_TYPE_WRITE 1
0809 #define JRINT_ERR_TYPE_BAD_INPADDR 3
0810 #define JRINT_ERR_TYPE_BAD_OUTADDR 4
0811 #define JRINT_ERR_TYPE_INV_INPWRT 5
0812 #define JRINT_ERR_TYPE_INV_OUTWRT 6
0813 #define JRINT_ERR_TYPE_RESET 7
0814 #define JRINT_ERR_TYPE_REMOVE_OFL 8
0815 #define JRINT_ERR_TYPE_ADD_OFL 9
0816
0817 #define JRCFG_SOE 0x04
0818 #define JRCFG_ICEN 0x02
0819 #define JRCFG_IMSK 0x01
0820 #define JRCFG_ICDCT_SHIFT 8
0821 #define JRCFG_ICTT_SHIFT 16
0822
0823 #define JRCR_RESET 0x01
0824
0825
0826
0827
0828
0829
0830 struct rtic_element {
0831 u64 address;
0832 u32 rsvd;
0833 u32 length;
0834 };
0835
0836 struct rtic_block {
0837 struct rtic_element element[2];
0838 };
0839
0840 struct rtic_memhash {
0841 u32 memhash_be[32];
0842 u32 memhash_le[32];
0843 };
0844
0845 struct caam_assurance {
0846
0847 u32 rsvd1;
0848 u32 status;
0849 u32 rsvd2;
0850 u32 cmd;
0851 u32 rsvd3;
0852 u32 ctrl;
0853 u32 rsvd4;
0854 u32 throttle;
0855 u32 rsvd5[2];
0856 u64 watchdog;
0857 u32 rsvd6;
0858 u32 rend;
0859 u32 rsvd7[50];
0860
0861
0862 struct rtic_block memblk[4];
0863 u32 rsvd8[32];
0864
0865
0866 struct rtic_memhash hash[4];
0867 u32 rsvd_3[640];
0868 };
0869
0870
0871
0872
0873
0874
0875 struct caam_queue_if {
0876 u32 qi_control_hi;
0877 u32 qi_control_lo;
0878 u32 rsvd1;
0879 u32 qi_status;
0880 u32 qi_deq_cfg_hi;
0881 u32 qi_deq_cfg_lo;
0882 u32 qi_enq_cfg_hi;
0883 u32 qi_enq_cfg_lo;
0884 u32 rsvd2[1016];
0885 };
0886
0887
0888 #define QICTL_DQEN 0x01
0889 #define QICTL_STOP 0x02
0890 #define QICTL_SOE 0x04
0891
0892
0893 #define QICTL_MBSI 0x01
0894 #define QICTL_MHWSI 0x02
0895 #define QICTL_MWSI 0x04
0896 #define QICTL_MDWSI 0x08
0897 #define QICTL_CBSI 0x10
0898 #define QICTL_CHWSI 0x20
0899 #define QICTL_CWSI 0x40
0900 #define QICTL_CDWSI 0x80
0901 #define QICTL_MBSO 0x0100
0902 #define QICTL_MHWSO 0x0200
0903 #define QICTL_MWSO 0x0400
0904 #define QICTL_MDWSO 0x0800
0905 #define QICTL_CBSO 0x1000
0906 #define QICTL_CHWSO 0x2000
0907 #define QICTL_CWSO 0x4000
0908 #define QICTL_CDWSO 0x8000
0909 #define QICTL_DMBS 0x010000
0910 #define QICTL_EPO 0x020000
0911
0912
0913 #define QISTA_PHRDERR 0x01
0914 #define QISTA_CFRDERR 0x02
0915 #define QISTA_OFWRERR 0x04
0916 #define QISTA_BPDERR 0x08
0917 #define QISTA_BTSERR 0x10
0918 #define QISTA_CFWRERR 0x20
0919 #define QISTA_STOPD 0x80000000
0920
0921
0922 struct deco_sg_table {
0923 u64 addr;
0924 u32 elen;
0925 u32 bpid_offset;
0926 };
0927
0928
0929
0930
0931
0932
0933
0934
0935
0936
0937 struct caam_deco {
0938 u32 rsvd1;
0939 u32 cls1_mode;
0940 u32 rsvd2;
0941 u32 cls1_keysize;
0942 u32 cls1_datasize_hi;
0943 u32 cls1_datasize_lo;
0944 u32 rsvd3;
0945 u32 cls1_icvsize;
0946 u32 rsvd4[5];
0947 u32 cha_ctrl;
0948 u32 rsvd5;
0949 u32 irq_crtl;
0950 u32 rsvd6;
0951 u32 clr_written;
0952 u32 ccb_status_hi;
0953 u32 ccb_status_lo;
0954 u32 rsvd7[3];
0955 u32 aad_size;
0956 u32 rsvd8;
0957 u32 cls1_iv_size;
0958 u32 rsvd9[7];
0959 u32 pkha_a_size;
0960 u32 rsvd10;
0961 u32 pkha_b_size;
0962 u32 rsvd11;
0963 u32 pkha_n_size;
0964 u32 rsvd12;
0965 u32 pkha_e_size;
0966 u32 rsvd13[24];
0967 u32 cls1_ctx[16];
0968 u32 rsvd14[48];
0969 u32 cls1_key[8];
0970 u32 rsvd15[121];
0971 u32 cls2_mode;
0972 u32 rsvd16;
0973 u32 cls2_keysize;
0974 u32 cls2_datasize_hi;
0975 u32 cls2_datasize_lo;
0976 u32 rsvd17;
0977 u32 cls2_icvsize;
0978 u32 rsvd18[56];
0979 u32 cls2_ctx[18];
0980 u32 rsvd19[46];
0981 u32 cls2_key[32];
0982 u32 rsvd20[84];
0983 u32 inp_infofifo_hi;
0984 u32 inp_infofifo_lo;
0985 u32 rsvd21[2];
0986 u64 inp_datafifo;
0987 u32 rsvd22[2];
0988 u64 out_datafifo;
0989 u32 rsvd23[2];
0990 u32 jr_ctl_hi;
0991 u32 jr_ctl_lo;
0992 u64 jr_descaddr;
0993 #define DECO_OP_STATUS_HI_ERR_MASK 0xF00000FF
0994 u32 op_status_hi;
0995 u32 op_status_lo;
0996 u32 rsvd24[2];
0997 u32 liodn;
0998 u32 td_liodn;
0999 u32 rsvd26[6];
1000 u64 math[4];
1001 u32 rsvd27[8];
1002 struct deco_sg_table gthr_tbl[4];
1003 u32 rsvd28[16];
1004 struct deco_sg_table sctr_tbl[4];
1005 u32 rsvd29[48];
1006 u32 descbuf[64];
1007 u32 rscvd30[193];
1008 #define DESC_DBG_DECO_STAT_VALID 0x80000000
1009 #define DESC_DBG_DECO_STAT_MASK 0x00F00000
1010 #define DESC_DBG_DECO_STAT_SHIFT 20
1011 u32 desc_dbg;
1012 u32 rsvd31[13];
1013 #define DESC_DER_DECO_STAT_MASK 0x000F0000
1014 #define DESC_DER_DECO_STAT_SHIFT 16
1015 u32 dbg_exec;
1016 u32 rsvd32[112];
1017 };
1018
1019 #define DECO_STAT_HOST_ERR 0xD
1020
1021 #define DECO_JQCR_WHL 0x20000000
1022 #define DECO_JQCR_FOUR 0x10000000
1023
1024 #define JR_BLOCK_NUMBER 1
1025 #define ASSURE_BLOCK_NUMBER 6
1026 #define QI_BLOCK_NUMBER 7
1027 #define DECO_BLOCK_NUMBER 8
1028 #define PG_SIZE_4K 0x1000
1029 #define PG_SIZE_64K 0x10000
1030 #endif