amd_sfh_pcie.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * AMD MP2 PCIe communication driver
  4. * Copyright 2020-2021 Advanced Micro Devices, Inc.
  5. * Authors: Shyam Sundar S K <[email protected]>
  6. * Sandeep Singh <[email protected]>
  7. * Basavaraj Natikar <[email protected]>
  8. */
  9. #ifndef PCIE_MP2_AMD_H
  10. #define PCIE_MP2_AMD_H
  11. #include "amd_sfh_common.h"
  12. /* MP2 C2P Message Registers */
  13. #define AMD_C2P_MSG0 0x10500
  14. #define AMD_C2P_MSG1 0x10504
  15. #define AMD_C2P_MSG2 0x10508
  16. /* MP2 P2C Message Registers */
  17. #define AMD_P2C_MSG3 0x1068C /* Supported Sensors info */
  18. #define V2_STATUS 0x2
  19. #define HPD_IDX 16
  20. #define SENSOR_DISCOVERY_STATUS_MASK GENMASK(5, 3)
  21. #define SENSOR_DISCOVERY_STATUS_SHIFT 3
  22. /* SFH Command register */
  23. union sfh_cmd_base {
  24. u32 ul;
  25. struct {
  26. u32 cmd_id : 8;
  27. u32 sensor_id : 8;
  28. u32 period : 16;
  29. } s;
  30. struct {
  31. u32 cmd_id : 4;
  32. u32 intr_disable : 1;
  33. u32 rsvd1 : 3;
  34. u32 length : 7;
  35. u32 mem_type : 1;
  36. u32 sensor_id : 8;
  37. u32 period : 8;
  38. } cmd_v2;
  39. };
  40. union cmd_response {
  41. u32 resp;
  42. struct {
  43. u32 status : 2;
  44. u32 out_in_c2p : 1;
  45. u32 rsvd1 : 1;
  46. u32 response : 4;
  47. u32 sub_cmd : 8;
  48. u32 sensor_id : 6;
  49. u32 rsvd2 : 10;
  50. } response_v2;
  51. };
  52. union sfh_cmd_param {
  53. u32 ul;
  54. struct {
  55. u32 buf_layout : 2;
  56. u32 buf_length : 6;
  57. u32 rsvd : 24;
  58. } s;
  59. };
  60. struct sfh_cmd_reg {
  61. union sfh_cmd_base cmd_base;
  62. union sfh_cmd_param cmd_param;
  63. phys_addr_t phys_addr;
  64. };
  65. enum sensor_idx {
  66. accel_idx = 0,
  67. gyro_idx = 1,
  68. mag_idx = 2,
  69. als_idx = 19
  70. };
  71. enum mem_use_type {
  72. USE_DRAM,
  73. USE_C2P_REG,
  74. };
  75. struct hpd_status {
  76. union {
  77. struct {
  78. u32 human_presence_report : 4;
  79. u32 human_presence_actual : 4;
  80. u32 probablity : 8;
  81. u32 object_distance : 16;
  82. } shpd;
  83. u32 val;
  84. };
  85. };
  86. int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id);
  87. int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata);
  88. int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata);
  89. void amd_sfh_set_desc_ops(struct amd_mp2_ops *mp2_ops);
  90. #endif