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
,
24 case PMBUS_VIRT_READ_VOUT_MAX
:
25 ret
= pmbus_read_word_data(client
, page
, phase
,
26 MAX16064_MFR_VOUT_PEAK
);
28 case PMBUS_VIRT_READ_TEMP_MAX
:
29 ret
= pmbus_read_word_data(client
, page
, phase
,
30 MAX16064_MFR_TEMPERATURE_PEAK
);
32 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
33 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
43 static int max16064_write_word_data(struct i2c_client
*client
, int page
,
49 case PMBUS_VIRT_RESET_VOUT_HISTORY
:
50 ret
= pmbus_write_word_data(client
, page
,
51 MAX16064_MFR_VOUT_PEAK
, 0);
53 case PMBUS_VIRT_RESET_TEMP_HISTORY
:
54 ret
= pmbus_write_word_data(client
, page
,
55 MAX16064_MFR_TEMPERATURE_PEAK
,
65 static struct pmbus_driver_info max16064_info
= {
67 .format
[PSC_VOLTAGE_IN
] = direct
,
68 .format
[PSC_VOLTAGE_OUT
] = direct
,
69 .format
[PSC_TEMPERATURE
] = direct
,
70 .m
[PSC_VOLTAGE_IN
] = 19995,
71 .b
[PSC_VOLTAGE_IN
] = 0,
72 .R
[PSC_VOLTAGE_IN
] = -1,
73 .m
[PSC_VOLTAGE_OUT
] = 19995,
74 .b
[PSC_VOLTAGE_OUT
] = 0,
75 .R
[PSC_VOLTAGE_OUT
] = -1,
76 .m
[PSC_TEMPERATURE
] = -7612,
77 .b
[PSC_TEMPERATURE
] = 335,
78 .R
[PSC_TEMPERATURE
] = -3,
79 .func
[0] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_TEMP
80 | PMBUS_HAVE_STATUS_VOUT
| PMBUS_HAVE_STATUS_TEMP
,
81 .func
[1] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
82 .func
[2] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
83 .func
[3] = PMBUS_HAVE_VOUT
| PMBUS_HAVE_STATUS_VOUT
,
84 .read_word_data
= max16064_read_word_data
,
85 .write_word_data
= max16064_write_word_data
,
88 static int max16064_probe(struct i2c_client
*client
)
90 return pmbus_do_probe(client
, &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 .id_table
= max16064_id
,
109 module_i2c_driver(max16064_driver
);
111 MODULE_AUTHOR("Guenter Roeck");
112 MODULE_DESCRIPTION("PMBus driver for Maxim MAX16064");
113 MODULE_LICENSE("GPL");
114 MODULE_IMPORT_NS("PMBUS");