Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3ec9a67 authored by Gilad Ben-Yossef's avatar Gilad Ben-Yossef Committed by Greg Kroah-Hartman
Browse files

staging: ccree: staging: ccree: replace sysfs by debugfs interface



The ccree driver has had a none standard sysfs interface for debugging.
Replace it with a proper debugfs interface.

Signed-off-by: default avatarGilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 31aeaca4
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
obj-$(CONFIG_CRYPTO_DEV_CCREE) := ccree.o
ccree-y := ssi_driver.o ssi_sysfs.o ssi_buffer_mgr.o ssi_request_mgr.o ssi_cipher.o ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ssi_pm.o
ccree-y := ssi_driver.o ssi_buffer_mgr.o ssi_request_mgr.o ssi_cipher.o ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ssi_pm.o
ccree-$(CONFIG_CRYPTO_FIPS) += ssi_fips.o
ccree-$(CONFIG_DEBUG_FS) += cc_debugfs.o
+114 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012-2017 ARM Limited or its affiliates.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#include <linux/kernel.h>
#include <linux/debugfs.h>
#include <linux/stringify.h>
#include "ssi_config.h"
#include "ssi_driver.h"
#include "cc_crypto_ctx.h"

struct cc_debugfs_ctx {
	struct dentry *dir;
};

#define CC_DEBUG_REG(_X) {	\
	.name = __stringify(_X),\
	.offset = CC_REG(_X)	\
	}

/*
 * This is a global var for the dentry of the
 * debugfs ccree/ dir. It is not tied down to
 * a specific instance of ccree, hence it is
 * global.
 */
static struct dentry *cc_debugfs_dir;

struct debugfs_reg32 debug_regs[] = {
	CC_DEBUG_REG(HOST_SIGNATURE),
	CC_DEBUG_REG(HOST_IRR),
	CC_DEBUG_REG(HOST_POWER_DOWN_EN),
	CC_DEBUG_REG(AXIM_MON_ERR),
	CC_DEBUG_REG(DSCRPTR_QUEUE_CONTENT),
	CC_DEBUG_REG(HOST_IMR),
	CC_DEBUG_REG(AXIM_CFG),
	CC_DEBUG_REG(AXIM_CACHE_PARAMS),
	CC_DEBUG_REG(HOST_VERSION),
	CC_DEBUG_REG(GPR_HOST),
	CC_DEBUG_REG(AXIM_MON_COMP),
};

int cc_debugfs_global_init(void)
{
	cc_debugfs_dir = debugfs_create_dir("ccree", NULL);

	return !cc_debugfs_dir;
}

void cc_debugfs_global_fini(void)
{
	debugfs_remove(cc_debugfs_dir);
}

int cc_debugfs_init(struct cc_drvdata *drvdata)
{
	struct device *dev = drvdata_to_dev(drvdata);
	struct cc_debugfs_ctx *ctx;
	struct debugfs_regset32 *regset;
	struct dentry *file;

	ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
	if (!ctx)
		return -ENOMEM;

	regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
	if (!regset)
		return -ENOMEM;

	regset->regs = debug_regs;
	regset->nregs = ARRAY_SIZE(debug_regs);
	regset->base = drvdata->cc_base;

	ctx->dir = debugfs_create_dir(drvdata->plat_dev->name, cc_debugfs_dir);
	if (!ctx->dir)
		return -ENFILE;

	file = debugfs_create_regset32("regs", 0400, ctx->dir, regset);
	if (!file) {
		debugfs_remove(ctx->dir);
		return -ENFILE;
	}

	file = debugfs_create_bool("coherent", 0400, ctx->dir,
				   &drvdata->coherent);

	if (!file) {
		debugfs_remove_recursive(ctx->dir);
		return -ENFILE;
	}

	drvdata->debugfs = ctx;

	return 0;
}

void cc_debugfs_fini(struct cc_drvdata *drvdata)
{
	struct cc_debugfs_ctx *ctx = (struct cc_debugfs_ctx *)drvdata->debugfs;

	debugfs_remove_recursive(ctx->dir);
}
+23 −10
Original line number Diff line number Diff line
@@ -14,19 +14,32 @@
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

/* \file ssi_sysfs.h
 * ARM CryptoCell sysfs APIs
 */
#ifndef __CC_DEBUGFS_H__
#define __CC_DEBUGFS_H__

#ifdef CONFIG_DEBUG_FS
int cc_debugfs_global_init(void);
void cc_debugfs_global_fini(void);

int cc_debugfs_init(struct cc_drvdata *drvdata);
void cc_debugfs_fini(struct cc_drvdata *drvdata);

#else

int cc_debugfs_global_init(void)
{
	return 0;
}

#ifndef __CC_SYSFS_H__
#define __CC_SYSFS_H__
void cc_debugfs_global_fini(void) {}

#include <asm/timex.h>
int cc_debugfs_init(struct cc_drvdata *drvdata)
{
	return 0;
}

/* forward declaration */
struct cc_drvdata;
void cc_debugfs_fini(struct cc_drvdata *drvdata) {}

int ssi_sysfs_init(struct kobject *sys_dev_obj, struct cc_drvdata *drvdata);
void ssi_sysfs_fini(void);
#endif

#endif /*__CC_SYSFS_H__*/
+0 −1
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@
#include "ssi_aead.h"
#include "ssi_request_mgr.h"
#include "ssi_hash.h"
#include "ssi_sysfs.h"
#include "ssi_sram_mgr.h"

#define template_aead	template_u.aead
+0 −1
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@
#include "ssi_buffer_mgr.h"
#include "ssi_cipher.h"
#include "ssi_request_mgr.h"
#include "ssi_sysfs.h"

#define MAX_ABLKCIPHER_SEQ_LEN 6

Loading