Hi ZhiGang,
Thanks for your patch. I post it inline, and have some comments bellow.
On 2021/2/23 22:15, Xie XiuQi wrote:
From: Li ZhiGang lizhigang@kylinos.cn
Nationz Tech TCM are used for trusted computing, the chip attached via SPI or LPC. We have a brief verify/test with this driver on KunPeng920 + openEuler system, with externally compiled module.
About this tcm, do you have any public document for reference. If so, you can give a public link here.
Signed-off-by: Li ZhiGang lizhigang@kylinos.cn
drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 2 + drivers/staging/gmjstcm/Kconfig | 21 + drivers/staging/gmjstcm/Makefile | 5 + drivers/staging/gmjstcm/tcm.c | 949 ++++++++++++++++++++++++++ drivers/staging/gmjstcm/tcm.h | 123 ++++ drivers/staging/gmjstcm/tcm_tis_spi.c | 868 +++++++++++++++++++++++ 7 files changed, 1970 insertions(+) create mode 100644 drivers/staging/gmjstcm/Kconfig create mode 100644 drivers/staging/gmjstcm/Makefile create mode 100644 drivers/staging/gmjstcm/tcm.c create mode 100644 drivers/staging/gmjstcm/tcm.h create mode 100644 drivers/staging/gmjstcm/tcm_tis_spi.c
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 1abf76be2aa8..d51fa4f4e7ca 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -126,4 +126,6 @@ source "drivers/staging/axis-fifo/Kconfig"
source "drivers/staging/erofs/Kconfig"
+source "drivers/staging/gmjstcm/Kconfig"
endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
...
diff --git a/drivers/staging/gmjstcm/tcm_tis_spi.c b/drivers/staging/gmjstcm/tcm_tis_spi.c new file mode 100644 index 000000000000..db30a5b4c47d --- /dev/null +++ b/drivers/staging/gmjstcm/tcm_tis_spi.c @@ -0,0 +1,868 @@ +// SPDX-License-Identifier: GPL-2.0 +/*
- Copyright (C) 2020 Kylin Tech. Co., Ltd.
- */
+#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/interrupt.h> +#include <linux/wait.h> +#include <linux/acpi.h> +#include <linux/spi/spi.h>
+#include "tcm.h"
+#if !defined(CONFIG_KYLINOS_SERVER) && !defined(CONFIG_KYLINOS_DESKTOP) +static int is_ft_all(void) {
- return 0;
+} +#endif
We do not have this CONFIG_ in openEuler, is it better to use a cmdline option instead? Or add a more meaningful CONFIG_ in Kconfig.
+#define TCM_HEADER_SIZE 10
+static bool tcm_debug; +module_param_named(debug, tcm_debug, bool, 0600); +MODULE_PARM_DESC(debug, "Turn TCM debugging mode on and off");
+#define tcm_dbg(fmt, args...) \ +{ \
- if (tcm_debug) \
pr_err(fmt, ## args); \
+}
...
+static struct spi_driver tcm_tis_spi_drv = {
- .driver = {
.name = "tcm_tis_spi",
.acpi_match_table = ACPI_PTR(tcm_tis_spi_acpi_match),
- },
- .id_table = tcm_tis_spi_id_table,
- .probe = tcm_tis_spi_probe,
- .remove = tcm_tis_spi_remove,
+};
+#if 1 +module_spi_driver(tcm_tis_spi_drv); +#else/*0*/
+static int __init __spi_driver_init(void) +{
- pr_info("TCM(ky): __init __func__(ver=%2d)\n",
10);
- return spi_register_driver(&tcm_tis_spi_drv);
+}
+static void __exit __spi_driver_exit(void) +{
- pr_info("TCM(ky): __exit __func__\n");
- spi_unregister_driver(&tcm_tis_spi_drv);
+}
+module_init(__spi_driver_init); +module_exit(__spi_driver_exit); +#endif/*0*/
We'd better juse remove this two function here.
+MODULE_AUTHOR("xiongxinxiongxin@tj.kylinos.cn"); +MODULE_DESCRIPTION("TCM Driver Base Spi"); +MODULE_VERSION("6.1.0.2"); +MODULE_LICENSE("GPL");