diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-16 11:49:41 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-16 11:49:41 -0400 |
commit | 30255100d7c253c82b596a0768235d5865eee2cf (patch) | |
tree | 982c77473b182642f4dc6ea5b84e20998e9b9d56 | |
parent | 9efeaaf9a0c1a27c2be8b2d37c73142555702a4f (diff) | |
parent | cd1faefa66425c3fa338777773c5c017edea3439 (diff) |
Merge tag 'hwmon-for-linus-v4.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck:
"Two patches for the nct6775 driver: add support for NCT6793D, and fix
swapped registers"
* tag 'hwmon-for-linus-v4.3-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
hwmon: (nct6775) Add support for NCT6793D
hwmon: (nct6775) Swap STEP_UP_TIME and STEP_DOWN_TIME registers for most chips
-rw-r--r-- | Documentation/hwmon/nct6775 | 4 | ||||
-rw-r--r-- | drivers/hwmon/Kconfig | 4 | ||||
-rw-r--r-- | drivers/hwmon/nct6775.c | 64 |
3 files changed, 48 insertions, 24 deletions
diff --git a/Documentation/hwmon/nct6775 b/Documentation/hwmon/nct6775 index f0dd3d2fec96..76add4c9cd68 100644 --- a/Documentation/hwmon/nct6775 +++ b/Documentation/hwmon/nct6775 | |||
@@ -32,6 +32,10 @@ Supported chips: | |||
32 | Prefix: 'nct6792' | 32 | Prefix: 'nct6792' |
33 | Addresses scanned: ISA address retrieved from Super I/O registers | 33 | Addresses scanned: ISA address retrieved from Super I/O registers |
34 | Datasheet: Available from Nuvoton upon request | 34 | Datasheet: Available from Nuvoton upon request |
35 | * Nuvoton NCT6793D | ||
36 | Prefix: 'nct6793' | ||
37 | Addresses scanned: ISA address retrieved from Super I/O registers | ||
38 | Datasheet: Available from Nuvoton upon request | ||
35 | 39 | ||
36 | Authors: | 40 | Authors: |
37 | Guenter Roeck <linux@roeck-us.net> | 41 | Guenter Roeck <linux@roeck-us.net> |
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 500b262b89bb..e13c902e8966 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -1140,8 +1140,8 @@ config SENSORS_NCT6775 | |||
1140 | help | 1140 | help |
1141 | If you say yes here you get support for the hardware monitoring | 1141 | If you say yes here you get support for the hardware monitoring |
1142 | functionality of the Nuvoton NCT6106D, NCT6775F, NCT6776F, NCT6779D, | 1142 | functionality of the Nuvoton NCT6106D, NCT6775F, NCT6776F, NCT6779D, |
1143 | NCT6791D, NCT6792D and compatible Super-I/O chips. This driver | 1143 | NCT6791D, NCT6792D, NCT6793D, and compatible Super-I/O chips. This |
1144 | replaces the w83627ehf driver for NCT6775F and NCT6776F. | 1144 | driver replaces the w83627ehf driver for NCT6775F and NCT6776F. |
1145 | 1145 | ||
1146 | This driver can also be built as a module. If so, the module | 1146 | This driver can also be built as a module. If so, the module |
1147 | will be called nct6775. | 1147 | will be called nct6775. |
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index bd1c99deac71..8b4fa55e46c6 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c | |||
@@ -39,6 +39,7 @@ | |||
39 | * nct6779d 15 5 5 2+6 0xc560 0xc1 0x5ca3 | 39 | * nct6779d 15 5 5 2+6 0xc560 0xc1 0x5ca3 |
40 | * nct6791d 15 6 6 2+6 0xc800 0xc1 0x5ca3 | 40 | * nct6791d 15 6 6 2+6 0xc800 0xc1 0x5ca3 |
41 | * nct6792d 15 6 6 2+6 0xc910 0xc1 0x5ca3 | 41 | * nct6792d 15 6 6 2+6 0xc910 0xc1 0x5ca3 |
42 | * nct6793d 15 6 6 2+6 0xd120 0xc1 0x5ca3 | ||
42 | * | 43 | * |
43 | * #temp lists the number of monitored temperature sources (first value) plus | 44 | * #temp lists the number of monitored temperature sources (first value) plus |
44 | * the number of directly connectable temperature sensors (second value). | 45 | * the number of directly connectable temperature sensors (second value). |
@@ -63,7 +64,7 @@ | |||
63 | 64 | ||
64 | #define USE_ALTERNATE | 65 | #define USE_ALTERNATE |
65 | 66 | ||
66 | enum kinds { nct6106, nct6775, nct6776, nct6779, nct6791, nct6792 }; | 67 | enum kinds { nct6106, nct6775, nct6776, nct6779, nct6791, nct6792, nct6793 }; |
67 | 68 | ||
68 | /* used to set data->name = nct6775_device_names[data->sio_kind] */ | 69 | /* used to set data->name = nct6775_device_names[data->sio_kind] */ |
69 | static const char * const nct6775_device_names[] = { | 70 | static const char * const nct6775_device_names[] = { |
@@ -73,6 +74,17 @@ static const char * const nct6775_device_names[] = { | |||
73 | "nct6779", | 74 | "nct6779", |
74 | "nct6791", | 75 | "nct6791", |
75 | "nct6792", | 76 | "nct6792", |
77 | "nct6793", | ||
78 | }; | ||
79 | |||
80 | static const char * const nct6775_sio_names[] __initconst = { | ||
81 | "NCT6106D", | ||
82 | "NCT6775F", | ||
83 | "NCT6776D/F", | ||
84 | "NCT6779D", | ||
85 | "NCT6791D", | ||
86 | "NCT6792D", | ||
87 | "NCT6793D", | ||
76 | }; | 88 | }; |
77 | 89 | ||
78 | static unsigned short force_id; | 90 | static unsigned short force_id; |
@@ -104,6 +116,7 @@ MODULE_PARM_DESC(fan_debounce, "Enable debouncing for fan RPM signal"); | |||
104 | #define SIO_NCT6779_ID 0xc560 | 116 | #define SIO_NCT6779_ID 0xc560 |
105 | #define SIO_NCT6791_ID 0xc800 | 117 | #define SIO_NCT6791_ID 0xc800 |
106 | #define SIO_NCT6792_ID 0xc910 | 118 | #define SIO_NCT6792_ID 0xc910 |
119 | #define SIO_NCT6793_ID 0xd120 | ||
107 | #define SIO_ID_MASK 0xFFF0 | 120 | #define SIO_ID_MASK 0xFFF0 |
108 | 121 | ||
109 | enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 }; | 122 | enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 }; |
@@ -354,6 +367,10 @@ static const u16 NCT6775_REG_TEMP_CRIT[ARRAY_SIZE(nct6775_temp_label) - 1] | |||
354 | 367 | ||
355 | /* NCT6776 specific data */ | 368 | /* NCT6776 specific data */ |
356 | 369 | ||
370 | /* STEP_UP_TIME and STEP_DOWN_TIME regs are swapped for all chips but NCT6775 */ | ||
371 | #define NCT6776_REG_FAN_STEP_UP_TIME NCT6775_REG_FAN_STEP_DOWN_TIME | ||
372 | #define NCT6776_REG_FAN_STEP_DOWN_TIME NCT6775_REG_FAN_STEP_UP_TIME | ||
373 | |||
357 | static const s8 NCT6776_ALARM_BITS[] = { | 374 | static const s8 NCT6776_ALARM_BITS[] = { |
358 | 0, 1, 2, 3, 8, 21, 20, 16, /* in0.. in7 */ | 375 | 0, 1, 2, 3, 8, 21, 20, 16, /* in0.. in7 */ |
359 | 17, -1, -1, -1, -1, -1, -1, /* in8..in14 */ | 376 | 17, -1, -1, -1, -1, -1, -1, /* in8..in14 */ |
@@ -533,7 +550,7 @@ static const s8 NCT6791_ALARM_BITS[] = { | |||
533 | 4, 5, 13, -1, -1, -1, /* temp1..temp6 */ | 550 | 4, 5, 13, -1, -1, -1, /* temp1..temp6 */ |
534 | 12, 9 }; /* intrusion0, intrusion1 */ | 551 | 12, 9 }; /* intrusion0, intrusion1 */ |
535 | 552 | ||
536 | /* NCT6792 specific data */ | 553 | /* NCT6792/NCT6793 specific data */ |
537 | 554 | ||
538 | static const u16 NCT6792_REG_TEMP_MON[] = { | 555 | static const u16 NCT6792_REG_TEMP_MON[] = { |
539 | 0x73, 0x75, 0x77, 0x79, 0x7b, 0x7d }; | 556 | 0x73, 0x75, 0x77, 0x79, 0x7b, 0x7d }; |
@@ -1056,6 +1073,7 @@ static bool is_word_sized(struct nct6775_data *data, u16 reg) | |||
1056 | case nct6779: | 1073 | case nct6779: |
1057 | case nct6791: | 1074 | case nct6791: |
1058 | case nct6792: | 1075 | case nct6792: |
1076 | case nct6793: | ||
1059 | return reg == 0x150 || reg == 0x153 || reg == 0x155 || | 1077 | return reg == 0x150 || reg == 0x153 || reg == 0x155 || |
1060 | ((reg & 0xfff0) == 0x4b0 && (reg & 0x000f) < 0x0b) || | 1078 | ((reg & 0xfff0) == 0x4b0 && (reg & 0x000f) < 0x0b) || |
1061 | reg == 0x402 || | 1079 | reg == 0x402 || |
@@ -1407,6 +1425,7 @@ static void nct6775_update_pwm_limits(struct device *dev) | |||
1407 | case nct6779: | 1425 | case nct6779: |
1408 | case nct6791: | 1426 | case nct6791: |
1409 | case nct6792: | 1427 | case nct6792: |
1428 | case nct6793: | ||
1410 | reg = nct6775_read_value(data, | 1429 | reg = nct6775_read_value(data, |
1411 | data->REG_CRITICAL_PWM_ENABLE[i]); | 1430 | data->REG_CRITICAL_PWM_ENABLE[i]); |
1412 | if (reg & data->CRITICAL_PWM_ENABLE_MASK) | 1431 | if (reg & data->CRITICAL_PWM_ENABLE_MASK) |
@@ -2822,6 +2841,7 @@ store_auto_pwm(struct device *dev, struct device_attribute *attr, | |||
2822 | case nct6779: | 2841 | case nct6779: |
2823 | case nct6791: | 2842 | case nct6791: |
2824 | case nct6792: | 2843 | case nct6792: |
2844 | case nct6793: | ||
2825 | nct6775_write_value(data, data->REG_CRITICAL_PWM[nr], | 2845 | nct6775_write_value(data, data->REG_CRITICAL_PWM[nr], |
2826 | val); | 2846 | val); |
2827 | reg = nct6775_read_value(data, | 2847 | reg = nct6775_read_value(data, |
@@ -3256,7 +3276,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data) | |||
3256 | pwm4pin = false; | 3276 | pwm4pin = false; |
3257 | pwm5pin = false; | 3277 | pwm5pin = false; |
3258 | pwm6pin = false; | 3278 | pwm6pin = false; |
3259 | } else { /* NCT6779D, NCT6791D, or NCT6792D */ | 3279 | } else { /* NCT6779D, NCT6791D, NCT6792D, or NCT6793D */ |
3260 | regval = superio_inb(sioreg, 0x1c); | 3280 | regval = superio_inb(sioreg, 0x1c); |
3261 | 3281 | ||
3262 | fan3pin = !(regval & (1 << 5)); | 3282 | fan3pin = !(regval & (1 << 5)); |
@@ -3269,7 +3289,8 @@ nct6775_check_fan_inputs(struct nct6775_data *data) | |||
3269 | 3289 | ||
3270 | fan4min = fan4pin; | 3290 | fan4min = fan4pin; |
3271 | 3291 | ||
3272 | if (data->kind == nct6791 || data->kind == nct6792) { | 3292 | if (data->kind == nct6791 || data->kind == nct6792 || |
3293 | data->kind == nct6793) { | ||
3273 | regval = superio_inb(sioreg, 0x2d); | 3294 | regval = superio_inb(sioreg, 0x2d); |
3274 | fan6pin = (regval & (1 << 1)); | 3295 | fan6pin = (regval & (1 << 1)); |
3275 | pwm6pin = (regval & (1 << 0)); | 3296 | pwm6pin = (regval & (1 << 0)); |
@@ -3528,8 +3549,8 @@ static int nct6775_probe(struct platform_device *pdev) | |||
3528 | data->REG_FAN_PULSES = NCT6776_REG_FAN_PULSES; | 3549 | data->REG_FAN_PULSES = NCT6776_REG_FAN_PULSES; |
3529 | data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; | 3550 | data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; |
3530 | data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; | 3551 | data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; |
3531 | data->REG_FAN_TIME[1] = NCT6775_REG_FAN_STEP_UP_TIME; | 3552 | data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; |
3532 | data->REG_FAN_TIME[2] = NCT6775_REG_FAN_STEP_DOWN_TIME; | 3553 | data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; |
3533 | data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; | 3554 | data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; |
3534 | data->REG_PWM[0] = NCT6775_REG_PWM; | 3555 | data->REG_PWM[0] = NCT6775_REG_PWM; |
3535 | data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; | 3556 | data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; |
@@ -3600,8 +3621,8 @@ static int nct6775_probe(struct platform_device *pdev) | |||
3600 | data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; | 3621 | data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; |
3601 | data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; | 3622 | data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; |
3602 | data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; | 3623 | data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; |
3603 | data->REG_FAN_TIME[1] = NCT6775_REG_FAN_STEP_UP_TIME; | 3624 | data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; |
3604 | data->REG_FAN_TIME[2] = NCT6775_REG_FAN_STEP_DOWN_TIME; | 3625 | data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; |
3605 | data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; | 3626 | data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; |
3606 | data->REG_PWM[0] = NCT6775_REG_PWM; | 3627 | data->REG_PWM[0] = NCT6775_REG_PWM; |
3607 | data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; | 3628 | data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; |
@@ -3643,6 +3664,7 @@ static int nct6775_probe(struct platform_device *pdev) | |||
3643 | break; | 3664 | break; |
3644 | case nct6791: | 3665 | case nct6791: |
3645 | case nct6792: | 3666 | case nct6792: |
3667 | case nct6793: | ||
3646 | data->in_num = 15; | 3668 | data->in_num = 15; |
3647 | data->pwm_num = 6; | 3669 | data->pwm_num = 6; |
3648 | data->auto_pwm_num = 4; | 3670 | data->auto_pwm_num = 4; |
@@ -3677,8 +3699,8 @@ static int nct6775_probe(struct platform_device *pdev) | |||
3677 | data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; | 3699 | data->REG_FAN_PULSES = NCT6779_REG_FAN_PULSES; |
3678 | data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; | 3700 | data->FAN_PULSE_SHIFT = NCT6775_FAN_PULSE_SHIFT; |
3679 | data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; | 3701 | data->REG_FAN_TIME[0] = NCT6775_REG_FAN_STOP_TIME; |
3680 | data->REG_FAN_TIME[1] = NCT6775_REG_FAN_STEP_UP_TIME; | 3702 | data->REG_FAN_TIME[1] = NCT6776_REG_FAN_STEP_UP_TIME; |
3681 | data->REG_FAN_TIME[2] = NCT6775_REG_FAN_STEP_DOWN_TIME; | 3703 | data->REG_FAN_TIME[2] = NCT6776_REG_FAN_STEP_DOWN_TIME; |
3682 | data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; | 3704 | data->REG_TOLERANCE_H = NCT6776_REG_TOLERANCE_H; |
3683 | data->REG_PWM[0] = NCT6775_REG_PWM; | 3705 | data->REG_PWM[0] = NCT6775_REG_PWM; |
3684 | data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; | 3706 | data->REG_PWM[1] = NCT6775_REG_FAN_START_OUTPUT; |
@@ -3918,6 +3940,7 @@ static int nct6775_probe(struct platform_device *pdev) | |||
3918 | case nct6779: | 3940 | case nct6779: |
3919 | case nct6791: | 3941 | case nct6791: |
3920 | case nct6792: | 3942 | case nct6792: |
3943 | case nct6793: | ||
3921 | break; | 3944 | break; |
3922 | } | 3945 | } |
3923 | 3946 | ||
@@ -3950,6 +3973,7 @@ static int nct6775_probe(struct platform_device *pdev) | |||
3950 | break; | 3973 | break; |
3951 | case nct6791: | 3974 | case nct6791: |
3952 | case nct6792: | 3975 | case nct6792: |
3976 | case nct6793: | ||
3953 | tmp |= 0x7e; | 3977 | tmp |= 0x7e; |
3954 | break; | 3978 | break; |
3955 | } | 3979 | } |
@@ -4047,7 +4071,8 @@ static int __maybe_unused nct6775_resume(struct device *dev) | |||
4047 | if (reg != data->sio_reg_enable) | 4071 | if (reg != data->sio_reg_enable) |
4048 | superio_outb(sioreg, SIO_REG_ENABLE, data->sio_reg_enable); | 4072 | superio_outb(sioreg, SIO_REG_ENABLE, data->sio_reg_enable); |
4049 | 4073 | ||
4050 | if (data->kind == nct6791 || data->kind == nct6792) | 4074 | if (data->kind == nct6791 || data->kind == nct6792 || |
4075 | data->kind == nct6793) | ||
4051 | nct6791_enable_io_mapping(sioreg); | 4076 | nct6791_enable_io_mapping(sioreg); |
4052 | 4077 | ||
4053 | superio_exit(sioreg); | 4078 | superio_exit(sioreg); |
@@ -4106,15 +4131,6 @@ static struct platform_driver nct6775_driver = { | |||
4106 | .probe = nct6775_probe, | 4131 | .probe = nct6775_probe, |
4107 | }; | 4132 | }; |
4108 | 4133 | ||
4109 | static const char * const nct6775_sio_names[] __initconst = { | ||
4110 | "NCT6106D", | ||
4111 | "NCT6775F", | ||
4112 | "NCT6776D/F", | ||
4113 | "NCT6779D", | ||
4114 | "NCT6791D", | ||
4115 | "NCT6792D", | ||
4116 | }; | ||
4117 | |||
4118 | /* nct6775_find() looks for a '627 in the Super-I/O config space */ | 4134 | /* nct6775_find() looks for a '627 in the Super-I/O config space */ |
4119 | static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) | 4135 | static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) |
4120 | { | 4136 | { |
@@ -4150,6 +4166,9 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) | |||
4150 | case SIO_NCT6792_ID: | 4166 | case SIO_NCT6792_ID: |
4151 | sio_data->kind = nct6792; | 4167 | sio_data->kind = nct6792; |
4152 | break; | 4168 | break; |
4169 | case SIO_NCT6793_ID: | ||
4170 | sio_data->kind = nct6793; | ||
4171 | break; | ||
4153 | default: | 4172 | default: |
4154 | if (val != 0xffff) | 4173 | if (val != 0xffff) |
4155 | pr_debug("unsupported chip ID: 0x%04x\n", val); | 4174 | pr_debug("unsupported chip ID: 0x%04x\n", val); |
@@ -4175,7 +4194,8 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data) | |||
4175 | superio_outb(sioaddr, SIO_REG_ENABLE, val | 0x01); | 4194 | superio_outb(sioaddr, SIO_REG_ENABLE, val | 0x01); |
4176 | } | 4195 | } |
4177 | 4196 | ||
4178 | if (sio_data->kind == nct6791 || sio_data->kind == nct6792) | 4197 | if (sio_data->kind == nct6791 || sio_data->kind == nct6792 || |
4198 | sio_data->kind == nct6793) | ||
4179 | nct6791_enable_io_mapping(sioaddr); | 4199 | nct6791_enable_io_mapping(sioaddr); |
4180 | 4200 | ||
4181 | superio_exit(sioaddr); | 4201 | superio_exit(sioaddr); |
@@ -4285,7 +4305,7 @@ static void __exit sensors_nct6775_exit(void) | |||
4285 | } | 4305 | } |
4286 | 4306 | ||
4287 | MODULE_AUTHOR("Guenter Roeck <linux@roeck-us.net>"); | 4307 | MODULE_AUTHOR("Guenter Roeck <linux@roeck-us.net>"); |
4288 | MODULE_DESCRIPTION("NCT6106D/NCT6775F/NCT6776F/NCT6779D/NCT6791D/NCT6792D driver"); | 4308 | MODULE_DESCRIPTION("Driver for NCT6775F and compatible chips"); |
4289 | MODULE_LICENSE("GPL"); | 4309 | MODULE_LICENSE("GPL"); |
4290 | 4310 | ||
4291 | module_init(sensors_nct6775_init); | 4311 | module_init(sensors_nct6775_init); |