From: Eddie James <eajames@linux.ibm.com>
To: linux-fsi@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
linux-spi@vger.kernel.org, broonie@kernel.org,
andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au,
jk@ozlabs.org, andrew@codeconstruct.com.au,
linux-aspeed@lists.ozlabs.org, eajames@linux.ibm.com
Subject: [PATCH v3 34/40] fsi: core: Add master register read-only sysfs
Date: Thu, 16 May 2024 13:19:01 -0500 [thread overview]
Message-ID: <20240516181907.3468796-35-eajames@linux.ibm.com> (raw)
In-Reply-To: <20240516181907.3468796-1-eajames@linux.ibm.com>
The master registers are commonly used for debugging or diagnosis so
provide them in sysfs files.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
drivers/fsi/fsi-core.c | 144 +++++++++++++++++++++++++++++++++++++++
drivers/fsi/fsi-master.h | 6 ++
2 files changed, 150 insertions(+)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index ae65d87d4b13e..096b26c6421f2 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -1392,6 +1392,141 @@ static ssize_t master_break_store(struct device *dev,
static DEVICE_ATTR(break, 0200, NULL, master_break_store);
+struct fsi_master_attribute {
+ struct device_attribute attr;
+ int reg;
+};
+
+static ssize_t master_reg_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct fsi_master_attribute *fattr = container_of(attr, struct fsi_master_attribute, attr);
+ struct fsi_master *master = to_fsi_master(dev);
+ unsigned int reg;
+ int rc;
+
+ rc = regmap_read(master->map, fattr->reg, ®);
+ if (rc)
+ return rc;
+
+ return sysfs_emit(buf, "%08x\n", reg);
+}
+
+static ssize_t master_reg_1bpp_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct fsi_master_attribute *fattr = container_of(attr, struct fsi_master_attribute, attr);
+ struct fsi_master *master = to_fsi_master(dev);
+ unsigned int count = (master->n_links + 31) / 32;
+ unsigned int reg;
+ unsigned int i;
+ int len = 0;
+ int rc;
+
+ for (i = 0; i < count; ++i) {
+ rc = regmap_read(master->map, fattr->reg + (i * 4), ®);
+ if (rc)
+ return rc;
+
+ len += sysfs_emit_at(buf, len, "%08x\n", reg);
+ }
+
+ return len;
+}
+
+static ssize_t master_reg_4bpp_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct fsi_master_attribute *fattr = container_of(attr, struct fsi_master_attribute, attr);
+ struct fsi_master *master = to_fsi_master(dev);
+ unsigned int count = (master->n_links + 7) / 8;
+ unsigned int reg;
+ unsigned int i;
+ int len = 0;
+ int rc;
+
+ for (i = 0; i < count; ++i) {
+ rc = regmap_read(master->map, fattr->reg + (i * 4), ®);
+ if (rc)
+ return rc;
+
+ len += sysfs_emit_at(buf, len, "%08x\n", reg);
+ }
+
+ return len;
+}
+
+static ssize_t master_reg_32bpp_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct fsi_master_attribute *fattr = container_of(attr, struct fsi_master_attribute, attr);
+ struct fsi_master *master = to_fsi_master(dev);
+ unsigned int reg;
+ int len = 0;
+ int rc;
+ int i;
+
+ for (i = 0; i < master->n_links; ++i) {
+ rc = regmap_read(master->map, fattr->reg + (i * 4), ®);
+ if (rc)
+ return rc;
+
+ len += sysfs_emit_at(buf, len, "%08x\n", reg);
+ }
+
+ return len;
+}
+
+#define FSI_MASTER_ATTR(name, reg) \
+ struct fsi_master_attribute dev_attr_##name = { __ATTR(name, 0444, master_reg_show, NULL), reg }
+#define FSI_MASTER_ATTR_1BPP(name, reg) \
+ struct fsi_master_attribute dev_attr_##name = { __ATTR(name, 0444, master_reg_1bpp_show, NULL), reg }
+#define FSI_MASTER_ATTR_4BPP(name, reg) \
+ struct fsi_master_attribute dev_attr_##name = { __ATTR(name, 0444, master_reg_4bpp_show, NULL), reg }
+#define FSI_MASTER_ATTR_32BPP(name, reg) \
+ struct fsi_master_attribute dev_attr_##name = { __ATTR(name, 0444, master_reg_32bpp_show, NULL), reg }
+
+static FSI_MASTER_ATTR(mmode, FSI_MMODE);
+static FSI_MASTER_ATTR(mdlyr, FSI_MDLYR);
+static FSI_MASTER_ATTR_1BPP(mcrsp, FSI_MCRSP);
+static FSI_MASTER_ATTR_1BPP(menp, FSI_MENP0);
+static FSI_MASTER_ATTR_1BPP(mlevp, FSI_MLEVP0);
+static FSI_MASTER_ATTR_1BPP(mrefp, FSI_MREFP0);
+static FSI_MASTER_ATTR_1BPP(mhpmp, FSI_MHPMP0);
+static FSI_MASTER_ATTR_4BPP(msiep, FSI_MSIEP0);
+static FSI_MASTER_ATTR_1BPP(maesp, FSI_MAESP0);
+static FSI_MASTER_ATTR(maeb, FSI_MAEB);
+static FSI_MASTER_ATTR(mver, FSI_MVER);
+static FSI_MASTER_ATTR_1BPP(mbsyp, FSI_MBSYP0);
+static FSI_MASTER_ATTR_32BPP(mstap, FSI_MSTAP0);
+static FSI_MASTER_ATTR(mesrb, FSI_MESRB0);
+static FSI_MASTER_ATTR(mscsb, FSI_MSCSB0);
+static FSI_MASTER_ATTR(matrb, FSI_MATRB0);
+static FSI_MASTER_ATTR(mdtrb, FSI_MDTRB0);
+static FSI_MASTER_ATTR(mectrl, FSI_MECTRL);
+
+static struct attribute *master_mapped_attrs[] = {
+ &dev_attr_mmode.attr.attr,
+ &dev_attr_mdlyr.attr.attr,
+ &dev_attr_mcrsp.attr.attr,
+ &dev_attr_menp.attr.attr,
+ &dev_attr_mlevp.attr.attr,
+ &dev_attr_mrefp.attr.attr,
+ &dev_attr_mhpmp.attr.attr,
+ &dev_attr_msiep.attr.attr,
+ &dev_attr_maesp.attr.attr,
+ &dev_attr_maeb.attr.attr,
+ &dev_attr_mver.attr.attr,
+ &dev_attr_mbsyp.attr.attr,
+ &dev_attr_mstap.attr.attr,
+ &dev_attr_mesrb.attr.attr,
+ &dev_attr_mscsb.attr.attr,
+ &dev_attr_matrb.attr.attr,
+ &dev_attr_mdtrb.attr.attr,
+ &dev_attr_mectrl.attr.attr,
+ NULL
+};
+
+static const struct attribute_group master_mapped_group = {
+ .attrs = master_mapped_attrs,
+};
+
static struct attribute *master_attrs[] = {
&dev_attr_break.attr,
&dev_attr_rescan.attr,
@@ -1665,6 +1800,12 @@ int fsi_master_register(struct fsi_master *master)
}
out:
mutex_unlock(&master->scan_lock);
+
+ if (!rc && master->map) {
+ if (!sysfs_create_group(&master->dev.kobj, &master_mapped_group))
+ master->groups = true;
+ }
+
return rc;
}
EXPORT_SYMBOL_GPL(fsi_master_register);
@@ -1675,6 +1816,9 @@ void fsi_master_unregister(struct fsi_master *master)
trace_fsi_master_unregister(master);
+ if (master->groups)
+ sysfs_remove_group(&master->dev.kobj, &master_mapped_group);
+
mutex_lock(&master->scan_lock);
fsi_master_unscan(master);
master->n_links = 0;
diff --git a/drivers/fsi/fsi-master.h b/drivers/fsi/fsi-master.h
index 2104902091e05..1fa101a477899 100644
--- a/drivers/fsi/fsi-master.h
+++ b/drivers/fsi/fsi-master.h
@@ -12,6 +12,7 @@
#include <linux/device.h>
#include <linux/irq.h>
#include <linux/mutex.h>
+#include <linux/sysfs.h>
/*
* Master registers
@@ -27,12 +28,16 @@
#define FSI_MENP0 0x10 /* R/W: enable */
#define FSI_MLEVP0 0x18 /* R: plug detect */
#define FSI_MSENP0 0x18 /* S: Set enable */
+#define FSI_MREFP0 0x20 /* R: Plug reference */
#define FSI_MCENP0 0x20 /* C: Clear enable */
+#define FSI_MHPMP0 0x28 /* R: Plug monitor */
#define FSI_MSIEP0 0x30 /* R/W: interrupt enable */
+#define FSI_MAESP0 0x50 /* R: Any error port */
#define FSI_MSSIEP0 0x50 /* S: Set interrupt enable */
#define FSI_MCSIEP0 0x70 /* C: Clear interrupt enable */
#define FSI_MAEB 0x70 /* R: Error address */
#define FSI_MVER 0x74 /* R: master version/type */
+#define FSI_MBSYP0 0x78 /* R: Port busy */
#define FSI_MSTAP0 0xd0 /* R: Port status */
#define FSI_MRESP0 0xd0 /* W: Port reset */
#define FSI_MESRB0 0x1d0 /* R: Master error status */
@@ -151,6 +156,7 @@ struct fsi_master {
int (*link_config)(struct fsi_master *, int link,
u8 t_send_delay, u8 t_echo_delay);
u8 remote_interrupt_status;
+ bool groups;
};
#define to_fsi_master(d) container_of(d, struct fsi_master, dev)
--
2.39.3
next prev parent reply other threads:[~2024-05-16 18:19 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-16 18:18 [PATCH v3 00/40] fsi: Add interrupt support Eddie James
2024-05-16 18:18 ` [PATCH v3 01/40] fsi: hub: Set master index to link number plus one Eddie James
2024-05-16 18:18 ` [PATCH v3 02/40] fsi: Move slave definitions to fsi-slave.h Eddie James
2024-05-16 18:18 ` [PATCH v3 03/40] fsi: Fix slave addressing after break command Eddie James
2024-05-16 18:18 ` [PATCH v3 04/40] fsi: Use a defined value for default echo delay Eddie James
2024-05-16 18:18 ` [PATCH v3 05/40] fsi: Calculate local bus clock frequency Eddie James
2024-05-16 18:18 ` [PATCH v3 06/40] fsi: core: Improve master read/write/error traces Eddie James
2024-05-16 18:18 ` [PATCH v3 07/40] fsi: core: Add slave error trace Eddie James
2024-05-16 18:18 ` [PATCH v3 08/40] fsi: core: Reset errors instead of clearing interrupts Eddie James
2024-05-16 18:18 ` [PATCH v3 09/40] fsi: aspeed: Add AST2700 support Eddie James
2024-05-16 18:18 ` [PATCH v3 10/40] fsi: core: Add slave spinlock Eddie James
2024-05-16 18:18 ` [PATCH v3 11/40] fsi: core: Allow cfam device type aliases Eddie James
2024-05-16 18:18 ` [PATCH v3 12/40] fsi: core: Add common regmap master functions Eddie James
2024-05-16 18:18 ` [PATCH v3 13/40] fsi: core: Disable relative addressing during scan Eddie James
2024-05-16 18:18 ` [PATCH v3 14/40] fsi: hub: Use common initialization and link enable Eddie James
2024-05-16 18:18 ` [PATCH v3 15/40] fsi: aspeed: " Eddie James
2024-05-16 18:18 ` [PATCH v3 16/40] fsi: aspeed: Remove cfam reset sysfs file in error path and remove Eddie James
2024-05-16 18:18 ` [PATCH v3 17/40] fsi: aspeed: Refactor trace functions Eddie James
2024-05-16 18:18 ` [PATCH v3 18/40] fsi: aspeed: Don't clear all IRQs during OPB transfers Eddie James
2024-05-16 18:18 ` [PATCH v3 19/40] fsi: aspeed: Only read result register for successful read Eddie James
2024-05-16 18:18 ` [PATCH v3 20/40] fsi: aspeed: Switch to spinlock Eddie James
2024-05-16 18:18 ` [PATCH v3 21/40] fsi: aspeed: Disable relative addressing and IPOLL for cfam reset Eddie James
2024-05-16 18:18 ` [PATCH v3 22/40] fsi: aspeed: Use common master error handler Eddie James
2024-05-16 18:18 ` [PATCH v3 23/40] fsi: core: Add interrupt support Eddie James
2024-05-17 20:41 ` kernel test robot
2024-05-16 18:18 ` [PATCH v3 24/40] fsi: aspeed: " Eddie James
2024-05-16 18:18 ` [PATCH v3 25/40] fsi: hub: " Eddie James
2024-05-16 18:18 ` [PATCH v3 26/40] i2c: fsi: Calculate clock divider from local bus frequency Eddie James
2024-05-16 18:18 ` [PATCH v3 27/40] i2c: fsi: Improve formatting Eddie James
2024-05-16 18:18 ` [PATCH v3 28/40] i2c: fsi: Change fsi_i2c_write_reg to accept data instead of a pointer Eddie James
2024-05-16 18:18 ` [PATCH v3 29/40] i2c: fsi: Remove list structure of ports Eddie James
2024-05-16 18:18 ` [PATCH v3 30/40] i2c: fsi: Define a function to check status error bits Eddie James
2024-05-16 18:18 ` [PATCH v3 31/40] i2c: fsi: Add boolean for skip stop command on abort Eddie James
2024-05-16 18:18 ` [PATCH v3 32/40] i2c: fsi: Add interrupt support Eddie James
2024-05-16 18:19 ` [PATCH v3 33/40] fsi: hub master: Reset hub master after errors Eddie James
2024-05-16 18:19 ` Eddie James [this message]
2024-05-16 18:19 ` [PATCH v3 35/40] fsi: core: Add slave register read-only sysfs Eddie James
2024-05-16 18:19 ` [PATCH v3 36/40] fsi: i2cr: Adjust virtual CFAM ID to match Odyssey chip Eddie James
2024-05-16 18:19 ` [PATCH v3 37/40] fsi: core: Add different types of CFAM Eddie James
2024-05-17 12:38 ` kernel test robot
2024-05-17 15:49 ` kernel test robot
2024-05-18 1:03 ` kernel test robot
2024-05-16 18:19 ` [PATCH v3 38/40] spi: fsi: Calculate clock divider from local bus frequency Eddie James
2024-05-16 18:24 ` Mark Brown
2024-05-16 18:19 ` [PATCH v3 39/40] ARM: dts: aspeed: P10 and tacoma: Set FSI clock frequency Eddie James
2024-05-16 18:19 ` [PATCH v3 40/40] ARM: dts: aspeed: P10: Bump SPI max frequencies Eddie James
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=20240516181907.3468796-35-eajames@linux.ibm.com \
--to=eajames@linux.ibm.com \
--cc=alistair@popple.id.au \
--cc=andi.shyti@kernel.org \
--cc=andrew@codeconstruct.com.au \
--cc=broonie@kernel.org \
--cc=jk@ozlabs.org \
--cc=joel@jms.id.au \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-fsi@lists.ozlabs.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.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 read-only IMAP folder(s) and NNTP newsgroup(s).