Skip to content

Commit 00c5ff5

Browse files
spandruvadarafaeljw
authored andcommitted
thermal: intel: int340x: Fix Panther Lake DLVR support
Panther Lake uses the same DLVR register offsets as Lunar Lake, but the driver uses the default register offsets table for it by mistake. Move the selection of register offsets table from the actual attribute read/write callbacks to proc_thermal_rfim_add() and make it handle Panther Lake the same way as Lunar Lake. This way it is clean and in the future such issues can be avoided. Fixes: e50eeab ("thermal: intel: int340x: Panther Lake DLVR support") Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Link: https://patch.msgid.link/20250411115438.594114-1-srinivas.pandruvada@linux.intel.com [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 5ddcc65 commit 00c5ff5

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

drivers/thermal/intel/int340x_thermal/processor_thermal_rfim.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,18 @@ static const struct mmio_reg adl_dvfs_mmio_regs[] = {
166166
{ 0, 0x5A40, 1, 0x1, 0}, /* rfi_disable */
167167
};
168168

169+
static const struct mapping_table *dlvr_mapping;
170+
static const struct mmio_reg *dlvr_mmio_regs_table;
171+
169172
#define RFIM_SHOW(suffix, table)\
170173
static ssize_t suffix##_show(struct device *dev,\
171174
struct device_attribute *attr,\
172175
char *buf)\
173176
{\
174-
const struct mapping_table *mapping = NULL;\
177+
const struct mmio_reg *mmio_regs = dlvr_mmio_regs_table;\
178+
const struct mapping_table *mapping = dlvr_mapping;\
175179
struct proc_thermal_device *proc_priv;\
176180
struct pci_dev *pdev = to_pci_dev(dev);\
177-
const struct mmio_reg *mmio_regs;\
178181
const char **match_strs;\
179182
int ret, err;\
180183
u32 reg_val;\
@@ -186,12 +189,6 @@ static ssize_t suffix##_show(struct device *dev,\
186189
mmio_regs = adl_dvfs_mmio_regs;\
187190
} else if (table == 2) { \
188191
match_strs = (const char **)dlvr_strings;\
189-
if (pdev->device == PCI_DEVICE_ID_INTEL_LNLM_THERMAL) {\
190-
mmio_regs = lnl_dlvr_mmio_regs;\
191-
mapping = lnl_dlvr_mapping;\
192-
} else {\
193-
mmio_regs = dlvr_mmio_regs;\
194-
} \
195192
} else {\
196193
match_strs = (const char **)fivr_strings;\
197194
mmio_regs = tgl_fivr_mmio_regs;\
@@ -214,12 +211,12 @@ static ssize_t suffix##_store(struct device *dev,\
214211
struct device_attribute *attr,\
215212
const char *buf, size_t count)\
216213
{\
217-
const struct mapping_table *mapping = NULL;\
214+
const struct mmio_reg *mmio_regs = dlvr_mmio_regs_table;\
215+
const struct mapping_table *mapping = dlvr_mapping;\
218216
struct proc_thermal_device *proc_priv;\
219217
struct pci_dev *pdev = to_pci_dev(dev);\
220218
unsigned int input;\
221219
const char **match_strs;\
222-
const struct mmio_reg *mmio_regs;\
223220
int ret, err;\
224221
u32 reg_val;\
225222
u32 mask;\
@@ -230,12 +227,6 @@ static ssize_t suffix##_store(struct device *dev,\
230227
mmio_regs = adl_dvfs_mmio_regs;\
231228
} else if (table == 2) { \
232229
match_strs = (const char **)dlvr_strings;\
233-
if (pdev->device == PCI_DEVICE_ID_INTEL_LNLM_THERMAL) {\
234-
mmio_regs = lnl_dlvr_mmio_regs;\
235-
mapping = lnl_dlvr_mapping;\
236-
} else {\
237-
mmio_regs = dlvr_mmio_regs;\
238-
} \
239230
} else {\
240231
match_strs = (const char **)fivr_strings;\
241232
mmio_regs = tgl_fivr_mmio_regs;\
@@ -448,6 +439,16 @@ int proc_thermal_rfim_add(struct pci_dev *pdev, struct proc_thermal_device *proc
448439
}
449440

450441
if (proc_priv->mmio_feature_mask & PROC_THERMAL_FEATURE_DLVR) {
442+
switch (pdev->device) {
443+
case PCI_DEVICE_ID_INTEL_LNLM_THERMAL:
444+
case PCI_DEVICE_ID_INTEL_PTL_THERMAL:
445+
dlvr_mmio_regs_table = lnl_dlvr_mmio_regs;
446+
dlvr_mapping = lnl_dlvr_mapping;
447+
break;
448+
default:
449+
dlvr_mmio_regs_table = dlvr_mmio_regs;
450+
break;
451+
}
451452
ret = sysfs_create_group(&pdev->dev.kobj, &dlvr_attribute_group);
452453
if (ret)
453454
return ret;

0 commit comments

Comments
 (0)