Skip to content

Commit aee395b

Browse files
committed
hwmon: (nct6755) Add support for NCT6799D
NCT6799D is mostly compatible to NCT6798D, with minor variations. Note that NCT6798D and NCT6799D have a new means to select temperature sources, and to report temperatures from those sources. This is not currently implemented, meaning that most likely not all temperatures are reported. Cc: Sebastian Arnhold <sebastian.arnhold@posteo.de> Cc: Ahmad Khalifa <ahmad@khalifa.ws> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Sebastian Arnhold <sebastian.arnhold@posteo.de> Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com> Link: https://lore.kernel.org/r/20221228135744.281752-1-linux@roeck-us.net
1 parent be144ee commit aee395b

4 files changed

Lines changed: 94 additions & 6 deletions

File tree

drivers/hwmon/nct6775-core.c

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* (0xd451)
3434
* nct6798d 14 7 7 2+6 0xd428 0xc1 0x5ca3
3535
* (0xd429)
36+
* nct6799d 14 7 7 2+6 0xd802 0xc1 0x5ca3
3637
*
3738
* #temp lists the number of monitored temperature sources (first value) plus
3839
* the number of directly connectable temperature sensors (second value).
@@ -73,6 +74,7 @@ static const char * const nct6775_device_names[] = {
7374
"nct6796",
7475
"nct6797",
7576
"nct6798",
77+
"nct6799",
7678
};
7779

7880
/* Common and NCT6775 specific data */
@@ -381,7 +383,7 @@ static const u16 NCT6779_REG_TEMP_OVER[ARRAY_SIZE(NCT6779_REG_TEMP)] = {
381383
0x39, 0x155 };
382384

383385
static const u16 NCT6779_REG_TEMP_OFFSET[] = {
384-
0x454, 0x455, 0x456, 0x44a, 0x44b, 0x44c };
386+
0x454, 0x455, 0x456, 0x44a, 0x44b, 0x44c, 0x44d, 0x449 };
385387

