xref: /linux/drivers/hwmon/pmbus/stef48h28.c (revision ff124bbbca1d3a07fa1392ffdbbdeece71f68ece)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Hardware monitoring driver for STMicroelectronics digital controller stef48h28
4  */
5 
6 #include <linux/err.h>
7 #include <linux/i2c.h>
8 #include <linux/mod_devicetable.h>
9 #include <linux/module.h>
10 
11 #include "pmbus.h"
12 
13 static struct pmbus_driver_info stef48h28_info = {
14 	.pages = 1,
15 	.format[PSC_VOLTAGE_IN] = direct,
16 	.format[PSC_VOLTAGE_OUT] = direct,
17 	.format[PSC_CURRENT_IN] = direct,
18 	.format[PSC_CURRENT_OUT] = direct,
19 	.format[PSC_POWER] = direct,
20 	.format[PSC_TEMPERATURE] = direct,
21 	.m[PSC_VOLTAGE_IN] = 50,
22 	.b[PSC_VOLTAGE_IN] = 0,
23 	.R[PSC_VOLTAGE_IN] = 0,
24 	.m[PSC_VOLTAGE_OUT] = 50,
25 	.b[PSC_VOLTAGE_OUT] = 0,
26 	.R[PSC_VOLTAGE_OUT] = 0,
27 	.m[PSC_CURRENT_IN] = 100,
28 	.b[PSC_CURRENT_IN] = 0,
29 	.R[PSC_CURRENT_IN] = 0,
30 	.m[PSC_CURRENT_OUT] = 100,
31 	.b[PSC_CURRENT_OUT] = 0,
32 	.R[PSC_CURRENT_OUT] = 0,
33 	.m[PSC_POWER] = 9765,
34 	.b[PSC_POWER] = 0,
35 	.R[PSC_POWER] = -3,
36 	.m[PSC_TEMPERATURE] = 25,
37 	.b[PSC_TEMPERATURE] = 500,
38 	.R[PSC_TEMPERATURE] = 0,
39 	.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN
40 		| PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
41 		| PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
42 		| PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT
43 };
44 
45 static int stef48h28_probe(struct i2c_client *client)
46 {
47 	return pmbus_do_probe(client, &stef48h28_info);
48 }
49 
50 static const struct i2c_device_id stef48h28_id[] = {
51 	{"stef48h28"},
52 	{}
53 };
54 MODULE_DEVICE_TABLE(i2c, stef48h28_id);
55 
56 static const struct of_device_id __maybe_unused stef48h28_of_match[] = {
57 	{.compatible = "st,stef48h28"},
58 	{}
59 };
60 
61 static struct i2c_driver stef48h28_driver = {
62 	.driver = {
63 			.name = "stef48h28",
64 			.of_match_table = of_match_ptr(stef48h28_of_match),
65 			},
66 	.probe = stef48h28_probe,
67 	.id_table = stef48h28_id,
68 };
69 
70 module_i2c_driver(stef48h28_driver);
71 
72 MODULE_AUTHOR("Charles Hsu <hsu.yungteng@gmail.com>");
73 MODULE_DESCRIPTION("PMBus driver for ST stef48h28");
74 MODULE_LICENSE("GPL");
75 MODULE_IMPORT_NS("PMBUS");
76