Skip to content

Commit de07619

Browse files
ninadpalsulegroeck
authored andcommitted
hwmon: (pmbus/crps) Add Intel CRPS185 power supply
Add the driver to monitor Intel common redundant power supply (crps185) with hwmon over pmbus. Signed-off-by: Ninad Palsule <ninad@linux.ibm.com> Link: https://lore.kernel.org/r/20241217173537.192331-3-ninad@linux.ibm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 18e930f commit de07619

File tree

6 files changed

+189
-0
lines changed

6 files changed

+189
-0
lines changed

Documentation/hwmon/crps.rst

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.. SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
Kernel driver crps
4+
==================
5+
6+
Supported chips:
7+
8+
* Intel CRPS185
9+
10+
Prefix: 'crps185'
11+
12+
Addresses scanned: -
13+
14+
Datasheet: Only available under NDA.
15+
16+
Authors:
17+
Ninad Palsule <ninad@linux.ibm.com>
18+
19+
20+
Description
21+
-----------
22+
23+
This driver implements support for Intel Common Redundant Power supply with
24+
PMBus support.
25+
26+
The driver is a client driver to the core PMBus driver.
27+
Please see Documentation/hwmon/pmbus.rst for details on PMBus client drivers.
28+
29+
30+
Usage Notes
31+
-----------
32+
33+
This driver does not auto-detect devices. You will have to instantiate the
34+
devices explicitly. Please see Documentation/i2c/instantiating-devices.rst for
35+
details.
36+
37+
38+
Sysfs entries
39+
-------------
40+
41+
======================= ======================================================
42+
curr1_label "iin"
43+
curr1_input Measured input current
44+
curr1_max Maximum input current
45+
curr1_max_alarm Input maximum current high alarm
46+
curr1_crit Critial high input current
47+
curr1_crit_alarm Input critical current high alarm
48+
curr1_rated_max Maximum rated input current
49+
50+
curr2_label "iout1"
51+
curr2_input Measured output current
52+
curr2_max Maximum output current
53+
curr2_max_alarm Output maximum current high alarm
54+
curr2_crit Critial high output current
55+
curr2_crit_alarm Output critical current high alarm
56+
curr2_rated_max Maximum rated output current
57+
58+
in1_label "vin"
59+
in1_input Measured input voltage
60+
in1_crit Critical input over voltage
61+
in1_crit_alarm Critical input over voltage alarm
62+
in1_max Maximum input over voltage
63+
in1_max_alarm Maximum input over voltage alarm
64+
in1_rated_min Minimum rated input voltage
65+
in1_rated_max Maximum rated input voltage
66+
67+
in2_label "vout1"
68+
in2_input Measured input voltage
69+
in2_crit Critical input over voltage
70+
in2_crit_alarm Critical input over voltage alarm
71+
in2_lcrit Critical input under voltage fault
72+
in2_lcrit_alarm Critical input under voltage fault alarm
73+
in2_max Maximum input over voltage
74+
in2_max_alarm Maximum input over voltage alarm
75+
in2_min Minimum input under voltage warning
76+
in2_min_alarm Minimum input under voltage warning alarm
77+
in2_rated_min Minimum rated input voltage
78+
in2_rated_max Maximum rated input voltage
79+
80+
power1_label "pin"
81+
power1_input Measured input power
82+
power1_alarm Input power high alarm
83+
power1_max Maximum input power
84+
power1_rated_max Maximum rated input power
85+
86+
temp[1-2]_input Measured temperature
87+
temp[1-2]_crit Critical temperature
88+
temp[1-2]_crit_alarm Critical temperature alarm
89+
temp[1-2]_max Maximum temperature
90+
temp[1-2]_max_alarm Maximum temperature alarm
91+
temp[1-2]_rated_max Maximum rated temperature
92+
93+
fan1_alarm Fan 1 warning.
94+
fan1_fault Fan 1 fault.
95+
fan1_input Fan 1 speed in RPM.
96+
fan1_target Fan 1 target.
97+
======================= ======================================================

Documentation/hwmon/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Hardware Monitoring Kernel Drivers
5858
corsair-cpro
5959
corsair-psu
6060
cros_ec_hwmon
61+
crps
6162
da9052
6263
da9055
6364
dell-smm-hwmon

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6064,6 +6064,13 @@ L: linux-input@vger.kernel.org
60646064
S: Maintained
60656065
F: drivers/hid/hid-creative-sb0540.c
60666066

