From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31D15C04AB4 for ; Tue, 14 May 2019 08:27:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01E26214C6 for ; Tue, 14 May 2019 08:27:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="V5p+VSaI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726676AbfENI1X (ORCPT ); Tue, 14 May 2019 04:27:23 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:43015 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbfENI1B (ORCPT ); Tue, 14 May 2019 04:27:01 -0400 Received: by mail-wr1-f65.google.com with SMTP id r4so18106167wro.10 for ; Tue, 14 May 2019 01:26:59 -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=ABNodvidPpmQibNK03maenhQOWEuJJdUvRf24Z3W14k=; b=V5p+VSaIHFJiu028UV0cKcC4xTMdP7TT7IlerUXE9FLCbzyJhGUgx5wYnuBsaaSMX1 LNcViMP4OrXhUjvE8zSVvPm3syH9Glc/58weTycU7bK7eP/dC5C/bhNtwRZ1goZE3zcI sERDfGVwifJoD+nMoQuMlFvID1739aQ1Z3vARzbOlKlLaEuyBpFrj0P+H7HhS36+ob8g 7IN+4QuoUy6CgCDhkhHpUp28VqCo+ZA7deerUWW+yKSXlkNKquuLX5UotZSiiaXkNEbL kS13t/L0FUpbmV4/49fu8coD5iKKhOlfJ/BTt4bW/bzxFXtYzrZTyhrw1yNB+NSGTVny ipiw== 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=ABNodvidPpmQibNK03maenhQOWEuJJdUvRf24Z3W14k=; b=p/4dk/VDdolnn/j27ltJ6T6k/4SshMHVISDfJJidpgpSTxLwH0RKtcY2+oouur+hr6 PkiUveVg4+T8dKtUnT2pJUEkcdhwilLDb5gWE2efJ/U+ViHlDYhYTPU6dK2nu/Nzckwx +1abiaVeB3bdzGqon/LhUu4c/pEzXd/z7o88t26NQBHJmBiM4X7tHBQjd5kGQFAJfrcm COER3j2syTCqIKECReXPjdPgLSO3+IclbG6L3nl/cIfdT9gdG4J/t1n7fEX3Rtb+wdIP OjomWTDU/tsKNmi/XkaIauLBCOj3ayA3JJsbyHos0OMTXkC5s8NTXzHJBCbUDPqWNEov 77Bw== X-Gm-Message-State: APjAAAXlXBWV1upQjCc972slyAZXGKMY+G3aZUj3fSShARV0hVev7EmF uEkMZnUe0OD8OK/UWDvPT/7hCw== X-Google-Smtp-Source: APXvYqxDB4ujZcu4wi+99AP5cvFV4yfG5NrLvHLGnQ+xsd2i6Tfm4wBOsp6h6hPNffVml94ddIn/wQ== X-Received: by 2002:a5d:4109:: with SMTP id l9mr20002695wrp.204.1557822419187; Tue, 14 May 2019 01:26:59 -0700 (PDT) Received: from glaroque-ThinkPad-T480.home ([2a01:cb1d:379:8b00:1910:6694:7019:d3a]) by smtp.gmail.com with ESMTPSA id j190sm2450772wmb.19.2019.05.14.01.26.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2019 01:26:58 -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 v6 4/6] pinctrl: meson: Rework enable/disable bias part Date: Tue, 14 May 2019 10:26:50 +0200 Message-Id: <20190514082652.20686-5-glaroque@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514082652.20686-1-glaroque@baylibre.com> References: <20190514082652.20686-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 Reviewed-by: Martin Blumenstingl Tested-by: Martin Blumenstingl --- 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