43
43
/* 7475 Common Registers */
44
44
45
45
#define REG_DEVREV2 0x12 /* ADT7490 only */
46
+ #define REG_IMON 0x1D /* ADT7490 only */
46
47
47
48
#define REG_VTT 0x1E /* ADT7490 only */
48
49
#define REG_EXTEND3 0x1F /* ADT7490 only */
103
104
#define REG_VTT_MIN 0x84 /* ADT7490 only */
104
105
#define REG_VTT_MAX 0x86 /* ADT7490 only */
105
106
107
+ #define REG_IMON_MIN 0x85 /* ADT7490 only */
108
+ #define REG_IMON_MAX 0x87 /* ADT7490 only */
109
+
106
110
#define VID_VIDSEL 0x80 /* ADT7476 only */
107
111
108
112
#define CONFIG2_ATTN 0x20
123
127
124
128
/* ADT7475 Settings */
125
129
126
- #define ADT7475_VOLTAGE_COUNT 5 /* Not counting Vtt */
130
+ #define ADT7475_VOLTAGE_COUNT 5 /* Not counting Vtt or Imon */
127
131
#define ADT7475_TEMP_COUNT 3
128
132
#define ADT7475_TACH_COUNT 4
129
133
#define ADT7475_PWM_COUNT 3
@@ -204,7 +208,7 @@ struct adt7475_data {
204
208
u8 has_fan4 :1 ;
205
209
u8 has_vid :1 ;
206
210
u32 alarms ;
207
- u16 voltage [3 ][6 ];
211
+ u16 voltage [3 ][7 ];
208
212
u16 temp [7 ][3 ];
209
213
u16 tach [2 ][4 ];
210
214
u8 pwm [4 ][3 ];
@@ -215,7 +219,7 @@ struct adt7475_data {
215
219
216
220
u8 vid ;
217
221
u8 vrm ;
218
- const struct attribute_group * groups [9 ];
222
+ const struct attribute_group * groups [10 ];
219
223
};
220
224
221
225
static struct i2c_driver adt7475_driver ;
@@ -273,13 +277,14 @@ static inline u16 rpm2tach(unsigned long rpm)
273
277
}
274
278
275
279
/* Scaling factors for voltage inputs, taken from the ADT7490 datasheet */
276
- static const int adt7473_in_scaling [ADT7475_VOLTAGE_COUNT + 1 ][2 ] = {
280
+ static const int adt7473_in_scaling [ADT7475_VOLTAGE_COUNT + 2 ][2 ] = {
277
281
{ 45 , 94 }, /* +2.5V */
278
282
{ 175 , 525 }, /* Vccp */
279
283
{ 68 , 71 }, /* Vcc */
280
284
{ 93 , 47 }, /* +5V */
281
285
{ 120 , 20 }, /* +12V */
282
286
{ 45 , 45 }, /* Vtt */
287
+ { 45 , 45 }, /* Imon */
283
288
};
284
289
285
290
static inline int reg2volt (int channel , u16 reg , u8 bypass_attn )
@@ -369,11 +374,16 @@ static ssize_t voltage_store(struct device *dev,
369
374
reg = VOLTAGE_MIN_REG (sattr -> index );
370
375
else
371
376
reg = VOLTAGE_MAX_REG (sattr -> index );
372
- } else {
377
+ } else if ( sattr -> index == 5 ) {
373
378
if (sattr -> nr == MIN )
374
379
reg = REG_VTT_MIN ;
375
380
else
376
381
reg = REG_VTT_MAX ;
382
+ } else {
383
+ if (sattr -> nr == MIN )
384
+ reg = REG_IMON_MIN ;
385
+ else
386
+ reg = REG_IMON_MAX ;
377
387
}
378
388
379
389
i2c_smbus_write_byte_data (client , reg ,
@@ -1104,6 +1114,10 @@ static SENSOR_DEVICE_ATTR_2_RO(in5_input, voltage, INPUT, 5);
1104
1114
static SENSOR_DEVICE_ATTR_2_RW (in5_max , voltage , MAX , 5 ) ;
1105
1115
static SENSOR_DEVICE_ATTR_2_RW (in5_min , voltage , MIN , 5 ) ;
1106
1116
static SENSOR_DEVICE_ATTR_2_RO (in5_alarm , voltage , ALARM , 31 ) ;
1117
+ static SENSOR_DEVICE_ATTR_2_RO (in6_input , voltage , INPUT , 6 ) ;
1118
+ static SENSOR_DEVICE_ATTR_2_RW (in6_max , voltage , MAX , 6 ) ;
1119
+ static SENSOR_DEVICE_ATTR_2_RW (in6_min , voltage , MIN , 6 ) ;
1120
+ static SENSOR_DEVICE_ATTR_2_RO (in6_alarm , voltage , ALARM , 30 ) ;
1107
1121
static SENSOR_DEVICE_ATTR_2_RO (temp1_input , temp , INPUT , 0 ) ;
1108
1122
static SENSOR_DEVICE_ATTR_2_RO (temp1_alarm , temp , ALARM , 0 ) ;
1109
1123
static SENSOR_DEVICE_ATTR_2_RO (temp1_fault , temp , FAULT , 0 ) ;
@@ -1294,6 +1308,14 @@ static struct attribute *in5_attrs[] = {
1294
1308
NULL
1295
1309
};
1296
1310
1311
+ static struct attribute * in6_attrs [] = {
1312
+ & sensor_dev_attr_in6_input .dev_attr .attr ,
1313
+ & sensor_dev_attr_in6_max .dev_attr .attr ,
1314
+ & sensor_dev_attr_in6_min .dev_attr .attr ,
1315
+ & sensor_dev_attr_in6_alarm .dev_attr .attr ,
1316
+ NULL
1317
+ };
1318
+
1297
1319
static struct attribute * vid_attrs [] = {
1298
1320
& dev_attr_cpu0_vid .attr ,
1299
1321
& dev_attr_vrm .attr ,
@@ -1307,6 +1329,7 @@ static const struct attribute_group in0_attr_group = { .attrs = in0_attrs };
1307
1329
static const struct attribute_group in3_attr_group = { .attrs = in3_attrs };
1308
1330
static const struct attribute_group in4_attr_group = { .attrs = in4_attrs };
1309
1331
static const struct attribute_group in5_attr_group = { .attrs = in5_attrs };
1332
+ static const struct attribute_group in6_attr_group = { .attrs = in6_attrs };
1310
1333
static const struct attribute_group vid_attr_group = { .attrs = vid_attrs };
1311
1334
1312
1335
static int adt7475_detect (struct i2c_client * client ,
@@ -1389,6 +1412,18 @@ static int adt7475_update_limits(struct i2c_client *client)
1389
1412
data -> voltage [MAX ][5 ] = ret << 2 ;
1390
1413
}
1391
1414
1415
+ if (data -> has_voltage & (1 << 6 )) {
1416
+ ret = adt7475_read (REG_IMON_MIN );
1417
+ if (ret < 0 )
1418
+ return ret ;
1419
+ data -> voltage [MIN ][6 ] = ret << 2 ;
1420
+
1421
+ ret = adt7475_read (REG_IMON_MAX );
1422
+ if (ret < 0 )
1423
+ return ret ;
1424
+ data -> voltage [MAX ][6 ] = ret << 2 ;
1425
+ }
1426
+
1392
1427
for (i = 0 ; i < ADT7475_TEMP_COUNT ; i ++ ) {
1393
1428
/* Adjust values so they match the input precision */
1394
1429
ret = adt7475_read (TEMP_MIN_REG (i ));
@@ -1663,7 +1698,7 @@ static int adt7475_probe(struct i2c_client *client)
1663
1698
revision = adt7475_read (REG_DEVID2 ) & 0x07 ;
1664
1699
break ;
1665
1700
case adt7490 :
1666
- data -> has_voltage = 0x3e ; /* in1 to in5 */
1701
+ data -> has_voltage = 0x7e ; /* in1 to in6 */
1667
1702
revision = adt7475_read (REG_DEVID2 ) & 0x03 ;
1668
1703
if (revision == 0x03 )
1669
1704
revision += adt7475_read (REG_DEVREV2 );
@@ -1775,6 +1810,9 @@ static int adt7475_probe(struct i2c_client *client)
1775
1810
if (data -> has_voltage & (1 << 5 )) {
1776
1811
data -> groups [group_num ++ ] = & in5_attr_group ;
1777
1812
}
1813
+ if (data -> has_voltage & (1 << 6 )) {
1814
+ data -> groups [group_num ++ ] = & in6_attr_group ;
1815
+ }
1778
1816
if (data -> has_vid ) {
1779
1817
data -> vrm = vid_which_vrm ();
1780
1818
data -> groups [group_num ] = & vid_attr_group ;
@@ -1960,6 +1998,24 @@ static int adt7475_update_measure(struct device *dev)
1960
1998
((ext >> 4 ) & 3 );
1961
1999
}
1962
2000
2001
+ if (data -> has_voltage & (1 << 6 )) {
2002
+ ret = adt7475_read (REG_STATUS4 );
2003
+ if (ret < 0 )
2004
+ return ret ;
2005
+ data -> alarms |= ret << 24 ;
2006
+
2007
+ ret = adt7475_read (REG_EXTEND3 );
2008
+ if (ret < 0 )
2009
+ return ret ;
2010
+ ext = ret ;
2011
+
2012
+ ret = adt7475_read (REG_IMON );
2013
+ if (ret < 0 )
2014
+ return ret ;
2015
+ data -> voltage [INPUT ][6 ] = ret << 2 |
2016
+ ((ext >> 6 ) & 3 );
2017
+ }
2018
+
1963
2019
for (i = 0 ; i < ADT7475_TACH_COUNT ; i ++ ) {
1964
2020
if (i == 3 && !data -> has_fan4 )
1965
2021
continue ;
0 commit comments