xref: /linux/drivers/hwmon/pmbus/ir38064.c (revision 00669d196c616c0a9970a3a9ee66efab6868df0c)
1*00669d19SMaxim Sloyko // SPDX-License-Identifier: GPL-2.0+
2*00669d19SMaxim Sloyko /*
3*00669d19SMaxim Sloyko  * Hardware monitoring driver for Infineon IR38064
4*00669d19SMaxim Sloyko  *
5*00669d19SMaxim Sloyko  * Copyright (c) 2017 Google Inc
6*00669d19SMaxim Sloyko  *
7*00669d19SMaxim Sloyko  * VOUT_MODE is not supported by the device. The driver fakes VOUT linear16
8*00669d19SMaxim Sloyko  * mode with exponent value -8 as direct mode with m=256/b=0/R=0.
9*00669d19SMaxim Sloyko  *
10*00669d19SMaxim Sloyko  * The device supports VOUT_PEAK, IOUT_PEAK, and TEMPERATURE_PEAK, however
11*00669d19SMaxim Sloyko  * this driver does not currently support them.
12*00669d19SMaxim Sloyko  */
13*00669d19SMaxim Sloyko 
14*00669d19SMaxim Sloyko #include <linux/err.h>
15*00669d19SMaxim Sloyko #include <linux/i2c.h>
16*00669d19SMaxim Sloyko #include <linux/init.h>
17*00669d19SMaxim Sloyko #include <linux/kernel.h>
18*00669d19SMaxim Sloyko #include <linux/module.h>
19*00669d19SMaxim Sloyko #include "pmbus.h"
20*00669d19SMaxim Sloyko 
21*00669d19SMaxim Sloyko static struct pmbus_driver_info ir38064_info = {
22*00669d19SMaxim Sloyko 	.pages = 1,
23*00669d19SMaxim Sloyko 	.format[PSC_VOLTAGE_IN] = linear,
24*00669d19SMaxim Sloyko 	.format[PSC_VOLTAGE_OUT] = direct,
25*00669d19SMaxim Sloyko 	.format[PSC_CURRENT_OUT] = linear,
26*00669d19SMaxim Sloyko 	.format[PSC_POWER] = linear,
27*00669d19SMaxim Sloyko 	.format[PSC_TEMPERATURE] = linear,
28*00669d19SMaxim Sloyko 	.m[PSC_VOLTAGE_OUT] = 256,
29*00669d19SMaxim Sloyko 	.b[PSC_VOLTAGE_OUT] = 0,
30*00669d19SMaxim Sloyko 	.R[PSC_VOLTAGE_OUT] = 0,
31*00669d19SMaxim Sloyko 	.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
32*00669d19SMaxim Sloyko 	    | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
33*00669d19SMaxim Sloyko 	    | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
34*00669d19SMaxim Sloyko 	    | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
35*00669d19SMaxim Sloyko 	    | PMBUS_HAVE_POUT,
36*00669d19SMaxim Sloyko };
37*00669d19SMaxim Sloyko 
38*00669d19SMaxim Sloyko static int ir38064_probe(struct i2c_client *client,
39*00669d19SMaxim Sloyko 			 const struct i2c_device_id *id)
40*00669d19SMaxim Sloyko {
41*00669d19SMaxim Sloyko 	return pmbus_do_probe(client, id, &ir38064_info);
42*00669d19SMaxim Sloyko }
43*00669d19SMaxim Sloyko 
44*00669d19SMaxim Sloyko static const struct i2c_device_id ir38064_id[] = {
45*00669d19SMaxim Sloyko 	{"ir38064", 0},
46*00669d19SMaxim Sloyko 	{}
47*00669d19SMaxim Sloyko };
48*00669d19SMaxim Sloyko 
49*00669d19SMaxim Sloyko MODULE_DEVICE_TABLE(i2c, ir38064_id);
50*00669d19SMaxim Sloyko 
51*00669d19SMaxim Sloyko /* This is the driver that will be inserted */
52*00669d19SMaxim Sloyko static struct i2c_driver ir38064_driver = {
53*00669d19SMaxim Sloyko 	.driver = {
54*00669d19SMaxim Sloyko 		   .name = "ir38064",
55*00669d19SMaxim Sloyko 		   },
56*00669d19SMaxim Sloyko 	.probe = ir38064_probe,
57*00669d19SMaxim Sloyko 	.remove = pmbus_do_remove,
58*00669d19SMaxim Sloyko 	.id_table = ir38064_id,
59*00669d19SMaxim Sloyko };
60*00669d19SMaxim Sloyko 
61*00669d19SMaxim Sloyko module_i2c_driver(ir38064_driver);
62*00669d19SMaxim Sloyko 
63*00669d19SMaxim Sloyko MODULE_AUTHOR("Maxim Sloyko <maxims@google.com>");
64*00669d19SMaxim Sloyko MODULE_DESCRIPTION("PMBus driver for Infineon IR38064");
65*00669d19SMaxim Sloyko MODULE_LICENSE("GPL");
66