From patchwork Tue May 8 00:15:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 909992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="iOmkCi8b"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40g0Pb3QQcz9s4Z for ; Tue, 8 May 2018 10:15:31 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753530AbeEHAP3 (ORCPT ); Mon, 7 May 2018 20:15:29 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43909 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753085AbeEHAP1 (ORCPT ); Mon, 7 May 2018 20:15:27 -0400 Received: by mail-pf0-f194.google.com with SMTP id j20so8751084pff.10 for ; Mon, 07 May 2018 17:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=MIEyBVp5gtFFo2Jre40LrlDELxH133vadn6RR+O9iMg=; b=iOmkCi8bcjvcbKswMEMN5a2Rk2S19PJ1nQ8mP20n8exd1YhKy6Ns5WHzfjcwndRaWl NGGrOYCNbDmvIFLgOeRcscxrYCgaPGr4uZPnq8esWH6sBt2Nt7XJMZ3MtNNtNoUNaZdn 4Ux9pdp5mjtxlBTZQ5X1eqiNDzccJMHmzHJFo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MIEyBVp5gtFFo2Jre40LrlDELxH133vadn6RR+O9iMg=; b=rbE/7B/3/dk0jzSSRoT7Dg/wGGbuPrrXJR0TvMsCEDZ6zaPu+g5P6covTonTCrbEhz SGwebfJpPAH+LTu6KHlrBKTbtwAJh11qPUNnjinojyWx2wDpLC1iX7DdJvIqk5CSnkIr EUCOI7GlktnHY8Icq6QmEPsAfZjsmv7oEDuW7XV/v6r5SENgLtB6JgFir/994P+UmTKj +NnbWM8f6YZ94qleIECPH3tHDE+q7cTkuGmrjdmsjpTYfs+LokH5Nw1ibSNew7SapTch qA/aaaKD2pHgN7UDeIv4l9HTXS1e4AWH7GBASf6tR7sT+stxn3N9O4kfJyaX3NeJh2E/ KpKQ== X-Gm-Message-State: ALQs6tAbjb1SAJdegl02RDdzOmtAEcs0uO7xNRspWDcGBTxVZNmexqgC izXUg5GnWt2Sp+oKf+Y0coGa1g== X-Google-Smtp-Source: AB8JxZq886v6BWGYfOrD4C/90wjOtvFXl4WgNH80T0cbCOiy7Sjwz8F9zYDWOl+I5T0+qbI2dV8F3A== X-Received: by 2002:a63:ab45:: with SMTP id k5-v6mr17005086pgp.199.1525738526218; Mon, 07 May 2018 17:15:26 -0700 (PDT) Received: from swboyd.mtv.corp.google.com ([2620:0:1000:1511:d30e:62c6:f82c:ff40]) by smtp.gmail.com with ESMTPSA id 29sm15093880pfj.14.2018.05.07.17.15.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 17:15:25 -0700 (PDT) From: Stephen Boyd To: Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org, Bjorn Andersson , Alexandru M Stan Subject: [PATCH] pinctrl: qcom: Print high/low status of gpios in debugfs Date: Mon, 7 May 2018 17:15:23 -0700 Message-Id: <20180508001523.1264-1-swboyd@chromium.org> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org I was debugging some gpio issues and I thought that the output of gpio debugfs was telling me the high or low level of the gpios with a '1' or a '0'. We saw a line like this though: gpio93 : in 4 2mA pull down and I started to think that there may be a gas leak in the building because '4' doesn't mean high or low, and other pins said '0' or '1'. It turns out, '4' is the function selection for the pinmux of the gpio and not the value on the pin. Reading code helps decipher what debugfs is actually saying. Add support to read the input or output pin depending on how the pin is configured so we can easily see the high or low value of the pin in debugfs. Now the output looks like gpio93 : in low func4 2mA pull down which clearly shows that the pin is an input, low, with function 4 and a 2mA drive strength plus a pull down. Cc: Bjorn Andersson Cc: Alexandru M Stan Signed-off-by: Stephen Boyd --- I have a patch to pretty print the function name, but I don't know how useful that is given we have pinctrl debugfs which prints that and the ACPI qcom driver doesn't have function names. drivers/pinctrl/qcom/pinctrl-msm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c index ad80a17c9990..4c546b8052a7 100644 --- a/drivers/pinctrl/qcom/pinctrl-msm.c +++ b/drivers/pinctrl/qcom/pinctrl-msm.c @@ -506,7 +506,8 @@ static void msm_gpio_dbg_show_one(struct seq_file *s, int is_out; int drive; int pull; - u32 ctl_reg; + int val; + u32 ctl_reg, io_reg; static const char * const pulls[] = { "no pull", @@ -520,13 +521,20 @@ static void msm_gpio_dbg_show_one(struct seq_file *s, g = &pctrl->soc->groups[offset]; ctl_reg = readl(pctrl->regs + g->ctl_reg); + io_reg = readl(pctrl->regs + g->io_reg); is_out = !!(ctl_reg & BIT(g->oe_bit)); func = (ctl_reg >> g->mux_bit) & 7; drive = (ctl_reg >> g->drv_bit) & 7; pull = (ctl_reg >> g->pull_bit) & 3; - seq_printf(s, " %-8s: %-3s %d", g->name, is_out ? "out" : "in", func); + if (is_out) + val = !!(io_reg & BIT(g->out_bit)); + else + val = !!(io_reg & BIT(g->in_bit)); + + seq_printf(s, " %-8s: %-3s", g->name, is_out ? "out" : "in"); + seq_printf(s, " %-4s func%d", val ? "high" : "low", func); seq_printf(s, " %dmA", msm_regval_to_drive(drive)); seq_printf(s, " %s", pulls[pull]); seq_puts(s, "\n");