|
13 | 13 | #include <linux/fsl/mc.h> |
14 | 14 |
|
15 | 15 | #include "compat.h" |
| 16 | +#include "debugfs.h" |
16 | 17 | #include "regs.h" |
17 | 18 | #include "intern.h" |
18 | 19 | #include "jr.h" |
@@ -582,12 +583,10 @@ static int init_clocks(struct device *dev, const struct caam_imx_data *data) |
582 | 583 | return devm_add_action_or_reset(dev, disable_clocks, ctrlpriv); |
583 | 584 | } |
584 | 585 |
|
585 | | -#ifdef CONFIG_DEBUG_FS |
586 | 586 | static void caam_remove_debugfs(void *root) |
587 | 587 | { |
588 | 588 | debugfs_remove_recursive(root); |
589 | 589 | } |
590 | | -#endif |
591 | 590 |
|
592 | 591 | #ifdef CONFIG_FSL_MC_BUS |
593 | 592 | static bool check_version(struct fsl_mc_version *mc_version, u32 major, |
@@ -619,10 +618,7 @@ static int caam_probe(struct platform_device *pdev) |
619 | 618 | struct device_node *nprop, *np; |
620 | 619 | struct caam_ctrl __iomem *ctrl; |
621 | 620 | struct caam_drv_private *ctrlpriv; |
622 | | -#ifdef CONFIG_DEBUG_FS |
623 | | - struct caam_perfmon *perfmon; |
624 | 621 | struct dentry *dfs_root; |
625 | | -#endif |
626 | 622 | u32 scfgr, comp_params; |
627 | 623 | u8 rng_vid; |
628 | 624 | int pg_size; |
@@ -777,21 +773,15 @@ static int caam_probe(struct platform_device *pdev) |
777 | 773 | ctrlpriv->era = caam_get_era(ctrl); |
778 | 774 | ctrlpriv->domain = iommu_get_domain_for_dev(dev); |
779 | 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 | 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 | 785 |
|
796 | 786 | /* Check to see if (DPAA 1.x) QI present. If so, enable */ |
797 | 787 | if (ctrlpriv->qi_present && !caam_dpaa2) { |
@@ -912,57 +902,6 @@ static int caam_probe(struct platform_device *pdev) |
912 | 902 | dev_info(dev, "job rings = %d, qi = %d\n", |
913 | 903 | ctrlpriv->total_jobrs, ctrlpriv->qi_present); |
914 | 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 | 905 | ret = devm_of_platform_populate(dev); |
967 | 906 | if (ret) |
968 | 907 | dev_err(dev, "JR platform devices creation error\n"); |
|
0 commit comments