Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <tomeu.vizoso@collabora.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

+40 -2
+40 -2
drivers/memory/tegra/tegra124-emc.c
··· 1027 1027 DEFINE_SIMPLE_ATTRIBUTE(emc_debug_rate_fops, emc_debug_rate_get, 1028 1028 emc_debug_rate_set, "%lld\n"); 1029 1029 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) 1031 1064 { 1032 1065 struct dentry *root, *file; 1033 1066 struct clk *clk; ··· 1079 1046 1080 1047 file = debugfs_create_file("rate", S_IRUGO | S_IWUSR, root, clk, 1081 1048 &emc_debug_rate_fops); 1049 + if (!file) 1050 + dev_err(dev, "failed to create debugfs entry\n"); 1051 + 1052 + file = debugfs_create_file("supported_rates", S_IRUGO, root, emc, 1053 + &emc_debug_supported_rates_fops); 1082 1054 if (!file) 1083 1055 dev_err(dev, "failed to create debugfs entry\n"); 1084 1056 } ··· 1157 1119 platform_set_drvdata(pdev, emc); 1158 1120 1159 1121 if (IS_ENABLED(CONFIG_DEBUG_FS)) 1160 - emc_debugfs_init(&pdev->dev); 1122 + emc_debugfs_init(&pdev->dev, emc); 1161 1123 1162 1124 return 0; 1163 1125 };