1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Hardware monitoring driver for Analog Devices MAX20860A 4 * 5 * SPDX-FileCopyrightText: Copyright Hewlett Packard Enterprise Development LP 6 */ 7 8 #include <linux/i2c.h> 9 #include <linux/module.h> 10 #include <linux/regulator/driver.h> 11 #include "pmbus.h" 12 13 #if IS_ENABLED(CONFIG_SENSORS_MAX20860A_REGULATOR) 14 static const struct regulator_desc max20860a_reg_desc[] = { 15 PMBUS_REGULATOR_ONE("vout"), 16 }; 17 #endif 18 19 static struct pmbus_driver_info max20860a_info = { 20 .pages = 1, 21 .format[PSC_VOLTAGE_IN] = linear, 22 .format[PSC_VOLTAGE_OUT] = linear, 23 .format[PSC_CURRENT_OUT] = linear, 24 .format[PSC_TEMPERATURE] = linear, 25 .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | 26 PMBUS_HAVE_STATUS_VOUT | 27 PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | 28 PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | 29 PMBUS_HAVE_STATUS_TEMP | PMBUS_HAVE_STATUS_INPUT, 30 #if IS_ENABLED(CONFIG_SENSORS_MAX20860A_REGULATOR) 31 .num_regulators = 1, 32 .reg_desc = max20860a_reg_desc, 33 #endif 34 }; 35 36 static int max20860a_probe(struct i2c_client *client) 37 { 38 return pmbus_do_probe(client, &max20860a_info); 39 } 40 41 static const struct i2c_device_id max20860a_id[] = { 42 {"max20860a"}, 43 {} 44 }; 45 MODULE_DEVICE_TABLE(i2c, max20860a_id); 46 47 static const struct of_device_id max20860a_of_match[] = { 48 { .compatible = "adi,max20860a" }, 49 {} 50 }; 51 MODULE_DEVICE_TABLE(of, max20860a_of_match); 52 53 static struct i2c_driver max20860a_driver = { 54 .driver = { 55 .name = "max20860a", 56 .of_match_table = max20860a_of_match, 57 }, 58 .probe = max20860a_probe, 59 .id_table = max20860a_id, 60 }; 61 62 module_i2c_driver(max20860a_driver); 63 64 MODULE_AUTHOR("Syed Arif <arif.syed@hpe.com>"); 65 MODULE_AUTHOR("Sanman Pradhan <psanman@juniper.net>"); 66 MODULE_DESCRIPTION("PMBus driver for Analog Devices MAX20860A"); 67 MODULE_LICENSE("GPL"); 68 MODULE_IMPORT_NS("PMBUS"); 69