From patchwork Wed Sep 11 18:07:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 827472 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp922145wrc; Wed, 11 Sep 2024 11:07:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWYQttw1HkWUBXTyxER8dMWuIyONpdA9FN3+PVkgaIUOl6tfZiKiWVhpdyxTHRXMN14Uy/0mw==@linaro.org X-Google-Smtp-Source: AGHT+IFt2pkcc+8tcqH6Ypfxa3+i7Mx/fhpKqn7dxDlZAEn6n+eJC72KXdMwKO5nmS+tkT+Kx9Wp X-Received: by 2002:a17:907:e64e:b0:a86:7d62:4c28 with SMTP id a640c23a62f3a-a90295a6016mr28514766b.30.1726078051124; Wed, 11 Sep 2024 11:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726078051; cv=none; d=google.com; s=arc-20240605; b=YPsR9O0YrGQev5NuxeSJNTZcD2S0dbffVWDCbGE7p6MXUgllS4Ivr/+pSgdNIXTOgc lDFJhhsIyedTsMCu/xOiebsD9rLH/BoHnO29G6856X5JdatTc34FoXyDNyX9gMCVTDDy aXYcdsgfnivMsA+atXbRL2xHPiooU6HjSyPoWCwMBayGYunnma9djqN/HgB+n4IQ18PT uomTZeurpcoTYAHcsfriNGxvkf0Z1xkysFj4rjSLm8hjQceDz2GCZbXOlgdCCFXxSYTX H8sf0JdGn9oinvwL3Doj9G2uf2zQjGM9m75Q532bzFfizaISWsABxgB0wwlrwHb28piF psvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=wiAtme929kZSm5f6Dxzpw/4FODGxe7FfO8rO9BH0BXE=; fh=/OduIcglOGGyJf7qok+ShyNh7iqbi/Fa16pAiaWGx3U=; b=CN9mwfUaRfP9NkIpVzd6oLtv80j/CIZ8zEIL9ygPBuKHzgDjSOBgZduSXBGFzYTWxN 0xQhiUnlxp/r5JKjzF7vVCJLTT1a0fhf4rWyARSfE15IY6zCc+nshsJ6kSZh78YIxqyY PK04L5iYd9iH1c3UF60pqKfJTz9bu2HG+/PDJjXEW6wbF/IxuzJGbk1YEFe9gt8vZv4/ ihD2hUW3nQwurzxCvKUkb2dJwhRA6+F4xgYv8R0uoHZRi7lzBFrSnwuAgVyT9Su1v3gN 9aQ7+kq3EpZ3UnfjXHL7ZPXjo7snnpJTxZJYjVcjEjVV2ry7Qdb9sXbeV3YvLC6FCeF+ 60DQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YuJioySZ; 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; dara=neutral header.i=@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 a640c23a62f3a-a8d2584ccb8si759498766b.84.2024.09.11.11.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 11:07:31 -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=YuJioySZ; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 27B4889304; Wed, 11 Sep 2024 20:07:24 +0200 (CEST) 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="YuJioySZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6AD4888E83; Wed, 11 Sep 2024 20:07:21 +0200 (CEST) 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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 7183C892FF for ; Wed, 11 Sep 2024 20:07:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42cacabd2e0so243655e9.3 for ; Wed, 11 Sep 2024 11:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726078039; x=1726682839; 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=wiAtme929kZSm5f6Dxzpw/4FODGxe7FfO8rO9BH0BXE=; b=YuJioySZrs0FBEi1JTv8C/cHZBgVXUfsIiJbJ09dCcpLxmy82m2jdgdXUt6OsKHMTU w6uSIg7osT3enS/FrwYPLhMgT3NZP3Aubxzl44Z4RLdbXBTz1MZuOf9lNY1cD0eciPPj FiD1RsaXcnsGTeJBPu2waEpv316aRuRMSRLCyN8hY+P8r/LgUODPAprpZiKHDAv5Xods k8U3jw44POEL0G5RG2qHcql4te9CuMzkSwztSeGuszTDV6fuQTXMnD1OXhy4OjG4cXjI Z3iD28MbfDfbITev4WBHsc7O60G1OdatBojU3agehemOGndE/WbxVez1F7Z3cvsnidif kz8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726078039; x=1726682839; 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=wiAtme929kZSm5f6Dxzpw/4FODGxe7FfO8rO9BH0BXE=; b=ma5g9B5rkbbtSVfkAX19Jw8zxiyBDxuGayio05bdm2rjqXRsBa9jaree/CYT/P5t5r 4nAQvF7N8POugqA6X1bkMDn39imOgyEzGWYvu9a3U9rqYdTnRrnRUpi+67mfQrlZJyJB cU6f/Ygh1ilQDthFl238zIT+SyacuG9tR6tIO58ohTDwr84/40hxGx2CC24E4vfBAdEh vo+Tw6NucnwGUOM5L2ZZVCNCMdvz0MOeeGVU1Lv0NqrjzkwBypCztpfbMMm3fDfdwO6J 4V1KyuAVtc07QjNFJ5b5Q+nWlVQO/rRfklk9bMq5XDgfSTWmS8hjqe2XG80gkoXcMEBZ QhPQ== X-Forwarded-Encrypted: i=1; AJvYcCW9RghF9bw25UBTVwCPFhHHiU4VL0uazTSEGxycWndfduD1QmuqBPCl8vIVjERD6Ml37aC9NR0=@lists.denx.de X-Gm-Message-State: AOJu0YzqcN36G6LVAseG1IpZtg/Jh+N/RH5w66oWsFagtYhsLnJSq3M6 jEyUEhvE/EQeNMggWrwlwAYBnN8r32I1Ta1XkZ8kYI+hPnLBDP0cW2iQIWmZUrxFth0N+46tWzN H X-Received: by 2002:a05:600c:1e0f:b0:42c:bc03:e765 with SMTP id 5b1f17b1804b1-42cdb53bbddmr3160535e9.16.1726078038680; Wed, 11 Sep 2024 11:07:18 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895675b8bsm12192404f8f.54.2024.09.11.11.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 11:07:18 -0700 (PDT) From: Neil Armstrong Date: Wed, 11 Sep 2024 20:07:14 +0200 Subject: [PATCH v2 1/2] gpio: msm: add support for special pins MIME-Version: 1.0 Message-Id: <20240911-topic-sm8x50-msm-gpio-special-pins-sm8250-v2-1-c49834055128@linaro.org> References: <20240911-topic-sm8x50-msm-gpio-special-pins-sm8250-v2-0-c49834055128@linaro.org> In-Reply-To: <20240911-topic-sm8x50-msm-gpio-special-pins-sm8250-v2-0-c49834055128@linaro.org> To: Caleb Connolly , Sumit Garg , Tom Rini Cc: u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4823; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=hpzDe3p6sPzJQLFujHI5KRQb2puJ+WsxzjYzQ7F0P44=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBm4dxU8IkZwwWmw30vKQAEet9zgPU3Scv1VyYmq1L/ tjSRSaeJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZuHcVAAKCRB33NvayMhJ0euhD/ 9hlnf7iAXkIde2kIvuqVgEJNDhGeMs8yQFRl8g0Ce0YUHxdAG7TsUb/jSzakZ3FM+TIASvnqAb5md2 b/5RGZM5VktnJeRFmx0EbPHnuytmJYihUbUUvbc1b+PMdCplmvKiTVY9HArZKzOq+8nUNgVlNxwzoX +1DlwA0PabI8B8xlWjInvLUCXAOpWoXWRVXr7C71CJtZyS8pC6HGBin/Fs3sMQJufy8x+NZTLx3eVB r3GNvJH6wKjZUooWdiy/hF6hyMQSouSloDE/2oQnJ5JieFdaYo62bf5BJUw8W/bGYOxtNOGgBHskv8 oEpwmj4Sn1C8ksU9lCAquhdBBGWH1dJnrYOJefTENqwcEDVIjuy9wj5ObA1qqhkRiZKUIyfhc2juYU oPq6RJ527QqmLomgtyqEHj7jjiHiWciNqsbxIYYL3xH4WdTSfI0+wG7F4lGCxwK7n5sBDspjom1+Me WI/gMrqAmfvTW/g1N9wvGz2ifPPOKf8OOmKob6MlamYcWJJr7w2OsJXJ3YolaOxKT4mc/B9/79frRz Zeg4Ro2gUpsdAyOm7xC/m/cYDtWrXLMUVhwGRgNeBNk7gtPlcTm4zG8A6jivRQiK/J4mWoALCtHsVB W3KUIesk2qTzcGSVnkTBLOAYgoewKnp9+hZ0+D6tBLFbn3G760rlFxvQ7/sA== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE 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 Leverage the data introduced in the struct msm_special_pin_data to allow setting the gpio direction and value if supported by the pin data. Signed-off-by: Neil Armstrong --- drivers/gpio/msm_gpio.c | 97 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/msm_gpio.c b/drivers/gpio/msm_gpio.c index 2fb266f1285..cea073b3297 100644 --- a/drivers/gpio/msm_gpio.c +++ b/drivers/gpio/msm_gpio.c @@ -34,13 +34,31 @@ struct msm_gpio_bank { #define GPIO_IN_OUT_REG(dev, x) \ (GPIO_CONFIG_REG(dev, x) + 0x4) +static void msm_gpio_direction_input_special(struct msm_gpio_bank *priv, + unsigned int gpio) +{ + unsigned int offset = gpio - priv->pin_data->special_pins_start; + const struct msm_special_pin_data *data; + + if (!priv->pin_data->special_pins_data) + return; + + data = &priv->pin_data->special_pins_data[offset]; + + if (!data->ctl_reg || data->oe_bit >= 31) + return; + + /* switch direction */ + clrsetbits_le32(priv->base + data->ctl_reg, + BIT(data->oe_bit), 0); +} + 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; + msm_gpio_direction_input_special(priv, gpio); /* Disable OE bit */ clrsetbits_le32(priv->base + GPIO_CONFIG_REG(dev, gpio), @@ -49,13 +67,33 @@ static void msm_gpio_direction_input(struct udevice *dev, unsigned int gpio) return; } +static int msm_gpio_set_value_special(struct msm_gpio_bank *priv, + unsigned int gpio, int value) +{ + unsigned int offset = gpio - priv->pin_data->special_pins_start; + const struct msm_special_pin_data *data; + + if (!priv->pin_data->special_pins_data) + return 0; + + data = &priv->pin_data->special_pins_data[offset]; + + if (!data->io_reg || data->out_bit >= 31) + return 0; + + value = !!value; + /* set value */ + writel(value << data->out_bit, priv->base + data->io_reg); + + return 0; +} + static int msm_gpio_set_value(struct udevice *dev, unsigned int gpio, int value) { 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 msm_gpio_set_value_special(priv, gpio, value); value = !!value; /* set value */ @@ -64,14 +102,42 @@ static int msm_gpio_set_value(struct udevice *dev, unsigned int gpio, int value) return 0; } +static int msm_gpio_direction_output_special(struct msm_gpio_bank *priv, + unsigned int gpio, + int value) +{ + unsigned int offset = gpio - priv->pin_data->special_pins_start; + const struct msm_special_pin_data *data; + + if (!priv->pin_data->special_pins_data) + return 0; + + data = &priv->pin_data->special_pins_data[offset]; + + if (!data->io_reg || data->out_bit >= 31) + return 0; + + value = !!value; + /* set value */ + writel(value << data->out_bit, priv->base + data->io_reg); + + if (!data->ctl_reg || data->oe_bit >= 31) + return 0; + + /* switch direction */ + clrsetbits_le32(priv->base + data->ctl_reg, + BIT(data->oe_bit), BIT(data->oe_bit)); + + return 0; +} + static int msm_gpio_direction_output(struct udevice *dev, unsigned int gpio, int value) { 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 msm_gpio_direction_output_special(priv, gpio, value); value = !!value; /* set value */ @@ -100,13 +166,28 @@ static int msm_gpio_set_flags(struct udevice *dev, unsigned int gpio, ulong flag return 0; } +static int msm_gpio_get_value_special(struct msm_gpio_bank *priv, unsigned int gpio) +{ + unsigned int offset = gpio - priv->pin_data->special_pins_start; + const struct msm_special_pin_data *data; + + if (!priv->pin_data->special_pins_data) + return 0; + + data = &priv->pin_data->special_pins_data[offset]; + + if (!data->io_reg || data->in_bit >= 31) + return 0; + + return !!(readl(priv->base + data->io_reg) >> data->in_bit); +} + static int msm_gpio_get_value(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 msm_gpio_get_value_special(priv, gpio); return !!(readl(priv->base + GPIO_IN_OUT_REG(dev, gpio)) >> GPIO_IN); } From patchwork Wed Sep 11 18:07:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 827473 Delivered-To: patch@linaro.org Received: by 2002:adf:ab1c:0:b0:367:895a:4699 with SMTP id q28csp922214wrc; Wed, 11 Sep 2024 11:07:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU6AUcOxNq0exieB+GAgM6wlEO9fZJ2ATTbFGGnupjfKl9jgyteyXqk6qIaGE11/cbQ1VaigQ==@linaro.org X-Google-Smtp-Source: AGHT+IER5xkBjHZZXZ0qTmQtfnk8jPx1bviBK3FIwbLGLcc7+jT/oOFeEPB8dfAl9q8SsaJ0AC5w X-Received: by 2002:a05:6512:2351:b0:536:7377:7d23 with SMTP id 2adb3069b0e04-53678fe6973mr179816e87.40.1726078059731; Wed, 11 Sep 2024 11:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726078059; cv=none; d=google.com; s=arc-20240605; b=VER04lhCkEtzDv8BbHQ3GaUbgWN65ou3YNX19qkExfDNSn/Sg3oqHHFXHGwDWOWIxp 4pcXAyfkfdLNtAR5EGMaxEsYMH+gRq3+rbGBx95mroulXDFZOI8/rF/Tz3TgfXZ98U3y XZt0SO6UEq5dIUVd6C1C5/dImW6UllDSMPgmmdq21+Wg6WSTXvwkwvbEBP8mWVEbT6iQ sb02XtCiZSvQeIprldkFH6EgcLm4wTduQzG302y4hGA08JNJ1CAIZh2mobVKp0RjgcYu 4QWh4dqpCXQrEyI8S1UaIgAA/XPtKC5JHXXt+1zA5UeQBw0j5eQgJBLKBGSvKFAatOAo 21bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Cmf/fbNVJaJLRb9lKxkY6Si07zCgMRRrId512VSL/bE=; fh=qC6KelM4BHyLvhXs45tF0O/Lo751WjXEEJNKkTgYF1g=; b=DgXwWpVt1RV8rjeS+EvTmlh1eBinalwJk99XbSnSAuFHQXa41JVOMDsfK4Lqh/THv/ RV4TwvYK39Kb/3o0auwoZ7YLE1a2Xl0q7aKLs3ZpYnbtrbcH8ZyXTUiC2dOC22wX1rbF R3ZlIh+pFdOtl2Ifoo1N6DOicYXQ9px+UMNKFGzXim33BxGCMIxE13TjHi4C/I02pHow V9J4J4+G3uhFL17aV1v+2PNAQKUvsV+ecEBe0jKWrI5CIUval73X5neeOIp7JF/pJd5i txOG16GTxeAcJv41Lt0A/MoAorXN85KS6oX9eMezPYJ+h3YeXpEvBO1MJUlDcLIhTJ0r 9l0g==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VkddneD+; 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; dara=neutral header.i=@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 a640c23a62f3a-a8d25d663fdsi753754166b.850.2024.09.11.11.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 11:07:39 -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=VkddneD+; 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; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 80BBB8930A; Wed, 11 Sep 2024 20:07:24 +0200 (CEST) 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="VkddneD+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F151E89306; Wed, 11 Sep 2024 20:07:22 +0200 (CEST) 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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (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 146F289303 for ; Wed, 11 Sep 2024 20:07:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=neil.armstrong@linaro.org Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-374c3400367so119117f8f.2 for ; Wed, 11 Sep 2024 11:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1726078039; x=1726682839; 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=Cmf/fbNVJaJLRb9lKxkY6Si07zCgMRRrId512VSL/bE=; b=VkddneD+Sy0EEcbRMFHW3n1hk8gMGOO1CEzzg9YL4G5d24HtqbBSxupJHdj6eG/vST Ifmehodc7eP4J0MQNiSU58CC/Acz90oTSFlKYqfwh4JUPEK1Ybn60ffNTTbot/DOwsv4 ILuQW5EsuuE6W6/FCyfUf7yQrvFpNOYl4pddzY0NYFCvq0yDzHUC8MAwv7Vf6N2l8xBq rHypu3gh6eDV9gs+Mx1fmoYFZb8YIeEfTAH+6Y9JNRextZggBQ8043CVABMGgKywPMiW yOjaIsKvBoL670/Oj2GyLxotpAIBOGygCTNB5zqYzh+J0cN/YHgGILfMaMM7AFTZUx2W UghQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726078039; x=1726682839; 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=Cmf/fbNVJaJLRb9lKxkY6Si07zCgMRRrId512VSL/bE=; b=mgtlK54JfgwOM39myk0FemPqtLhDOH1MPrLSbSMtyKHYSj2/HSWqcLw/FxxlCM5nlI Ok/tlW1xtm0InTmRRFvjIasCZN+BZtsV6COQitAYJrStNtcMADi7KwbtStdSSk5bJfVF PXz7m4gFJliwJKXl2mjgG8xLYZ1fkZ/ETh5B+o8XG6Mt7f+VTsAXVsoM1DnYsAcWWO/0 nEhJZssmU59dOX4zy/rC3yz8wHQ8kRyp2ZHzJtqUcugpj19xxlBAxukqTex9CH11wHJV y/ArOaqg4+SFm1U67WGLu85M8x5785a1BdbfM8h9a/RnMgfCF36p7Nem89XdYo3Pnq96 /ymA== X-Forwarded-Encrypted: i=1; AJvYcCWxHUTPcBAOGtNNI17R2nySdHWoMeSPVcqAAFXjWtBkwPrb+WLTfPWagELD9XCw7lRiv3z3IL4=@lists.denx.de X-Gm-Message-State: AOJu0Yyj2DrucHjsqgXEa4QmOb7vQ3u03WA3QoO6n3p6rkq0VPyWU/6f lfk+2VNzTVd5HH/cwaFaHMQjK69Zj8f0p8PMb9F1S61uzqbiLQOalPSEhkWwMhfqJQIViXs1m5d P X-Received: by 2002:a05:6000:87:b0:374:c3e4:d6b1 with SMTP id ffacd0b85a97d-378c2d4d177mr60248f8f.44.1726078039363; Wed, 11 Sep 2024 11:07:19 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895675b8bsm12192404f8f.54.2024.09.11.11.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 11:07:19 -0700 (PDT) From: Neil Armstrong Date: Wed, 11 Sep 2024 20:07:15 +0200 Subject: [PATCH v2 2/2] pinctr: qcom: sm8250: add special pins pins configuration data MIME-Version: 1.0 Message-Id: <20240911-topic-sm8x50-msm-gpio-special-pins-sm8250-v2-2-c49834055128@linaro.org> References: <20240911-topic-sm8x50-msm-gpio-special-pins-sm8250-v2-0-c49834055128@linaro.org> In-Reply-To: <20240911-topic-sm8x50-msm-gpio-special-pins-sm8250-v2-0-c49834055128@linaro.org> To: Caleb Connolly , Sumit Garg , Tom Rini Cc: u-boot-qcom@groups.io, u-boot@lists.denx.de, Neil Armstrong X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3125; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=9nqmucjOd8nAPp4aFInlnm94wqsPYUREu9/EeJ+2/JY=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBm4dxU6Z44LkBSin8Eg9JU0TGCL6JRtKJKcbZQGIKN KuhxGx+JAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZuHcVAAKCRB33NvayMhJ0YrJD/ wKtuUZtoqqdhL8WEaPCLtANYu0Ji8KWEjV8p8BfZPJke8NGqS1SMKBEa7FOrwpVjBn7DfG2a5wOkge 2jiMhRfh+THJbcEnkgHjWgzRG69eih2pQ3Kn43EJOGUS94xSuXrXWAZh8xHvyI1qxOkkia35bQmUKY jkz6gMdNGLlc4xgSFih8ZSWT/NbfVxsmD2/Ai48osWPg1/K6SGbngX/wboajGNdj1H7G9IcuppZvZb 4pcFERTb/YcifGdSZAk0mAUqVu/Wv+K8GUaU+mdKyTf9HVgndDIM+Y6YdZmuYlGOo/l0OBc3hB85AS sk5/RalOQoWUdmk/AjtnsMRikaMucF7EKECMTr2Mx1ghc2medxDhnUT0x5fZqufWUFXvFtmr2MxFxT CHOHxw01PLtD3xfRqxobPwIdSBvq9qqHcmVvYFpYcbeKqymfBssxV+GuAktFfG76ERJsyb6ygmKkDw ovEStiieo49lfKzdYe32yUQx4ur+IYM+xNVrM+XiQbqN2P/9DYmLIda9nPa5DA9KtoN5nyQXqYyQz6 F7iHP65K21nvpOWGCfUX1tSoWiaZ023vjx5D/C+9LFssCT0lVNYnQ1NvRSUrYAw/XfylZhCfloHX5X Q3rHBgqb+WF4FoGLVCP1CDzbS3ZjryxbVctCFv8X6LR5xCwF9wgzdCuRdmKg== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE 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 Add the special pins configuration data to allow setup the bias of the UFS and SDCard pins on the SM8250 SoC. Signed-off-by: Neil Armstrong --- drivers/pinctrl/qcom/pinctrl-sm8250.c | 42 +++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/qcom/pinctrl-sm8250.c b/drivers/pinctrl/qcom/pinctrl-sm8250.c index dac24f11bc2..cab42fa64ed 100644 --- a/drivers/pinctrl/qcom/pinctrl-sm8250.c +++ b/drivers/pinctrl/qcom/pinctrl-sm8250.c @@ -18,8 +18,37 @@ static char pin_name[MAX_PIN_NAME_LEN] __section(".data"); static const struct pinctrl_function msm_pinctrl_functions[] = { { "qup12", 1 }, - { "gpio", 0 }, - { "sdc2_clk", 0 } }; + { "gpio", 0 }, }; +#define SDC_PINGROUP(pg_name, ctl, pull, drv) \ + { \ + .name = pg_name, \ + .ctl_reg = ctl, \ + .io_reg = 0, \ + .pull_bit = pull, \ + .drv_bit = drv, \ + .oe_bit = -1, \ + .in_bit = -1, \ + .out_bit = -1, \ + } + +#define UFS_RESET(pg_name, offset) \ + { \ + .name = pg_name, \ + .ctl_reg = offset, \ + .io_reg = offset + 0x4, \ + .pull_bit = 3, \ + .drv_bit = 0, \ + .oe_bit = -1, \ + .in_bit = -1, \ + .out_bit = 0, \ + } + +static const struct msm_special_pin_data sm8250_special_pins_data[] = { + [0] = UFS_RESET("ufs_reset", SOUTH + 0xb8000), + [1] = SDC_PINGROUP("sdc2_clk", NORTH + 0xb7000, 14, 6), + [2] = SDC_PINGROUP("sdc2_cmd", NORTH + 0xb7000, 11, 3), + [3] = SDC_PINGROUP("sdc2_data", NORTH + 0xb7000, 9, 0), +}; static const unsigned int sm8250_pin_offsets[] = { [0] = SOUTH, [1] = SOUTH, [2] = SOUTH, [3] = SOUTH, [4] = NORTH, [5] = NORTH, @@ -52,7 +81,6 @@ static const unsigned int sm8250_pin_offsets[] = { [162] = WEST, [163] = WEST, [164] = WEST, [165] = WEST, [166] = WEST, [167] = WEST, [168] = WEST, [169] = WEST, [170] = WEST, [171] = WEST, [172] = WEST, [173] = WEST, [174] = WEST, [175] = WEST, [176] = WEST, [177] = WEST, [178] = WEST, [179] = WEST, - [180] = 0, [181] = 0, [182] = 0, [183] = 0, }; static const char *sm8250_get_function_name(struct udevice *dev, unsigned int selector) @@ -62,7 +90,12 @@ static const char *sm8250_get_function_name(struct udevice *dev, unsigned int se static const char *sm8250_get_pin_name(struct udevice *dev, unsigned int selector) { - snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); + if (selector >= 180 && selector <= 183) + snprintf(pin_name, MAX_PIN_NAME_LEN, + sm8250_special_pins_data[selector - 180].name); + else + snprintf(pin_name, MAX_PIN_NAME_LEN, "gpio%u", selector); + return pin_name; } @@ -76,6 +109,7 @@ static struct msm_pinctrl_data sm8250_data = { .pin_offsets = sm8250_pin_offsets, .pin_count = ARRAY_SIZE(sm8250_pin_offsets), .special_pins_start = 180, + .special_pins_data = sm8250_special_pins_data, }, .functions_count = ARRAY_SIZE(msm_pinctrl_functions), .get_function_name = sm8250_get_function_name,