From patchwork Fri Mar 15 15:10:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 780518 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp253407wrs; Fri, 15 Mar 2024 08:12:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVUHNSRetETfnkDd1YS3thDK21rNWFpCoYDYj2ar2dD0ik4FOLxSoAPQw00QxBYVkQT4NeG9hcN+DBNg5MlqwwJ X-Google-Smtp-Source: AGHT+IHzrfOelQrcL6pQ3SjNyraQbgrmQ3jmTGfUfQ3L5zwrQRqFxBt8PnHXdKQZ/mpX12LpbPys X-Received: by 2002:a05:600c:1f10:b0:413:1dcd:b39 with SMTP id bd16-20020a05600c1f1000b004131dcd0b39mr4045864wmb.38.1710515524888; Fri, 15 Mar 2024 08:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710515524; cv=none; d=google.com; s=arc-20160816; b=J4FVrcfM4cTUewFFYzej9HrglvvoEx+PapKfHRr30MEGf//XLa4n2U1r3GZj6pbBCD n6n3pkhmoMbpE9cyGP9tpe40WojsYNyyEO2NZ1urECVtHBrXJk5roBMGcxKrqYRJ1qxX 8XReH8nY/eI0VsiGfMLEsI9Oby8800HYE4GwCdMmWEohyInJt/0F5kNt07qkCdVz6HoX wHd2Lk4mhnNnTrv7y7GYtqejFgwHKUHVcDH9itLu066jGTaQg3IAPZ04qUGO70xg1jgy QOgCTN7b8Hgoe0nrueCY+edKsyA0SonnjmCCXEXaQuufHWrZv2379e47BWBLgbGKDnay ZjfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:cc:to:in-reply-to:references :message-id:content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=3JOoPnE7/Qw4KSbwZg45xCKwsyTMmqgOFvlWbdDPRFE=; fh=gSVpyLKtvZ+QePPYgVwr0OwBuSQ/slJGUurC/y9msiw=; b=Jj8JuhmwguuBqQrbikIvB2V+RPlKSwgVeGhmExCITXiJ05Mfu0qQsIalxAvKOLtZOh SzD1m6Ccf9Xpi4FTMfBrzpzrFAGZVExKMOOvvCxiTQm5lHEG0iIf1Bj0O/T9aLwQEno9 Cb/g9WGgzR+Id41DO0w48qplM9rugmUlHzflVnvfdL+LG2dDewX7gm1MU1DkD3Phq4k6 S+5ZV9f+7N/iEgcNEY5Q1mMcdCMOGHDKT3IzN7Q43xva5vzYLJiL/BPy9Wgc0bLv9rnr vtTzBA9dsoUenQMMItytSkBrjs7hdmaig27rwicL4xnDfgCLvqFwyfs1qL3ym3h+QRJQ f4rw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bvf+/O57"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 19-20020a05600c231300b00412f83e8fbfsi2320302wmo.81.2024.03.15.08.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 08:12:04 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="bvf+/O57"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A54988041; Fri, 15 Mar 2024 16:10:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bvf+/O57"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9AB3987FC6; Fri, 15 Mar 2024 16:10:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E48B588007 for ; Fri, 15 Mar 2024 16:10:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=caleb.connolly@linaro.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-414037f37cfso3788615e9.0 for ; Fri, 15 Mar 2024 08:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710515437; x=1711120237; darn=lists.denx.de; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3JOoPnE7/Qw4KSbwZg45xCKwsyTMmqgOFvlWbdDPRFE=; b=bvf+/O57DaFItCBlz6Yp6MlkADz/NN/XCH3//at0davQMyPgm09x7rELSMxziZLVvF 1U9bnPWOGIoGcFizcxFdpK3vfkFq0gVVCh2BMT6ls2vBKiUKEC/Mw3WNlq6+26PDVPtg NMd/87Nf1vWvc9TKAy+7IP83fZDOuxZ7Mlpak0YILv2xbQhgEFxptgxUjLrRnKZvl6j4 D6CfVA2bMb9S1pu3Go8T/KxglEsDT9fSeNlOwXRhqQm+dOso2qHk9ok8V548yPPhi0dv YG70n3wPrwntU5G/52Bb9+kQHmq6rCxZchfywTR7FjqkVUszBWgEiLhAFGYdOV4hNfm9 jdNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710515437; x=1711120237; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3JOoPnE7/Qw4KSbwZg45xCKwsyTMmqgOFvlWbdDPRFE=; b=bu+1RbffdKYgsNinNupFB72umeYPLjKn0ChLnNMeeUEDIBumRkPSM4aOCsnA6rN/Cr 4uRdjIJtW3CIiIu9sX9bbHsLd0/QQ5Cr4RrkVBi3b6GfOqSOXqNPavpUXRu9wOYCRN+U 6PjEPuaGvAco/8Klq3I6a24PJE+IgtJRoO9NZbImXLVxdALlrqfyelzsV4K+Ohf347CM pR15kKiGCFf5ghQxEWTis323pu2Pno7nAnoblJkK7wmgh+BdfwirIw+rDlze3+d4TG5C WVXaHa4G75/H1uXOa8rd8gxnTnelLY+7rCpiKVKrpzmOZmTRmLaFOgdQ/qV/k4jrMlAM 1oeQ== X-Gm-Message-State: AOJu0YyjJKpF8tgftNcxhJYCY8otdWJbXkCP0dgvUNB5MhI4AdE1aLJo FSlKYcx8tApQeN8ke4sKmf3QExvjimKwrZA1Ji6OtAHOF0+cvFdqhOxX64VOc2SYhP/0NUBATeb C X-Received: by 2002:a05:6000:1805:b0:33e:c7e3:b2e7 with SMTP id m5-20020a056000180500b0033ec7e3b2e7mr3554917wrh.11.1710515437305; Fri, 15 Mar 2024 08:10:37 -0700 (PDT) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id n6-20020a5d4006000000b0033e699fc6b4sm3398141wrp.69.2024.03.15.08.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 08:10:36 -0700 (PDT) From: Caleb Connolly Date: Fri, 15 Mar 2024 15:10:17 +0000 Subject: [PATCH v2 08/14] gpio: msm_gpio: add .set_flags op MIME-Version: 1.0 Message-Id: <20240315-b4-qcom-livetree-v2-8-ab635774b2dc@linaro.org> References: <20240315-b4-qcom-livetree-v2-0-ab635774b2dc@linaro.org> In-Reply-To: <20240315-b4-qcom-livetree-v2-0-ab635774b2dc@linaro.org> To: Tom Rini , Caleb Connolly , Neil Armstrong , Sumit Garg , Lukasz Majewski , Sean Anderson Cc: u-boot@lists.denx.de X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2529; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=BqhIvZ0D1m2EoNdcJwYk4o3G6xvhwsOurBZjgFCw3S0=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQvKY+DAjS6ZmRx3ZzLsHm3crtIk6zfAz2/CesO9znrH fh//WtuRykLgyAHg6yYIov4iWWWTWsv22tsX3ABZg4rE8gQBi5OAZjIpReMDEu9A9/lPY7j4tz4 7/pVZbNYnQP31x+/39xtv/D0tas86lWMDG1G+nuUO1TVz2iyJ+hyCat8ddqvffup2Tmz2+/1X/W xxQAA X-Developer-Key: i=caleb.connolly@linaro.org; a=openpgp; fpr=83B24DA7FE145076BC38BB250CD904EB673A7C47 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The .direction_input and .direction_output ops are deprecated, and don't seem to behave properly for us. Implement our own .set_flags op to handle this correctly. Signed-off-by: Caleb Connolly --- drivers/gpio/msm_gpio.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c index 5e57b0cbde75..f5d9ab54e817 100644 --- a/drivers/gpio/msm_gpio.c +++ b/drivers/gpio/msm_gpio.c @@ -34,21 +34,21 @@ struct msm_gpio_bank { #define GPIO_IN_OUT_REG(dev, x) \ (GPIO_CONFIG_REG(dev, x) + 0x4) -static int msm_gpio_direction_input(struct udevice *dev, unsigned int gpio) +static void msm_gpio_direction_input(struct udevice *dev, unsigned int gpio) { struct msm_gpio_bank *priv = dev_get_priv(dev); /* Always NOP for special pins, assume they're in the correct state */ if (qcom_is_special_pin(priv->pin_data, gpio)) - return 0; + return; /* Disable OE bit */ clrsetbits_le32(priv->base + GPIO_CONFIG_REG(dev, gpio), GPIO_OE_MASK, GPIO_OE_DISABLE); - return 0; + return; } static int msm_gpio_set_value(struct udevice *dev, unsigned int gpio, int value) { @@ -83,8 +83,25 @@ static int msm_gpio_direction_output(struct udevice *dev, unsigned int gpio, return 0; } +static int msm_gpio_set_flags(struct udevice *dev, unsigned int gpio, ulong flags) +{ + if (flags & GPIOD_IS_OUT_ACTIVE) { + return msm_gpio_direction_output(dev, gpio, 1); + } else if (flags & GPIOD_IS_OUT) { + return msm_gpio_direction_output(dev, gpio, 0); + } else if (flags & GPIOD_IS_IN) { + msm_gpio_direction_input(dev, gpio); + if (flags & GPIOD_PULL_UP) + return msm_gpio_set_value(dev, gpio, 1); + else if (flags & GPIOD_PULL_DOWN) + return msm_gpio_set_value(dev, gpio, 0); + } + + return 0; +} + static int msm_gpio_get_value(struct udevice *dev, unsigned int gpio) { struct msm_gpio_bank *priv = dev_get_priv(dev); @@ -109,12 +126,10 @@ static int msm_gpio_get_function(struct udevice *dev, unsigned int gpio) return GPIOF_INPUT; } static const struct dm_gpio_ops gpio_msm_ops = { - .direction_input = msm_gpio_direction_input, - .direction_output = msm_gpio_direction_output, + .set_flags = msm_gpio_set_flags, .get_value = msm_gpio_get_value, - .set_value = msm_gpio_set_value, .get_function = msm_gpio_get_function, }; static int msm_gpio_probe(struct udevice *dev)