104f17595SRadu Sabau // SPDX-License-Identifier: GPL-2.0
204f17595SRadu Sabau /*
304f17595SRadu Sabau * Hardware monitoring driver for Analog Devices ADP1050
404f17595SRadu Sabau *
504f17595SRadu Sabau * Copyright (C) 2024 Analog Devices, Inc.
604f17595SRadu Sabau */
704f17595SRadu Sabau #include <linux/bits.h>
804f17595SRadu Sabau #include <linux/i2c.h>
99c379362SAndy Shevchenko #include <linux/mod_devicetable.h>
1004f17595SRadu Sabau #include <linux/module.h>
119c379362SAndy Shevchenko
1204f17595SRadu Sabau #include "pmbus.h"
1304f17595SRadu Sabau
1404f17595SRadu Sabau static struct pmbus_driver_info adp1050_info = {
1504f17595SRadu Sabau .pages = 1,
1604f17595SRadu Sabau .format[PSC_VOLTAGE_IN] = linear,
1704f17595SRadu Sabau .format[PSC_VOLTAGE_OUT] = linear,
1804f17595SRadu Sabau .format[PSC_CURRENT_IN] = linear,
1904f17595SRadu Sabau .format[PSC_TEMPERATURE] = linear,
2004f17595SRadu Sabau .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
2104f17595SRadu Sabau | PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
2204f17595SRadu Sabau | PMBUS_HAVE_IIN | PMBUS_HAVE_TEMP
2304f17595SRadu Sabau | PMBUS_HAVE_STATUS_TEMP,
2404f17595SRadu Sabau };
2504f17595SRadu Sabau
adp1050_probe(struct i2c_client * client)2604f17595SRadu Sabau static int adp1050_probe(struct i2c_client *client)
2704f17595SRadu Sabau {
2804f17595SRadu Sabau return pmbus_do_probe(client, &adp1050_info);
2904f17595SRadu Sabau }
3004f17595SRadu Sabau
3104f17595SRadu Sabau static const struct i2c_device_id adp1050_id[] = {
32*d8a66f36SUwe Kleine-König {"adp1050"},
3304f17595SRadu Sabau {}
3404f17595SRadu Sabau };
3504f17595SRadu Sabau MODULE_DEVICE_TABLE(i2c, adp1050_id);
3604f17595SRadu Sabau
3704f17595SRadu Sabau static const struct of_device_id adp1050_of_match[] = {
3804f17595SRadu Sabau { .compatible = "adi,adp1050"},
3904f17595SRadu Sabau {}
4004f17595SRadu Sabau };
4104f17595SRadu Sabau MODULE_DEVICE_TABLE(of, adp1050_of_match);
4204f17595SRadu Sabau
4304f17595SRadu Sabau static struct i2c_driver adp1050_driver = {
4404f17595SRadu Sabau .driver = {
4504f17595SRadu Sabau .name = "adp1050",
4604f17595SRadu Sabau .of_match_table = adp1050_of_match,
4704f17595SRadu Sabau },
4804f17595SRadu Sabau .probe = adp1050_probe,
4904f17595SRadu Sabau .id_table = adp1050_id,
5004f17595SRadu Sabau };
5104f17595SRadu Sabau module_i2c_driver(adp1050_driver);
5204f17595SRadu Sabau
5304f17595SRadu Sabau MODULE_AUTHOR("Radu Sabau <radu.sabau@analog.com>");
5404f17595SRadu Sabau MODULE_DESCRIPTION("Analog Devices ADP1050 HWMON PMBus Driver");
5504f17595SRadu Sabau MODULE_LICENSE("GPL");
5604f17595SRadu Sabau MODULE_IMPORT_NS(PMBUS);
57