6067+
INTEL CRPS COMMON REDUNDANT PSU DRIVER
6068+
M: Ninad Palsule <ninad@linux.ibm.com>
6069+
L: linux-hwmon@vger.kernel.org
6070+
S: Maintained
6071+
F: Documentation/hwmon/crps.rst
6072+
F: drivers/hwmon/pmbus/crps.c
6073+
60676074
CRYPTO API
60686075
M: Herbert Xu <herbert@gondor.apana.org.au>
60696076
M: "David S. Miller" <davem@davemloft.net>

drivers/hwmon/pmbus/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ config SENSORS_BPA_RS600
8585
This driver can also be built as a module. If so, the module will
8686
be called bpa-rs600.
8787

88+
config SENSORS_CRPS
89+
tristate "Intel Common Redundant Power Supply"
90+
help
91+
If you say yes here you get hardware monitoring support for the Intel
92+
Common Redundant Power Supply.
93+
94+
This driver can also be built as a module. If so, the module will
95+
be called crps.
96+
8897
config SENSORS_DELTA_AHE50DC_FAN
8998
tristate "Delta AHE-50DC fan control module"
9099
help

drivers/hwmon/pmbus/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ obj-$(CONFIG_SENSORS_XDPE122) += xdpe12284.o
6262
obj-$(CONFIG_SENSORS_XDPE152) += xdpe152c4.o
6363
obj-$(CONFIG_SENSORS_ZL6100) += zl6100.o
6464
obj-$(CONFIG_SENSORS_PIM4328) += pim4328.o
65+
obj-$(CONFIG_SENSORS_CRPS) += crps.o

drivers/hwmon/pmbus/crps.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Copyright 2024 IBM Corp.
4+
*/
5+
6+
#include <linux/i2c.h>
7+
#include <linux/of.h>
8+
#include <linux/pmbus.h>
9+
10+
#include "pmbus.h"
11+
12+
static const struct i2c_device_id crps_id[] = {
13+
{ "intel_crps185" },
14+
{}
15+
};
16+
MODULE_DEVICE_TABLE(i2c, crps_id);
17+
18+
static struct pmbus_driver_info crps_info = {
19+
.pages = 1,
20+
/* PSU uses default linear data format. */
21+
.func[0] = PMBUS_HAVE_PIN | PMBUS_HAVE_IOUT |
22+
PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_IIN |
23+
PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT |
24+
PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
25+
PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 |
26+
PMBUS_HAVE_STATUS_TEMP |
27+
PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12,
28+
};
29+
30+
static int crps_probe(struct i2c_client *client)
31+
{
32+
int rc;
33+
struct device *dev = &client->dev;
34+
char buf[I2C_SMBUS_BLOCK_MAX + 2] = { 0 };
35+
36+
rc = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf);
37+
if (rc < 0)
38+
return dev_err_probe(dev, rc, "Failed to read PMBUS_MFR_MODEL\n");
39+
40+
if (rc != 7 || strncmp(buf, "03NK260", 7)) {
41+
buf[rc] = '\0';
42+
return dev_err_probe(dev, -ENODEV, "Model '%s' not supported\n", buf);
43+
}
44+
45+
rc = pmbus_do_probe(client, &crps_info);
46+
if (rc)
47+
return dev_err_probe(dev, rc, "Failed to probe\n");
48+
49+
return 0;
50+
}
51+
52+
static const struct of_device_id crps_of_match[] = {
53+
{
54+
.compatible = "intel,crps185",
55+
},
56+
{}
57+
};
58+
MODULE_DEVICE_TABLE(of, crps_of_match);
59+
60+
static struct i2c_driver crps_driver = {
61+
.driver = {
62+
.name = "crps",
63+
.of_match_table = crps_of_match,
64+
},
65+
.probe = crps_probe,
66+
.id_table = crps_id,
67+
};
68+
69+
module_i2c_driver(crps_driver);
70+
71+
MODULE_AUTHOR("Ninad Palsule");
72+
MODULE_DESCRIPTION("PMBus driver for Intel Common Redundant power supplies");
73+
MODULE_LICENSE("GPL");
74+
MODULE_IMPORT_NS("PMBUS");

0 commit comments

Comments
 (0)