Lines Matching +full:temp +full:- +full:sensor

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * k8temp.c - Linux kernel module for hardware monitoring
19 #define TEMP_FROM_REG(val) (((((val) >> 16) & 0xff) - 49) * 1000)
28 u8 sensorsp; /* sensor presence bits - SEL_CORE, SEL_PLACE */
76 if ((channel & 1) && !(data->sensorsp & SEL_PLACE)) in k8temp_is_visible()
79 if ((channel & 2) && !(data->sensorsp & SEL_CORE)) in k8temp_is_visible()
90 struct pci_dev *pdev = to_pci_dev(dev->parent); in k8temp_read()
92 u32 temp; in k8temp_read() local
98 core ^= data->swap_core_select; in k8temp_read()
100 mutex_lock(&data->update_lock); in k8temp_read()
108 pci_read_config_dword(pdev, REG_TEMP, &temp); in k8temp_read()
109 mutex_unlock(&data->update_lock); in k8temp_read()
111 *val = TEMP_FROM_REG(temp) + data->temp_offset; in k8temp_read()
122 HWMON_CHANNEL_INFO(temp,
136 u32 temp; in k8temp_probe() local
141 data = devm_kzalloc(&pdev->dev, sizeof(struct k8temp_data), GFP_KERNEL); in k8temp_probe()
143 return -ENOMEM; in k8temp_probe()
148 /* feature available since SH-C0, exclude older revisions */ in k8temp_probe()
151 return -ENODEV; in k8temp_probe()
158 data->swap_core_select = 1; in k8temp_probe()
159 dev_warn(&pdev->dev, in k8temp_probe()
160 "Temperature readouts might be wrong - check erratum #141\n"); in k8temp_probe()
169 data->temp_offset = 21000; in k8temp_probe()
172 scfg &= ~(SEL_PLACE | SEL_CORE); /* Select sensor 0, core0 */ in k8temp_probe()
177 dev_err(&pdev->dev, "Configuration bit(s) stuck at 1!\n"); in k8temp_probe()
178 return -ENODEV; in k8temp_probe()
184 /* now we know if we can change core and/or sensor */ in k8temp_probe()
185 pci_read_config_byte(pdev, REG_TEMP, &data->sensorsp); in k8temp_probe()
187 if (data->sensorsp & SEL_PLACE) { in k8temp_probe()
188 scfg &= ~SEL_CORE; /* Select sensor 1, core0 */ in k8temp_probe()
190 pci_read_config_dword(pdev, REG_TEMP, &temp); in k8temp_probe()
192 if (!((temp >> 16) & 0xff)) /* if temp is 0 -49C is unlikely */ in k8temp_probe()
193 data->sensorsp &= ~SEL_PLACE; in k8temp_probe()
196 if (data->sensorsp & SEL_CORE) { in k8temp_probe()
197 scfg &= ~SEL_PLACE; /* Select sensor 0, core1 */ in k8temp_probe()
199 pci_read_config_dword(pdev, REG_TEMP, &temp); in k8temp_probe()
200 if (!((temp >> 16) & 0xff)) /* if temp is 0 -49C is unlikely */ in k8temp_probe()
201 data->sensorsp &= ~SEL_CORE; in k8temp_probe()
204 mutex_init(&data->update_lock); in k8temp_probe()
206 hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, in k8temp_probe()