1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Hardware monitoring driver for Analog Devices MAX17616/MAX17616A
4 *
5 * Copyright (C) 2025 Analog Devices, Inc.
6 */
7
8 #include <linux/err.h>
9 #include <linux/i2c.h>
10 #include <linux/module.h>
11
12 #include "pmbus.h"
13
14 static struct pmbus_driver_info max17616_info = {
15 .pages = 1,
16 .format[PSC_VOLTAGE_IN] = direct,
17 .m[PSC_VOLTAGE_IN] = 512,
18 .b[PSC_VOLTAGE_IN] = -18,
19 .R[PSC_VOLTAGE_IN] = -1,
20
21 .format[PSC_VOLTAGE_OUT] = direct,
22 .m[PSC_VOLTAGE_OUT] = 512,
23 .b[PSC_VOLTAGE_OUT] = -18,
24 .R[PSC_VOLTAGE_OUT] = -1,
25
26 .format[PSC_CURRENT_OUT] = direct,
27 .m[PSC_CURRENT_OUT] = 5845,
28 .b[PSC_CURRENT_OUT] = 80,
29 .R[PSC_CURRENT_OUT] = -1,
30
31 .format[PSC_TEMPERATURE] = direct,
32 .m[PSC_TEMPERATURE] = 71,
33 .b[PSC_TEMPERATURE] = 19653,
34 .R[PSC_TEMPERATURE] = -1,
35
36 .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT |
37 PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_VOUT |
38 PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_INPUT |
39 PMBUS_HAVE_STATUS_TEMP,
40 };
41
max17616_probe(struct i2c_client * client)42 static int max17616_probe(struct i2c_client *client)
43 {
44 return pmbus_do_probe(client, &max17616_info);
45 }
46
47 static const struct i2c_device_id max17616_id[] = {
48 { .name = "max17616" },
49 { }
50 };
51 MODULE_DEVICE_TABLE(i2c, max17616_id);
52
53 static const struct of_device_id max17616_of_match[] = {
54 { .compatible = "adi,max17616" },
55 { }
56 };
57 MODULE_DEVICE_TABLE(of, max17616_of_match);
58
59 static struct i2c_driver max17616_driver = {
60 .driver = {
61 .name = "max17616",
62 .of_match_table = max17616_of_match,
63 },
64 .probe = max17616_probe,
65 .id_table = max17616_id,
66 };
67 module_i2c_driver(max17616_driver);
68
69 MODULE_AUTHOR("Kim Seer Paller <kimseer.paller@analog.com>");
70 MODULE_DESCRIPTION("PMBus driver for Analog Devices MAX17616/MAX17616A");
71 MODULE_LICENSE("GPL");
72 MODULE_IMPORT_NS("PMBUS");
73