ctrl.c (d85ddd1318e66c0c2665dbfcbc21a8b66c9152aa) ctrl.c (abd9875497ba47e198fb565f11d5f332eeb08ab3)
1// SPDX-License-Identifier: GPL-2.0+
2/* * CAAM control-plane driver backend
3 * Controller-level driver, kernel property detection, initialization
4 *
5 * Copyright 2008-2012 Freescale Semiconductor, Inc.
6 * Copyright 2018-2019 NXP
7 */
8
9#include <linux/device.h>
10#include <linux/of_address.h>
11#include <linux/of_irq.h>
12#include <linux/sys_soc.h>
13#include <linux/fsl/mc.h>
14
15#include "compat.h"
1// SPDX-License-Identifier: GPL-2.0+
2/* * CAAM control-plane driver backend
3 * Controller-level driver, kernel property detection, initialization
4 *
5 * Copyright 2008-2012 Freescale Semiconductor, Inc.
6 * Copyright 2018-2019 NXP
7 */
8
9#include <linux/device.h>
10#include <linux/of_address.h>
11#include <linux/of_irq.h>
12#include <linux/sys_soc.h>
13#include <linux/fsl/mc.h>
14
15#include "compat.h"
16#include "debugfs.h"
16#include "regs.h"
17#include "intern.h"
18#include "jr.h"
19#include "desc_constr.h"
20#include "ctrl.h"
21
22bool caam_dpaa2;
23EXPORT_SYMBOL(caam_dpaa2);

--- 553 unchanged lines hidden (view full) ---

577 dev_err(dev,
578 "Failed to prepare/enable all necessary clocks\n");
579 return ret;
580 }
581
582 return devm_add_action_or_reset(dev, disable_clocks, ctrlpriv);
583}
584
17#include "regs.h"
18#include "intern.h"
19#include "jr.h"
20#include "desc_constr.h"
21#include "ctrl.h"
22
23bool caam_dpaa2;
24EXPORT_SYMBOL(caam_dpaa2);

--- 553 unchanged lines hidden (view full) ---

