Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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