Skip to content

Commit 3dd4885

Browse files
drivers: adc: comp: refactor to support power domains and pin ret
The ADC did not implement a PM device structure, this PM could not resume its power domains. Additionally, the ADC and COMP on the nrf54h20 both have all of their analog inputs routed to pads in different power domains than themselves, this means the device drivers for both of them need to request the pads to be resumed. To keep the drivers simple, we can rely on HW to keep the power domain the COMP and ADC are in powered, which happens automatically when the ADC or COMP is ENABLED. We can then replace their power domains in the devicetree with the one all of their their analog inputs need, so PM ensures the pads are powered and not retained when the ADC or COMP is resumed. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 36d18bb commit 3dd4885

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

drivers/adc/adc_nrfx_saadc.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <zephyr/dt-bindings/adc/nrf-saadc-nrf54l.h>
1111
#include <zephyr/dt-bindings/adc/nrf-saadc-haltium.h>
1212
#include <zephyr/linker/devicetree_regions.h>
13+
#include <zephyr/pm/device.h>
1314
#include <zephyr/logging/log.h>
1415
#include <zephyr/irq.h>
1516
#include <dmm.h>
@@ -777,6 +778,11 @@ static void event_handler(const nrfx_saadc_evt_t *event)
777778
}
778779
}
779780

781+
static int saadc_pm_handler(const struct device *dev, enum pm_device_action action)
782+
{
783+
return 0;
784+
}
785+
780786
static int init_saadc(const struct device *dev)
781787
{
782788
nrfx_err_t err;
@@ -837,5 +843,7 @@ DT_FOREACH_CHILD(DT_DRV_INST(0), VALIDATE_CHANNEL_CONFIG)
837843

838844
NRF_DT_CHECK_NODE_HAS_REQUIRED_MEMORY_REGIONS(DT_DRV_INST(0));
839845

840-
DEVICE_DT_INST_DEFINE(0, init_saadc, NULL, NULL, NULL, POST_KERNEL,
846+
PM_DEVICE_DT_INST_DEFINE(0, saadc_pm_handler);
847+
848+
DEVICE_DT_INST_DEFINE(0, init_saadc, PM_DEVICE_DT_INST_GET(0), NULL, NULL, POST_KERNEL,
841849
CONFIG_ADC_INIT_PRIORITY, &adc_nrfx_driver_api);

dts/vendor/nordic/nrf54h20.dtsi

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,13 @@
991991
interrupts = <386 NRF_DEFAULT_IRQ_PRIORITY>;
992992
status = "disabled";
993993
#io-channel-cells = <1>;
994-
power-domains = <&gdpwr_slow_active>;
994+
/*
995+
* This device is actually in the gdpwr_slow_active domain, but all of its
996+
* analog inputs are routed to pads in the gdpwr_slow_main. Request
997+
* gdpwr_slow_main and rely on the device to force its own power domain on
998+
* when active.
999+
*/
1000+
power-domains = <&gdpwr_slow_main>;
9951001
zephyr,pm-device-runtime-auto;
9961002
};
9971003

@@ -1004,6 +1010,12 @@
10041010
reg = <0x983000 0x1000>;
10051011
status = "disabled";
10061012
interrupts = <387 NRF_DEFAULT_IRQ_PRIORITY>;
1013+
/*
1014+
* This device is actually in the gdpwr_slow_active domain, but all of its
1015+
* analog inputs are routed to pads in the gdpwr_slow_main. Request
1016+
* gdpwr_slow_main and rely on the device to force its own power domain on
1017+
* when active.
1018+
*/
10071019
power-domains = <&gdpwr_slow_active>;
10081020
};
10091021

0 commit comments

Comments
 (0)