blob: 4211de048069d9e127dfa4d69412279ca7198dea [file] [log] [blame]
Maxim Sloyko00669d12019-04-12 13:37:56 -07001// 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.
9 *
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>
Arthur Heymanse65de222021-12-13 15:28:13 +010019#include <linux/of_device.h>
Maxim Sloyko00669d12019-04-12 13:37:56 -070020#include "pmbus.h"
21
22static struct pmbus_driver_info ir38064_info = {
23 .pages = 1,
24 .format[PSC_VOLTAGE_IN] = linear,
25 .format[PSC_VOLTAGE_OUT] = direct,
26 .format[PSC_CURRENT_OUT] = linear,
27 .format[PSC_POWER] = linear,
28 .format[PSC_TEMPERATURE] = linear,
29 .m[PSC_VOLTAGE_OUT] = 256,
30 .b[PSC_VOLTAGE_OUT] = 0,
31 .R[PSC_VOLTAGE_OUT] = 0,
32 .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT
33 | PMBUS_HAVE_TEMP | PMBUS_HAVE_STATUS_TEMP
34 | PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
35 | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT
36 | PMBUS_HAVE_POUT,
37};
38
Stephen Kittdd431932020-08-08 23:00:04 +020039static int ir38064_probe(struct i2c_client *client)
Maxim Sloyko00669d12019-04-12 13:37:56 -070040{
Stephen Kittdd431932020-08-08 23:00:04 +020041 return pmbus_do_probe(client, &ir38064_info);
Maxim Sloyko00669d12019-04-12 13:37:56 -070042}
43
44static const struct i2c_device_id ir38064_id[] = {
Patrick Rudolphca003af2021-12-13 15:28:12 +010045 {"ir38060", 0},
Maxim Sloyko00669d12019-04-12 13:37:56 -070046 {"ir38064", 0},
Patrick Rudolphca003af2021-12-13 15:28:12 +010047 {"ir38164", 0},
48 {"ir38263", 0},
Maxim Sloyko00669d12019-04-12 13:37:56 -070049 {}
50};
51
52MODULE_DEVICE_TABLE(i2c, ir38064_id);
53
Arthur Heymanse65de222021-12-13 15:28:13 +010054static const struct of_device_id ir38064_of_match[] = {
55 { .compatible = "infineon,ir38060" },
56 { .compatible = "infineon,ir38064" },
57 { .compatible = "infineon,ir38164" },
58 { .compatible = "infineon,ir38263" },
59 {}
60};
61
62MODULE_DEVICE_TABLE(of, ir38064_of_match);
63
Maxim Sloyko00669d12019-04-12 13:37:56 -070064/* This is the driver that will be inserted */
65static struct i2c_driver ir38064_driver = {
66 .driver = {
67 .name = "ir38064",
Arthur Heymanse65de222021-12-13 15:28:13 +010068 .of_match_table = of_match_ptr(ir38064_of_match),
Maxim Sloyko00669d12019-04-12 13:37:56 -070069 },
Stephen Kittdd431932020-08-08 23:00:04 +020070 .probe_new = ir38064_probe,
Maxim Sloyko00669d12019-04-12 13:37:56 -070071 .id_table = ir38064_id,
72};
73
74module_i2c_driver(ir38064_driver);
75
76MODULE_AUTHOR("Maxim Sloyko <maxims@google.com>");
Patrick Rudolphca003af2021-12-13 15:28:12 +010077MODULE_DESCRIPTION("PMBus driver for Infineon IR38064 and comaptible chips");
Maxim Sloyko00669d12019-04-12 13:37:56 -070078MODULE_LICENSE("GPL");
Guenter Roeckb94ca772021-04-19 23:07:07 -070079MODULE_IMPORT_NS(PMBUS);