Vignesh Raghavendra | 53b04c6 | 2020-07-07 13:43:33 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com |
| 4 | * Author: Peter Ujfalusi <peter.ujfalusi@ti.com> |
| 5 | */ |
| 6 | |
| 7 | #include <linux/kernel.h> |
| 8 | #include <linux/err.h> |
| 9 | |
| 10 | #include "k3-psil-priv.h" |
| 11 | |
| 12 | static const struct psil_ep_map *soc_ep_map; |
| 13 | |
| 14 | struct psil_endpoint_config *psil_get_ep_config(u32 thread_id) |
| 15 | { |
| 16 | int i; |
| 17 | |
| 18 | if (!soc_ep_map) { |
| 19 | if (IS_ENABLED(CONFIG_SOC_K3_AM6)) |
| 20 | soc_ep_map = &am654_ep_map; |
| 21 | else if (IS_ENABLED(CONFIG_SOC_K3_J721E)) |
| 22 | soc_ep_map = &j721e_ep_map; |
Vignesh Raghavendra | 6f617d8 | 2021-05-10 20:06:07 +0530 | [diff] [blame] | 23 | else if (IS_ENABLED(CONFIG_SOC_K3_AM642)) |
| 24 | soc_ep_map = &am64_ep_map; |
Vignesh Raghavendra | 53b04c6 | 2020-07-07 13:43:33 +0530 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | if (thread_id & K3_PSIL_DST_THREAD_ID_OFFSET && soc_ep_map->dst) { |
| 28 | /* check in destination thread map */ |
| 29 | for (i = 0; i < soc_ep_map->dst_count; i++) { |
| 30 | if (soc_ep_map->dst[i].thread_id == thread_id) |
| 31 | return &soc_ep_map->dst[i].ep_config; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | thread_id &= ~K3_PSIL_DST_THREAD_ID_OFFSET; |
| 36 | if (soc_ep_map->src) { |
| 37 | for (i = 0; i < soc_ep_map->src_count; i++) { |
| 38 | if (soc_ep_map->src[i].thread_id == thread_id) |
| 39 | return &soc_ep_map->src[i].ep_config; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | return ERR_PTR(-ENOENT); |
| 44 | } |