thermal/drivers/int340x: processor_thermal: Export mailbox interface
[linux-2.6-microblaze.git] / drivers / thermal / intel / int340x_thermal / processor_thermal_device.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * processor_thermal_device.h
4  * Copyright (c) 2020, Intel Corporation.
5  */
6
7 #ifndef __PROCESSOR_THERMAL_DEVICE_H__
8 #define __PROCESSOR_THERMAL_DEVICE_H__
9
10 #include <linux/intel_rapl.h>
11
12 #define PCI_DEVICE_ID_INTEL_ADL_THERMAL 0x461d
13 #define PCI_DEVICE_ID_INTEL_BDW_THERMAL 0x1603
14 #define PCI_DEVICE_ID_INTEL_BSW_THERMAL 0x22DC
15
16 #define PCI_DEVICE_ID_INTEL_BXT0_THERMAL        0x0A8C
17 #define PCI_DEVICE_ID_INTEL_BXT1_THERMAL        0x1A8C
18 #define PCI_DEVICE_ID_INTEL_BXTX_THERMAL        0x4A8C
19 #define PCI_DEVICE_ID_INTEL_BXTP_THERMAL        0x5A8C
20
21 #define PCI_DEVICE_ID_INTEL_CNL_THERMAL 0x5a03
22 #define PCI_DEVICE_ID_INTEL_CFL_THERMAL 0x3E83
23 #define PCI_DEVICE_ID_INTEL_GLK_THERMAL 0x318C
24 #define PCI_DEVICE_ID_INTEL_HSB_THERMAL 0x0A03
25 #define PCI_DEVICE_ID_INTEL_ICL_THERMAL 0x8a03
26 #define PCI_DEVICE_ID_INTEL_JSL_THERMAL 0x4E03
27 #define PCI_DEVICE_ID_INTEL_SKL_THERMAL 0x1903
28 #define PCI_DEVICE_ID_INTEL_TGL_THERMAL 0x9A03
29
30 struct power_config {
31         u32     index;
32         u32     min_uw;
33         u32     max_uw;
34         u32     tmin_us;
35         u32     tmax_us;
36         u32     step_uw;
37 };
38
39 struct proc_thermal_device {
40         struct device *dev;
41         struct acpi_device *adev;
42         struct power_config power_limits[2];
43         struct int34x_thermal_zone *int340x_zone;
44         struct intel_soc_dts_sensors *soc_dts;
45         u32 mmio_feature_mask;
46         void __iomem *mmio_base;
47 };
48
49 struct rapl_mmio_regs {
50         u64 reg_unit;
51         u64 regs[RAPL_DOMAIN_MAX][RAPL_DOMAIN_REG_MAX];
52         int limits[RAPL_DOMAIN_MAX];
53 };
54
55 #define PROC_THERMAL_FEATURE_NONE       0x00
56 #define PROC_THERMAL_FEATURE_RAPL       0x01
57 #define PROC_THERMAL_FEATURE_FIVR       0x02
58 #define PROC_THERMAL_FEATURE_DVFS       0x04
59 #define PROC_THERMAL_FEATURE_MBOX       0x08
60
61 #if IS_ENABLED(CONFIG_PROC_THERMAL_MMIO_RAPL)
62 int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
63 void proc_thermal_rapl_remove(void);
64 #else
65 static int __maybe_unused proc_thermal_rapl_add(struct pci_dev *pdev,
66                                                 struct proc_thermal_device *proc_priv)
67 {
68         return 0;
69 }
70
71 static void __maybe_unused proc_thermal_rapl_remove(void)
72 {
73 }
74 #endif
75
76 int proc_thermal_rfim_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
77 void proc_thermal_rfim_remove(struct pci_dev *pdev);
78
79 int proc_thermal_mbox_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);
80 void proc_thermal_mbox_remove(struct pci_dev *pdev);
81
82 int processor_thermal_send_mbox_cmd(struct pci_dev *pdev, u16 cmd_id, u32 cmd_data, u32 *cmd_resp);
83
84 #endif