// SPDX-License-Identifier: GPL-2.0
/*
 *  Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com
 *  Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
 */

#include <linux/kernel.h>
#include <linux/err.h>

#include "k3-psil-priv.h"

static const struct psil_ep_map *soc_ep_map;

struct psil_endpoint_config *psil_get_ep_config(u32 thread_id)
{
	int i;

	if (!soc_ep_map) {
		if (IS_ENABLED(CONFIG_SOC_K3_AM654))
			soc_ep_map = &am654_ep_map;
		else if (IS_ENABLED(CONFIG_SOC_K3_J721E))
			soc_ep_map = &j721e_ep_map;
		else if (IS_ENABLED(CONFIG_SOC_K3_J721S2))
			soc_ep_map = &j721s2_ep_map;
		else if (IS_ENABLED(CONFIG_SOC_K3_AM642))
			soc_ep_map = &am64_ep_map;
		else if (IS_ENABLED(CONFIG_SOC_K3_AM625))
			soc_ep_map = &am62_ep_map;
		else if (IS_ENABLED(CONFIG_SOC_K3_AM62A7))
			soc_ep_map = &am62a_ep_map;
		else if (IS_ENABLED(CONFIG_SOC_K3_J784S4))
			soc_ep_map = &j784s4_ep_map;
		else if (IS_ENABLED(CONFIG_SOC_K3_AM62P5))
			soc_ep_map = &am62p_ep_map;
		else if (IS_ENABLED(CONFIG_SOC_K3_J722S))
			soc_ep_map = &am62p_ep_map;
	}

	if (thread_id & K3_PSIL_DST_THREAD_ID_OFFSET && soc_ep_map->dst) {
		/* check in destination thread map */
		for (i = 0; i < soc_ep_map->dst_count; i++) {
			if (soc_ep_map->dst[i].thread_id == thread_id)
				return &soc_ep_map->dst[i].ep_config;
		}
	}

	thread_id &= ~K3_PSIL_DST_THREAD_ID_OFFSET;
	if (soc_ep_map->src) {
		for (i = 0; i < soc_ep_map->src_count; i++) {
			if (soc_ep_map->src[i].thread_id == thread_id)
				return &soc_ep_map->src[i].ep_config;
		}
	}

	return ERR_PTR(-ENOENT);
}
