mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-02 16:44:10 +08:00
mmc: add a file to debugfs for changing host clock at runtime
For debugging power management features it is convenient to have the possibility of changing the MMC host controller clock at runtime. This patch adds a 'clock' file for this under the MMC host root of debugfs. Usage is as follows: # cat /sys/kernel/debug/mmc0/clock 52000000 # echo "1000000000" > /sys/kernel/debug/mmc0/clock # cat /sys/kernel/debug/mmc0/clock 52000000 # echo "48000000" > /sys/kernel/debug/mmc0/clock # cat /sys/kernel/debug/mmc0/clock 48000000 The middle example shows limits being applied by the host driver. Signed-off-by: Andy Shevchenko <ext-andriy.shevchenko@nokia.com> Cc: Adrian Hunter <adrian.hunter@nokia.com> [cjb: modify changelog language] Signed-off-by: Chris Ball <cjb@laptop.org>
This commit is contained in:
parent
643a81ff3c
commit
703aae3d09
@ -134,6 +134,33 @@ static const struct file_operations mmc_ios_fops = {
|
||||
.release = single_release,
|
||||
};
|
||||
|
||||
static int mmc_clock_opt_get(void *data, u64 *val)
|
||||
{
|
||||
struct mmc_host *host = data;
|
||||
|
||||
*val = host->ios.clock;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mmc_clock_opt_set(void *data, u64 val)
|
||||
{
|
||||
struct mmc_host *host = data;
|
||||
|
||||
/* We need this check due to input value is u64 */
|
||||
if (val > host->f_max)
|
||||
return -EINVAL;
|
||||
|
||||
mmc_claim_host(host);
|
||||
mmc_set_clock(host, (unsigned int) val);
|
||||
mmc_release_host(host);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set,
|
||||
"%llu\n");
|
||||
|
||||
void mmc_add_host_debugfs(struct mmc_host *host)
|
||||
{
|
||||
struct dentry *root;
|
||||
@ -150,11 +177,15 @@ void mmc_add_host_debugfs(struct mmc_host *host)
|
||||
host->debugfs_root = root;
|
||||
|
||||
if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops))
|
||||
goto err_ios;
|
||||
goto err_node;
|
||||
|
||||
if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host,
|
||||
&mmc_clock_fops))
|
||||
goto err_node;
|
||||
|
||||
return;
|
||||
|
||||
err_ios:
|
||||
err_node:
|
||||
debugfs_remove_recursive(root);
|
||||
host->debugfs_root = NULL;
|
||||
err_root:
|
||||
|
Loading…
Reference in New Issue
Block a user