ctrl.c (b70366e5d31788650b2a5cec5cd13ea80ac7e44a) | ctrl.c (67c2315def06c1ef18492b214686531e69682800) |
---|---|
1/* * CAAM control-plane driver backend 2 * Controller-level driver, kernel property detection, initialization 3 * 4 * Copyright 2008-2012 Freescale Semiconductor, Inc. 5 */ 6 7#include <linux/device.h> 8#include <linux/of_address.h> --- 4 unchanged lines hidden (view full) --- 13#include "intern.h" 14#include "jr.h" 15#include "desc_constr.h" 16#include "ctrl.h" 17 18bool caam_little_end; 19EXPORT_SYMBOL(caam_little_end); 20 | 1/* * CAAM control-plane driver backend 2 * Controller-level driver, kernel property detection, initialization 3 * 4 * Copyright 2008-2012 Freescale Semiconductor, Inc. 5 */ 6 7#include <linux/device.h> 8#include <linux/of_address.h> --- 4 unchanged lines hidden (view full) --- 13#include "intern.h" 14#include "jr.h" 15#include "desc_constr.h" 16#include "ctrl.h" 17 18bool caam_little_end; 19EXPORT_SYMBOL(caam_little_end); 20 |
21#ifdef CONFIG_CAAM_QI 22#include "qi.h" 23#endif 24 |
|
21/* 22 * i.MX targets tend to have clock control subsystems that can 23 * enable/disable clocking to our device. 24 */ 25#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_IMX 26static inline struct clk *caam_drv_identify_clk(struct device *dev, 27 char *clk_name) 28{ --- 277 unchanged lines hidden (view full) --- 306 ctrldev = &pdev->dev; 307 ctrlpriv = dev_get_drvdata(ctrldev); 308 ctrl = (struct caam_ctrl __iomem *)ctrlpriv->ctrl; 309 310 /* Remove platform devices for JobRs */ 311 for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) 312 of_device_unregister(ctrlpriv->jrpdev[ring]); 313 | 25/* 26 * i.MX targets tend to have clock control subsystems that can 27 * enable/disable clocking to our device. 28 */ 29#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_IMX 30static inline struct clk *caam_drv_identify_clk(struct device *dev, 31 char *clk_name) 32{ --- 277 unchanged lines hidden (view full) --- 310 ctrldev = &pdev->dev; 311 ctrlpriv = dev_get_drvdata(ctrldev); 312 ctrl = (struct caam_ctrl __iomem *)ctrlpriv->ctrl; 313 314 /* Remove platform devices for JobRs */ 315 for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) 316 of_device_unregister(ctrlpriv->jrpdev[ring]); 317 |
318#ifdef CONFIG_CAAM_QI 319 if (ctrlpriv->qidev) 320 caam_qi_shutdown(ctrlpriv->qidev); 321#endif 322 |
|
314 /* De-initialize RNG state handles initialized by this driver. */ 315 if (ctrlpriv->rng4_sh_init) 316 deinstantiate_rng(ctrldev, ctrlpriv->rng4_sh_init); 317 318 /* Shut down debug views */ 319#ifdef CONFIG_DEBUG_FS 320 debugfs_remove_recursive(ctrlpriv->dfs_root); 321#endif --- 74 unchanged lines hidden (view full) --- 396 caam_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); 397 ret = of_property_read_u32(caam_node, "fsl,sec-era", &prop); 398 of_node_put(caam_node); 399 400 return ret ? -ENOTSUPP : prop; 401} 402EXPORT_SYMBOL(caam_get_era); 403 | 323 /* De-initialize RNG state handles initialized by this driver. */ 324 if (ctrlpriv->rng4_sh_init) 325 deinstantiate_rng(ctrldev, ctrlpriv->rng4_sh_init); 326 327 /* Shut down debug views */ 328#ifdef CONFIG_DEBUG_FS 329 debugfs_remove_recursive(ctrlpriv->dfs_root); 330#endif --- 74 unchanged lines hidden (view full) --- 405 caam_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); 406 ret = of_property_read_u32(caam_node, "fsl,sec-era", &prop); 407 of_node_put(caam_node); 408 409 return ret ? -ENOTSUPP : prop; 410} 411EXPORT_SYMBOL(caam_get_era); 412 |
404#ifdef CONFIG_DEBUG_FS 405static int caam_debugfs_u64_get(void *data, u64 *val) 406{ 407 *val = caam64_to_cpu(*(u64 *)data); 408 return 0; 409} 410 411static int caam_debugfs_u32_get(void *data, u64 *val) 412{ 413 *val = caam32_to_cpu(*(u32 *)data); 414 return 0; 415} 416 417DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u32_ro, caam_debugfs_u32_get, NULL, "%llu\n"); 418DEFINE_SIMPLE_ATTRIBUTE(caam_fops_u64_ro, caam_debugfs_u64_get, NULL, "%llu\n"); 419#endif 420 | |
421/* Probe routine for CAAM top (controller) level */ 422static int caam_probe(struct platform_device *pdev) 423{ 424 int ret, ring, ridx, rspec, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN; 425 u64 caam_id; 426 struct device *dev; 427 struct device_node *nprop, *np; 428 struct caam_ctrl __iomem *ctrl; --- 181 unchanged lines hidden (view full) --- 610 611 ctrlpriv->jrpdev = devm_kcalloc(&pdev->dev, rspec, 612 sizeof(*ctrlpriv->jrpdev), GFP_KERNEL); 613 if (ctrlpriv->jrpdev == NULL) { 614 ret = -ENOMEM; 615 goto iounmap_ctrl; 616 } 617 | 413/* Probe routine for CAAM top (controller) level */ 414static int caam_probe(struct platform_device *pdev) 415{ 416 int ret, ring, ridx, rspec, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN; 417 u64 caam_id; 418 struct device *dev; 419 struct device_node *nprop, *np; 420 struct caam_ctrl __iomem *ctrl; --- 181 unchanged lines hidden (view full) --- 602 603 ctrlpriv->jrpdev = devm_kcalloc(&pdev->dev, rspec, 604 sizeof(*ctrlpriv->jrpdev), GFP_KERNEL); 605 if (ctrlpriv->jrpdev == NULL) { 606 ret = -ENOMEM; 607 goto iounmap_ctrl; 608 } 609 |
610#ifdef CONFIG_DEBUG_FS 611 /* 612 * FIXME: needs better naming distinction, as some amalgamation of 613 * "caam" and nprop->full_name. The OF name isn't distinctive, 614 * but does separate instances 615 */ 616 perfmon = (struct caam_perfmon __force *)&ctrl->perfmon; 617 618 ctrlpriv->dfs_root = debugfs_create_dir(dev_name(dev), NULL); 619 ctrlpriv->ctl = debugfs_create_dir("ctl", ctrlpriv->dfs_root); 620#endif |
|
618 ring = 0; 619 ridx = 0; 620 ctrlpriv->total_jobrs = 0; 621 for_each_available_child_of_node(nprop, np) 622 if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || 623 of_device_is_compatible(np, "fsl,sec4.0-job-ring")) { 624 ctrlpriv->jrpdev[ring] = 625 of_platform_device_create(np, NULL, dev); --- 19 unchanged lines hidden (view full) --- 645 CTPR_MS_QI_MASK); 646 if (ctrlpriv->qi_present) { 647 ctrlpriv->qi = (struct caam_queue_if __iomem __force *) 648 ((__force uint8_t *)ctrl + 649 BLOCK_OFFSET * QI_BLOCK_NUMBER 650 ); 651 /* This is all that's required to physically enable QI */ 652 wr_reg32(&ctrlpriv->qi->qi_control_lo, QICTL_DQEN); | 621 ring = 0; 622 ridx = 0; 623 ctrlpriv->total_jobrs = 0; 624 for_each_available_child_of_node(nprop, np) 625 if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || 626 of_device_is_compatible(np, "fsl,sec4.0-job-ring")) { 627 ctrlpriv->jrpdev[ring] = 628 of_platform_device_create(np, NULL, dev); --- 19 unchanged lines hidden (view full) --- 648 CTPR_MS_QI_MASK); 649 if (ctrlpriv->qi_present) { 650 ctrlpriv->qi = (struct caam_queue_if __iomem __force *) 651 ((__force uint8_t *)ctrl + 652 BLOCK_OFFSET * QI_BLOCK_NUMBER 653 ); 654 /* This is all that's required to physically enable QI */ 655 wr_reg32(&ctrlpriv->qi->qi_control_lo, QICTL_DQEN); |
656 657 /* If QMAN driver is present, init CAAM-QI backend */ 658#ifdef CONFIG_CAAM_QI 659 ret = caam_qi_init(pdev); 660 if (ret) 661 dev_err(dev, "caam qi i/f init failed: %d\n", ret); 662#endif |
|
653 } 654 655 /* If no QI and no rings specified, quit and go home */ 656 if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) { 657 dev_err(dev, "no queues configured, terminating\n"); 658 ret = -ENOMEM; 659 goto caam_remove; 660 } --- 71 unchanged lines hidden (view full) --- 732 733 /* Report "alive" for developer to see */ 734 dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id, 735 caam_get_era()); 736 dev_info(dev, "job rings = %d, qi = %d\n", 737 ctrlpriv->total_jobrs, ctrlpriv->qi_present); 738 739#ifdef CONFIG_DEBUG_FS | 663 } 664 665 /* If no QI and no rings specified, quit and go home */ 666 if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) { 667 dev_err(dev, "no queues configured, terminating\n"); 668 ret = -ENOMEM; 669 goto caam_remove; 670 } --- 71 unchanged lines hidden (view full) --- 742 743 /* Report "alive" for developer to see */ 744 dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id, 745 caam_get_era()); 746 dev_info(dev, "job rings = %d, qi = %d\n", 747 ctrlpriv->total_jobrs, ctrlpriv->qi_present); 748 749#ifdef CONFIG_DEBUG_FS |
740 /* 741 * FIXME: needs better naming distinction, as some amalgamation of 742 * "caam" and nprop->full_name. The OF name isn't distinctive, 743 * but does separate instances 744 */ 745 perfmon = (struct caam_perfmon __force *)&ctrl->perfmon; | |
746 | 750 |
747 ctrlpriv->dfs_root = debugfs_create_dir(dev_name(dev), NULL); 748 ctrlpriv->ctl = debugfs_create_dir("ctl", ctrlpriv->dfs_root); 749 750 /* Controller-level - performance monitor counters */ 751 | |
752 ctrlpriv->ctl_rq_dequeued = 753 debugfs_create_file("rq_dequeued", 754 S_IRUSR | S_IRGRP | S_IROTH, 755 ctrlpriv->ctl, &perfmon->req_dequeued, 756 &caam_fops_u64_ro); 757 ctrlpriv->ctl_ob_enc_req = 758 debugfs_create_file("ob_rq_encrypted", 759 S_IRUSR | S_IRGRP | S_IROTH, --- 65 unchanged lines hidden (view full) --- 825 S_IRUSR | 826 S_IRGRP | S_IROTH, 827 ctrlpriv->ctl, 828 &ctrlpriv->ctl_tdsk_wrap); 829#endif 830 return 0; 831 832caam_remove: | 751 ctrlpriv->ctl_rq_dequeued = 752 debugfs_create_file("rq_dequeued", 753 S_IRUSR | S_IRGRP | S_IROTH, 754 ctrlpriv->ctl, &perfmon->req_dequeued, 755 &caam_fops_u64_ro); 756 ctrlpriv->ctl_ob_enc_req = 757 debugfs_create_file("ob_rq_encrypted", 758 S_IRUSR | S_IRGRP | S_IROTH, --- 65 unchanged lines hidden (view full) --- 824 S_IRUSR | 825 S_IRGRP | S_IROTH, 826 ctrlpriv->ctl, 827 &ctrlpriv->ctl_tdsk_wrap); 828#endif 829 return 0; 830 831caam_remove: |
832#ifdef CONFIG_DEBUG_FS 833 debugfs_remove_recursive(ctrlpriv->dfs_root); 834#endif |
|
833 caam_remove(pdev); 834 return ret; 835 836iounmap_ctrl: 837 iounmap(ctrl); 838disable_caam_emi_slow: 839 if (ctrlpriv->caam_emi_slow) 840 clk_disable_unprepare(ctrlpriv->caam_emi_slow); --- 34 unchanged lines hidden --- | 835 caam_remove(pdev); 836 return ret; 837 838iounmap_ctrl: 839 iounmap(ctrl); 840disable_caam_emi_slow: 841 if (ctrlpriv->caam_emi_slow) 842 clk_disable_unprepare(ctrlpriv->caam_emi_slow); --- 34 unchanged lines hidden --- |