Skip to content

Commit d89d6c0

Browse files
Lakshmi-ygroeck
authored andcommitted
hwmon: (pmbus/acbel-fsg032) Add Acbel power supply
Add the driver to support ACBEL FSG032 power supply. Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com> Link: https://lore.kernel.org/r/20230413132627.3444119-4-lakshmiy@us.ibm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent b0cda2c commit d89d6c0

3 files changed

Lines changed: 95 additions & 0 deletions

File tree

drivers/hwmon/pmbus/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ config SENSORS_PMBUS
2727
This driver can also be built as a module. If so, the module will
2828
be called pmbus.
2929

30+
config SENSORS_ACBEL_FSG032
31+
tristate "ACBEL FSG032 Power Supply"
32+
help
33+
If you say yes here you get hardware monitoring support for the ACBEL
34+
FSG032 Power Supply.
35+
36+
This driver can also be built as a module. If so, the module will
37+
be called acbel-fsg032.
38+
3039
config SENSORS_ADM1266
3140
tristate "Analog Devices ADM1266 Sequencer"
3241
select CRC8

drivers/hwmon/pmbus/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
obj-$(CONFIG_PMBUS) += pmbus_core.o
77
obj-$(CONFIG_SENSORS_PMBUS) += pmbus.o
8+
obj-$(CONFIG_SENSORS_ACBEL_FSG032) += acbel-fsg032.o
89
obj-$(CONFIG_SENSORS_ADM1266) += adm1266.o
910
obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o
1011
obj-$(CONFIG_SENSORS_BEL_PFE) += bel-pfe.o

drivers/hwmon/pmbus/acbel-fsg032.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Copyright 2023 IBM Corp.
4+
*/
5+
6+
#include <linux/device.h>
7+
#include <linux/fs.h>
8+
#include <linux/i2c.h>
9+
#include <linux/module.h>
10+
#include <linux/pmbus.h>
11+
#include <linux/hwmon-sysfs.h>
12+
#include "pmbus.h"
13+
14+
static const struct i2c_device_id acbel_fsg032_id[] = {
15+
{ "acbel_fsg032" },
16+
{}
17+
};
18+
19+
static struct pmbus_driver_info acbel_fsg032_info = {
20+
.pages = 1,
21+
.func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN |
22+
PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT |
23+
PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
24+
PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_VOUT |
25+
PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_STATUS_TEMP |
26+
PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_FAN12,
27+
};
28+
29+
static int acbel_fsg032_probe(struct i2c_client *client)
30+
{
31+
u8 buf[I2C_SMBUS_BLOCK_MAX + 1];
32+
struct device *dev = &client->dev;
33+
int rc;
34+
35+
rc = i2c_smbus_read_block_data(client, PMBUS_MFR_ID, buf);
36+
if (rc < 0) {
37+
dev_err(dev, "Failed to read PMBUS_MFR_ID\n");
38+
return rc;
39+
}
40+
if (strncmp(buf, "ACBEL", 5)) {
41+
buf[rc] = '\0';
42+
dev_err(dev, "Manufacturer '%s' not supported\n", buf);
43+
return -ENODEV;
44+
}
45+
46+
rc = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
47+
if (rc < 0) {
48+
dev_err(dev, "Failed to read PMBUS_MFR_MODEL\n");
49+
return rc;
50+
}
51+
52+
if (strncmp(buf, "FSG032", 6)) {
53+
buf[rc] = '\0';
54+
dev_err(dev, "Model '%s' not supported\n", buf);
55+
return -ENODEV;
56+
}
57+
58+
rc = pmbus_do_probe(client, &acbel_fsg032_info);
59+
if (rc)
60+
return rc;
61+
62+
return 0;
63+
}
64+
65+
static const struct of_device_id acbel_fsg032_of_match[] = {
66+
{ .compatible = "acbel,fsg032" },
67+
{}
68+
};
69+
MODULE_DEVICE_TABLE(of, acbel_fsg032_of_match);
70+
71+
static struct i2c_driver acbel_fsg032_driver = {
72+
.driver = {
73+
.name = "acbel-fsg032",
74+
.of_match_table = acbel_fsg032_of_match,
75+
},
76+
.probe_new = acbel_fsg032_probe,
77+
.id_table = acbel_fsg032_id,
78+
};
79+
80+
module_i2c_driver(acbel_fsg032_driver);
81+
82+
MODULE_AUTHOR("Lakshmi Yadlapati");
83+
MODULE_DESCRIPTION("PMBus driver for AcBel Power System power supplies");
84+
MODULE_LICENSE("GPL");
85+
MODULE_IMPORT_NS(PMBUS);

0 commit comments

Comments
 (0)