From: Tony Lindgren <tony@atomide.com>
To: linux-omap@vger.kernel.org
Cc: mike.rapoport@gmail.com
Subject: [PATCH 5/5] omap: mux: Add debugfs support for new mux code
Date: Thu, 29 Oct 2009 13:36:54 -0700 [thread overview]
Message-ID: <20091029203654.11843.87021.stgit@localhost> (raw)
In-Reply-To: <20091029203124.11843.89983.stgit@localhost>
Add debugfs support for new mux code
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
arch/arm/mach-omap2/mux.c | 143 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 143 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 45e6d4d..a31bcfa 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -28,6 +28,9 @@
#include <linux/io.h>
#include <linux/spinlock.h>
#include <linux/list.h>
+#include <linux/ctype.h>
+#include <linux/debugfs.h>
+#include <linux/seq_file.h>
#include <asm/system.h>
@@ -780,6 +783,146 @@ static void __init omap_mux_apply_pins(struct omap_ball *b,
}
}
+#define OMAP_MUX_MAX_NR_FLAGS 10
+#define OMAP_MUX_TEST_FLAG(val, mask) \
+ if (((val) & (mask)) == (mask)) { \
+ i++; \
+ flags[i] = #mask; \
+ }
+
+/* REVISIT: Add checking for non-optimal mux settings */
+static inline void omap_mux_decode(struct seq_file *s, u16 val)
+{
+ char *flags[OMAP_MUX_MAX_NR_FLAGS];
+ char mode[14];
+ int i = -1;
+
+ sprintf(mode, "OMAP_MUX_MODE%d", val & 0x7);
+ i++;
+ flags[i] = mode;
+
+ OMAP_MUX_TEST_FLAG(val, OMAP_PIN_OFF_WAKEUPENABLE);
+ if (val & OMAP_OFF_EN) {
+ if (!(val & OMAP_OFFOUT_EN)) {
+ if (!(val & OMAP_OFF_PULL_UP)) {
+ OMAP_MUX_TEST_FLAG(val,
+ OMAP_PIN_OFF_INPUT_PULLDOWN);
+ } else {
+ OMAP_MUX_TEST_FLAG(val,
+ OMAP_PIN_OFF_INPUT_PULLUP);
+ }
+ } else {
+ if (!(val & OMAP_OFFOUT_VAL)) {
+ OMAP_MUX_TEST_FLAG(val,
+ OMAP_PIN_OFF_OUTPUT_LOW);
+ } else {
+ OMAP_MUX_TEST_FLAG(val,
+ OMAP_PIN_OFF_OUTPUT_HIGH);
+ }
+ }
+ } else {
+ i++;
+ flags[i] = "OMAP_PIN_OFF_NONE";
+ }
+
+ if (val & OMAP_INPUT_EN) {
+ if (val & OMAP_PULL_ENA) {
+ if (!(val & OMAP_PULL_UP)) {
+ OMAP_MUX_TEST_FLAG(val,
+ OMAP_PIN_INPUT_PULLDOWN);
+ } else {
+ OMAP_MUX_TEST_FLAG(val, OMAP_PIN_INPUT_PULLUP);
+ }
+ }
+ OMAP_MUX_TEST_FLAG(val, OMAP_PIN_INPUT);
+ } else {
+ i++;
+ flags[i] = "OMAP_PIN_OUTPUT";
+ }
+
+ do {
+ seq_printf(s, "%s", flags[i]);
+ if (i > 0)
+ seq_printf(s, " | ");
+ } while (i-- > 0);
+}
+
+#define OMAP_MUX_DEFNAME_LEN 16
+
+static int omap_mux_dbg_show(struct seq_file *s, void *unused)
+{
+ struct omap_mux_entry *e;
+
+ list_for_each_entry_reverse(e, &muxmodes, node) {
+ struct omap_mux *m = &e->mux;
+ char m0_def[OMAP_MUX_DEFNAME_LEN];
+ char *m0_name = m->muxnames[0];
+ u16 val;
+ int i, mode;
+
+ if (!m0_name)
+ continue;
+
+ for (i = 0; i < OMAP_MUX_DEFNAME_LEN; i++) {
+ if (m0_name[i] == '\0') {
+ m0_def[i] = m0_name[i];
+ break;
+ }
+ m0_def[i] = toupper(m0_name[i]);
+ }
+ val = omap_mux_read(m->reg_offset);
+ mode = val & 0x7;
+
+ seq_printf(s, "OMAP%i_MUX(%s, ",
+ cpu_is_omap34xx() ? 3: 0, m0_def);
+ omap_mux_decode(s, val);
+ seq_printf(s, ", 0),\n");
+
+ seq_printf(s, "padconf: %s\tsignal: %s:\toffset: 0x%03x\t"
+ "value: 0x%04x\n",
+ m->muxnames[0], m->muxnames[mode], m->reg_offset, val);
+ seq_printf(s, "m0: %-11s\tm1: %-10s\tm2: %-10s\tm3: %-10s\n"
+ "m4: %-10s\tm5: %-10s\tm6: %-10s\tm7: %-10s\n",
+ m->muxnames[0] ? m->muxnames[0] : "",
+ m->muxnames[1] ? m->muxnames[1] : "",
+ m->muxnames[2] ? m->muxnames[2] : "",
+ m->muxnames[3] ? m->muxnames[3] : "",
+ m->muxnames[4] ? m->muxnames[4] : "",
+ m->muxnames[5] ? m->muxnames[5] : "",
+ m->muxnames[6] ? m->muxnames[6] : "",
+ m->muxnames[7] ? m->muxnames[7] : "");
+ seq_printf(s, "phys: 0x%08lx\tball bottom: %s\t "
+ "ball top: %s\n\n",
+ cpu_is_omap34xx() ?
+ OMAP3_CONTROL_PADCONF_MUX_PBASE + m->reg_offset : 0,
+ m->balls[0] ? m->balls[0] : "",
+ m->balls[1] ? m->balls[1] : "");
+ }
+
+ return 0;
+}
+
+static int omap_mux_dbg_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, omap_mux_dbg_show, &inode->i_private);
+}
+
+static const struct file_operations omap_mux_dbg_fops = {
+ .open = omap_mux_dbg_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+static int __init omap_mux_dbg_init(void)
+{
+ (void)debugfs_create_file("omap_mux", S_IRUGO, NULL, NULL,
+ &omap_mux_dbg_fops);
+
+ return 0;
+}
+late_initcall(omap_mux_dbg_init);
+
#else /* CONFIG_DEBUG_FS */
static inline void omap_mux_apply_pins(struct omap_ball *b,
next prev parent reply other threads:[~2009-10-29 20:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-29 20:35 [PATCH 0/5] New mux code for 34xx Tony Lindgren
2009-10-29 20:36 ` [PATCH 1/5] omap2: mux: intoduce omap_mux_{read,write} Tony Lindgren
2009-10-29 20:36 ` [PATCH 2/5] omap: mux: Add new style pin multiplexing code for omap3 Tony Lindgren
2009-11-01 10:30 ` Mike Rapoport
2009-11-02 18:54 ` Tony Lindgren
2009-11-03 6:56 ` Mike Rapoport
2009-10-29 20:36 ` [PATCH 3/5] omap: mux: Add new style pin multiplexing data for 34xx Tony Lindgren
2009-11-01 10:30 ` Mike Rapoport
2009-11-02 19:10 ` Tony Lindgren
2009-11-03 7:10 ` Mike Rapoport
2009-11-03 16:43 ` Tony Lindgren
2009-11-03 22:55 ` [PATCH] omap: mux: Replace omap_cfg_reg() with new style signal or gpio functions (Re: [PATCH 3/5] omap: mux: Add new style pin multiplexing data for 34xx) Tony Lindgren
2009-11-04 7:14 ` [PATCH 3/5] omap: mux: Add new style pin multiplexing data for 34xx Mike Rapoport
2009-11-10 22:37 ` Tony Lindgren
2009-11-11 8:23 ` Mike Rapoport
2009-10-29 20:36 ` [PATCH 4/5] omap: mux: Add new style init functions to omap3 board-*.c files Tony Lindgren
2009-10-29 20:36 ` Tony Lindgren [this message]
2009-10-29 21:19 ` [PATCH 0/5] New mux code for 34xx Mike Rapoport
2009-10-29 21:59 ` Tony Lindgren
2009-11-01 10:29 ` Mike Rapoport
2009-11-02 18:56 ` Tony Lindgren
2009-11-03 6:42 ` Mike Rapoport
2009-11-03 16:46 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091029203654.11843.87021.stgit@localhost \
--to=tony@atomide.com \
--cc=linux-omap@vger.kernel.org \
--cc=mike.rapoport@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox