Linux Audio

Check our new training course

Loading...
v6.2
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * AMD Platform Security Processor (PSP) interface driver
 4 *
 5 * Copyright (C) 2017-2019 Advanced Micro Devices, Inc.
 6 *
 7 * Author: Brijesh Singh <brijesh.singh@amd.com>
 
 
 
 
 8 */
 9
10#ifndef __PSP_DEV_H__
11#define __PSP_DEV_H__
12
13#include <linux/device.h>
 
 
 
14#include <linux/list.h>
15#include <linux/bits.h>
 
 
 
16#include <linux/interrupt.h>
 
 
 
 
17
18#include "sp-dev.h"
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20#define PSP_CMDRESP_RESP		BIT(31)
21#define PSP_CMDRESP_ERR_MASK		0xffff
22
23#define MAX_PSP_NAME_LEN		16
24
25extern struct psp_device *psp_master;
26
27typedef void (*psp_irq_handler_t)(int, void *, unsigned int);
 
28
29struct psp_device {
30	struct list_head entry;
31
32	struct psp_vdata *vdata;
33	char name[MAX_PSP_NAME_LEN];
34
35	struct device *dev;
36	struct sp_device *sp;
37
38	void __iomem *io_regs;
39
40	psp_irq_handler_t sev_irq_handler;
41	void *sev_irq_data;
42
43	psp_irq_handler_t tee_irq_handler;
44	void *tee_irq_data;
45
46	void *sev_data;
47	void *tee_data;
48
49	unsigned int capability;
50};
51
52void psp_set_sev_irq_handler(struct psp_device *psp, psp_irq_handler_t handler,
53			     void *data);
54void psp_clear_sev_irq_handler(struct psp_device *psp);
55
56void psp_set_tee_irq_handler(struct psp_device *psp, psp_irq_handler_t handler,
57			     void *data);
58void psp_clear_tee_irq_handler(struct psp_device *psp);
59
60struct psp_device *psp_get_master_device(void);
61
62#define PSP_CAPABILITY_SEV			BIT(0)
63#define PSP_CAPABILITY_TEE			BIT(1)
64#define PSP_CAPABILITY_PSP_SECURITY_REPORTING	BIT(7)
65
66#define PSP_CAPABILITY_PSP_SECURITY_OFFSET	8
67/*
68 * The PSP doesn't directly store these bits in the capability register
69 * but instead copies them from the results of query command.
70 *
71 * The offsets from the query command are below, and shifted when used.
72 */
73#define PSP_SECURITY_FUSED_PART			BIT(0)
74#define PSP_SECURITY_DEBUG_LOCK_ON		BIT(2)
75#define PSP_SECURITY_TSME_STATUS		BIT(5)
76#define PSP_SECURITY_ANTI_ROLLBACK_STATUS	BIT(7)
77#define PSP_SECURITY_RPMC_PRODUCTION_ENABLED	BIT(8)
78#define PSP_SECURITY_RPMC_SPIROM_AVAILABLE	BIT(9)
79#define PSP_SECURITY_HSP_TPM_AVAILABLE		BIT(10)
80#define PSP_SECURITY_ROM_ARMOR_ENFORCED		BIT(11)
81
82#endif /* __PSP_DEV_H */
v4.17
 
 1/*
 2 * AMD Platform Security Processor (PSP) interface driver
 3 *
 4 * Copyright (C) 2017 Advanced Micro Devices, Inc.
 5 *
 6 * Author: Brijesh Singh <brijesh.singh@amd.com>
 7 *
 8 * This program is free software; you can redistribute it and/or modify
 9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __PSP_DEV_H__
14#define __PSP_DEV_H__
15
16#include <linux/device.h>
17#include <linux/pci.h>
18#include <linux/spinlock.h>
19#include <linux/mutex.h>
20#include <linux/list.h>
21#include <linux/wait.h>
22#include <linux/dmapool.h>
23#include <linux/hw_random.h>
24#include <linux/bitops.h>
25#include <linux/interrupt.h>
26#include <linux/irqreturn.h>
27#include <linux/dmaengine.h>
28#include <linux/psp-sev.h>
29#include <linux/miscdevice.h>
30
31#include "sp-dev.h"
32
33#define PSP_C2PMSG(_num)		((_num) << 2)
34#define PSP_CMDRESP			PSP_C2PMSG(32)
35#define PSP_CMDBUFF_ADDR_LO		PSP_C2PMSG(56)
36#define PSP_CMDBUFF_ADDR_HI             PSP_C2PMSG(57)
37#define PSP_FEATURE_REG			PSP_C2PMSG(63)
38
39#define PSP_P2CMSG(_num)		((_num) << 2)
40#define PSP_CMD_COMPLETE_REG		1
41#define PSP_CMD_COMPLETE		PSP_P2CMSG(PSP_CMD_COMPLETE_REG)
42
43#define PSP_P2CMSG_INTEN		0x0110
44#define PSP_P2CMSG_INTSTS		0x0114
45
46#define PSP_C2PMSG_ATTR_0		0x0118
47#define PSP_C2PMSG_ATTR_1		0x011c
48#define PSP_C2PMSG_ATTR_2		0x0120
49#define PSP_C2PMSG_ATTR_3		0x0124
50#define PSP_P2CMSG_ATTR_0		0x0128
51
52#define PSP_CMDRESP_CMD_SHIFT		16
53#define PSP_CMDRESP_IOC			BIT(0)
54#define PSP_CMDRESP_RESP		BIT(31)
55#define PSP_CMDRESP_ERR_MASK		0xffff
56
57#define MAX_PSP_NAME_LEN		16
58
59struct sev_misc_dev {
60	struct kref refcount;
61	struct miscdevice misc;
62};
63
64struct psp_device {
65	struct list_head entry;
66
67	struct psp_vdata *vdata;
68	char name[MAX_PSP_NAME_LEN];
69
70	struct device *dev;
71	struct sp_device *sp;
72
73	void __iomem *io_regs;
74
75	int sev_state;
76	unsigned int sev_int_rcvd;
77	wait_queue_head_t sev_int_queue;
78	struct sev_misc_dev *sev_misc;
79	struct sev_user_data_status status_cmd_buf;
80	struct sev_data_init init_cmd_buf;
 
 
 
 
81};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
83#endif /* __PSP_DEV_H */