xref: /linux/drivers/hwmon/pmbus/xdpe152c4.c (revision 621cde16e49b3ecf7d59a8106a20aaebfb4a59a9)
19054416aSGreg.Schwendimann@infineon.com // SPDX-License-Identifier: GPL-2.0-or-later
29054416aSGreg.Schwendimann@infineon.com /*
39054416aSGreg.Schwendimann@infineon.com  * Hardware monitoring driver for Infineon Multi-phase Digital VR Controllers
49054416aSGreg.Schwendimann@infineon.com  *
59054416aSGreg.Schwendimann@infineon.com  * Copyright (c) 2022 Infineon Technologies. All rights reserved.
69054416aSGreg.Schwendimann@infineon.com  */
79054416aSGreg.Schwendimann@infineon.com 
89054416aSGreg.Schwendimann@infineon.com #include <linux/err.h>
99054416aSGreg.Schwendimann@infineon.com #include <linux/i2c.h>
109054416aSGreg.Schwendimann@infineon.com #include <linux/init.h>
119054416aSGreg.Schwendimann@infineon.com #include <linux/kernel.h>
129054416aSGreg.Schwendimann@infineon.com #include <linux/module.h>
139054416aSGreg.Schwendimann@infineon.com #include "pmbus.h"
149054416aSGreg.Schwendimann@infineon.com 
159054416aSGreg.Schwendimann@infineon.com #define XDPE152_PAGE_NUM 2
169054416aSGreg.Schwendimann@infineon.com 
179054416aSGreg.Schwendimann@infineon.com static struct pmbus_driver_info xdpe152_info = {
189054416aSGreg.Schwendimann@infineon.com 	.pages = XDPE152_PAGE_NUM,
199054416aSGreg.Schwendimann@infineon.com 	.format[PSC_VOLTAGE_IN] = linear,
209054416aSGreg.Schwendimann@infineon.com 	.format[PSC_VOLTAGE_OUT] = linear,
219054416aSGreg.Schwendimann@infineon.com 	.format[PSC_TEMPERATURE] = linear,
229054416aSGreg.Schwendimann@infineon.com 	.format[PSC_CURRENT_IN] = linear,
239054416aSGreg.Schwendimann@infineon.com 	.format[PSC_CURRENT_OUT] = linear,
249054416aSGreg.Schwendimann@infineon.com 	.format[PSC_POWER] = linear,
259054416aSGreg.Schwendimann@infineon.com 	.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
269054416aSGreg.Schwendimann@infineon.com 		PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
279054416aSGreg.Schwendimann@infineon.com 		PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP |
289054416aSGreg.Schwendimann@infineon.com 		PMBUS_HAVE_POUT | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
299054416aSGreg.Schwendimann@infineon.com 	.func[1] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
309054416aSGreg.Schwendimann@infineon.com 		PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
319054416aSGreg.Schwendimann@infineon.com 		PMBUS_HAVE_POUT | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
329054416aSGreg.Schwendimann@infineon.com };
339054416aSGreg.Schwendimann@infineon.com 
xdpe152_probe(struct i2c_client * client)349054416aSGreg.Schwendimann@infineon.com static int xdpe152_probe(struct i2c_client *client)
359054416aSGreg.Schwendimann@infineon.com {
369054416aSGreg.Schwendimann@infineon.com 	struct pmbus_driver_info *info;
379054416aSGreg.Schwendimann@infineon.com 
389054416aSGreg.Schwendimann@infineon.com 	info = devm_kmemdup(&client->dev, &xdpe152_info, sizeof(*info),
399054416aSGreg.Schwendimann@infineon.com 			    GFP_KERNEL);
409054416aSGreg.Schwendimann@infineon.com 	if (!info)
419054416aSGreg.Schwendimann@infineon.com 		return -ENOMEM;
429054416aSGreg.Schwendimann@infineon.com 
439054416aSGreg.Schwendimann@infineon.com 	return pmbus_do_probe(client, info);
449054416aSGreg.Schwendimann@infineon.com }
459054416aSGreg.Schwendimann@infineon.com 
469054416aSGreg.Schwendimann@infineon.com static const struct i2c_device_id xdpe152_id[] = {
47*d8a66f36SUwe Kleine-König 	{"xdpe152c4"},
48*d8a66f36SUwe Kleine-König 	{"xdpe15284"},
499054416aSGreg.Schwendimann@infineon.com 	{}
509054416aSGreg.Schwendimann@infineon.com };
519054416aSGreg.Schwendimann@infineon.com 
529054416aSGreg.Schwendimann@infineon.com MODULE_DEVICE_TABLE(i2c, xdpe152_id);
539054416aSGreg.Schwendimann@infineon.com 
549054416aSGreg.Schwendimann@infineon.com static const struct of_device_id __maybe_unused xdpe152_of_match[] = {
559054416aSGreg.Schwendimann@infineon.com 	{.compatible = "infineon,xdpe152c4"},
569054416aSGreg.Schwendimann@infineon.com 	{.compatible = "infineon,xdpe15284"},
579054416aSGreg.Schwendimann@infineon.com 	{}
589054416aSGreg.Schwendimann@infineon.com };
599054416aSGreg.Schwendimann@infineon.com MODULE_DEVICE_TABLE(of, xdpe152_of_match);
609054416aSGreg.Schwendimann@infineon.com 
619054416aSGreg.Schwendimann@infineon.com static struct i2c_driver xdpe152_driver = {
629054416aSGreg.Schwendimann@infineon.com 	.driver = {
639054416aSGreg.Schwendimann@infineon.com 		.name = "xdpe152c4",
649054416aSGreg.Schwendimann@infineon.com 		.of_match_table = of_match_ptr(xdpe152_of_match),
659054416aSGreg.Schwendimann@infineon.com 	},
661975d167SUwe Kleine-König 	.probe = xdpe152_probe,
679054416aSGreg.Schwendimann@infineon.com 	.id_table = xdpe152_id,
689054416aSGreg.Schwendimann@infineon.com };
699054416aSGreg.Schwendimann@infineon.com 
709054416aSGreg.Schwendimann@infineon.com module_i2c_driver(xdpe152_driver);
719054416aSGreg.Schwendimann@infineon.com 
729054416aSGreg.Schwendimann@infineon.com MODULE_AUTHOR("Greg Schwendimann <greg.schwendimann@infineon.com>");
739054416aSGreg.Schwendimann@infineon.com MODULE_DESCRIPTION("PMBus driver for Infineon XDPE152 family");
749054416aSGreg.Schwendimann@infineon.com MODULE_LICENSE("GPL");
759054416aSGreg.Schwendimann@infineon.com MODULE_IMPORT_NS(PMBUS);
76