0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <linux/err.h>
0015 #include <linux/i2c.h>
0016 #include <linux/init.h>
0017 #include <linux/kernel.h>
0018 #include <linux/module.h>
0019 #include <linux/of_device.h>
0020 #include <linux/regulator/driver.h>
0021 #include "pmbus.h"
0022
0023 #if IS_ENABLED(CONFIG_SENSORS_IR38064_REGULATOR)
0024 static const struct regulator_desc ir38064_reg_desc[] = {
0025 PMBUS_REGULATOR("vout", 0),
0026 };
0027 #endif
0028
0029 static struct pmbus_driver_info ir38064_info = {
0030 .pages = 1,
0031 .format[PSC_VOLTAGE_IN] = linear,
0032 .format[PSC_VOLTAGE_OUT] = direct,
0033 .format[PSC_CURRENT_OUT] = linear,
0034 .format[PSC_POWER] = linear,
0035 .format[PSC_TEMPERATURE] = linear,
0036 .m[PSC_VOLTAGE_OUT] = 256,
0037 .b[PSC_VOLTAGE_OUT] = 0,
0038 .R[PSC_VOLTAGE_OUT] = 0,
0039 .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
0040 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
0041 | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
0042 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
0043 | PMBUS_HAVE_POUT,
0044 #if IS_ENABLED(CONFIG_SENSORS_IR38064_REGULATOR)
0045 .num_regulators = 1,
0046 .reg_desc = ir38064_reg_desc,
0047 #endif
0048 };
0049
0050 static int ir38064_probe(struct i2c_client *client)
0051 {
0052 return pmbus_do_probe(client, &ir38064_info);
0053 }
0054
0055 static const struct i2c_device_id ir38064_id[] = {
0056 {"ir38060", 0},
0057 {"ir38064", 0},
0058 {"ir38164", 0},
0059 {"ir38263", 0},
0060 {}
0061 };
0062
0063 MODULE_DEVICE_TABLE(i2c, ir38064_id);
0064
0065 static const struct of_device_id __maybe_unused ir38064_of_match[] = {
0066 { .compatible = "infineon,ir38060" },
0067 { .compatible = "infineon,ir38064" },
0068 { .compatible = "infineon,ir38164" },
0069 { .compatible = "infineon,ir38263" },
0070 {}
0071 };
0072
0073 MODULE_DEVICE_TABLE(of, ir38064_of_match);
0074
0075
0076 static struct i2c_driver ir38064_driver = {
0077 .driver = {
0078 .name = "ir38064",
0079 .of_match_table = of_match_ptr(ir38064_of_match),
0080 },
0081 .probe_new = ir38064_probe,
0082 .id_table = ir38064_id,
0083 };
0084
0085 module_i2c_driver(ir38064_driver);
0086
0087 MODULE_AUTHOR("Maxim Sloyko <maxims@google.com>");
0088 MODULE_DESCRIPTION("PMBus driver for Infineon IR38064 and compatible chips");
0089 MODULE_LICENSE("GPL");
0090 MODULE_IMPORT_NS(PMBUS);