From: <alexandru.tachici@analog.com>
To: <linux-hwmon@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<devicetree@vger.kernel.org>
Cc: <robh+dt@kernel.org>, <linux@roeck-us.net>,
Alexandru Tachici <alexandru.tachici@analog.com>
Subject: [PATCH v7 4/9] hwmon: pmbus: adm1266: add debugfs for states
Date: Mon, 27 Jul 2020 19:19:23 +0300 [thread overview]
Message-ID: <20200727161928.14122-5-alexandru.tachici@analog.com> (raw)
In-Reply-To: <20200727161928.14122-1-alexandru.tachici@analog.com>
From: Alexandru Tachici <alexandru.tachici@analog.com>
Add a debugfs entry which prints the current state
of the adm1266 sequencer.
Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
---
drivers/hwmon/pmbus/adm1266.c | 41 ++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c
index be911de02cf6..0ea016b7e113 100644
--- a/drivers/hwmon/pmbus/adm1266.c
+++ b/drivers/hwmon/pmbus/adm1266.c
@@ -19,6 +19,7 @@
#include <linux/slab.h>
#define ADM1266_PDIO_CONFIG 0xD4
+#define ADM1266_READ_STATE 0xD9
#define ADM1266_GPIO_CONFIG 0xE1
#define ADM1266_PDIO_STATUS 0xE9
#define ADM1266_GPIO_STATUS 0xEA
@@ -43,6 +44,7 @@ struct adm1266_data {
struct gpio_chip gc;
const char *gpio_names[ADM1266_GPIO_NR + ADM1266_PDIO_NR];
struct i2c_client *client;
+ struct dentry *debugfs_dir;
struct mutex buf_mutex;
u8 write_buf[ADM1266_PMBUS_BLOCK_MAX + 1] ____cacheline_aligned;
u8 read_buf[ADM1266_PMBUS_BLOCK_MAX + 1] ____cacheline_aligned;
@@ -287,6 +289,37 @@ static int adm1266_config_gpio(struct adm1266_data *data)
return ret;
}
+static int adm1266_state_read(struct seq_file *s, void *pdata)
+{
+ struct device *dev = s->private;
+ struct i2c_client *client = to_i2c_client(dev);
+ int ret;
+
+ ret = i2c_smbus_read_word_data(client, ADM1266_READ_STATE);
+ if (ret < 0)
+ return ret;
+
+ seq_printf(s, "%d\n", ret);
+
+ return 0;
+}
+
+static void adm1266_init_debugfs(struct adm1266_data *data)
+{
+ struct dentry *root;
+
+ root = pmbus_get_debugfs_dir(data->client);
+ if (!root)
+ return;
+
+ data->debugfs_dir = debugfs_create_dir(data->client->name, root);
+ if (!data->debugfs_dir)
+ return;
+
+ debugfs_create_devm_seqfile(&data->client->dev, "sequencer_state", data->debugfs_dir,
+ adm1266_state_read);
+}
+
static int adm1266_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
struct adm1266_data *data;
@@ -310,7 +343,13 @@ static int adm1266_probe(struct i2c_client *client, const struct i2c_device_id *
if (ret < 0)
return ret;
- return pmbus_do_probe(client, id, &data->info);
+ ret = pmbus_do_probe(client, id, &data->info);
+ if (ret)
+ return ret;
+
+ adm1266_init_debugfs(data);
+
+ return 0;
}
static const struct of_device_id adm1266_of_match[] = {
--
2.20.1
next prev parent reply other threads:[~2020-07-27 16:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-27 16:19 [PATCH v7 0/9] hwmon: pmbus: adm1266: add support alexandru.tachici
2020-07-27 16:19 ` [PATCH v7 1/9] " alexandru.tachici
2020-07-27 16:19 ` [PATCH v7 2/9] hwmon: pmbus: adm1266: Add Block process call alexandru.tachici
2020-08-05 11:55 ` Dan Carpenter
2020-07-27 16:19 ` [PATCH v7 3/9] hwmon: pmbus: adm1266: Add support for GPIOs alexandru.tachici
2020-08-07 16:05 ` Guenter Roeck
2020-07-27 16:19 ` alexandru.tachici [this message]
2020-07-27 16:19 ` [PATCH v7 5/9] hwmon: pmbus: adm1266: read blackbox alexandru.tachici
2020-07-27 16:19 ` [PATCH v7 6/9] hwmon: pmbus: adm1266: Add group command support alexandru.tachici
2020-07-27 16:19 ` [PATCH v7 7/9] hwmon: pmbus: adm1266: program firmware alexandru.tachici
2020-07-27 16:19 ` [PATCH v7 8/9] hwmon: pmbus: adm1266: program configuration alexandru.tachici
2020-07-27 16:19 ` [PATCH v7 9/9] dt-bindings: hwmon: Add bindings for ADM1266 alexandru.tachici
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=20200727161928.14122-5-alexandru.tachici@analog.com \
--to=alexandru.tachici@analog.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=robh+dt@kernel.org \
/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).