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