xref: /linux/drivers/hwmon/pmbus/ir38064.c (revision dd43193976b9a7b2affe8fb71780bb96d16a8449)
100669d19SMaxim Sloyko // SPDX-License-Identifier: GPL-2.0+
200669d19SMaxim Sloyko /*
300669d19SMaxim Sloyko  * Hardware monitoring driver for Infineon IR38064
400669d19SMaxim Sloyko  *
500669d19SMaxim Sloyko  * Copyright (c) 2017 Google Inc
600669d19SMaxim Sloyko  *
700669d19SMaxim Sloyko  * VOUT_MODE is not supported by the device. The driver fakes VOUT linear16
800669d19SMaxim Sloyko  * mode with exponent value -8 as direct mode with m=256/b=0/R=0.
900669d19SMaxim Sloyko  *
1000669d19SMaxim Sloyko  * The device supports VOUT_PEAK, IOUT_PEAK, and TEMPERATURE_PEAK, however
1100669d19SMaxim Sloyko  * this driver does not currently support them.
1200669d19SMaxim Sloyko  */
1300669d19SMaxim Sloyko 
1400669d19SMaxim Sloyko #include <linux/err.h>
1500669d19SMaxim Sloyko #include <linux/i2c.h>
1600669d19SMaxim Sloyko #include <linux/init.h>
1700669d19SMaxim Sloyko #include <linux/kernel.h>
1800669d19SMaxim Sloyko #include <linux/module.h>
1900669d19SMaxim Sloyko #include "pmbus.h"
2000669d19SMaxim Sloyko 
2100669d19SMaxim Sloyko static struct pmbus_driver_info ir38064_info = {
2200669d19SMaxim Sloyko 	.pages = 1,
2300669d19SMaxim Sloyko 	.format[PSC_VOLTAGE_IN] = linear,
2400669d19SMaxim Sloyko 	.format[PSC_VOLTAGE_OUT] = direct,
2500669d19SMaxim Sloyko 	.format[PSC_CURRENT_OUT] = linear,
2600669d19SMaxim Sloyko 	.format[PSC_POWER] = linear,
2700669d19SMaxim Sloyko 	.format[PSC_TEMPERATURE] = linear,
2800669d19SMaxim Sloyko 	.m[PSC_VOLTAGE_OUT] = 256,
2900669d19SMaxim Sloyko 	.b[PSC_VOLTAGE_OUT] = 0,
3000669d19SMaxim Sloyko 	.R[PSC_VOLTAGE_OUT] = 0,
3100669d19SMaxim Sloyko 	.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
3200669d19SMaxim Sloyko 	    | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
3300669d19SMaxim Sloyko 	    | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
3400669d19SMaxim Sloyko 	    | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
3500669d19SMaxim Sloyko 	    | PMBUS_HAVE_POUT,
3600669d19SMaxim Sloyko };
3700669d19SMaxim Sloyko 
38*dd431939SStephen Kitt static int ir38064_probe(struct i2c_client *client)
3900669d19SMaxim Sloyko {
40*dd431939SStephen Kitt 	return pmbus_do_probe(client, &ir38064_info);
4100669d19SMaxim Sloyko }
4200669d19SMaxim Sloyko 
4300669d19SMaxim Sloyko static const struct i2c_device_id ir38064_id[] = {
4400669d19SMaxim Sloyko 	{"ir38064", 0},
4500669d19SMaxim Sloyko 	{}
4600669d19SMaxim Sloyko };
4700669d19SMaxim Sloyko 
4800669d19SMaxim Sloyko MODULE_DEVICE_TABLE(i2c, ir38064_id);
4900669d19SMaxim Sloyko 
5000669d19SMaxim Sloyko /* This is the driver that will be inserted */
5100669d19SMaxim Sloyko static struct i2c_driver ir38064_driver = {
5200669d19SMaxim Sloyko 	.driver = {
5300669d19SMaxim Sloyko 		   .name = "ir38064",
5400669d19SMaxim Sloyko 		   },
55*dd431939SStephen Kitt 	.probe_new = ir38064_probe,
5600669d19SMaxim Sloyko 	.remove = pmbus_do_remove,
5700669d19SMaxim Sloyko 	.id_table = ir38064_id,
5800669d19SMaxim Sloyko };
5900669d19SMaxim Sloyko 
6000669d19SMaxim Sloyko module_i2c_driver(ir38064_driver);
6100669d19SMaxim Sloyko 
6200669d19SMaxim Sloyko MODULE_AUTHOR("Maxim Sloyko <maxims@google.com>");
6300669d19SMaxim Sloyko MODULE_DESCRIPTION("PMBus driver for Infineon IR38064");
6400669d19SMaxim Sloyko MODULE_LICENSE("GPL");
65