@@ -955,14 +955,25 @@ static const u16 scale_in[15] = {
955955 800 , 800
956956};
957957
958- static inline long in_from_reg (u8 reg , u8 nr )
958+ /*
959+ * NCT6798 scaling:
960+ * CPUVC, IN1, AVSB, 3VCC, IN0, IN8, IN4, 3VSB, VBAT, VTT, IN5, IN6, IN2,
961+ * IN3, IN7
962+ * Additional scales to be added later: IN9 (800), VHIF (1600)
963+ */
964+ static const u16 scale_in_6798 [15 ] = {
965+ 800 , 800 , 1600 , 1600 , 800 , 800 , 800 , 1600 , 1600 , 1600 , 1600 , 1600 , 800 ,
966+ 800 , 800
967+ };
968+
969+ static inline long in_from_reg (u8 reg , u8 nr , const u16 * scales )
959970{
960- return DIV_ROUND_CLOSEST (reg * scale_in [nr ], 100 );
971+ return DIV_ROUND_CLOSEST (reg * scales [nr ], 100 );
961972}
962973
963- static inline u8 in_to_reg (u32 val , u8 nr )
974+ static inline u8 in_to_reg (u32 val , u8 nr , const u16 * scales )
964975{
965- return clamp_val (DIV_ROUND_CLOSEST (val * 100 , scale_in [nr ]), 0 , 255 );
976+ return clamp_val (DIV_ROUND_CLOSEST (val * 100 , scales [nr ]), 0 , 255 );
966977}
967978
968979/* TSI temperatures are in 8.3 format */
@@ -1673,7 +1684,8 @@ show_in_reg(struct device *dev, struct device_attribute *attr, char *buf)
16731684 if (IS_ERR (data ))
16741685 return PTR_ERR (data );
16751686
1676- return sprintf (buf , "%ld\n" , in_from_reg (data -> in [nr ][index ], nr ));
1687+ return sprintf (buf , "%ld\n" ,
1688+ in_from_reg (data -> in [nr ][index ], nr , data -> scale_in ));
16771689}
16781690
16791691static ssize_t
@@ -1691,7 +1703,7 @@ store_in_reg(struct device *dev, struct device_attribute *attr, const char *buf,
16911703 if (err < 0 )
16921704 return err ;
16931705 mutex_lock (& data -> update_lock );
1694- data -> in [nr ][index ] = in_to_reg (val , nr );
1706+ data -> in [nr ][index ] = in_to_reg (val , nr , data -> scale_in );
16951707 err = nct6775_write_value (data , data -> REG_IN_MINMAX [index - 1 ][nr ], data -> in [nr ][index ]);
16961708 mutex_unlock (& data -> update_lock );
16971709 return err ? : count ;
@@ -3462,6 +3474,7 @@ int nct6775_probe(struct device *dev, struct nct6775_data *data,
34623474 mutex_init (& data -> update_lock );
34633475 data -> name = nct6775_device_names [data -> kind ];
34643476 data -> bank = 0xff ; /* Force initial bank selection */
3477+ data -> scale_in = scale_in ;
34653478
34663479 switch (data -> kind ) {
34673480 case nct6106 :
@@ -3977,6 +3990,9 @@ int nct6775_probe(struct device *dev, struct nct6775_data *data,
39773990 break ;
39783991 }
39793992
3993+ if (data -> kind == nct6798 || data -> kind == nct6799 )
3994+ data -> scale_in = scale_in_6798 ;
3995+
39803996 reg_temp = NCT6779_REG_TEMP ;
39813997 num_reg_temp = ARRAY_SIZE (NCT6779_REG_TEMP );
39823998 if (data -> kind == nct6791 ) {
0 commit comments