578 dev_err(dev,
579 "Failed to prepare/enable all necessary clocks\n");
580 return ret;
581 }
582
583 return devm_add_action_or_reset(dev, disable_clocks, ctrlpriv);
584}
585
585#ifdef CONFIG_DEBUG_FS
586static void caam_remove_debugfs(void *root)
587{
588 debugfs_remove_recursive(root);
589}
586static void caam_remove_debugfs(void *root)
587{
588 debugfs_remove_recursive(root);
589}
590#endif
591
592#ifdef CONFIG_FSL_MC_BUS
593static bool check_version(struct fsl_mc_version *mc_version, u32 major,
594 u32 minor, u32 revision)
595{
596 if (mc_version->major > major)
597 return true;
598

--- 15 unchanged lines hidden (view full) ---

614{
615 int ret, ring, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN;
616 u64 caam_id;
617 const struct soc_device_attribute *imx_soc_match;
618 struct device *dev;
619 struct device_node *nprop, *np;
620 struct caam_ctrl __iomem *ctrl;
621 struct caam_drv_private *ctrlpriv;
590
591#ifdef CONFIG_FSL_MC_BUS
592static bool check_version(struct fsl_mc_version *mc_version, u32 major,
593 u32 minor, u32 revision)
594{
595 if (mc_version->major > major)
596 return true;
597

--- 15 unchanged lines hidden (view full) ---

613{
614 int ret, ring, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN;
615 u64 caam_id;
616 const struct soc_device_attribute *imx_soc_match;
617 struct device *dev;
618 struct device_node *nprop, *np;
619 struct caam_ctrl __iomem *ctrl;
620 struct caam_drv_private *ctrlpriv;
622#ifdef CONFIG_DEBUG_FS
623 struct caam_perfmon *perfmon;
624 struct dentry *dfs_root;
621 struct dentry *dfs_root;
625#endif
626 u32 scfgr, comp_params;
627 u8 rng_vid;
628 int pg_size;
629 int BLOCK_OFFSET = 0;
630 bool pr_support = false;
631
632 ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(*ctrlpriv), GFP_KERNEL);
633 if (!ctrlpriv)

--- 138 unchanged lines hidden (view full) ---

772 if (ret) {
773 dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
774 return ret;
775 }
776
777 ctrlpriv->era = caam_get_era(ctrl);
778 ctrlpriv->domain = iommu_get_domain_for_dev(dev);
779
622 u32 scfgr, comp_params;
623 u8 rng_vid;
624 int pg_size;
625 int BLOCK_OFFSET = 0;
626 bool pr_support = false;
627
628 ctrlpriv = devm_kzalloc(&pdev->dev, sizeof(*ctrlpriv), GFP_KERNEL);
629 if (!ctrlpriv)

--- 138 unchanged lines hidden (view full) ---

768 if (ret) {
769 dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret);
770 return ret;
771 }
772
773 ctrlpriv->era = caam_get_era(ctrl);
774 ctrlpriv->domain = iommu_get_domain_for_dev(dev);
775
780#ifdef CONFIG_DEBUG_FS
781 /*
782 * FIXME: needs better naming distinction, as some amalgamation of
783 * "caam" and nprop->full_name. The OF name isn't distinctive,
784 * but does separate instances
785 */
786 perfmon = (struct caam_perfmon __force *)&ctrl->perfmon;
787
788 dfs_root = debugfs_create_dir(dev_name(dev), NULL);
776 dfs_root = debugfs_create_dir(dev_name(dev), NULL);
789 ret = devm_add_action_or_reset(dev, caam_remove_debugfs, dfs_root);
790 if (ret)
791 return ret;
777 if (IS_ENABLED(CONFIG_DEBUG_FS)) {
778 ret = devm_add_action_or_reset(dev, caam_remove_debugfs,
779 dfs_root);
780 if (ret)
781 return ret;
782 }
792
783
793 ctrlpriv->ctl = debugfs_create_dir("ctl", dfs_root);
794#endif
784 caam_debugfs_init(ctrlpriv, dfs_root);
795
796 /* Check to see if (DPAA 1.x) QI present. If so, enable */
797 if (ctrlpriv->qi_present && !caam_dpaa2) {
798 ctrlpriv->qi = (struct caam_queue_if __iomem __force *)
799 ((__force uint8_t *)ctrl +
800 BLOCK_OFFSET * QI_BLOCK_NUMBER
801 );
802 /* This is all that's required to physically enable QI */

--- 104 unchanged lines hidden (view full) ---

907 (u64)rd_reg32(&ctrl->perfmon.caam_id_ls);
908
909 /* Report "alive" for developer to see */
910 dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id,
911 ctrlpriv->era);
912 dev_info(dev, "job rings = %d, qi = %d\n",
913 ctrlpriv->total_jobrs, ctrlpriv->qi_present);
914
785
786 /* Check to see if (DPAA 1.x) QI present. If so, enable */
787 if (ctrlpriv->qi_present && !caam_dpaa2) {
788 ctrlpriv->qi = (struct caam_queue_if __iomem __force *)
789 ((__force uint8_t *)ctrl +
790 BLOCK_OFFSET * QI_BLOCK_NUMBER
791 );
792 /* This is all that's required to physically enable QI */

--- 104 unchanged lines hidden (view full) ---

897 (u64)rd_reg32(&ctrl->perfmon.caam_id_ls);
898
899 /* Report "alive" for developer to see */
900 dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id,
901 ctrlpriv->era);
902 dev_info(dev, "job rings = %d, qi = %d\n",
903 ctrlpriv->total_jobrs, ctrlpriv->qi_present);
904
915#ifdef CONFIG_DEBUG_FS
916 debugfs_create_file("rq_dequeued", S_IRUSR | S_IRGRP | S_IROTH,
917 ctrlpriv->ctl, &perfmon->req_dequeued,
918 &caam_fops_u64_ro);
919 debugfs_create_file("ob_rq_encrypted", S_IRUSR | S_IRGRP | S_IROTH,
920 ctrlpriv->ctl, &perfmon->ob_enc_req,
921 &caam_fops_u64_ro);
922 debugfs_create_file("ib_rq_decrypted", S_IRUSR | S_IRGRP | S_IROTH,
923 ctrlpriv->ctl, &perfmon->ib_dec_req,
924 &caam_fops_u64_ro);
925 debugfs_create_file("ob_bytes_encrypted", S_IRUSR | S_IRGRP | S_IROTH,
926 ctrlpriv->ctl, &perfmon->ob_enc_bytes,
927 &caam_fops_u64_ro);
928 debugfs_create_file("ob_bytes_protected", S_IRUSR | S_IRGRP | S_IROTH,
929 ctrlpriv->ctl, &perfmon->ob_prot_bytes,
930 &caam_fops_u64_ro);
931 debugfs_create_file("ib_bytes_decrypted", S_IRUSR | S_IRGRP | S_IROTH,
932 ctrlpriv->ctl, &perfmon->ib_dec_bytes,
933 &caam_fops_u64_ro);
934 debugfs_create_file("ib_bytes_validated", S_IRUSR | S_IRGRP | S_IROTH,
935 ctrlpriv->ctl, &perfmon->ib_valid_bytes,
936 &caam_fops_u64_ro);
937
938 /* Controller level - global status values */
939 debugfs_create_file("fault_addr", S_IRUSR | S_IRGRP | S_IROTH,
940 ctrlpriv->ctl, &perfmon->faultaddr,
941 &caam_fops_u32_ro);
942 debugfs_create_file("fault_detail", S_IRUSR | S_IRGRP | S_IROTH,
943 ctrlpriv->ctl, &perfmon->faultdetail,
944 &caam_fops_u32_ro);
945 debugfs_create_file("fault_status", S_IRUSR | S_IRGRP | S_IROTH,
946 ctrlpriv->ctl, &perfmon->status,
947 &caam_fops_u32_ro);
948
949 /* Internal covering keys (useful in non-secure mode only) */
950 ctrlpriv->ctl_kek_wrap.data = (__force void *)&ctrlpriv->ctrl->kek[0];
951 ctrlpriv->ctl_kek_wrap.size = KEK_KEY_SIZE * sizeof(u32);
952 debugfs_create_blob("kek", S_IRUSR | S_IRGRP | S_IROTH, ctrlpriv->ctl,
953 &ctrlpriv->ctl_kek_wrap);
954
955 ctrlpriv->ctl_tkek_wrap.data = (__force void *)&ctrlpriv->ctrl->tkek[0];
956 ctrlpriv->ctl_tkek_wrap.size = KEK_KEY_SIZE * sizeof(u32);
957 debugfs_create_blob("tkek", S_IRUSR | S_IRGRP | S_IROTH, ctrlpriv->ctl,
958 &ctrlpriv->ctl_tkek_wrap);
959
960 ctrlpriv->ctl_tdsk_wrap.data = (__force void *)&ctrlpriv->ctrl->tdsk[0];
961 ctrlpriv->ctl_tdsk_wrap.size = KEK_KEY_SIZE * sizeof(u32);
962 debugfs_create_blob("tdsk", S_IRUSR | S_IRGRP | S_IROTH, ctrlpriv->ctl,
963 &ctrlpriv->ctl_tdsk_wrap);
964#endif
965
966 ret = devm_of_platform_populate(dev);
967 if (ret)
968 dev_err(dev, "JR platform devices creation error\n");
969
970 return ret;
971}
972
973static struct platform_driver caam_driver = {

--- 12 unchanged lines hidden ---
905 ret = devm_of_platform_populate(dev);
906 if (ret)
907 dev_err(dev, "JR platform devices creation error\n");
908
909 return ret;
910}
911
912static struct platform_driver caam_driver = {

--- 12 unchanged lines hidden ---