1 /*
2  * Copyright (c) 2022 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <errno.h>
8 #include <stdbool.h>
9 #include <stdint.h>
10 
11 #include "comm_widget.h"
12 #include "pmc_interface.h"
13 
14 /*
15  * Report number of used HP-SRAM memory banks to the PMC, unit is 32 KB.
16  */
adsp_comm_widget_pmc_send_ipc(uint16_t banks)17 int adsp_comm_widget_pmc_send_ipc(uint16_t banks)
18 {
19 	if (!cw_upstream_ready()) {
20 		return -EBUSY;
21 	}
22 
23 	uint32_t iface = FIELD_PREP(CW_PMC_IPC_OP_CODE, CW_PMC_OPC_SRAM_CONFIG) |
24 			 FIELD_PREP(CW_PMC_IPC_SRAM_USED_BANKS, banks) |
25 			 CW_PMC_IPC_BUSY;
26 
27 	cw_sb_write(CW_PMC_DESTID_VALUE, 0, CW_PMC_MAILBOX3_INTERFACE_ADDRESS, iface);
28 
29 	cw_upstream_wait_for_sent();
30 	return 0;
31 }
32