[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240611225643.GA1005995@bhelgaas>
Date: Tue, 11 Jun 2024 17:56:43 -0500
From: Bjorn Helgaas <helgaas@...nel.org>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Liam Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Marcel Holtmann <marcel@...tmann.org>,
Luiz Augusto von Dentz <luiz.dentz@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Balakrishna Godavarthi <quic_bgodavar@...cinc.com>,
Rocky Liao <quic_rjliao@...cinc.com>, Kalle Valo <kvalo@...nel.org>,
Jeff Johnson <jjohnson@...nel.org>,
Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konrad.dybcio@...aro.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Srini Kandagatla <srinivas.kandagatla@...aro.org>,
Elliot Berman <quic_eberman@...cinc.com>,
Caleb Connolly <caleb.connolly@...aro.org>,
Neil Armstrong <neil.armstrong@...aro.org>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Alex Elder <elder@...nel.org>, linux-arm-msm@...r.kernel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
linux-bluetooth@...r.kernel.org, netdev@...r.kernel.org,
linux-wireless@...r.kernel.org, ath11k@...ts.infradead.org,
Jeff Johnson <quic_jjohnson@...cinc.com>,
ath12k@...ts.infradead.org, linux-pm@...r.kernel.org,
linux-pci@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
kernel@...cinc.com, Amit Pundir <amit.pundir@...aro.org>
Subject: Re: [PATCH v8 16/17] PCI/pwrctl: add a PCI power control driver for
power sequenced devices
On Tue, May 28, 2024 at 09:03:24PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
>
> 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.
>
> Tested-by: Amit Pundir <amit.pundir@...aro.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
With s/add/Add/ in subject,
Acked-by: Bjorn Helgaas <bhelgaas@...gle.com>
> ---
> drivers/pci/pwrctl/Kconfig | 9 ++++
> drivers/pci/pwrctl/Makefile | 2 +
> drivers/pci/pwrctl/pci-pwrctl-pwrseq.c | 89 ++++++++++++++++++++++++++++++++++
> 3 files changed, 100 insertions(+)
>
> 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 <linux/device.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/pci-pwrctl.h>
> +#include <linux/platform_device.h>
> +#include <linux/pwrseq/consumer.h>
> +#include <linux/slab.h>
> +#include <linux/types.h>
> +
> +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 <bartosz.golaszewski@...aro.org>");
> +MODULE_DESCRIPTION("Generic PCI Power Control module for power sequenced devices");
> +MODULE_LICENSE("GPL");
>
> --
> 2.43.0
>
Powered by blists - more mailing lists