From patchwork Tue Mar 19 12:22:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 781091 Delivered-To: patch@linaro.org Received: by 2002:a5d:46c1:0:b0:33e:7753:30bd with SMTP id g1csp1896310wrs; Tue, 19 Mar 2024 05:24:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWnxLV+R4yIVTOR9O0OZZ+1SkDca7Wj6+Q1Rsvcov3GY1BVC39F1cldRtx1e6/I2HG55FYIVoXejpEmx43AG0Gf X-Google-Smtp-Source: AGHT+IFpGnmYtJlemOBfUSmJaIvUptqwm9RnZePk5SbniKbXm77jzq0m+87Ar75EXKp/P/D9FhGk X-Received: by 2002:a05:600c:a0b:b0:414:21b:9a92 with SMTP id z11-20020a05600c0a0b00b00414021b9a92mr8536980wmp.8.1710851053355; Tue, 19 Mar 2024 05:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1710851053; cv=none; d=google.com; s=arc-20160816; b=Cr36S1/r78zJnoZdypLONQ0ldtUKWAsGDDc6AR+y1TkPbTdYv609ivuJa7E6kQmgIQ 9gzrd/3KzQLzKybacG87aFdhALvk2KPXMeIy6YC7cYMrC/Jquemeg62itQ3DbF3mnVkz od3IXAE3zGgnX3tgAffhkET65UL0rbFtQy6pI/NP6Nh5TO7IAqHFGV36bfilBkJPvkgx PpbseASOm4wRpYGPGGPSnZGhCAK1hp07jSpo6pcqb3RicOslIwb+mmGSfaIZPZgC63X4 tbhAMiF3OpDpEBrCra5OMWZf0TvcA3f388MZAmWFT/OPyDZ+zCBON5TMCnaDFq9zEQ0U MbkA== 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=IEqzU3JBI7KctO031msLqIdNJN6T3Hq1Xp3tl47hRMmuC4Qqy4EaF0OVP0qjUt6C+s tuqaD9BF363DKl1GZBi2zfhlSwQyDVR/LXKoc/ccCHSPrZYotmLqpINY/fm3fy5Fa2ZP RGC9V3dfWnhkG7ca+y2uxOvo8aN8FIji+2Gd+4OVwwuV3FA6LnbcX6/3L+tGc2Sg4141 X+IhG72C8ssagwWyNqv7ZDw0vuhhXDpHgk8l+AqC/XjmuFBHU9zgeZawx2JP/UgCPgOV SW/KtJbPg58WzHjXvhaAE7yxB0UIa/LMWGOcXqT7r/GCVuGMiKbqbdsQB7KCR2kF6kCo nY6w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uy4AZYtS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id bi11-20020a05600c3d8b00b0041413887460si1851636wmb.107.2024.03.19.05.24.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 05:24:13 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uy4AZYtS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 4B9A888065; Tue, 19 Mar 2024 13:22:53 +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="uy4AZYtS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 029B687F46; Tue, 19 Mar 2024 13:22:52 +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-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (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 150BD8807F for ; Tue, 19 Mar 2024 13:22:44 +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-wr1-x432.google.com with SMTP id ffacd0b85a97d-33e1d327595so3506896f8f.2 for ; Tue, 19 Mar 2024 05:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710850964; x=1711455764; 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=uy4AZYtSSv8dkzIhyqNATrukWxWu1p+4V8VUC11gqJm0GGloP93OKHd+ejLyrQSzbQ zkcOq0RUgFxf8vaprH1LnV8WQsyDRFuIyr7P5y/+hII3m6PgdSKsSr6nr72VXyeMeyIo /YNOMyFq2dzW1tRmZa9+qM7GHw7/1X5/6q0soqMmMFp+QYDHsHvfJZk5ePmyJlU524MI RfwVz2lxp/AcCD++D/SSJpSQApMnwFRRv+otI8Cxy3ccxvujGV0cvbFFNzEZQw/MnZBe 3h5UfOjGeT5NWfRrnuSuMk8/j7f/32UD+OEsJVrX4iADi7KFaqbfr/tVvsZmju3XAjl0 KGjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710850964; x=1711455764; 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=uKAXtbABSVJga/Ww97DApP+UTUDa7OaROf3X/4gwizqODJTPgV1L5Fd/Bo5pQDolVI 2F1JhlypkP+zONCn1FgXYjg+ceSdKSIoBx+JmxWxHfrMBujK+oiD/M237YvswqcJP2YN nPlDP9oWCJ5Wbc9ILpy7rKvSbLV/xKGIp/KneSLfew/DS9Qe+iv04u78m9X3JZCzGt0I 4ysn4ixDIJmaKK4Jtm2sAkTsikdHZHaTEn8VrA7puSOWA17Plb5rDJgpqfiMJUjpi7yW ctX4akeJRMerj7B7RdLLinOz2YXpv2UOWZavJ41Kc09n5l2rbbMasNx6mJ16kHJ3e89t vf1w== X-Gm-Message-State: AOJu0Yyc+tJOkRptcrO/AcQFDs4i8zYK4x5zFHevmZq6gSN69BqySXOU WO+1NLdg34HomlBoEAiXvNC31lkNkEKnPdT5756hfEKBahxqFcBO1e3GNKMgcSt8h1RiVdC3ESE 1 X-Received: by 2002:adf:ec90:0:b0:33e:777c:3899 with SMTP id z16-20020adfec90000000b0033e777c3899mr7520391wrn.38.1710850964034; Tue, 19 Mar 2024 05:22:44 -0700 (PDT) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id du18-20020a0560000d5200b0033b7ce8b496sm12170498wrb.108.2024.03.19.05.22.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 05:22:43 -0700 (PDT) From: Caleb Connolly Date: Tue, 19 Mar 2024 12:22:07 +0000 Subject: [PATCH v3 08/14] gpio: msm_gpio: add .set_flags op MIME-Version: 1.0 Message-Id: <20240319-b4-qcom-livetree-v3-8-e1b38d9b4fa4@linaro.org> References: <20240319-b4-qcom-livetree-v3-0-e1b38d9b4fa4@linaro.org> In-Reply-To: <20240319-b4-qcom-livetree-v3-0-e1b38d9b4fa4@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=owGbwMvMwCFYaeA6f6eBkTjjabUkhtSfzV1V19/vDwz+EpPY5XxJJd5SeteMQxcOCPklCET97 bMU/6jTUcrCIMjBICumyCJ+Ypll09rL9hrbF1yAmcPKBDKEgYtTACbyTpThn8L6pbMKN3WoPQro EJ286F5c1SvhVFmVh+tsFBZdE/jXw8Hwv/b6mymle6zZ58sWW8yf+mb/xtDF8z9/3yW59k/1Sjv mSzcB 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 Reviewed-by: Sumit Garg --- 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)