From patchwork Mon Oct 14 13:29:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Pargmann X-Patchwork-Id: 3036351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 783479F243 for ; Mon, 14 Oct 2013 13:30:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4A9C620221 for ; Mon, 14 Oct 2013 13:30:50 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D1C51201FE for ; Mon, 14 Oct 2013 13:30:48 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VViDn-0001SW-Nq; Mon, 14 Oct 2013 13:30:07 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VViDb-000612-EK; Mon, 14 Oct 2013 13:29:55 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VViDJ-0005y0-6r for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2013 13:29:39 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1VViCo-0003pb-N9; Mon, 14 Oct 2013 15:29:06 +0200 Received: from mpa by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1VViCo-0006Mn-EF; Mon, 14 Oct 2013 15:29:06 +0200 From: Markus Pargmann To: Felipe Balbi Subject: [PATCH 3/3] usb: musb: dsps, debugfs files Date: Mon, 14 Oct 2013 15:29:02 +0200 Message-Id: <1381757342-13324-4-git-send-email-mpa@pengutronix.de> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1381757342-13324-1-git-send-email-mpa@pengutronix.de> References: <1381757342-13324-1-git-send-email-mpa@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131014_092937_795689_529CFE03 X-CRM114-Status: GOOD ( 17.25 ) X-Spam-Score: -2.4 (--) Cc: Markus Pargmann , linux-usb@vger.kernel.org, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP debugfs files to show the contents of important dsps registers. Signed-off-by: Markus Pargmann --- drivers/usb/musb/musb_dsps.c | 89 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 189e52c..b24b697 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -46,6 +46,8 @@ #include #include +#include + #include "musb_core.h" static const struct of_device_id musb_dsps_of_match[]; @@ -121,6 +123,61 @@ struct dsps_glue { unsigned long last_timer; /* last timer data for each instance */ }; +#if IS_ENABLED(CONFIG_DEBUG_FS) + +struct musb_register_map { + char *name; + unsigned offset; +}; + +static const struct musb_register_map musb_regmap[] = { + { "revision", 0x00 }, + { "control", 0x14 }, + { "status", 0x18 }, + { "eoi", 0x24 }, + { "intr0_stat", 0x30 }, + { "intr1_stat", 0x34 }, + { "intr0_set", 0x38 }, + { "intr1_set", 0x3c }, + { "txmode", 0x70 }, + { "rxmode", 0x74 }, + { "autoreq", 0xd0 }, + { "srpfixtime", 0xd4 }, + { "tdown", 0xd8 }, + { "phy_utmi", 0xe0 }, + { "mode", 0xe8 }, + { } /* Terminating Entry */ +}; + +static int musb_regdump_show(struct seq_file *s, void *unused) +{ + struct musb *musb = s->private; + unsigned i; + + seq_puts(s, "MUSB (M)HDRC dsps Register Dump\n"); + + for (i = 0; i < ARRAY_SIZE(musb_regmap); i++) { + u32 val = musb_readl(musb->ctrl_base, musb_regmap[i].offset); + seq_printf(s, "%-12s: %08x\n", musb_regmap[i].name, val); + } + + return 0; +} + +static int musb_regdump_open(struct inode *inode, struct file *file) +{ + return single_open(file, musb_regdump_show, inode->i_private); +} + +static const struct file_operations musb_regdump_fops = { + .open = musb_regdump_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +#endif /* IS_ENABLED(CONFIG_DEBUG_FS) */ + /** * dsps_musb_enable - enable interrupts */ @@ -348,6 +405,31 @@ out: return ret; } +#if IS_ENABLED(CONFIG_DEBUG_FS) +static int dsps_musb_dbg_init(struct musb *musb) +{ + struct dentry *root; + struct dentry *file; + char buf[128]; + + sprintf(buf, "%s.dsps", dev_name(musb->controller)); + root = debugfs_create_dir(buf, NULL); + if (!root) + return -ENOMEM; + + file = debugfs_create_file("regdump", S_IRUGO, root, musb, + &musb_regdump_fops); + if (!file) + return -ENOMEM; + return 0; +} +#else +static int dsps_musb_dbg_init(struct musb *musb) +{ + return 0; +} +#endif + static int dsps_musb_init(struct musb *musb) { struct device *dev = musb->controller; @@ -357,6 +439,7 @@ static int dsps_musb_init(struct musb *musb) void __iomem *reg_base; struct resource *r; u32 rev, val; + int ret; r = platform_get_resource_byname(parent, IORESOURCE_MEM, "control"); if (!r) @@ -390,6 +473,12 @@ static int dsps_musb_init(struct musb *musb) val &= ~(1 << wrp->otg_disable); dsps_writel(musb->ctrl_base, wrp->phy_utmi, val); + ret = dsps_musb_dbg_init(musb); + if (ret) + return ret; + + dev_info(dev, "%s:%d %s: OK\n", __FILE__, __LINE__, __func__); + return 0; }