Commit graph

19 commits

Author SHA1 Message Date
Konrad Dybcio
07d59dec67 power: sequencing: qcom-wcn: fix bluetooth-wifi copypasta for WCN6855
Prevent a name conflict (which is surprisingly not caught by the
framework).

Fixes: bd4c8bafcf ("power: sequencing: qcom-wcn: improve support for wcn6855")
Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20250625-topic-wcn6855_pwrseq-v1-1-cfb96d599ff8@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-06-30 09:07:57 +02:00
Bartosz Golaszewski
385b735c90 power: sequencing: thead-gpu: use new defines for match() return values
Replace the magic numbers with proper defines we now have in the header.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250624-pwrseq-match-defines-v1-5-a59d90a951f1@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-06-30 09:07:41 +02:00
Bartosz Golaszewski
f698155029 power: sequencing: qcom-wcn: use new defines for match() return values
Replace the magic numbers with proper defines we now have in the header.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250624-pwrseq-match-defines-v1-4-a59d90a951f1@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-06-30 09:07:34 +02:00
Bartosz Golaszewski
62b5848f73 power: sequencing: add defines for return values of the match() callback
Instead of using 0 and 1 as magic numbers, let's add proper defines
whose names tell the reader what the meaning behind them is.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250624-pwrseq-match-defines-v1-3-a59d90a951f1@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-06-30 09:07:26 +02:00
Bartosz Golaszewski
1a7312b93a power: sequencing: extend build coverage with COMPILE_TEST=y
Enable building the pwrseq drivers with COMPILE_TEST enabled. This makes
it easier to build-test them.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250624-pwrseq-match-defines-v1-2-a59d90a951f1@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-06-30 09:06:54 +02:00
Bartosz Golaszewski
5bcfc4ef40 power: sequencing: thead-gpu: add missing header
When using kcalloc(), kfree() etc., we need to include linux/slab.h.
While on some architectures it may work fine because the header is
pulled in implicitly, on others it triggers the following errors:

drivers/power/sequencing/pwrseq-thead-gpu.c: In function ‘pwrseq_thead_gpu_match’:
drivers/power/sequencing/pwrseq-thead-gpu.c:147:21: error: implicit declaration of function ‘kcalloc’ [-Wimplicit-function-declaration]
  147 |         ctx->clks = kcalloc(ctx->num_clks, sizeof(*ctx->clks), GFP_KERNEL);

Fixes: d4c2d9b5b7 ("power: sequencing: Add T-HEAD TH1520 GPU power sequencer driver")
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20250624-pwrseq-match-defines-v1-1-a59d90a951f1@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-06-30 09:06:12 +02:00
Michal Wilczynski
d4c2d9b5b7 power: sequencing: Add T-HEAD TH1520 GPU power sequencer driver
Introduce the pwrseq-thead-gpu driver, a power sequencer provider for
the Imagination BXM-4-64 GPU on the T-HEAD TH1520 SoC. This driver
controls an auxiliary device instantiated by the AON power domain.

The TH1520 GPU requires a specific sequence to correctly initialize and
power down its resources:
 - Enable GPU clocks (core and sys).
 - De-assert the GPU clock generator reset (clkgen_reset).
 - Introduce a short hardware-required delay.
 - De-assert the GPU core reset. The power-down sequence performs these
   steps in reverse.

Implement this sequence via the pwrseq_power_on and pwrseq_power_off
callbacks.

Crucially, the driver's match function is called when a consumer (the
Imagination GPU driver) requests the "gpu-power" target. During this
match, the sequencer uses clk_bulk_get() and
reset_control_get_exclusive() on the consumer's device to obtain handles
to the GPU's "core" and "sys" clocks, and the GPU core reset.  These,
along with clkgen_reset obtained from parent aon node, allow it to
perform the complete sequence.

Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
Link: https://lore.kernel.org/r/20250623-apr_14_for_sending-v6-1-6583ce0f6c25@samsung.com
[Bartosz: use a ternary operator instead of implicitly casting the
result of a boolean expression to int]
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-06-24 15:55:05 +02:00
Bartosz Golaszewski
29da3e8748 power: sequencing: qcom-wcn: explain why we need the WLAN_EN GPIO hack
With the recent rework of the PCI power control code, the workaround for
the wlan-enable GPIO - where we don't set a default (low) state in the
power sequencing driver, but instead request the pin as-is - should no
longer be needed but some platforms still fail to probe the WLAN
controller. This is caused by the Qcom PCIe controller and needs a
workaround in the controller driver so add a FIXME to eventually remove
the hack from this driver once this is done.

