2 * Debugfs support for hosts and cards
4 * Copyright (C) 2008 Atmel Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/debugfs.h>
12 #include <linux/seq_file.h>
13 #include <linux/stat.h>
15 #include <linux/mmc/host.h>
19 /* The debugfs functions are optimized away when CONFIG_DEBUG_FS isn't set. */
20 static int mmc_ios_show(struct seq_file
*s
, void *data
)
22 static const char *vdd_str
[] = {
41 struct mmc_host
*host
= s
->private;
42 struct mmc_ios
*ios
= &host
->ios
;
45 seq_printf(s
, "clock:\t\t%u Hz\n", ios
->clock
);
46 seq_printf(s
, "vdd:\t\t%u ", ios
->vdd
);
47 if ((1 << ios
->vdd
) & MMC_VDD_165_195
)
48 seq_printf(s
, "(1.65 - 1.95 V)\n");
49 else if (ios
->vdd
< (ARRAY_SIZE(vdd_str
) - 1)
50 && vdd_str
[ios
->vdd
] && vdd_str
[ios
->vdd
+ 1])
51 seq_printf(s
, "(%s ~ %s V)\n", vdd_str
[ios
->vdd
],
52 vdd_str
[ios
->vdd
+ 1]);
54 seq_printf(s
, "(invalid)\n");
56 switch (ios
->bus_mode
) {
57 case MMC_BUSMODE_OPENDRAIN
:
60 case MMC_BUSMODE_PUSHPULL
:
67 seq_printf(s
, "bus mode:\t%u (%s)\n", ios
->bus_mode
, str
);
69 switch (ios
->chip_select
) {
83 seq_printf(s
, "chip select:\t%u (%s)\n", ios
->chip_select
, str
);
85 switch (ios
->power_mode
) {
99 seq_printf(s
, "power mode:\t%u (%s)\n", ios
->power_mode
, str
);
100 seq_printf(s
, "bus width:\t%u (%u bits)\n",
101 ios
->bus_width
, 1 << ios
->bus_width
);
103 switch (ios
->timing
) {
104 case MMC_TIMING_LEGACY
:
107 case MMC_TIMING_MMC_HS
:
108 str
= "mmc high-speed";
110 case MMC_TIMING_SD_HS
:
111 str
= "sd high-speed";
117 seq_printf(s
, "timing spec:\t%u (%s)\n", ios
->timing
, str
);
122 static int mmc_ios_open(struct inode
*inode
, struct file
*file
)
124 return single_open(file
, mmc_ios_show
, inode
->i_private
);
127 static const struct file_operations mmc_ios_fops
= {
128 .open
= mmc_ios_open
,
131 .release
= single_release
,
134 void mmc_add_host_debugfs(struct mmc_host
*host
)
138 root
= debugfs_create_dir(mmc_hostname(host
), NULL
);
140 /* Don't complain -- debugfs just isn't enabled */
143 /* Complain -- debugfs is enabled, but it failed to
144 * create the directory. */
147 host
->debugfs_root
= root
;
149 if (!debugfs_create_file("ios", S_IRUSR
, root
, host
, &mmc_ios_fops
))
155 debugfs_remove_recursive(root
);
156 host
->debugfs_root
= NULL
;
158 dev_err(&host
->class_dev
, "failed to initialize debugfs\n");
161 void mmc_remove_host_debugfs(struct mmc_host
*host
)
163 debugfs_remove_recursive(host
->debugfs_root
);