Skip to content

Commit 30a636f

Browse files
committed
memory: tegra: Expose supported rates via debugfs
In order to ease testing, expose the list of supported EMC frequencies via debugfs. Reviewed-by: Tomeu Vizoso <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent d770e55 commit 30a636f

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

drivers/memory/tegra/tegra124-emc.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,40 @@ static int emc_debug_rate_set(void *data, u64 rate)
10271027
DEFINE_SIMPLE_ATTRIBUTE(emc_debug_rate_fops, emc_debug_rate_get,
10281028
emc_debug_rate_set, "%lld\n");
10291029

1030-
static void emc_debugfs_init(struct device *dev)
1030+
static int emc_debug_supported_rates_show(struct seq_file *s, void *data)
1031+
{
1032+
struct tegra_emc *emc = s->private;
1033+
const char *prefix = "";
1034+
unsigned int i;
1035+
1036+
for (i = 0; i < emc->num_timings; i++) {
1037+
struct emc_timing *timing = &emc->timings[i];
1038+
1039+
seq_printf(s, "%s%lu", prefix, timing->rate);
1040+
1041+
prefix = " ";
1042+
}
1043+
1044+
seq_puts(s, "\n");
1045+
1046+
return 0;
1047+
}
1048+
1049+
static int emc_debug_supported_rates_open(struct inode *inode,
1050+
struct file *file)
1051+
{
1052+
return single_open(file, emc_debug_supported_rates_show,
1053+
inode->i_private);
1054+
}
1055+
1056+
static const struct file_operations emc_debug_supported_rates_fops = {
1057+
.open = emc_debug_supported_rates_open,
1058+
.read = seq_read,
1059+
.llseek = seq_lseek,
1060+
.release = single_release,
1061+
};
1062+
1063+
static void emc_debugfs_init(struct device *dev, struct tegra_emc *emc)
10311064
{
10321065
struct dentry *root, *file;
10331066
struct clk *clk;
@@ -1048,6 +1081,11 @@ static void emc_debugfs_init(struct device *dev)
10481081
&emc_debug_rate_fops);
10491082
if (!file)
10501083
dev_err(dev, "failed to create debugfs entry\n");
1084+
1085+
file = debugfs_create_file("supported_rates", S_IRUGO, root, emc,
1086+
&emc_debug_supported_rates_fops);
1087+
if (!file)
1088+
dev_err(dev, "failed to create debugfs entry\n");
10511089
}
10521090

10531091
static int tegra_emc_probe(struct platform_device *pdev)
@@ -1119,7 +1157,7 @@ static int tegra_emc_probe(struct platform_device *pdev)
11191157
platform_set_drvdata(pdev, emc);
11201158

11211159
if (IS_ENABLED(CONFIG_DEBUG_FS))
1122-
emc_debugfs_init(&pdev->dev);
1160+
emc_debugfs_init(&pdev->dev, emc);
11231161

11241162
return 0;
11251163
};

0 commit comments

Comments
 (0)