summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-kernel/linux/linux-aspeed/0072-pmbus-add-fault-and-beep-attributes.patch
blob: 40a9272e02bbaa5672d39639aeb6e940bebcfb76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From e360a6c2a3f15bfc8900c7262c56f9bcd5e0f16e Mon Sep 17 00:00:00 2001
From: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
Date: Thu, 8 Aug 2019 10:38:00 -0700
Subject: [PATCH] pmbus: add 'fault' and 'beep' attributes

This commit adds two more attirbutes to reflect MFR_SPECIFIC bit in
the STATUS_WORD and 'Unit Off For Insufficient Input Voltage' bit in
the STATUS_INPUT into 'fault' and 'beep' attributes respectively.

The attributes will be enumerated as 'inX_fault' and 'inX_beep' in
a 'vin' group.

Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
---
 drivers/hwmon/pmbus/pmbus.h      |  1 +
 drivers/hwmon/pmbus/pmbus_core.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
index d198af3a92b6..09e6fe01c304 100644
--- a/drivers/hwmon/pmbus/pmbus.h
+++ b/drivers/hwmon/pmbus/pmbus.h
@@ -303,6 +303,7 @@ enum pmbus_fan_mode { percent = 0, rpm };
 #define PB_PIN_OP_WARNING		BIT(0)
 #define PB_IIN_OC_WARNING		BIT(1)
 #define PB_IIN_OC_FAULT			BIT(2)
+#define PB_UNIT_OFF_FOR_INSUF_VIN	BIT(3)
 
 /*
  * STATUS_TEMPERATURE
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 898d7378f4f8..85295a45c3ba 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -1163,6 +1163,8 @@ struct pmbus_limit_attr {
 struct pmbus_sensor_attr {
 	u16 reg;			/* sensor register */
 	u16 gbit;			/* generic status bit */
+	u16 gfbit;			/* generic fault status bit */
+	u16 sbbit;			/* beep status bit */
 	u8 nlimit;			/* # of limit registers */
 	enum pmbus_sensor_classes class;/* sensor class */
 	const char *label;		/* sensor label */
@@ -1264,6 +1266,32 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client,
 				return ret;
 		}
 	}
+	/*
+	 * Add fault attribute if there is a generic fault bit, and if
+	 * the generic status register (word or byte, depending on which global
+	 * bit is set) for this page is accessible.
+	 */
+	if (attr->gfbit) {
+		upper = !!(attr->gfbit & 0xff00); /* need to check STATUS_WORD */
+		if ((!upper || (upper && data->has_status_word)) &&
+		    pmbus_check_status_register(client, page)) {
+			ret = pmbus_add_boolean(data, name, "fault", index,
+						NULL, NULL,
+						PB_STATUS_BASE + page,
+						attr->gfbit);
+			if (ret)
+				return ret;
+		}
+	}
+	/* Add beep attribute if there is a beep status bit. */
+	if (attr->sbbit) {
+		ret = pmbus_add_boolean(data, name, "beep", index,
+					NULL, NULL,
+					attr->sbase + page,
+					attr->sbbit);
+		if (ret)
+			return ret;
+	}
 	return 0;
 }
 
@@ -1435,6 +1463,8 @@ static const struct pmbus_sensor_attr voltage_attributes[] = {
 		.gbit = PB_STATUS_VIN_UV,
 		.limit = vin_limit_attrs,
 		.nlimit = ARRAY_SIZE(vin_limit_attrs),
+		.gfbit = PB_STATUS_WORD_MFR,
+		.sbbit = PB_UNIT_OFF_FOR_INSUF_VIN,
 	}, {
 		.reg = PMBUS_VIRT_READ_VMON,
 		.class = PSC_VOLTAGE_IN,
-- 
2.7.4