amd_sfh_common.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * AMD MP2 common macros and structures
  4. *
  5. * Copyright (c) 2022, Advanced Micro Devices, Inc.
  6. * All Rights Reserved.
  7. *
  8. * Author: Basavaraj Natikar <[email protected]>
  9. */
  10. #ifndef AMD_SFH_COMMON_H
  11. #define AMD_SFH_COMMON_H
  12. #include <linux/pci.h>
  13. #include "amd_sfh_hid.h"
  14. #define PCI_DEVICE_ID_AMD_MP2 0x15E4
  15. #define PCI_DEVICE_ID_AMD_MP2_1_1 0x164A
  16. #define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4))
  17. #define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4))
  18. #define SENSOR_ENABLED 4
  19. #define SENSOR_DISABLED 5
  20. #define AMD_SFH_IDLE_LOOP 200
  21. enum cmd_id {
  22. NO_OP,
  23. ENABLE_SENSOR,
  24. DISABLE_SENSOR,
  25. STOP_ALL_SENSORS = 8,
  26. };
  27. struct amd_mp2_sensor_info {
  28. u8 sensor_idx;
  29. u32 period;
  30. dma_addr_t dma_address;
  31. };
  32. struct amd_mp2_dev {
  33. struct pci_dev *pdev;
  34. struct amdtp_cl_data *cl_data;
  35. void __iomem *mmio;
  36. void __iomem *vsbase;
  37. const struct amd_sfh1_1_ops *sfh1_1_ops;
  38. struct amd_mp2_ops *mp2_ops;
  39. struct amd_input_data in_data;
  40. /* mp2 active control status */
  41. u32 mp2_acs;
  42. };
  43. struct amd_mp2_ops {
  44. void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
  45. void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx);
  46. void (*stop_all)(struct amd_mp2_dev *privdata);
  47. int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
  48. void (*clear_intr)(struct amd_mp2_dev *privdata);
  49. int (*init_intr)(struct amd_mp2_dev *privdata);
  50. int (*discovery_status)(struct amd_mp2_dev *privdata);
  51. void (*suspend)(struct amd_mp2_dev *mp2);
  52. void (*resume)(struct amd_mp2_dev *mp2);
  53. void (*remove)(void *privdata);
  54. int (*get_rep_desc)(int sensor_idx, u8 rep_desc[]);
  55. u32 (*get_desc_sz)(int sensor_idx, int descriptor_name);
  56. u8 (*get_feat_rep)(int sensor_idx, int report_id, u8 *feature_report);
  57. u8 (*get_in_rep)(u8 current_index, int sensor_idx, int report_id,
  58. struct amd_input_data *in_data);
  59. };
  60. void amd_sfh_work(struct work_struct *work);
  61. void amd_sfh_work_buffer(struct work_struct *work);
  62. void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata);
  63. int amd_sfh_irq_init_v2(struct amd_mp2_dev *privdata);
  64. void amd_sfh_clear_intr(struct amd_mp2_dev *privdata);
  65. int amd_sfh_irq_init(struct amd_mp2_dev *privdata);
  66. #endif