13
13
#include <linux/jiffies.h>
14
14
#include <linux/module.h>
15
15
#include <linux/slab.h>
16
+ #include <linux/property.h>
16
17
17
18
/* MAX31790 registers */
18
19
#define MAX31790_REG_GLOBAL_CONFIG 0x00
@@ -65,6 +66,7 @@ struct max31790_data {
65
66
u16 tach [NR_CHANNEL * 2 ];
66
67
u16 pwm [NR_CHANNEL ];
67
68
u16 target_count [NR_CHANNEL ];
69
+ u32 mode [NR_CHANNEL ];
68
70
};
69
71
70
72
static struct max31790_data * max31790_update_device (struct device * dev )
@@ -96,7 +98,6 @@ static struct max31790_data *max31790_update_device(struct device *dev)
96
98
if (rv < 0 )
97
99
goto abort ;
98
100
data -> tach [i ] = rv ;
99
-
100
101
if (data -> fan_config [i ]
101
102
& MAX31790_FAN_CFG_TACH_INPUT ) {
102
103
rv = i2c_smbus_read_word_swapped (client ,
@@ -490,6 +491,13 @@ static int max31790_init_client(struct i2c_client *client,
490
491
MAX31790_REG_FAN_CONFIG (i ));
491
492
if (rv < 0 )
492
493
return rv ;
494
+
495
+ if (data -> mode [i ]) {
496
+ rv |= MAX31790_FAN_CFG_TACH_INPUT ;
497
+ } else {
498
+ rv &= ~(MAX31790_FAN_CFG_TACH_INPUT );
499
+ }
500
+
493
501
data -> fan_config [i ] = rv ;
494
502
495
503
rv = i2c_smbus_read_byte_data (client ,
@@ -509,6 +517,7 @@ static int max31790_probe(struct i2c_client *client)
509
517
struct max31790_data * data ;
510
518
struct device * hwmon_dev ;
511
519
int err ;
520
+ int i ;
512
521
513
522
if (!i2c_check_functionality (adapter ,
514
523
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA ))
@@ -521,6 +530,16 @@ static int max31790_probe(struct i2c_client *client)
521
530
data -> client = client ;
522
531
mutex_init (& data -> update_lock );
523
532
533
+ if (device_property_present (dev ,"pwm-to-tach" )) {
534
+ err = device_property_read_u32_array (dev ,"pwm-to-tach" ,data -> mode ,NR_CHANNEL );
535
+ if (err < 0 )
536
+ return err ;
537
+ } else {
538
+ for (i = 0 ; i < NR_CHANNEL ; i ++ ) {
539
+ data -> mode [i ]= 0 ;
540
+ }
541
+ }
542
+
524
543
/*
525
544
* Initialize the max31790 chip
526
545
*/
0 commit comments