From patchwork Tue Dec 12 17:43:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10107963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBA69602C2 for ; Tue, 12 Dec 2017 17:44:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A930C296B6 for ; Tue, 12 Dec 2017 17:44:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C838298D5; Tue, 12 Dec 2017 17:44:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 26772296B6 for ; Tue, 12 Dec 2017 17:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=msjCQ22I3KflFEjop8YYFMfhlQVF2CmMkLDMj2+HSQE=; b=R02 rbwHExWbj/T1rWF27hq94bjuVLChY6nuQiitmS4Z0i7BWjMMePmnjzr+AHcIWHbw6jugnTw4xat3A 5IKVrXJF9hLzP8VdHhFca6YIn1BequqeTTwPW1sbggj7X2S65PRyCeLoqMzaGMoU6DFs+OMfV79dR Wq6CqG/3LqJR8SR9QN0K/DMenZAnGMtQOcbc1P5DzVEmeaIDeh9JTY62ICjXNIzRS2pC30t6AcwfL kG2ns7v7yUzoQzE5dFIBXIBspongW3p+P3VtblxxBW+lDGc0Kn+geylaYwPr5ysvi0KPVCmIH20GE yiQ9aBvXLwtWYyrN+IfrI2Ywi2nMQXQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eOobr-00071M-9Z; Tue, 12 Dec 2017 17:44:51 +0000 Received: from mail-it0-x241.google.com ([2607:f8b0:4001:c0b::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eOobn-0006zU-PA for linux-rockchip@lists.infradead.org; Tue, 12 Dec 2017 17:44:49 +0000 Received: by mail-it0-x241.google.com with SMTP id u62so418987ita.2 for ; Tue, 12 Dec 2017 09:44:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=ENuRXCf/abWVkhvgfKCqdGYracy59keZzDcI8S9+qGw=; b=of+G3ZCtL+sqXBh7TPq2pb8CuOJG7pJQk1RrJ1FwwPKgF+R87GqWa56jHWU7sJxsWu O5/q86pFUG5pG3um/y3VYU0zyoC8dve2OUcx1m4rwP7MIwEyiCjU3gnZ3J5RviuyoNyZ oZ/iwwPkcXLxQe5mzlBPmdRx1gKRyA8c+c62U= 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=ENuRXCf/abWVkhvgfKCqdGYracy59keZzDcI8S9+qGw=; b=C3gAD5efc3JNN6RqToF41lGnb251Arjz1zBx0PMmqKfdS41hcNhwI1xr4cdqxkjzxu N6mEJ+f8uxS88Bg4oeBqky+rygs0Zm7fnci3IzZKI/oG2oku1/4lCMZh60iAbbsgwmFG OPSNntVruKJUQFfmf2DHLZg/ns55Rg/uyn6GtCAKfYe6e0OJA3FfForVzGmpRHBg4syA CrwWo9On5zzXhaCyjP8cBRaPP7LdPJBoepsNc5b5H/acbqEkfnr9c+CL0nqKKzT5Og/b IxOeZi1MuRYQLxoN0SaruX96Dtl7ZDkGPq7d0uM3+JBu0fW0R37PlNOdKBMfPlv4BsxJ +AiQ== X-Gm-Message-State: AKGB3mI/phQVpBZU6nMFsyrR+6Z9IcXnghVZvT6yB5ghVsrQfTOK+ULl xNg60xzFZfHAGlyXyWGR8YtH9Q== X-Google-Smtp-Source: ACJfBotC2Sudknu3IQ9uVeY080kxNahNSDfJCniBc6BYHyviEqS8VygxHHlCIbi8utM2Ovsvs+rPaQ== X-Received: by 10.107.102.26 with SMTP id a26mr4144078ioc.187.1513100666520; Tue, 12 Dec 2017 09:44:26 -0800 (PST) Received: from ban.mtv.corp.google.com ([172.22.113.17]) by smtp.gmail.com with ESMTPSA id d3sm32253itj.34.2017.12.12.09.44.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Dec 2017 09:44:24 -0800 (PST) From: Brian Norris To: Linus Walleij , Heiko Stuebner Subject: [PATCH] pinctrl: rockchip: enable clock when reading pin direction register Date: Tue, 12 Dec 2017 09:43:43 -0800 Message-Id: <20171212174343.192017-1-briannorris@chromium.org> X-Mailer: git-send-email 2.15.1.424.g9478a66081-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171212_094447_929830_D3C8D414 X-CRM114-Status: UNSURE ( 8.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rockchip@lists.infradead.org, Brian Norris , Doug Anderson , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We generally leave the GPIO clock disabled, unless an interrupt is requested or we're accessing IO registers. We forgot to do this for the ->get_direction() callback, which means we can sometimes [1] get incorrect results [2] from, e.g., /sys/kernel/debug/gpio. Enable the clock, so we get the right results! [1] Sometimes, because many systems have 1 or mor interrupt requested on each GPIO bank, so they always leave their clock on. [2] Incorrect, meaning the register returns 0, and so we interpret that as "input". Signed-off-by: Brian Norris Reviewed-by: Heiko Stuebner --- drivers/pinctrl/pinctrl-rockchip.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 2ba17548ad5b..073de6a9ed34 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -2014,8 +2014,16 @@ static int rockchip_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { struct rockchip_pin_bank *bank = gpiochip_get_data(chip); u32 data; + int ret; + ret = clk_enable(bank->clk); + if (ret < 0) { + dev_err(bank->drvdata->dev, + "failed to enable clock for bank %s\n", bank->name); + return ret; + } data = readl_relaxed(bank->reg_base + GPIO_SWPORT_DDR); + clk_disable(bank->clk); return !(data & BIT(offset)); }