Received: by 10.213.65.68 with SMTP id h4csp143031imn; Mon, 12 Mar 2018 22:11:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELuHw7vNCYQC7oowG+gXCSOuNDgQ3Lp7zAwkHhzp1XQdOtyV/fshRK0HXsbUHLZEDJ8hwtB+ X-Received: by 2002:a17:902:718c:: with SMTP id b12-v6mr10519661pll.121.1520917894069; Mon, 12 Mar 2018 22:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520917894; cv=none; d=google.com; s=arc-20160816; b=oI/3B4KO813pJ0nxmnIcvo2nk6RQhZOF8KHhl24TZfGwljNXa9XayIenwggQ3qME5m meqxTcjsahlYIp++uLk5/rWoa3YRMj6WThF5PWgyvjjkTe334t8aQvR7OQH6jHwq24+3 TM3Yfj/NWS0K1uaDTwH4ZYWpK+WI1tFsYNBzEmwB2pXHhRKU5ftICx3I9hL9a8Qsw7Je RSLA28ZILnv+2yV9/pF/crjH1U04CSKwBocmo+x4T0T+v1w2KwTkYZzzyPl08vV5AMgD gFqerCaw14H1AY6ZxnRgs6Q+b/JORehXWQX0ifWdyfWr0JVVrB+eKGY8tnIYFclwKkG8 fl5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=Aq6c7HmqEH3jS2orXtvPzRLhxx3dHOJif4gL8unNHeY=; b=OcBUu5jm8X3Xx8vNjJjM9cqUPK1EwXp760RlwQl+RLYVKjwq3ifR3fjMFahJJEVTA4 ut326eaIpeKxGfYtn1bWy/DpQJxjxoShSsOAq1SMeflQvD1DuCEj8dvaXr1sI8Smcg2M saiwssy3J+JVD1Hh7JhP9pQf/Wnkh7f7UsdGdtVfsInskZZAXGMwYJlRSuDqN83qJpIJ HcpOWnzhq/UVBTYh2q5VnnaLv7WF5SguOKAgUX9KJYNjYqV1n+UVfNQVNAelxrw7acvA XISpV9ehb19OL+pC2iWe0wpb3TqirIi5c4Uk8NsYJKPrYvReHhxASxFl5xA6zNDIJBZo viLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b8si2291587pgr.612.2018.03.12.22.11.19; Mon, 12 Mar 2018 22:11:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751407AbeCMFKZ (ORCPT + 99 others); Tue, 13 Mar 2018 01:10:25 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:46863 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750784AbeCMFKX (ORCPT ); Tue, 13 Mar 2018 01:10:23 -0400 Received: from svr-orw-fem-04.mgc.mentorg.com ([147.34.97.41]) by relay1.mentorg.com with esmtps (TLSv1:ECDHE-RSA-AES256-SHA:256) id 1evcCa-0007T0-IY from Harish_Kandiga@mentor.com ; Mon, 12 Mar 2018 22:10:20 -0700 Received: from hkandiga-VirtualBox.ina.mentorg.com (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.3.224.2; Mon, 12 Mar 2018 22:10:19 -0700 From: Harish Jenny K N To: , , , , , CC: , , , Subject: [PATCH v10] mmc: Export host capabilities to debugfs. Date: Tue, 13 Mar 2018 10:40:12 +0530 Message-ID: <1520917812-20047-1-git-send-email-harish_kandiga@mentor.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch exports the host capabilities to debugfs This idea of sharing host capabilities over debugfs came up from Abbas Raza Earlier discussions: https://lkml.org/lkml/2018/3/5/357 https://www.spinics.net/lists/linux-mmc/msg48219.html Reviewed-by: Andy Shevchenko Signed-off-by: Harish Jenny K N --- Changes in v10: - minor review comment addressed. - Added "Reviewed-by" line Changes in v9 - More code cleanup as suggested by Andy Shevchenko. Changes in v8 - Changes to use for_each_set_bit as suggested by Andy Shevchenko. Changes in v7 - Moved additional capabilities also to caps file as mentioned by Ulf Hansson - compacting the code with macros Changes in v6: - Used DEFINE_SHOW_ATTRIBUTE Changes in v5: - Added parser logic in kernel by using debugfs_create_file for caps and caps2 instead of debugfs_create_x32 - Changed Author Changes in v4: - Moved the creation of nodes to mmc_add_host_debugfs - Exported caps2 - Renamed host_caps to caps Changes in v3: - Removed typecasting of &host->caps to (u32 *) Changes in v2: - Changed Author drivers/mmc/core/debugfs.c | 107 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..826d361 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -225,6 +225,110 @@ static int mmc_clock_opt_set(void *data, u64 val) DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set, "%llu\n"); +/* + * mmc_host_capabilities - MMC host capabilities + * + * This must be in sync with caps definitions in the mmc/host.h + */ +static const char * const mmc_host_capabilities[] = { + "4-bit transfers allowed", + "Supports MMC high-speed timing", + "Supports SD high-speed timing", + "Can signal pending SDIO IRQs", + "Talks only SPI protocols", + "Needs polling for card-detection", + "8 bit transfers allowed", + "Suspends (e)MMC/SD at idle", + "Nonremovable", + "Waits while card is busy", + "Allows erase/trim commands", + "Supports DDR mode at 3.3V", + "Supports DDR mode at 1.8V", + "Supports DDR mode at 1.2V", + "Can power off after boot", + "CMD14/CMD19 bus width ok", + "Supports UHS SDR12 mode", + "Supports UHS SDR25 mode", + "Supports UHS SDR50 mode", + "Supports UHS SDR104 mode", + "Supports UHS DDR50 mode", + "Unknown (bit 21)", + "Unknown (bit 22)", + "Supports Driver Type A", + "Supports Driver Type C", + "Supports Driver Type D", + "Unknown (bit 26)", + "RW reqs can be completed within mmc_request_done()", + "Supports Enable card detect wake", + "Can send commands during data transfer", + "CMD23 supported", + "Supports Hardware reset" +}; + +/* + * mmc_host_capabilities2 - MMC host additional capabilities + * + * This must be in sync with caps2 definitions in the mmc/host.h + */ +static const char * const mmc_host_capabilities2[] = { + "No access to Boot partition", + "Unknown (bit 1)", + "Can do full power cycle", + "Unknown (bit 3)", + "Unknown (bit 4)", + "Supports HS200 1.8V SDR", + "Supports HS200 1.2V SDR", + "Unknown (bit 7)", + "Unknown (bit 8)", + "Unknown (bit 9)", + "Card-detect signal active high", + "Write-protect signal active high", + "Unknown (bit 12)", + "Unknown (bit 13)", + "Can do complete power cycle of the card", + "Supports HS400 1.8V", + "Support HS400 1.2V", + "SDIO IRQ - Nothread", + "No physical write protect pin, assume always read-write", + "Do not send SDIO commands during initialization", + "Supports enhanced strobe", + "Do not send SD commands during initialization", + "Do not send (e)MMC commands during initialization", + "Has eMMC command queue engine", + "CQE can issue a direct command", + "Unknown (bit 25)", + "Unknown (bit 26)", + "Unknown (bit 27)", + "Unknown (bit 28)", + "Unknown (bit 29)", + "Unknown (bit 30)", + "Unknown (bit 31)" +}; + +static int mmc_caps_show(struct seq_file *s, void *unused) +{ + struct mmc_host *host = s->private; + unsigned long caps = host->caps; + unsigned long caps2 = host->caps2; + int bit; + + seq_puts(s, "MMC Host capabilities are:\n"); + seq_puts(s, "=============================================\n"); + + for_each_set_bit(bit, &caps, ARRAY_SIZE(mmc_host_capabilities)) + seq_printf(s, "%s\n", mmc_host_capabilities[bit]); + + seq_puts(s, "=============================================\n"); + seq_puts(s, "MMC Host additional capabilities are:\n"); + seq_puts(s, "=============================================\n"); + + for_each_set_bit(bit, &caps2, ARRAY_SIZE(mmc_host_capabilities2)) + seq_printf(s, "%s\n", mmc_host_capabilities2[bit]); + + return 0; +} +DEFINE_SHOW_ATTRIBUTE(mmc_caps); + void mmc_add_host_debugfs(struct mmc_host *host) { struct dentry *root; @@ -243,6 +347,9 @@ void mmc_add_host_debugfs(struct mmc_host *host) if (!debugfs_create_file("ios", S_IRUSR, root, host, &mmc_ios_fops)) goto err_node; + if (!debugfs_create_file("caps", 0400, root, host, &mmc_caps_fops)) + goto err_node; + if (!debugfs_create_file("clock", S_IRUSR | S_IWUSR, root, host, &mmc_clock_fops)) goto err_node; -- 1.9.1