Skip to content

Commit d387d88

Browse files
zevweissgroeck
authored andcommitted
hwmon: (pmbus) Add Delta AHE-50DC fan control module driver
This device is an integrated module of the Delta AHE-50DC Open19 power shelf. I haven't been able to procure any proper documentation for it, but it seems to be a (somewhat minimally) PMBus-compliant device. It provides four fan speeds, four temperatures (three standard and one manufacturer-specific via a virtual second page), and a vin reading. Signed-off-by: Zev Weiss <zev@bewilderbeest.net> Link: https://lore.kernel.org/r/20211208213703.2577-2-zev@bewilderbeest.net Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 130d168 commit d387d88

4 files changed

Lines changed: 131 additions & 0 deletions

File tree

MAINTAINERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5436,6 +5436,12 @@ W: https://linuxtv.org
54365436
T: git git://linuxtv.org/media_tree.git
54375437
F: drivers/media/platform/sti/delta
54385438

5439+
DELTA AHE-50DC FAN CONTROL MODULE DRIVER
5440+
M: Zev Weiss <zev@bewilderbeest.net>
5441+
L: linux-hwmon@vger.kernel.org
5442+
S: Maintained
5443+
F: drivers/hwmon/pmbus/delta-ahe50dc-fan.c
5444+
54395445
DELTA DPS920AB PSU DRIVER
54405446
M: Robert Marko <robert.marko@sartura.hr>
54415447
L: linux-hwmon@vger.kernel.org

drivers/hwmon/pmbus/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ config SENSORS_BPA_RS600
6666
This driver can also be built as a module. If so, the module will
6767
be called bpa-rs600.
6868

69+
config SENSORS_DELTA_AHE50DC_FAN
70+
tristate "Delta AHE-50DC fan control module"
71+
help
72+
If you say yes here you get hardware monitoring support for
73+
the integrated fan control module of the Delta AHE-50DC
74+
Open19 power shelf.
75+
76+
This driver can also be built as a module. If so, the module
77+
will be called delta-ahe50dc-fan.
78+
6979
config SENSORS_FSP_3Y
7080
tristate "FSP/3Y-Power power supplies"
7181
help

