Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3648529yba; Tue, 7 May 2019 04:59:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4twLDj8DbAcHPw13V+QR2U96HRld6yIQPOZrEVt2n7IMMmI9B3OdUSBQ4YWWAAHmnjPwh X-Received: by 2002:a65:578b:: with SMTP id b11mr17570909pgr.446.1557230360754; Tue, 07 May 2019 04:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557230360; cv=none; d=google.com; s=arc-20160816; b=VT3aHYpbeJ+Jv4tnqSCY73M/YKIt6ne6jkPzeUVIDqdVNAl6jLXWTznX7LzePeS7b6 QywuVYdbrYJiHQf7w5xlBdW/YQ1UADmdLoM9SlElsw379o8x+ysxY3PCQsROGJ8SGviP bbuOoxkSmZRaLki0+JbX1ynaDKhSflIlnX3c6pAKFIspuOWyb0rw4VgcLDllgtb+lTwJ wSKmxeEoJKDv1zQFIsx9c4kIu+6Yec+Wbu8txicP8TSlk4G0WCNR3ah9j06cWuN1VUSg UDo9cl1P8YX8FRxQJEMG9MdxnG7l5/J+WF7u+qhFoaDAS6xTW/oBeaCRUjWCSmdzjrYJ UkEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=/Ryaw0CwF3TL07iEm7ZRTzsdOIYoEQ5xbLX69lpJF4M=; b=0pH4fmoIsFJkzVnLIP+A83Xtwb1UvFdQxA8PqUtsmtfdbRN2rQ2SBXKaD0hpr20R7N MooxDnATqalCmRh9b7gC1xbI4Um9czOVxVMr0/nO0VMacqEQekavWegBxtpQ4C6wr95y iLhCFaQwasZFUKVBnp1tCZ9Wd2z4Xfs1qw7oN3ve+eGO0DfCpinxH7Es1v3aGt1TU8G1 ZeGqX9ehxu1Q7tCFwwPfVcaH2kdeFJSa9HYgVUXtcug3tt/2ydA0hPoGmGWzyOfvtodS a42TeFxnNexdZNX9Scjwx4PkPq2xu40RnlM5PRpdwZ8QBhUvsIsMvtZlKRlz8xznJJFY PRkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=eVnhrsbD; 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 u1si18363834pgr.347.2019.05.07.04.59.05; Tue, 07 May 2019 04:59:20 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=eVnhrsbD; 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 S1726799AbfEGL5x (ORCPT + 99 others); Tue, 7 May 2019 07:57:53 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55324 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726614AbfEGL5e (ORCPT ); Tue, 7 May 2019 07:57:34 -0400 Received: by mail-wm1-f67.google.com with SMTP id y2so19777083wmi.5 for ; Tue, 07 May 2019 04:57:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/Ryaw0CwF3TL07iEm7ZRTzsdOIYoEQ5xbLX69lpJF4M=; b=eVnhrsbD0eL9XxWgaC4xyCq3cICT92y5RNfh7j5ubwQ4rKvO2lpin4vROxI5x7x0/V LQ7N3YZAw55ojIg14I4t1OjfbqUv5YoN7mWIRoHIUsxy3l+8CB+adcnjf3BOFB9Rx4bK 5B8lwt5+7NsdSpzDSYBxqJgrrxb6Ovt7grrBVN3Ct2dcvAgqPIKzzfNhaBOA38WywQcW Dqb0MAL751uovhqSYERs+EWp8L2RmC1GXWxYq/gRuFXJeU2x7AOm7Pr/Hy3SmhxR9U2l 5X2SD9U9Y5LWYpIg+of1Qr5b0Oy7AnfCqkmkg+V+kmphYWFxBbd7w/HTaWVxKecUSFV4 /79w== 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:in-reply-to :references; bh=/Ryaw0CwF3TL07iEm7ZRTzsdOIYoEQ5xbLX69lpJF4M=; b=oaxtHKyyAU9euNUai1q9K7EZ15gvRfxhyl0fdWnBXKbdLvZ/pC0gSiOdmVFuHpV7dg jOAsyuu92Om9Y5pgElRH9tRe+2BPeBylhQiDfnHRaHUTX6YbhaGB8Nb613lUlGvhNoz3 dttQzizZsQgzSVuGnZ77fFCbQvUf9nY/CzC3j0dOx0UEr25zUePCPtBFTtBZflua6zg2 ZU6845v0I9AWs0Zmz5zo96b8msa6ZFMIoRXEr5dezK1X4as7Z4VOJgWBJhHcQ0aNtFyj 8Q4UV2u3fdLDuk+IVHSVU/3599pGcMny1hyL4vRiG7W28neCynMUVHowkeIq9hS+xHCU vP5w== X-Gm-Message-State: APjAAAUdHZc2qgLmjUCHfZw6Rj8pmzAkY4VjxRfi8sYnPS/P6vhErIfk 1NQuxpYAfspQ7Alak4WFpPxyMA== X-Received: by 2002:a1c:f205:: with SMTP id s5mr19644763wmc.131.1557230252671; Tue, 07 May 2019 04:57:32 -0700 (PDT) Received: from glaroque-ThinkPad-T480.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id s11sm7120274wrb.71.2019.05.07.04.57.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 May 2019 04:57:31 -0700 (PDT) From: Guillaume La Roque To: linus.walleij@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, khilman@baylibre.com Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/6] pinctrl: meson: Rework enable/disable bias part Date: Tue, 7 May 2019 13:57:24 +0200 Message-Id: <20190507115726.23714-5-glaroque@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190507115726.23714-1-glaroque@baylibre.com> References: <20190507115726.23714-1-glaroque@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org rework bias enable/disable part to prepare drive-strength integration Signed-off-by: Guillaume La Roque --- drivers/pinctrl/meson/pinctrl-meson.c | 79 ++++++++++++++++----------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 96a4a72708e4..a216a7537564 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -174,13 +174,57 @@ int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector, return 0; } +static int meson_pinconf_disable_bias(struct meson_pinctrl *pc, + unsigned int pin) +{ + struct meson_bank *bank; + unsigned int reg, bit = 0; + int ret; + + ret = meson_get_bank(pc, pin, &bank); + if (ret) + return ret; + meson_calc_reg_and_bit(bank, pin, REG_PULLEN, ®, &bit); + ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit), 0); + if (ret) + return ret; + + return 0; +} + +static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin, + bool pull_up) +{ + struct meson_bank *bank; + unsigned int reg, bit, val = 0; + int ret; + + ret = meson_get_bank(pc, pin, &bank); + if (ret) + return ret; + + meson_calc_reg_and_bit(bank, pin, REG_PULL, ®, &bit); + if (pull_up) + val = BIT(bit); + + ret = regmap_update_bits(pc->reg_pull, reg, BIT(bit), val); + if (ret) + return ret; + + meson_calc_reg_and_bit(bank, pin, REG_PULLEN, ®, &bit); + ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit), BIT(bit)); + if (ret) + return ret; + + return 0; +} + static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, unsigned long *configs, unsigned num_configs) { struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev); struct meson_bank *bank; enum pin_config_param param; - unsigned int reg, bit; int i, ret; ret = meson_get_bank(pc, pin, &bank); @@ -192,44 +236,17 @@ static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, switch (param) { case PIN_CONFIG_BIAS_DISABLE: - dev_dbg(pc->dev, "pin %u: disable bias\n", pin); - - meson_calc_reg_and_bit(bank, pin, REG_PULLEN, ®, - &bit); - ret = regmap_update_bits(pc->reg_pullen, reg, - BIT(bit), 0); + ret = meson_pinconf_disable_bias(pc, pin); if (ret) return ret; break; case PIN_CONFIG_BIAS_PULL_UP: - dev_dbg(pc->dev, "pin %u: enable pull-up\n", pin); - - meson_calc_reg_and_bit(bank, pin, REG_PULLEN, - ®, &bit); - ret = regmap_update_bits(pc->reg_pullen, reg, - BIT(bit), BIT(bit)); - if (ret) - return ret; - - meson_calc_reg_and_bit(bank, pin, REG_PULL, ®, &bit); - ret = regmap_update_bits(pc->reg_pull, reg, - BIT(bit), BIT(bit)); + ret = meson_pinconf_enable_bias(pc, pin, 1); if (ret) return ret; break; case PIN_CONFIG_BIAS_PULL_DOWN: - dev_dbg(pc->dev, "pin %u: enable pull-down\n", pin); - - meson_calc_reg_and_bit(bank, pin, REG_PULLEN, - ®, &bit); - ret = regmap_update_bits(pc->reg_pullen, reg, - BIT(bit), BIT(bit)); - if (ret) - return ret; - - meson_calc_reg_and_bit(bank, pin, REG_PULL, ®, &bit); - ret = regmap_update_bits(pc->reg_pull, reg, - BIT(bit), 0); + ret = meson_pinconf_enable_bias(pc, pin, 0); if (ret) return ret; break; -- 2.17.1