1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Hardware monitoring driver for Texas Instruments TPS53679
5 * Copyright (c) 2017 Mellanox Technologies. All rights reserved.
6 * Copyright (c) 2017 Vadim Pasternak <vadimp@mellanox.com>
10 #include <linux/i2c.h>
11 #include <linux/init.h>
12 #include <linux/kernel.h>
13 #include <linux/module.h>
16 #define TPS53679_PROT_VR12_5MV 0x01 /* VR12.0 mode, 5-mV DAC */
17 #define TPS53679_PROT_VR12_5_10MV 0x02 /* VR12.5 mode, 10-mV DAC */
18 #define TPS53679_PROT_VR13_10MV 0x04 /* VR13.0 mode, 10-mV DAC */
19 #define TPS53679_PROT_IMVP8_5MV 0x05 /* IMVP8 mode, 5-mV DAC */
20 #define TPS53679_PROT_VR13_5MV 0x07 /* VR13.0 mode, 5-mV DAC */
21 #define TPS53679_PAGE_NUM 2
23 static int tps53679_identify(struct i2c_client *client,
24 struct pmbus_driver_info *info)
29 /* Read the register with VOUT scaling value.*/
30 ret = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE);
34 vout_params = ret & GENMASK(4, 0);
36 switch (vout_params) {
37 case TPS53679_PROT_VR13_10MV:
38 case TPS53679_PROT_VR12_5_10MV:
39 info->vrm_version = vr13;
41 case TPS53679_PROT_VR13_5MV:
42 case TPS53679_PROT_VR12_5MV:
43 case TPS53679_PROT_IMVP8_5MV:
44 info->vrm_version = vr12;
53 static struct pmbus_driver_info tps53679_info = {
54 .pages = TPS53679_PAGE_NUM,
55 .format[PSC_VOLTAGE_IN] = linear,
56 .format[PSC_VOLTAGE_OUT] = vid,
57 .format[PSC_TEMPERATURE] = linear,
58 .format[PSC_CURRENT_OUT] = linear,
59 .format[PSC_POWER] = linear,
60 .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
61 PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
62 PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
64 .func[1] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
65 PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
66 PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP |
68 .identify = tps53679_identify,
71 static int tps53679_probe(struct i2c_client *client,
72 const struct i2c_device_id *id)
74 struct pmbus_driver_info *info;
76 info = devm_kmemdup(&client->dev, &tps53679_info, sizeof(*info),
81 return pmbus_do_probe(client, id, info);
84 static const struct i2c_device_id tps53679_id[] = {
89 MODULE_DEVICE_TABLE(i2c, tps53679_id);
91 static const struct of_device_id __maybe_unused tps53679_of_match[] = {
92 {.compatible = "ti,tps53679"},
95 MODULE_DEVICE_TABLE(of, tps53679_of_match);
97 static struct i2c_driver tps53679_driver = {
100 .of_match_table = of_match_ptr(tps53679_of_match),
102 .probe = tps53679_probe,
103 .remove = pmbus_do_remove,
104 .id_table = tps53679_id,
107 module_i2c_driver(tps53679_driver);
109 MODULE_AUTHOR("Vadim Pasternak <vadimp@mellanox.com>");
110 MODULE_DESCRIPTION("PMBus driver for Texas Instruments TPS53679");
111 MODULE_LICENSE("GPL");