caamalg.c (a5e5c13398f353bb7ebbe913a7bb0c2a77b2ae10) | caamalg.c (1b46c90c8e002028dc622bf7bd8cf89efcaab274) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * caam - Freescale FSL CAAM support for crypto API 4 * 5 * Copyright 2008-2011 Freescale Semiconductor, Inc. 6 * Copyright 2016-2019 NXP 7 * 8 * Based on talitos crypto API driver. --- 3457 unchanged lines hidden (view full) --- 3466 caam_exit_common(crypto_skcipher_ctx(tfm)); 3467} 3468 3469static void caam_aead_exit(struct crypto_aead *tfm) 3470{ 3471 caam_exit_common(crypto_aead_ctx(tfm)); 3472} 3473 | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * caam - Freescale FSL CAAM support for crypto API 4 * 5 * Copyright 2008-2011 Freescale Semiconductor, Inc. 6 * Copyright 2016-2019 NXP 7 * 8 * Based on talitos crypto API driver. --- 3457 unchanged lines hidden (view full) --- 3466 caam_exit_common(crypto_skcipher_ctx(tfm)); 3467} 3468 3469static void caam_aead_exit(struct crypto_aead *tfm) 3470{ 3471 caam_exit_common(crypto_aead_ctx(tfm)); 3472} 3473 |
3474static void __exit caam_algapi_exit(void) | 3474void caam_algapi_exit(void) |
3475{ 3476 int i; 3477 3478 for (i = 0; i < ARRAY_SIZE(driver_aeads); i++) { 3479 struct caam_aead_alg *t_alg = driver_aeads + i; 3480 3481 if (t_alg->registered) 3482 crypto_unregister_aead(&t_alg->aead); --- 28 unchanged lines hidden (view full) --- 3511 alg->base.cra_priority = CAAM_CRA_PRIORITY; 3512 alg->base.cra_ctxsize = sizeof(struct caam_ctx); 3513 alg->base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY; 3514 3515 alg->init = caam_aead_init; 3516 alg->exit = caam_aead_exit; 3517} 3518 | 3475{ 3476 int i; 3477 3478 for (i = 0; i < ARRAY_SIZE(driver_aeads); i++) { 3479 struct caam_aead_alg *t_alg = driver_aeads + i; 3480 3481 if (t_alg->registered) 3482 crypto_unregister_aead(&t_alg->aead); --- 28 unchanged lines hidden (view full) --- 3511 alg->base.cra_priority = CAAM_CRA_PRIORITY; 3512 alg->base.cra_ctxsize = sizeof(struct caam_ctx); 3513 alg->base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY; 3514 3515 alg->init = caam_aead_init; 3516 alg->exit = caam_aead_exit; 3517} 3518 |
3519static int __init caam_algapi_init(void) | 3519int caam_algapi_init(struct device *ctrldev) |
3520{ | 3520{ |
3521 struct device_node *dev_node; 3522 struct platform_device *pdev; 3523 struct caam_drv_private *priv; | 3521 struct caam_drv_private *priv = dev_get_drvdata(ctrldev); |
3524 int i = 0, err = 0; 3525 u32 aes_vid, aes_inst, des_inst, md_vid, md_inst, ccha_inst, ptha_inst; 3526 u32 arc4_inst; 3527 unsigned int md_limit = SHA512_DIGEST_SIZE; 3528 bool registered = false, gcm_support; 3529 | 3522 int i = 0, err = 0; 3523 u32 aes_vid, aes_inst, des_inst, md_vid, md_inst, ccha_inst, ptha_inst; 3524 u32 arc4_inst; 3525 unsigned int md_limit = SHA512_DIGEST_SIZE; 3526 bool registered = false, gcm_support; 3527 |
3530 dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); 3531 if (!dev_node) { 3532 dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec4.0"); 3533 if (!dev_node) 3534 return -ENODEV; 3535 } 3536 3537 pdev = of_find_device_by_node(dev_node); 3538 if (!pdev) { 3539 of_node_put(dev_node); 3540 return -ENODEV; 3541 } 3542 3543 priv = dev_get_drvdata(&pdev->dev); 3544 of_node_put(dev_node); 3545 | |
3546 /* | 3528 /* |
3547 * If priv is NULL, it's probably because the caam driver wasn't 3548 * properly initialized (e.g. RNG4 init failed). Thus, bail out here. 3549 */ 3550 if (!priv) { 3551 err = -ENODEV; 3552 goto out_put_dev; 3553 } 3554 3555 3556 /* | |
3557 * Register crypto algorithms the device supports. 3558 * First, detect presence and attributes of DES, AES, and MD blocks. 3559 */ 3560 if (priv->era < 10) { 3561 u32 cha_vid, cha_inst, aes_rn; 3562 3563 cha_vid = rd_reg32(&priv->ctrl->perfmon.cha_id_ls); 3564 aes_vid = cha_vid & CHA_ID_LS_AES_MASK; --- 125 unchanged lines hidden (view full) --- 3690 3691 t_alg->registered = true; 3692 registered = true; 3693 } 3694 3695 if (registered) 3696 pr_info("caam algorithms registered in /proc/crypto\n"); 3697 | 3529 * Register crypto algorithms the device supports. 3530 * First, detect presence and attributes of DES, AES, and MD blocks. 3531 */ 3532 if (priv->era < 10) { 3533 u32 cha_vid, cha_inst, aes_rn; 3534 3535 cha_vid = rd_reg32(&priv->ctrl->perfmon.cha_id_ls); 3536 aes_vid = cha_vid & CHA_ID_LS_AES_MASK; --- 125 unchanged lines hidden (view full) --- 3662 3663 t_alg->registered = true; 3664 registered = true; 3665 } 3666 3667 if (registered) 3668 pr_info("caam algorithms registered in /proc/crypto\n"); 3669 |
3698out_put_dev: 3699 put_device(&pdev->dev); | |
3700 return err; 3701} | 3670 return err; 3671} |
3702 3703module_init(caam_algapi_init); 3704module_exit(caam_algapi_exit); 3705 3706MODULE_LICENSE("GPL"); 3707MODULE_DESCRIPTION("FSL CAAM support for crypto API"); 3708MODULE_AUTHOR("Freescale Semiconductor - NMG/STC"); | |