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 	uint32_t iface = FIELD_PREP(CW_PMC_IPC_OP_CODE, CW_PMC_OPC_SRAM_CONFIG) |
23 			 FIELD_PREP(CW_PMC_IPC_SRAM_USED_BANKS, banks) |
24 			 CW_PMC_IPC_BUSY;
25 
26 	cw_sb_write(CW_PMC_DESTID_VALUE, 0, CW_PMC_MAILBOX3_INTERFACE_ADDRESS, iface);
27 
28 	cw_upstream_wait_for_sent();
29 	return 0;
30 }
31