drivers/hwmon/pmbus/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ obj-$(CONFIG_SENSORS_ADM1266) += adm1266.o
99
obj-$(CONFIG_SENSORS_ADM1275) += adm1275.o
1010
obj-$(CONFIG_SENSORS_BEL_PFE) += bel-pfe.o
1111
obj-$(CONFIG_SENSORS_BPA_RS600) += bpa-rs600.o
12+
obj-$(CONFIG_SENSORS_DELTA_AHE50DC_FAN) += delta-ahe50dc-fan.o
1213
obj-$(CONFIG_SENSORS_FSP_3Y) += fsp-3y.o
1314
obj-$(CONFIG_SENSORS_IBM_CFFPS) += ibm-cffps.o
1415
obj-$(CONFIG_SENSORS_DPS920AB) += dps920ab.o
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Delta AHE-50DC power shelf fan control module driver
4+
*
5+
* Copyright 2021 Zev Weiss <zev@bewilderbeest.net>
6+
*/
7+
8+
#include <linux/i2c.h>
9+
#include <linux/kernel.h>
10+
#include <linux/module.h>
11+
#include <linux/pmbus.h>
12+
13+
#include "pmbus.h"
14+
15+
#define AHE50DC_PMBUS_READ_TEMP4 0xd0
16+
17+
static int ahe50dc_fan_read_word_data(struct i2c_client *client, int page, int phase, int reg)
18+
{
19+
/* temp1 in (virtual) page 1 is remapped to mfr-specific temp4 */
20+
if (page == 1) {
21+
if (reg == PMBUS_READ_TEMPERATURE_1)
22+
return i2c_smbus_read_word_data(client, AHE50DC_PMBUS_READ_TEMP4);
23+
return -EOPNOTSUPP;
24+
}
25+
26+
/*
27+
* There's a fairly limited set of commands this device actually
28+
* supports, so here we block attempts to read anything else (which
29+
* return 0xffff and would cause confusion elsewhere).
30+
*/
31+
switch (reg) {
32+
case PMBUS_STATUS_WORD:
33+
case PMBUS_FAN_COMMAND_1:
34+
case PMBUS_FAN_COMMAND_2:
35+
case PMBUS_FAN_COMMAND_3:
36+
case PMBUS_FAN_COMMAND_4:
37+
case PMBUS_STATUS_FAN_12:
38+
case PMBUS_STATUS_FAN_34:
39+
case PMBUS_READ_VIN:
40+
case PMBUS_READ_TEMPERATURE_1:
41+
case PMBUS_READ_TEMPERATURE_2:
42+
case PMBUS_READ_TEMPERATURE_3:
43+
case PMBUS_READ_FAN_SPEED_1:
44+
case PMBUS_READ_FAN_SPEED_2:
45+
case PMBUS_READ_FAN_SPEED_3:
46+
case PMBUS_READ_FAN_SPEED_4:
47+
return -ENODATA;
48+
default:
49+
return -EOPNOTSUPP;
50+
}
51+
}
52+
53+
static struct pmbus_driver_info ahe50dc_fan_info = {
54+
.pages = 2,
55+
.format[PSC_FAN] = direct,
56+
.format[PSC_TEMPERATURE] = direct,
57+
.format[PSC_VOLTAGE_IN] = direct,
58+
.m[PSC_FAN] = 1,
59+
.b[PSC_FAN] = 0,
60+
.R[PSC_FAN] = 0,
61+
.m[PSC_TEMPERATURE] = 1,
62+
.b[PSC_TEMPERATURE] = 0,
63+
.R[PSC_TEMPERATURE] = 1,
64+
.m[PSC_VOLTAGE_IN] = 1,
65+
.b[PSC_VOLTAGE_IN] = 0,
66+
.R[PSC_VOLTAGE_IN] = 3,
67+
.func[0] = PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
68+
PMBUS_HAVE_VIN | PMBUS_HAVE_FAN12 | PMBUS_HAVE_FAN34 |
69+
PMBUS_HAVE_STATUS_FAN12 | PMBUS_HAVE_STATUS_FAN34 | PMBUS_PAGE_VIRTUAL,
70+
.func[1] = PMBUS_HAVE_TEMP | PMBUS_PAGE_VIRTUAL,
71+
.read_word_data = ahe50dc_fan_read_word_data,
72+
};
73+
74+
/*
75+
* CAPABILITY returns 0xff, which appears to be this device's way indicating
76+
* it doesn't support something (and if we enable I2C_CLIENT_PEC on seeing bit
77+
* 7 being set it generates bad PECs, so let's not go there).
78+
*/
79+
static struct pmbus_platform_data ahe50dc_fan_data = {
80+
.flags = PMBUS_NO_CAPABILITY,
81+
};
82+
83+
static int ahe50dc_fan_probe(struct i2c_client *client)
84+
{
85+
client->dev.platform_data = &ahe50dc_fan_data;
86+
return pmbus_do_probe(client, &ahe50dc_fan_info);
87+
}
88+
89+
static const struct i2c_device_id ahe50dc_fan_id[] = {
90+
{ "ahe50dc_fan" },
91+
{ }
92+
};
93+
MODULE_DEVICE_TABLE(i2c, ahe50dc_fan_id);
94+
95+
static const struct of_device_id __maybe_unused ahe50dc_fan_of_match[] = {
96+
{ .compatible = "delta,ahe50dc-fan" },
97+
{ }
98+
};
99+
MODULE_DEVICE_TABLE(of, ahe50dc_fan_of_match);
100+
101+
static struct i2c_driver ahe50dc_fan_driver = {
102+
.driver = {
103+
.name = "ahe50dc_fan",
104+
.of_match_table = of_match_ptr(ahe50dc_fan_of_match),
105+
},
106+
.probe_new = ahe50dc_fan_probe,
107+
.id_table = ahe50dc_fan_id,
108+
};
109+
module_i2c_driver(ahe50dc_fan_driver);
110+
111+
MODULE_AUTHOR("Zev Weiss <zev@bewilderbeest.net>");
112+
MODULE_DESCRIPTION("Driver for Delta AHE-50DC power shelf fan control module");
113+
MODULE_LICENSE("GPL");
114+
MODULE_IMPORT_NS(PMBUS);

0 commit comments

Comments
 (0)