Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp291131lqp; Wed, 12 Jun 2024 01:24:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUS6O48SwwNl2GproFTMvAJ66DGW+v2dneNUlF4l/NQxkT1cyplvDuyOHXPqpGrFQIiZYwYU0DVv6A+Fmye5heaiCCYoT6YhsgyTNzIcQ== X-Google-Smtp-Source: AGHT+IGWVh0Ix4NQAOGPFL3Y3O7x9VKkuzMI6jjyqlTG9rGKXnFbibEn3Mxfci/83jwcExXU3j7Z X-Received: by 2002:a05:6808:10cd:b0:3d2:2490:5641 with SMTP id 5614622812f47-3d23e00ef4amr1478065b6e.17.1718180674551; Wed, 12 Jun 2024 01:24:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718180674; cv=pass; d=google.com; s=arc-20160816; b=R9luWRUcxH1gE07skbno9RZnMZyrr2PtKpz2oEiiEQ3tFaJDvqNfApCH535UHuuEr/ IZ+qY2iTIPmdpUCkhRyEORFPjuwVmNhkEBCjC9d2VjIVdBFO1SLDYjIRCVZ2Ccmkd9vf sCYsTPtn/lt7WYSNAhGKebnnr6DTYVewsEecCE3FBe0VSdreYpHrPL2I95Bx67NJm7Dq 9NttTxBAljmqs9HNXxGdFJBhtdvxxlVG7FFdbvpiZG7P0objqjsb569X72PZjAgWA6gj vNyLo6PJZS2u553M+WC/EgPE64ID1HKGLPyZ3fCAuJceS0w3819npRfuPdmQnEAcmO7b 9/ug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1cFlU09skU5ebmY9aZrVFHQpziQipb3LWw7NexBUGMI=; fh=yZps1dv0x8HTcVwHqv61CIg3atuzNLvnIddHsSL3P0c=; b=aKw7sn0kUdc1AnbBqRvL5MdMunvTuI2TBBvyvEz8MkzvX0eL4bnwzVR21VsOPme86t Z6OOLp1OU2Npet2cXPbYd2qM1oj+DxN9uo4WL8nBlODWRsaHc/RuocaruSgCjQQYns08 HvWUcFRAmpCwapVaDV+BW4evdb9xL3yMcZXV/H0SbfNaTTIG6Ht3JfuW58bQD8N7IYwJ kfKxGTOVs3yMqrwNGWf6ajc8vVYwz5hzwxxCGQpsji9UaOTTQ6sU3JgMYZz6g57b3XZT ZvO/rSHkP9OxAQ3rpMmzSOCVziRdg8DaqIhm0ePo9oh3DgUuSr0WLhuAYfOt5v5kN+Lw hqzA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=2DcswdaS; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-211171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211171-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-7059d26f1d5si4444486b3a.72.2024.06.12.01.24.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 01:24:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=2DcswdaS; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-211171-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211171-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1BAF12837A9 for ; Wed, 12 Jun 2024 08:22:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 665D416DED5; Wed, 12 Jun 2024 08:20:44 +0000 (UTC) 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="2DcswdaS" 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 D780716DEAD for ; Wed, 12 Jun 2024 08:20:41 +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=1718180443; cv=none; b=Rx3IjQl1iFsoj6svzGqii2WG3BLZM4ykzBUlv74E5u/6lHHWW0bjhHVH7XwJoN09vSZVOPiH4m/kTxEPFqJ5D1yeGVjoQMG6GM5Grq0ZsgNa99djK3BUy8HnTbFC/yqUKhQCYtejKxnxJtlCtQoYiAllJCD9F5EDNjix7JulIjo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718180443; c=relaxed/simple; bh=5vtUivy1WsDU2PhTRIW8MACVGYRRPVmSCnZVpABDwUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=no2fUGXgUOGhvARVPmiIy2XYlBlLie7gJVDn8NQPuE3aT0DH0I1DVOcv/m7CLribq4c/M6Yvryl6mGDb2PddjHFdxMj/BEjP3rI6nTx4iJz2MmCYoEuJ2hSl2lUhxJfd/qYa+ocSSpydmxOS9Vhq3UZKsdBqhFHWcWcPRQvR3bg= 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=2DcswdaS; 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 Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4217926991fso38597455e9.3 for ; Wed, 12 Jun 2024 01:20:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1718180439; x=1718785239; 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=1cFlU09skU5ebmY9aZrVFHQpziQipb3LWw7NexBUGMI=; b=2DcswdaSS6aZygc0pVThMlOZ9iOPckBFvB4vKU2FNRN/t1YpZ/WEbZOahc6aYhwqdA kIAEvAUVXKJYjAk030svcnbAHlPLQMRmd6Q6gBfO41nEzZfqSkgMqXPUc09xUSfSsYcY 3RaqvhMcuLYqA7BcXSCh4JD4Yr/eKQiOkPZFZudqLYhebKC4Ihfgr5PN7jtKv7+l2l0v DocbMezNCrVx4uF4uYfNcyC+1qvbR/p13ytPm1iyy2p73nOZpKg6+t18Qm0zuZFVvX4v neRM5OqubD8vBmnVL1Ogo7q4QUrSubadDKw3C0/kVNiWMgQzJUnbu9JOGRppZm/u2Tou zJOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718180439; x=1718785239; 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=1cFlU09skU5ebmY9aZrVFHQpziQipb3LWw7NexBUGMI=; b=IfCDn0tQyhCPZlumYoKB8SAYoaDZrbk8e3E8K6wKyQ1YvO7DgnLRYiPZXkjEge/oa5 MMavnU2msAxpwJDeAcHghE/rKc3+aFpeFkC98fnNnXna6fCyGJJ4DKL+wxaHCiIc9emI C5j9MX+ZFLBeZDi/fSbnapHvQFcN16ovtJmtSZgRIzkIYc8qckbIVlP22oQ1ea+9iGWO UugHW2+Dlory6ezYWFra9JPojsIspZJDOPj2lryW7ritdt10ouTGOkkSOf8sB9l3Ufen 9T0KoS4eWHcozgb7QvlXTTnb5rrc/MmyZLdGrg3U4nECd7Sk6YUxdz2paxgvjq+ohcEv SKgA== X-Gm-Message-State: AOJu0YyxJZiC2WPze5G/bopW//nN2G+AwhksiMSatXb6um+oDxpPk9KZ ix5IqKkWORDAznvizu8sTmEZioeilYqy9gHkefkQp3NwHEDCUT+kIqDkCxPP3z3YtAyYbWwXFHn F X-Received: by 2002:a05:600c:358b:b0:422:6765:2726 with SMTP id 5b1f17b1804b1-422865ad68fmr9616235e9.30.1718180439724; Wed, 12 Jun 2024 01:20:39 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:8d3:3800:a172:4e8b:453e:2f03]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4229207d1a7sm6011775e9.1.2024.06.12.01.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 01:20:39 -0700 (PDT) From: Bartosz Golaszewski To: Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Bartosz Golaszewski , Amit Pundir , Neil Armstrong , Caleb Connolly Subject: [PATCH v9 5/5] PCI/pwrctl: Add a PCI power control driver for power sequenced devices Date: Wed, 12 Jun 2024 10:20:18 +0200 Message-ID: <20240612082019.19161-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240612082019.19161-1-brgl@bgdev.pl> References: <20240612082019.19161-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Bartosz Golaszewski Add a PCI power control driver that's capable of correctly powering up devices using the power sequencing subsystem. The first users of this driver are the ath11k module on QCA6390 and ath12k on WCN7850. These packages require a certain delay between enabling the Bluetooth and WLAN modules and the power sequencing subsystem takes care of it behind the scenes. Tested-by: Amit Pundir Tested-by: Neil Armstrong # on SM8550-QRD, SM8650-QRD & SM8650-HDK Tested-by: Caleb Connolly # OnePlus 8T Acked-by: Bjorn Helgaas Signed-off-by: Bartosz Golaszewski --- drivers/pci/pwrctl/Kconfig | 9 +++ drivers/pci/pwrctl/Makefile | 2 + drivers/pci/pwrctl/pci-pwrctl-pwrseq.c | 89 ++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 drivers/pci/pwrctl/pci-pwrctl-pwrseq.c diff --git a/drivers/pci/pwrctl/Kconfig b/drivers/pci/pwrctl/Kconfig index 96195395af69..f1b824955d4b 100644 --- a/drivers/pci/pwrctl/Kconfig +++ b/drivers/pci/pwrctl/Kconfig @@ -5,4 +5,13 @@ 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 || ATH12K) && ARCH_QCOM) + help + Enable support for the PCI power control driver for device + drivers using the Power Sequencing subsystem. + endmenu diff --git a/drivers/pci/pwrctl/Makefile b/drivers/pci/pwrctl/Makefile index 52ae0640ef7b..d308aae4800c 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_PWRSEQ) += pci-pwrctl-pwrseq.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..c7a113a76c0c --- /dev/null +++ b/drivers/pci/pwrctl/pci-pwrctl-pwrseq.c @@ -0,0 +1,89 @@ +// 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", + }, + { + /* ATH12K in WCN7850 package. */ + .compatible = "pci17cb,1107", + .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"); -- 2.40.1