psp-dev.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #ifndef __PSP_DEV_H__
  13. #define __PSP_DEV_H__
  14. #include <linux/device.h>
  15. #include <linux/pci.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/mutex.h>
  18. #include <linux/list.h>
  19. #include <linux/wait.h>
  20. #include <linux/dmapool.h>
  21. #include <linux/hw_random.h>
  22. #include <linux/bitops.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irqreturn.h>
  25. #include <linux/dmaengine.h>
  26. #include <linux/psp-sev.h>
  27. #include <linux/miscdevice.h>
  28. #include "sp-dev.h"
  29. #define PSP_C2PMSG(_num) ((_num) << 2)
  30. #define PSP_CMDRESP PSP_C2PMSG(32)
  31. #define PSP_CMDBUFF_ADDR_LO PSP_C2PMSG(56)
  32. #define PSP_CMDBUFF_ADDR_HI PSP_C2PMSG(57)
  33. #define PSP_FEATURE_REG PSP_C2PMSG(63)
  34. #define PSP_P2CMSG(_num) ((_num) << 2)
  35. #define PSP_CMD_COMPLETE_REG 1
  36. #define PSP_CMD_COMPLETE PSP_P2CMSG(PSP_CMD_COMPLETE_REG)
  37. #define PSP_P2CMSG_INTEN 0x0110
  38. #define PSP_P2CMSG_INTSTS 0x0114
  39. #define PSP_C2PMSG_ATTR_0 0x0118
  40. #define PSP_C2PMSG_ATTR_1 0x011c
  41. #define PSP_C2PMSG_ATTR_2 0x0120
  42. #define PSP_C2PMSG_ATTR_3 0x0124
  43. #define PSP_P2CMSG_ATTR_0 0x0128
  44. #define PSP_CMDRESP_CMD_SHIFT 16
  45. #define PSP_CMDRESP_IOC BIT(0)
  46. #define PSP_CMDRESP_RESP BIT(31)
  47. #define PSP_CMDRESP_ERR_MASK 0xffff
  48. #define MAX_PSP_NAME_LEN 16
  49. struct sev_misc_dev {
  50. struct kref refcount;
  51. struct miscdevice misc;
  52. };
  53. struct psp_device {
  54. struct list_head entry;
  55. struct psp_vdata *vdata;
  56. char name[MAX_PSP_NAME_LEN];
  57. struct device *dev;
  58. struct sp_device *sp;
  59. void __iomem *io_regs;
  60. int sev_state;
  61. unsigned int sev_int_rcvd;
  62. wait_queue_head_t sev_int_queue;
  63. struct sev_misc_dev *sev_misc;
  64. struct sev_user_data_status status_cmd_buf;
  65. struct sev_data_init init_cmd_buf;
  66. u8 api_major;
  67. u8 api_minor;
  68. u8 build;
  69. };
  70. #endif /* __PSP_DEV_H */