Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2032842ybb; Sat, 11 Apr 2020 18:35:42 -0700 (PDT) X-Google-Smtp-Source: APiQypKnKoxjBx9VXt76x4vumlvFx88mSoPvVwNJNcqf21JE6Btk4RDcpVX3VFFzrEAdWgrTZH3M X-Received: by 2002:a37:e115:: with SMTP id c21mr10909377qkm.249.1586655342829; Sat, 11 Apr 2020 18:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586655342; cv=none; d=google.com; s=arc-20160816; b=yZs/Xpiws0Zv4KmmWk0WmwYkmlVNX8yUGo4l1S0I7FUa/I8PBJJENr0YMrrYvSqt+D MotvMzpeW/Xwtica5SvOnVlrWN+QtcYliDjayVmgG5xdgSRGmXWn78IpJ+rXlmBMZKyF Kr7F1GjLjfniLuMfg/0Unh3MV4o2MkJ+DPBs5uBmbRhcGKR7B2F+intOVbIIGVLeb1mT 0ohU+eQxBbNjTexEAKci0msDpwKECSOVvYf7azyBRruD28dEg/gALHb3eZScpgAWuDp+ 4//A95FVm1p+PN2MGWV9rlSDJ8R+/quwDQnLgDaP9oL1lD+BM7okKRGnj6vg/b9a813R 7Acw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=G3nQaM43k9Rklf2xLNnAGkRhKH0gN0HpijPYsLTLZdM=; b=r1s9V/Z/6zmN3fXyNDRlBI1EoJk6TslepVpS2hRx25bgZrzIUQz7c82RpiF7utvqY2 dGrZkko12yIalbc/N6oHN3sVr8acLSnNeLiW8mfSy5UAZFKHagMqmo7x/UmseuBm/899 /qlRJecCOqE2YAPvPkkO3RN1zDPhbcMV+4wqLsKDfFDlnrL2Wi9Qwwhf/KDF3MfO2b+m MF3/fbz4EVlpSNEf4YuoCNXYlVkXAmQpNl4ZCCkf/CS6LEjoq3kAau6VjPkdxSylKUoq AOdcJeTPVZYnfL3MZnMP6gkujHL9Id7pU9Dmaj7Ae/YuvVHEbSafSOcsG4a/3JvDzVIe yDbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AwPTvAUI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si4677573qtw.306.2020.04.11.18.35.22; Sat, 11 Apr 2020 18:35:42 -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=@gmail.com header.s=20161025 header.b=AwPTvAUI; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbgDLBeA (ORCPT + 99 others); Sat, 11 Apr 2020 21:34:00 -0400 Received: from mail-qv1-f65.google.com ([209.85.219.65]:40566 "EHLO mail-qv1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726155AbgDLBeA (ORCPT ); Sat, 11 Apr 2020 21:34:00 -0400 Received: by mail-qv1-f65.google.com with SMTP id k9so2818236qvw.7; Sat, 11 Apr 2020 18:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=G3nQaM43k9Rklf2xLNnAGkRhKH0gN0HpijPYsLTLZdM=; b=AwPTvAUITiOJF80dM/rPAHATDeQ3GU/8cDAo/hNSm4EOixAspTDZ53W/ovEXabIXJP e0xUYfwOywrkk9NqihZ14MIAOHUhXmTwoQsbk0GAGjO98BJAnpUk9DdqI1HNB2FQAjUI 4pH3/Yb/3y+UnAxVViaohluOE0a8zpMYnGerS8s4wIe+fCtRTh2Kjxx9Ci7RpiP3AbNN GO88B3Ft2D0KY+4FC1mRrbhHu8yq40rZLboGWpdk2e2cvGB+OG3S73cHpUcKEYeYTT0K pCzrZ1tQKwokXPE2RzleSzlhvv52z5xs2Ah7M8BPGQKvrq9QnWEqMsqdzrYneMcA+uJX Zofw== 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:mime-version :content-transfer-encoding; bh=G3nQaM43k9Rklf2xLNnAGkRhKH0gN0HpijPYsLTLZdM=; b=lQd3bbPFEfYQEaQIYB3V59nO1Giacdkmt/p8PCBizIk1LDJ0a4N34P+bVjiLIpjdCb LEq3gXSljg1RfPZZJF7J42WxuYXCjDB/nLzQQnWRCacnkJaLpCudPieXH8jE1iKHKxnQ GNTCiHe0DWvRDotddcV8iUPb4kJh4aLHIHZKj4Fn3Py2hN87o9obsEbjdLMv2KyHwUgr iJAv+O+Oa4qCqd+QZjoFcQ00Ev0nGsckGAd4O/UOYUcm9iUyn8g/0cf/9kEFIhfBCZGI dx+QF4NK3c5fZBon5xNCZ0pPuySFusNM/vK9n+DG+GpXBB2b+5cLQrn3p5r44N3Kdj/t lobg== X-Gm-Message-State: AGi0PuYcx6FnvpNX4aiVqZXvPb1PtZ9VcZKsS9NF5dJTUkssTWs/gweT cC3eu5xx4u/dEJ9nlubHFWHQcxQngVY= X-Received: by 2002:a0c:f70d:: with SMTP id w13mr11652746qvn.118.1586655239720; Sat, 11 Apr 2020 18:33:59 -0700 (PDT) Received: from localhost.localdomain (c-73-37-219-234.hsd1.mn.comcast.net. [73.37.219.234]) by smtp.gmail.com with ESMTPSA id n92sm4965192qtd.68.2020.04.11.18.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Apr 2020 18:33:59 -0700 (PDT) From: Adam Ford To: linux-gpio@vger.kernel.org Cc: aford@beaconembedded.com, Adam Ford , Linus Walleij , Bartosz Golaszewski , Thomas Petazzoni , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] gpiolib: of: Improve gpiolib-of support pull up/down on expanders Date: Sat, 11 Apr 2020 20:33:51 -0500 Message-Id: <20200412013352.674506-1-aford173@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When using GPIO expanders attached to I2C ports, their set_config function needs to be passed a config setting which contains options to enable pull up or pull down bias feature. In order to set this config properly, the gpio parser needs to handle GPIO_PULL_UP and GPIO_PULL_DOWN. This patch enables the flags corresponding to GPIO_PULL_UP and GPIO_PULL_DOWN. Signed-off-by: Adam Ford diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index c6d30f73df07..bf17afb1f66d 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -344,6 +344,12 @@ struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, if (transitory) lflags |= GPIO_TRANSITORY; + if (flags & OF_GPIO_PULL_UP) + lflags |= GPIO_PULL_UP; + + if (flags & OF_GPIO_PULL_DOWN) + lflags |= GPIO_PULL_DOWN; + ret = gpiod_configure_flags(desc, propname, lflags, dflags); if (ret < 0) { gpiod_put(desc); @@ -585,6 +591,10 @@ static struct gpio_desc *of_parse_own_gpio(struct device_node *np, *lflags |= GPIO_ACTIVE_LOW; if (xlate_flags & OF_GPIO_TRANSITORY) *lflags |= GPIO_TRANSITORY; + if (xlate_flags & OF_GPIO_PULL_UP) + *lflags |= GPIO_PULL_UP; + if (xlate_flags & OF_GPIO_PULL_DOWN) + *lflags |= GPIO_PULL_DOWN; if (of_property_read_bool(np, "input")) *dflags |= GPIOD_IN; -- 2.25.1