Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf fromlist] Fix SPIM120 handling when power management is enabled #2356

Merged
merged 11 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 30 additions & 34 deletions drivers/spi/spi_nrfx_spim.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ static inline void finalize_spi_transaction(const struct device *dev, bool deact
if (NRF_SPIM_IS_320MHZ_SPIM(reg) && !(dev_data->ctx.config->operation & SPI_HOLD_ON_CS)) {
nrfy_spim_disable(reg);
}
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
pm_device_runtime_put(dev);
}

pm_device_runtime_put_async(dev, K_NO_WAIT);
}

static inline uint32_t get_nrf_spim_frequency(uint32_t frequency)
Expand Down Expand Up @@ -464,9 +463,7 @@ static int transceive(const struct device *dev,
void *reg = dev_config->spim.p_reg;
int error;

if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
pm_device_runtime_get(dev);
}
pm_device_runtime_get(dev);
spi_context_lock(&dev_data->ctx, asynchronous, cb, userdata, spi_cfg);

error = configure(dev, spi_cfg);
Expand Down Expand Up @@ -578,49 +575,48 @@ static const struct spi_driver_api spi_nrfx_driver_api = {
.release = spi_nrfx_release,
};

static int spim_nrfx_pm_action(const struct device *dev,
enum pm_device_action action)
static void spim_resume(const struct device *dev)
{
int ret = -ENOTSUP;
struct spi_nrfx_data *dev_data = dev->data;
const struct spi_nrfx_config *dev_config = dev->config;

switch (action) {
case PM_DEVICE_ACTION_TURN_ON:
ret = 0;
break;
case PM_DEVICE_ACTION_RESUME:
ret = pinctrl_apply_state(dev_config->pcfg,
PINCTRL_STATE_DEFAULT);
/* nrfx_spim_init() will be called at configuration before
* the next transfer.
*/
(void)pinctrl_apply_state(dev_config->pcfg, PINCTRL_STATE_DEFAULT);
/* nrfx_spim_init() will be called at configuration before
* the next transfer.
*/

#ifdef CONFIG_SOC_NRF54H20_GPD
nrf_gpd_retain_pins_set(dev_config->pcfg, false);
nrf_gpd_retain_pins_set(dev_config->pcfg, false);
#endif
}

break;
static void spim_suspend(const struct device *dev)
{
const struct spi_nrfx_config *dev_config = dev->config;
struct spi_nrfx_data *dev_data = dev->data;

case PM_DEVICE_ACTION_SUSPEND:
if (dev_data->initialized) {
nrfx_spim_uninit(&dev_config->spim);
dev_data->initialized = false;
}
if (dev_data->initialized) {
nrfx_spim_uninit(&dev_config->spim);
dev_data->initialized = false;
}

#ifdef CONFIG_SOC_NRF54H20_GPD
nrf_gpd_retain_pins_set(dev_config->pcfg, true);
nrf_gpd_retain_pins_set(dev_config->pcfg, true);
#endif

ret = pinctrl_apply_state(dev_config->pcfg,
PINCTRL_STATE_SLEEP);
break;
(void)pinctrl_apply_state(dev_config->pcfg, PINCTRL_STATE_SLEEP);
}

default:
break;
static int spim_nrfx_pm_action(const struct device *dev, enum pm_device_action action)
{
if (action == PM_DEVICE_ACTION_RESUME) {
spim_resume(dev);
} else if (IS_ENABLED(CONFIG_PM_DEVICE) && (action == PM_DEVICE_ACTION_SUSPEND)) {
spim_suspend(dev);
} else {
return -ENOTSUP;
}

return ret;
return 0;
}

static int spi_nrfx_init(const struct device *dev)
Expand Down
5 changes: 4 additions & 1 deletion modules/hal_nordic/nrfs/backends/nrfs_backend_ipc_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@

nrfs_err_t nrfs_backend_send_ex(void *message, size_t size, k_timeout_t timeout, bool high_prio)
{
if (size <= MAX_PACKET_DATA_SIZE) {
if (!k_is_in_isr() && nrfs_backend_connected()) {
return ipc_service_send(&ipc_cpusys_channel_config.ipc_ept, message, size) ?
NRFS_SUCCESS : NRFS_ERR_IPC;
} else if (size <= MAX_PACKET_DATA_SIZE) {

Check notice on line 182 in modules/hal_nordic/nrfs/backends/nrfs_backend_ipc_service.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

modules/hal_nordic/nrfs/backends/nrfs_backend_ipc_service.c:182 - return ipc_service_send(&ipc_cpusys_channel_config.ipc_ept, message, size) ? - NRFS_SUCCESS : NRFS_ERR_IPC; + return ipc_service_send(&ipc_cpusys_channel_config.ipc_ept, message, size) + ? NRFS_SUCCESS + : NRFS_ERR_IPC;
int err;
struct ipc_data_packet tx_data;

Expand Down
2 changes: 1 addition & 1 deletion samples/drivers/jesd216/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tests:
sample.drivers.jesd216.nrf52840dk_spi:
extra_args:
- DTC_OVERLAY_FILE=boards/nrf52840dk_nrf52840_spi.overlay
- OVERLAY_CONFIG=boards/nrf52840dk_nrf52840_spi.conf
- EXTRA_CONF_FILE=boards/nrf52840dk_nrf52840_spi.conf
platform_allow: nrf52840dk/nrf52840
integration_platforms:
- nrf52840dk/nrf52840
Expand Down
8 changes: 4 additions & 4 deletions samples/drivers/spi_flash_at45/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ tests:
filter: dt_compat_enabled("atmel,at45")
build_only: true
sample.drivers.spi.flash.at45.build.page_layout:
extra_args: OVERLAY_CONFIG="overlay-page_layout.conf"
extra_args: EXTRA_CONF_FILE="overlay-page_layout.conf"
tags:
- spi
- flash
depends_on: spi
filter: dt_compat_enabled("atmel,at45")
build_only: true
sample.drivers.spi.flash.at45.build.pm:
extra_args: OVERLAY_CONFIG="overlay-pm.conf"
extra_args: EXTRA_CONF_FILE="overlay-pm.conf"
tags:
- spi
- flash
depends_on: spi
filter: dt_compat_enabled("atmel,at45")
build_only: true
sample.drivers.spi.flash.at45.build.page_layout_pm:
extra_args: OVERLAY_CONFIG="overlay-page_layout.conf;overlay-pm.conf"
extra_args: EXTRA_CONF_FILE="overlay-page_layout.conf;overlay-pm.conf"
tags:
- spi
- flash
depends_on: spi
filter: dt_compat_enabled("atmel,at45")
build_only: true
sample.drivers.spi.flash.at45:
extra_args: OVERLAY_CONFIG="overlay-page_layout.conf;overlay-pm.conf"
extra_args: EXTRA_CONF_FILE="overlay-page_layout.conf;overlay-pm.conf"
tags:
- spi
- flash
Expand Down
2 changes: 1 addition & 1 deletion samples/modules/thrift/hello/client/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ tests:
extra_configs:
- CONFIG_THRIFT_COMPACT_PROTOCOL=y
sample.thrift.hello.client.tlsTransport:
extra_args: OVERLAY_CONFIG="../overlay-tls.conf"
extra_args: EXTRA_CONF_FILE="../overlay-tls.conf"
2 changes: 1 addition & 1 deletion samples/modules/thrift/hello/server/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ tests:
extra_configs:
- CONFIG_THRIFT_COMPACT_PROTOCOL=y
sample.thrift.hello.server.tlsTransport:
extra_args: OVERLAY_CONFIG="../overlay-tls.conf"
extra_args: EXTRA_CONF_FILE="../overlay-tls.conf"
4 changes: 2 additions & 2 deletions samples/net/cloud/tagoio_http_post/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ tests:
integration_platforms:
- frdm_k64f
sample.net.cloud.tagoio_http_post.wifi:
extra_args: OVERLAY_CONFIG="overlay-wifi.conf"
extra_args: EXTRA_CONF_FILE="overlay-wifi.conf"
platform_allow: disco_l475_iot1
sample.net.cloud.tagoio_http_post.wifi.esp:
extra_args:
- SHIELD=esp_8266_arduino
- OVERLAY_CONFIG="overlay-wifi.conf"
- EXTRA_CONF_FILE="overlay-wifi.conf"
platform_allow:
- frdm_k64f
- nucleo_f767zi
Expand Down
4 changes: 2 additions & 2 deletions samples/net/lwm2m_client/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tests:
sample.net.lwm2m_client.dtls:
harness: net
depends_on: netif
extra_args: OVERLAY_CONFIG=overlay-dtls.conf
extra_args: EXTRA_CONF_FILE=overlay-dtls.conf
platform_allow:
- qemu_x86
- frdm_k64f
Expand All @@ -55,7 +55,7 @@ tests:
sample.net.lwm2m_client.queue_mode:
harness: net
depends_on: netif
extra_args: OVERLAY_CONFIG=overlay-queue.conf
extra_args: EXTRA_CONF_FILE=overlay-queue.conf
platform_allow:
- qemu_x86
- native_sim
Expand Down
4 changes: 2 additions & 2 deletions samples/net/openthread/coprocessor/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tests:
- nrf52840dk/nrf52840
tags: ci_build
extra_args:
- OVERLAY_CONFIG=overlay-usb-nrf-br.conf
- EXTRA_CONF_FILE=overlay-usb-nrf-br.conf
- DTC_OVERLAY_FILE="usb.overlay"
sample.openthread.coprocessor.rcp:
build_only: true
Expand All @@ -36,4 +36,4 @@ tests:
- tlsr9518adk80d
integration_platforms:
- nrf52840dk/nrf52840
extra_args: OVERLAY_CONFIG=overlay-rcp.conf
extra_args: EXTRA_CONF_FILE=overlay-rcp.conf
4 changes: 2 additions & 2 deletions samples/net/secure_mqtt_sensor_actuator/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tests:
- adi_eval_adin1110ebz
sample.net.secure_mqtt_sensor_actuator.staticip:
harness: net
extra_args: OVERLAY_CONFIG="overlay-static.conf"
extra_args: EXTRA_CONF_FILE="overlay-static.conf"
tags:
- net
- mqtt
Expand All @@ -22,7 +22,7 @@ tests:
- native_sim
sample.net.secure_mqtt_sensor_actuator.staticip_insecure:
harness: net
extra_args: OVERLAY_CONFIG="overlay-static-insecure.conf"
extra_args: EXTRA_CONF_FILE="overlay-static-insecure.conf"
tags:
- net
- mqtt
Expand Down
2 changes: 1 addition & 1 deletion samples/net/sockets/big_http_download/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ tests:
extra_configs:
- CONFIG_POSIX_API=y
sample.net.sockets.big_http_download.ci:
extra_args: OVERLAY_CONFIG=overlay-ci.conf
extra_args: EXTRA_CONF_FILE=overlay-ci.conf
4 changes: 2 additions & 2 deletions samples/net/sockets/dumb_http_server/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tests:
sample.net.sockets.dumb_http_server.netusb:
depends_on: usb_device
harness: net
extra_args: OVERLAY_CONFIG="overlay-netusb.conf"
extra_args: EXTRA_CONF_FILE="overlay-netusb.conf"
tags: usb
# native_sim usb driver does not work with CONFIG_POSIX_API
platform_exclude:
Expand All @@ -28,7 +28,7 @@ tests:
sample.net.sockets.dumb_http_server.netusb_zeroconf:
depends_on: usb_device
harness: net
extra_args: OVERLAY_CONFIG="overlay-netusb.conf;overlay-zeroconf.conf"
extra_args: EXTRA_CONF_FILE="overlay-netusb.conf;overlay-zeroconf.conf"
tags: usb
# native_sim usb driver does not work with CONFIG_POSIX_API
platform_exclude:
Expand Down
28 changes: 14 additions & 14 deletions samples/net/sockets/echo_client/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ tests:
integration_platforms:
- qemu_x86
sample.net.sockets.echo_client.802154:
extra_args: OVERLAY_CONFIG="overlay-qemu_802154.conf"
extra_args: EXTRA_CONF_FILE="overlay-qemu_802154.conf"
platform_allow: qemu_x86
sample.net.sockets.echo_client.802154.rf2xx:
extra_args: OVERLAY_CONFIG="overlay-802154.conf"
extra_args: EXTRA_CONF_FILE="overlay-802154.conf"
platform_allow: samr21_xpro
sample.net.sockets.echo_client.802154.rf2xx.xplained:
extra_args:
- SHIELD=atmel_rf2xx_xplained
- OVERLAY_CONFIG="overlay-802154.conf"
- EXTRA_CONF_FILE="overlay-802154.conf"
platform_allow: sam4s_xplained
sample.net.sockets.echo_client.802154.rf2xx.xpro:
extra_args:
- SHIELD=atmel_rf2xx_xpro
- OVERLAY_CONFIG="overlay-802154.conf"
- EXTRA_CONF_FILE="overlay-802154.conf"
platform_allow:
- sam4e_xpro
- sam_v71_xult/samv71q21
Expand All @@ -41,7 +41,7 @@ tests:
sample.net.sockets.echo_client.802154.rf2xx.legacy:
extra_args:
- SHIELD=atmel_rf2xx_legacy
- OVERLAY_CONFIG="overlay-802154.conf"
- EXTRA_CONF_FILE="overlay-802154.conf"
platform_allow:
- sam4e_xpro
- sam_v71_xult/samv71q21
Expand All @@ -50,7 +50,7 @@ tests:
sample.net.sockets.echo_client.802154.rf2xx.arduino:
extra_args:
- SHIELD=atmel_rf2xx_arduino
- OVERLAY_CONFIG="overlay-802154.conf"
- EXTRA_CONF_FILE="overlay-802154.conf"
platform_allow:
- sam_v71_xult/samv71q21
- frdm_k64f
Expand All @@ -60,37 +60,37 @@ tests:
sample.net.sockets.echo_client.802154.rf2xx.mikrobus:
extra_args:
- SHIELD=atmel_rf2xx_mikrobus
- OVERLAY_CONFIG="overlay-802154.conf"
- EXTRA_CONF_FILE="overlay-802154.conf"
platform_allow: lpcxpresso55s69/lpc55s69/cpu0/ns
sample.net.sockets.echo_client.mcr20a:
extra_args:
- SHIELD=frdm_cr20a
- OVERLAY_CONFIG=overlay-802154.conf
- EXTRA_CONF_FILE=overlay-802154.conf
platform_allow: frdm_k64f
sample.net.sockets.echo_client.nrf_802154:
extra_args: OVERLAY_CONFIG="overlay-802154.conf"
extra_args: EXTRA_CONF_FILE="overlay-802154.conf"
platform_allow: nrf52840dk/nrf52840
sample.net.sockets.echo_client.nrf_openthread:
extra_args: OVERLAY_CONFIG="overlay-ot.conf"
extra_args: EXTRA_CONF_FILE="overlay-ot.conf"
slow: true
tags:
- net
- openthread
platform_allow: nrf52840dk/nrf52840
filter: CONFIG_FULL_LIBC_SUPPORTED and not CONFIG_NATIVE_LIBC
sample.net.sockets.echo_client.b91_802154:
extra_args: OVERLAY_CONFIG="overlay-802154.conf"
extra_args: EXTRA_CONF_FILE="overlay-802154.conf"
platform_allow: tlsr9518adk80d
sample.net.sockets.echo_client.b91_openthread:
extra_args: OVERLAY_CONFIG="overlay-ot.conf"
extra_args: EXTRA_CONF_FILE="overlay-ot.conf"
slow: true
tags:
- net
- openthread
platform_allow: tlsr9518adk80d
filter: CONFIG_FULL_LIBC_SUPPORTED and not CONFIG_NATIVE_LIBC
sample.net.sockets.echo_client.kw41z_openthread:
extra_args: OVERLAY_CONFIG="overlay-ot.conf"
extra_args: EXTRA_CONF_FILE="overlay-ot.conf"
slow: true
tags:
- net
Expand All @@ -100,7 +100,7 @@ tests:
sample.net.sockets.echo_client.userspace:
extra_args:
- CONFIG_USERSPACE=y
- OVERLAY_CONFIG="overlay-e1000.conf"
- EXTRA_CONF_FILE="overlay-e1000.conf"
platform_allow:
- qemu_x86
- qemu_x86_64
Expand Down
Loading
Loading