1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * AMD SoC Power Management Controller Driver 4 * 5 * Copyright (c) 2023, Advanced Micro Devices, Inc. 6 * All Rights Reserved. 7 * 8 * Author: Mario Limonciello <[email protected]> 9 */ 10 11 #ifndef PMC_H 12 #define PMC_H 13 14 #include <linux/types.h> 15 #include <linux/mutex.h> 16 17 enum s2d_msg_port { 18 MSG_PORT_PMC, 19 MSG_PORT_S2D, 20 }; 21 22 struct amd_mp2_dev { 23 void __iomem *mmio; 24 void __iomem *vslbase; 25 void *stbdata; 26 void *devres_gid; 27 struct pci_dev *pdev; 28 dma_addr_t dma_addr; 29 int stb_len; 30 bool is_stb_data; 31 }; 32 33 struct stb_arg { 34 u32 s2d_msg_id; 35 u32 msg; 36 u32 arg; 37 u32 resp; 38 }; 39 40 struct amd_pmc_dev { 41 void __iomem *regbase; 42 void __iomem *smu_virt_addr; 43 void __iomem *stb_virt_addr; 44 void __iomem *fch_virt_addr; 45 u32 base_addr; 46 u32 cpu_id; 47 u32 dram_size; 48 u32 active_ips; 49 const struct amd_pmc_bit_map *ips_ptr; 50 u32 num_ips; 51 u32 smu_msg; 52 /* SMU version information */ 53 u8 smu_program; 54 u8 major; 55 u8 minor; 56 u8 rev; 57 u8 msg_port; 58 struct device *dev; 59 struct pci_dev *rdev; 60 struct mutex lock; /* generic mutex lock */ 61 struct dentry *dbgfs_dir; 62 struct quirk_entry *quirks; 63 bool disable_8042_wakeup; 64 struct amd_mp2_dev *mp2; 65 struct stb_arg stb_arg; 66 }; 67 68 void amd_pmc_process_restore_quirks(struct amd_pmc_dev *dev); 69 void amd_pmc_quirks_init(struct amd_pmc_dev *dev); 70 void amd_mp2_stb_init(struct amd_pmc_dev *dev); 71 void amd_mp2_stb_deinit(struct amd_pmc_dev *dev); 72 73 /* List of supported CPU ids */ 74 #define AMD_CPU_ID_RV 0x15D0 75 #define AMD_CPU_ID_RN 0x1630 76 #define AMD_CPU_ID_PCO AMD_CPU_ID_RV 77 #define AMD_CPU_ID_CZN AMD_CPU_ID_RN 78 #define AMD_CPU_ID_YC 0x14B5 79 #define AMD_CPU_ID_CB 0x14D8 80 #define AMD_CPU_ID_PS 0x14E8 81 #define AMD_CPU_ID_SP 0x14A4 82 #define PCI_DEVICE_ID_AMD_1AH_M20H_ROOT 0x1507 83 #define PCI_DEVICE_ID_AMD_1AH_M60H_ROOT 0x1122 84 #define PCI_DEVICE_ID_AMD_MP2_STB 0x172c 85 86 int amd_stb_s2d_init(struct amd_pmc_dev *dev); 87 int amd_stb_read(struct amd_pmc_dev *dev, u32 *buf); 88 int amd_stb_write(struct amd_pmc_dev *dev, u32 data); 89 int amd_pmc_send_cmd(struct amd_pmc_dev *dev, u32 arg, u32 *data, u8 msg, bool ret); 90 91 #endif /* PMC_H */ 92