diff options
author | Mikko Perttunen <mperttunen@nvidia.com> | 2015-03-12 17:48:06 +0300 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2015-05-05 12:39:48 +0300 |
commit | 9c77a81f215bfeee8f96c50c8ab27dbebffec80d (patch) | |
tree | a4249ef84e5da6a23c907b4e742dd39124ada3ff /drivers | |
parent | 73a7f0a90641b09300d47308682b674c570dd6a2 (diff) | |
download | linux-9c77a81f215bfeee8f96c50c8ab27dbebffec80d.tar.xz |
memory: tegra: Add EMC frequency debugfs entry
This file in debugfs can be used to get or set the EMC frequency.
Reading the file will return the currently set frequency in Hz, while
writing the file sets the specified frequency rounded to the next
highest frequency supported by the board.
Will be very useful when tuning memory scaling.
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
[treding@nvidia.com: add "emc" debugfs directory]
Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/memory/tegra/tegra124-emc.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/memory/tegra/tegra124-emc.c b/drivers/memory/tegra/tegra124-emc.c index 900504c01a64..8620355776fe 100644 --- a/drivers/memory/tegra/tegra124-emc.c +++ b/drivers/memory/tegra/tegra124-emc.c @@ -18,6 +18,7 @@ #include <linux/clk-provider.h> #include <linux/clk.h> #include <linux/clkdev.h> +#include <linux/debugfs.h> #include <linux/delay.h> #include <linux/of_address.h> #include <linux/of_platform.h> @@ -1005,6 +1006,50 @@ tegra_emc_find_node_by_ram_code(struct device_node *node, u32 ram_code) return NULL; } +/* Debugfs entry */ + +static int emc_debug_rate_get(void *data, u64 *rate) +{ + struct clk *c = data; + + *rate = clk_get_rate(c); + + return 0; +} + +static int emc_debug_rate_set(void *data, u64 rate) +{ + struct clk *c = data; + + return clk_set_rate(c, rate); +} + +DEFINE_SIMPLE_ATTRIBUTE(emc_debug_rate_fops, emc_debug_rate_get, + emc_debug_rate_set, "%lld\n"); + +static void emc_debugfs_init(struct device *dev) +{ + struct dentry *root, *file; + struct clk *clk; + + root = debugfs_create_dir("emc", NULL); + if (!root) { + dev_err(dev, "failed to create debugfs directory\n"); + return; + } + + clk = clk_get_sys("tegra-clk-debug", "emc"); + if (IS_ERR(clk)) { + dev_err(dev, "failed to get debug clock: %ld\n", PTR_ERR(clk)); + return; + } + + file = debugfs_create_file("rate", S_IRUGO | S_IWUSR, root, clk, + &emc_debug_rate_fops); + if (!file) + dev_err(dev, "failed to create debugfs entry\n"); +} + static int tegra_emc_probe(struct platform_device *pdev) { struct platform_device *mc; @@ -1073,6 +1118,9 @@ static int tegra_emc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, emc); + if (IS_ENABLED(CONFIG_DEBUG_FS)) + emc_debugfs_init(&pdev->dev); + return 0; }; |