Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp461408lqb; Wed, 29 May 2024 00:16:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXAlvgfIliJw8mb5lJ+kj1vlhQsgFy/5IU7/t+FoesnkyCiybX5pTW8fdZ8o2W4PVx1rARhKK+TbCP/wsd/F+TDIhwFVYYJB43KHtdobQ== X-Google-Smtp-Source: AGHT+IHmD2/w+V5HsJsTuWXDmERUFFSD0gCERxlqevoAfTRLnwatVWAHgVO0MBZCohueRJ78o9YS X-Received: by 2002:a50:bb09:0:b0:574:ebe0:7dbf with SMTP id 4fb4d7f45d1cf-578519870cbmr8339654a12.12.1716966995853; Wed, 29 May 2024 00:16:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716966995; cv=pass; d=google.com; s=arc-20160816; b=xt0IieEu4DiCaA0ye5ZC7d+rreKJaDp6yvteMCSTk+epsUTIqj8VV9GJOA6+8LyVU+ czUSaK5W7SifJdCBkKj+15Qzh9xbSXZYgnA43CM/TT/eMAhgFrnPGLwqEsLMF2BSf39d 5Zby7KSKaEjBvtQ14331xdyTgS879J8a2zQI/HXphTCyuQ30/dcqVLPJY4Vv3+hDwpJX fScJZ2J/XHSWRIeAMhiva81zK6OchoJtRjvJnMtyT09zYTO5vFit4bBUqgJ3HFFa3XKk ozanwdzwPswVOBp6io1JrjjD7z0APJdIhe0uT5Q4CyhfFbZa8x9tQsg7fCjkGtLTYjsi yOfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :dlp-filter:cms-type:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=SiGNd/X062sCjbQ3KNasPq9AXI1T7vTAaXy64r0sd5g=; fh=1K/zG1T7kBcCNNYiJprnHVCeoxvCPM4Ys7NTkv30Bzw=; b=k9l7NA7ySNnL6IcJ3f+EKyGkgQd6SoCX75xilOWWMyHxh4fJq0IDMk/I2QAay4ucB0 iSAe8LeQY/ExS7WvqKuFWAVL0nkDi1t3my7v9XrfLWuPbg7JNSV37QaYd/V9Grk+TPO1 uCmMP0663C1AH70oW7K26d9n9WMteGFeBeKjqC6+ayUmsgONGT5F/BJi7ppIPkS+TmiW MEczCSdHhiDGUX7RPUrS21GVq8JdBXPqgwyfGWnyFRS+IlhFSofWmz9jJsAhhm1eTSRk 8cBi5Qq7lEZrQRAHqy/8kug8RwduFenmBBX0ZSoCDIYBUnefQ5XaqT9Uy6fo1dV3kskK JVLQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=K8SUtCHJ; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-193570-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193570-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-579cd9799fbsi3767684a12.594.2024.05.29.00.16.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 00:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193570-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=K8SUtCHJ; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-193570-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193570-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 64D211F232CF for ; Wed, 29 May 2024 07:16:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79DCE1649DF; Wed, 29 May 2024 07:16:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="K8SUtCHJ" Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 830CA15B99A for ; Wed, 29 May 2024 07:16:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.24 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716966986; cv=none; b=QIixpKod5AJl2WiSiKgeyM+4iVmIHM9JdqIlDp9f4154YCpn2oIKaOFyW+ozc2r5Ey7OaNv48IX9v+zvPx2V4pzX+ta100qhxkuv5Tq9WYEZX9T9ybiKW2acK+dJt/XIeTOJte7muNs8ARZ715kWK7QGW1DSEr9ri7yi7gjnI2I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716966986; c=relaxed/simple; bh=nq9OPjriJWIJ5BFeLbgNqrTQm3GhcP0bGpwBiZ8qkO8=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:References; b=pOv8vdq2tKrJZJQ3bQ18EkFDfaInUyM09MGCoilcwAZIF57sslFuWyeLlhwBB+pVct03xiwFnDxsY3OaAT/naqNxiZ2SNWb93/7KbZ8oC0en+I/wk7SWnv6fHU8dtrUpIWdLCBcVUfnE/6kgRObYsISiYf7Nezy4H9hm+6FNtKA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=K8SUtCHJ; arc=none smtp.client-ip=203.254.224.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20240529071621epoutp011a779517e95757c96dcd5cd321f04799~T5F96VNtU0122101221epoutp01b for ; Wed, 29 May 2024 07:16:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20240529071621epoutp011a779517e95757c96dcd5cd321f04799~T5F96VNtU0122101221epoutp01b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1716966981; bh=SiGNd/X062sCjbQ3KNasPq9AXI1T7vTAaXy64r0sd5g=; h=From:To:Cc:Subject:Date:References:From; b=K8SUtCHJ3n7H9BRfgnOdXRSJ4bj6GCNBIYh/TSsQwm9Q8TdJFdCAR2XL8AjoAfmJZ FOWcDMi6oBOgu6MUQjNIYeSN7YzznUJPH7GodW3Lpj2NqhCH+dmwzjq/HpGLAn0OMS gel+perT/43YNxOED0fGFp4R/zLc8w7RBfFSQCJk= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20240529071621epcas5p23fe659a7ce88c64dab6ca24ccaec2ec2~T5F9cD9pv3114431144epcas5p25; Wed, 29 May 2024 07:16:21 +0000 (GMT) Received: from epsmgec5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4Vq0zm0Y7cz4x9Pr; Wed, 29 May 2024 07:16:20 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmgec5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 53.60.08853.246D6566; Wed, 29 May 2024 16:16:18 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20240529070220epcas5p140580a28b93ce5cb256ef825c778c649~T45urcH3o2715427154epcas5p1B; Wed, 29 May 2024 07:02:20 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240529070220epsmtrp2922cc095f16316937ad6715823142c6d~T45uqpiv91136511365epsmtrp2l; Wed, 29 May 2024 07:02:20 +0000 (GMT) X-AuditID: b6c32a44-5fcaba8000002295-e2-6656d642360e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 41.36.08622.CF2D6566; Wed, 29 May 2024 16:02:20 +0900 (KST) Received: from cheetah.sa.corp.samsungelectronics.net (unknown [107.109.115.53]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240529070219epsmtip17ef35fc42e2bd39fbdedfa6f12c23d0a~T45tOTlm01300713007epsmtip1H; Wed, 29 May 2024 07:02:19 +0000 (GMT) From: Vishnu Reddy To: krzk@kernel.org, s.nawrocki@samsung.com, alim.akhtar@samsung.com, linus.walleij@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, pankaj.dubey@samsung.com, ravi.patel@samsung.com Subject: [PATCH] pinctrl: samsung: Add support for pull-up and pull-down Date: Wed, 29 May 2024 12:29:39 +0530 Message-Id: <20240529065939.36369-1-vishnu.reddy@samsung.com> X-Mailer: git-send-email 2.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uami4vjr f7RL2xt+gaQZlUosxRmJhlrMRcWJAINOWoKgAgAA X-CMS-MailID: 20240529070220epcas5p140580a28b93ce5cb256ef825c778c649 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240529070220epcas5p140580a28b93ce5cb256ef825c778c649 References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: gpiolib framework has the implementation of setting up the PUD configuration for GPIO pins but there is no driver support. Add support to handle the PUD configuration request from the userspace in samsung pinctrl driver. Signed-off-by: Vishnu Reddy --- drivers/pinctrl/samsung/pinctrl-samsung.c | 51 +++++++++++++++++++++++ drivers/pinctrl/samsung/pinctrl-samsung.h | 7 ++++ 2 files changed, 58 insertions(+) diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index ed07e23e0912..a4b6eea5e168 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -939,6 +939,56 @@ static int samsung_pinctrl_unregister(struct platform_device *pdev, return 0; } +/* + * samsung_gpio_set_pud will enable or disable the pull-down and + * pull-up for the gpio pins in the PUD register. + */ +static void samsung_gpio_set_pud(struct gpio_chip *gc, unsigned int offset, + unsigned int value) +{ + struct samsung_pin_bank *bank = gpiochip_get_data(gc); + const struct samsung_pin_bank_type *type = bank->type; + void __iomem *reg; + unsigned int data; + + reg = bank->pctl_base + bank->pctl_offset; + data = readl(reg + type->reg_offset[PINCFG_TYPE_PUD]); + data &= ~(0xf << (offset * 4)); + data |= value << (offset * 4); + writel(data, reg + type->reg_offset[PINCFG_TYPE_PUD]); +} + +/* + * samsung_gpio_set_config will identify the type of PUD config based + * on the gpiolib request to enable or disable the PUD configuration. + */ +static int samsung_gpio_set_config(struct gpio_chip *gc, unsigned int offset, + unsigned long config) +{ + struct samsung_pin_bank *bank = gpiochip_get_data(gc); + unsigned long flags; + unsigned int value = 0; + + switch (pinconf_to_config_param(config)) { + case PIN_CONFIG_BIAS_DISABLE: + value = DISABLE_PIN_PULL_UP_DOWN; + break; + case PIN_CONFIG_BIAS_PULL_DOWN: + value = ENABLE_PIN_PULL_DOWN; + break; + case PIN_CONFIG_BIAS_PULL_UP: + value = ENABLE_PIN_PULL_UP; + break; + default: + return -ENOTSUPP; + } + + raw_spin_lock_irqsave(&bank->slock, flags); + samsung_gpio_set_pud(gc, offset, value); + raw_spin_unlock_irqrestore(&bank->slock, flags); + return 0; +} + static const struct gpio_chip samsung_gpiolib_chip = { .request = gpiochip_generic_request, .free = gpiochip_generic_free, @@ -948,6 +998,7 @@ static const struct gpio_chip samsung_gpiolib_chip = { .direction_output = samsung_gpio_direction_output, .to_irq = samsung_gpio_to_irq, .add_pin_ranges = samsung_add_pin_ranges, + .set_config = samsung_gpio_set_config, .owner = THIS_MODULE, }; diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.h b/drivers/pinctrl/samsung/pinctrl-samsung.h index ab791afaabf5..23b70ddcaccc 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.h +++ b/drivers/pinctrl/samsung/pinctrl-samsung.h @@ -61,6 +61,13 @@ enum pincfg_type { #define PIN_CON_FUNC_INPUT 0x0 #define PIN_CON_FUNC_OUTPUT 0x1 +/* + * Values for the pin PUD register. + */ +#define DISABLE_PIN_PULL_UP_DOWN 0x0 +#define ENABLE_PIN_PULL_DOWN 0x1 +#define ENABLE_PIN_PULL_UP 0x3 + /** * enum eint_type - possible external interrupt types. * @EINT_TYPE_NONE: bank does not support external interrupts -- 2.17.1