]> git.sur5r.net Git - groeck-it87/blobdiff - it87.c
Checkpatch cleanup: Double semicolon, missing space
[groeck-it87] / it87.c
diff --git a/it87.c b/it87.c
index 46544856c591cf07917aa526c96d3d20411b87df..63eef08d01f68fbce5e530b0b5dc29cdaf859149 100644 (file)
--- a/it87.c
+++ b/it87.c
 #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"
 
@@ -372,6 +375,7 @@ struct it87_devices {
 #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] = {
@@ -610,13 +614,14 @@ static const struct it87_devices it87_devices[] = {
                .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",
@@ -716,6 +721,7 @@ static const struct it87_devices it87_devices[] = {
 #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;
@@ -1430,7 +1436,7 @@ static const u8 temp_types_8686[NUM_TEMP][9] = {
 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;
@@ -1452,7 +1458,7 @@ static int get_temp_type(struct it87_data *data, int index)
                                break;
                        }
                        src2 = data->temp_src[3];
-                       switch(src1) {
+                       switch (src1) {
                        case 3:
                                type = (src2 & BIT(index)) ? 6 : 5;
                                break;
@@ -1470,15 +1476,37 @@ static int get_temp_type(struct it87_data *data, int index)
                        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))
@@ -1810,7 +1838,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
 
        err = it87_lock(data);
        if (err)
-               return err;;
+               return err;
 
        it87_update_pwm_ctrl(data, nr);
 
@@ -3885,15 +3913,14 @@ static int it87_probe(struct platform_device *pdev)
                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);
@@ -3984,7 +4011,9 @@ static int it87_probe(struct platform_device *pdev)
        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 */