Link: https://lore.kernel.org/r/20250102121530.26993-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-01-13 09:07:20 +01:00
Janaki Ramaiah Thota
93e3c990fc power: sequencing: qcom-wcn: add support for the WCN6750 PMU
Enable support for controlling the power-up sequence of the PMU inside
the WCN6750 model.

Signed-off-by: Janaki Ramaiah Thota <quic_janathot@quicinc.com>
Link: https://lore.kernel.org/r/20241209103455.9675-5-quic_janathot@quicinc.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-12-10 14:31:19 +01:00
Bartosz Golaszewski
bd4c8bafcf power: sequencing: qcom-wcn: improve support for wcn6855
WCN6855 (also known as QCA6490) is similar to the already supported
QCA6390 but takes in two more supplies so add a new vregs list for it.

On sm8450-hdk it also requires a short assert of the xo-clk pin so add
handling for it in a dedicated unit.

As we now have a separate set of targets for this variant, store the
pointer to the targets struct associated with a model in the device
match data.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20241018-sc8280xp-pwrseq-v6-2-8da8310d9564@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-25 09:59:30 +02:00
Bartosz Golaszewski
f82bf3c579 power: sequencing: make the QCom PMU pwrseq driver depend on CONFIG_OF
This driver uses various OF-specific functions and depends on phandle
parsing. There's no reason to make it available to non-OF systems so add
a relevant dependency switch to its Kconfig entry.

Fixes: 2f1630f437 ("power: pwrseq: add a driver for the PMU module on the QCom WCN chipsets")
Link: https://lore.kernel.org/r/20241004130449.51725-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-10-23 09:54:06 +02:00
Linus Torvalds
2fe3c78a2c power sequencing updates for v6.12-rc1
- add support for the new PMU variant inside the WCN6855 chipset
 - add documentation for the subsystem
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmboGdwACgkQEacuoBRx
 13KsGg/9GTiUYAKZwrK41Njh79DLGp4+tbVx2/AR1Az2hkablZa6PkRQrLs8AQT5
 nOWfnWFSNuQoBXPo3XZ6Hh/NAwHBQTmJjw9lQVZUJPQAcdJC6lyo6pGH0/Exu9qB
 V69UgNhqWKJ/9Vv23+i8pBOoH/IjyhCLZJU9+NHU3X3/SJ2Ek+5g5O/mgpq3fPk9
 wgcs6/s1ITaOKAqZ5p0uPWMlCTKf9tWiszrRDik9AHOD9kpfLzzJs8SqV3f+XGZN
 P+oi3NOqgf7nQbVQcIiMrGFyd4eRM1tZAMySVZdMaqZO8KK5Aimy4MX9fdVtAIzC
 Gv42R6uyG2O/mkEpkFE7wgKL/S9r4ThZB18KbwuWOCdfRPRPDwvGSFSxvPJue272
 zRSAweIp8FPcds2Jktsb1D5ypiJ9eV9Ti+wjloKG81EXgiwp4PGgQ1sviAy+1rSl
 Wyr/E5UQ98tSpm86CXJu7KyBoenfhLOAGkotPr7zNbbGFDmRgyNODz82fSaOZMtx
 ZB+js7DtQ5vFeQZHAAHKDUoIjUY9J8KvEoamKvB+sKq81BpR2pPCyA0mPD7cOVD/
 ksfs86UffGh9fHRoz1Q+jCZyLAdA7MY4mdfVCIdXm71EFe7KpMCP886DykYoDIOp
 qiO0fJsnRiZdNzV240FD+9k4rWd+NV56o00v2pwgiAjjFeb9ROk=
 =u9Ea
 -----END PGP SIGNATURE-----

Merge tag 'pwrseq-updates-for-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull power sequencing updates from Bartosz Golaszewski:
 "There's one change adding support for a new PMU model and another
  adding documentation for the subsystem which probably should have been
  part of the initial commit but better late than never:

   - add support for the new PMU variant inside the WCN6855 chipset

   - add documentation for the subsystem"

