Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1821101yba; Fri, 10 May 2019 01:25:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2Y45hee6ZQjM64MY9/gSYyNFkbwZOPp0FPRhnTm+pnUQJXCjtCTzuaL51TSf8xF9Y76ce X-Received: by 2002:aa7:91c8:: with SMTP id z8mr12434969pfa.110.1557476724995; Fri, 10 May 2019 01:25:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557476724; cv=none; d=google.com; s=arc-20160816; b=pRDkvCgjQ8TQTH6XMhkZmxJEwrEL7Uphz2fTBBxq1cp6rBRwzDo/YgQghakUVYGal/ pYC+BUwI/pXDIm1Qx9WrW1/0KSdERGgNSwvhCwrMm5t07B2nKK1sjE/1J1ARx/ZLkK09 GbIfRm1lEm8qliX0uhFaonTzKNWhzkKzDuCLW3ZAOKm4b1Ez/P7zaAvlRbwdVu1/XAQw MNwu2F4jOcHCUXXIupHYNpp2SX+mqRtpvsrOSiGZuCb7mhvUHMmGMhtLoylOeGrS/vmd k1Enk4D9CilZZajYcur7z9hCu7KQJR+2onh2OamXoEqcdzbp2LaIjY1cBmKsJ1UG1+Gt /dpQ== 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=vmeMuMSDMRsdloGxuoikGok3kV3ygZ9BvAD0hdZ7+1Q=; b=ThEVn4aZnmC0BIWABI62vmRQomU3L0bBGQ/d8Idg88vG5bHUK4HnBadYZXGIsgKTgL 8IXK3tE2ohC3SNuzriJRX7g3Se/MUry4N6xLEFBZAA96cpcDVZPLp0wvuYZO8tLc5Tw0 avM0l0bFZiGBt2x2HRhVJzVzC7bCyUsPgphPhs0mPkxZ/l8Rg+uJk+IP01Q3QBWS70v/ 693fVXPTe6xuUAB8fYVxD62eK+YB3cLKIlxgEWsiFzLmnn8Y2Ci+/E7cEwtS+SOS7341 BkBWwCm1g/hlHs0SOUjq8uKZZqMEgsGWKDEfUhfEf/didYydo+3UpVBEz+x5+9wBQT/S u/jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0mH9YjY5; 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 p85si6539493pfi.27.2019.05.10.01.25.08; Fri, 10 May 2019 01:25:24 -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=0mH9YjY5; 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 S1727324AbfEJIXw (ORCPT + 99 others); Fri, 10 May 2019 04:23:52 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54269 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbfEJIXc (ORCPT ); Fri, 10 May 2019 04:23:32 -0400 Received: by mail-wm1-f66.google.com with SMTP id 198so6462689wme.3 for ; Fri, 10 May 2019 01:23:31 -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=vmeMuMSDMRsdloGxuoikGok3kV3ygZ9BvAD0hdZ7+1Q=; b=0mH9YjY5pN4altS8m8esAKUXR8IjrVzuxHW1h+AtZQx1kLM9VnfJwqhePnEaJ3+tcQ LDsHRX5weQ9wgdfEnAhU2tnojIKrjQyaRKZBpIiIC/6QOSZxzPqq8AVQh0dQcOvopUCT MmZPZTadQtHXyNJpU2dKz9hO1m/Kuh7a06sz6g0BzBnVl2JndWzmNQFQgG3WHVB7bBAg chdGBxSgbo/1Nwsc6TAmltJjr2DtkcNk0bJl+qbmNHHzu6thGLT7IAxq+ahgEcy8qYHy LItGoR6khG+/yWSoyynqqrIjzgfYTQRuqO8gHCKgi8DfrNVIG1F0tbq1XgHLBAZJhHIV unFQ== 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=vmeMuMSDMRsdloGxuoikGok3kV3ygZ9BvAD0hdZ7+1Q=; b=jhyAvoV+OSGt2IjgOtcf0IcfPdlvOMkrCITCeHyzaloIyV+ONf3JgP2mC9tBd25Qjk 3TQz8nmmTMm9g+G3i0cd7cceSFXqhYW4Xnj1xqDmq437cPhYweU6PVQPo2EWc3El8LIt wcRLnquY+kDIri5MuQHaEY1I47zgdjhA7Zf6vZSg8hTSxUj+3HdAJ5efSDrzIBRpccb1 gddx9s8+oIoe2bDLPWEi4prKxT65XALXfzu9U5jQY6Bivpev1bpVzLMc+OCJyb86Tqki AYfI7cMsuKxLRp/OYrhHANloGP4AuEfUXFHyHH+dC2WsE/YqZSrgA8flfTmeYUyXVh61 FEng== X-Gm-Message-State: APjAAAVDbstIJRVL5cIVhx7gVJ78SybBaa9mKUpF78+JEEJ1eYp0mMro jcKnwX4hoCO2f+U9chvBdX3uHg== X-Received: by 2002:a1c:2109:: with SMTP id h9mr6127281wmh.68.1557476610628; Fri, 10 May 2019 01:23:30 -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 z4sm3790285wmk.5.2019.05.10.01.23.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 May 2019 01:23:30 -0700 (PDT) From: Guillaume La Roque To: linus.walleij@linaro.org, khilman@baylibre.com Cc: jbrunet@baylibre.com, linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 4/6] pinctrl: meson: Rework enable/disable bias part Date: Fri, 10 May 2019 10:23:22 +0200 Message-Id: <20190510082324.21181-5-glaroque@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510082324.21181-1-glaroque@baylibre.com> References: <20190510082324.21181-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 no functional changes Signed-off-by: Guillaume La Roque --- drivers/pinctrl/meson/pinctrl-meson.c | 85 +++++++++++++++------------ 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c index 96a4a72708e4..8ea5c1527064 100644 --- a/drivers/pinctrl/meson/pinctrl-meson.c +++ b/drivers/pinctrl/meson/pinctrl-meson.c @@ -174,62 +174,75 @@ int meson_pmx_get_groups(struct pinctrl_dev *pcdev, unsigned selector, return 0; } -static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, - unsigned long *configs, unsigned num_configs) +static int meson_pinconf_disable_bias(struct meson_pinctrl *pc, + unsigned int pin) { - 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; + 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); + enum pin_config_param param; + int i, ret; + for (i = 0; i < num_configs; i++) { param = pinconf_to_config_param(configs[i]); 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, true); 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, false); if (ret) return ret; break; -- 2.17.1