126 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * processor_thermal_device.h4 * 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 0x461d13#define PCI_DEVICE_ID_INTEL_ARL_S_THERMAL 0xAD0314#define PCI_DEVICE_ID_INTEL_BDW_THERMAL 0x160315#define PCI_DEVICE_ID_INTEL_BSW_THERMAL 0x22DC16 17#define PCI_DEVICE_ID_INTEL_BXT0_THERMAL 0x0A8C18#define PCI_DEVICE_ID_INTEL_BXT1_THERMAL 0x1A8C19#define PCI_DEVICE_ID_INTEL_BXTX_THERMAL 0x4A8C20#define PCI_DEVICE_ID_INTEL_BXTP_THERMAL 0x5A8C21 22#define PCI_DEVICE_ID_INTEL_CNL_THERMAL 0x5a0323#define PCI_DEVICE_ID_INTEL_CFL_THERMAL 0x3E8324#define PCI_DEVICE_ID_INTEL_GLK_THERMAL 0x318C25#define PCI_DEVICE_ID_INTEL_HSB_THERMAL 0x0A0326#define PCI_DEVICE_ID_INTEL_ICL_THERMAL 0x8a0327#define PCI_DEVICE_ID_INTEL_JSL_THERMAL 0x4E0328#define PCI_DEVICE_ID_INTEL_LNLM_THERMAL 0x641D29#define PCI_DEVICE_ID_INTEL_MTLP_THERMAL 0x7D0330#define PCI_DEVICE_ID_INTEL_RPL_THERMAL 0xA71D31#define PCI_DEVICE_ID_INTEL_SKL_THERMAL 0x190332#define PCI_DEVICE_ID_INTEL_TGL_THERMAL 0x9A0333 34struct power_config {35 u32 index;36 u32 min_uw;37 u32 max_uw;38 u32 tmin_us;39 u32 tmax_us;40 u32 step_uw;41};42 43struct proc_thermal_device {44 struct device *dev;45 struct acpi_device *adev;46 struct power_config power_limits[2];47 struct int34x_thermal_zone *int340x_zone;48 struct intel_soc_dts_sensors *soc_dts;49 u32 mmio_feature_mask;50 void __iomem *mmio_base;51 void *priv_data;52};53 54struct rapl_mmio_regs {55 u64 reg_unit;56 u64 regs[RAPL_DOMAIN_MAX][RAPL_DOMAIN_REG_MAX];57 int limits[RAPL_DOMAIN_MAX];58};59 60#define PROC_THERMAL_FEATURE_NONE 0x0061#define PROC_THERMAL_FEATURE_RAPL 0x0162#define PROC_THERMAL_FEATURE_FIVR 0x0263#define PROC_THERMAL_FEATURE_DVFS 0x0464#define PROC_THERMAL_FEATURE_WT_REQ 0x0865#define PROC_THERMAL_FEATURE_DLVR 0x1066#define PROC_THERMAL_FEATURE_WT_HINT 0x2067#define PROC_THERMAL_FEATURE_POWER_FLOOR 0x4068#define PROC_THERMAL_FEATURE_MSI_SUPPORT 0x8069 70#if IS_ENABLED(CONFIG_PROC_THERMAL_MMIO_RAPL)71int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);72void proc_thermal_rapl_remove(void);73#else74static int __maybe_unused proc_thermal_rapl_add(struct pci_dev *pdev,75 struct proc_thermal_device *proc_priv)76{77 return 0;78}79 80static void __maybe_unused proc_thermal_rapl_remove(void)81{82}83#endif84 85int proc_thermal_rfim_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);86void proc_thermal_rfim_remove(struct pci_dev *pdev);87 88int proc_thermal_wt_req_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);89void proc_thermal_wt_req_remove(struct pci_dev *pdev);90 91#define MBOX_CMD_WORKLOAD_TYPE_READ 0x0E92#define MBOX_CMD_WORKLOAD_TYPE_WRITE 0x0F93 94#define MBOX_DATA_BIT_AC_DC 3095#define MBOX_DATA_BIT_VALID 3196 97#define SOC_WT_RES_INT_STATUS_OFFSET 0x5B1898#define SOC_WT_RES_INT_STATUS_MASK GENMASK_ULL(3, 2)99 100int proc_thermal_read_power_floor_status(struct proc_thermal_device *proc_priv);101int proc_thermal_power_floor_set_state(struct proc_thermal_device *proc_priv, bool enable);102bool proc_thermal_power_floor_get_state(struct proc_thermal_device *proc_priv);103void proc_thermal_power_floor_intr_callback(struct pci_dev *pdev,104 struct proc_thermal_device *proc_priv);105bool proc_thermal_check_power_floor_intr(struct proc_thermal_device *proc_priv);106 107int processor_thermal_send_mbox_read_cmd(struct pci_dev *pdev, u16 id, u64 *resp);108int processor_thermal_send_mbox_write_cmd(struct pci_dev *pdev, u16 id, u32 data);109int processor_thermal_mbox_interrupt_config(struct pci_dev *pdev, bool enable, int enable_bit,110 int time_window);111int proc_thermal_add(struct device *dev, struct proc_thermal_device *priv);112void proc_thermal_remove(struct proc_thermal_device *proc_priv);113 114int proc_thermal_wt_hint_add(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);115void proc_thermal_wt_hint_remove(struct pci_dev *pdev);116void proc_thermal_wt_intr_callback(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);117bool proc_thermal_check_wt_intr(struct proc_thermal_device *proc_priv);118 119int proc_thermal_suspend(struct device *dev);120int proc_thermal_resume(struct device *dev);121int proc_thermal_mmio_add(struct pci_dev *pdev,122 struct proc_thermal_device *proc_priv,123 kernel_ulong_t feature_mask);124void proc_thermal_mmio_remove(struct pci_dev *pdev, struct proc_thermal_device *proc_priv);125#endif126