Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Driver for MPS MP5023 Hot-Swap Controller
0004  */
0005 
0006 #include <linux/i2c.h>
0007 #include <linux/module.h>
0008 #include <linux/of_device.h>
0009 #include "pmbus.h"
0010 
0011 static struct pmbus_driver_info mp5023_info = {
0012     .pages = 1,
0013 
0014     .format[PSC_VOLTAGE_IN] = direct,
0015     .format[PSC_VOLTAGE_OUT] = direct,
0016     .format[PSC_CURRENT_OUT] = direct,
0017     .format[PSC_POWER] = direct,
0018     .format[PSC_TEMPERATURE] = direct,
0019 
0020     .m[PSC_VOLTAGE_IN] = 32,
0021     .b[PSC_VOLTAGE_IN] = 0,
0022     .R[PSC_VOLTAGE_IN] = 0,
0023     .m[PSC_VOLTAGE_OUT] = 32,
0024     .b[PSC_VOLTAGE_OUT] = 0,
0025     .R[PSC_VOLTAGE_OUT] = 0,
0026     .m[PSC_CURRENT_OUT] = 16,
0027     .b[PSC_CURRENT_OUT] = 0,
0028     .R[PSC_CURRENT_OUT] = 0,
0029     .m[PSC_POWER] = 1,
0030     .b[PSC_POWER] = 0,
0031     .R[PSC_POWER] = 0,
0032     .m[PSC_TEMPERATURE] = 2,
0033     .b[PSC_TEMPERATURE] = 0,
0034     .R[PSC_TEMPERATURE] = 0,
0035 
0036     .func[0] =
0037         PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_PIN |
0038         PMBUS_HAVE_TEMP | PMBUS_HAVE_IOUT |
0039         PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP,
0040 };
0041 
0042 static int mp5023_probe(struct i2c_client *client)
0043 {
0044     return pmbus_do_probe(client, &mp5023_info);
0045 }
0046 
0047 static const struct of_device_id __maybe_unused mp5023_of_match[] = {
0048     { .compatible = "mps,mp5023", },
0049     {}
0050 };
0051 
0052 MODULE_DEVICE_TABLE(of, mp5023_of_match);
0053 
0054 static struct i2c_driver mp5023_driver = {
0055     .driver = {
0056            .name = "mp5023",
0057            .of_match_table = of_match_ptr(mp5023_of_match),
0058     },
0059     .probe_new = mp5023_probe,
0060 };
0061 
0062 module_i2c_driver(mp5023_driver);
0063 
0064 MODULE_AUTHOR("Howard Chiu <howard.chiu@quantatw.com>");
0065 MODULE_DESCRIPTION("PMBus driver for MPS MP5023 HSC");
0066 MODULE_LICENSE("GPL");
0067 MODULE_IMPORT_NS(PMBUS);