diff options
Diffstat (limited to 'drivers/crypto/ccp/ccp-dev-v5.c')
-rw-r--r-- | drivers/crypto/ccp/ccp-dev-v5.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c index 41cc853f8569..fc5666eb59f2 100644 --- a/drivers/crypto/ccp/ccp-dev-v5.c +++ b/drivers/crypto/ccp/ccp-dev-v5.c | |||
@@ -108,6 +108,12 @@ union ccp_function { | |||
108 | u16 type:2; | 108 | u16 type:2; |
109 | } aes_xts; | 109 | } aes_xts; |
110 | struct { | 110 | struct { |
111 | u16 size:7; | ||
112 | u16 encrypt:1; | ||
113 | u16 mode:5; | ||
114 | u16 type:2; | ||
115 | } des3; | ||
116 | struct { | ||
111 | u16 rsvd1:10; | 117 | u16 rsvd1:10; |
112 | u16 type:4; | 118 | u16 type:4; |
113 | u16 rsvd2:1; | 119 | u16 rsvd2:1; |
@@ -139,6 +145,10 @@ union ccp_function { | |||
139 | #define CCP_AES_TYPE(p) ((p)->aes.type) | 145 | #define CCP_AES_TYPE(p) ((p)->aes.type) |
140 | #define CCP_XTS_SIZE(p) ((p)->aes_xts.size) | 146 | #define CCP_XTS_SIZE(p) ((p)->aes_xts.size) |
141 | #define CCP_XTS_ENCRYPT(p) ((p)->aes_xts.encrypt) | 147 | #define CCP_XTS_ENCRYPT(p) ((p)->aes_xts.encrypt) |
148 | #define CCP_DES3_SIZE(p) ((p)->des3.size) | ||
149 | #define CCP_DES3_ENCRYPT(p) ((p)->des3.encrypt) | ||
150 | #define CCP_DES3_MODE(p) ((p)->des3.mode) | ||
151 | #define CCP_DES3_TYPE(p) ((p)->des3.type) | ||
142 | #define CCP_SHA_TYPE(p) ((p)->sha.type) | 152 | #define CCP_SHA_TYPE(p) ((p)->sha.type) |
143 | #define CCP_RSA_SIZE(p) ((p)->rsa.size) | 153 | #define CCP_RSA_SIZE(p) ((p)->rsa.size) |
144 | #define CCP_PT_BYTESWAP(p) ((p)->pt.byteswap) | 154 | #define CCP_PT_BYTESWAP(p) ((p)->pt.byteswap) |
@@ -388,6 +398,47 @@ static int ccp5_perform_sha(struct ccp_op *op) | |||
388 | return ccp5_do_cmd(&desc, op->cmd_q); | 398 | return ccp5_do_cmd(&desc, op->cmd_q); |
389 | } | 399 | } |
390 | 400 | ||
401 | static int ccp5_perform_des3(struct ccp_op *op) | ||
402 | { | ||
403 | struct ccp5_desc desc; | ||
404 | union ccp_function function; | ||
405 | u32 key_addr = op->sb_key * LSB_ITEM_SIZE; | ||
406 | |||
407 | /* Zero out all the fields of the command desc */ | ||
408 | memset(&desc, 0, sizeof(struct ccp5_desc)); | ||
409 | |||
410 | CCP5_CMD_ENGINE(&desc) = CCP_ENGINE_DES3; | ||
411 | |||
412 | CCP5_CMD_SOC(&desc) = op->soc; | ||
413 | CCP5_CMD_IOC(&desc) = 1; | ||
414 | CCP5_CMD_INIT(&desc) = op->init; | ||
415 | CCP5_CMD_EOM(&desc) = op->eom; | ||
416 | CCP5_CMD_PROT(&desc) = 0; | ||
417 | |||
418 | function.raw = 0; | ||
419 | CCP_DES3_ENCRYPT(&function) = op->u.des3.action; | ||
420 | CCP_DES3_MODE(&function) = op->u.des3.mode; | ||
421 | CCP_DES3_TYPE(&function) = op->u.des3.type; | ||
422 | CCP5_CMD_FUNCTION(&desc) = cpu_to_le32(function.raw); | ||
423 | |||
424 | CCP5_CMD_LEN(&desc) = cpu_to_le32(op->src.u.dma.length); | ||
425 | |||
426 | CCP5_CMD_SRC_LO(&desc) = cpu_to_le32(ccp_addr_lo(&op->src.u.dma)); | ||
427 | CCP5_CMD_SRC_HI(&desc) = cpu_to_le32(ccp_addr_hi(&op->src.u.dma)); | ||
428 | CCP5_CMD_SRC_MEM(&desc) = cpu_to_le32(CCP_MEMTYPE_SYSTEM); | ||
429 | |||
430 | CCP5_CMD_DST_LO(&desc) = cpu_to_le32(ccp_addr_lo(&op->dst.u.dma)); | ||
431 | CCP5_CMD_DST_HI(&desc) = cpu_to_le32(ccp_addr_hi(&op->dst.u.dma)); | ||
432 | CCP5_CMD_DST_MEM(&desc) = cpu_to_le32(CCP_MEMTYPE_SYSTEM); | ||
433 | |||
434 | CCP5_CMD_KEY_LO(&desc) = cpu_to_le32(lower_32_bits(key_addr)); | ||
435 | CCP5_CMD_KEY_HI(&desc) = 0; | ||
436 | CCP5_CMD_KEY_MEM(&desc) = cpu_to_le32(CCP_MEMTYPE_SB); | ||
437 | CCP5_CMD_LSB_ID(&desc) = cpu_to_le32(op->sb_ctx); | ||
438 | |||
439 | return ccp5_do_cmd(&desc, op->cmd_q); | ||
440 | } | ||
441 | |||
391 | static int ccp5_perform_rsa(struct ccp_op *op) | 442 | static int ccp5_perform_rsa(struct ccp_op *op) |
392 | { | 443 | { |
393 | struct ccp5_desc desc; | 444 | struct ccp5_desc desc; |
@@ -435,6 +486,7 @@ static int ccp5_perform_passthru(struct ccp_op *op) | |||
435 | struct ccp_dma_info *saddr = &op->src.u.dma; | 486 | struct ccp_dma_info *saddr = &op->src.u.dma; |
436 | struct ccp_dma_info *daddr = &op->dst.u.dma; | 487 | struct ccp_dma_info *daddr = &op->dst.u.dma; |
437 | 488 | ||
489 | |||
438 | memset(&desc, 0, Q_DESC_SIZE); | 490 | memset(&desc, 0, Q_DESC_SIZE); |
439 | 491 | ||
440 | CCP5_CMD_ENGINE(&desc) = CCP_ENGINE_PASSTHRU; | 492 | CCP5_CMD_ENGINE(&desc) = CCP_ENGINE_PASSTHRU; |
@@ -729,6 +781,7 @@ static int ccp5_init(struct ccp_device *ccp) | |||
729 | 781 | ||
730 | dev_dbg(dev, "queue #%u available\n", i); | 782 | dev_dbg(dev, "queue #%u available\n", i); |
731 | } | 783 | } |
784 | |||
732 | if (ccp->cmd_q_count == 0) { | 785 | if (ccp->cmd_q_count == 0) { |
733 | dev_notice(dev, "no command queues available\n"); | 786 | dev_notice(dev, "no command queues available\n"); |
734 | ret = -EIO; | 787 | ret = -EIO; |
@@ -994,6 +1047,7 @@ static const struct ccp_actions ccp5_actions = { | |||
994 | .aes = ccp5_perform_aes, | 1047 | .aes = ccp5_perform_aes, |
995 | .xts_aes = ccp5_perform_xts_aes, | 1048 | .xts_aes = ccp5_perform_xts_aes, |
996 | .sha = ccp5_perform_sha, | 1049 | .sha = ccp5_perform_sha, |
1050 | .des3 = ccp5_perform_des3, | ||
997 | .rsa = ccp5_perform_rsa, | 1051 | .rsa = ccp5_perform_rsa, |
998 | .passthru = ccp5_perform_passthru, | 1052 | .passthru = ccp5_perform_passthru, |
999 | .ecc = ccp5_perform_ecc, | 1053 | .ecc = ccp5_perform_ecc, |