From patchwork Fri Feb 16 20:31:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 774069 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B892F139595 for ; Fri, 16 Feb 2024 20:33:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115597; cv=none; b=GteaKAIVPUKSuBdBVJTj/EcOivY/XSUHNJChiWwU1sA5cZvqLSX/cZb+ZztrPBvPFC8phUnxCvOYHdXH/oUU54dPitF3Lc+JpG1LU3E2K4Xs+494hBRRPjo9gCi6xmVo6q4K2iVP8+vTQtPZz7/tybQfofNKwSzbjp7J3QUGnkE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115597; c=relaxed/simple; bh=0QV0XOVkgQZCCrRrdg+X1apPFOwyznZIa0nD2VYHxpg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r+NIPPgeidEYILV37T70/oaKXDZleyQuy3H/YFoQ0GKDYKuFu3DAQZfxTdUtBF/aCORh8scZMD1BWK3936QHLY2/w7rndOPb2vYIOAR9DjBkhsLbEK7MKS8/gw3YEwgOFUKKyloNsb4bhWp3rlxi7wCckn1OX19W8HUcYMmHoeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=JvanfooB; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="JvanfooB" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2d0a4e8444dso11595101fa.2 for ; Fri, 16 Feb 2024 12:33:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115592; x=1708720392; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xzau/i70OXFn0nQv+xGSpdZtho+tWjzX+6Y/L0CiXOM=; b=JvanfooBq97Z2sHrKPc3VpFIgrK3j/jFli+kAib5aKwMIanlbpELte4UbuyoKFppIs gnNNEzb8EG5Rd095l7oHT+3g/PZKTMaVbf46FZermOQA/Jmdl2Bwo9Rr0dywTS8lm+h3 +UpB0SaOvcH+gWPHsCZntdeunaiR4eKYBKxtyvCD4T5GU5zPEmO85VyHwbazjpo0p1BI UDYVphdb/Q4JKjwDs/p1480137jM28OZ6Te+HzDNyyDOd+6VCiYSmwFe3SRAI2HgmzNM T7e0rINuN88kEcNUzxrYwBgEasp5p77mMV0Tek2j7T318VT/AKfT0bnxXRAevCYHIOVG jcUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115592; x=1708720392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xzau/i70OXFn0nQv+xGSpdZtho+tWjzX+6Y/L0CiXOM=; b=WS1S2x6Q5TrXQSwVzekd/hHSt+9Xe5Lb5H7yusPhx8O8KIyUkDFxMRrsrvNmXPIqW8 +9TfaFs4XQrbwYUh8FENBkG5dlayztN1zXhhZNILruChapd84rH4PFdld5oyHcTkiuMi 3rlFHqnWcAnEu0w73noYxOKjdNRcGd3jCG0rGakDaTZOk2v4E/RKATcRFSBlOx/espaS YvoBNrKflMDxrvozSQom/YQdoaDJIWY13ATVDEXBeml2m8tzabQ/lu1k4bESYw6X2ZAd TkdoIQ6B5CGC6GbtRnwHVRtSB63fLRXt/FO5tLH1XSs2DPXx6NYCZX48arlLSQmfbr2g AXqw== X-Forwarded-Encrypted: i=1; AJvYcCUHhey7950T0cZ/f6tyFVuL5e0wdl79g2QbD+nl7+D661bVl+fK7YQc0S80XnRVuc6+LgiCJKRK1ynhvQJ+k1hMO98cRdttTS2vnlx/1fo= X-Gm-Message-State: AOJu0YxWKe57xAruQbZTEcZ+MqYXGJix2feOGgIvgmmvBD7ba5YKsQrM z2PWK97oZpJPLnDgvUNd+tsH8PcHFI6PTBp/jiCahnnWOYMSCvQYXj/XdX7TG5k= X-Google-Smtp-Source: AGHT+IHDXA1CmYyMRhXqVjoGiSoJb0Qo9lCMPdos1FiMsILNtLiMwId05Qkpwu2DiA7OHYVJNW3yMg== X-Received: by 2002:a05:651c:b0f:b0:2d0:dfa7:fa1a with SMTP id b15-20020a05651c0b0f00b002d0dfa7fa1amr4944359ljr.0.1708115592326; Fri, 16 Feb 2024 12:33:12 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:11 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Jonathan Cameron , Bartosz Golaszewski Subject: [PATCH v5 01/18] of: Add cleanup.h based auto release via __free(device_node) markings. Date: Fri, 16 Feb 2024 21:31:58 +0100 Message-Id: <20240216203215.40870-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron The recent addition of scope based cleanup support to the kernel provides a convenient tool to reduce the chances of leaking reference counts where of_node_put() should have been called in an error path. This enables struct device_node *child __free(device_node) = NULL; for_each_child_of_node(np, child) { if (test) return test; } with no need for a manual call of of_node_put(). A following patch will reduce the scope of the child variable to the for loop, to avoid an issues with ordering of autocleanup, and make it obvious when this assigned a non NULL value. In this simple example the gains are small but there are some very complex error handling cases buried in these loops that will be greatly simplified by enabling early returns with out the need for this manual of_node_put() call. Note that there are coccinelle checks in scripts/coccinelle/iterators/for_each_child.cocci to detect a failure to call of_node_put(). This new approach does not cause false positives. Longer term we may want to add scripting to check this new approach is done correctly with no double of_node_put() calls being introduced due to the auto cleanup. It may also be useful to script finding places this new approach is useful. Signed-off-by: Jonathan Cameron Signed-off-by: Bartosz Golaszewski --- include/linux/of.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/of.h b/include/linux/of.h index 331e05918f11..8df240214db1 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -13,6 +13,7 @@ */ #include #include +#include #include #include #include @@ -134,6 +135,7 @@ static inline struct device_node *of_node_get(struct device_node *node) } static inline void of_node_put(struct device_node *node) { } #endif /* !CONFIG_OF_DYNAMIC */ +DEFINE_FREE(device_node, struct device_node *, if (_T) of_node_put(_T)) /* Pointer for first entry in chain of all nodes. */ extern struct device_node *of_root; From patchwork Fri Feb 16 20:31:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773679 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0DAD13B290 for ; Fri, 16 Feb 2024 20:33:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115598; cv=none; b=Pft4t0TaTMk6PO64M7J26ApzOL9YZNKrPKJ3BpVnJK7dqaUZLyDSEcl8UqmEbD8yJpnnWRKKuOQJp9SDU2rVVfobZo6QUDnWB9jvu9ZvVUpf+TDBcS0LiRIbUTHyM71+8mCKSSBaWPhaQ5dZZaWAGkJbiJoeCHitoftnT3YNbiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115598; c=relaxed/simple; bh=2ltRDktWv/9W2XdsRxj5VGYiomy6evtqamrK4xBuy4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kIRzdzNyhMVnQF9z9j7RUhgBM1J6C1LmHWPTl37W/GhjpA0nUNw7rfMdeyPwWKhNp6DXCBUNI1jDFgBCqxtu+MrBXDSH47XOXtLPDHp8pLzX1kGmRMyc0Fpz5Mk6NrZetzgMd+L6ay8VPDjmuaz6HTmKTIuCgfqGgxcd/xEAveM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=y6k7gcJp; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="y6k7gcJp" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-411d231ea71so18919655e9.1 for ; Fri, 16 Feb 2024 12:33:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115594; x=1708720394; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ck620ZgSsNsz/9RxF9gWPnIMgXNLaJ0oGJUqb+80gj0=; b=y6k7gcJpn+XZ7AWF0/XvQ4Q96VAarA6gk2frrhD65tMM3JI9chOvKebMHaLmx4VQiy 6SyTWxxIavK/cq/ZWOWDmyNL8aQ7ZpAPOS+QbbNjvv6lwYLullK5EHPYW1rKz2HeEuGE REY6g/xSFDyFDikTpkIhvvvaIdB0KTc1IDerWBG62xuN5qmk0Gw7GuMS30WD1arpBHQ+ JSLKA/Tl4G0zDeSEZkjdyoNdLLpHpJbJYiZI8QvQgWXBs0A/7+pCBR98BsTT077hmART 8mZxoDeB7vnlYJILMdHv6J8oSe44huKkGYx14nIb0jVR6QEyPfLq6FnBSjhLdqnIPFUI e7TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115594; x=1708720394; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ck620ZgSsNsz/9RxF9gWPnIMgXNLaJ0oGJUqb+80gj0=; b=OQpTg6hQzWZMDXnHtVFYwYDvu7jMIMUc6otK3jFtMx/8hPF1tgSNVIa64rzrmXZawe fraPx6jGJAA5QasC7ZySwgLYhHIgOAubo/0+1TScnj/sg601bMA+v6aoUOcWNK8rIbDY y6zp1wFSr5F50S7OUXIcLks5YpuKwBc+dozQ/nJaPmdoB51N7ID36ngct7hlHuZDNa0V DJHmJmqXPac4KLMV4wyT2156smLmtIgcQ3k+1hhGIcJGzGhSj+8DkTB8J6Lbq2Jo+Ax/ B1dXItNzsEb9vNJo7RwBy2poP0uw4Lc+9qxdWgpHPA+sT0SyVJcon5IEW6bjkWGhRUNP UGuA== X-Forwarded-Encrypted: i=1; AJvYcCUiGQ5VYf58HiH9Kt8yaJWmlYhDu2xWvUuiJ57bL0NR5viW/Q/d76SAHrpE8e5yhV8SDqsuOJ/uwVa+sotvxHKFY9chdG8wxfbvyUj6NiU= X-Gm-Message-State: AOJu0YwOd5UmYUh74tx3nJXqUueR8HYfBXIrQyrMYx9Ic64ydYiKfnUl IPVME14523QxZkDXM7tM2eLn8J4NbEYn07jI/G+3dU2nvShaeAv6HUr+KjB3zSo= X-Google-Smtp-Source: AGHT+IFWK3RiERh4OJ6PyhlMX4HmF3lfvM2tBpYy/a0m9DxHn1nwJ9Sx7MIneHFQhvuUZ8wTNDj2GA== X-Received: by 2002:a05:600c:1389:b0:40e:dbdf:9fb4 with SMTP id u9-20020a05600c138900b0040edbdf9fb4mr4364542wmf.23.1708115593893; Fri, 16 Feb 2024 12:33:13 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:13 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 02/18] arm64: defconfig: enable ath12k as a module Date: Fri, 16 Feb 2024 21:31:59 +0100 Message-Id: <20240216203215.40870-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Build the ath12k driver as a module for arm64 default config. Signed-off-by: Bartosz Golaszewski --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index b8adb28185ad..23d6bb156cbc 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -409,6 +409,7 @@ CONFIG_WCN36XX=m CONFIG_ATH11K=m CONFIG_ATH11K_AHB=m CONFIG_ATH11K_PCI=m +CONFIG_ATH12K=m CONFIG_BRCMFMAC=m CONFIG_MWIFIEX=m CONFIG_MWIFIEX_SDIO=m From patchwork Fri Feb 16 20:32:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 774068 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A0062FE28 for ; Fri, 16 Feb 2024 20:33:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115599; cv=none; b=uoxnzK+/oD/hgI/6U/cIKdpnY8BtnHd9EWIILrGrTBLTJScN57L4EJdxrKIxypq8i7RaF+LX+HtMaOO75sVxIvpFIP7IXEDZFymonqDkwrNcJ+JpGvtz+YalwwvDwM2p2VDae73VuUqwgyn0DGF0c0KVqnJaOdR7SSGc+erza4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115599; c=relaxed/simple; bh=7siulsM+YIxL/zjVU9vKxvQTmEA2EKQzsqGyT9XfH/0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ne5+fLlSIZEGd93j8sA1MC0Xtm7O6NcPsrESKRtX2YPrXsfZJQkdi82zFkLLJ/yOtkul6vC1Fk+hlUBjDVhAi1MhZ64gg2Wat2aU80Cz13FpgDq7ZCfEmqlsEvfMzWTT7PRt0S8C7i5yVXhu9qMdDgAhS3zusZBAqEEDMrAhi1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=RopNAYmB; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="RopNAYmB" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-411d715c401so19060145e9.1 for ; Fri, 16 Feb 2024 12:33:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115595; x=1708720395; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=aLo65DzlI0Pw6qQCEKnNFvuFSJmqXUdVDuf68OGs0ug=; b=RopNAYmBLzbU0E8FWuUlqcWP+GlVGJt0id3KbTdr5k9HaYH+UzwCoQfr0p1eAnfS2Y q9/ws62XvkUz89rZck2b2fw5t1uyn2WBFJ0Hf0MSsaobdw3m0k98z5FaG6tknDpRE1wY K10/03ea4vPXLOYm9561Jquaq6kOLSduihRk/P7VN3fTPQ2bRogDP18BW0prc0klPtpq pmfSKOsmTYGK5j5OcMDiHCLtyrqrGp0RWIq+4Z31VISMBcoQGOACQFLvBO9fQ0FkjX3o Av22SeTujKCnxSC2kmjHEWJqUp1JlrSdt0MPnMF/ljI3K+m/uUNTjTefCWM4yYs187Oi r8tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115595; x=1708720395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aLo65DzlI0Pw6qQCEKnNFvuFSJmqXUdVDuf68OGs0ug=; b=JusLhA7I8aMUnnIK5Y6kVSVBa/kaIgwV1Uln5TbO4GD9PqUN4ATqGD1P2IAQSbrzZ7 EpE+svmlQVTG90HM2pFszFKcAjs3ZWJ8iGwbf7mMt+U+SaOMifd9z3EfEMDZYbjpe10Y lkzFCxgTQZdG6zv80EjoXeVeDDA5ygNGQ0QTF7vBMTmTofMobKpoGjlDcP0Of1HVDvby bKkGWuVnD9XCKx563u9D+JWhwpAcZv49rtLbPGkZ3VGExpuVen/vr3lRwTU5Ac0k8PdK 7Baiq8y6ckf9r7SO8NK9HQTtcdqujdpmBoQXz8mKJr1nBMUh3a9t0b1g/iwyM8AXwtI/ fz0g== X-Forwarded-Encrypted: i=1; AJvYcCUDUtftOY8HaklBO1T6EK7kgssh/Y524MnkI5WbydIoyE/oZK7/TCBHFwyesjSjH6bdmSBTIrPVDoL/37+dzgPvDOSfnEBdDS2ptazGbkE= X-Gm-Message-State: AOJu0YwZM4/0f3NfNCdFFa8Lmzd1PTiOI3cjKXITpW6jo0AJaEo3xol/ 7AlCkfNy4jgdJ/tCrhnDiE6Q2VRIBK6lJAeOitvYL7SyeoGoJvTFfBaic5fNt0E= X-Google-Smtp-Source: AGHT+IFiDpD9jnNjXHaYBDe5iqmGRvtMJpVfZZ7zS3b3nDAA5bd5zEp/CAbSuDJNq9KUS4HizlvLyA== X-Received: by 2002:a05:600c:b91:b0:411:e398:9f33 with SMTP id fl17-20020a05600c0b9100b00411e3989f33mr4538745wmb.15.1708115595442; Fri, 16 Feb 2024 12:33:15 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:15 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 03/18] dt-bindings: regulator: describe the PMU module of the QCA6390 package Date: Fri, 16 Feb 2024 21:32:00 +0100 Message-Id: <20240216203215.40870-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski The QCA6390 package contains discreet modules for WLAN and Bluetooth. They are powered by the Power Management Unit (PMU) that takes inputs from the host and provides LDO outputs. This document describes this module. Signed-off-by: Bartosz Golaszewski Reviewed-by: Krzysztof Kozlowski --- .../bindings/regulator/qcom,qca6390-pmu.yaml | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/qcom,qca6390-pmu.yaml diff --git a/Documentation/devicetree/bindings/regulator/qcom,qca6390-pmu.yaml b/Documentation/devicetree/bindings/regulator/qcom,qca6390-pmu.yaml new file mode 100644 index 000000000000..b71fa782fc63 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/qcom,qca6390-pmu.yaml @@ -0,0 +1,166 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/qcom,qca6390-pmu.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Technologies, Inc. QCA6390 PMU Regulators + +maintainers: + - Bartosz Golaszewski + +description: + The QCA6390 package contains discreet modules for WLAN and Bluetooth. They + are powered by the Power Management Unit (PMU) that takes inputs from the + host and provides LDO outputs. This document describes this module. + +properties: + compatible: + const: qcom,qca6390-pmu + + vddaon-supply: + description: VDD_AON supply regulator handle + + vddpmu-supply: + description: VDD_PMU supply regulator handle + + vddrfa0p95-supply: + description: VDD_RFA_0P95 supply regulator handle + + vddrfa1p3-supply: + description: VDD_RFA_1P3 supply regulator handle + + vddrfa1p9-supply: + description: VDD_RFA_1P9 supply regulator handle + + vddpcie1p3-supply: + description: VDD_PCIE_1P3 supply regulator handle + + vddpcie1p9-supply: + description: VDD_PCIE_1P9 supply regulator handle + + vddio-supply: + description: VDD_IO supply regulator handle + + wlan-enable-gpios: + maxItems: 1 + description: + GPIO line enabling the ATH11K WLAN module supplied by the PMU + + bt-enable-gpios: + maxItems: 1 + description: + GPIO line enabling the ATH11K Bluetooth module supplied by the PMU + + regulators: + type: object + description: + LDO outputs of the PMU + + patternProperties: + "^ldo[0-9]$": + $ref: regulator.yaml# + type: object + unevaluatedProperties: false + + additionalProperties: false + +required: + - compatible + - vddaon-supply + - vddpmu-supply + - vddrfa0p95-supply + - vddrfa1p3-supply + - vddrfa1p9-supply + - vddpcie1p3-supply + - vddpcie1p9-supply + - vddio-supply + - wlan-enable-gpios + - bt-enable-gpios + - regulators + +additionalProperties: false + +examples: + - | + #include + pmu { + compatible = "qcom,qca6390-pmu"; + + pinctrl-names = "default"; + pinctrl-0 = <&bt_en_state>, <&wlan_en_state>; + + vddaon-supply = <&vreg_s6a_0p95>; + vddpmu-supply = <&vreg_s2f_0p95>; + vddrfa0p95-supply = <&vreg_s2f_0p95>; + vddrfa1p3-supply = <&vreg_s8c_1p3>; + vddrfa1p9-supply = <&vreg_s5a_1p9>; + vddpcie1p3-supply = <&vreg_s8c_1p3>; + vddpcie1p9-supply = <&vreg_s5a_1p9>; + vddio-supply = <&vreg_s4a_1p8>; + + wlan-enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + bt-enable-gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; + + regulators { + vreg_pmu_rfa_cmn: ldo0 { + regulator-name = "vreg_pmu_rfa_cmn"; + regulator-min-microvolt = <760000>; + regulator-max-microvolt = <840000>; + }; + + vreg_pmu_aon_0p59: ldo1 { + regulator-name = "vreg_pmu_aon_0p59"; + regulator-min-microvolt = <540000>; + regulator-max-microvolt = <840000>; + }; + + vreg_pmu_wlcx_0p8: ldo2 { + regulator-name = "vreg_pmu_wlcx_0p8"; + regulator-min-microvolt = <760000>; + regulator-max-microvolt = <840000>; + }; + + vreg_pmu_wlmx_0p85: ldo3 { + regulator-name = "vreg_pmu_wlmx_0p85"; + regulator-min-microvolt = <810000>; + regulator-max-microvolt = <890000>; + }; + + vreg_pmu_btcmx_0p85: ldo4 { + regulator-name = "vreg_pmu_btcmx_0p85"; + regulator-min-microvolt = <810000>; + regulator-max-microvolt = <890000>; + }; + + vreg_pmu_rfa_0p8: ldo5 { + regulator-name = "vreg_pmu_rfa_0p8"; + regulator-min-microvolt = <760000>; + regulator-max-microvolt = <840000>; + }; + + vreg_pmu_rfa_1p2: ldo6 { + regulator-name = "vreg_pmu_rfa_1p2"; + regulator-min-microvolt = <1187000>; + regulator-max-microvolt = <1313000>; + }; + + vreg_pmu_rfa_1p7: ldo7 { + regulator-name = "vreg_pmu_rfa_1p7"; + regulator-min-microvolt = <1710000>; + regulator-max-microvolt = <1890000>; + }; + + vreg_pmu_pcie_0p9: ldo8 { + regulator-name = "vreg_pmu_pcie_0p9"; + regulator-min-microvolt = <870000>; + regulator-max-microvolt = <970000>; + }; + + vreg_pmu_pcie_1p8: ldo9 { + regulator-name = "vreg_pmu_pcie_1p8"; + regulator-min-microvolt = <1710000>; + regulator-max-microvolt = <1890000>; + }; + }; + }; From patchwork Fri Feb 16 20:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773678 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B2091487DE for ; Fri, 16 Feb 2024 20:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115601; cv=none; b=pZWFE72Amd58RDKkeNg8nmn1ZaLyIBM28cL8nihhSOuVStCppwvJUT7E1vUycyI8jc6EkvLUm29eJK5bN862OSGKARYY3a8m8NX3dORu0Ic5A4ulDWBaO7gQF2y8DDGgzbiwp/rg4F2E7588qR5bUYfEXiSOBEdw5TqTGHn8sBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115601; c=relaxed/simple; bh=4LhLqDvGFT+IFCIuC4QIrfBunrKDwXswnSE7spSs1og=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HGXUbS1aaOMQtbtwHOhKaDLox7Qubw/cEWT9dZIuWrnno+rxBVZ1rPp4fvJRMCf43K7chJKqPJfTrMtijVmTErtvVKCB1Xdba2i0epcgR96xikMOlPC9BXacMvzoyFuyBNpHP6etbxsp7adcAkVugaPELJGKKVxwvAO8nIIwIPU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=pw8lpZRn; arc=none smtp.client-ip=209.85.208.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="pw8lpZRn" Received: by mail-lj1-f182.google.com with SMTP id 38308e7fff4ca-2d180d6bd32so15730381fa.1 for ; Fri, 16 Feb 2024 12:33:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115597; x=1708720397; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CC1pu2stpbN83NTwAu2tyUDsfSSkKlZ+7hcnIJ0S5bk=; b=pw8lpZRn9/vsWZaABII0+DvViHbRjQuPwgLb4i/WqjXSHfa+GQL9WfkQm2XwOqrj0T GgdQaumG3DKydg4bv2YIWQ8DAmwCPQF0Id8uxPCSEMJedRMKpx3RxsIAMQ6tN1ae2qvI D2D0o7vb0bRHjGZSY6USu9vvbc8cKt05nC3L3FfK6STwd8GsqxUbPidtj7TA7VxbNmET EHfo18kb0Si1z/F0xUrdzARIVWWY7FZ9wjAnfB7ibIP7WJc1tZ6h9POam9qgL/6A7YsS TaXO73fSKrUMelRH2EDx7SbMwFinYm4Emmni39o3pSPCUmZsPjSPEPLEJA3dp5BxJU9R xGqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115597; x=1708720397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CC1pu2stpbN83NTwAu2tyUDsfSSkKlZ+7hcnIJ0S5bk=; b=ChQ7mSueKRPvTBdLTpCGaPTu89+5OgZe4jyI/MWFJGZSXQRg+DGkonNSV5DTi3LjWy qTy4ocTbclg4pDHvdV059lGcc+6cDFSAqa1HmCsB4NI0h22WY7LUUiG3NPqr3mjQ1tB7 pUb5FDHxxCiLD8wiHCBlucao5b09YMvlg4yrNsJjv715K6yanuocCjcHYukgxusdwCVj GdrsWjXMl46YzgeMaz8tvWUUerzT1MD0ZeTO5X2pKqpanEYkfiSPwSM0cWIN/KfzC4bS +8jhP5BCXNUS/eRoG4uznB7SaFj11UsdIzjAPm6iqJZDaMp/tbNwxZUMfGTVDoBJwj0N UpRg== X-Forwarded-Encrypted: i=1; AJvYcCVOAxZsfBsTZVgEkhO/fqIAnCuCPw3zBHcrKnFkDY10ZA4eWmvbKkNsUVyGGSMOXCWH6l030Cdd7/19V6I17sbKLjf1A0WoK0ww9vkGytY= X-Gm-Message-State: AOJu0Ywg4laSqjShdaRlLrkFYVg7WxEB+BqOxJ4YL83xxjdUC8pQDGzv yt6fT7ubzeawZhgQy4TlDcdTsdH15aOIJzFPKXZLPKx3r2OBwLMUFJ4MMw47K60= X-Google-Smtp-Source: AGHT+IEodiKrpQa3Lrik26TTHjpOXpZBll1rH3wk3i2Jrykp7F0GsM6rUA/Fp5cYuEYiOGeqkA/RiQ== X-Received: by 2002:a2e:9b8d:0:b0:2d0:85dc:bf9b with SMTP id z13-20020a2e9b8d000000b002d085dcbf9bmr4383652lji.14.1708115597122; Fri, 16 Feb 2024 12:33:17 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:16 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 04/18] dt-bindings: net: bluetooth: qualcomm: describe regulators for QCA6390 Date: Fri, 16 Feb 2024 21:32:01 +0100 Message-Id: <20240216203215.40870-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski QCA6390 has a compatible listed in the bindings but is missing the regulators description. Add the missing supply property and list the required ones in the allOf section. Signed-off-by: Bartosz Golaszewski Reviewed-by: Krzysztof Kozlowski --- .../net/bluetooth/qualcomm-bluetooth.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml b/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml index eba2f3026ab0..702d04cdb247 100644 --- a/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml +++ b/Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml @@ -62,6 +62,9 @@ properties: vdddig-supply: description: VDD_DIG supply regulator handle + vddbtcmx-supply: + description: VDD_BT_CMX supply regulator handle + vddbtcxmx-supply: description: VDD_BT_CXMX supply regulator handle @@ -180,6 +183,20 @@ allOf: - vddrfa0p8-supply - vddrfa1p2-supply - vddrfa1p9-supply + - if: + properties: + compatible: + contains: + enum: + - qcom,qca6390-bt + then: + required: + - vddrfacmn-supply + - vddaon-supply + - vddbtcmx-supply + - vddrfa0p8-supply + - vddrfa1p2-supply + - vddrfa1p7-supply examples: - | From patchwork Fri Feb 16 20:32:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 774067 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D0DD1487FF for ; Fri, 16 Feb 2024 20:33:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115603; cv=none; b=qF3lBdXdXBBjkqT7KK8dLJfm0Cugtck/DDQH67VRs76+e2lr9/+lXn/MxvW6xbVmZj5/aI7TCDAFnx4Xya2e8h2z7BCeY27cEJbLCmsg8A4aDXkcyjeLxk/AYTHxkkmFLLNijZb8eldOXIeM0l0IKdTMFieEX8ciRwbdJgPwjag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115603; c=relaxed/simple; bh=O7nx4GuaEFpnnuUD6ygAdgpAn4wNrIX0dYYGgklGofM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X98B/ozfW945TCpl94G/hRcu2IWs7jZBqSjwwg9cDTvBia6/zpu8raQviz5+2VEtUr9PLXhUDAsdhYqIxHNV/WGoG8IVfpp8QtjeU/7nCWtLR8YpcJzrxedLIFSdaPWHXCu39oeAVev/h/u/7WMgxVkP2kCZq3gWGJSTUGAAuiU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=vNSW99UH; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="vNSW99UH" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2d09cf00214so15778781fa.0 for ; Fri, 16 Feb 2024 12:33:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115598; x=1708720398; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uCxfUMaCEPLwwU/U5b6rWEOq2v1UOckbc/XqxqCn7/I=; b=vNSW99UHa1jexGB4uT35qe82IbU6ZjYwLgsG1TXnp0o9F6kUwIyOKAD2/+KlHR3Dzn Y2OeP4kXe/GSSKo3Dm1QWh3dwp8XUT1QdMrr12oYcAKtxNnqdh0vcptxu8ow6VD0IVAH x8xEStW2omL4NUBn1jA8/GA/Etj7RlY+xD2aRrFZQl+0LZjByzYRt1xoT63x+T+LbaBk AjCaRbncHsR3V3gwLY98GYBzxnKAdC6P3RgGKifTBdqOaL0Pemu4tQUu42K5F3n9875/ P6zFgQ0iggZlgwRcEZ2OtIbBYRkkzoL4V0VdP0AEqsURX4x7cP2ddeGgwfFENnVZA96F r/dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115598; x=1708720398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uCxfUMaCEPLwwU/U5b6rWEOq2v1UOckbc/XqxqCn7/I=; b=usf/JiFcUhFR1YPf+jbAo8VpbC7i4uzJ4SrQn4lxZTwGl/1KkifIwzA972t6nIplwX Rt+l4suhFdx4thy/cCCRSdp4pBgkhqhMAhoHBg2K9XzUrZpxwcr+VV7b3FfP0UanTdsh NaR9A/OKkry7j9jv1PaGFTaOEizFzPbsPrIOj3l7VHNB+ZVf6UeePdxu+iOsK0h+5Gwj I4WkkXQ5pPPFUfjcfHb3gkzwGwvJlnUUEbVuDlUrdVEy0w6LiW8cu5RV1GtvzbL7Mm0j WjAE+BboZIZ5BfCDGi1QAuLiBZkeuMxpRkWxLmJrhKri3RIe7Tbb9ELll93flZe7SlNU H1kw== X-Forwarded-Encrypted: i=1; AJvYcCWk8pMT8Sjk0jUBi3W733xl9PArQctsdzmWqM4zG31vJZePUoWtdeqC0gzO/wIwxmIcJ1R3dQm70Qqeop6G/C9j+UZi9m7y6l78hP0/S7Y= X-Gm-Message-State: AOJu0YxuhuAfUQlw9IrKAyXDWAbkZPWUi9Pu5Q90opsNr/XH0S3DNNJ+ mO69vGxkJV9Pnfaj0La5M+NIw0urpM14UoZP8X1BVFcnWAVwD52Brj+AAe1a7Dg= X-Google-Smtp-Source: AGHT+IFAXOhWT1XmRLdjz3VCAvr/YH6TnW+qrkPk0m7YA7Kc63/Ou1aaEWcCkYoTCQIrVMOwhQ0h5w== X-Received: by 2002:a2e:8812:0:b0:2d0:99b7:e68c with SMTP id x18-20020a2e8812000000b002d099b7e68cmr3478497ljh.15.1708115598736; Fri, 16 Feb 2024 12:33:18 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:18 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 05/18] dt-bindings: new: wireless: qcom,ath11k: describe the ath11k on QCA6390 Date: Fri, 16 Feb 2024 21:32:02 +0100 Message-Id: <20240216203215.40870-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Add a PCI compatible for the ATH11K module on QCA6390 and describe the power inputs from the PMU that it consumes. Signed-off-by: Bartosz Golaszewski --- .../net/wireless/qcom,ath11k-pci.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Documentation/devicetree/bindings/net/wireless/qcom,ath11k-pci.yaml b/Documentation/devicetree/bindings/net/wireless/qcom,ath11k-pci.yaml index 817f02a8b481..8530f01df6d9 100644 --- a/Documentation/devicetree/bindings/net/wireless/qcom,ath11k-pci.yaml +++ b/Documentation/devicetree/bindings/net/wireless/qcom,ath11k-pci.yaml @@ -16,6 +16,7 @@ description: | properties: compatible: enum: + - pci17cb,1101 # QCA6390 - pci17cb,1103 # WCN6855 reg: @@ -27,6 +28,33 @@ properties: string to uniquely identify variant of the calibration data for designs with colliding bus and device ids + vddrfacmn-supply: + description: VDD_RFA_CMN supply regulator handle + + vddaon-supply: + description: VDD_AON supply regulator handle + + vddwlcx-supply: + description: VDD_WL_CX supply regulator handle + + vddwlmx-supply: + description: VDD_WL_MX supply regulator handle + + vddrfa0p8-supply: + description: VDD_RFA_0P8 supply regulator handle + + vddrfa1p2-supply: + description: VDD_RFA_1P2 supply regulator handle + + vddrfa1p7-supply: + description: VDD_RFA_1P7 supply regulator handle + + vddpcie0p9-supply: + description: VDD_PCIE_0P9 supply regulator handle + + vddpcie1p8-supply: + description: VDD_PCIE_1P8 supply regulator handle + required: - compatible - reg From patchwork Fri Feb 16 20:32:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773677 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9486F14A0AA for ; Fri, 16 Feb 2024 20:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115605; cv=none; b=tiTF+hGOKUTWXasiK46tUTl+JYUlREZmt8anr2ylyDsXXeU9GmbDVvCWFa0FFP7/p4CTVUNIxiK13mhb+6b4guKzeQNfrnDXbgmZCZaRt26rlJj2UFjeQs3E2P+LEXrvdbwr18+1ttv/rWFEuhwq5/nGKlxEJHDI8sYeNzQ8OGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115605; c=relaxed/simple; bh=QomsFZdvlO3Um/w6n0gLWUpVxNmjbstnoc/fUGr+uLY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XSGVOV8+MaxIcv9P8V6us0SiCirp0mH2GlAf/2RZOHDQ5xgT8N+nwEigFjMyqYUjufbzsAMqB/eR7/0ynhkMHvRGxCopJw0nz+4rep71dOIBAbmct972y/EmxqBmz3mYZIwpGFxBqVdzVQaqtCjzHOFTe8H5Og4jKvdy8zGN9Y8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=2kjTrD8s; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="2kjTrD8s" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d1094b5568so32825371fa.1 for ; Fri, 16 Feb 2024 12:33:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115600; x=1708720400; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hlPormlXa3l6k1Z+tnXCNjE2JFWbtT+cHvZXGY4tddg=; b=2kjTrD8sjG2dDsxTsb3CWRBw95iVtIqVD1oc12pXtMOO5LaZrocehbGPiH0vSi/jnh T5FpeFfgrhbYI4U5mJEArAoAc/0PBWDGKkyaJEq69Nf9thhkqyODPuk8fyxQGD9ujkQr c92570KgKYO8gnoECMRioEUHsnI6B+odhAM+MVxsMIXa4bcvNtPvtWFp87nYuhgmux9Y tQdfMynZNwtKl9LlbVcVQflgvIIx2YLGzKQMr/mbHQ93XfCMxUhFIG2o1FHdNoT87Agz +tIX27TpPmzAC67Vhkg04NtjAR0w5ZuPNVesO1KeD+iz4gT+aP+FtGGz7zm86pHgKYk5 H4Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115600; x=1708720400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hlPormlXa3l6k1Z+tnXCNjE2JFWbtT+cHvZXGY4tddg=; b=I4WU7B0F3OvZd10pHMkWiQ/7wqzSl97iHNxR+y1TnCYK0Sa0TD0p/pkNEumYLoFNlh VFAEES4hfQE8bJ7iQiQHP5w2sz2JaLveZ5kZvqSEJ6KwNLM9AfuTqqsmElWIPT36DTic RBBTUKEQMD2/L+ZznLX/4u+7T5FQ+Jrfn8NQy6TV74HXGEDXpDfq9cHv6wmBXaXY2cML Dg+Fakc3KEpFe7BeXxOXqWYAWS1CL/BiT0kMRrsPmxTaiLL6NIOd3nrzecXf8LTFlOEV Tbh18aozMWyyWCBjTt+3wfhX8dcXbuRXxO+BNMekqCO/gufGhSSj5qwEu40ESetqpDW8 Hejg== X-Forwarded-Encrypted: i=1; AJvYcCWQym3ExhrNiCnvU6R8pKN1u+h9yt0Zwquy530cBua8f9q5xw1cAUpaMIrLg74dr4rqjJ3ExpTk2gIk9T5ZNDDEDbCnH6EkOl2CqNnDyLA= X-Gm-Message-State: AOJu0YxyqUseGKnC6T1ctwzxTdFAMbPtHU3DKoPUvN/KRmRb+8gjmJ7u QYnJsAQJLmkKjQZT6YW2LzGgeAl8RVCJxQe4jXHL6uQ8LnOIsdfcTeZT/pU7GqQ= X-Google-Smtp-Source: AGHT+IEkFURpgepPlDG+ueLwKqqzySZpTpb0gzgEBbEk7oxfGbiVn1m6Ly2ffglkki0hcfkMVZUFhg== X-Received: by 2002:a2e:80da:0:b0:2d0:9fb2:2c79 with SMTP id r26-20020a2e80da000000b002d09fb22c79mr4506727ljg.3.1708115600369; Fri, 16 Feb 2024 12:33:20 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:19 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 06/18] dt-bindings: new: wireless: describe the ath12k PCI module Date: Fri, 16 Feb 2024 21:32:03 +0100 Message-Id: <20240216203215.40870-7-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Add device-tree bindings for the ATH12K module found in the WCN7850 package. Signed-off-by: Bartosz Golaszewski --- .../net/wireless/qcom,ath12k-pci.yaml | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/wireless/qcom,ath12k-pci.yaml diff --git a/Documentation/devicetree/bindings/net/wireless/qcom,ath12k-pci.yaml b/Documentation/devicetree/bindings/net/wireless/qcom,ath12k-pci.yaml new file mode 100644 index 000000000000..063c576b99a0 --- /dev/null +++ b/Documentation/devicetree/bindings/net/wireless/qcom,ath12k-pci.yaml @@ -0,0 +1,103 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (c) 2024 Linaro Limited +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/wireless/qcom,ath12k-pci.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Technologies ath12k wireless devices (PCIe) + +maintainers: + - Bartosz Golaszewski + +description: | + Qualcomm Technologies IEEE 802.11ax PCIe devices + +properties: + compatible: + enum: + - pci17cb,1107 # WCN7850 + + reg: + maxItems: 1 + + enable-gpios: + maxItems: 1 + description: GPIO line enabling the WLAN module + + vdd-supply: + description: VDD supply regulator handle + + vddio-supply: + description: VDD_IO supply regulator handle + + vddio1p2-supply: + description: VDD_IO_1P2 supply regulator handle + + vddaon-supply: + description: VDD_AON supply regulator handle + + vdddig-supply: + description: VDD_DIG supply regulator handle + + vddrfa1p2-supply: + description: VDD_RFA_1P2 supply regulator handle + + vddrfa1p8-supply: + description: VDD_PCIE_1P8 supply regulator handle + + clocks: + maxItems: 1 + description: + Reference clock phandle + +required: + - compatible + - reg + - vdd-supply + - vddio-supply + - vddaon-supply + - vdddig-supply + - vddrfa1p2-supply + - vddrfa1p8-supply + +additionalProperties: false + +examples: + - | + #include + #include + pcie { + #address-cells = <3>; + #size-cells = <2>; + + pcie@0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + bus-range = <0x01 0xff>; + + wifi@0 { + compatible = "pci17cb,1107"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + + pinctrl-names = "default"; + pinctrl-0 = <&wlan_en>; + + enable-gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>; + + vdd-supply = <&vreg_s4i_0p85>; + vddio-supply = <&vreg_l15b_1p8>; + vddio1p2-supply = <&vreg_l3c_1p2>; + vddaon-supply = <&vreg_s2c_0p8>; + vdddig-supply = <&vreg_s3c_0p9>; + vddrfa1p2-supply = <&vreg_s1c_1p2>; + vddrfa1p8-supply = <&vreg_s6c_1p8>; + + clocks = <&rpmhcc RPMH_RF_CLK1>; + }; + }; + }; From patchwork Fri Feb 16 20:32:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 774066 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B340A14A4EA for ; Fri, 16 Feb 2024 20:33:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115606; cv=none; b=qbjpjAQm/KaPddGImie+IGQfwDKBpwI9Narc2KYxIlHTad7er9NsbMdjkdFBxKb/7DGLTzmCT4N5pHkTGkVAa0ZhVwqS9rk2SfdjtTlDL6iZiTQXBdcIyDXOuPUfY3XcCMcr89qtg1mpZdj+rdKVumyHkhrNWp4mJQuGA7Tnzv8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115606; c=relaxed/simple; bh=DA4ectayxTx+RjdRwpkpKa9bLFLkHFkmFO+48GVSSpY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PuSquvuQrzhgjOa5fGZDGetrNFtPNayMv+N+1WNa+wIg7Kg7ebI1hUIkxYYhJEgdkIdWA2OKYrQKpxsKHqEsCzFzVdqZ2pKr02U+h2GgY0LLe7vTvayU70AuCTwQTdz3v9XgBeExkdIfLch7wRSa+GU6wYWlZX84Vo6ZzZCKnoY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=fJO3t5mH; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="fJO3t5mH" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d0b4ea773eso31127301fa.0 for ; Fri, 16 Feb 2024 12:33:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115602; x=1708720402; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cxxyf5WK5kLEb1ft4RDq8oKAwu3D1i1cTrok0abawwQ=; b=fJO3t5mHa7DdULYXt+lZvU/2eM2lEOmcbu9X2uy/UNm2wscLaBe2+8dl/E2JD83s9x b3QwdhvoZySAPaAdlwQ/du/1yx7sIPZ+XWUsrTDQhTJOlPKG4X70lddeacXpxCObFckn yiEXTNai8/6k/WNFQPbeyYkZUyZU0PUOIZswYBPAGIXWqOXB7JEdL5o6hYdTiP1OMd0y VUw333fYKirnwWYGN+XAAGHeTW+49TIzlP7ZMvpLePhBKy+ttyAP6e55zGc6ykDbGplf uTLRicLz5Tl6Spd9MUyyuuGT4MMq43vNJ3EjYC6OtTcI8JWcUPi21e6guJcKamYDTrMj NzaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115602; x=1708720402; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cxxyf5WK5kLEb1ft4RDq8oKAwu3D1i1cTrok0abawwQ=; b=B0IhxmLXAmqGHkjRom6ipK74bsa6/AuBROElaUPxk6eJ7zhErOZ6UvhIaxovqyd52y f+0140m6MrQegO03oADzYTZlo00ihu2XuwOS0pnAMdBRwHBreqBrJHXNc6h8N4M3Ep4n 4Y+gvsZvhdLw+bRgN6IqqcfDNKwkwrXAsuTEHQNINmhQ5t15CcdRZ80C8VFOxsPuNxzD aml7rIgsjbj9qENm+STGZc5GE4aSBUNoTVdTsDRXptuOkoe5NY2Iyrn1nRy3Ldr2nfuB QYBhah5IoQp3XVdTrcOISjk78khCrH+jYZgpgQ382YQi5QfAIYo4H7wCoyTpPRr08hqu MGuw== X-Forwarded-Encrypted: i=1; AJvYcCUrNzv+vEDDxfpHK24pC71JnlLZJ8sCghZbVd+8NZSXxF4fGO5FVcwlJZ0Aau8vkVZagQhc4SektpIldrRdwfS1bIUde8LNuTYls0hoywU= X-Gm-Message-State: AOJu0Ywu2Y7sL8d/hz2mDkrDu6AFPShQ4p+PMSwA3ae5xqcPwL3Euv6L FpomjgXPwXJysWh4BEYcpWdR9lz9DlnhfGuwlDLF+J4pmJrE4Zxp/vx30NtPlAg= X-Google-Smtp-Source: AGHT+IE/2ahKMsZvabc/gm6bCNhd1e6PO1jafL5NM+NOIbNtqIA1pLBKR3l3Gurnhpr74OlhOP7RBQ== X-Received: by 2002:a05:651c:21b:b0:2d0:bf87:b3a6 with SMTP id y27-20020a05651c021b00b002d0bf87b3a6mr4518706ljn.37.1708115602002; Fri, 16 Feb 2024 12:33:22 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:21 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 07/18] arm64: dts: qcom: sm8550-qrd: add the Wifi node Date: Fri, 16 Feb 2024 21:32:04 +0100 Message-Id: <20240216203215.40870-8-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Neil Armstrong Describe the ath12k WLAN on-board the WCN7850 module present on the board. Signed-off-by: Neil Armstrong [Bartosz: - move the pcieport0 node into the .dtsi - make regulator naming consistent with existing DT code - add commit message] Signed-off-by: Bartosz Golaszewski --- arch/arm64/boot/dts/qcom/sm8550-qrd.dts | 37 +++++++++++++++++++++++++ arch/arm64/boot/dts/qcom/sm8550.dtsi | 10 +++++++ 2 files changed, 47 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sm8550-qrd.dts b/arch/arm64/boot/dts/qcom/sm8550-qrd.dts index 92f015017418..67bd11e82abd 100644 --- a/arch/arm64/boot/dts/qcom/sm8550-qrd.dts +++ b/arch/arm64/boot/dts/qcom/sm8550-qrd.dts @@ -824,6 +824,25 @@ &pcie0 { status = "okay"; }; +&pcieport0 { + wifi@0 { + compatible = "pci17cb,1107"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + + pinctrl-names = "default"; + pinctrl-0 = <&wlan_en>, <&pmk8550_sleep_clk>; + + enable-gpios = <&tlmm 80 GPIO_ACTIVE_HIGH>; + + vdd-supply = <&vreg_s5g_0p85>; + vddio-supply = <&vreg_l15b_1p8>; + vddaon-supply = <&vreg_s2g_0p85>; + vdddig-supply = <&vreg_s4e_0p95>; + vddrfa1p2-supply = <&vreg_s4g_1p25>; + vddrfa1p8-supply = <&vreg_s6g_1p86>; + }; +}; + &pcie0_phy { vdda-phy-supply = <&vreg_l1e_0p88>; vdda-pll-supply = <&vreg_l3e_1p2>; @@ -911,6 +930,17 @@ &pcie_1_phy_aux_clk { clock-frequency = <1000>; }; +&pmk8550_gpios { + pmk8550_sleep_clk: sleep-clk-state { + pins = "gpio3"; + function = "func1"; + input-disable; + output-enable; + bias-disable; + power-source = <0>; + }; +}; + &qupv3_id_0 { status = "okay"; }; @@ -1084,6 +1114,13 @@ wcd_default: wcd-reset-n-active-state { bias-disable; output-low; }; + + wlan_en: wlan-en-state { + pins = "gpio80"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; }; &uart7 { diff --git a/arch/arm64/boot/dts/qcom/sm8550.dtsi b/arch/arm64/boot/dts/qcom/sm8550.dtsi index 9a545087d70e..5fcf8d5ac084 100644 --- a/arch/arm64/boot/dts/qcom/sm8550.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8550.dtsi @@ -1767,6 +1767,16 @@ pcie0: pcie@1c00000 { phy-names = "pciephy"; status = "disabled"; + + pcieport0: pcie@0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + bus-range = <0x01 0xff>; + }; }; pcie0_phy: phy@1c06000 { From patchwork Fri Feb 16 20:32:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773676 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB77E14C59B for ; Fri, 16 Feb 2024 20:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115608; cv=none; b=GLf2ZgjpMcpO/PhxhnmpnNua2UFJz8GxFSNBvN0bukkw9uctn2eyPalsZezZEX7N12h2RdQjb2O0pevdsQB1yZ12+GKNi6pDSZK+h4pd1n2rtRvmP8s9JPxK+RDbVoeBlOJgAlWQRxJqqfcv+y4NheY/U+63zQUbYnWa9GB6qOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115608; c=relaxed/simple; bh=wwd3Xij+rOHq/CWdFCeH+2K4nGFWVnX35W8A6dmUUSw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dVN6KRW4bcfnZQdaog1kL99bGOIE0zD266cjv+JJurPJJ4nWUSSFFo4CmS/ayVm7z+99quyj7qmMbP9sD1uICrmASuSA0yKGrghdtpcg+sCfutLEB4w6iMdMcUkFnaz9rHodt5Igb2E6DFe77alG6HDIFjlty6NQ4RpPA56tfQE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=xzHP3Y9o; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="xzHP3Y9o" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-411e5f21c0bso20061575e9.0 for ; Fri, 16 Feb 2024 12:33:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115603; x=1708720403; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xi8a7IDbsc7NWjITXvW8vzVKHWVwk2jKqzcZASrP8yE=; b=xzHP3Y9ofocgeq5RhsS9vy5SmKIlXOnikKLURkiBqIDkswYtPU+ZOHO+xqTxrumgZI iSxWmFouzFCfQggfrm5uJyd7JkaAiKoVQaJOv6GsNZGM8ejhlCzZ/NCUinLbKoD9pDYb jZm8ggLrbYfCHQbsXkI1VB3m24xFFYfyZXsoJYFIEiK+XqZqNQoTe34/94WGnOdMN8M2 WazihsqiNR8+jHmA2xrhF/b7dNI8IDamGTm2o8OQ8uIIzE0hSmduvffcLd7m+9ZWswxh BHwMqulHu4zPvc8+vi+/8xTrktuKontRPqDR7w8icl12DtdJWM/1qA3Gz+4PIDjFvrkY S3IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115603; x=1708720403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xi8a7IDbsc7NWjITXvW8vzVKHWVwk2jKqzcZASrP8yE=; b=Pz+3qnMxeoNwcIjnVH8h3kmF4RQgSlqo5hxxVoueaEFqan7nugCqp/EsO2sAJQElC+ 6CZ0KLvg09t8vIx1j4JHIS/44pltkZCjs3keyxOoWnJaslUmKHIkugAJi2Ua15/ftxm7 sva4750DTEZJRPUOSmFMKBBNPR2gI9Wn4zYY4YtUXIql602Awk9pCxq6OUAi+qPyOF0y 7WfpJQGCG6kJTJAtTxWRt/gKFFytAZtTedvv2FG+gsjGBJMOs9usyKWeBS/aFlDlGau1 2D4HgKatsja/s+0jw1Qls/xnsityY/ULoWfXCmT6yvj4BrPcq0NO9rQIuUTzq+Bep40M k6Gg== X-Forwarded-Encrypted: i=1; AJvYcCVus67nSfUI9JITPQFaLPFxKiagLNW9UUxBDgSF3N+ZcGkLtIck0z6eiAfkbs6EGcvRjUIB6BquyrveyczOkPdIFH6U3lciP/sN3FoZ0tg= X-Gm-Message-State: AOJu0YzQNdNI6x2F9pN2KosB2sbVFX+MtXZQqrTiIvt1ihOui8PBtthd 1FEZE2VzdHEhjS9YM5bdlGNCYO3Jm8kJqmlDkOWFxKBeNI83aCOIB/97ikIm1Jk= X-Google-Smtp-Source: AGHT+IEdNFiS4jqjTMwr9bbhFoBmmcjEmHiM7ik8UO5vPc2X24r/EQeJTolFoj1NizIPC6YHWTEuWQ== X-Received: by 2002:a05:600c:4f0d:b0:410:7428:1fb5 with SMTP id l13-20020a05600c4f0d00b0041074281fb5mr4348569wmq.27.1708115603697; Fri, 16 Feb 2024 12:33:23 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:23 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 08/18] arm64: dts: qcom: sm8650-qrd: add the Wifi node Date: Fri, 16 Feb 2024 21:32:05 +0100 Message-Id: <20240216203215.40870-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Neil Armstrong Describe the ath12k WLAN on-board the WCN7850 module present on the board. Signed-off-by: Neil Armstrong [Bartosz: - move the pcieport0 node into the .dtsi - make regulator naming consistent with existing DT code - add commit message] Signed-off-by: Bartosz Golaszewski --- arch/arm64/boot/dts/qcom/sm8650-qrd.dts | 29 +++++++++++++++++++++++++ arch/arm64/boot/dts/qcom/sm8650.dtsi | 10 +++++++++ 2 files changed, 39 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sm8650-qrd.dts b/arch/arm64/boot/dts/qcom/sm8650-qrd.dts index b07cac2e5bc8..4623c358f634 100644 --- a/arch/arm64/boot/dts/qcom/sm8650-qrd.dts +++ b/arch/arm64/boot/dts/qcom/sm8650-qrd.dts @@ -845,6 +845,28 @@ &pcie0 { status = "okay"; }; +&pcieport0 { + wifi@0 { + compatible = "pci17cb,1107"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + + pinctrl-names = "default"; + pinctrl-0 = <&wlan_en>; + + enable-gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>; + + vdd-supply = <&vreg_s4i_0p85>; + vddio-supply = <&vreg_l15b_1p8>; + vddio1p2-supply = <&vreg_l3c_1p2>; + vddaon-supply = <&vreg_s2c_0p8>; + vdddig-supply = <&vreg_s3c_0p9>; + vddrfa1p2-supply = <&vreg_s1c_1p2>; + vddrfa1p8-supply = <&vreg_s6c_1p8>; + + clocks = <&rpmhcc RPMH_RF_CLK1>; + }; +}; + &pcie0_phy { vdda-phy-supply = <&vreg_l1i_0p88>; vdda-pll-supply = <&vreg_l3i_1p2>; @@ -1139,6 +1161,13 @@ wcd_default: wcd-reset-n-active-state { bias-disable; output-low; }; + + wlan_en: wlan-en-state { + pins = "gpio16"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; }; &uart14 { diff --git a/arch/arm64/boot/dts/qcom/sm8650.dtsi b/arch/arm64/boot/dts/qcom/sm8650.dtsi index d488b3b3265e..baf4932e460c 100644 --- a/arch/arm64/boot/dts/qcom/sm8650.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8650.dtsi @@ -2293,6 +2293,16 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, dma-coherent; status = "disabled"; + + pcieport0: pcie@0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + bus-range = <0x01 0xff>; + }; }; pcie0_phy: phy@1c06000 { From patchwork Fri Feb 16 20:32:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 774065 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 776B114D456 for ; Fri, 16 Feb 2024 20:33:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115609; cv=none; b=r2ICo7oFLE1taYVjCTHjORWrAyLtxQ5OnCzXAXI4dF6hS5YV3KrdVToWT4/A/ruNB+tvrO7+/lqOHtFp2dOTUyLPz2Fbhk9TsxIZUFc2EZf77LRjkywRFi6yb4w3jwDU+7JfkNtRNKuWf7cXqgrhhFTjCDm8st7k6TPd5xMtF6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115609; c=relaxed/simple; bh=KPOrp8LPSUDq6IOAE4mPfTWcsTyUCeGoXHAEp71vpf4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ikPnS7zfedWAD+BSusZiAz2rCqu0wz84EhSJG0qXxJdNlgcZbiDDNSe77Q+x/+0X91PXEOpNqK/pgFCigHaPN/mWVLF5cjmbGGSpk0jTqisAAueMsYq9WujQTtNs4ofU2IeAmPuCdGkw2I3eLPJdpiW5gRt4paD0VUnpCn6Xv50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=zm7jveLW; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="zm7jveLW" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-412393ea2a0so7618705e9.2 for ; Fri, 16 Feb 2024 12:33:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115605; x=1708720405; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x5nC77QhQSBlcsUVXNEDIX3kn3g283v1vwONwQpCCWg=; b=zm7jveLWaQvt/lezHPz9PHmJh5+DMATnqk0WVN1qgs1gnmJHT7RpMHu7ihyk03pAhl uetvcNgK4PPo+DqlByOtyI2BN+XOkIRQo1/ltNgwujScmPPGMt1bq24qW7sTRPVWAaFT 8zHFxWnE+IAkBWVYAOhHFcQiFdz6EdLb3Q0AKHIHityc9RPpgcKA7818vaZkilnzXaFU 99nGoXX8iASr5LntfJBqgkxSdC+FSCLYJgwyts9IT3zB4utDjELdqFn7+R+n6FMCsX25 Zeh6J/IaaS6s2Tb0RUcyNcruAoiJS7syqrPrdRhd9J1e+X7O8p4LlTeERUtKxnL+pHPD s9lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115605; x=1708720405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x5nC77QhQSBlcsUVXNEDIX3kn3g283v1vwONwQpCCWg=; b=n7Kp+uHI3hdUQkzgm6zNVgERoBXhPhRr9KMkEMGheYsRU5IJ4PiUyJ7YaCw6f1Tagu Gb2fe/V398TI2FFbbY/n5w5sex8Lv7xYhITHdd2eYeKdUkZI+FbBpJ1LaPGF61FpC0p6 nFCgYQDkmh2uxNZ5QqPg4HMDTokTao2deEZUqG4wZ6+Vt07c8mgR2krpsd+klLffPxVF jz37mdpMFIyG+LA53N+Up6NJy3FQRmHdh+54tzRl+YAAx1F1OzhrmlxNq98EVrU/ESEc oUSpWPoKF8rF680bcHIREgYKukSSssPPB589hRCpeKef+kgheC1JCuoH7qZh0Z5lfZ9Q aVsA== X-Forwarded-Encrypted: i=1; AJvYcCVReG6fdnzv5RCbRHGs8Kehz7IjrMKiiZ7FJm7gmH/91SYRNF4UrrfDFzF70KRjFanQKkcBNjmgdA/lFuQXSD6HyD1BRnZOwoUQm4HpCZU= X-Gm-Message-State: AOJu0YwHaYWFyO/HK3WibhnO6Zyw2Bw7P6Fs0r9ruZS2ZnryDg30e0Wh FMkVebBhzT3g6gLers4gv0dJy4sAvzywp7Zvm1sRtDQQA6Ly61fct7HCjPt58qM= X-Google-Smtp-Source: AGHT+IEkPmEwWu14kQGv5R1Lwesa1KAhBlsFwwGo+rcDfqAPB+2TTrwOswrMYt6s8NA+Tefu42gDRQ== X-Received: by 2002:a05:600c:3594:b0:412:62:86f8 with SMTP id p20-20020a05600c359400b00412006286f8mr4602389wmq.4.1708115605434; Fri, 16 Feb 2024 12:33:25 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:25 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 09/18] arm64: dts: qcom: qrb5165-rb5: model the PMU of the QCA6391 Date: Fri, 16 Feb 2024 21:32:06 +0100 Message-Id: <20240216203215.40870-10-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Add a node for the PMU module of the QCA6391 present on the RB5 board. Assign its LDO power outputs to the existing Bluetooth module. Add a node for the PCIe port to sm8250.dtsi and define the WLAN node on it in the board's .dts and also make it consume the power outputs of the PMU. Signed-off-by: Bartosz Golaszewski --- arch/arm64/boot/dts/qcom/qrb5165-rb5.dts | 123 +++++++++++++++++++++-- arch/arm64/boot/dts/qcom/sm8250.dtsi | 10 ++ 2 files changed, 122 insertions(+), 11 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/qrb5165-rb5.dts b/arch/arm64/boot/dts/qcom/qrb5165-rb5.dts index cd0db4f31d4a..3331a3e5aaa8 100644 --- a/arch/arm64/boot/dts/qcom/qrb5165-rb5.dts +++ b/arch/arm64/boot/dts/qcom/qrb5165-rb5.dts @@ -108,6 +108,87 @@ lt9611_3v3: lt9611-3v3 { regulator-always-on; }; + qca6390-pmu { + compatible = "qcom,qca6390-pmu"; + + pinctrl-names = "default"; + pinctrl-0 = <&bt_en_state>, <&wlan_en_state>; + + vddaon-supply = <&vreg_s6a_0p95>; + vddpmu-supply = <&vreg_s2f_0p95>; + vddrfa0p95-supply = <&vreg_s2f_0p95>; + vddrfa1p3-supply = <&vreg_s8c_1p3>; + vddrfa1p9-supply = <&vreg_s5a_1p9>; + vddpcie1p3-supply = <&vreg_s8c_1p3>; + vddpcie1p9-supply = <&vreg_s5a_1p9>; + vddio-supply = <&vreg_s4a_1p8>; + + wlan-enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>; + bt-enable-gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; + + regulators { + vreg_pmu_rfa_cmn: ldo0 { + regulator-name = "vreg_pmu_rfa_cmn"; + regulator-min-microvolt = <760000>; + regulator-max-microvolt = <840000>; + }; + + vreg_pmu_aon_0p59: ldo1 { + regulator-name = "vreg_pmu_aon_0p59"; + regulator-min-microvolt = <540000>; + regulator-max-microvolt = <840000>; + }; + + vreg_pmu_wlcx_0p8: ldo2 { + regulator-name = "vreg_pmu_wlcx_0p8"; + regulator-min-microvolt = <760000>; + regulator-max-microvolt = <840000>; + }; + + vreg_pmu_wlmx_0p85: ldo3 { + regulator-name = "vreg_pmu_wlmx_0p85"; + regulator-min-microvolt = <810000>; + regulator-max-microvolt = <890000>; + }; + + vreg_pmu_btcmx_0p85: ldo4 { + regulator-name = "vreg_pmu_btcmx_0p85"; + regulator-min-microvolt = <810000>; + regulator-max-microvolt = <890000>; + }; + + vreg_pmu_rfa_0p8: ldo5 { + regulator-name = "vreg_pmu_rfa_0p8"; + regulator-min-microvolt = <760000>; + regulator-max-microvolt = <840000>; + }; + + vreg_pmu_rfa_1p2: ldo6 { + regulator-name = "vreg_pmu_rfa_1p2"; + regulator-min-microvolt = <1187000>; + regulator-max-microvolt = <1313000>; + }; + + vreg_pmu_rfa_1p7: ldo7 { + regulator-name = "vreg_pmu_rfa_1p7"; + regulator-min-microvolt = <1710000>; + regulator-max-microvolt = <1890000>; + }; + + vreg_pmu_pcie_0p9: ldo8 { + regulator-name = "vreg_pmu_pcie_0p9"; + regulator-min-microvolt = <870000>; + regulator-max-microvolt = <970000>; + }; + + vreg_pmu_pcie_1p8: ldo9 { + regulator-name = "vreg_pmu_pcie_1p8"; + regulator-min-microvolt = <1710000>; + regulator-max-microvolt = <1890000>; + }; + }; + }; + thermal-zones { conn-thermal { polling-delay-passive = <0>; @@ -734,6 +815,23 @@ &pcie0_phy { vdda-pll-supply = <&vreg_l9a_1p2>; }; +&pcieport0 { + wifi@0 { + compatible = "pci17cb,1101"; + reg = <0x10000 0x0 0x0 0x0 0x0>; + + vddrfacmn-supply = <&vreg_pmu_rfa_cmn>; + vddaon-supply = <&vreg_pmu_aon_0p59>; + vddwlcx-supply = <&vreg_pmu_wlcx_0p8>; + vddwlmx-supply = <&vreg_pmu_wlmx_0p85>; + vddrfa0p8-supply = <&vreg_pmu_rfa_0p8>; + vddrfa1p2-supply = <&vreg_pmu_rfa_1p2>; + vddrfa1p7-supply = <&vreg_pmu_rfa_1p7>; + vddpcie0p9-supply = <&vreg_pmu_pcie_0p9>; + vddpcie1p8-supply = <&vreg_pmu_pcie_1p8>; + }; +}; + &pcie1 { status = "okay"; }; @@ -1303,6 +1401,14 @@ sdc2_card_det_n: sd-card-det-n-state { function = "gpio"; bias-pull-up; }; + + wlan_en_state: wlan-default-state { + pins = "gpio20"; + function = "gpio"; + drive-strength = <16>; + output-low; + bias-pull-up; + }; }; &uart6 { @@ -1311,17 +1417,12 @@ &uart6 { bluetooth { compatible = "qcom,qca6390-bt"; - pinctrl-names = "default"; - pinctrl-0 = <&bt_en_state>; - - enable-gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>; - - vddio-supply = <&vreg_s4a_1p8>; - vddpmu-supply = <&vreg_s2f_0p95>; - vddaon-supply = <&vreg_s6a_0p95>; - vddrfa0p9-supply = <&vreg_s2f_0p95>; - vddrfa1p3-supply = <&vreg_s8c_1p3>; - vddrfa1p9-supply = <&vreg_s5a_1p9>; + vddrfacmn-supply = <&vreg_pmu_rfa_cmn>; + vddaon-supply = <&vreg_pmu_aon_0p59>; + vddbtcmx-supply = <&vreg_pmu_btcmx_0p85>; + vddrfa0p8-supply = <&vreg_pmu_rfa_0p8>; + vddrfa1p2-supply = <&vreg_pmu_rfa_1p2>; + vddrfa1p7-supply = <&vreg_pmu_rfa_1p7>; }; }; diff --git a/arch/arm64/boot/dts/qcom/sm8250.dtsi b/arch/arm64/boot/dts/qcom/sm8250.dtsi index f3c70b87efad..29d2ccb5b389 100644 --- a/arch/arm64/boot/dts/qcom/sm8250.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8250.dtsi @@ -2203,6 +2203,16 @@ pcie0: pcie@1c00000 { dma-coherent; status = "disabled"; + + pcieport0: pcie@0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + bus-range = <0x01 0xff>; + }; }; pcie0_phy: phy@1c06000 { From patchwork Fri Feb 16 20:32:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773675 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED6A514F9C2 for ; Fri, 16 Feb 2024 20:33:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115611; cv=none; b=WfwbhPJTh7qQow4pzhu0cVHB/P6RyCvC2Y+F31Tch3qmrvK5pJeqlAQBj/GrCydqBX9qH7y6F1RUfIpE3y8YFax0p+de7T1Zbgh3v2PSU4ZEtUNk3TDef4esVFpsZSrAFrcn+Fo8NeNlaDNFmnkyrkbA6M8hnbkWfBd7vfJR1Yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115611; c=relaxed/simple; bh=1MzVv0nSisKV/T8y8z+7k5GcP430Ri3hmser4aGxhTc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KItovPraEyr9eVs8dJRFS+OkYWTGV32d83U+1ZE1m2kXYg1hVBhpQy+DNqy3F2OKn5P1ylAETd+5Td4eUureiBMrKcXFPwF44OyYgp/GT41ML317/c69RsrhQvMEJ63dDWNku2Y8boGMcL7KWhuJ40Li8BuMJBM4BeMtdkaftEc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=dh/RVxIT; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="dh/RVxIT" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2d220ad10b3so6103761fa.1 for ; Fri, 16 Feb 2024 12:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115607; x=1708720407; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eErBIOjTQ5lnZfiQvyC9U9P7RJRdhki8x/CaBEW0suw=; b=dh/RVxITCtXQhFAY6jllUpH6ijZmzSl3oVgfciKAwSldS0aKth9QMGwJOlCO4EfBQ2 WRDOESAwQsPgDwqk5uyyMJiclBn+cnAR9x7eOPzEZjIi5ojzpGoVM6ac18dW2K+pNdDv WmWv23ry3sVEaBIsaZ7CHDxdvi+lI3Dl5Md35UOVXjDtYzoSVn/JEVGexjNforZG20d/ KKIsMec5L9Ua1UE115q6masiZyyaAqT3eQXZaz0Uj7MAcvM1hyrieLFRN6t2yScFTiwQ pBzOa5n3sRpP/HtksgKDyUM71kZjtjL4a4HNUYZRAHRYdzCemSftVAbwYLdk2BdWm5dy ZGOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115607; x=1708720407; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eErBIOjTQ5lnZfiQvyC9U9P7RJRdhki8x/CaBEW0suw=; b=GJzG4/UCks25Il7JdsXU9y1F5LYcZY7olneGUwSD1Va0Y3kXk8BkUymZ69dpjPy6kD AZzThll4YomViu5EDz3cdyOrEOYcximPEtEHmHrVvLGkVnzsvpIwcFABNDNxf6fwc9u4 D3rmG5yBkg2ZQyTXlrMR2T3EJAvdYMrbA83BZScqb/5gZQNQJx+ryzwAqW/5BxrJCMtn 2E5DFI1PlNi+ZrfZd9sD5896U9k57prMi2wTtE2aAii9INMG6B3Qa8RmB6A9tZmpMRhA 3Oyzc5lBith0xuXy5jjFFJI5B3dhUPQgBmEqPS6zLXS5x8dAVfmfTsocqW/PjlScXOgG OnmA== X-Forwarded-Encrypted: i=1; AJvYcCW7pTGyYLzaDXxBGkNWmd9sOi9rugY86jnXHQ4YOAmFOmNLmyc1S2cfHgXb7WnR4wE6Gzvm3fiJ8qiOvfv29fTKokpMlDGbhy0TlZrocQY= X-Gm-Message-State: AOJu0Yx11TkxtsoiCWF6hOwzDUe8xWtbeqZmMHBAL7dbWnznNXVpJ/tm wl74WfRqFVRdW6LW+UobP+iU/ickWHSPMMawL0EItCRAGHtcZHFxjN6UB6LCMS0= X-Google-Smtp-Source: AGHT+IEGi5tv9AIVQSVPvOrOZQQ9v1N9yVfrGqntVvYxcBnIqc7VX5XHcJUa0nQEF7j51CNJg9AgoQ== X-Received: by 2002:a05:651c:10c7:b0:2d2:1107:3a7 with SMTP id l7-20020a05651c10c700b002d2110703a7mr3197736ljn.8.1708115607005; Fri, 16 Feb 2024 12:33:27 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:26 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 10/18] PCI: hold the rescan mutex when scanning for the first time Date: Fri, 16 Feb 2024 21:32:07 +0100 Message-Id: <20240216203215.40870-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski With the introduction of PCI device power control drivers that will be able to trigger the port rescan when probing, we need to hold the rescan mutex during the initial pci_host_probe() too or the two could get in each other's way. Signed-off-by: Bartosz Golaszewski --- drivers/pci/probe.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 467c16358f17..f8ba073ffc9b 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3066,7 +3066,9 @@ int pci_host_probe(struct pci_host_bridge *bridge) struct pci_bus *bus, *child; int ret; + pci_lock_rescan_remove(); ret = pci_scan_root_bus_bridge(bridge); + pci_unlock_rescan_remove(); if (ret < 0) { dev_err(bridge->dev.parent, "Scanning root bridge failed"); return ret; From patchwork Fri Feb 16 20:32:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 774064 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 979B6150996 for ; Fri, 16 Feb 2024 20:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115614; cv=none; b=RmtPiktQC5X5UKqCBqpL2kt1lwTEShxQd4gMeNFTyyAaX28fH5jvkOgAVVcwXfXqEU7aZD4Ich9z0cmVpBtm9Xvzzm/BGNa1XHlnTxmXySYPZKMPd+rWnbBDGAsC074TuJtSo6kDctQEp1FwzQG4ILR/+rqJdP/mj/cX1VcvTyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115614; c=relaxed/simple; bh=iWQpZyVUYNR0FgdTLJWWfXolJLly1aZ0q2sdWcfiADU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M6kwmp5DBU1YI1/eh7OJpdAPwj5EHbq1NsVRiJjaB9SlmjJxJ1EGusWmwKwd4RNcKNBHNpTPeRXOKmKaPHM0iFhkdLc9Kert3b598+pwjInazF+Q4hoTmFKrgNPUZSDF/uj3aBVTpW6Mkh4G9ebu4RH/Q69YC+yArJkFzRnWlcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=JlO18UXd; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="JlO18UXd" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d11c55d7f2so34620511fa.2 for ; Fri, 16 Feb 2024 12:33:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115608; x=1708720408; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VPKtETY44L+sLLhmL3uaX4nFnllKG+8eyvkbzTNtgX4=; b=JlO18UXdAY40EYPh5vQMlAFsIPsHixgABilZ9EkLiVRSYzLOSjW5w+ypfcbuMeHrfZ CjEn1EyR1b4/rA7fxre/BWWN0FumJvdbBNy7LiHW23Uu6JgXO3AM6b3HgrQuCxUexSO8 8XpfNDuMNPm8XbbzzOhjM0K5uGImrSyKsDGkLl9V7jvCAEkeoP4cJwkHiR5U34FMABTe qFXW5mmFrbqL/QQqcnHl68kZl3ACLvKxIv8BqgCo+nyqzzqAviso6s6C5/trv4oan69U Q0X06jqsaVauq/rzu3/3ZqSQftU65tbC/WCOJ4wIWUW7SJBKnuP/5gxaSFP1Pe861jde u2rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115608; x=1708720408; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VPKtETY44L+sLLhmL3uaX4nFnllKG+8eyvkbzTNtgX4=; b=XABH/pe3MLcilup4f/kJtONccYdG7Su4VX3NWqU86yOJa5el0q2Zngg3OUBoTTb1js zBJneFlh65irwP/FTeUT1Ferl6hzzwi8f8Elwx3QOjyiKrsP/1uSXjr+MKoU5MYxvCFC dUzvG4qKBg2ZCoNBpah2Vdxc2bGV9lJJwygiwrjUNAUyqDSmp2dj/K1rtNhEjE3afOnE 8c1YAQgfJYg8itkqYDj918tUjRVXOHUFtqcdKXI6eU8M11xHIABK3Ny09Az8ud3RVR1H NGSgL/XZjDMaKIT4kjZGaMQhEmeWllB1fltlE5nEWbmjGfIPgsNcdunH2z3LD+aavbSw YsYw== X-Forwarded-Encrypted: i=1; AJvYcCXdRnG/LBbE+BwgdAVgFP2gqlsp+wYF8DW/7mP/9FyTz9wqHQj2AtNPhRrgk92GZoUp/vfdrK0NXhPhgEUvHgU8uvir24VDzZXO6PkLZ+8= X-Gm-Message-State: AOJu0Yy2DJsRM+r2YSJ74C/MiBuSP1wDnK4g6j+tLMCHquD19HdfuWIY KyI+PDfS2fi8stoi135kxnSj0dFTIV1DcZou36R7ipq2tRDM0nyxHitJe0jy4JM= X-Google-Smtp-Source: AGHT+IEA6PoShhob8vA8LHOTLObGA6LSgflaMRnbW+2bPuCja7p6p6LxUhdbKaL3IWhCeNx0gCY0nA== X-Received: by 2002:a2e:9198:0:b0:2d0:cfe6:4364 with SMTP id f24-20020a2e9198000000b002d0cfe64364mr4325724ljg.36.1708115608679; Fri, 16 Feb 2024 12:33:28 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:28 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 11/18] PCI/pwrctl: reuse the OF node for power controlled devices Date: Fri, 16 Feb 2024 21:32:08 +0100 Message-Id: <20240216203215.40870-12-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski With PCI power control we deal with two struct device objects bound to two different drivers but consuming the same OF node. We must not bind the pinctrl twice. To that end: before setting the OF node of the newly instantiated PCI device, check if a platform device consuming the same OF node doesn't already exist on the platform bus and - if so - mark the PCI device as reusing the OF node. Signed-off-by: Bartosz Golaszewski --- drivers/pci/of.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/pci/of.c b/drivers/pci/of.c index 51e3dd0ea5ab..b908fe1ae951 100644 --- a/drivers/pci/of.c +++ b/drivers/pci/of.c @@ -6,6 +6,7 @@ */ #define pr_fmt(fmt) "PCI: OF: " fmt +#include #include #include #include @@ -13,6 +14,7 @@ #include #include #include +#include #include "pci.h" #ifdef CONFIG_PCI @@ -25,16 +27,20 @@ */ int pci_set_of_node(struct pci_dev *dev) { - struct device_node *node; - if (!dev->bus->dev.of_node) return 0; - node = of_pci_find_child_device(dev->bus->dev.of_node, dev->devfn); + struct device_node *node __free(device_node) = + of_pci_find_child_device(dev->bus->dev.of_node, dev->devfn); if (!node) return 0; - device_set_node(&dev->dev, of_fwnode_handle(node)); + struct device *pdev __free(put_device) = + bus_find_device_by_of_node(&platform_bus_type, node); + if (pdev) + dev->bus->dev.of_node_reused = true; + + device_set_node(&dev->dev, of_fwnode_handle(no_free_ptr(node))); return 0; } From patchwork Fri Feb 16 20:32:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773674 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F088B151CCF for ; Fri, 16 Feb 2024 20:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115614; cv=none; b=YQWFCf5LLi2SIklZcPBdtH4UxuxYCTrDPCRjdExX+4aQYpCpdj9vlYGDxMTJVd6c0rCMgrW28WU+cEMpYZYcbDbU0k3FSLs9vRQ1GqdoGLRJEuP34v+G7w5WNKwzFfSC+9L0DAGijhJkCJHudTyrM+mmt7C9dpyRHKcfsXM9/jI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115614; c=relaxed/simple; bh=ItVOWrm+zmPgwU0jiuXsWbAoFc6imFhaKj9fNGvBoW8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TNxDKTJlvXg3c5cekoVAim2F0yqVfqYQv4K1GeZuI+ocK7Qj6/iYOpZrsBKgzxXRpEsdaUn5GEUV2/88o3bse9VbWUadHMtF7VGU3M9mS6hvTNoK12TjSUt4gqeuDjHNoTJ+gv5u0EnxBl5pdcJD6nP8Zqw0w+EFN8X3HIfCjMk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=0H0mj5jr; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="0H0mj5jr" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-41258904302so174395e9.3 for ; Fri, 16 Feb 2024 12:33:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115610; x=1708720410; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cLRQo0XRS8LZDKEz8aQDPJI24t7vYnPhkxLETHKtHpE=; b=0H0mj5jr4OKi3HUByCC09hQ4mHsGgmT/ol2rT5sRBJo4LXMsR509dnLVPQj88to99o IvqXfP2wG1BMwPRHq9dOyb5uujUUvdqwYww2Ol+fK5o9d0SD6VzxvwVyXRX/UGtD3jXZ GU/wPJDv2XuKlHN7RGhU+1dL8pJo7zo4od3kKv8e2Ln2UAuVJK7Lbnw6GIYyo9RN1D/x f/48r2Iv0iIrjniwH/1YwJ5PnazRK64E7v5y/huSURRtDQihH2H9SzQGZXPPjP1pTUF1 A8+pS7wbNNt9pofbY8fr6k0026ZmPd68kOn4wYRIXruRmkBFGxaW4TE2kXqzPfZIllRD RFcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115610; x=1708720410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cLRQo0XRS8LZDKEz8aQDPJI24t7vYnPhkxLETHKtHpE=; b=sf0uTpSgvl6SJ8gXh5YKtvak7As8YMP+uyVzw7tuVrOrsOfLEqTqp7lO3I6BZX02nc ewMfsZ/+w4zQSh/Qj32EFgv7+f1Ge2dO/9cKt6AETWcOhW4JtAHtal8AGnublx8WKkm5 ovL0joFEvLgwJpybfj0HFPId4WA5CpDDwSDZ/6eM6YqsWxIuvx0poWqbr4v6XX6iDxth 0UVU78tWouFKWnybdhvywoyRlIDYIe/lBLjRb6ekO9qPNsFhji1X/C/H23x3eqEzQnlH MO54XUve/XnTa8ElXkQZOKLJITcLZiCTTK35TSTZl3Tp77SusjU1oII40gErCMw4AX0M 2mcw== X-Forwarded-Encrypted: i=1; AJvYcCWeEmslawJfSO0Nn3Jv7zwsdgvNyT0YFJPRMo9JRiYQXJOZ52Pd9hWZIQylJip9MjuZwsB2pIYp+d7T3QIMnDib2S41JVl0vynBwKLOihI= X-Gm-Message-State: AOJu0YwYxtpikyF9jag0diQ9WwgaQYN1Qt0ctZCVEz7HqYUZPtoBRPir aB1Qxz4LpT0dk92nWedUARAip13WtprM1b+AWS1aT7qA3UEw4JKD5egmq10nXbM= X-Google-Smtp-Source: AGHT+IEIxZ+2uB3UEcdhGVTyTJDaWzytlIE0jDJvcLHgbNngP62RD3/E1pF6wGg8FGrlRiGNZ99JNg== X-Received: by 2002:a05:600c:3c8a:b0:411:9508:e237 with SMTP id bg10-20020a05600c3c8a00b004119508e237mr4998629wmb.19.1708115610266; Fri, 16 Feb 2024 12:33:30 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:29 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 12/18] PCI/pwrctl: create platform devices for child OF nodes of the port node Date: Fri, 16 Feb 2024 21:32:09 +0100 Message-Id: <20240216203215.40870-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski In preparation for introducing PCI device power control - a set of library functions that will allow powering-up of PCI devices before they're detected on the PCI bus - we need to populate the devices defined on the device-tree. We are reusing the platform bus as it provides us with all the infrastructure we need to match the pwrctl drivers against the compatibles from OF nodes. These platform devices will be probed by the driver core and bound to the PCI pwrctl drivers we'll introduce later. Signed-off-by: Bartosz Golaszewski --- drivers/pci/bus.c | 9 ++++++++- drivers/pci/remove.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 826b5016a101..17ab41094c4e 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -342,8 +343,14 @@ void pci_bus_add_device(struct pci_dev *dev) */ pcibios_bus_add_device(dev); pci_fixup_device(pci_fixup_final, dev); - if (pci_is_bridge(dev)) + if (pci_is_bridge(dev)) { of_pci_make_dev_node(dev); + retval = of_platform_populate(dev->dev.of_node, NULL, NULL, + &dev->dev); + if (retval) + pci_err(dev, "failed to populate child OF nodes (%d)\n", + retval); + } pci_create_sysfs_dev_files(dev); pci_proc_attach_device(dev); pci_bridge_d3_update(dev); diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index d749ea8250d6..fc9db2805888 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include #include +#include #include "pci.h" static void pci_free_resources(struct pci_dev *dev) @@ -22,6 +23,7 @@ static void pci_stop_dev(struct pci_dev *dev) device_release_driver(&dev->dev); pci_proc_detach_device(dev); pci_remove_sysfs_dev_files(dev); + of_platform_depopulate(&dev->dev); of_pci_remove_node(dev); pci_dev_assign_added(dev, false); From patchwork Fri Feb 16 20:32:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 774063 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0DCF152E11 for ; Fri, 16 Feb 2024 20:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115616; cv=none; b=MF36+b4BVhbd23/SbO5UgVc6RBYZbb9cO4RwF/GFbpRa8VD4W5UiFqi+7HHjyslx48o7MH9OvYzgo5TQ1seCnUmDxPKSvwkxHBTRFQjgdceaat3JQ2pZi4+b6bRmAza8jAx4yWt8hOdTTKWnpukCesfHOeRXTq5e2epKdacc29c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115616; c=relaxed/simple; bh=3mCqNjHuoaUHiO0st6ivDZGmPe1iRnSnLzO7cdPvDrI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ntmWya2gj5Cqd3jzsZwT7X31k7ZkqPWNhesLS9L/STt18moLmtLfGQJggD/8LtkR3NRs9A5EWc4lS2PoQ6y9q0b2e4WES9q8j8XuiD6nFiDVTJTkkMtifjsxk+RJnF4xbk224aG/PMt3sXM6IKAze7uxZ6bX0LuFDKFQcyDztAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=D6VvxF6e; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="D6VvxF6e" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-41258905ea2so159145e9.2 for ; Fri, 16 Feb 2024 12:33:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115612; x=1708720412; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WoDV4sXNx4Iy0QllvGHLAhCC+BDrXl0CdEk2kmG14Eg=; b=D6VvxF6ex0Iotgxww6+YsyvFdNozb3d1hlySD77zNBv20liBuhTPhNABpdXyKta5h0 rSgIZ7QihbrSHVby4Reyur+SN6JWO6tPFQV7SSY7IrSkMqtQpE/v0rb9WuENycx2LnYy DGFT6zLog03lhAjJWptwxQOG/1WdpHgmDqWLRiNRjWc60nzZHBULm+OekJNpjCPqeSJ9 Ml/d17MSFzlHbHusApf6hFTv9he1TGUHGuA4SshsUwdzTqc2Aor6oHvuVrO8UsELJ2DC mBg3xv5w9g8SBbivmvuYMFczyiP/w+irrro7AukdtlH6H8U1vaR0QAd6V9d0o+Ph9jfE TMxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115612; x=1708720412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WoDV4sXNx4Iy0QllvGHLAhCC+BDrXl0CdEk2kmG14Eg=; b=FfADo1kDrlvT9Spz1ISGX6FfXHrOiOUXLmnx8dVXN4qN780szuFyWAlHnxrljUCgy4 rNWndwSqprHbF6yiV8cCOqRz7yZN6PIxKJQEchamrGAxGgg8i2v/cMDwSlHlmu0BJdhu 70wC8IKhPV8qLA03l37bZ1a0lJ7n/cFmr3Vk65iFRwHiAT+vgCHUdC/PzXPm39P26a/y ZSX+Jt2srK55XzkUnhuVHn4pg44Yb0gPACUz/lYkyWzbc5O7282vtuoViNdIJ/I1EtgY cIDYP16KyWOKaTgjjwCEIVONQZEWhZ3sx5SA4jaahmkMNjLrS3eaRgPXrDfiMFt/oDns UmYQ== X-Forwarded-Encrypted: i=1; AJvYcCXlpYSpL0VZ3cG0skzvNBBBG9LwbVH+tKT2d71dcjBlmPC0DpaUkPoitWAdGK+6OvtqhToVFN3aqqVZTvw0waL/zj+YLN9OV1nfMjIbz+g= X-Gm-Message-State: AOJu0YwxUoYqye86rg2z28CH7th4IuWeJicQ6J1GAmLD93e+RgiaaDlt tyiipQnGc5rrLc0Xzuk07oJhiJCxixS3SB4Wx1K962iC8OHMc4Aa5Rh85CtlsQQ= X-Google-Smtp-Source: AGHT+IFXKbQhTTCa9bKUVYS5LxGzgjU3Nrxv1nk159yBDqlBO6SfJp1wc5BtiuHAIJqXzniGOTOwcg== X-Received: by 2002:a05:600c:1f8d:b0:410:c5a9:a24a with SMTP id je13-20020a05600c1f8d00b00410c5a9a24amr4443428wmb.20.1708115611827; Fri, 16 Feb 2024 12:33:31 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:31 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 13/18] PCI/pwrctl: add PCI power control core code Date: Fri, 16 Feb 2024 21:32:10 +0100 Message-Id: <20240216203215.40870-14-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Some PCI devices must be powered-on before they can be detected on the bus. Introduce a simple framework reusing the existing PCI OF infrastructure. The way this works is: a DT node representing a PCI device connected to the port can be matched against its power control platform driver. If the match succeeds, the driver is responsible for powering-up the device and calling pcie_pwrctl_device_set_ready() which will trigger a PCI bus rescan as well as subscribe to PCI bus notifications. When the device is detected and created, we'll make it consume the same DT node that the platform device did. When the device is bound, we'll create a device link between it and the parent power control device. Signed-off-by: Bartosz Golaszewski --- drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/pwrctl/Kconfig | 8 +++ drivers/pci/pwrctl/Makefile | 4 ++ drivers/pci/pwrctl/core.c | 136 ++++++++++++++++++++++++++++++++++++ include/linux/pci-pwrctl.h | 51 ++++++++++++++ 6 files changed, 201 insertions(+) create mode 100644 drivers/pci/pwrctl/Kconfig create mode 100644 drivers/pci/pwrctl/Makefile create mode 100644 drivers/pci/pwrctl/core.c create mode 100644 include/linux/pci-pwrctl.h diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index d35001589d88..aa4d1833f442 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -296,5 +296,6 @@ source "drivers/pci/hotplug/Kconfig" source "drivers/pci/controller/Kconfig" source "drivers/pci/endpoint/Kconfig" source "drivers/pci/switch/Kconfig" +source "drivers/pci/pwrctl/Kconfig" endif diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 175302036890..8ddad57934a6 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o \ obj-$(CONFIG_PCI) += msi/ obj-$(CONFIG_PCI) += pcie/ +obj-$(CONFIG_PCI) += pwrctl/ ifdef CONFIG_PCI obj-$(CONFIG_PROC_FS) += proc.o diff --git a/drivers/pci/pwrctl/Kconfig b/drivers/pci/pwrctl/Kconfig new file mode 100644 index 000000000000..96195395af69 --- /dev/null +++ b/drivers/pci/pwrctl/Kconfig @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only + +menu "PCI Power control drivers" + +config PCI_PWRCTL + tristate + +endmenu diff --git a/drivers/pci/pwrctl/Makefile b/drivers/pci/pwrctl/Makefile new file mode 100644 index 000000000000..52ae0640ef7b --- /dev/null +++ b/drivers/pci/pwrctl/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_PCI_PWRCTL) += pci-pwrctl-core.o +pci-pwrctl-core-y := core.o diff --git a/drivers/pci/pwrctl/core.c b/drivers/pci/pwrctl/core.c new file mode 100644 index 000000000000..11bd19519841 --- /dev/null +++ b/drivers/pci/pwrctl/core.c @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2024 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include + +static int pci_pwrctl_notify(struct notifier_block *nb, unsigned long action, + void *data) +{ + struct pci_pwrctl *pwrctl = container_of(nb, struct pci_pwrctl, nb); + struct device *dev = data; + + if (dev_fwnode(dev) != dev_fwnode(pwrctl->dev)) + return NOTIFY_DONE; + + switch (action) { + case BUS_NOTIFY_ADD_DEVICE: + /* + * We will have two struct device objects bound to two different + * drivers on different buses but consuming the same DT node. We + * must not bind the pins twice in this case but only once for + * the first device to be added. + * + * If we got here then the PCI device is the second after the + * power control platform device. Mark its OF node as reused. + */ + dev->of_node_reused = true; + break; + case BUS_NOTIFY_BOUND_DRIVER: + pwrctl->link = device_link_add(dev, pwrctl->dev, + DL_FLAG_AUTOREMOVE_CONSUMER); + if (!pwrctl->link) + dev_err(pwrctl->dev, "Failed to add device link\n"); + break; + case BUS_NOTIFY_UNBOUND_DRIVER: + if (pwrctl->link) + device_link_del(pwrctl->link); + break; + } + + return NOTIFY_DONE; +} + +/** + * pci_pwrctl_device_set_ready() - Notify the pwrctl subsystem that the PCI + * device is powered-up and ready to be detected. + * + * @pwrctl: PCI power control data + * + * Returns: + * 0 on success, negative error number on error. + * + * Note: + * This function returning 0 doesn't mean the device was detected. It means, + * that the bus rescan was successfully started. The device will get bound to + * its PCI driver asynchronously. + */ +int pci_pwrctl_device_set_ready(struct pci_pwrctl *pwrctl) +{ + int ret; + + if (!pwrctl->dev) + return -ENODEV; + + pwrctl->nb.notifier_call = pci_pwrctl_notify; + ret = bus_register_notifier(&pci_bus_type, &pwrctl->nb); + if (ret) + return ret; + + pci_lock_rescan_remove(); + pci_rescan_bus(to_pci_dev(pwrctl->dev->parent)->bus); + pci_unlock_rescan_remove(); + + return 0; +} +EXPORT_SYMBOL_GPL(pci_pwrctl_device_set_ready); + +/** + * pci_pwrctl_device_unset_ready() - Notify the pwrctl subsystem that the PCI + * device is about to be powered-down. + * + * @pwrctl: PCI power control data + */ +void pci_pwrctl_device_unset_ready(struct pci_pwrctl *pwrctl) +{ + /* + * We don't have to delete the link here. Typically, this function + * is only called when the power control device is being detached. If + * it is being detached then the child PCI device must have already + * been unbound too or the device core wouldn't let us unbind. + */ + bus_unregister_notifier(&pci_bus_type, &pwrctl->nb); +} +EXPORT_SYMBOL_GPL(pci_pwrctl_device_unset_ready); + +static void devm_pci_pwrctl_device_unset_ready(void *data) +{ + struct pci_pwrctl *pwrctl = data; + + pci_pwrctl_device_set_ready(pwrctl); +} + +/** + * devm_pci_pwrctl_device_set_ready - Managed variant of + * pci_pwrctl_device_set_ready(). + * + * @pwrctl: PCI power control data + * + * Returns: + * 0 on success, negative error number on error. + */ +int devm_pci_pwrctl_device_set_ready(struct device *dev, + struct pci_pwrctl *pwrctl) +{ + int ret; + + ret = pci_pwrctl_device_set_ready(pwrctl); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, + devm_pci_pwrctl_device_unset_ready, + pwrctl); +} +EXPORT_SYMBOL_GPL(devm_pci_pwrctl_device_set_ready); + +MODULE_AUTHOR("Bartosz Golaszewski "); +MODULE_DESCRIPTION("PCI Device Power Control core driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/pci-pwrctl.h b/include/linux/pci-pwrctl.h new file mode 100644 index 000000000000..ae8324ea7eeb --- /dev/null +++ b/include/linux/pci-pwrctl.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024 Linaro Ltd. + */ + +#ifndef __PCI_PWRCTL_H__ +#define __PCI_PWRCTL_H__ + +#include + +struct device; +struct device_link; + +/* + * This is a simple framework for solving the issue of PCI devices that require + * certain resources (regulators, GPIOs, clocks) to be enabled before the + * device can actually be detected on the PCI bus. + * + * The idea is to reuse the platform bus to populate OF nodes describing the + * PCI device and its resources, let these platform devices probe and enable + * relevant resources and then trigger a rescan of the PCI bus allowing for the + * same device (with a second associated struct device) to be registered with + * the PCI subsystem. + * + * To preserve a correct hierarchy for PCI power management and device reset, + * we create a device link between the power control platform device (parent) + * and the supplied PCI device (child). + */ + +/** + * struct pci_pwrctl - PCI device power control context. + * @dev - Address of the power controlling device. + * + * An object of this type must be allocated by the PCI power control device and + * passed to the pwrctl subsystem to trigger a bus rescan and setup a device + * link with the device once it's up. + */ +struct pci_pwrctl { + struct device *dev; + + /* Private, don't use. */ + struct notifier_block nb; + struct device_link *link; +}; + +int pci_pwrctl_device_set_ready(struct pci_pwrctl *pwrctl); +void pci_pwrctl_device_unset_ready(struct pci_pwrctl *pwrctl); +int devm_pci_pwrctl_device_set_ready(struct device *dev, + struct pci_pwrctl *pwrctl); + +#endif /* __PCI_PWRCTL_H__ */ From patchwork Fri Feb 16 20:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773673 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7052115351B for ; Fri, 16 Feb 2024 20:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115618; cv=none; b=Ks0cEmYxk+d1PF1QFo5HR8cFnwrNqQO1tlQwBvrTFcQnBQ8+cjHI0poxbmQxUfup1mxXAoqnCprDsBtD00Rw2+17uX32/xfNBRco5XZAW/P7hGY0+hQ8gc2pWLz8c+B84wL0meVxnXzaQRdcGSrqtw7cEyrtmufV3xZZxgA9Ki8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115618; c=relaxed/simple; bh=yx9oNf9d3eA1FlLSpotJY/uy8bPphhk+h+RPxHa1al0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AkgnZcUqjInTyNjvz5Ih21hUpv8Dsq2S0MyQdJuLodmLifd7CgIjZJKwhvzUDEd5qnW32EjN6Wi4uol5RRvMON9RNjB1TrZXT71//DH8L9ddnow/tfoHxh22eddYFjjpdpoqxdOR8osyuAFjrrDKcwnMm24ALbasxdHxIFw1SjU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=Pb6XyWpV; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="Pb6XyWpV" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d0e520362cso25705891fa.2 for ; Fri, 16 Feb 2024 12:33:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115613; x=1708720413; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iiAgZXD5R5oyKE5kvpTu1Xl8SVVb50mDoXKZHDVMF3g=; b=Pb6XyWpVwDbIYabChrT2njYtuWzXrM7tQ4+lP6XtchjVJY/hIvgDhIk5waBW9aypVb 4av6eZQpVGzknbr4L71sVR9W7g17bX1uZLAL4bjR5uogLyd46dbiO2TsbmiCvAeXVWy1 o+yBvWgtxLnAjrk68YnBWTESHcXDCPi0d5b93xlU7H/l6KyQex5bHHbuXali1zfukm1l Dvg3PTpRg8UZh9OF4YoMqnadhLpzX2PRTi+kDmQyW5x/gQxny2Q3tGkQ2gjrufrtSMl8 E6K11IpDvKhsqKLcdJGwN3Yb+xqen7TWGIdj0LU5vkmwVAeSS3r+O4UJ7xWzWt8CR6ZD DY7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115613; x=1708720413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iiAgZXD5R5oyKE5kvpTu1Xl8SVVb50mDoXKZHDVMF3g=; b=jrCQxTjNU+TjyxIt/bzUzGCBaTmDgCVGVRSF3d0H54QXXDpsaJ1/OVppIF220WBirE DeUzyA/DYi4Y/khzfqLzCvapV35orLKn0nn6fjATYHuml0GfEFb9OATHno4VixxootR9 dw12zRIGB5yBIKEf37O1W/W1BfqXoeEjdc81Pb56XSlh6m1ibTSS0UVPPpSXZiYLVFvU /pADl2v4UDfKObsuiRi/6g5j7FPkqjS1xJEUdNU5qZylCvM20WW1Mvn7D08iqUMh2uRG SFCodQ2y3r9c9EM+eEaJFn1ENNJ1YIUdy9U0uW8iSTCXD9JQ9/eU/ngUWoXykomFWE59 Jzmw== X-Forwarded-Encrypted: i=1; AJvYcCU+1TS0hqpm+GP37e1ed99YxHL+BAwoA4KlhS4RDE6gBuQzgtFn9MKSbIDl8bMtFu6RjuzcGx7JX/Vuvb2gO9x3GzoNT+FsWn8EbnA1/WA= X-Gm-Message-State: AOJu0YzvEAWYJhYGhGa2YtxzaXvTN7EB/jYNC0zJsUR28YAIGtvGpDuU ehGIhVBUAtZ9x8eclEqiDCgFK+rXcqk5XhGq6fDyHR77Kgm2ddLTGfYEi3t3WrU= X-Google-Smtp-Source: AGHT+IEuflH9wQzsx8TrMcwmwhz38pYeg7QRtUYyjKydmIUvwvFOOto2iAhoyBREDsH8Oy9snBTz1A== X-Received: by 2002:a2e:b8c6:0:b0:2d1:1dae:c562 with SMTP id s6-20020a2eb8c6000000b002d11daec562mr4928843ljp.6.1708115613459; Fri, 16 Feb 2024 12:33:33 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:33 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 14/18] PCI/pwrctl: add a power control driver for WCN7850 Date: Fri, 16 Feb 2024 21:32:11 +0100 Message-Id: <20240216203215.40870-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Add a PCI power control driver that's capable of correctly powering up the ath12k module on WCN7850 using the PCI pwrctl functionality. Signed-off-by: Bartosz Golaszewski --- drivers/pci/pwrctl/Kconfig | 8 + drivers/pci/pwrctl/Makefile | 2 + drivers/pci/pwrctl/pci-pwrctl-wcn7850.c | 202 ++++++++++++++++++++++++ 3 files changed, 212 insertions(+) create mode 100644 drivers/pci/pwrctl/pci-pwrctl-wcn7850.c diff --git a/drivers/pci/pwrctl/Kconfig b/drivers/pci/pwrctl/Kconfig index 96195395af69..b91170ebfb49 100644 --- a/drivers/pci/pwrctl/Kconfig +++ b/drivers/pci/pwrctl/Kconfig @@ -5,4 +5,12 @@ menu "PCI Power control drivers" config PCI_PWRCTL tristate +config PCI_PWRCTL_WCN7850 + tristate "PCI Power Control driver for WCN7850" + select PCI_PWRCTL + default m if (ATH12K && ARCH_QCOM) + help + Enable support for the PCI power control driver for the ath12k + module of the WCN7850 WLAN/BT chip. + endmenu diff --git a/drivers/pci/pwrctl/Makefile b/drivers/pci/pwrctl/Makefile index 52ae0640ef7b..de20c3af1b78 100644 --- a/drivers/pci/pwrctl/Makefile +++ b/drivers/pci/pwrctl/Makefile @@ -2,3 +2,5 @@ obj-$(CONFIG_PCI_PWRCTL) += pci-pwrctl-core.o pci-pwrctl-core-y := core.o + +obj-$(CONFIG_PCI_PWRCTL_WCN7850) += pci-pwrctl-wcn7850.o diff --git a/drivers/pci/pwrctl/pci-pwrctl-wcn7850.c b/drivers/pci/pwrctl/pci-pwrctl-wcn7850.c new file mode 100644 index 000000000000..e2b2c53bff29 --- /dev/null +++ b/drivers/pci/pwrctl/pci-pwrctl-wcn7850.c @@ -0,0 +1,202 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2024 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct pci_pwrctl_wcn7850_vreg { + const char *name; + unsigned int load_uA; +}; + +struct pci_pwrctl_wcn7850_pdata { + struct pci_pwrctl_wcn7850_vreg *vregs; + size_t num_vregs; + unsigned int delay_msec; +}; + +struct pci_pwrctl_wcn7850_ctx { + struct pci_pwrctl pwrctl; + const struct pci_pwrctl_wcn7850_pdata *pdata; + struct regulator_bulk_data *regs; + struct gpio_desc *en_gpio; + struct clk *clk; +}; + +static struct pci_pwrctl_wcn7850_vreg pci_pwrctl_wcn7850_vregs[] = { + { + .name = "vdd", + .load_uA = 16000, + }, + { + .name = "vddio", + .load_uA = 5000, + }, + { + .name = "vddio1p2", + .load_uA = 16000, + }, + { + .name = "vddaon", + .load_uA = 26000, + }, + { + .name = "vdddig", + .load_uA = 126000, + }, + { + .name = "vddrfa1p2", + .load_uA = 257000, + }, + { + .name = "vddrfa1p8", + .load_uA = 302000, + }, +}; + +static struct pci_pwrctl_wcn7850_pdata pci_pwrctl_wcn7850_of_data = { + .vregs = pci_pwrctl_wcn7850_vregs, + .num_vregs = ARRAY_SIZE(pci_pwrctl_wcn7850_vregs), + .delay_msec = 50, +}; + +static int pci_pwrctl_wcn7850_power_on(struct pci_pwrctl_wcn7850_ctx *ctx) +{ + int ret; + + ret = regulator_bulk_enable(ctx->pdata->num_vregs, ctx->regs); + if (ret) + return ret; + + ret = clk_prepare_enable(ctx->clk); + if (ret) + return ret; + + gpiod_set_value_cansleep(ctx->en_gpio, 1); + + if (ctx->pdata->delay_msec) + msleep(ctx->pdata->delay_msec); + + return 0; +} + +static int pci_pwrctl_wcn7850_power_off(struct pci_pwrctl_wcn7850_ctx *ctx) +{ + gpiod_set_value_cansleep(ctx->en_gpio, 0); + clk_disable_unprepare(ctx->clk); + + return regulator_bulk_disable(ctx->pdata->num_vregs, ctx->regs); +} + +static void devm_pci_pwrctl_wcn7850_power_off(void *data) +{ + struct pci_pwrctl_wcn7850_ctx *ctx = data; + + pci_pwrctl_wcn7850_power_off(ctx); +} + +static int pci_pwrctl_wcn7850_probe(struct platform_device *pdev) +{ + struct pci_pwrctl_wcn7850_ctx *ctx; + struct device *dev = &pdev->dev; + int ret, i; + + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ctx->pdata = of_device_get_match_data(dev); + if (!ctx->pdata) + return dev_err_probe(dev, -ENODEV, + "Failed to obtain platform data\n"); + + if (ctx->pdata->vregs) { + ctx->regs = devm_kcalloc(dev, ctx->pdata->num_vregs, + sizeof(*ctx->regs), GFP_KERNEL); + if (!ctx->regs) + return -ENOMEM; + + for (i = 0; i < ctx->pdata->num_vregs; i++) + ctx->regs[i].supply = ctx->pdata->vregs[i].name; + + ret = devm_regulator_bulk_get(dev, ctx->pdata->num_vregs, + ctx->regs); + if (ret < 0) + return dev_err_probe(dev, ret, + "Failed to get all regulators\n"); + + for (i = 0; i < ctx->pdata->num_vregs; i++) { + if (!ctx->pdata->vregs[1].load_uA) + continue; + + ret = regulator_set_load(ctx->regs[i].consumer, + ctx->pdata->vregs[i].load_uA); + if (ret) + return dev_err_probe(dev, ret, + "Failed to set vreg load\n"); + } + } + + ctx->clk = devm_clk_get_optional(dev, NULL); + if (IS_ERR(ctx->clk)) + return dev_err_probe(dev, PTR_ERR(ctx->clk), + "Failed to get clock\n"); + + ctx->en_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); + if (IS_ERR(ctx->en_gpio)) + return dev_err_probe(dev, PTR_ERR(ctx->en_gpio), + "Failed to get enable the GPIO\n"); + + ret = pci_pwrctl_wcn7850_power_on(ctx); + if (ret) + return dev_err_probe(dev, ret, + "Failed to power on the device\n"); + + ret = devm_add_action_or_reset(dev, devm_pci_pwrctl_wcn7850_power_off, + ctx); + if (ret) + return ret; + + ctx->pwrctl.dev = dev; + + ret = devm_pci_pwrctl_device_set_ready(dev, &ctx->pwrctl); + if (ret) + return dev_err_probe(dev, ret, + "Failed to register the pwrctl wrapper\n"); + + return 0; +} + +static const struct of_device_id pci_pwrctl_wcn7850_of_match[] = { + { + .compatible = "pci17cb,1107", + .data = &pci_pwrctl_wcn7850_of_data, + }, + { } +}; +MODULE_DEVICE_TABLE(of, pci_pwrctl_wcn7850_of_match); + +static struct platform_driver pci_pwrctl_wcn7850_driver = { + .driver = { + .name = "pci-pwrctl-wcn7850", + .of_match_table = pci_pwrctl_wcn7850_of_match, + }, + .probe = pci_pwrctl_wcn7850_probe, +}; +module_platform_driver(pci_pwrctl_wcn7850_driver); + +MODULE_AUTHOR("Bartosz Golaszewski "); +MODULE_DESCRIPTION("PCI Power Sequencing module for WCN7850"); +MODULE_LICENSE("GPL"); From patchwork Fri Feb 16 20:32:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773672 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8EB715444A for ; Fri, 16 Feb 2024 20:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115624; cv=none; b=tj9fYiyynpsoyQGR35wg3wqf/rdUtF0hrka4Q5JIdA0tYrKoiIpFQkkA0NDEEW+/GpCSaoQVH4gdgXkGvp0vVKvLp9/tg0FiqTzvZwa5xQDwKxryV3pKZsiDJNffaUYBI9wni3i5lFb+O/7ibskrZbMrzl+6HF/hG2Hb4tVzOM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115624; c=relaxed/simple; bh=X4ZHvrwqZEyBeAi01/H9KK4yq2KrD2I61w6lZdlucm8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MIyAcnKwMCvLDlRH4KV8XlXb40oUmPAcdxlfpfjHBy2cj21acqkDx38YQdCSyD8Qnc1IdusIvuq5MFdpWZ0+1LSf4RXP9VZJIeoAjWq4E/BUn+DGzs4YMFwoUq4Su7A7PCvvj44d8KWP+gw/RVb0YnxMSSLsIEIRMlTAo61qea0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=pjlvdI/s; arc=none smtp.client-ip=209.85.128.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="pjlvdI/s" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-41241f64c6bso8129365e9.0 for ; Fri, 16 Feb 2024 12:33:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115615; x=1708720415; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GuKEVUfMPtlst7kCN+rX1Jrkz0IJ3Rvo08UBdK/Kj2o=; b=pjlvdI/sxQ1gFz5TMLL66V0LLiJgQvBTtyXuouQZHff9UHlgn2uORC/wYhKzNlDM3i EnhSwxY8acZllak0pUw3nLOZV9CkKRXP1ElKd2nOJH9kA8zZnFgSxP541NCkg9bE1IBf GjGgKMqjuskv/m5Fm3uEhSY3rD1U59W6DdljXEIKHksHayJFZ0Vm3nQg5Nw2IhSccgj1 9w+Fv2WqDWlDdtJ1vQE8PUR+BEO/f9+1duO+Ffl2LbX30ZPNNT87kfAAI2H9brncOnuO Rqxbc6VF2dNY3KHI56iQgD58kFjVeTVkLW3oxF0M3o8yclyHVXk2Mg5XFSgrECFv+odr iU9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115615; x=1708720415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GuKEVUfMPtlst7kCN+rX1Jrkz0IJ3Rvo08UBdK/Kj2o=; b=IutEGHuo5AS5MBvbHdTfSFG4ZCDwBbErW1PjMMkOw5SIq/aOBhdkPLjh0hUd2xLMYj 0dbmk77ypF2/FnVvRf5vOPrsXNYVsFryPm1RlVNKsgQK/N2h4iHDjuQnj0sfbvj+BAm3 rG+F4Uvf8pgQb8RoZAtu3E5YjpSBQJ/QyAdNZArr041epSbP2GrIErclmVdp6v4zk7Tu yJcEG/ZFlHXu278yS73SmDThGsIPa+z069xp1YjzkCdj1p8h8++LGBuSjPoY3g4Vid3F B+Lr+G9/fgvUtBHKBK+A2VQY6sUkhJvk+JTSIH3QPjKEP6753f/Q/qGD+sNP+cctm+kQ 1kAw== X-Forwarded-Encrypted: i=1; AJvYcCXEj5D/v4qw5Oz1ltmkleVffy3L6u3xut9b78ONZf00jB5IrtlHjsDOzd15maW70YbqW+FwDmiWw5J0ax77xWk5ZDvdG39kkc1L4Croh40= X-Gm-Message-State: AOJu0YzJzYvclq8Wrh5zWAV5XikUcMHoWQzownUmaUo3L4tOR8WvOhPm zbjYzsocFguI9NAZ1TPwyELtKFaExQ6dabkLJDk7Tl2Lk+w8SRkNWkfWGKwUFBoX2u+wRqEAyZf 6 X-Google-Smtp-Source: AGHT+IHb8SpXqlCOaYZS0/LtKlaiDT1Th7jjQPV0KlR4ZbBnZeojtxBKYA7yzzVwfWdcIv+Ln3zIjQ== X-Received: by 2002:a05:600c:3d9a:b0:411:e009:f3c7 with SMTP id bi26-20020a05600c3d9a00b00411e009f3c7mr4161252wmb.4.1708115615191; Fri, 16 Feb 2024 12:33:35 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:34 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 15/18] power: sequencing: implement the pwrseq core Date: Fri, 16 Feb 2024 21:32:12 +0100 Message-Id: <20240216203215.40870-16-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Implement the power sequencing subsystem allowing devices to share complex powering-up and down procedures. It's split into the consumer and provider parts but does not implement any new DT bindings so that the actual power sequencing is never revealed in the DT representation. Signed-off-by: Bartosz Golaszewski --- MAINTAINERS | 8 + drivers/power/Kconfig | 1 + drivers/power/Makefile | 1 + drivers/power/sequencing/Kconfig | 12 + drivers/power/sequencing/Makefile | 4 + drivers/power/sequencing/core.c | 1065 +++++++++++++++++++++++++++++ include/linux/pwrseq/consumer.h | 56 ++ include/linux/pwrseq/provider.h | 75 ++ 8 files changed, 1222 insertions(+) create mode 100644 drivers/power/sequencing/Kconfig create mode 100644 drivers/power/sequencing/Makefile create mode 100644 drivers/power/sequencing/core.c create mode 100644 include/linux/pwrseq/consumer.h create mode 100644 include/linux/pwrseq/provider.h diff --git a/MAINTAINERS b/MAINTAINERS index cd7980e5b1ad..5187a30952e4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -17647,6 +17647,14 @@ F: include/linux/pm_* F: include/linux/powercap.h F: kernel/configs/nopm.config +POWER SEQUENCING +M: Bartosz Golaszewski +L: linux-pm@vger.kernel.org +S: Maintained +T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git +F: drivers/power/sequencing/ +F: include/linux/pwrseq/ + POWER STATE COORDINATION INTERFACE (PSCI) M: Mark Rutland M: Lorenzo Pieralisi diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 696bf77a7042..9a8e44ca9ae4 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only source "drivers/power/reset/Kconfig" +source "drivers/power/sequencing/Kconfig" source "drivers/power/supply/Kconfig" diff --git a/drivers/power/Makefile b/drivers/power/Makefile index effbf0377f32..962a2cd30a51 100644 --- a/drivers/power/Makefile +++ b/drivers/power/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_POWER_RESET) += reset/ +obj-$(CONFIG_POWER_SEQUENCING) += sequencing/ obj-$(CONFIG_POWER_SUPPLY) += supply/ diff --git a/drivers/power/sequencing/Kconfig b/drivers/power/sequencing/Kconfig new file mode 100644 index 000000000000..ba5732b1dbf8 --- /dev/null +++ b/drivers/power/sequencing/Kconfig @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-only + +menuconfig POWER_SEQUENCING + tristate "Power Sequencing support" + help + Say Y here to enable the Power Sequencing subsystem. + + This subsystem is designed to control power to devices that share + complex resources and/or require specific power sequences to be run + during power-up. + + If unsure, say no. diff --git a/drivers/power/sequencing/Makefile b/drivers/power/sequencing/Makefile new file mode 100644 index 000000000000..dcdf8c0c159e --- /dev/null +++ b/drivers/power/sequencing/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_POWER_SEQUENCING) += pwrseq-core.o +pwrseq-core-y := core.o diff --git a/drivers/power/sequencing/core.c b/drivers/power/sequencing/core.c new file mode 100644 index 000000000000..00ad7964a0b6 --- /dev/null +++ b/drivers/power/sequencing/core.c @@ -0,0 +1,1065 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2024 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Power-sequencing framework for linux. + * + * This subsystem allows power sequence providers to register a set of targets + * that consumers may request and power-up/down. + * + * Glossary: + * + * Unit - a unit is a discreet chunk of a power sequence. For instance one unit + * may enable a set of regulators, another may enable a specific GPIO. Units + * can define dependencies in the form of other units that must be enabled + * before it itself can be. + * + * Target - a target is a set of units (composed of the "final" unit and its + * dependencies) that a consumer selects by its name when requesting a handle + * to the power sequencer. Via the dependency system, multiple targets may + * share the same parts of a power sequence but ignore parts that are + * irrelevant. + * + * Descriptor - a handle passed by the pwrseq core to every consumer that + * serves as the entry point to the provider layer. It ensures coherence + * between different users and keeps reference counting consistent. + * + * Each provider must define a .match() callback whose role is to determine + * whether a potential consumer is in fact associated with this sequencer. + * This allows creating abstraction layers on top of regular device-tree + * resources like regulators, clocks and other nodes connected to the consumer + * via phandle. + */ + +static DEFINE_IDA(pwrseq_ida); + +/* + * Protects the device list on the pwrseq bus from concurrent modifications + * but allows simultaneous read-only access. + */ +static DECLARE_RWSEM(pwrseq_sem); + +/** + * struct pwrseq_unit - Private power-sequence unit data. + * @ref: Reference count for this object. When it goes to 0, the object is + * destroyed. + * @name: Name of this target. + * @list: Link to siblings on the list of all units of a single sequencer. + * @deps: List of units on which this unit depends. + * @enable: Callback running the part of the power-on sequence provided by + * this unit. + * @disable: Callback running the part of the power-off sequence provided + * by this unit. + * @enable_count: Current number of users that enabled this unit. May be the + * consumer of the power sequencer or other units that depend + * on this one. + */ +struct pwrseq_unit { + struct kref ref; + const char *name; + struct list_head list; + struct list_head deps; + pwrseq_power_state_func enable; + pwrseq_power_state_func disable; + unsigned int enable_count; +}; + +static struct pwrseq_unit *pwrseq_unit_new(const struct pwrseq_unit_data *data) +{ + struct pwrseq_unit *unit; + + unit = kzalloc(sizeof(*unit), GFP_KERNEL); + if (!unit) + return NULL; + + unit->name = kstrdup_const(data->name, GFP_KERNEL); + if (!unit->name) { + kfree(unit); + return NULL; + } + + kref_init(&unit->ref); + INIT_LIST_HEAD(&unit->deps); + unit->enable = data->enable; + unit->disable = data->disable; + + return unit; +} + +static struct pwrseq_unit *pwrseq_unit_incref(struct pwrseq_unit *unit) +{ + kref_get(&unit->ref); + + return unit; +} + +static void pwrseq_unit_release(struct kref *ref); + +static void pwrseq_unit_decref(struct pwrseq_unit *unit) +{ + kref_put(&unit->ref, pwrseq_unit_release); +} + +/** + * struct pwrseq_unit_dep - Wrapper around a reference to the unit structure + * allowing to keep it on multiple dependency lists + * in different units. + * @list: Siblings on the list. + * @unit: Address of the referenced unit. + */ +struct pwrseq_unit_dep { + struct list_head list; + struct pwrseq_unit *unit; +}; + +static struct pwrseq_unit_dep *pwrseq_unit_dep_new(struct pwrseq_unit *unit) +{ + struct pwrseq_unit_dep *dep; + + dep = kzalloc(sizeof(*dep), GFP_KERNEL); + if (!dep) + return NULL; + + dep->unit = unit; + + return dep; +} + +static void pwrseq_unit_dep_free(struct pwrseq_unit_dep *ref) +{ + pwrseq_unit_decref(ref->unit); + kfree(ref); +} + +static void pwrseq_unit_free_deps(struct list_head *list) +{ + struct pwrseq_unit_dep *dep, *next; + + list_for_each_entry_safe(dep, next, list, list) { + list_del(&dep->list); + pwrseq_unit_dep_free(dep); + } +} + +static void pwrseq_unit_release(struct kref *ref) +{ + struct pwrseq_unit *unit = container_of(ref, struct pwrseq_unit, ref); + + pwrseq_unit_free_deps(&unit->deps); + list_del(&unit->list); + kfree_const(unit->name); + kfree(unit); +} + +/** + * struct pwrseq_target - Private power-sequence target data. + * @list: Siblings on the list of all targets exposed by a power sequencer. + * @name: Name of the target. + * @unit: Final unit for this target. + * @post_enable: Callback run after the target unit has been enabled, *after* + * the state lock has been released. It's useful for implementing + * boot-up delays without blocking other users from powering up + * using the same power sequencer. + */ +struct pwrseq_target { + struct list_head list; + const char *name; + struct pwrseq_unit *unit; + pwrseq_power_state_func post_enable; +}; + +static struct pwrseq_target * +pwrseq_target_new(const struct pwrseq_target_data *data) +{ + struct pwrseq_target *target; + + target = kzalloc(sizeof(*target), GFP_KERNEL); + if (!target) + return NULL; + + target->name = kstrdup_const(data->name, GFP_KERNEL); + if (!target->name) { + kfree(target); + return NULL; + } + + target->post_enable = data->post_enable; + + return target; +} + +static void pwrseq_target_free(struct pwrseq_target *target) +{ + pwrseq_unit_decref(target->unit); + kfree_const(target->name); + kfree(target); +} + +/** + * struct pwrseq_device - Private power sequencing data. + * @dev: Device struct associated with this sequencer. + * @id: Device ID. + * @owner: Prevents removal of active power sequencing providers. + * @rw_lock: Protects the device from being unregistered while in use. + * @state_lock: Prevents multiple users running the power sequence at the same + * time. + * @match: Power sequencer matching callback. + * @targets: List of targets exposed by this sequencer. + * @units: List of all units supported by this sequencer. + */ +struct pwrseq_device { + struct device dev; + int id; + struct module *owner; + struct rw_semaphore rw_lock; + struct mutex state_lock; + pwrseq_match_func match; + struct list_head targets; + struct list_head units; +}; + +static struct pwrseq_device *to_pwrseq_device(struct device *dev) +{ + return container_of(dev, struct pwrseq_device, dev); +} + +static struct pwrseq_device *pwrseq_device_get(struct pwrseq_device *pwrseq) +{ + get_device(&pwrseq->dev); + + return pwrseq; +} + +static void pwrseq_device_put(struct pwrseq_device *pwrseq) +{ + put_device(&pwrseq->dev); +} + +/** + * struct pwrseq_desc - Wraps access to the pwrseq_device and ensures that one + * user cannot break the reference counting for others. + * @pwrseq: Reference to the power sequencing device. + * @target: Reference to the target this descriptor allows to control. + * @powered_on: Power state set by the holder of the descriptor (not necessarily + * corresponding to the actual power state of the device). + */ +struct pwrseq_desc { + struct pwrseq_device *pwrseq; + struct pwrseq_target *target; + bool powered_on; +}; + +static const struct bus_type pwrseq_bus = { + .name = "pwrseq", +}; + +static void pwrseq_release(struct device *dev) +{ + struct pwrseq_device *pwrseq = to_pwrseq_device(dev); + struct pwrseq_target *target; + + list_for_each_entry(target, &pwrseq->targets, list) + pwrseq_target_free(target); + + mutex_destroy(&pwrseq->state_lock); + ida_free(&pwrseq_ida, pwrseq->id); + kfree(pwrseq); +} + +static const struct device_type pwrseq_device_type = { + .name = "power_sequencer", + .release = pwrseq_release, +}; + +static int pwrseq_unit_setup_deps(const struct pwrseq_unit_data **data, + struct list_head *dep_list, + struct list_head *unit_list, + struct radix_tree_root *processed_units) +{ + const struct pwrseq_unit_data *pos; + struct pwrseq_unit_dep *dep; + struct pwrseq_unit *unit; + int ret, i; + + for (i = 0; data[i]; i++) { + pos = data[i]; + + unit = radix_tree_lookup(processed_units, (unsigned long)data); + if (unit) { + pwrseq_unit_incref(unit); + } else { + unit = pwrseq_unit_new(pos); + if (!unit) + return -ENOMEM; + + if (pos->deps) { + ret = pwrseq_unit_setup_deps(pos->deps, + &unit->deps, + unit_list, + processed_units); + if (ret) { + pwrseq_unit_decref(unit); + return ret; + } + } + + ret = radix_tree_insert(processed_units, + (unsigned long)data, unit); + if (ret) { + pwrseq_unit_decref(unit); + return ret; + } + + list_add_tail(&unit->list, unit_list); + } + + dep = pwrseq_unit_dep_new(unit); + if (!dep) { + pwrseq_unit_decref(unit); + return -ENOMEM; + } + + list_add_tail(&dep->list, dep_list); + } + + return 0; +} + +static int pwrseq_target_setup_unit(struct pwrseq_target *target, + const struct pwrseq_unit_data *data, + struct list_head *unit_list, + struct radix_tree_root *processed_units) +{ + struct pwrseq_unit *unit; + int ret; + + unit = radix_tree_lookup(processed_units, (unsigned long)data); + if (unit) { + target->unit = pwrseq_unit_incref(unit); + return 0; + } + + unit = pwrseq_unit_new(data); + if (!unit) + return -ENOMEM; + + ret = pwrseq_unit_setup_deps(data->deps, &unit->deps, unit_list, + processed_units); + if (ret) { + pwrseq_unit_decref(unit); + return ret; + } + + ret = radix_tree_insert(processed_units, (unsigned long)data, unit); + if (ret) { + pwrseq_unit_decref(unit); + return ret; + } + + target->unit = unit; + list_add_tail(&unit->list, unit_list); + + return 0; +} + +static int pwrseq_do_setup_targets(const struct pwrseq_target_data **data, + struct pwrseq_device *pwrseq, + struct radix_tree_root *processed_units) +{ + const struct pwrseq_target_data *pos; + struct pwrseq_target *target; + int ret, i; + + for (i = 0; data[i]; i++) { + pos = data[i]; + + target = pwrseq_target_new(pos); + if (!target) + return -ENOMEM; + + ret = pwrseq_target_setup_unit(target, pos->unit, + &pwrseq->units, + processed_units); + if (ret) { + pwrseq_target_free(target); + return ret; + } + + list_add_tail(&target->list, &pwrseq->targets); + } + + return 0; +} + +static int pwrseq_setup_targets(const struct pwrseq_target_data **targets, + struct pwrseq_device *pwrseq) +{ + struct radix_tree_root processed_units; + struct radix_tree_iter iter; + void __rcu **slot; + int ret; + + INIT_RADIX_TREE(&processed_units, GFP_KERNEL); + ret = pwrseq_do_setup_targets(targets, pwrseq, &processed_units); + radix_tree_for_each_slot(slot, &processed_units, &iter, 0) + radix_tree_delete(&processed_units, iter.index); + + return ret; +} + +/** + * pwrseq_device_register() - Register a new power sequencer. + * @config: Configuration of the new power sequencing device. + * + * The config structure is only used during the call and can be freed after + * the function returns. The config structure *must* have the parent device + * as well as the match() callback and at least one target set. + * + * Returns: + * Returns the address of the new pwrseq device or ERR_PTR() on failure. + */ +struct pwrseq_device * +pwrseq_device_register(const struct pwrseq_config *config) +{ + struct pwrseq_device *pwrseq; + int ret; + + if (!config->parent || !config->match || !config->targets || + !config->targets[0]) + return ERR_PTR(-EINVAL); + + pwrseq = kzalloc(sizeof(*pwrseq), GFP_KERNEL); + if (!pwrseq) + return ERR_PTR(-ENOMEM); + + pwrseq->dev.type = &pwrseq_device_type; + pwrseq->dev.bus = &pwrseq_bus; + pwrseq->dev.parent = config->parent; + device_set_node(&pwrseq->dev, dev_fwnode(config->parent)); + dev_set_drvdata(&pwrseq->dev, config->drvdata); + + pwrseq->id = ida_alloc(&pwrseq_ida, GFP_KERNEL); + if (pwrseq->id < 0) { + kfree(pwrseq); + return ERR_PTR(pwrseq->id); + } + + /* + * From this point onwards the device's release() callback is + * responsible for freeing resources. + */ + device_initialize(&pwrseq->dev); + + ret = dev_set_name(&pwrseq->dev, "pwrseq.%d", pwrseq->id); + if (ret) + goto err_put_pwrseq; + + pwrseq->owner = config->owner ?: THIS_MODULE; + pwrseq->match = config->match; + + init_rwsem(&pwrseq->rw_lock); + mutex_init(&pwrseq->state_lock); + INIT_LIST_HEAD(&pwrseq->targets); + INIT_LIST_HEAD(&pwrseq->units); + + ret = pwrseq_setup_targets(config->targets, pwrseq); + if (ret) + goto err_put_pwrseq; + + scoped_guard(rwsem_write, &pwrseq_sem) { + ret = device_add(&pwrseq->dev); + if (ret) + goto err_put_pwrseq; + } + + return pwrseq; + +err_put_pwrseq: + pwrseq_device_put(pwrseq); + return ERR_PTR(ret); +} +EXPORT_SYMBOL_GPL(pwrseq_device_register); + +/** + * pwrseq_device_unregister() - Unregister the power sequencer. + * @pwrseq: Power sequencer to unregister. + */ +void pwrseq_device_unregister(struct pwrseq_device *pwrseq) +{ + struct device *dev = &pwrseq->dev; + struct pwrseq_target *target; + + scoped_guard(mutex, &pwrseq->state_lock) { + guard(rwsem_write)(&pwrseq->rw_lock); + + list_for_each_entry(target, &pwrseq->targets, list) + WARN_ONCE(target->unit->enable_count, + "REMOVING POWER SEQUENCER WITH ACTIVE USERS\n"); + + guard(rwsem_write)(&pwrseq_sem); + + device_del(dev); + } + + pwrseq_device_put(pwrseq); +} +EXPORT_SYMBOL_GPL(pwrseq_device_unregister); + +static void devm_pwrseq_device_unregister(void *data) +{ + struct pwrseq_device *pwrseq = data; + + pwrseq_device_unregister(pwrseq); +} + +/** + * devm_pwrseq_device_register() - Managed variant of pwrseq_device_register(). + * @dev: Managing device. + * @config: Configuration of the new power sequencing device. + * + * Returns: + * Returns the address of the new pwrseq device or ERR_PTR() on failure. + */ +struct pwrseq_device * +devm_pwrseq_device_register(struct device *dev, + const struct pwrseq_config *config) +{ + struct pwrseq_device *pwrseq; + int ret; + + pwrseq = pwrseq_device_register(config); + if (IS_ERR(pwrseq)) + return pwrseq; + + ret = devm_add_action_or_reset(dev, devm_pwrseq_device_unregister, + pwrseq); + if (ret) + return ERR_PTR(ret); + + return pwrseq; +} +EXPORT_SYMBOL_GPL(devm_pwrseq_device_register); + +/** + * pwrseq_device_get_data() - Get the driver private data associated with this + * sequencer. + * @pwrseq: Power sequencer object. + * + * Returns: + * Address of the private driver data. + */ +void *pwrseq_device_get_drvdata(struct pwrseq_device *pwrseq) +{ + return dev_get_drvdata(&pwrseq->dev); +} +EXPORT_SYMBOL_GPL(pwrseq_device_get_drvdata); + +struct pwrseq_match_data { + struct pwrseq_desc *desc; + struct device *dev; + const char *target; +}; + +static int pwrseq_match_device(struct device *pwrseq_dev, void *data) +{ + struct pwrseq_device *pwrseq = to_pwrseq_device(pwrseq_dev); + struct pwrseq_match_data *match_data = data; + struct pwrseq_target *target; + int ret; + + guard(rwsem_read)(&pwrseq->rw_lock); + if (!device_is_registered(&pwrseq->dev)) + return 0; + + ret = pwrseq->match(pwrseq, match_data->dev); + if (ret <= 0) + return ret; + + /* We got the matching device, let's find the right target. */ + list_for_each_entry(target, &pwrseq->targets, list) { + if (strcmp(target->name, match_data->target)) + continue; + + match_data->desc->target = target; + } + + /* + * This device does not have this target. No point in deferring as it + * will not get a new target dynamically later. + */ + if (!match_data->desc->target) + return -ENOENT; + + if (!try_module_get(pwrseq->owner)) + return -EPROBE_DEFER; + + match_data->desc->pwrseq = pwrseq_device_get(pwrseq); + + return 1; +} + +/** + * pwrseq_get() - Get the power sequencer associated with this device. + * @dev: Device for which to get the sequencer. + * @target: Name of the target exposed by the sequencer this device wants to + * reach. + * + * Returns: + * New power sequencer descriptor for use by the consumer driver or ERR_PTR() + * on failure. + */ +struct pwrseq_desc *pwrseq_get(struct device *dev, const char *target) +{ + struct pwrseq_match_data match_data; + int ret; + + struct pwrseq_desc *desc __free(kfree) = kzalloc(sizeof(*desc), + GFP_KERNEL); + if (!desc) + return ERR_PTR(-ENOMEM); + + match_data.desc = desc; + match_data.dev = dev; + match_data.target = target; + + guard(rwsem_read)(&pwrseq_sem); + + ret = bus_for_each_dev(&pwrseq_bus, NULL, &match_data, + pwrseq_match_device); + if (ret < 0) + return ERR_PTR(ret); + if (ret == 0) + /* No device matched. */ + return ERR_PTR(-EPROBE_DEFER); + + return no_free_ptr(desc); +} +EXPORT_SYMBOL_GPL(pwrseq_get); + +/** + * pwrseq_put() - Release the power sequencer descriptor. + * @desc: Descriptor to release. + */ +void pwrseq_put(struct pwrseq_desc *desc) +{ + struct pwrseq_device *pwrseq; + + if (!desc) + return; + + pwrseq = desc->pwrseq; + + if (desc->powered_on) + pwrseq_power_off(desc); + + kfree(desc); + module_put(pwrseq->owner); + pwrseq_device_put(pwrseq); +} +EXPORT_SYMBOL_GPL(pwrseq_put); + +static void devm_pwrseq_put(void *data) +{ + struct pwrseq_desc *desc = data; + + pwrseq_put(desc); +} + +/** + * devm_pwrseq_get() - Managed variant of pwrseq_get(). + * @dev: Device for which to get the sequencer and which also manages its + * lifetime. + * @target: Name of the target exposed by the sequencer this device wants to + * reach. + * + * Returns: + * New power sequencer descriptor for use by the consumer driver or ERR_PTR() + * on failure. + */ +struct pwrseq_desc *devm_pwrseq_get(struct device *dev, const char *target) +{ + struct pwrseq_desc *desc; + int ret; + + desc = pwrseq_get(dev, target); + if (IS_ERR(desc)) + return desc; + + ret = devm_add_action_or_reset(dev, devm_pwrseq_put, desc); + if (ret) + return ERR_PTR(ret); + + return desc; +} +EXPORT_SYMBOL_GPL(devm_pwrseq_get); + +static int pwrseq_unit_enable(struct pwrseq_device *pwrseq, + struct pwrseq_unit *target); +static int pwrseq_unit_disable(struct pwrseq_device *pwrseq, + struct pwrseq_unit *target); + +static int pwrseq_unit_enable_deps(struct pwrseq_device *pwrseq, + struct list_head *list) +{ + struct pwrseq_unit_dep *pos; + int ret = 0; + + list_for_each_entry(pos, list, list) { + ret = pwrseq_unit_enable(pwrseq, pos->unit); + if (ret) { + list_for_each_entry_continue_reverse(pos, list, list) + pwrseq_unit_disable(pwrseq, pos->unit); + break; + } + } + + return ret; +} + +static int pwrseq_unit_disable_deps(struct pwrseq_device *pwrseq, + struct list_head *list) +{ + struct pwrseq_unit_dep *pos; + int ret = 0; + + list_for_each_entry_reverse(pos, list, list) { + ret = pwrseq_unit_disable(pwrseq, pos->unit); + if (ret) { + list_for_each_entry_continue(pos, list, list) + pwrseq_unit_enable(pwrseq, pos->unit); + break; + } + } + + return ret; +} + +static int pwrseq_unit_enable(struct pwrseq_device *pwrseq, + struct pwrseq_unit *unit) +{ + int ret; + + if (unit->enable_count != 0) { + unit->enable_count++; + return 0; + } + + ret = pwrseq_unit_enable_deps(pwrseq, &unit->deps); + if (ret) { + dev_err(&pwrseq->dev, + "Failed to enable dependencies before power-on for target '%s': %d\n", + unit->name, ret); + return ret; + } + + if (unit->enable) { + ret = unit->enable(pwrseq); + if (ret) { + dev_err(&pwrseq->dev, + "Failed to enable target '%s': %d\n", + unit->name, ret); + pwrseq_unit_disable_deps(pwrseq, &unit->deps); + return ret; + } + } + + unit->enable_count++; + + return 0; +} + +static int pwrseq_unit_disable(struct pwrseq_device *pwrseq, + struct pwrseq_unit *unit) +{ + int ret; + + if (unit->enable_count == 0) { + WARN_ONCE(1, "Unmatched power-off for target '%s'\n", + unit->name); + return -EBUSY; + } + + if (unit->enable_count != 1) { + unit->enable_count--; + return 0; + } + + if (unit->disable) { + ret = unit->disable(pwrseq); + if (ret) { + dev_err(&pwrseq->dev, + "Failed to disable target '%s': %d\n", + unit->name, ret); + return ret; + } + } + + ret = pwrseq_unit_disable_deps(pwrseq, &unit->deps); + if (ret) { + dev_err(&pwrseq->dev, + "Failed to disable dependencies after power-off for target '%s': %d\n", + unit->name, ret); + if (unit->enable) + unit->enable(pwrseq); + return ret; + } + + unit->enable_count--; + + return 0; +} + +/** + * pwrseq_power_on() - Issue a power-on request on behalf of the consumer + * device. + * @desc: Descriptor referencing the power sequencer. + * + * This function tells the power sequencer that the consumer wants to be + * powered-up. The sequencer may already have powered-up the device in which + * case the function returns 0. If the power-up sequence is already in + * progress, the function will block until it's done and return 0. If this is + * the first request, the device will be powered up. + * + * Returns: + * 0 on success, negative error number on failure. + */ +int pwrseq_power_on(struct pwrseq_desc *desc) +{ + struct pwrseq_device *pwrseq; + struct pwrseq_target *target; + struct pwrseq_unit *unit; + int ret; + + might_sleep(); + + if (!desc || desc->powered_on) + return 0; + + pwrseq = desc->pwrseq; + target = desc->target; + unit = target->unit; + + guard(rwsem_read)(&pwrseq->rw_lock); + if (!device_is_registered(&pwrseq->dev)) + return -ENODEV; + + scoped_guard(mutex, &pwrseq->state_lock) { + ret = pwrseq_unit_enable(pwrseq, unit); + if (!ret) + desc->powered_on = true; + } + + if (target->post_enable) { + ret = target->post_enable(pwrseq); + if (ret) { + pwrseq_unit_disable(pwrseq, unit); + desc->powered_on = false; + } + } + + return ret; +} +EXPORT_SYMBOL_GPL(pwrseq_power_on); + +/** + * pwrseq_power_off() - Issue a power-off request on behalf of the consumer + * device. + * @desc: Descriptor referencing the power sequencer. + * + * This undoes the effects of pwrseq_power_on(). It issues a power-off request + * on behalf of the consumer and when the last remaining user does so, the + * power-down sequence will be started. If one is in progress, the function + * will block until it's complete and then return. + * + * Returns: + * 0 on success, negative error number on failure. + */ +int pwrseq_power_off(struct pwrseq_desc *desc) +{ + struct pwrseq_device *pwrseq; + struct pwrseq_unit *unit; + int ret; + + might_sleep(); + + if (!desc || !desc->powered_on) + return 0; + + pwrseq = desc->pwrseq; + unit = desc->target->unit; + + guard(rwsem_read)(&pwrseq->rw_lock); + if (!device_is_registered(&pwrseq->dev)) + return -ENODEV; + + guard(mutex)(&pwrseq->state_lock); + + ret = pwrseq_unit_disable(pwrseq, unit); + if (!ret) + desc->powered_on = false; + + return ret; +} +EXPORT_SYMBOL_GPL(pwrseq_power_off); + +#if IS_ENABLED(CONFIG_DEBUG_FS) + +struct pwrseq_debugfs_count_ctx { + struct device *dev; + loff_t index; +}; + +static int pwrseq_debugfs_seq_count(struct device *dev, void *data) +{ + struct pwrseq_debugfs_count_ctx *ctx = data; + + ctx->dev = dev; + + return ctx->index-- ? 0 : 1; +} + +static void *pwrseq_debugfs_seq_start(struct seq_file *seq, loff_t *pos) +{ + struct pwrseq_debugfs_count_ctx ctx; + + ctx.dev = NULL; + ctx.index = *pos; + + /* + * We're holding the lock for the entire printout so no need to fiddle + * with device reference count. + */ + down_read(&pwrseq_sem); + + bus_for_each_dev(&pwrseq_bus, NULL, &ctx, pwrseq_debugfs_seq_count); + if (!ctx.index) + return NULL; + + return ctx.dev; +} + +static void *pwrseq_debugfs_seq_next(struct seq_file *seq, void *data, + loff_t *pos) +{ + struct device *curr = data; + + ++*pos; + + struct device *next __free(put_device) = + bus_find_next_device(&pwrseq_bus, curr); + return next; +} + +static void pwrseq_debugfs_seq_show_target(struct seq_file *seq, + struct pwrseq_target *target) +{ + seq_printf(seq, " target: [%s] (target unit: [%s])\n", + target->name, target->unit->name); +} + +static void pwrseq_debugfs_seq_show_unit(struct seq_file *seq, + struct pwrseq_unit *unit) +{ + struct pwrseq_unit_dep *ref; + + seq_printf(seq, " unit: [%s] - enable count: %u\n", + unit->name, unit->enable_count); + + if (list_empty(&unit->deps)) + return; + + seq_puts(seq, " dependencies:\n"); + list_for_each_entry(ref, &unit->deps, list) + seq_printf(seq, " [%s]\n", ref->unit->name); +} + +static int pwrseq_debugfs_seq_show(struct seq_file *seq, void *data) +{ + struct device *dev = data; + struct pwrseq_device *pwrseq = to_pwrseq_device(dev); + struct pwrseq_target *target; + struct pwrseq_unit *unit; + + seq_printf(seq, "%s:\n", dev_name(dev)); + + seq_puts(seq, " targets:\n"); + list_for_each_entry(target, &pwrseq->targets, list) + pwrseq_debugfs_seq_show_target(seq, target); + + seq_puts(seq, " units:\n"); + list_for_each_entry(unit, &pwrseq->units, list) + pwrseq_debugfs_seq_show_unit(seq, unit); + + return 0; +} + +static void pwrseq_debugfs_seq_stop(struct seq_file *seq, void *data) +{ + up_read(&pwrseq_sem); +} + +static const struct seq_operations pwrseq_debugfs_sops = { + .start = pwrseq_debugfs_seq_start, + .next = pwrseq_debugfs_seq_next, + .show = pwrseq_debugfs_seq_show, + .stop = pwrseq_debugfs_seq_stop, +}; +DEFINE_SEQ_ATTRIBUTE(pwrseq_debugfs); + +static struct dentry *pwrseq_debugfs_dentry; + +#endif /* CONFIG_DEBUG_FS */ + +static int __init pwrseq_init(void) +{ + int ret; + + ret = bus_register(&pwrseq_bus); + if (ret) { + pr_err("Failed to register the power sequencer bus\n"); + return ret; + } + +#if IS_ENABLED(CONFIG_DEBUG_FS) + pwrseq_debugfs_dentry = debugfs_create_file("pwrseq", 0444, NULL, NULL, + &pwrseq_debugfs_fops); +#endif /* CONFIG_DEBUG_FS */ + + return 0; +} +subsys_initcall(pwrseq_init); + +static void __exit pwrseq_exit(void) +{ +#if IS_ENABLED(CONFIG_DEBUG_FS) + debugfs_remove_recursive(pwrseq_debugfs_dentry); +#endif /* CONFIG_DEBUG_FS */ + + bus_unregister(&pwrseq_bus); +} +module_exit(pwrseq_exit); + +MODULE_AUTHOR("Bartosz Golaszewski "); +MODULE_DESCRIPTION("Power Sequencing subsystem core"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/pwrseq/consumer.h b/include/linux/pwrseq/consumer.h new file mode 100644 index 000000000000..7d583b4f266e --- /dev/null +++ b/include/linux/pwrseq/consumer.h @@ -0,0 +1,56 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024 Linaro Ltd. + */ + +#ifndef __POWER_SEQUENCING_CONSUMER_H__ +#define __POWER_SEQUENCING_CONSUMER_H__ + +#include + +struct device; +struct pwrseq_desc; + +#if IS_ENABLED(CONFIG_POWER_SEQUENCING) + +struct pwrseq_desc * __must_check +pwrseq_get(struct device *dev, const char *target); +void pwrseq_put(struct pwrseq_desc *desc); + +struct pwrseq_desc * __must_check +devm_pwrseq_get(struct device *dev, const char *target); + +int pwrseq_power_on(struct pwrseq_desc *desc); +int pwrseq_power_off(struct pwrseq_desc *desc); + +#else /* CONFIG_POWER_SEQUENCING */ + +static inline struct pwrseq_desc * __must_check +pwrseq_get(struct device *dev, const char *target) +{ + return ERR_PTR(-ENOSYS); +} + +static inline void pwrseq_put(struct pwrseq_desc *desc) +{ +} + +static inline struct pwrseq_desc * __must_check +devm_pwrseq_get(struct device *dev, const char *target) +{ + return ERR_PTR(-ENOSYS); +} + +static inline int pwrseq_power_on(struct pwrseq_desc *desc) +{ + return -ENOSYS; +} + +static inline int pwrseq_power_off(struct pwrseq_desc *desc) +{ + return -ENOSYS; +} + +#endif /* CONFIG_POWER_SEQUENCING */ + +#endif /* __POWER_SEQUENCING_CONSUMER_H__ */ diff --git a/include/linux/pwrseq/provider.h b/include/linux/pwrseq/provider.h new file mode 100644 index 000000000000..e627ed2f4d91 --- /dev/null +++ b/include/linux/pwrseq/provider.h @@ -0,0 +1,75 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2024 Linaro Ltd. + */ + +#ifndef __POWER_SEQUENCING_PROVIDER_H__ +#define __POWER_SEQUENCING_PROVIDER_H__ + +struct device; +struct module; +struct pwrseq_device; + +typedef int (*pwrseq_power_state_func)(struct pwrseq_device *); +typedef int (*pwrseq_match_func)(struct pwrseq_device *, struct device *); + +/** + * struct pwrseq_unit_data - Configuration of a single power sequencing + * unit. + * @name: Name of the unit. + * @deps: Units that must be enabled before this one and disabled after it + * in the order they come in this array. + * @enable: Callback running the part of the power-on sequence provided by + * this unit. + * @disable: Callback running the part of the power-off sequence provided + * by this unit. + */ +struct pwrseq_unit_data { + const char *name; + const struct pwrseq_unit_data **deps; + pwrseq_power_state_func enable; + pwrseq_power_state_func disable; +}; + +/** + * struct pwrseq_target_data - Configuration of a power sequencing target. + * @name: Name of the target. + * @unit: Final unit that this target must reach in order to be considered + * enabled. + * @post_enable: Callback run after the target unit has been enabled, *after* + * the state lock has been released. It's useful for implementing + * boot-up delays without blocking other users from powering up + * using the same power sequencer. + */ +struct pwrseq_target_data { + const char *name; + const struct pwrseq_unit_data *unit; + pwrseq_power_state_func post_enable; +}; + +/** + * struct pwrseq_config - Configuration used for registering a new provider. + * @parent: Parent device for the sequencer. Must be set. + * @owner: Module providing this device. + * @drvdata: Private driver data. + * @match: Provider callback used to match the consumer device to the sequencer. + * @targets: Array of targets for this power sequencer. Must be NULL-terminated. + */ +struct pwrseq_config { + struct device *parent; + struct module *owner; + void *drvdata; + pwrseq_match_func match; + const struct pwrseq_target_data **targets; +}; + +struct pwrseq_device * +pwrseq_device_register(const struct pwrseq_config *config); +void pwrseq_device_unregister(struct pwrseq_device *pwrseq); +struct pwrseq_device * +devm_pwrseq_device_register(struct device *dev, + const struct pwrseq_config *config); + +void *pwrseq_device_get_drvdata(struct pwrseq_device *pwrseq); + +#endif /* __POWER_SEQUENCING_PROVIDER_H__ */ From patchwork Fri Feb 16 20:32:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 774062 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE465154BEA for ; Fri, 16 Feb 2024 20:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115623; cv=none; b=Lk4X0eLiYVtmmKtXNmXaTKA2rKEI+YZzOqrDkulQNDH9SXvalXFbIL2KaPJbGApke7HcXmAiVm1ZtEvXvSoi7Fe35zyZw1coHAvmVOrMqIMmOkigtY6h3oecOTl68H3+SiIqb2yPUYmvQQl4n575USWxcDHf1wYunlEC07KNssY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115623; c=relaxed/simple; bh=uxQvnPI8/bGrVMuVI5gjeJIZtyIinJjoJ9no/gq7xoY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=U8OaD0tfjEfrz8NbgGKGV9fiU6SncUiooBlvEEVc2pShZ/eMEdzam2O2izjMFi2xhyoVwFqSRf8qtoLGhFYxBoNrPeM+iyDYY1xrF0mZzuJT8R+U56rnIwd/CiBsJcDlC5gYb4+28Q6iGAU9Q8M33MLk+YhjdoqwCDm1AFvUXk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=ima8Razl; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="ima8Razl" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3394b892691so1621246f8f.1 for ; Fri, 16 Feb 2024 12:33:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115617; x=1708720417; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EQHWuFoizOSDk7qTx/YRGg03f0p2QHBA18E+Wk2phRk=; b=ima8RazlHxQgrhYUtLazcByVb/KfgI7dsyQqZ0aIfBHwMqW4I47iJlZk4IGfnGQJIA ehB9c1mG0+kpBC3Gx7/qr2Ne9bqIYra099A7WMajVzhs/X1HXDh9B0NYLV+wLDEynaAa bPagwOVue6iYIKRXn5Ev8bxDzBB8nLvEboYDbA5H7Z3o3H2rrCGICZohoSNXyTjUIp5u sYMq2ozIzJhwNF5yQdcZiAdekbVfJ58LS8RhLe2jcjjFfcREpZcWtZ8lkttQFror3h/X sphpIQ4AUHc1FmNebvywyEuZGp5qC9kRg8/N/VrtY5Zobvcc7ENnnhSkF0v2i+j7vXrp qCZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115617; x=1708720417; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EQHWuFoizOSDk7qTx/YRGg03f0p2QHBA18E+Wk2phRk=; b=I2wk9JeAoIq6vhuZh9ku2W/eLwI5rOC6UdWX7XuD7/r2HioLihiNhFu04SzovcyyHf M2RceLySpzhfw4NiXBeG5i2rMwUHVxgdauf9b0T83DmCvZadfsjJ8OSxu4NKsdtVy1Bp vG2wh6YCUV3bIMOwgC6tzHShpCLnfzXOP5xhb21doyoIRlc5ZL+BfsLZ5oo5ARgjucG7 4pD0itub+11WdcgBPSRpTfr86j9FdWAZna6bJEuQWlZ3MS4oehLWLsJcNm5WhgtW+Fsx g8CAUBpCwRZ/Uut0GlzmSZa9vLc/kpqD0rOO6Noyak87R5hyF+pTa/UC8N799DtfmLTJ Ng0A== X-Forwarded-Encrypted: i=1; AJvYcCVAULfG1CjGDMuEdAv1/ZHkhGY3AO2LII05EmXL/A/JJG1WwxBsa9vWKKNMj8dMFz2JhGKk7dGl0xJ6FYzw3yJOqz1wBTw2sLH0eFDhv0c= X-Gm-Message-State: AOJu0Yw8BSz6JgREEVrPxvQt1K4pFV9fIe94yqDhHhkK8xnB10orCGKH fRghayKRw2ISfEnazSVct0XjyYXivj6gKp8eAm+m0JHTrEGg78BDVCBeyF7LT+c= X-Google-Smtp-Source: AGHT+IGinJo+FpgyRjl2kJ/ySAi2AYljBCrn99NoRGeBpUSzr8brtEvQeJbO+Rn9M6cn5QFIJHX91A== X-Received: by 2002:adf:fd0b:0:b0:33d:119e:2ca1 with SMTP id e11-20020adffd0b000000b0033d119e2ca1mr3839965wrr.5.1708115616769; Fri, 16 Feb 2024 12:33:36 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:36 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 16/18] power: pwrseq: add a driver for the QCA6390 PMU module Date: Fri, 16 Feb 2024 21:32:13 +0100 Message-Id: <20240216203215.40870-17-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski This adds the power sequencing driver for the QCA6390's PMU module. It uses the pwrseq subsystem and knows how to match the sequencer to the consumer device by verifying the relevant properties and DT layout. Signed-off-by: Bartosz Golaszewski --- drivers/power/sequencing/Kconfig | 16 + drivers/power/sequencing/Makefile | 2 + drivers/power/sequencing/pwrseq-qca6390.c | 353 ++++++++++++++++++++++ 3 files changed, 371 insertions(+) create mode 100644 drivers/power/sequencing/pwrseq-qca6390.c diff --git a/drivers/power/sequencing/Kconfig b/drivers/power/sequencing/Kconfig index ba5732b1dbf8..84ddf3b4ae56 100644 --- a/drivers/power/sequencing/Kconfig +++ b/drivers/power/sequencing/Kconfig @@ -10,3 +10,19 @@ menuconfig POWER_SEQUENCING during power-up. If unsure, say no. + +if POWER_SEQUENCING + +config POWER_SEQUENCING_QCA6390 + tristate "QCA6390 PMU driver" + default m if ARCH_QCOM + help + Say U here to enable the power sequencing driver for Qualcomm + QCA6390. + + The QCA6390 package contains the BT and WLAN modules whose power + is controlled by the PMU module. As the former two share the power-up + sequence which is executed by the PMU, this driver is needed for + correct power control. + +endif diff --git a/drivers/power/sequencing/Makefile b/drivers/power/sequencing/Makefile index dcdf8c0c159e..628345c4e7ae 100644 --- a/drivers/power/sequencing/Makefile +++ b/drivers/power/sequencing/Makefile @@ -2,3 +2,5 @@ obj-$(CONFIG_POWER_SEQUENCING) += pwrseq-core.o pwrseq-core-y := core.o + +obj-$(CONFIG_POWER_SEQUENCING_QCA6390) += pwrseq-qca6390.o diff --git a/drivers/power/sequencing/pwrseq-qca6390.c b/drivers/power/sequencing/pwrseq-qca6390.c new file mode 100644 index 000000000000..5f254f9c71d7 --- /dev/null +++ b/drivers/power/sequencing/pwrseq-qca6390.c @@ -0,0 +1,353 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2024 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct pwrseq_qca6390_vreg { + const char *name; + unsigned int load_uA; +}; + +struct pwrseq_qca6390_pdata { + const struct pwrseq_qca6390_vreg *vregs_common; + size_t num_vregs_common; + const struct pwrseq_qca6390_vreg *vregs_wlan; + size_t num_vregs_wlan; + unsigned int pwup_delay_msec; +}; + +struct pwrseq_qca6390_ctx { + struct pwrseq_device *pwrseq; + struct device_node *of_node; + const struct pwrseq_qca6390_pdata *pdata; + struct regulator_bulk_data *regs_common; + struct regulator_bulk_data *regs_wlan; + struct gpio_desc *bt_gpio; + struct gpio_desc *wlan_gpio; + unsigned long last_gpio_enable; +}; + +static const struct pwrseq_qca6390_vreg pwrseq_qca6390_vregs_common[] = { + { + .name = "vddio", + .load_uA = 20000, + }, + { + .name = "vddaon", + .load_uA = 100000, + }, + { + .name = "vddpmu", + .load_uA = 1250000, + }, + { + .name = "vddrfa0p95", + .load_uA = 200000, + }, + { + .name = "vddrfa1p3", + .load_uA = 400000, + }, + { + .name = "vddrfa1p9", + .load_uA = 400000, + }, +}; + +static const struct pwrseq_qca6390_vreg pwrseq_qca6390_vregs_wlan[] = { + { + .name = "vddpcie1p3", + .load_uA = 35000, + }, + { + .name = "vddpcie1p9", + .load_uA = 15000, + }, +}; + +static void pwrseq_qca6390_ensure_gpio_delay(struct pwrseq_qca6390_ctx *ctx) +{ + unsigned long diff_jiffies = jiffies - ctx->last_gpio_enable; + unsigned int diff_msecs = jiffies_to_msecs(diff_jiffies); + + if (diff_msecs < 100) + msleep(100 - diff_msecs); +} + +static const struct pwrseq_qca6390_pdata pwrseq_qca6390_of_data = { + .vregs_common = pwrseq_qca6390_vregs_common, + .num_vregs_common = ARRAY_SIZE(pwrseq_qca6390_vregs_common), + .vregs_wlan = pwrseq_qca6390_vregs_wlan, + .num_vregs_wlan = ARRAY_SIZE(pwrseq_qca6390_vregs_wlan), + .pwup_delay_msec = 16, +}; + +static int pwrseq_qca6390_vregs_enable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_qca6390_ctx *ctx = pwrseq_device_get_drvdata(pwrseq); + + return regulator_bulk_enable(ctx->pdata->num_vregs_common, + ctx->regs_common); +} + +static int pwrseq_qca6390_vregs_disable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_qca6390_ctx *ctx = pwrseq_device_get_drvdata(pwrseq); + + return regulator_bulk_disable(ctx->pdata->num_vregs_common, + ctx->regs_common); +} + +static const struct pwrseq_unit_data pwrseq_qca6390_vregs_unit_data = { + .name = "regulators-enable", + .enable = pwrseq_qca6390_vregs_enable, + .disable = pwrseq_qca6390_vregs_disable, +}; + +static const struct pwrseq_unit_data *pwrseq_qca6390_unit_deps[] = { + &pwrseq_qca6390_vregs_unit_data, + NULL +}; + +static int pwrseq_qca6390_bt_enable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_qca6390_ctx *ctx = pwrseq_device_get_drvdata(pwrseq); + + pwrseq_qca6390_ensure_gpio_delay(ctx); + gpiod_set_value_cansleep(ctx->bt_gpio, 1); + ctx->last_gpio_enable = jiffies; + + return 0; +} + +static int pwrseq_qca6390_bt_disable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_qca6390_ctx *ctx = pwrseq_device_get_drvdata(pwrseq); + + gpiod_set_value_cansleep(ctx->bt_gpio, 0); + + return 0; +} + +static const struct pwrseq_unit_data pwrseq_qca6390_bt_unit_data = { + .name = "bluetooth-enable", + .deps = pwrseq_qca6390_unit_deps, + .enable = pwrseq_qca6390_bt_enable, + .disable = pwrseq_qca6390_bt_disable, +}; + +static int pwrseq_qca6390_wlan_enable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_qca6390_ctx *ctx = pwrseq_device_get_drvdata(pwrseq); + int ret; + + ret = regulator_bulk_enable(ctx->pdata->num_vregs_wlan, ctx->regs_wlan); + if (ret) + return ret; + + pwrseq_qca6390_ensure_gpio_delay(ctx); + gpiod_set_value_cansleep(ctx->wlan_gpio, 1); + ctx->last_gpio_enable = jiffies; + + return 0; +} + +static int pwrseq_qca6390_wlan_disable(struct pwrseq_device *pwrseq) +{ + struct pwrseq_qca6390_ctx *ctx = pwrseq_device_get_drvdata(pwrseq); + + gpiod_set_value_cansleep(ctx->wlan_gpio, 0); + + return regulator_bulk_disable(ctx->pdata->num_vregs_wlan, + ctx->regs_wlan); +} + +static const struct pwrseq_unit_data pwrseq_qca6390_wlan_unit_data = { + .name = "wlan-enable", + .deps = pwrseq_qca6390_unit_deps, + .enable = pwrseq_qca6390_wlan_enable, + .disable = pwrseq_qca6390_wlan_disable, +}; + +static int pwrseq_qca6390_pwup_delay(struct pwrseq_device *pwrseq) +{ + struct pwrseq_qca6390_ctx *ctx = pwrseq_device_get_drvdata(pwrseq); + + if (ctx->pdata->pwup_delay_msec) + msleep(ctx->pdata->pwup_delay_msec); + + return 0; +} + +static const struct pwrseq_target_data pwrseq_qca6390_bt_target_data = { + .name = "bluetooth", + .unit = &pwrseq_qca6390_bt_unit_data, + .post_enable = pwrseq_qca6390_pwup_delay, +}; + +static const struct pwrseq_target_data pwrseq_qca6390_wlan_target_data = { + .name = "wlan", + .unit = &pwrseq_qca6390_wlan_unit_data, + .post_enable = pwrseq_qca6390_pwup_delay, +}; + +static const struct pwrseq_target_data *pwrseq_qca6390_targets[] = { + &pwrseq_qca6390_bt_target_data, + &pwrseq_qca6390_wlan_target_data, + NULL +}; + +static int pwrseq_qca6390_match(struct pwrseq_device *pwrseq, + struct device *dev) +{ + struct pwrseq_qca6390_ctx *ctx = pwrseq_device_get_drvdata(pwrseq); + struct device_node *dev_node = dev->of_node; + + /* + * The PMU supplies power to the Bluetooth and WLAN modules. both + * consume the PMU AON output so check the presence of the + * 'vddaon-supply' property and whether it leads us to the right + * device. + */ + if (!of_property_present(dev_node, "vddaon-supply")) + return 0; + + struct device_node *reg_node __free(device_node) = + of_parse_phandle(dev_node, "vddaon-supply", 0); + if (!reg_node) + return 0; + + /* + * `reg_node` is the PMU AON regulator, its parent is the `regulators` + * node and finally its grandparent is the PMU device node that we're + * looking for. + */ + if (!reg_node->parent || !reg_node->parent->parent || + reg_node->parent->parent != ctx->of_node) + return 0; + + return 1; +} + +static struct regulator_bulk_data * +pwrseq_qca6390_get_regs(struct device *dev, size_t num_regs, + const struct pwrseq_qca6390_vreg *pdata) +{ + struct regulator_bulk_data *regs; + int ret, i; + + regs = devm_kcalloc(dev, num_regs, sizeof(*regs), GFP_KERNEL); + if (!regs) + return ERR_PTR(-ENOMEM); + + for (i = 0; i < num_regs; i++) + regs[i].supply = pdata[i].name; + + ret = devm_regulator_bulk_get(dev, num_regs, regs); + if (ret < 0) + return ERR_PTR(ret); + + for (i = 0; i < num_regs; i++) { + if (!pdata[i].load_uA) + continue; + + ret = regulator_set_load(regs[i].consumer, pdata[i].load_uA); + if (ret) + return ERR_PTR(ret); + } + + return regs; +} + +static int pwrseq_qca6390_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct pwrseq_qca6390_ctx *ctx; + struct pwrseq_config config; + + ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ctx->of_node = dev->of_node; + + ctx->pdata = of_device_get_match_data(dev); + if (!ctx->pdata) + return dev_err_probe(dev, -ENODEV, + "Failed to obtain platform data\n"); + + ctx->regs_common = pwrseq_qca6390_get_regs(dev, + ctx->pdata->num_vregs_common, + ctx->pdata->vregs_common); + if (IS_ERR(ctx->regs_common)) + return dev_err_probe(dev, PTR_ERR(ctx->regs_common), + "Failed to get all regulators\n"); + + ctx->regs_wlan = pwrseq_qca6390_get_regs(dev, + ctx->pdata->num_vregs_wlan, + ctx->pdata->vregs_wlan); + if (IS_ERR(ctx->regs_wlan)) + return dev_err_probe(dev, PTR_ERR(ctx->regs_wlan), + "Failed to get all regulators\n"); + + ctx->bt_gpio = devm_gpiod_get_optional(dev, "bt-enable", GPIOD_OUT_LOW); + if (IS_ERR(ctx->bt_gpio)) + return dev_err_probe(dev, PTR_ERR(ctx->bt_gpio), + "Failed to get the Bluetooth enable GPIO\n"); + + ctx->wlan_gpio = devm_gpiod_get_optional(dev, "wlan-enable", + GPIOD_OUT_LOW); + if (IS_ERR(ctx->wlan_gpio)) + return dev_err_probe(dev, PTR_ERR(ctx->wlan_gpio), + "Failed to get the WLAN enable GPIO\n"); + + memset(&config, 0, sizeof(config)); + + config.parent = dev; + config.owner = THIS_MODULE; + config.drvdata = ctx; + config.match = pwrseq_qca6390_match; + config.targets = pwrseq_qca6390_targets; + + ctx->pwrseq = devm_pwrseq_device_register(dev, &config); + if (IS_ERR(ctx->pwrseq)) + return dev_err_probe(dev, PTR_ERR(ctx->pwrseq), + "Failed to register the power sequencer\n"); + + return 0; +} + +static const struct of_device_id pwrseq_qca6390_of_match[] = { + { + .compatible = "qcom,qca6390-pmu", + .data = &pwrseq_qca6390_of_data, + }, + { } +}; +MODULE_DEVICE_TABLE(of, pwrseq_qca6390_of_match); + +static struct platform_driver pwrseq_qca6390_driver = { + .driver = { + .name = "pwrseq-qca6390", + .of_match_table = pwrseq_qca6390_of_match, + }, + .probe = pwrseq_qca6390_probe, +}; +module_platform_driver(pwrseq_qca6390_driver); + +MODULE_AUTHOR("Bartosz Golaszewski "); +MODULE_DESCRIPTION("QCA6390 PMU power sequencing driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Feb 16 20:32:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 774061 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44272154C1C for ; Fri, 16 Feb 2024 20:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115624; cv=none; b=DfKo0jsNT7PpQIU6/pkkNlrz2PB+fdGDxyE/muy3Xqe1k/Bj68MhdQeNpYS01oiXLXeZ6iIsQQocztxJbzxLBUwPtnmptjkwjWgVHfkrl1vkVVMfBRIHfdffTsMFiNqtojzCwZHth1l+BnNBIdwFeCMiW27xU/yrSfsSSovji+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115624; c=relaxed/simple; bh=uljvXxVDpjLWioO7DI8DpfhUCiBQy2gqLlZzbqfC6rk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RnruunEbd6C4j+B57r/Zw/dXRP/KcWnyPYfGyEfJJyb+MA7QJKPDn1qtq39LIzlD2ABrZerqeQ1YD6bi55Q3/K2kRvK5lY4kSzBc9bhsvZx5+1qVZYIIkzWb8pSMmKB0Xye1HtGN/pWuOuPeJCGvqantTm47jjDzI3Sr6dYxOXY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=V+le+COp; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="V+le+COp" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2d10f52e7d8so27264611fa.3 for ; Fri, 16 Feb 2024 12:33:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115618; x=1708720418; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0uwXThQ+QNJ1YUcFKYkH+xTMKxSP1HSsH1gWvVHVIOI=; b=V+le+COpES3rzhzVkrdn4DxtzXuOAw0tE8JdWra0ezkowznSetxsc6HeplrfocJW3m 1ZP6ZL1oY8BKpW1yfY1VqifVkhhLXTAcw+dFeKVcskePCazEzV/ysTSMBzfjRdZfMhtO lIKtosZX71EB32XBCC2XYDGobjcLO6xoJGFw8I9/bK3qHLdWjKYHIYvT4Lx9KJqJ+Bzb vUqQpahzE4iv4VdI/tfEEBhDEqTevGR6sL96gohZpeQ6XaQ1VrAF9DqC0omUU2PbIgwk Clk6Dq+UKJ5MWcDzf3f2HSUHvvwW/ZQIulpmI3vHefhtqQ/e5E3KHrU3+nDAIbxQJwI7 7+HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115618; x=1708720418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0uwXThQ+QNJ1YUcFKYkH+xTMKxSP1HSsH1gWvVHVIOI=; b=K89bCbrJKWfaT/z1fw2aT6gI7Qqx4kJEmQsXOkdjFegvXJRcmxb+PuMJKdCxwGCcl7 R6XU0qi83BEi21MGq3wJ57Q2HXOUDOvA8UOa4G3O+iVHL/w5zPebzKbsf4rrduH5kljy roit21Bs1lUGVnH+2LqysNaSZqg/l4N5n76TLdafv6utl9+gyQnIYQxV6KaYB9fPG6pU VlolhTxC5BSEYV7M4AaYNc3QoThlFSLWdFzvMQyZz6iI1TEQyWX2qVPTH0HEh5Q9zWRu 8qMjgI4h17odIRJP2MKJdqoxLA5/K4Otvmv1h24fiLuB8tMZs4ICMDm8Swv5OgHfsRmS 3JQg== X-Forwarded-Encrypted: i=1; AJvYcCVDjT9qDIJMy1/iycBocwrp0k5XtfQ65juGfnkLdBCS+rshPXAnnezLckfFPCpNf+EqLkC1KfbIJlxzBprsmMor9K6XBHpycrUuh1leHew= X-Gm-Message-State: AOJu0YxfWunL7hd37chbf9kxTXV/6d4yIGM/n1yERwGXqfsSAVAxMOUx L+Dcw78PKC79RihLfTa4VUVSB3Lqaps4M5r2Fv7HPMkbu1B5TweKyxBH4SWRlw8= X-Google-Smtp-Source: AGHT+IF7BFIzhFkzuOLkmprDQ2Up8MWLKknrN8msVe4koNW57AcePamcT2Ya3gh+sU9bXgW3MuxO5g== X-Received: by 2002:a2e:a36a:0:b0:2d0:ffe3:db07 with SMTP id i10-20020a2ea36a000000b002d0ffe3db07mr4323626ljn.25.1708115618351; Fri, 16 Feb 2024 12:33:38 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:37 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 17/18] Bluetooth: qca: use the power sequencer for QCA6390 Date: Fri, 16 Feb 2024 21:32:14 +0100 Message-Id: <20240216203215.40870-18-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Use the pwrseq subsystem's consumer API to run the power-up sequence for the Bluetooth module of the QCA6390 package. Signed-off-by: Bartosz Golaszewski --- drivers/bluetooth/hci_qca.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index edd2a81b4d5e..6e747db30492 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -215,6 +216,7 @@ struct qca_power { struct regulator_bulk_data *vreg_bulk; int num_vregs; bool vregs_on; + struct pwrseq_desc *pwrseq; }; struct qca_serdev { @@ -1792,6 +1794,11 @@ static int qca_power_on(struct hci_dev *hdev) ret = qca_regulator_init(hu); break; + case QCA_QCA6390: + qcadev = serdev_device_get_drvdata(hu->serdev); + ret = pwrseq_power_on(qcadev->bt_power->pwrseq); + break; + default: qcadev = serdev_device_get_drvdata(hu->serdev); if (qcadev->bt_en) { @@ -2170,6 +2177,10 @@ static void qca_power_shutdown(struct hci_uart *hu) } break; + case QCA_QCA6390: + pwrseq_power_off(qcadev->bt_power->pwrseq); + break; + default: gpiod_set_value_cansleep(qcadev->bt_en, 0); } @@ -2308,12 +2319,25 @@ static int qca_serdev_probe(struct serdev_device *serdev) case QCA_WCN6750: case QCA_WCN6855: case QCA_WCN7850: + case QCA_QCA6390: qcadev->bt_power = devm_kzalloc(&serdev->dev, sizeof(struct qca_power), GFP_KERNEL); if (!qcadev->bt_power) return -ENOMEM; + break; + default: + break; + } + switch (qcadev->btsoc_type) { + case QCA_WCN3988: + case QCA_WCN3990: + case QCA_WCN3991: + case QCA_WCN3998: + case QCA_WCN6750: + case QCA_WCN6855: + case QCA_WCN7850: qcadev->bt_power->dev = &serdev->dev; err = qca_init_regulators(qcadev->bt_power, data->vregs, data->num_vregs); @@ -2354,6 +2378,13 @@ static int qca_serdev_probe(struct serdev_device *serdev) } break; + case QCA_QCA6390: + qcadev->bt_power->pwrseq = devm_pwrseq_get(&serdev->dev, + "bluetooth"); + if (IS_ERR(qcadev->bt_power->pwrseq)) + return PTR_ERR(qcadev->bt_power->pwrseq); + fallthrough; + default: qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable", GPIOD_OUT_LOW); From patchwork Fri Feb 16 20:32:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 773671 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F2541552FD for ; Fri, 16 Feb 2024 20:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115625; cv=none; b=gNfM+fgiYYczx/RY2EkXJkBeDBue/CNw/PEsRn/hLpoqFRA4yKdaJtfuRBXgQPv+mghOowZEAdRo+FZopqNLmjTW88m/6cTKWdV4sxHi3y0TutvET8pbrz8zc08kwexKIiZk4KnnRiXOplrrsWwNTkaU8AYxmLKq0C5LVfsl+9U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708115625; c=relaxed/simple; bh=l7BCMdtK460/NfNyVFkhn6WxPhHDN9NJk1dX5OE3xb4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YINu9WBoFv3lvIuxJMpTpnmR57tnLEA77gdsfcVHzJCqW9z7+XFzTnvY27hHHn4A8feYm7JBq3NW2G7ob42xRU+/jtIai3hY68jAsbNYzQ5HCePty+T2z5lnFlfmpyi63qcmNJZFq9Q9bN/HMZ+LRQAp9ol2oBDL50bF5hRP3yw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=AbkrsG4h; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="AbkrsG4h" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-41258904302so175475e9.3 for ; Fri, 16 Feb 2024 12:33:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1708115620; x=1708720420; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H+W//dfF0n/wy1LXmbmCGBv/0bG6tpfv/t9YAFDF8dg=; b=AbkrsG4hQozdqZIAuPuUwi6rboShfc+IbD8ZzU38JoHYU54EYvu5+IRAI/AZBtmGjF SNyCVX/wbfv8KwFnh8dOXq2QGD/byWIq5EppoOcTAwrDUh08EJhd9k4mY32qdpRG1iz7 5AQDmIaLXQhGVN6SBIdVseU09vRy9eC+p6+jhBkIh1HdEVKi88hs2PtCWDwsiitjqqoi 0BDFFaGoteZUSskckF+knIUgD68zDIH1lx7Cv0E1OkBocylB2h9+ojBklqMqLbacBIPS PCEoyccHC2UFBLUaMm6qRdnmijMTz1b4r0zzDudQD+P2fs9+BsV7letxEFv+BSlarZxE /3mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708115620; x=1708720420; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H+W//dfF0n/wy1LXmbmCGBv/0bG6tpfv/t9YAFDF8dg=; b=GDJCScsdf/xf2P8ohls0YlqdEikGD5LrqNWofIuVbSSVGpvgSaDYgNTMRX5DygVcLt gyxGRc2NGu/DHEJ5aA4n+BLkOocO723TvvgwC/3O7F3Os8jc2yAAPVOXlAeKg1K8M94f +OdfZRh2NOPiA5Orj+C3tcigrM4LON7/Pzms4PtG610CiU70zTgGHlLtvcJyCi+LxpPn t4z3Jy7gUoPey6y56r1mvkGOZLJt1qNKCK/b5dfW1pkwhsi2qvzH4adUivYUDXRbPoCe qkwREEdahV5Lt6F6ljCW9dTjJ+yr8HLkfw6K/zZFEaqwXpPtJcD0MPDJT0AdkidSvlX1 Llwg== X-Forwarded-Encrypted: i=1; AJvYcCVh3ndl+QbQ69Qcc7PIQx7Kcf3Raf8lHzuY7GbO8TxNx5ury7Ry/Vsrbc2gHL0c4MrYZzScIfSHePAndybhCNYD1JVh5VV51P8Q2nmn9SA= X-Gm-Message-State: AOJu0YzSEb5f28PxVGXERN2D4hJleQWJKCtAjoPTFIBSbcIGZZjHaR3r cG7rA2leBxQptCAXSrcUUsb0LbkZVqRr3RAxrX/oUp50qbBNXAbvGE89nb6Nvzk= X-Google-Smtp-Source: AGHT+IGBibCllNh8ll1Vx+GOheKaOUkavu0vOY90FybjEbw07Iwz+LAx2+7vA1a+b5lW/0606M1yCA== X-Received: by 2002:a05:600c:444b:b0:40f:e806:2f26 with SMTP id v11-20020a05600c444b00b0040fe8062f26mr4798554wmn.12.1708115619950; Fri, 16 Feb 2024 12:33:39 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:7758:12d:16:5f19]) by smtp.gmail.com with ESMTPSA id m5-20020a05600c4f4500b0041253d0acd6sm1420528wmq.47.2024.02.16.12.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 12:33:39 -0800 (PST) From: Bartosz Golaszewski To: Marcel Holtmann , Luiz Augusto von Dentz , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kalle Valo , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Catalin Marinas , Will Deacon , Bjorn Helgaas , Bartosz Golaszewski , Saravana Kannan , Geert Uytterhoeven , Arnd Bergmann , Neil Armstrong , Marek Szyprowski , Alex Elder , Srini Kandagatla , Greg Kroah-Hartman , Abel Vesa , Manivannan Sadhasivam , Lukas Wunner , Dmitry Baryshkov Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, linux-pm@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v5 18/18] PCI/pwrctl: add a PCI power control driver for power sequenced devices Date: Fri, 16 Feb 2024 21:32:15 +0100 Message-Id: <20240216203215.40870-19-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240216203215.40870-1-brgl@bgdev.pl> References: <20240216203215.40870-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Add a PCI power control driver that's capable of correctly powering up devices using the power sequencing subsystem. The first user of this driver is the ath11k module on QCA6390. Signed-off-by: Bartosz Golaszewski --- drivers/pci/pwrctl/Kconfig | 9 +++ drivers/pci/pwrctl/Makefile | 1 + drivers/pci/pwrctl/pci-pwrctl-pwrseq.c | 84 ++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 drivers/pci/pwrctl/pci-pwrctl-pwrseq.c diff --git a/drivers/pci/pwrctl/Kconfig b/drivers/pci/pwrctl/Kconfig index b91170ebfb49..3880a88aa73b 100644 --- a/drivers/pci/pwrctl/Kconfig +++ b/drivers/pci/pwrctl/Kconfig @@ -5,6 +5,15 @@ menu "PCI Power control drivers" config PCI_PWRCTL tristate +config PCI_PWRCTL_PWRSEQ + tristate "PCI Power Control driver using the Power Sequencing subsystem" + select POWER_SEQUENCING + select PCI_PWRCTL + default m if (ATH11K_PCI && ARCH_QCOM) + help + Enable support for the PCI power control driver for device + drivers using the Power Sequencing subsystem. + config PCI_PWRCTL_WCN7850 tristate "PCI Power Control driver for WCN7850" select PCI_PWRCTL diff --git a/drivers/pci/pwrctl/Makefile b/drivers/pci/pwrctl/Makefile index de20c3af1b78..47ab9db1fb42 100644 --- a/drivers/pci/pwrctl/Makefile +++ b/drivers/pci/pwrctl/Makefile @@ -3,4 +3,5 @@ obj-$(CONFIG_PCI_PWRCTL) += pci-pwrctl-core.o pci-pwrctl-core-y := core.o +obj-$(CONFIG_PCI_PWRCTL_PWRSEQ) += pci-pwrctl-pwrseq.o obj-$(CONFIG_PCI_PWRCTL_WCN7850) += pci-pwrctl-wcn7850.o diff --git a/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c b/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c new file mode 100644 index 000000000000..43820a727b3f --- /dev/null +++ b/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c @@ -0,0 +1,84 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2024 Linaro Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct pci_pwrctl_pwrseq_data { + struct pci_pwrctl ctx; + struct pwrseq_desc *pwrseq; +}; + +static void devm_pci_pwrctl_pwrseq_power_off(void *data) +{ + struct pwrseq_desc *pwrseq = data; + + pwrseq_power_off(pwrseq); +} + +static int pci_pwrctl_pwrseq_probe(struct platform_device *pdev) +{ + struct pci_pwrctl_pwrseq_data *data; + struct device *dev = &pdev->dev; + int ret; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->pwrseq = devm_pwrseq_get(dev, of_device_get_match_data(dev)); + if (IS_ERR(data->pwrseq)) + return dev_err_probe(dev, PTR_ERR(data->pwrseq), + "Failed to get the power sequencer\n"); + + ret = pwrseq_power_on(data->pwrseq); + if (ret) + return dev_err_probe(dev, ret, + "Failed to power-on the device\n"); + + ret = devm_add_action_or_reset(dev, devm_pci_pwrctl_pwrseq_power_off, + data->pwrseq); + if (ret) + return ret; + + data->ctx.dev = dev; + + ret = devm_pci_pwrctl_device_set_ready(dev, &data->ctx); + if (ret) + return dev_err_probe(dev, ret, + "Failed to register the pwrctl wrapper\n"); + + return 0; +} + +static const struct of_device_id pci_pwrctl_pwrseq_of_match[] = { + { + /* ATH11K in QCA6390 package. */ + .compatible = "pci17cb,1101", + .data = "wlan", + }, + { } +}; +MODULE_DEVICE_TABLE(of, pci_pwrctl_pwrseq_of_match); + +static struct platform_driver pci_pwrctl_pwrseq_driver = { + .driver = { + .name = "pci-pwrctl-pwrseq", + .of_match_table = pci_pwrctl_pwrseq_of_match, + }, + .probe = pci_pwrctl_pwrseq_probe, +}; +module_platform_driver(pci_pwrctl_pwrseq_driver); + +MODULE_AUTHOR("Bartosz Golaszewski "); +MODULE_DESCRIPTION("Generic PCI Power Control module for power sequenced devices"); +MODULE_LICENSE("GPL");