1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Hardware monitoring driver for Maxim MAX16064
5 * Copyright (c) 2011 Ericsson AB.
8 #include <linux/kernel.h>
9 #include <linux/module.h>
10 #include <linux/init.h>
11 #include <linux/err.h>
12 #include <linux/i2c.h>
15 #define MAX16064_MFR_VOUT_PEAK 0xd4
16 #define MAX16064_MFR_TEMPERATURE_PEAK 0xd6
18 static int max16064_read_word_data(struct i2c_client
*client
, int page
, int reg
)
23 case PMBUS_VIRT_READ_VOUT_MAX
:
24 ret
= pmbus_read_word_data(client
, page
,
25 MAX16064_MFR_VOUT_PEAK
);
27 case PMBUS_VIRT_READ_TEMP_MAX
:
28 ret
= pmbus_read_word_data(client
, page
,
29 MAX16064_MFR_TEMPERATURE_PEAK
);
31 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
32 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
42 static int max16064_write_word_data(struct i2c_client
*client
, int page
,
48 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
49 ret
= pmbus_write_word_data(client
, page
,
50 MAX16064_MFR_VOUT_PEAK
, 0);
52 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
53 ret
= pmbus_write_word_data(client
, page
,
54 MAX16064_MFR_TEMPERATURE_PEAK
,
64 static struct pmbus_driver_info max16064_info
= {
66 .format
[PSC_VOLTAGE_IN
] = direct
,
67 .format
[PSC_VOLTAGE_OUT
] = direct
,
68 .format
[PSC_TEMPERATURE
] = direct
,
69 .m
[PSC_VOLTAGE_IN
] = 19995,
70 .b
[PSC_VOLTAGE_IN
] = 0,
71 .R
[PSC_VOLTAGE_IN
] = -1,
72 .m
[PSC_VOLTAGE_OUT
] = 19995,
73 .b
[PSC_VOLTAGE_OUT
] = 0,
74 .R
[PSC_VOLTAGE_OUT
] = -1,
75 .m
[PSC_TEMPERATURE
] = -7612,
76 .b
[PSC_TEMPERATURE
] = 335,
77 .R
[PSC_TEMPERATURE
] = -3,
78 .func
[0] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_TEMP
79 | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_STATUS_TEMP
,
80 .func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
81 .func
[2] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
82 .func
[3] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
83 .read_word_data
= max16064_read_word_data
,
84 .write_word_data
= max16064_write_word_data
,
87 static int max16064_probe(struct i2c_client
*client
,
88 const struct i2c_device_id
*id
)
90 return pmbus_do_probe(client
, id
, &max16064_info
);
93 static const struct i2c_device_id max16064_id
[] = {
98 MODULE_DEVICE_TABLE(i2c
, max16064_id
);
100 /* This is the driver that will be inserted */
101 static struct i2c_driver max16064_driver
= {
105 .probe
= max16064_probe
,
106 .remove
= pmbus_do_remove
,
107 .id_table
= max16064_id
,
110 module_i2c_driver(max16064_driver
);
112 MODULE_AUTHOR("Guenter Roeck");
113 MODULE_DESCRIPTION("PMBus driver for Maxim MAX16064");
114 MODULE_LICENSE("GPL");