|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | +/* |
| 3 | + * Driver for MPS MP5023 Hot-Swap Controller |
| 4 | + */ |
| 5 | + |
| 6 | +#include <linux/i2c.h> |
| 7 | +#include <linux/module.h> |
| 8 | +#include <linux/of_device.h> |
| 9 | +#include "pmbus.h" |
| 10 | + |
| 11 | +static struct pmbus_driver_info mp5023_info = { |
| 12 | + .pages = 1, |
| 13 | + |
| 14 | + .format[PSC_VOLTAGE_IN] = direct, |
| 15 | + .format[PSC_VOLTAGE_OUT] = direct, |
| 16 | + .format[PSC_CURRENT_OUT] = direct, |
| 17 | + .format[PSC_POWER] = direct, |
| 18 | + .format[PSC_TEMPERATURE] = direct, |
| 19 | + |
| 20 | + .m[PSC_VOLTAGE_IN] = 32, |
| 21 | + .b[PSC_VOLTAGE_IN] = 0, |
| 22 | + .R[PSC_VOLTAGE_IN] = 0, |
| 23 | + .m[PSC_VOLTAGE_OUT] = 32, |
| 24 | + .b[PSC_VOLTAGE_OUT] = 0, |
| 25 | + .R[PSC_VOLTAGE_OUT] = 0, |
| 26 | + .m[PSC_CURRENT_OUT] = 16, |
| 27 | + .b[PSC_CURRENT_OUT] = 0, |
| 28 | + .R[PSC_CURRENT_OUT] = 0, |
| 29 | + .m[PSC_POWER] = 1, |
| 30 | + .b[PSC_POWER] = 0, |
| 31 | + .R[PSC_POWER] = 0, |
| 32 | + .m[PSC_TEMPERATURE] = 2, |
| 33 | + .b[PSC_TEMPERATURE] = 0, |
| 34 | + .R[PSC_TEMPERATURE] = 0, |
| 35 | + |
| 36 | + .func[0] = |
| 37 | + PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_PIN | |
| 38 | + PMBUS_HAVE_TEMP | PMBUS_HAVE_IOUT | |
| 39 | + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP, |
| 40 | +}; |
| 41 | + |
| 42 | +static int mp5023_probe(struct i2c_client *client) |
| 43 | +{ |
| 44 | + return pmbus_do_probe(client, &mp5023_info); |
| 45 | +} |
| 46 | + |
| 47 | +static const struct of_device_id __maybe_unused mp5023_of_match[] = { |
| 48 | + { .compatible = "mps,mp5023", }, |
| 49 | + {} |
| 50 | +}; |
| 51 | + |
| 52 | +MODULE_DEVICE_TABLE(of, mp5023_of_match); |
| 53 | + |
| 54 | +static struct i2c_driver mp5023_driver = { |
| 55 | + .driver = { |
| 56 | + .name = "mp5023", |
| 57 | + .of_match_table = of_match_ptr(mp5023_of_match), |
| 58 | + }, |
| 59 | + .probe_new = mp5023_probe, |
| 60 | +}; |
| 61 | + |
| 62 | +module_i2c_driver(mp5023_driver); |
| 63 | + |
| 64 | +MODULE_AUTHOR("Howard Chiu <howard.chiu@quantatw.com>"); |
| 65 | +MODULE_DESCRIPTION("PMBus driver for MPS MP5023 HSC"); |
| 66 | +MODULE_LICENSE("GPL"); |
| 67 | +MODULE_IMPORT_NS(PMBUS); |
0 commit comments