1 // SPDX-License-Identifier: GPL-2.0+
3 * Hardware monitoring driver for Infineon IR36021
5 * Copyright (c) 2021 Allied Telesis
9 #include <linux/init.h>
10 #include <linux/kernel.h>
11 #include <linux/module.h>
14 static struct pmbus_driver_info ir36021_info = {
16 .format[PSC_VOLTAGE_IN] = linear,
17 .format[PSC_VOLTAGE_OUT] = linear,
18 .format[PSC_CURRENT_IN] = linear,
19 .format[PSC_CURRENT_OUT] = linear,
20 .format[PSC_POWER] = linear,
21 .format[PSC_TEMPERATURE] = linear,
22 .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT
23 | PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT
24 | PMBUS_HAVE_PIN | PMBUS_HAVE_POUT
25 | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2
26 | PMBUS_HAVE_STATUS_TEMP,
29 static int ir36021_probe(struct i2c_client *client)
31 u8 buf[I2C_SMBUS_BLOCK_MAX];
34 if (!i2c_check_functionality(client->adapter,
35 I2C_FUNC_SMBUS_READ_BYTE_DATA
36 | I2C_FUNC_SMBUS_READ_WORD_DATA
37 | I2C_FUNC_SMBUS_READ_BLOCK_DATA))
40 ret = i2c_smbus_read_i2c_block_data(client, PMBUS_MFR_MODEL, 2, buf);
42 dev_err(&client->dev, "Failed to read PMBUS_MFR_MODEL\n");
45 if (ret != 2 || buf[0] != 0x01 || buf[1] != 0x2d) {
46 dev_err(&client->dev, "MFR_MODEL unrecognised\n");
50 return pmbus_do_probe(client, &ir36021_info);
53 static const struct i2c_device_id ir36021_id[] = {
57 MODULE_DEVICE_TABLE(i2c, ir36021_id);
59 static const struct of_device_id __maybe_unused ir36021_of_id[] = {
60 { .compatible = "infineon,ir36021" },
63 MODULE_DEVICE_TABLE(of, ir36021_of_id);
65 static struct i2c_driver ir36021_driver = {
66 .class = I2C_CLASS_HWMON,
69 .of_match_table = of_match_ptr(ir36021_of_id),
71 .probe_new = ir36021_probe,
72 .id_table = ir36021_id,
75 module_i2c_driver(ir36021_driver);
78 MODULE_DESCRIPTION("PMBus driver for Infineon IR36021");
79 MODULE_LICENSE("GPL");
80 MODULE_IMPORT_NS(PMBUS);