#include <linux/acpi.h>
#include <linux/io.h>
#include "compat.h"
-#include "version.h"
+
+#ifndef IT87_DRIVER_VERSION
+#define IT87_DRIVER_VERSION "<not provided>"
+#endif
#define DRVNAME "it87"
#define FEAT_11MV_ADC BIT(24)
#define FEAT_NEW_TEMPMAP BIT(25) /* new temp input selection */
#define FEAT_MMIO BIT(26) /* Chip supports MMIO */
+#define FEAT_FOUR_TEMP BIT(27)
static const struct it87_devices it87_devices[] = {
[it87] = {
.name = "it8622",
.suffix = "E",
.features = FEAT_NEWER_AUTOPWM | FEAT_12MV_ADC | FEAT_16BIT_FANS
- | FEAT_TEMP_PECI | FEAT_FIVE_FANS
+ | FEAT_TEMP_PECI | FEAT_FIVE_FANS | FEAT_FOUR_TEMP
| FEAT_FIVE_PWM | FEAT_IN7_INTERNAL | FEAT_PWM_FREQ2
| FEAT_AVCC3 | FEAT_VIN3_5V | FEAT_SCALING,
.num_temp_limit = 3,
.num_temp_offset = 3,
.num_temp_map = 4,
- .peci_mask = 0x07,
+ .peci_mask = 0x0f,
+ .smbus_bitmap = BIT(1) | BIT(2),
},
[it8625] = {
.name = "it8625",
#define has_11mv_adc(data) ((data)->features & FEAT_11MV_ADC)
#define has_new_tempmap(data) ((data)->features & FEAT_NEW_TEMPMAP)
#define has_mmio(data) ((data)->features & FEAT_MMIO)
+#define has_four_temp(data) ((data)->features & FEAT_FOUR_TEMP)
struct it87_sio_data {
enum chips type;
static int get_temp_type(struct it87_data *data, int index)
{
u8 reg, extra;
- int type = 0;
+ int ttype, type = 0;
if (has_bank_sel(data)) {
u8 src1, src2;
break;
}
src2 = data->temp_src[3];
- switch(src1) {
+ switch (src1) {
case 3:
type = (src2 & BIT(index)) ? 6 : 5;
break;
return 0;
}
}
- if (type || index >= 3)
+ if (type)
return type;
+ /* Dectect PECI vs. AMDTSI if possible */
+ ttype = 6;
+ if ((has_temp_peci(data, index)) && data->type != it8721) {
+ extra = data->read(data, 0x98); /* PCH/AMDTSI host status */
+ if (extra & BIT(6))
+ ttype = 5;
+ }
+
reg = data->read(data, IT87_REG_TEMP_ENABLE);
+
+ /* Per chip special detection */
+ switch (data->type) {
+ case it8622:
+ if (!(reg & 0xc0) && index == 3)
+ type = ttype;
+ break;
+ default:
+ break;
+ }
+
+ if (type || index >= 3)
+ return type;
+
extra = data->read(data, IT87_REG_TEMP_EXTRA);
if ((has_temp_peci(data, index) && (reg >> 6 == index + 1)) ||
(has_temp_old_peci(data, index) && (extra & 0x80)))
- type = 6; /* Intel PECI */
+ type = ttype; /* Intel PECI or AMDTSI */
if (reg & BIT(index))
type = 3; /* thermal diode */
else if (reg & BIT(index + 3))
err = it87_lock(data);
if (err)
- return err;;
+ return err;
it87_update_pwm_ctrl(data, nr);
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
- if (!res)
- return -EINVAL;
- if (res->flags & IORESOURCE_IO) {
+ if (res) {
if (!devm_request_region(dev, res->start, IT87_EC_EXTENT,
DRVNAME)) {
dev_err(dev, "Failed to request region %pR\n", res);
return -EBUSY;
}
} else {
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
data->mmio = devm_ioremap_resource(dev, res);
if (IS_ERR(data->mmio))
return PTR_ERR(data->mmio);
data->in_internal = sio_data->internal;
data->has_in = 0x3ff & ~sio_data->skip_in;
- if (has_six_temp(data)) {
+ if (has_four_temp(data)) {
+ data->has_temp |= BIT(3);
+ } else if (has_six_temp(data)) {
u8 reg = data->read(data, IT87_REG_TEMP456_ENABLE);
/* Check for additional temperature sensors */