0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/err.h>
0009 #include <linux/i2c.h>
0010 #include <linux/init.h>
0011 #include <linux/kernel.h>
0012 #include <linux/module.h>
0013 #include "pmbus.h"
0014
0015 #define XDPE152_PAGE_NUM 2
0016
0017 static struct pmbus_driver_info xdpe152_info = {
0018 .pages = XDPE152_PAGE_NUM,
0019 .format[PSC_VOLTAGE_IN] = linear,
0020 .format[PSC_VOLTAGE_OUT] = linear,
0021 .format[PSC_TEMPERATURE] = linear,
0022 .format[PSC_CURRENT_IN] = linear,
0023 .format[PSC_CURRENT_OUT] = linear,
0024 .format[PSC_POWER] = linear,
0025 .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
0026 PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
0027 PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_STATUS_TEMP |
0028 PMBUS_HAVE_POUT | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
0029 .func[1] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
0030 PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
0031 PMBUS_HAVE_POUT | PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT,
0032 };
0033
0034 static int xdpe152_probe(struct i2c_client *client)
0035 {
0036 struct pmbus_driver_info *info;
0037
0038 info = devm_kmemdup(&client->dev, &xdpe152_info, sizeof(*info),
0039 GFP_KERNEL);
0040 if (!info)
0041 return -ENOMEM;
0042
0043 return pmbus_do_probe(client, info);
0044 }
0045
0046 static const struct i2c_device_id xdpe152_id[] = {
0047 {"xdpe152c4", 0},
0048 {"xdpe15284", 0},
0049 {}
0050 };
0051
0052 MODULE_DEVICE_TABLE(i2c, xdpe152_id);
0053
0054 static const struct of_device_id __maybe_unused xdpe152_of_match[] = {
0055 {.compatible = "infineon,xdpe152c4"},
0056 {.compatible = "infineon,xdpe15284"},
0057 {}
0058 };
0059 MODULE_DEVICE_TABLE(of, xdpe152_of_match);
0060
0061 static struct i2c_driver xdpe152_driver = {
0062 .driver = {
0063 .name = "xdpe152c4",
0064 .of_match_table = of_match_ptr(xdpe152_of_match),
0065 },
0066 .probe_new = xdpe152_probe,
0067 .id_table = xdpe152_id,
0068 };
0069
0070 module_i2c_driver(xdpe152_driver);
0071
0072 MODULE_AUTHOR("Greg Schwendimann <greg.schwendimann@infineon.com>");
0073 MODULE_DESCRIPTION("PMBus driver for Infineon XDPE152 family");
0074 MODULE_LICENSE("GPL");
0075 MODULE_IMPORT_NS(PMBUS);