1 // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
2 /* Copyright 2019, 2023 NXP */
4 #include <linux/debugfs.h>
10 static int caam_debugfs_u64_get(void *data
, u64
*val
)
12 *val
= caam64_to_cpu(*(u64
*)data
);
16 static int caam_debugfs_u32_get(void *data
, u64
*val
)
18 *val
= caam32_to_cpu(*(u32
*)data
);
22 DEFINE_DEBUGFS_ATTRIBUTE(caam_fops_u32_ro
, caam_debugfs_u32_get
, NULL
, "%llu\n");
23 DEFINE_DEBUGFS_ATTRIBUTE(caam_fops_u64_ro
, caam_debugfs_u64_get
, NULL
, "%llu\n");
27 * This is a counter for the number of times the congestion group (where all
28 * the request and response queueus are) reached congestion. Incremented
29 * each time the congestion callback is called with congested == true.
31 static u64 times_congested
;
33 void caam_debugfs_qi_congested(void)
38 void caam_debugfs_qi_init(struct caam_drv_private
*ctrlpriv
)
40 debugfs_create_file("qi_congested", 0444, ctrlpriv
->ctl
,
41 ×_congested
, &caam_fops_u64_ro
);
45 void caam_debugfs_init(struct caam_drv_private
*ctrlpriv
,
46 struct caam_perfmon __force
*perfmon
,
50 * FIXME: needs better naming distinction, as some amalgamation of
51 * "caam" and nprop->full_name. The OF name isn't distinctive,
52 * but does separate instances
55 ctrlpriv
->ctl
= debugfs_create_dir("ctl", root
);
57 debugfs_create_file("rq_dequeued", 0444, ctrlpriv
->ctl
,
58 &perfmon
->req_dequeued
, &caam_fops_u64_ro
);
59 debugfs_create_file("ob_rq_encrypted", 0444, ctrlpriv
->ctl
,
60 &perfmon
->ob_enc_req
, &caam_fops_u64_ro
);
61 debugfs_create_file("ib_rq_decrypted", 0444, ctrlpriv
->ctl
,
62 &perfmon
->ib_dec_req
, &caam_fops_u64_ro
);
63 debugfs_create_file("ob_bytes_encrypted", 0444, ctrlpriv
->ctl
,
64 &perfmon
->ob_enc_bytes
, &caam_fops_u64_ro
);
65 debugfs_create_file("ob_bytes_protected", 0444, ctrlpriv
->ctl
,
66 &perfmon
->ob_prot_bytes
, &caam_fops_u64_ro
);
67 debugfs_create_file("ib_bytes_decrypted", 0444, ctrlpriv
->ctl
,
68 &perfmon
->ib_dec_bytes
, &caam_fops_u64_ro
);
69 debugfs_create_file("ib_bytes_validated", 0444, ctrlpriv
->ctl
,
70 &perfmon
->ib_valid_bytes
, &caam_fops_u64_ro
);
72 /* Controller level - global status values */
73 debugfs_create_file("fault_addr", 0444, ctrlpriv
->ctl
,
74 &perfmon
->faultaddr
, &caam_fops_u32_ro
);
75 debugfs_create_file("fault_detail", 0444, ctrlpriv
->ctl
,
76 &perfmon
->faultdetail
, &caam_fops_u32_ro
);
77 debugfs_create_file("fault_status", 0444, ctrlpriv
->ctl
,
78 &perfmon
->status
, &caam_fops_u32_ro
);
80 if (ctrlpriv
->optee_en
)
83 /* Internal covering keys (useful in non-secure mode only) */
84 ctrlpriv
->ctl_kek_wrap
.data
= (__force
void *)&ctrlpriv
->ctrl
->kek
[0];
85 ctrlpriv
->ctl_kek_wrap
.size
= KEK_KEY_SIZE
* sizeof(u32
);
86 debugfs_create_blob("kek", 0444, ctrlpriv
->ctl
,
87 &ctrlpriv
->ctl_kek_wrap
);
89 ctrlpriv
->ctl_tkek_wrap
.data
= (__force
void *)&ctrlpriv
->ctrl
->tkek
[0];
90 ctrlpriv
->ctl_tkek_wrap
.size
= KEK_KEY_SIZE
* sizeof(u32
);
91 debugfs_create_blob("tkek", 0444, ctrlpriv
->ctl
,
92 &ctrlpriv
->ctl_tkek_wrap
);
94 ctrlpriv
->ctl_tdsk_wrap
.data
= (__force
void *)&ctrlpriv
->ctrl
->tdsk
[0];
95 ctrlpriv
->ctl_tdsk_wrap
.size
= KEK_KEY_SIZE
* sizeof(u32
);
96 debugfs_create_blob("tdsk", 0444, ctrlpriv
->ctl
,
97 &ctrlpriv
->ctl_tdsk_wrap
);