[PATCH linux dev-5.3 1/4] fsi: aspeed: Add clock debugfs file

Joel Stanley joel at jms.id.au
Wed Oct 23 17:18:45 AEDT 2019


From: Jeremy Kerr <jk at ozlabs.org>

This can be used to adjust the divisor for the FSI bus clock.

Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 drivers/fsi/fsi-master-aspeed.c | 47 +++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/drivers/fsi/fsi-master-aspeed.c b/drivers/fsi/fsi-master-aspeed.c
index 95b7f833e8bc..60d302871db3 100644
--- a/drivers/fsi/fsi-master-aspeed.c
+++ b/drivers/fsi/fsi-master-aspeed.c
@@ -483,6 +483,50 @@ DEFINE_DEBUGFS_ATTRIBUTE(fsi_master_aspeed_debugfs_ops,
 			 fsi_master_aspeed_debugfs_get,
 			 fsi_master_aspeed_debugfs_set, "0x%08llx\n");
 
+static int fsi_master_aspeed_clock_debugfs_get(void *data, u64 *val)
+{
+	struct fsi_master_aspeed *aspeed = data;
+	u32 out;
+	int rc;
+
+	rc = opb_read(aspeed->base, ctrl_base, 4, &out);
+	if (rc)
+		return rc;
+
+	*val = (u64)((be32_to_cpu(out) >> 18) & 0x3ff);
+
+	return 0;
+}
+
+static int fsi_master_aspeed_clock_debugfs_set(void *data, u64 val)
+{
+	struct fsi_master_aspeed *aspeed = data;
+	u32 reg, rc;
+	__be32 raw;
+
+	if (val > 0x3ff)
+		return -EINVAL;
+
+	rc = opb_read(aspeed->base, ctrl_base, 4, &raw);
+	if (rc)
+		return rc;
+
+	reg = be32_to_cpu(raw);
+
+	reg &= ~(0x3ff << 18);
+	reg |= (val & 0x3ff) << 18;
+
+	rc = opb_write(aspeed->base, ctrl_base, cpu_to_be32(reg), 4);
+	if (rc)
+		return rc;
+
+	return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fsi_master_aspeed_clock_debugfs_ops,
+			 fsi_master_aspeed_clock_debugfs_get,
+			 fsi_master_aspeed_clock_debugfs_set, "0x%llx\n");
+
+
 static int fsi_master_aspeed_probe(struct platform_device *pdev)
 {
 	struct fsi_master_aspeed *aspeed;
@@ -642,6 +686,9 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev)
 		debugfs_create_file("mectrl", 0644, aspeed->debugfs_dir,
 				    &etrs[idx++],
 				    &fsi_master_aspeed_debugfs_ops);
+
+		debugfs_create_file("clock_div", 0644, aspeed->debugfs_dir,
+				aspeed, &fsi_master_aspeed_clock_debugfs_ops);
 	}
 
 	rc = fsi_master_register(&aspeed->master);
-- 
2.23.0



More information about the openbmc mailing list