xref: /linux/drivers/hwmon/pmbus/ir38064.c (revision e65de225ef2f7eade2888b00970eec37aeca0044)
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>
19*e65de225SArthur Heymans #include <linux/of_device.h>
2000669d19SMaxim Sloyko #include "pmbus.h"
2100669d19SMaxim Sloyko 
2200669d19SMaxim Sloyko static struct pmbus_driver_info ir38064_info = {
2300669d19SMaxim Sloyko 	.pages = 1,
2400669d19SMaxim Sloyko 	.format[PSC_VOLTAGE_IN] = linear,
2500669d19SMaxim Sloyko 	.format[PSC_VOLTAGE_OUT] = direct,
2600669d19SMaxim Sloyko 	.format[PSC_CURRENT_OUT] = linear,
2700669d19SMaxim Sloyko 	.format[PSC_POWER] = linear,
2800669d19SMaxim Sloyko 	.format[PSC_TEMPERATURE] = linear,
2900669d19SMaxim Sloyko 	.m[PSC_VOLTAGE_OUT] = 256,
3000669d19SMaxim Sloyko 	.b[PSC_VOLTAGE_OUT] = 0,
3100669d19SMaxim Sloyko 	.R[PSC_VOLTAGE_OUT] = 0,
3200669d19SMaxim Sloyko 	.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
3300669d19SMaxim Sloyko 	    | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
3400669d19SMaxim Sloyko 	    | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
3500669d19SMaxim Sloyko 	    | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
3600669d19SMaxim Sloyko 	    | PMBUS_HAVE_POUT,
3700669d19SMaxim Sloyko };
3800669d19SMaxim Sloyko 
39dd431939SStephen Kitt static int ir38064_probe(struct i2c_client *client)
4000669d19SMaxim Sloyko {
41dd431939SStephen Kitt 	return pmbus_do_probe(client, &ir38064_info);
4200669d19SMaxim Sloyko }
4300669d19SMaxim Sloyko 
4400669d19SMaxim Sloyko static const struct i2c_device_id ir38064_id[] = {
45ca003af3SPatrick Rudolph 	{"ir38060", 0},
4600669d19SMaxim Sloyko 	{"ir38064", 0},
47ca003af3SPatrick Rudolph 	{"ir38164", 0},
48ca003af3SPatrick Rudolph 	{"ir38263", 0},
4900669d19SMaxim Sloyko 	{}
5000669d19SMaxim Sloyko };
5100669d19SMaxim Sloyko 
5200669d19SMaxim Sloyko MODULE_DEVICE_TABLE(i2c, ir38064_id);
5300669d19SMaxim Sloyko 
54*e65de225SArthur Heymans static const struct of_device_id ir38064_of_match[] = {
55*e65de225SArthur Heymans 	{ .compatible = "infineon,ir38060" },
56*e65de225SArthur Heymans 	{ .compatible = "infineon,ir38064" },
57*e65de225SArthur Heymans 	{ .compatible = "infineon,ir38164" },
58*e65de225SArthur Heymans 	{ .compatible = "infineon,ir38263" },
59*e65de225SArthur Heymans 	{}
60*e65de225SArthur Heymans };
61*e65de225SArthur Heymans 
62*e65de225SArthur Heymans MODULE_DEVICE_TABLE(of, ir38064_of_match);
63*e65de225SArthur Heymans 
6400669d19SMaxim Sloyko /* This is the driver that will be inserted */
6500669d19SMaxim Sloyko static struct i2c_driver ir38064_driver = {
6600669d19SMaxim Sloyko 	.driver = {
6700669d19SMaxim Sloyko 		   .name = "ir38064",
68*e65de225SArthur Heymans 		   .of_match_table = of_match_ptr(ir38064_of_match),
6900669d19SMaxim Sloyko 		   },
70dd431939SStephen Kitt 	.probe_new = ir38064_probe,
7100669d19SMaxim Sloyko 	.id_table = ir38064_id,
7200669d19SMaxim Sloyko };
7300669d19SMaxim Sloyko 
7400669d19SMaxim Sloyko module_i2c_driver(ir38064_driver);
7500669d19SMaxim Sloyko 
7600669d19SMaxim Sloyko MODULE_AUTHOR("Maxim Sloyko <maxims@google.com>");
77ca003af3SPatrick Rudolph MODULE_DESCRIPTION("PMBus driver for Infineon IR38064 and comaptible chips");
7800669d19SMaxim Sloyko MODULE_LICENSE("GPL");
79b94ca77eSGuenter Roeck MODULE_IMPORT_NS(PMBUS);
80