# Copyright (c) 2021 Nordic Semiconductor (ASA)
# SPDX-License-Identifier: Apache-2.0

# Workaround for not being able to have commas in macro arguments
DT_CHOSEN_Z_IPC_SHM := zephyr,ipc_shm

menuconfig RPMSG_MULTI_INSTANCE
	bool "RPMsg multiple instance"
	select IPM
	select OPENAMP
	help
	  Enables support for RPMsg multiple instance.

if RPMSG_MULTI_INSTANCE

choice RPMSG_ROLE
	prompt "RPMSG device role"
	default RPMSG_MULTI_INSTANCE_REMOTE

config RPMSG_MULTI_INSTANCE_REMOTE
	bool "Remote"

config RPMSG_MULTI_INSTANCE_MASTER
	bool "Master"
endchoice

config RPMSG_MULTI_INSTANCES_NO
	int "Number of RPMSG instances."
	default 2
	range 1 8
	help
	  How many instances are to be used.

ipm_name_instance_num = 0
rsource "Kconfig.ipm_name_instance"
ipm_name_instance_num = 1
rsource "Kconfig.ipm_name_instance"
ipm_name_instance_num = 2
rsource "Kconfig.ipm_name_instance"
ipm_name_instance_num = 3
rsource "Kconfig.ipm_name_instance"
ipm_name_instance_num = 4
rsource "Kconfig.ipm_name_instance"
ipm_name_instance_num = 5
rsource "Kconfig.ipm_name_instance"
ipm_name_instance_num = 6
rsource "Kconfig.ipm_name_instance"
ipm_name_instance_num = 7
rsource "Kconfig.ipm_name_instance"

config RPMSG_MULTI_INSTANCE_SHM_BASE_ADDRESS
	hex
	default "$(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_IPC_SHM))"
	help
	  This option specifies base address of the memory region to
	  be used for the OpenAMP IPC shared memory.

config RPMSG_MULTI_INSTANCE_SHM_SIZE
	hex
	default "$(dt_chosen_reg_size_hex,$(DT_CHOSEN_Z_IPC_SHM))"
	help
	  This option specifies size of the memory region to be used
	  for the OpenAMP IPC shared memory.

config RPMSG_MULTI_INSTANCE_INIT_PRIORITY
	int "Initialization priority of RPMsg muliple instances"
	default 46
	help
	  If in doubt, do not modify this value.

module = RPMSG_MULTI_INSTANCE
module-str = RPMsg multi instance
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"

endif # RPMSG_MULTI_INSTANCE
