Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: ipc4: Add set_core_state pm_ops implementation

IPC4 uses the SET_DX message to enable/disable cores managed by the DSP.
The dx_state.core_mask indicates which core is going to change state,
the dx_state.dx_mask is to power on (1) or off (0) the core.
In the dx_mask only those bits (cores) checked which bit is set in the
core_mask, other bits (cores) ignored.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20220610083549.16773-5-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Peter Ujfalusi and committed by
Mark Brown
bd3df9ff 0a047daf

+34
+8
include/sound/sof/ipc4/header.h
··· 385 385 uint16_t build; 386 386 } __packed; 387 387 388 + /* Payload data for SOF_IPC4_MOD_SET_DX */ 389 + struct sof_ipc4_dx_state_info { 390 + /* core(s) to apply the change */ 391 + uint32_t core_mask; 392 + /* core state: 0: put core_id to D3; 1: put core_id to D0 */ 393 + uint32_t dx_mask; 394 + } __packed __aligned(4); 395 + 388 396 /* Reply messages */ 389 397 390 398 /*
+26
sound/soc/sof/ipc4.c
··· 597 597 } 598 598 } 599 599 600 + static int sof_ipc4_set_core_state(struct snd_sof_dev *sdev, int core_idx, bool on) 601 + { 602 + struct sof_ipc4_dx_state_info dx_state; 603 + struct sof_ipc4_msg msg; 604 + 605 + dx_state.core_mask = BIT(core_idx); 606 + if (on) 607 + dx_state.dx_mask = BIT(core_idx); 608 + else 609 + dx_state.dx_mask = 0; 610 + 611 + msg.primary = SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_MOD_SET_DX); 612 + msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST); 613 + msg.primary |= SOF_IPC4_MSG_TARGET(SOF_IPC4_MODULE_MSG); 614 + msg.extension = 0; 615 + msg.data_ptr = &dx_state; 616 + msg.data_size = sizeof(dx_state); 617 + 618 + return sof_ipc4_tx_msg(sdev, &msg, msg.data_size, NULL, 0, false); 619 + } 620 + 621 + static const struct sof_ipc_pm_ops ipc4_pm_ops = { 622 + .set_core_state = sof_ipc4_set_core_state, 623 + }; 624 + 600 625 const struct sof_ipc_ops ipc4_ops = { 601 626 .tx_msg = sof_ipc4_tx_msg, 602 627 .rx_msg = sof_ipc4_rx_msg, 603 628 .set_get_data = sof_ipc4_set_get_data, 604 629 .get_reply = sof_ipc4_get_reply, 630 + .pm = &ipc4_pm_ops, 605 631 .fw_loader = &ipc4_loader_ops, 606 632 };