2008-07-24 12:18:57 +00:00
|
|
|
/*
|
|
|
|
* Debugfs support for hosts and cards
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Atmel Corporation
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
2011-10-09 14:35:16 +00:00
|
|
|
#include <linux/moduleparam.h>
|
2011-07-10 16:42:00 +00:00
|
|
|
#include <linux/export.h>
|
2008-07-24 12:18:57 +00:00
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/seq_file.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2008-07-24 12:18:57 +00:00
|
|
|
#include <linux/stat.h>
|
2011-08-19 12:52:37 +00:00
|
|
|
#include <linux/fault-inject.h>
|
2008-07-24 12:18:57 +00:00
|
|
|
|
2008-07-24 12:18:58 +00:00
|
|
|
#include <linux/mmc/card.h>
|
2008-07-24 12:18:57 +00:00
|
|
|
#include <linux/mmc/host.h>
|
|
|
|
|
|
|
|
#include "core.h"
|
2017-01-13 13:14:14 +00:00
|
|
|
#include "card.h"
|
2017-01-13 13:14:15 +00:00
|
|
|
#include "host.h"
|
2008-07-24 12:18:58 +00:00
|
|
|
#include "mmc_ops.h"
|
2008-07-24 12:18:57 +00:00
|
|
|
|
2011-09-13 21:03:29 +00:00
|
|
|
#ifdef CONFIG_FAIL_MMC_REQUEST
|
|
|
|
|
|
|
|
static DECLARE_FAULT_ATTR(fail_default_attr);
|
|
|
|
static char *fail_request;
|
|
|
|
module_param(fail_request, charp, 0);
|
|
|
|
|
|
|
|
#endif /* CONFIG_FAIL_MMC_REQUEST */
|
|
|
|
|
2008-07-24 12:18:57 +00:00
|
|
|
/* The debugfs functions are optimized away when CONFIG_DEBUG_FS isn't set. */
|
|
|
|
static int mmc_ios_show(struct seq_file *s, void *data)
|
|
|
|
{
|
|
|
|
static const char *vdd_str[] = {
|
|
|
|
[8] = "2.0",
|
|
|
|
[9] = "2.1",
|
|
|
|
[10] = "2.2",
|
|
|
|
[11] = "2.3",
|
|
|
|
[12] = "2.4",
|
|
|
|
[13] = "2.5",
|
|
|
|
[14] = "2.6",
|
|
|
|
[15] = "2.7",
|
|
|
|
[16] = "2.8",
|
|
|
|
[17] = "2.9",
|
|
|
|
[18] = "3.0",
|
|
|
|
[19] = "3.1",
|
|
|
|
[20] = "3.2",
|
|
|
|
[21] = "3.3",
|
|
|
|
[22] = "3.4",
|
|
|
|
[23] = "3.5",
|
|
|
|
[24] = "3.6",
|
|
|
|
};
|
|
|
|
struct mmc_host *host = s->private;
|
|
|
|
struct mmc_ios *ios = &host->ios;
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
seq_printf(s, "clock:\t\t%u Hz\n", ios->clock);
|
2011-11-04 12:53:19 +00:00
|
|
|
if (host->actual_clock)
|
|
|
|
seq_printf(s, "actual clock:\t%u Hz\n", host->actual_clock);
|
2008-07-24 12:18:57 +00:00
|
|
|
seq_printf(s, "vdd:\t\t%u ", ios->vdd);
|
|
|
|
if ((1 << ios->vdd) & MMC_VDD_165_195)
|
|
|
|
seq_printf(s, "(1.65 - 1.95 V)\n");
|
|
|
|
else if (ios->vdd < (ARRAY_SIZE(vdd_str) - 1)
|
|
|
|
&& vdd_str[ios->vdd] && vdd_str[ios->vdd + 1])
|
|
|
|
seq_printf(s, "(%s ~ %s V)\n", vdd_str[ios->vdd],
|
|
|
|
vdd_str[ios->vdd + 1]);
|
|
|
|
else
|
|
|
|
seq_printf(s, "(invalid)\n");
|
|
|
|
|
|
|
|
switch (ios->bus_mode) {
|
|
|
|
case MMC_BUSMODE_OPENDRAIN:
|
|
|
|
str = "open drain";
|
|
|
|
break;
|
|
|
|
case MMC_BUSMODE_PUSHPULL:
|
|
|
|
str = "push-pull";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = "invalid";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
seq_printf(s, "bus mode:\t%u (%s)\n", ios->bus_mode, str);
|
|
|
|
|
|
|
|
switch (ios->chip_select) {
|
|
|
|
case MMC_CS_DONTCARE:
|
|
|
|
str = "don't care";
|
|
|
|
break;
|
|
|
|
case MMC_CS_HIGH:
|
|
|
|
str = "active high";
|
|
|
|
break;
|
|
|
|
case MMC_CS_LOW:
|
|
|
|
str = "active low";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = "invalid";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
seq_printf(s, "chip select:\t%u (%s)\n", ios->chip_select, str);
|
|
|
|
|
|
|
|
switch (ios->power_mode) {
|
|
|
|
case MMC_POWER_OFF:
|
|
|
|
str = "off";
|
|
|
|
break;
|
|
|
|
case MMC_POWER_UP:
|
|
|
|
str = "up";
|
|
|
|
break;
|
|
|
|
case MMC_POWER_ON:
|
|
|
|
str = "on";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = "invalid";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
seq_printf(s, "power mode:\t%u (%s)\n", ios->power_mode, str);
|
|
|
|
seq_printf(s, "bus width:\t%u (%u bits)\n",
|
|
|
|
ios->bus_width, 1 << ios->bus_width);
|
|
|
|
|
|
|
|
switch (ios->timing) {
|
|
|
|
case MMC_TIMING_LEGACY:
|
|
|
|
str = "legacy";
|
|
|
|
break;
|
|
|
|
case MMC_TIMING_MMC_HS:
|
|
|
|
str = "mmc high-speed";
|
|
|
|
break;
|
|
|
|
case MMC_TIMING_SD_HS:
|
|
|
|
str = "sd high-speed";
|
|
|
|
break;
|
2015-09-24 00:13:43 +00:00
|
|
|
case MMC_TIMING_UHS_SDR12:
|
|
|
|
str = "sd uhs SDR12";
|
|
|
|
break;
|
|
|
|
case MMC_TIMING_UHS_SDR25:
|
|
|
|
str = "sd uhs SDR25";
|
|
|
|
break;
|
2011-09-02 08:06:08 +00:00
|
|
|
case MMC_TIMING_UHS_SDR50:
|
|
|
|
str = "sd uhs SDR50";
|
|
|
|
break;
|
|
|
|
case MMC_TIMING_UHS_SDR104:
|
|
|
|
str = "sd uhs SDR104";
|
|
|
|
break;
|
|
|
|
case MMC_TIMING_UHS_DDR50:
|
|
|
|
str = "sd uhs DDR50";
|
|
|
|
break;
|
2014-03-14 12:11:56 +00:00
|
|
|
case MMC_TIMING_MMC_DDR52:
|
|
|
|
str = "mmc DDR52";
|
|
|
|
break;
|
2012-01-11 19:04:52 +00:00
|
|
|
case MMC_TIMING_MMC_HS200:
|
2014-04-23 08:08:44 +00:00
|
|
|
str = "mmc HS200";
|
2012-01-11 19:04:52 +00:00
|
|
|
break;
|
2014-04-23 08:14:58 +00:00
|
|
|
case MMC_TIMING_MMC_HS400:
|
2016-05-26 01:56:30 +00:00
|
|
|
str = mmc_card_hs400es(host->card) ?
|
|
|
|
"mmc HS400 enhanced strobe" : "mmc HS400";
|
2014-04-23 08:14:58 +00:00
|
|
|
break;
|
2008-07-24 12:18:57 +00:00
|
|
|
default:
|
|
|
|
str = "invalid";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
seq_printf(s, "timing spec:\t%u (%s)\n", ios->timing, str);
|
|
|
|
|
2012-10-26 09:31:55 +00:00
|
|
|
switch (ios->signal_voltage) {
|
|
|
|
case MMC_SIGNAL_VOLTAGE_330:
|
|
|
|
str = "3.30 V";
|
|
|
|
break;
|
|
|
|
case MMC_SIGNAL_VOLTAGE_180:
|
|
|
|
str = "1.80 V";
|
|
|
|
break;
|
|
|
|
case MMC_SIGNAL_VOLTAGE_120:
|
|
|
|
str = "1.20 V";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = "invalid";
|
|
|
|
break;
|
|
|
|
}
|
2016-01-18 09:35:19 +00:00
|
|
|
seq_printf(s, "signal voltage:\t%u (%s)\n", ios->signal_voltage, str);
|
2012-10-26 09:31:55 +00:00
|
|
|
|
2015-09-22 01:20:08 +00:00
|
|
|
switch (ios->drv_type) {
|
|
|
|
case MMC_SET_DRIVER_TYPE_A:
|
|
|
|
str = "driver type A";
|
|
|
|
break;
|
|
|
|
case MMC_SET_DRIVER_TYPE_B:
|
|
|
|
str = "driver type B";
|
|
|
|
break;
|
|
|
|
case MMC_SET_DRIVER_TYPE_C:
|
|
|
|
str = "driver type C";
|
|
|
|
break;
|
|
|
|
case MMC_SET_DRIVER_TYPE_D:
|
|
|
|
str = "driver type D";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
str = "invalid";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
seq_printf(s, "driver type:\t%u (%s)\n", ios->drv_type, str);
|
|
|
|
|
2008-07-24 12:18:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mmc_ios_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
return single_open(file, mmc_ios_show, inode->i_private);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations mmc_ios_fops = {
|
|
|
|
.open = mmc_ios_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
|
|
|
};
|
|
|
|
|
2010-10-13 08:22:22 +00:00
|
|
|
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 */
|
2016-01-21 12:57:51 +00:00
|
|
|
if (val != 0 && (val > host->f_max || val < host->f_min))
|
2010-10-13 08:22:22 +00:00
|
|
|
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");
|
|
|
|
|
2008-07-24 12:18:57 +00:00
|
|
|
void mmc_add_host_debugfs(struct mmc_host *host)
|
|
|
|
{
|
|
|
|
struct dentry *root;
|
|
|
|
|
|
|
|
root = debugfs_create_dir(mmc_hostname(host), NULL);
|
|
|
|
if (IS_ERR(root))
|
|
|
|
/* Don't complain -- debugfs just isn't enabled */
|
|
|
|
return;
|
|
|
|
if (!root)
|
|
|
|
/* Complain -- debugfs is enabled, but it failed to
|
|
|
|
* create the directory. */
|
|
|
|
goto err_root;
|
|
|
|
|
|
|
|
host->debugfs_root = root;
|
|
|
|
|
|
|
|
if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops))
|
2010-10-13 08:22:22 +00:00
|
|
|
goto err_node;
|
|
|
|
|
|
|
|
if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host,
|
|
|
|
&mmc_clock_fops))
|
|
|
|
goto err_node;
|
2008-07-24 12:18:57 +00:00
|
|
|
|
2011-08-19 12:52:37 +00:00
|
|
|
#ifdef CONFIG_FAIL_MMC_REQUEST
|
2011-09-13 21:03:29 +00:00
|
|
|
if (fail_request)
|
|
|
|
setup_fault_attr(&fail_default_attr, fail_request);
|
|
|
|
host->fail_mmc_request = fail_default_attr;
|
2011-08-19 12:52:37 +00:00
|
|
|
if (IS_ERR(fault_create_debugfs_attr("fail_mmc_request",
|
|
|
|
root,
|
|
|
|
&host->fail_mmc_request)))
|
|
|
|
goto err_node;
|
2010-11-09 02:36:50 +00:00
|
|
|
#endif
|
2008-07-24 12:18:57 +00:00
|
|
|
return;
|
|
|
|
|
2010-10-13 08:22:22 +00:00
|
|
|
err_node:
|
2008-07-24 12:18:57 +00:00
|
|
|
debugfs_remove_recursive(root);
|
|
|
|
host->debugfs_root = NULL;
|
|
|
|
err_root:
|
|
|
|
dev_err(&host->class_dev, "failed to initialize debugfs\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmc_remove_host_debugfs(struct mmc_host *host)
|
|
|
|
{
|
|
|
|
debugfs_remove_recursive(host->debugfs_root);
|
|
|
|
}
|
2008-07-24 12:18:58 +00:00
|
|
|
|
|
|
|
void mmc_add_card_debugfs(struct mmc_card *card)
|
|
|
|
{
|
|
|
|
struct mmc_host *host = card->host;
|
|
|
|
struct dentry *root;
|
|
|
|
|
|
|
|
if (!host->debugfs_root)
|
|
|
|
return;
|
|
|
|
|
|
|
|
root = debugfs_create_dir(mmc_card_id(card), host->debugfs_root);
|
|
|
|
if (IS_ERR(root))
|
|
|
|
/* Don't complain -- debugfs just isn't enabled */
|
|
|
|
return;
|
|
|
|
if (!root)
|
|
|
|
/* Complain -- debugfs is enabled, but it failed to
|
|
|
|
* create the directory. */
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
card->debugfs_root = root;
|
|
|
|
|
|
|
|
if (!debugfs_create_x32("state", S_IRUSR, root, &card->state))
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
err:
|
|
|
|
debugfs_remove_recursive(root);
|
|
|
|
card->debugfs_root = NULL;
|
|
|
|
dev_err(&card->dev, "failed to initialize debugfs\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void mmc_remove_card_debugfs(struct mmc_card *card)
|
|
|
|
{
|
|
|
|
debugfs_remove_recursive(card->debugfs_root);
|
|
|
|
}
|