Merge tag 'hwmon-for-v6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck...
[linux-2.6-block.git] / drivers / hwmon / pmbus / ir38064.c
CommitLineData
00669d19
MS
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Hardware monitoring driver for Infineon IR38064
4 *
5 * Copyright (c) 2017 Google Inc
6 *
7 * VOUT_MODE is not supported by the device. The driver fakes VOUT linear16
8 * mode with exponent value -8 as direct mode with m=256/b=0/R=0.
39f03438 9 *
00669d19
MS
10 * The device supports VOUT_PEAK, IOUT_PEAK, and TEMPERATURE_PEAK, however
11 * this driver does not currently support them.
12 */
13
14#include <linux/err.h>
15#include <linux/i2c.h>
16#include <linux/init.h>
17#include <linux/kernel.h>
18#include <linux/module.h>
39f03438 19#include <linux/of.h>
0ee7f624 20#include <linux/regulator/driver.h>
00669d19
MS
21#include "pmbus.h"
22
0ee7f624
PR
23#if IS_ENABLED(CONFIG_SENSORS_IR38064_REGULATOR)
24static const struct regulator_desc ir38064_reg_desc[] = {
cb722299 25 PMBUS_REGULATOR_ONE("vout"),
0ee7f624
PR
26};
27#endif /* CONFIG_SENSORS_IR38064_REGULATOR */
28
00669d19
MS
29static struct pmbus_driver_info ir38064_info = {
30 .pages = 1,
31 .format[PSC_VOLTAGE_IN] = linear,
32 .format[PSC_VOLTAGE_OUT] = direct,
33 .format[PSC_CURRENT_OUT] = linear,
34 .format[PSC_POWER] = linear,
35 .format[PSC_TEMPERATURE] = linear,
36 .m[PSC_VOLTAGE_OUT] = 256,
37 .b[PSC_VOLTAGE_OUT] = 0,
38 .R[PSC_VOLTAGE_OUT] = 0,
39 .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
40 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
41 | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
42 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
43 | PMBUS_HAVE_POUT,
0ee7f624
PR
44#if IS_ENABLED(CONFIG_SENSORS_IR38064_REGULATOR)
45 .num_regulators = 1,
46 .reg_desc = ir38064_reg_desc,
47#endif
00669d19
MS
48};
49
dd431939 50static int ir38064_probe(struct i2c_client *client)
00669d19 51{
dd431939 52 return pmbus_do_probe(client, &ir38064_info);
00669d19
MS
53}
54
55static const struct i2c_device_id ir38064_id[] = {
d8a66f36
UKK
56 {"ir38060"},
57 {"ir38064"},
58 {"ir38164"},
59 {"ir38263"},
00669d19
MS
60 {}
61};
62
63MODULE_DEVICE_TABLE(i2c, ir38064_id);
64
f1e75e0d 65static const struct of_device_id __maybe_unused ir38064_of_match[] = {
e65de225
AH
66 { .compatible = "infineon,ir38060" },
67 { .compatible = "infineon,ir38064" },
68 { .compatible = "infineon,ir38164" },
69 { .compatible = "infineon,ir38263" },
70 {}
71};
72
73MODULE_DEVICE_TABLE(of, ir38064_of_match);
74
00669d19
MS
75/* This is the driver that will be inserted */
76static struct i2c_driver ir38064_driver = {
77 .driver = {
78 .name = "ir38064",
e65de225 79 .of_match_table = of_match_ptr(ir38064_of_match),
00669d19 80 },
1975d167 81 .probe = ir38064_probe,
00669d19
MS
82 .id_table = ir38064_id,
83};
84
85module_i2c_driver(ir38064_driver);
86
87MODULE_AUTHOR("Maxim Sloyko <maxims@google.com>");
23c7df14 88MODULE_DESCRIPTION("PMBus driver for Infineon IR38064 and compatible chips");
00669d19 89MODULE_LICENSE("GPL");
b94ca77e 90MODULE_IMPORT_NS(PMBUS);