From patchwork Sun Aug 29 13:13:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 504057 Delivered-To: patch@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp927393jai; Sun, 29 Aug 2021 06:14:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzUdNj4YXSMlyjredKOrwfvyQinnJ3vmMg+LdxOWYmR4XWgMI5BUNgkoU8xa4dcj17Mtgh X-Received: by 2002:a92:c68a:: with SMTP id o10mr12950265ilg.163.1630242861272; Sun, 29 Aug 2021 06:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630242861; cv=none; d=google.com; s=arc-20160816; b=T3C36sZ1eAzfKqjyxEp3/J6k3h6RpQVnXOVrXlzQz0nc/JoVqb6pHBx6L3n6sogKXo 5uwaBxhgtXCLGEIGEeSaZJXzkdZSOrVdUTOtwWTZ28eR/zbTmLS/ilnifNpmrGjdT1eA /grL6eZR/015CimlVnA2cK9jIM8JmT72NhFVJ1GvMTBcQfgIWQchBcf7iX89HOmpe9Up 4SvkkAc0kfhpGkaB9Msk4btE45hKg1XGxbGTohLJ1qiBTdsv7rUHGInic4c//akPss++ P5fbzA2rHQ8nswFuc+9EjLSguqW//HTdMLScZX1fhnAj5T2WF1K0fU48jigC4UFwnaAW ycdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gLxBTtcfVl4dtJ5J9RXz2IWihrIE1icg8208P8LI768=; b=j4JF6ukoUOnZj1E68STvNz1zK9/xGluw/cp1jWCYmP6UWuDY6Hlrd/Uuh2jhjOQJ4h /mWDVJpS1ike/WQHDBx/HhqvwIWviqIVJkJoFwJUSyu2fkCcYm8q53f424eVVdSdlKb2 YjELV5hdjOYdE1RAgzM/m/nS2wMlTo8IKT85KtY3WgBygxl2K6KCqWozWlFSsHtUTIWH wQzCcCjO+O5OqxbwjFNw+MkbUxHLVHvLfzyz7c5H3VDzUpO7I+EPzASxh8c/C+VATlgv jPcZKQpuTisCi6nzi4tXOVKtzQBE6M1yluf5dillIiVfBj/+5EPEOxWyFKcV9b5m+HaD 7cuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eLd/Cdzi"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n3si12867009ioh.98.2021.08.29.06.14.21; Sun, 29 Aug 2021 06:14:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eLd/Cdzi"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235668AbhH2NPI (ORCPT + 2 others); Sun, 29 Aug 2021 09:15:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235495AbhH2NOL (ORCPT ); Sun, 29 Aug 2021 09:14:11 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA223C0612A7 for ; Sun, 29 Aug 2021 06:13:17 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id d16so20717482ljq.4 for ; Sun, 29 Aug 2021 06:13:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gLxBTtcfVl4dtJ5J9RXz2IWihrIE1icg8208P8LI768=; b=eLd/CdzikufAJoC+IWYRwvNs/Ql43QYVNlpuhiAPvhXzK3//Di9TCZafUPMM5EBULL Mo7y7RQS5b6C83VsilbdzSAvFTfgRwq9R6PJqo+k6+JPE6UTqoKCXW5SxiMrryD/RYk1 MQtk5NojhV6O5mVIyn4SLnYNe8drwgcqVngKycpPETjynfImIykdyRPNbJnWCR2gmidg zqSJ8xjaa55tkihcjiHk6+WjAFbO/PUtvtMessLfsw6NBVGRhhRtV7mZrqceZU91XyXp WVS598gLcNzThW5YhN+k5gzLYDy22dy7DJAXHZVF0i22qsRLVdcWSKv6nT1GmZzaEgeN LpCg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=gLxBTtcfVl4dtJ5J9RXz2IWihrIE1icg8208P8LI768=; b=laNKQFWPcxVE+fXkDtPYpVOAm8UOrtUC8OgBfTV+sxZCQNxwRF3oMwPxFJ4viP8nKZ Nq3VklrxZ35WDksVITCS241wCm53RkI8YtnDL/iMtcNye+kIyGjZkrNX5n+A9vRhl5j+ dHEwnHH7bZaWFL6xuA7cA5l/JxBKTw+sVTGoqs8dTaRd49ntF5IqQ/NfdzIFMk7rm271 4Ry1pFCo6ElcIDGO/cK09l9x+pfrV4JjX+pZiwXl/7/2Tbxr3//lQYjcstzIj+5qf1AY LPDISkQrGFqtSVGpzDFFOoPdEl9EHhKzh0J3KxWfwCuwbIlQbJMm4bLYLS+LigsTbvpv K1DQ== X-Gm-Message-State: AOAM530Sm8HHFySxfGUwmCUsSrb7uKeztFtsdtz0HxI1897Fgvrt1f39 zcYO2rM6UWiMIjQOOF4V7g61Fg== X-Received: by 2002:a2e:97cf:: with SMTP id m15mr16094354ljj.125.1630242796087; Sun, 29 Aug 2021 06:13:16 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id x13sm712503lfq.262.2021.08.29.06.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Aug 2021 06:13:15 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Ulf Hansson , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Kalle Valo , "David S. Miller" , Jakub Kicinski , Stanimir Varbanov Cc: linux-arm-msm@vger.kernel.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [RFC v2 08/13] ath10k: add support for pwrseq sequencing Date: Sun, 29 Aug 2021 16:13:00 +0300 Message-Id: <20210829131305.534417-9-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210829131305.534417-1-dmitry.baryshkov@linaro.org> References: <20210829131305.534417-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Power sequencing for Qualcomm WiFi+BT chipsets are being reworked to use pwrseq rather than individually handling all the regulators. Add support for pwrseq to ath10k SNOC driver. Signed-off-by: Dmitry Baryshkov --- drivers/net/wireless/ath/ath10k/snoc.c | 45 +++++++++++++------------- drivers/net/wireless/ath/ath10k/snoc.h | 4 +-- 2 files changed, 25 insertions(+), 24 deletions(-) -- 2.33.0 diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index ea00fbb15601..8578c56982df 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "ce.h" #include "coredump.h" @@ -41,14 +42,6 @@ static char *const ce_name[] = { "WLAN_CE_11", }; -static const char * const ath10k_regulators[] = { - "vdd-0.8-cx-mx", - "vdd-1.8-xo", - "vdd-1.3-rfa", - "vdd-3.3-ch0", - "vdd-3.3-ch1", -}; - static const char * const ath10k_clocks[] = { "cxo_ref_clk_pin", "qdss", }; @@ -1010,10 +1003,14 @@ static int ath10k_hw_power_on(struct ath10k *ar) ath10k_dbg(ar, ATH10K_DBG_SNOC, "soc power on\n"); - ret = regulator_bulk_enable(ar_snoc->num_vregs, ar_snoc->vregs); + ret = pwrseq_full_power_on(ar_snoc->pwrseq); if (ret) return ret; + ret = regulator_enable(ar_snoc->vreg_cx_mx); + if (ret) + goto vreg_pwrseq_off; + ret = clk_bulk_prepare_enable(ar_snoc->num_clks, ar_snoc->clks); if (ret) goto vreg_off; @@ -1021,11 +1018,14 @@ static int ath10k_hw_power_on(struct ath10k *ar) return ret; vreg_off: - regulator_bulk_disable(ar_snoc->num_vregs, ar_snoc->vregs); + regulator_disable(ar_snoc->vreg_cx_mx); +vreg_pwrseq_off: + pwrseq_power_off(ar_snoc->pwrseq); + return ret; } -static int ath10k_hw_power_off(struct ath10k *ar) +static void ath10k_hw_power_off(struct ath10k *ar) { struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); @@ -1033,7 +1033,9 @@ static int ath10k_hw_power_off(struct ath10k *ar) clk_bulk_disable_unprepare(ar_snoc->num_clks, ar_snoc->clks); - return regulator_bulk_disable(ar_snoc->num_vregs, ar_snoc->vregs); + regulator_disable(ar_snoc->vreg_cx_mx); + + pwrseq_power_off(ar_snoc->pwrseq); } static void ath10k_snoc_wlan_disable(struct ath10k *ar) @@ -1691,20 +1693,19 @@ static int ath10k_snoc_probe(struct platform_device *pdev) goto err_release_resource; } - ar_snoc->num_vregs = ARRAY_SIZE(ath10k_regulators); - ar_snoc->vregs = devm_kcalloc(&pdev->dev, ar_snoc->num_vregs, - sizeof(*ar_snoc->vregs), GFP_KERNEL); - if (!ar_snoc->vregs) { - ret = -ENOMEM; + ar_snoc->pwrseq = devm_pwrseq_get(&pdev->dev, "wifi"); + if (IS_ERR(ar_snoc->pwrseq)) { + ret = PTR_ERR(ar_snoc->pwrseq); + if (ret != -EPROBE_DEFER) + ath10k_warn(ar, "failed to acquire pwrseq: %d\n", ret); goto err_free_irq; } - for (i = 0; i < ar_snoc->num_vregs; i++) - ar_snoc->vregs[i].supply = ath10k_regulators[i]; - ret = devm_regulator_bulk_get(&pdev->dev, ar_snoc->num_vregs, - ar_snoc->vregs); - if (ret < 0) + ar_snoc->vreg_cx_mx = devm_regulator_get(&pdev->dev, "vdd-0.8-cx-mx"); + if (IS_ERR(ar_snoc->vreg_cx_mx)) { + ret = PTR_ERR(ar_snoc->vreg_cx_mx); goto err_free_irq; + } ar_snoc->num_clks = ARRAY_SIZE(ath10k_clocks); ar_snoc->clks = devm_kcalloc(&pdev->dev, ar_snoc->num_clks, diff --git a/drivers/net/wireless/ath/ath10k/snoc.h b/drivers/net/wireless/ath/ath10k/snoc.h index 5095d1893681..5188d6f6f850 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.h +++ b/drivers/net/wireless/ath/ath10k/snoc.h @@ -70,10 +70,10 @@ struct ath10k_snoc { struct ath10k_snoc_ce_irq ce_irqs[CE_COUNT_MAX]; struct ath10k_ce ce; struct timer_list rx_post_retry; - struct regulator_bulk_data *vregs; - size_t num_vregs; + struct regulator *vreg_cx_mx; struct clk_bulk_data *clks; size_t num_clks; + struct pwrseq *pwrseq; struct ath10k_qmi *qmi; unsigned long flags; bool xo_cal_supported;