From: rentao.bupt@gmail.com
To: Guenter Roeck <linux@roeck-us.net>,
Jean Delvare <jdelvare@suse.com>,
Jonathan Corbet <corbet@lwn.net>,
linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org,
taoren@fb.com
Cc: Tao Ren <rentao.bupt@gmail.com>
Subject: [PATCH 2/3] hwmon: (pmbus) add BEL PFE3000 power supply driver
Date: Mon, 28 Oct 2019 16:49:03 -0700 [thread overview]
Message-ID: <20191028234904.12441-3-rentao.bupt@gmail.com> (raw)
In-Reply-To: <20191028234904.12441-1-rentao.bupt@gmail.com>
From: Tao Ren <rentao.bupt@gmail.com>
Add the driver to support BEL PFE3000 which is 3000 Wat AC to DC power
supply. The chip has 8 pages.
Signed-off-by: Tao Ren <rentao.bupt@gmail.com>
---
drivers/hwmon/pmbus/bel-pfe.c | 65 ++++++++++++++++++++++++++++++++++-
1 file changed, 64 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/bel-pfe.c b/drivers/hwmon/pmbus/bel-pfe.c
index 117f9af21bf3..7b6c90b056c9 100644
--- a/drivers/hwmon/pmbus/bel-pfe.c
+++ b/drivers/hwmon/pmbus/bel-pfe.c
@@ -10,9 +10,21 @@
#include <linux/init.h>
#include <linux/err.h>
#include <linux/i2c.h>
+#include <linux/pmbus.h>
+
#include "pmbus.h"
-enum chips {pfe1100};
+enum chips {pfe1100, pfe3000};
+
+/*
+ * Disable status check for pfe3000 devices, because some devices report
+ * communication error (invalid command) for VOUT_MODE command (0x20)
+ * although correct VOUT_MODE (0x16) is returned: it leads to incorrect
+ * exponent in linear mode.
+ */
+static struct pmbus_platform_data pfe3000_plat_data = {
+ .flags = PMBUS_SKIP_STATUS_CHECK,
+};
static struct pmbus_driver_info pfe_driver_info[] = {
[pfe1100] = {
@@ -34,6 +46,45 @@ static struct pmbus_driver_info pfe_driver_info[] = {
PMBUS_HAVE_STATUS_TEMP |
PMBUS_HAVE_FAN12,
},
+
+ [pfe3000] = {
+ .pages = 8,
+ .format[PSC_VOLTAGE_IN] = linear,
+ .format[PSC_VOLTAGE_OUT] = linear,
+ .format[PSC_CURRENT_IN] = linear,
+ .format[PSC_CURRENT_OUT] = linear,
+ .format[PSC_POWER] = linear,
+ .format[PSC_TEMPERATURE] = linear,
+ .format[PSC_FAN] = linear,
+
+ /* Page 0: V1. */
+ .func[0] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
+ PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
+ PMBUS_HAVE_POUT | PMBUS_HAVE_FAN12 |
+ PMBUS_HAVE_VIN | PMBUS_HAVE_IIN |
+ PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT |
+ PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 |
+ PMBUS_HAVE_TEMP3 | PMBUS_HAVE_STATUS_TEMP |
+ PMBUS_HAVE_VCAP,
+
+ /* Page 1: Vsb. */
+ .func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT |
+ PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT |
+ PMBUS_HAVE_PIN | PMBUS_HAVE_STATUS_INPUT |
+ PMBUS_HAVE_POUT,
+
+ /*
+ * Page 2: V1 Ishare.
+ * Page 4: V1 Cathode.
+ * Page 5: Vsb Cathode.
+ * Page 6: V1 Sense.
+ * Page 3 and 7 are reserved.
+ */
+ .func[2] = PMBUS_HAVE_VOUT,
+ .func[4] = PMBUS_HAVE_VOUT,
+ .func[5] = PMBUS_HAVE_VOUT,
+ .func[6] = PMBUS_HAVE_VOUT,
+ },
};
static int pfe_pmbus_probe(struct i2c_client *client,
@@ -42,11 +93,23 @@ static int pfe_pmbus_probe(struct i2c_client *client,
int model;
model = (int)id->driver_data;
+
+ /*
+ * PFE3000-12-069RA devices may not stay in page 0 during device
+ * probe which leads to probe failure (read status word failed).
+ * So let's set the device to page 0 at the beginning.
+ */
+ if (model == pfe3000) {
+ client->dev.platform_data = &pfe3000_plat_data;
+ i2c_smbus_write_byte_data(client, PMBUS_PAGE, 0);
+ }
+
return pmbus_do_probe(client, id, &pfe_driver_info[model]);
}
static const struct i2c_device_id pfe_device_id[] = {
{"pfe1100", pfe1100},
+ {"pfe3000", pfe3000},
{}
};
--
2.17.1
next prev parent reply other threads:[~2019-10-28 23:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-28 23:49 [PATCH 0/3] hwmon: (pmbus) add driver for BEL PFE1100 and PFE3000 rentao.bupt
2019-10-28 23:49 ` [PATCH 1/3] hwmon: (pmbus) add BEL PFE1100 power supply driver rentao.bupt
2019-10-29 12:42 ` Guenter Roeck
2019-10-29 17:53 ` Tao Ren
2019-10-28 23:49 ` rentao.bupt [this message]
2019-10-29 12:50 ` [PATCH 2/3] hwmon: (pmbus) add BEL PFE3000 " Guenter Roeck
2019-10-29 17:58 ` Tao Ren
2019-10-28 23:49 ` [PATCH 3/3] docs: hwmon: Document bel-pfe pmbus driver rentao.bupt
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=20191028234904.12441-3-rentao.bupt@gmail.com \
--to=rentao.bupt@gmail.com \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=openbmc@lists.ozlabs.org \
--cc=taoren@fb.com \
/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;
as well as URLs for NNTP newsgroup(s).