386388
static const char *const nct6779_temp_label[] = {
387389
"",
@@ -654,6 +656,44 @@ static const char *const nct6798_temp_label[] = {
654656
#define NCT6798_TEMP_MASK 0xbfff0ffe
655657
#define NCT6798_VIRT_TEMP_MASK 0x80000c00
656658

659+
static const char *const nct6799_temp_label[] = {
660+
"",
661+
"SYSTIN",
662+
"CPUTIN",
663+
"AUXTIN0",
664+
"AUXTIN1",
665+
"AUXTIN2",
666+
"AUXTIN3",
667+
"AUXTIN4",
668+
"SMBUSMASTER 0",
669+
"SMBUSMASTER 1",
670+
"Virtual_TEMP",
671+
"Virtual_TEMP",
672+
"",
673+
"AUXTIN5",
674+
"",
675+
"",
676+
"PECI Agent 0",
677+
"PECI Agent 1",
678+
"PCH_CHIP_CPU_MAX_TEMP",
679+
"PCH_CHIP_TEMP",
680+
"PCH_CPU_TEMP",
681+
"PCH_MCH_TEMP",
682+
"Agent0 Dimm0",
683+
"Agent0 Dimm1",
684+
"Agent1 Dimm0",
685+
"Agent1 Dimm1",
686+
"BYTE_TEMP0",
687+
"BYTE_TEMP1",
688+
"PECI Agent 0 Calibration", /* undocumented */
689+
"PECI Agent 1 Calibration", /* undocumented */
690+
"",
691+
"Virtual_TEMP"
692+
};
693+
694+
#define NCT6799_TEMP_MASK 0xbfff2ffe
695+
#define NCT6799_VIRT_TEMP_MASK 0x80000c00
696+
657697
/* NCT6102D/NCT6106D specific data */
658698

659699
#define NCT6106_REG_VBAT 0x318
@@ -1109,6 +1149,7 @@ bool nct6775_reg_is_word_sized(struct nct6775_data *data, u16 reg)
11091149
case nct6796:
11101150
case nct6797:
11111151
case nct6798:
1152+
case nct6799:
11121153
return reg == 0x150 || reg == 0x153 || reg == 0x155 ||
11131154
(reg & 0xfff0) == 0x4c0 ||
11141155
reg == 0x402 ||
@@ -1462,6 +1503,7 @@ static int nct6775_update_pwm_limits(struct device *dev)
14621503
case nct6796:
14631504
case nct6797:
14641505
case nct6798:
1506+
case nct6799:
14651507
err = nct6775_read_value(data, data->REG_CRITICAL_PWM_ENABLE[i], &reg);
14661508
if (err)
14671509
return err;
@@ -3109,6 +3151,7 @@ store_auto_pwm(struct device *dev, struct device_attribute *attr,
31093151
case nct6796:
31103152
case nct6797:
31113153
case nct6798:
3154+
case nct6799:
31123155
err = nct6775_write_value(data, data->REG_CRITICAL_PWM[nr], val);
31133156
if (err)
31143157
break;
@@ -3807,10 +3850,12 @@ int nct6775_probe(struct device *dev, struct nct6775_data *data,
38073850
case nct6796:
38083851
case nct6797:
38093852
case nct6798:
3853+
case nct6799:
38103854
data->in_num = 15;
38113855
data->pwm_num = (data->kind == nct6796 ||
38123856
data->kind == nct6797 ||
3813-
data->kind == nct6798) ? 7 : 6;
3857+
data->kind == nct6798 ||
3858+
data->kind == nct6799) ? 7 : 6;
38143859
data->auto_pwm_num = 4;
38153860
data->has_fan_div = false;
38163861
data->temp_fixed_num = 6;
@@ -3859,6 +3904,11 @@ int nct6775_probe(struct device *dev, struct nct6775_data *data,
38593904
data->temp_mask = NCT6798_TEMP_MASK;
38603905
data->virt_temp_mask = NCT6798_VIRT_TEMP_MASK;
38613906
break;
3907+
case nct6799:
3908+
data->temp_label = nct6799_temp_label;
3909+
data->temp_mask = NCT6799_TEMP_MASK;
3910+
data->virt_temp_mask = NCT6799_VIRT_TEMP_MASK;
3911+
break;
38623912
}
38633913

38643914
data->REG_CONFIG = NCT6775_REG_CONFIG;
@@ -3918,6 +3968,7 @@ int nct6775_probe(struct device *dev, struct nct6775_data *data,
39183968
case nct6796:
39193969
case nct6797:
39203970
case nct6798:
3971+
case nct6799:
39213972
data->REG_TSI_TEMP = NCT6796_REG_TSI_TEMP;
39223973
num_reg_tsi_temp = ARRAY_SIZE(NCT6796_REG_TSI_TEMP);
39233974
break;

drivers/hwmon/nct6775-i2c.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ static const struct of_device_id __maybe_unused nct6775_i2c_of_match[] = {
8787
{ .compatible = "nuvoton,nct6796", .data = (void *)nct6796, },
8888
{ .compatible = "nuvoton,nct6797", .data = (void *)nct6797, },
8989
{ .compatible = "nuvoton,nct6798", .data = (void *)nct6798, },
90+
{ .compatible = "nuvoton,nct6799", .data = (void *)nct6799, },
9091
{ },
9192
};
9293
MODULE_DEVICE_TABLE(of, nct6775_i2c_of_match);
@@ -104,6 +105,7 @@ static const struct i2c_device_id nct6775_i2c_id[] = {
104105
{ "nct6796", nct6796 },
105106
{ "nct6797", nct6797 },
106107
{ "nct6798", nct6798 },
108+
{ "nct6799", nct6799 },
107109
{ }
108110
};
109111
MODULE_DEVICE_TABLE(i2c, nct6775_i2c_id);

drivers/hwmon/nct6775-platform.c

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static const char * const nct6775_sio_names[] __initconst = {
3535
"NCT6796D",
3636
"NCT6797D",
3737
"NCT6798D",
38+
"NCT6799D",
3839
};
3940

4041
static unsigned short force_id;
@@ -85,6 +86,7 @@ MODULE_PARM_DESC(fan_debounce, "Enable debouncing for fan RPM signal");
8586
#define SIO_NCT6796_ID 0xd420
8687
#define SIO_NCT6797_ID 0xd450
8788
#define SIO_NCT6798_ID 0xd428
89+
#define SIO_NCT6799_ID 0xd800
8890
#define SIO_ID_MASK 0xFFF8
8991

9092
/*
@@ -418,7 +420,7 @@ static int nct6775_resume(struct device *dev)
418420
if (data->kind == nct6791 || data->kind == nct6792 ||
419421
data->kind == nct6793 || data->kind == nct6795 ||
420422
data->kind == nct6796 || data->kind == nct6797 ||
421-
data->kind == nct6798)
423+
data->kind == nct6798 || data->kind == nct6799)
422424
nct6791_enable_io_mapping(sio_data);
423425

424426
sio_data->sio_exit(sio_data);
@@ -565,7 +567,7 @@ nct6775_check_fan_inputs(struct nct6775_data *data, struct nct6775_sio_data *sio
565567
} else {
566568
/*
567569
* NCT6779D, NCT6791D, NCT6792D, NCT6793D, NCT6795D, NCT6796D,
568-
* NCT6797D, NCT6798D
570+
* NCT6797D, NCT6798D, NCT6799D
569571
*/
570572
int cr1a = sio_data->sio_inb(sio_data, 0x1a);
571573
int cr1b = sio_data->sio_inb(sio_data, 0x1b);
@@ -575,12 +577,17 @@ nct6775_check_fan_inputs(struct nct6775_data *data, struct nct6775_sio_data *sio
575577
int cr2b = sio_data->sio_inb(sio_data, 0x2b);
576578
int cr2d = sio_data->sio_inb(sio_data, 0x2d);
577579
int cr2f = sio_data->sio_inb(sio_data, 0x2f);
580+
bool vsb_ctl_en = cr2f & BIT(0);
578581
bool dsw_en = cr2f & BIT(3);
579582
bool ddr4_en = cr2f & BIT(4);
583+
bool as_seq1_en = cr2f & BIT(7);
580584
int cre0;
585+
int cre6;
581586
int creb;
582587
int cred;
583588

589+
cre6 = sio_data->sio_inb(sio_data, 0xe0);
590+
584591
sio_data->sio_select(sio_data, NCT6775_LD_12);
585592
cre0 = sio_data->sio_inb(sio_data, 0xe0);
586593
creb = sio_data->sio_inb(sio_data, 0xeb);
@@ -683,6 +690,29 @@ nct6775_check_fan_inputs(struct nct6775_data *data, struct nct6775_sio_data *sio
683690
pwm7pin = !(cr1d & (BIT(2) | BIT(3)));
684691
pwm7pin |= cr2d & BIT(7);
685692
pwm7pin |= creb & BIT(2);
693+
break;
694+
case nct6799:
695+
fan4pin = cr1c & BIT(6);
696+
fan5pin = cr1c & BIT(7);
697+
698+
fan6pin = !(cr1b & BIT(0)) && (cre0 & BIT(3));
699+
fan6pin |= cre6 & BIT(5);
700+
fan6pin |= creb & BIT(5);
701+
fan6pin |= !as_seq1_en && (cr2a & BIT(4));
702+
703+
fan7pin = cr1b & BIT(5);
704+
fan7pin |= !vsb_ctl_en && !(cr2b & BIT(2));
705+
fan7pin |= creb & BIT(3);
706+
707+
pwm6pin = !(cr1b & BIT(0)) && (cre0 & BIT(4));
708+
pwm6pin |= !as_seq1_en && !(cred & BIT(2)) && (cr2a & BIT(3));
709+
pwm6pin |= (creb & BIT(4)) && !(cr2a & BIT(0));
710+
pwm6pin |= cre6 & BIT(3);
711+
712+
pwm7pin = !vsb_ctl_en && !(cr1d & (BIT(2) | BIT(3)));
713+
pwm7pin |= creb & BIT(2);
714+
pwm7pin |= cr2d & BIT(7);
715+
686716
break;
687717
default: /* NCT6779D */
688718
break;
@@ -838,6 +868,7 @@ static int nct6775_platform_probe_init(struct nct6775_data *data)
838868
case nct6796:
839869
case nct6797:
840870
case nct6798:
871+
case nct6799:
841872
break;
842873
}
843874

@@ -876,6 +907,7 @@ static int nct6775_platform_probe_init(struct nct6775_data *data)
876907
case nct6796:
877908
case nct6797:
878909
case nct6798:
910+
case nct6799:
879911
tmp |= 0x7e;
880912
break;
881913
}
@@ -1005,6 +1037,9 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
10051037
case SIO_NCT6798_ID:
10061038
sio_data->kind = nct6798;
10071039
break;
1040+
case SIO_NCT6799_ID:
1041+
sio_data->kind = nct6799;
1042+
break;
10081043
default:
10091044
if (val != 0xffff)
10101045
pr_debug("unsupported chip ID: 0x%04x\n", val);
@@ -1033,7 +1068,7 @@ static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
10331068
if (sio_data->kind == nct6791 || sio_data->kind == nct6792 ||
10341069
sio_data->kind == nct6793 || sio_data->kind == nct6795 ||
10351070
sio_data->kind == nct6796 || sio_data->kind == nct6797 ||
1036-
sio_data->kind == nct6798)
1071+
sio_data->kind == nct6798 || sio_data->kind == nct6799)
10371072
nct6791_enable_io_mapping(sio_data);
10381073

10391074
sio_data->sio_exit(sio_data);

drivers/hwmon/nct6775.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <linux/types.h>
66

77
enum kinds { nct6106, nct6116, nct6775, nct6776, nct6779, nct6791, nct6792,
8-
nct6793, nct6795, nct6796, nct6797, nct6798 };
8+
nct6793, nct6795, nct6796, nct6797, nct6798, nct6799 };
99
enum pwm_enable { off, manual, thermal_cruise, speed_cruise, sf3, sf4 };
1010

1111
#define NUM_TEMP 10 /* Max number of temp attribute sets w/ limits*/

0 commit comments

Comments
 (0)