xref: /linux/drivers/hwmon/pmbus/adp1050.c (revision 04f175954daee54e7c50dd831ee15e8a36fe5648)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Hardware monitoring driver for Analog Devices ADP1050
4  *
5  * Copyright (C) 2024 Analog Devices, Inc.
6  */
7 #include <linux/bits.h>
8 #include <linux/err.h>
9 #include <linux/i2c.h>
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/of.h>
14 #include "pmbus.h"
15 
16 static struct pmbus_driver_info adp1050_info = {
17 	.pages = 1,
18 	.format[PSC_VOLTAGE_IN] = linear,
19 	.format[PSC_VOLTAGE_OUT] = linear,
20 	.format[PSC_CURRENT_IN] = linear,
21 	.format[PSC_TEMPERATURE] = linear,
22 	.func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
23 		| PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
24 		| PMBUS_HAVE_IIN | PMBUS_HAVE_TEMP
25 		| PMBUS_HAVE_STATUS_TEMP,
26 };
27 
28 static int adp1050_probe(struct i2c_client *client)
29 {
30 	return pmbus_do_probe(client, &adp1050_info);
31 }
32 
33 static const struct i2c_device_id adp1050_id[] = {
34 	{"adp1050", 0},
35 	{}
36 };
37 MODULE_DEVICE_TABLE(i2c, adp1050_id);
38 
39 static const struct of_device_id adp1050_of_match[] = {
40 	{ .compatible = "adi,adp1050"},
41 	{}
42 };
43 MODULE_DEVICE_TABLE(of, adp1050_of_match);
44 
45 static struct i2c_driver adp1050_driver = {
46 	.driver = {
47 		.name = "adp1050",
48 		.of_match_table = adp1050_of_match,
49 	},
50 	.probe = adp1050_probe,
51 	.id_table = adp1050_id,
52 };
53 module_i2c_driver(adp1050_driver);
54 
55 MODULE_AUTHOR("Radu Sabau <radu.sabau@analog.com>");
56 MODULE_DESCRIPTION("Analog Devices ADP1050 HWMON PMBus Driver");
57 MODULE_LICENSE("GPL");
58 MODULE_IMPORT_NS(PMBUS);
59