xref: /openbmc/linux/drivers/hwmon/pmbus/irps5401.c (revision 55fd7e02)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Hardware monitoring driver for the Infineon IRPS5401M PMIC.
4  *
5  * Copyright (c) 2019 SED Systems, a division of Calian Ltd.
6  *
7  * The device supports VOUT_PEAK, IOUT_PEAK, and TEMPERATURE_PEAK, however
8  * this driver does not currently support them.
9  */
10 
11 #include <linux/err.h>
12 #include <linux/i2c.h>
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include "pmbus.h"
17 
18 #define IRPS5401_SW_FUNC (PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | \
19 			  PMBUS_HAVE_STATUS_INPUT | \
20 			  PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | \
21 			  PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | \
22 			  PMBUS_HAVE_PIN | PMBUS_HAVE_POUT | \
23 			  PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP)
24 
25 #define IRPS5401_LDO_FUNC (PMBUS_HAVE_VIN | \
26 			   PMBUS_HAVE_STATUS_INPUT | \
27 			   PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | \
28 			   PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | \
29 			   PMBUS_HAVE_PIN | PMBUS_HAVE_POUT | \
30 			   PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP)
31 
32 static struct pmbus_driver_info irps5401_info = {
33 	.pages = 5,
34 	.func[0] = IRPS5401_SW_FUNC,
35 	.func[1] = IRPS5401_SW_FUNC,
36 	.func[2] = IRPS5401_SW_FUNC,
37 	.func[3] = IRPS5401_SW_FUNC,
38 	.func[4] = IRPS5401_LDO_FUNC,
39 };
40 
41 static int irps5401_probe(struct i2c_client *client,
42 			  const struct i2c_device_id *id)
43 {
44 	return pmbus_do_probe(client, id, &irps5401_info);
45 }
46 
47 static const struct i2c_device_id irps5401_id[] = {
48 	{"irps5401", 0},
49 	{}
50 };
51 
52 MODULE_DEVICE_TABLE(i2c, irps5401_id);
53 
54 static struct i2c_driver irps5401_driver = {
55 	.driver = {
56 		   .name = "irps5401",
57 		   },
58 	.probe = irps5401_probe,
59 	.remove = pmbus_do_remove,
60 	.id_table = irps5401_id,
61 };
62 
63 module_i2c_driver(irps5401_driver);
64 
65 MODULE_AUTHOR("Robert Hancock");
66 MODULE_DESCRIPTION("PMBus driver for Infineon IRPS5401");
67 MODULE_LICENSE("GPL");
68