Unverified Commit d6056771 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12496 LoongArch: add loongson SE support

Merge Pull Request from: @ci-robot 
 
PR sync from: Hongchen Zhang <zhanghongchen@loongson.cn>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/7DNSFXFTCXP333OKQI7YWFEYNR4AI47F/ 
Hongchen Zhang (1):
  dt-bindings: security: add loongson_se

Zhao Qunqin (1):
  LoongArch: add loongson SE SDF support


-- 
2.33.0
 
https://gitee.com/openeuler/kernel/issues/IAZ3GN 
 
Link:https://gitee.com/openeuler/kernel/pulls/12496

 

Reviewed-by: default avatarJuxin Gao <gaojuxin@loongson.cn>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 8c7b5784 bcb31192
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/security/loongson_se/se.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Loongson SE module

description:
  Loongson SE module
maintainers:
  - Qunqin Zhao <zhaoqunqin@loongson.cn>

allOf:
  - $ref: se.yaml#

properties:
  compatible:
    const: loongson,ls3c6000se

  reg:
    maxItems: 2

  interrupts:
    maxItems: 2

required:
  - compatible
  - reg
  - interrupts

additionalProperties: false
+8 −0
Original line number Diff line number Diff line
@@ -12463,6 +12463,14 @@ S: Maintained
F:	Documentation/devicetree/bindings/pinctrl/loongson,ls2k-pinctrl.yaml
F:	drivers/pinctrl/pinctrl-loongson2.c
LOONGSON SE DRIVER
M:	Qunqin Zhao <zhaoqunqin@loongson.cn>
S:	Maintained
F:	Documentation/devicetree/bindings/security/loongson_se/se.yaml
F:	arch/loongarch/include/asm/se.h
F:	drivers/char/loongson_se.c
F:	drivers/char/lsse_sdf_cdev.c
LOONGSON-2 SOC SERIES THERMAL DRIVER
M:	zhanghongchen <zhanghongchen@loongson.cn>
M:	Yinbo Zhu <zhuyinbo@loongson.cn>
+147 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2012 IBM Corporation
 *
 * Copyright 2023 Loongson Technology, Inc.
 * Yinggang Gu <guyinggang@loongson.cn>
 *
 * Device driver for Loongson SE module.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, version 2 of the
 * License.
 *
 */
#ifndef __LOONGSON_SE_H__
#define __LOONGSON_SE_H__

#define SE_MAILBOX_S			0x0
#define SE_MAILBOX_L			0x20
#define SE_S2LINT_STAT			0x88
#define SE_S2LINT_EN			0x8c
#define SE_S2LINT_SET			0x90
#define SE_S2LINT_CL			0x94
#define SE_L2SINT_STAT			0x98
#define SE_L2SINT_EN			0x9c
#define SE_L2SINT_SET			0xa0
#define SE_L2SINT_CL			0xa4

/* INT bit definition */
#define SE_INT_SETUP			BIT(0)
#define SE_INT_SM2				BIT(0)
#define SE_INT_SM3				BIT(0)
#define SE_INT_SM4				BIT(0)
#define SE_INT_RNG				BIT(0)
#define SE_INT_TPM				BIT(5)
#define SE_INT_ALL				0xffffffff

#define SE_CMD_START			0x0
#define SE_CMD_STOP				0x1
#define SE_CMD_GETVER			0x2
#define SE_CMD_SETBUF			0x3
#define SE_CMD_SETMSG			0x4

#define SE_CMD_RNG				0x100

#define SE_CMD_SM2_SIGN			0x200
#define SE_CMD_SM2_VSIGN		0x201

#define SE_CMD_SM3_DIGEST		0x300
#define SE_CMD_SM3_UPDATE		0x301
#define SE_CMD_SM3_FINISH		0x302

#define SE_CMD_SM4_ECB_ENCRY		0x400
#define SE_CMD_SM4_ECB_DECRY		0x401
#define SE_CMD_SM4_CBC_ENCRY		0x402
#define SE_CMD_SM4_CBC_DECRY		0x403
#define SE_CMD_SM4_CTR			0x404

#define SE_CMD_TPM				0x500
#define SE_CMD_ZUC_INIT_READ		0x600
#define SE_CMD_ZUC_READ			0x601

#define SE_CMD_SDF				0x700

#define SE_CH_MAX			32

#define SE_CH_RNG			1
#define SE_CH_SM2			2
#define SE_CH_SM3			3
#define SE_CH_SM4			4
#define SE_CH_TPM			5
#define SE_CH_ZUC			6
#define SE_CH_SDF			7

struct se_msg {
	u32 cmd;
	u32 data_off;
	u32 data_len;
	u32 info[5];
};

struct se_cmd {
	u32 cmd;
	u32 info[7];
};

struct se_res {
	u32 cmd;
	u32 cmd_ret;
	u32 info[6];
};

struct se_mailbox_data {
	u32 int_bit;
	union {
		u32 mailbox[8];
		struct se_cmd gcmd;
		struct se_res res;
	} u;
};

struct lsse_ch {
	u32 id;
	u32 int_bit;
	struct loongson_se *se;
	void *priv;
	spinlock_t ch_lock;
	void *smsg;
	void *rmsg;
	int msg_size;
	void *data_buffer;
	dma_addr_t data_addr;
	int data_size;

	void (*complete)(struct lsse_ch *se_ch);
};

struct loongson_se {
	struct device *dev;
	void __iomem *base;
	u32 version;
	u32 ch_status;
	spinlock_t cmd_lock;
	spinlock_t dev_lock;

	/* Interaction memory */
	void *mem_base;
	dma_addr_t mem_addr;
	unsigned long *mem_map;
	int mem_map_size;
	void *smsg;
	void *rmsg;

	/* Synchronous CMD */
	struct completion cmd_completion;

	/* Virtual Channel */
	struct lsse_ch chs[SE_CH_MAX];
};

struct lsse_ch *se_init_ch(int id, int data_size, int msg_size, void *priv,
		void (*complete)(struct lsse_ch *se_ch));
void se_deinit_ch(struct lsse_ch *ch);
int se_send_ch_requeset(struct lsse_ch *ch);

#endif
+20 −0
Original line number Diff line number Diff line
@@ -391,6 +391,26 @@ config UV_MMTIMER
	  The uv_mmtimer device allows direct userspace access to the
	  UV system timer.

config LOONGSON_SE
	tristate "LOONGSON SECURITY MODULE Interface"
	depends on LOONGARCH
	default m
	help
	  If you have LOONGSON security module (SE) support say Yes and it
	  will be accessible from within Linux.
          To compile this driver as a module, choose M here,the module will
          be called loongson-se.

config LOONGSON_SE_SDF
	tristate "LOONGSON SECURITY MODULE SDF Interface"
	depends on LOONGARCH && LOONGSON_SE
	default m
	help
	  If you want to use LOONGSON security module (SE) as SDF say Yes
	  and it will be accessible from within Linux.
          To compile this driver as a module, choose M here,the module will
          be called loongson-se.

source "drivers/char/tpm/Kconfig"

config TELCLOCK
+2 −0
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
obj-$(CONFIG_PC8736x_GPIO)	+= pc8736x_gpio.o
obj-$(CONFIG_NSC_GPIO)		+= nsc_gpio.o
obj-$(CONFIG_TELCLOCK)		+= tlclk.o
obj-$(CONFIG_LOONGSON_SE)	+= loongson_se.o
obj-$(CONFIG_LOONGSON_SE_SDF)	+= lsse_sdf_cdev.o

obj-$(CONFIG_MWAVE)		+= mwave/
obj-y				+= agp/
Loading