* tag 'pwrseq-updates-for-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  Documentation: add a driver API doc for the power sequencing subsystem
  power: sequencing: qcom-wcn: add support for the WCN6855 PMU
2024-09-18 10:46:27 +02:00
Bartosz Golaszewski
d8b762070c power: sequencing: qcom-wcn: set the wlan-enable GPIO to output
Commit a9aaf1ff88 ("power: sequencing: request the WLAN enable GPIO
as-is") broke WLAN on boards on which the wlan-enable GPIO enabling the
wifi module isn't in output mode by default. We need to set direction to
output while retaining the value that was already set to keep the ath
module on if it's already started.

Fixes: a9aaf1ff88 ("power: sequencing: request the WLAN enable GPIO as-is")
Link: https://lore.kernel.org/r/20240823115500.37280-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-08-31 21:32:19 +02:00
Konrad Dybcio
b8e4b0529d power: sequencing: qcom-wcn: add support for the WCN6855 PMU
Enable support for controlling the power-up sequence of the PMU inside
the WCN6855 model.

Signed-off-by: Konrad Dybcio <konradybcio@kernel.org>
[Bartosz: split Konrad's bigger patch, write the commit message]
Co-developed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20240813190841.155067-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-08-19 10:03:31 +02:00
Bartosz Golaszewski
a9aaf1ff88 power: sequencing: request the WLAN enable GPIO as-is
If the WCN module is powered up before linux boots and the ath11k driver
probes at the same time as the power sequencing driver, we may end up
driving the wlan-enable GPIO low in the latter, breaking the start-up of
the WLAN module. Request the wlan-enable GPIO as-is so that if the WLAN
module is already starting/started, we leave it alone.

Fixes: 2f1630f437 ("power: pwrseq: add a driver for the PMU module on the QCom WCN chipsets")
Reported-by: Stephan Gerhold <stephan.gerhold@linaro.org>
Link: https://lore.kernel.org/r/20240813190751.155035-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-08-19 09:55:53 +02:00
Bartosz Golaszewski
a19ce320c3 power: sequencing: fix an invalid pointer dereference in error path
We may end up calling pwrseq_target_free() on a partially initialized
target object whose unit is either NULL or an ERR_PTR(). Avoid
dereferencing invalid memory by adding an appropriate check to
pwrseq_target_free().

Fixes: 249ebf3f65 ("power: sequencing: implement the pwrseq core")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/linux-pm/62a3531e-9927-40f8-b587-254a2dfa47ef@stanley.mountain/
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/20240712194004.241939-1-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-07-17 16:30:50 +02:00
Krzysztof Kozlowski
eba6d0f88b power: sequencing: simplify returning pointer without cleanup
Use 'return_ptr' helper for returning a pointer without cleanup for
shorter code.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240703083038.95777-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-07-03 11:49:04 +02:00
Bartosz Golaszewski
2f1630f437 power: pwrseq: add a driver for the PMU module on the QCom WCN chipsets
This adds the power sequencing driver for the PMU modules present on the
Qualcomm WCN Bluetooth and Wifi chipsets. It uses the pwrseq subsystem
and knows how to match the sequencer to the consumer device by verifying
the relevant properties and DT layout. Using this driver will allow the
BT and WLAN drivers to respect the required delays between enabling the
two modules.

Tested-by: Amit Pundir <amit.pundir@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD, SM8650-QRD & SM8650-HDK
Tested-by: Caleb Connolly <caleb.connolly@linaro.org> # OnePlus 8T
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240605123850.24857-3-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-06-12 09:20:13 +02:00
Bartosz Golaszewski
249ebf3f65 power: sequencing: implement the pwrseq core
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.

Tested-by: Amit Pundir <amit.pundir@linaro.org>
Tested-by: Neil Armstrong <neil.armstrong@linaro.org> # on SM8550-QRD, SM8650-QRD & SM8650-HDK
Tested-by: Caleb Connolly <caleb.connolly@linaro.org> # OnePlus 8T
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20240605123850.24857-2-brgl@bgdev.pl
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-06-12 09:20:13 +02:00