From patchwork Mon Feb 26 17:26:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Caleb Connolly X-Patchwork-Id: 775916 Delivered-To: patch@linaro.org Received: by 2002:ab3:621a:0:b0:258:3251:9e33 with SMTP id w26csp1493344lte; Mon, 26 Feb 2024 09:28:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX/C7VlX+v8k3Wn7VW/U4YwsGMSdxed66FqsXf8fehgArtaLn64V4Z1PleV5tyZ1CL0a/v8uxIku+QIRQ4fqZK6 X-Google-Smtp-Source: AGHT+IEBfZieuG/d/DeizOJ2BDQiFwtxT5iQVZ/AFRCn+9dPRAei4yLzlP9LMCcU9u3Wd9w7Tr4Z X-Received: by 2002:a2e:8401:0:b0:2d2:532f:bdf2 with SMTP id z1-20020a2e8401000000b002d2532fbdf2mr4208884ljg.51.1708968504664; Mon, 26 Feb 2024 09:28:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708968504; cv=none; d=google.com; s=arc-20160816; b=Io/Nj3/EH6mOCxIZboMQ1ob18tXmMNdrXbhnZzF3FTlDRdpupjYj+gip+Fl/wEenYK QHFejDsJFSWZJDLMjCJ8PRSqSR6RiM14g5/fIZjQFxZmaud9mYMooyBuTZODUZ2T3dNM Lkx+KUhw+9TdixOTr6fFq0iy2uGUkK+e+SCCeTHVZCqrHEadN/9jq4geGxVjx/3eqIZ+ Z4t3IpmOsVPwolsh5GlA0FMv9yvJUi3/z5V2zNyxtB3vogrO1Yf68e8m/WJo8Ip8D3xo ljA6AknI7ibX0ZY4DcF+1J2b8nZ0I6Jd692b1tZrzLCHmbdKof0aGo/cCCxzukOjZZrN CTNQ== 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=K8GensPlvh1O1pGB+6orMTcQX8FeUDhHw5hMSEk+bOY=; fh=iAB6No2GP1VcgrKb0V+OWO3QAreDU4AXOT2zJ8agfXY=; b=PMKI944ZRkJjkTa9EI7YVLZRHMXtkj7XzVtUndx69DQa7/3hWJzuGDvXXD8c/47CPV dFJxWgin36skxo8rcA2q1onl7Qjxt8OmeGkb9QELo07Q48DrO/eWMgH5X6g5MsASQIAm kRr3c3/0b2udoUVdo5zAYEIpPV0DUw57MT/rsiATcspqrjzwD68GIOWD7bmBzboK1Lyp ndpj3/bG5UHI2sHls9muLciE+ur1sG22C81RyojZMymcQv9e4n8sdGeyqOuJb2Gy0Gw2 AFJGUEih+lrunQXbpURaxTS1ETfvX9cZlQ9CtPc+UVL5C7Ki6Wyqlvq2ItKwymhXIEEp PmDw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iLlsiGDE; 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 n7-20020a5d6607000000b0033dbce08a74si2769578wru.279.2024.02.26.09.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:28:24 -0800 (PST) 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=iLlsiGDE; 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 E403E87FB4; Mon, 26 Feb 2024 18:26:42 +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="iLlsiGDE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5905387FA9; Mon, 26 Feb 2024 18:26:39 +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=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (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 E2B9287F6A for ; Mon, 26 Feb 2024 18:26:31 +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-x42d.google.com with SMTP id ffacd0b85a97d-33d118a181fso2257070f8f.1 for ; Mon, 26 Feb 2024 09:26:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708968391; x=1709573191; 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=K8GensPlvh1O1pGB+6orMTcQX8FeUDhHw5hMSEk+bOY=; b=iLlsiGDEGi5BAQC8tRKWeO2qsqCY0ZLSC+3LhU3iWfdW21FQLZAceCY4nDkWJ9eo3P O+xrUgkj5ub+vy5WC17086OMwSoRArFFiJd4PZ+8TYG0bDqF3CaJEkaMSuPFBZHNeNg4 XfywtwuMUq0Nvvp2VX4NprdDfPQlXzfdd48B2t8KF2SJtnlFxXaquTNdo4bgqOKs67JH sGCc5fHJDyT/5APtvHT7tC3oMQlGzeu7/gPk++z1LaLCZ12DecXZvJU9wJkQ6T7orgmk do0As9JnLRoa7UUId46HAOxtnbhW/citq50XP6EUGCaPrVtb4pET5RPLVtcPyS+2fJBA gU+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708968391; x=1709573191; 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=K8GensPlvh1O1pGB+6orMTcQX8FeUDhHw5hMSEk+bOY=; b=RAUZeNSUnD5Z2tVc8AyNHiQyFLD+Qqh6uH0/tNvogAR09CWqqaquF0wkob4R9nugx7 7btIkrMxrNUrIuu8ra9WsBd/2HaPfS5P/2qnyExM2QhYd237++g3NXDJTWVWqP8WLmro EFYM8J3SSJvO/vmV30SAzaEA1mLoR5KX167uNmjpltupTWpwiKtnOmn4YHy0B0X91u67 NiYesCWEzLS6hjtTUn62AcEsR+33+BvwGao4XiGt9qtuQ+qKP6liQJkZBaYzO+i5Pbhx OuhWKgtSe8wNxjCIHxlgM/1/Okus96/dFHSJ8QbULD8vUH75qvFmUEXOKn/5Mlh2+5DU WBfA== X-Forwarded-Encrypted: i=1; AJvYcCX97dPJSRG4bstFo3SZOubTnUMH8aF29e6gFbBdbrjby99VhfrB2CwmnAL0aI2mVc4lV5HQ4EaANspmRYcsjl47LtizlQ== X-Gm-Message-State: AOJu0YwcFXJRh3xNkqUJW0RwvAjKxEr0VsidvzRD2q5aH8EgY4SRGJ8J KjpUgSG1D6Rc+znXTm395b7VuUxPGRLyZeVShVH5aO0zzjPJ36pf6E7+en2xGqA= X-Received: by 2002:a5d:468a:0:b0:33d:50cd:4672 with SMTP id u10-20020a5d468a000000b0033d50cd4672mr4504905wrq.21.1708968391441; Mon, 26 Feb 2024 09:26:31 -0800 (PST) Received: from lion.localdomain (host-92-17-96-232.as13285.net. [92.17.96.232]) by smtp.gmail.com with ESMTPSA id bt1-20020a056000080100b0033d9c7eb63csm9142256wrb.84.2024.02.26.09.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:26:31 -0800 (PST) From: Caleb Connolly Date: Mon, 26 Feb 2024 17:26:14 +0000 Subject: [PATCH v5 10/39] gpio: qcom_pmic: add a quirk to skip GPIO configuration MIME-Version: 1.0 Message-Id: <20240226-b4-qcom-common-target-v5-10-10c8e078befb@linaro.org> References: <20240226-b4-qcom-common-target-v5-0-10c8e078befb@linaro.org> In-Reply-To: <20240226-b4-qcom-common-target-v5-0-10c8e078befb@linaro.org> To: Neil Armstrong , Sumit Garg , Ramon Fried , Dzmitry Sankouski , Caleb Connolly , Peng Fan , Jaehoon Chung , Rayagonda Kokatanur , Lukasz Majewski , Sean Anderson , Jorge Ramirez-Ortiz , Stephan Gerhold Cc: Marek Vasut , u-boot@lists.denx.de X-Mailer: b4 0.13-dev-4bd13 X-Developer-Signature: v=1; a=openpgp-sha256; l=2464; i=caleb.connolly@linaro.org; h=from:subject:message-id; bh=WFOE1aBqYJfs0haUszbjoPUuUGsyz6AsID+c/IrzLM0=; b=owGbwMvMwCFYaeA6f6eBkTjjabUkhtQ7J3eaLTp+xaNHXKVPjfPUDrZdvb9jWU1uSdXVPVtyr uPdoZrkjlIWBkEOBlkxRRbxE8ssm9ZettfYvuACzBxWJpAhDFycAjCRczEM/53v7H+UMGWiDqem /HfhhI46oU3RLA1afj7tN+rtDLSjlzH80w8+6uf8+lTmcsegHt+dOy9rzxVaWXXg3jLL7qnz/Q+ GzQIA 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 Some platforms hard reset when attempting to configure PMIC GPIOs. Add support for quirks specified in match data with a single quirk to skip this configuration. We rely on the GPIO already be configured correctly, which is always the case for volume up (the only current user of these GPIOs). This is not expected behaviour but appears to be due to a U-Boot specific bug. This quirk at least allows for the volume buttons to be used on platforms where this bug is apparent. Signed-off-by: Caleb Connolly Reviewed-by: Sumit Garg --- drivers/gpio/qcom_pmic_gpio.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/qcom_pmic_gpio.c b/drivers/gpio/qcom_pmic_gpio.c index 2a4fef8d28cb..63b512725ad9 100644 --- a/drivers/gpio/qcom_pmic_gpio.c +++ b/drivers/gpio/qcom_pmic_gpio.c @@ -63,8 +63,19 @@ #define REG_EN_CTL 0x46 #define REG_EN_CTL_ENABLE (1 << 7) +/** + * pmic_gpio_match_data - platform specific configuration + * + * @PMIC_MATCH_READONLY: treat all GPIOs as readonly, don't attempt to configure them. + * This is a workaround for an unknown bug on some platforms where trying to write the + * GPIO configuration registers causes the board to hang. + */ +enum pmic_gpio_quirks { + QCOM_PMIC_QUIRK_READONLY = (1 << 0), +}; + struct qcom_gpio_bank { uint32_t pid; /* Peripheral ID on SPMI bus */ bool lv_mv_type; /* If subtype is GPIO_LV(0x10) or GPIO_MV(0x11) */ }; @@ -74,9 +85,14 @@ static int qcom_gpio_set_direction(struct udevice *dev, unsigned offset, { struct qcom_gpio_bank *priv = dev_get_priv(dev); uint32_t gpio_base = priv->pid + REG_OFFSET(offset); uint32_t reg_ctl_val; - int ret; + ulong quirks = dev_get_driver_data(dev); + int ret = 0; + + /* Some PMICs don't like their GPIOs being configured */ + if (quirks & QCOM_PMIC_QUIRK_READONLY) + return 0; /* Disable the GPIO */ ret = pmic_clrsetbits(dev->parent, gpio_base + REG_EN_CTL, REG_EN_CTL_ENABLE, 0); @@ -303,9 +319,9 @@ static int qcom_gpio_of_to_plat(struct udevice *dev) static const struct udevice_id qcom_gpio_ids[] = { { .compatible = "qcom,pm8916-gpio" }, { .compatible = "qcom,pm8994-gpio" }, /* 22 GPIO's */ - { .compatible = "qcom,pm8998-gpio" }, + { .compatible = "qcom,pm8998-gpio", .data = QCOM_PMIC_QUIRK_READONLY }, { .compatible = "qcom,pms405-gpio" }, { } };