Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1025825yba; Thu, 9 May 2019 09:31:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjgDjgeDMPfzjYNMQxp6y8VMmCUsAqKmV4FyIRi1k6sx+64rMZWnBojv8xAK/5l3XjkQpI X-Received: by 2002:a62:e10f:: with SMTP id q15mr6576937pfh.56.1557419469545; Thu, 09 May 2019 09:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557419469; cv=none; d=google.com; s=arc-20160816; b=ufoIh1MdEtzyTRTdKzYwILIV0bK3iOgdlFe+rV5A4fNje8h5M5dWETFC1jIQtzjEYU obdVsyWSrl294u4xGG90PwLYaFZi4vEUQW+FeDE8rVupUBrM8UpBIfFREVFMqTJajRBs WOT+SQlVGU1/SuHWSzLuUpw6zrvN7vur51l3YGAf7XDgMenwBoReaXRMHtEXjbnq+O1C UI4hrAJzgI/St9r4qwMXBfSJmNAdHMBftZef0nIoLMMGF4f9fyhfzoteI4ugl2VkmnjG kAMJcIVA6nZQbiDcbTXWUQ4YXSiIVXXwK2B9cqfS82WVkZkXO+gLPbB2CRpehLH4RMkI bTgw== 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=osjiNPAbpnUtMytO+bzOqr2qePaLnC3stv6P+BAqJfTUaCX+VRlvdhORHYeXo+23Lj gIRGh2YGmqCwnJxPoWt4nc7g2LxqqBBz8pwf4LUCRNXn7HL2RbzkEC2TKHUA/8Fp9Oyx wnPYemIxWnWWxU8hLiArFfMzhcYUZTHifL0PrrdfSKt6fEkuw6tS+vRjnJZUNqkX4fde QS184mGkuSKEzhS/IAmqx+pfhl7DQWs2yu3Z3stTDDIYcE5c7udhpbHLSsPTer4dreRd V8Wdis5JtvoXnBMCyqtNINCKkjOxb/+ixfxHTkbgliJTfkNhCQIffBlXcDS81enAtW6G L8YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=M7g8Ekqm; 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 z2si2931398pfz.143.2019.05.09.09.30.52; Thu, 09 May 2019 09:31:09 -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=M7g8Ekqm; 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 S1727533AbfEIQ3t (ORCPT + 99 others); Thu, 9 May 2019 12:29:49 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38425 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727427AbfEIQ32 (ORCPT ); Thu, 9 May 2019 12:29:28 -0400 Received: by mail-wr1-f66.google.com with SMTP id v11so3937373wru.5 for ; Thu, 09 May 2019 09:29:27 -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=M7g8EkqmvRrEK7koH/I8Kj1kubFPWigS6HT0fcBopuqWq6SnSLdzjd+eubupKFJI4i YGDwcdR/5lRYsBsRlACF3H4pHAfoY7mphC1mMDkk881qa6DNjfbOy7jeIjvkLnZcWgxu K4L3MBFd4sXJTvkKtg3ODCpogtLmWYr7agApw9asekiBLNjRelZwGw6T6qxEvPnISFJ3 OO/S+2US00AnP1F7w+N9wTTmLXYfza8zcGcHC0VJt3ikurVHGHm/EnRxNrXO7ELpoRvT WeV/R0GQ4ndrXz08DqgjUFzn6R/z1R9K7D0VdX8H23y+bhodq8+c6viI/xYUUktpfBf/ 1p5Q== 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=pYzTsbWVPXHSsFwR9vTLqQ481GqWqBmHe1S9EvOZ1WCCkqrQnIaNcVkGVxGozoGXc3 cetu2pWNISTjWNFgkcowQK1KISEr4it9GItMxvt3ypRlS7Z32Yz4gYxNbdfoMWrdUHhY WPntDs6Kn2TVsv1ve7Jy7sge57s10mfIeWVxgiskNxTJ9iNMWuG1UiOQholrqcY0yeCi Cf1b2lGP+NTJjSJkk2ZkZ8ugSqzAe4ZTfrkJXh7CY75aWO1bzVuNTrHbWLoFCz9WG0oc qjDkxOm4CpGUfiSjcU77UwEnc09ZxVrkIFQecHJZ8sAgs4t6/ADL/ure3tjMEm7ETzdj iHkQ== X-Gm-Message-State: APjAAAVnx/I5XoRIdlGrFzCnyaISzZwnWdCr9WQirVOfTymS0hrhkdMt MUDn2tbAE51XecViV99b/WKO3Q== X-Received: by 2002:adf:da4a:: with SMTP id r10mr3858823wrl.216.1557419366867; Thu, 09 May 2019 09:29:26 -0700 (PDT) Received: from glaroque-ThinkPad-T480.home ([2a01:cb1d:379:8b00:1910:6694:7019:d3a]) by smtp.gmail.com with ESMTPSA id k2sm4116297wrg.22.2019.05.09.09.29.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 09:29:26 -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 v4 4/6] pinctrl: meson: Rework enable/disable bias part Date: Thu, 9 May 2019 18:29:18 +0200 Message-Id: <20190509162920.7054-5-glaroque@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190509162920.7054-1-glaroque@baylibre.com> References: <20190509162920.7054-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