.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
---|
2 | | -/* Copyright (C) 2012-2018 ARM Limited or its affiliates. */ |
---|
| 2 | +/* Copyright (C) 2012-2019 ARM Limited or its affiliates. */ |
---|
3 | 3 | |
---|
4 | 4 | #include <linux/kernel.h> |
---|
5 | 5 | #include <linux/debugfs.h> |
---|
.. | .. |
---|
7 | 7 | #include "cc_driver.h" |
---|
8 | 8 | #include "cc_crypto_ctx.h" |
---|
9 | 9 | #include "cc_debugfs.h" |
---|
10 | | - |
---|
11 | | -struct cc_debugfs_ctx { |
---|
12 | | - struct dentry *dir; |
---|
13 | | -}; |
---|
14 | 10 | |
---|
15 | 11 | #define CC_DEBUG_REG(_X) { \ |
---|
16 | 12 | .name = __stringify(_X),\ |
---|
.. | .. |
---|
25 | 21 | */ |
---|
26 | 22 | static struct dentry *cc_debugfs_dir; |
---|
27 | 23 | |
---|
28 | | -static struct debugfs_reg32 debug_regs[] = { |
---|
| 24 | +static struct debugfs_reg32 ver_sig_regs[] = { |
---|
29 | 25 | { .name = "SIGNATURE" }, /* Must be 0th */ |
---|
30 | 26 | { .name = "VERSION" }, /* Must be 1st */ |
---|
| 27 | +}; |
---|
| 28 | + |
---|
| 29 | +static const struct debugfs_reg32 pid_cid_regs[] = { |
---|
| 30 | + CC_DEBUG_REG(PERIPHERAL_ID_0), |
---|
| 31 | + CC_DEBUG_REG(PERIPHERAL_ID_1), |
---|
| 32 | + CC_DEBUG_REG(PERIPHERAL_ID_2), |
---|
| 33 | + CC_DEBUG_REG(PERIPHERAL_ID_3), |
---|
| 34 | + CC_DEBUG_REG(PERIPHERAL_ID_4), |
---|
| 35 | + CC_DEBUG_REG(COMPONENT_ID_0), |
---|
| 36 | + CC_DEBUG_REG(COMPONENT_ID_1), |
---|
| 37 | + CC_DEBUG_REG(COMPONENT_ID_2), |
---|
| 38 | + CC_DEBUG_REG(COMPONENT_ID_3), |
---|
| 39 | +}; |
---|
| 40 | + |
---|
| 41 | +static const struct debugfs_reg32 debug_regs[] = { |
---|
31 | 42 | CC_DEBUG_REG(HOST_IRR), |
---|
32 | 43 | CC_DEBUG_REG(HOST_POWER_DOWN_EN), |
---|
33 | 44 | CC_DEBUG_REG(AXIM_MON_ERR), |
---|
.. | .. |
---|
39 | 50 | CC_DEBUG_REG(AXIM_MON_COMP), |
---|
40 | 51 | }; |
---|
41 | 52 | |
---|
42 | | -int __init cc_debugfs_global_init(void) |
---|
| 53 | +void __init cc_debugfs_global_init(void) |
---|
43 | 54 | { |
---|
44 | 55 | cc_debugfs_dir = debugfs_create_dir("ccree", NULL); |
---|
45 | | - |
---|
46 | | - return !cc_debugfs_dir; |
---|
47 | 56 | } |
---|
48 | 57 | |
---|
49 | | -void __exit cc_debugfs_global_fini(void) |
---|
| 58 | +void cc_debugfs_global_fini(void) |
---|
50 | 59 | { |
---|
51 | 60 | debugfs_remove(cc_debugfs_dir); |
---|
52 | 61 | } |
---|
.. | .. |
---|
54 | 63 | int cc_debugfs_init(struct cc_drvdata *drvdata) |
---|
55 | 64 | { |
---|
56 | 65 | struct device *dev = drvdata_to_dev(drvdata); |
---|
57 | | - struct cc_debugfs_ctx *ctx; |
---|
58 | | - struct debugfs_regset32 *regset; |
---|
59 | | - struct dentry *file; |
---|
60 | | - |
---|
61 | | - debug_regs[0].offset = drvdata->sig_offset; |
---|
62 | | - debug_regs[1].offset = drvdata->ver_offset; |
---|
63 | | - |
---|
64 | | - ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); |
---|
65 | | - if (!ctx) |
---|
66 | | - return -ENOMEM; |
---|
| 66 | + struct debugfs_regset32 *regset, *verset; |
---|
67 | 67 | |
---|
68 | 68 | regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL); |
---|
69 | 69 | if (!regset) |
---|
.. | .. |
---|
72 | 72 | regset->regs = debug_regs; |
---|
73 | 73 | regset->nregs = ARRAY_SIZE(debug_regs); |
---|
74 | 74 | regset->base = drvdata->cc_base; |
---|
| 75 | + regset->dev = dev; |
---|
75 | 76 | |
---|
76 | | - ctx->dir = debugfs_create_dir(drvdata->plat_dev->name, cc_debugfs_dir); |
---|
77 | | - if (!ctx->dir) |
---|
78 | | - return -ENFILE; |
---|
| 77 | + drvdata->dir = debugfs_create_dir(drvdata->plat_dev->name, |
---|
| 78 | + cc_debugfs_dir); |
---|
79 | 79 | |
---|
80 | | - file = debugfs_create_regset32("regs", 0400, ctx->dir, regset); |
---|
81 | | - if (!file) { |
---|
82 | | - debugfs_remove(ctx->dir); |
---|
83 | | - return -ENFILE; |
---|
| 80 | + debugfs_create_regset32("regs", 0400, drvdata->dir, regset); |
---|
| 81 | + debugfs_create_bool("coherent", 0400, drvdata->dir, &drvdata->coherent); |
---|
| 82 | + |
---|
| 83 | + verset = devm_kzalloc(dev, sizeof(*verset), GFP_KERNEL); |
---|
| 84 | + /* Failing here is not important enough to fail the module load */ |
---|
| 85 | + if (!verset) |
---|
| 86 | + return 0; |
---|
| 87 | + |
---|
| 88 | + if (drvdata->hw_rev <= CC_HW_REV_712) { |
---|
| 89 | + ver_sig_regs[0].offset = drvdata->sig_offset; |
---|
| 90 | + ver_sig_regs[1].offset = drvdata->ver_offset; |
---|
| 91 | + verset->regs = ver_sig_regs; |
---|
| 92 | + verset->nregs = ARRAY_SIZE(ver_sig_regs); |
---|
| 93 | + } else { |
---|
| 94 | + verset->regs = pid_cid_regs; |
---|
| 95 | + verset->nregs = ARRAY_SIZE(pid_cid_regs); |
---|
84 | 96 | } |
---|
| 97 | + verset->base = drvdata->cc_base; |
---|
| 98 | + verset->dev = dev; |
---|
85 | 99 | |
---|
86 | | - file = debugfs_create_bool("coherent", 0400, ctx->dir, |
---|
87 | | - &drvdata->coherent); |
---|
88 | | - |
---|
89 | | - if (!file) { |
---|
90 | | - debugfs_remove_recursive(ctx->dir); |
---|
91 | | - return -ENFILE; |
---|
92 | | - } |
---|
93 | | - |
---|
94 | | - drvdata->debugfs = ctx; |
---|
95 | | - |
---|
| 100 | + debugfs_create_regset32("version", 0400, drvdata->dir, verset); |
---|
96 | 101 | return 0; |
---|
97 | 102 | } |
---|
98 | 103 | |
---|
99 | 104 | void cc_debugfs_fini(struct cc_drvdata *drvdata) |
---|
100 | 105 | { |
---|
101 | | - struct cc_debugfs_ctx *ctx = (struct cc_debugfs_ctx *)drvdata->debugfs; |
---|
102 | | - |
---|
103 | | - debugfs_remove_recursive(ctx->dir); |
---|
| 106 | + debugfs_remove_recursive(drvdata->dir); |
---|
104 | 107 | } |
---|