From: Naresh Solanki <naresh.solanki@9elements.com>
To: Guenter Roeck <linux@roeck-us.net>,
linux-hwmon@vger.kernel.org, Jean Delvare <jdelvare@suse.com>
Cc: broonie@kernel.org, Naresh Solanki <Naresh.Solanki@9elements.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/3] hwmon: (pmbus/core): Update regulator flag map
Date: Tue, 22 Nov 2022 12:32:55 +0100 [thread overview]
Message-ID: <20221122113257.3213700-1-Naresh.Solanki@9elements.com> (raw)
Add regulator flag map for PMBUS status byte & status input.
Signed-off-by: Naresh Solanki <Naresh.Solanki@9elements.com>
---
drivers/hwmon/pmbus/pmbus_core.c | 52 +++++++++++++++++---------------
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 20ca26e19db7..08f96e2b4837 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -2756,26 +2756,47 @@ static const struct pmbus_regulator_status_category pmbus_regulator_flag_map[] =
.reg = PMBUS_STATUS_VOUT,
.bits = (const struct pmbus_regulator_status_assoc[]) {
{ PB_VOLTAGE_UV_WARNING, REGULATOR_ERROR_UNDER_VOLTAGE_WARN },
- { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE },
+ { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE },
{ PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN },
- { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_REGULATION_OUT },
+ { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_REGULATION_OUT },
{ },
},
}, {
.func = PMBUS_HAVE_STATUS_IOUT,
.reg = PMBUS_STATUS_IOUT,
.bits = (const struct pmbus_regulator_status_assoc[]) {
- { PB_IOUT_OC_WARNING, REGULATOR_ERROR_OVER_CURRENT_WARN },
- { PB_IOUT_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT },
- { PB_IOUT_OC_LV_FAULT, REGULATOR_ERROR_OVER_CURRENT },
+ { PB_IOUT_OC_WARNING, REGULATOR_ERROR_OVER_CURRENT_WARN },
+ { PB_IOUT_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT },
+ { PB_IOUT_OC_LV_FAULT, REGULATOR_ERROR_OVER_CURRENT },
+ { PB_POUT_OP_FAULT, REGULATOR_ERROR_OVER_CURRENT },
{ },
},
}, {
.func = PMBUS_HAVE_STATUS_TEMP,
.reg = PMBUS_STATUS_TEMPERATURE,
.bits = (const struct pmbus_regulator_status_assoc[]) {
- { PB_TEMP_OT_WARNING, REGULATOR_ERROR_OVER_TEMP_WARN },
- { PB_TEMP_OT_FAULT, REGULATOR_ERROR_OVER_TEMP },
+ { PB_TEMP_OT_WARNING, REGULATOR_ERROR_OVER_TEMP_WARN },
+ { PB_TEMP_OT_FAULT, REGULATOR_ERROR_OVER_TEMP },
+ { },
+ },
+ }, {
+ .func = -1,
+ .reg = PMBUS_STATUS_BYTE,
+ .bits = (const struct pmbus_regulator_status_assoc[]) {
+ { PB_STATUS_IOUT_OC, REGULATOR_ERROR_OVER_CURRENT },
+ { PB_STATUS_VOUT_OV, REGULATOR_ERROR_REGULATION_OUT },
+ { PB_STATUS_VIN_UV, REGULATOR_ERROR_UNDER_VOLTAGE },
+ { PB_STATUS_NONE_ABOVE, REGULATOR_ERROR_FAIL },
+ { },
+ },
+ }, {
+ .func = PMBUS_HAVE_STATUS_INPUT,
+ .reg = PMBUS_STATUS_INPUT,
+ .bits = (const struct pmbus_regulator_status_assoc[]) {
+ { PB_IIN_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT },
+ { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_OVER_VOLTAGE_WARN },
+ { PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN },
+ { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE },
{ },
},
},
@@ -2834,23 +2855,6 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned
if (status & PB_STATUS_POWER_GOOD_N)
*flags |= REGULATOR_ERROR_REGULATION_OUT;
}
- /*
- * Unlike most other status bits, PB_STATUS_{IOUT_OC,VOUT_OV} are
- * defined strictly as fault indicators (not warnings).
- */
- if (status & PB_STATUS_IOUT_OC)
- *flags |= REGULATOR_ERROR_OVER_CURRENT;
- if (status & PB_STATUS_VOUT_OV)
- *flags |= REGULATOR_ERROR_REGULATION_OUT;
-
- /*
- * If we haven't discovered any thermal faults or warnings via
- * PMBUS_STATUS_TEMPERATURE, map PB_STATUS_TEMPERATURE to a warning as
- * a (conservative) best-effort interpretation.
- */
- if (!(*flags & (REGULATOR_ERROR_OVER_TEMP | REGULATOR_ERROR_OVER_TEMP_WARN)) &&
- (status & PB_STATUS_TEMPERATURE))
- *flags |= REGULATOR_ERROR_OVER_TEMP_WARN;
return 0;
}
base-commit: 2c71b3246ec3246522e8cb7c8191dc7a5d62cc70
--
2.37.3
next reply other threads:[~2022-11-22 11:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 11:32 Naresh Solanki [this message]
2022-11-22 11:32 ` [PATCH 2/3] hwmon: (pmbus/core): Add events to regulator flag map Naresh Solanki
2022-11-22 11:32 ` [PATCH 3/3] hwmon: (pmbus/core): Implement IRQ support Naresh Solanki
-- strict thread matches above, loose matches on Subject: below --
2022-11-22 13:50 [PATCH 1/3] hwmon: (pmbus/core): Update regulator flag map Naresh Solanki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221122113257.3213700-1-Naresh.Solanki@9elements.com \
--to=naresh.solanki@9elements.com \
--cc=broonie@kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox