blob: 369e679886fa44ee1f25f4c0fc6d9c35ab0071dc [file] [log] [blame]
Vignesh Raghavendraa5552862020-07-07 13:43:33 +05301// SPDX-License-Identifier: GPL-2.0
2/*
Nishanth Menoneaa39c62023-11-01 15:56:03 -05003 * Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com
Vignesh Raghavendraa5552862020-07-07 13:43:33 +05304 * 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
12static const struct psil_ep_map *soc_ep_map;
13
14struct psil_endpoint_config *psil_get_ep_config(u32 thread_id)
15{
16 int i;
17
18 if (!soc_ep_map) {
Andrew Davis1be5e972022-07-15 10:25:27 -050019 if (IS_ENABLED(CONFIG_SOC_K3_AM654))
Vignesh Raghavendraa5552862020-07-07 13:43:33 +053020 soc_ep_map = &am654_ep_map;
21 else if (IS_ENABLED(CONFIG_SOC_K3_J721E))
22 soc_ep_map = &j721e_ep_map;
David Huang7bee6e12022-01-25 20:56:32 +053023 else if (IS_ENABLED(CONFIG_SOC_K3_J721S2))
24 soc_ep_map = &j721s2_ep_map;
Vignesh Raghavendra6d338ce2021-05-10 20:06:07 +053025 else if (IS_ENABLED(CONFIG_SOC_K3_AM642))
26 soc_ep_map = &am64_ep_map;
Vignesh Raghavendra8ad3d202022-05-25 13:38:44 +053027 else if (IS_ENABLED(CONFIG_SOC_K3_AM625))
28 soc_ep_map = &am62_ep_map;
Vignesh Raghavendra49f55942023-11-13 08:51:44 -060029 else if (IS_ENABLED(CONFIG_SOC_K3_AM62A7))
30 soc_ep_map = &am62a_ep_map;
Apurva Nandan7a25c302024-02-24 01:51:45 +053031 else if (IS_ENABLED(CONFIG_SOC_K3_J784S4))
32 soc_ep_map = &j784s4_ep_map;
Vignesh Raghavendra0ee11df2024-03-12 15:20:27 -050033 else if (IS_ENABLED(CONFIG_SOC_K3_AM62P5))
34 soc_ep_map = &am62p_ep_map;
35 else if (IS_ENABLED(CONFIG_SOC_K3_J722S))
36 soc_ep_map = &am62p_ep_map;
Vignesh Raghavendraa5552862020-07-07 13:43:33 +053037 }
38
39 if (thread_id & K3_PSIL_DST_THREAD_ID_OFFSET && soc_ep_map->dst) {
40 /* check in destination thread map */
41 for (i = 0; i < soc_ep_map->dst_count; i++) {
42 if (soc_ep_map->dst[i].thread_id == thread_id)
43 return &soc_ep_map->dst[i].ep_config;
44 }
45 }
46
47 thread_id &= ~K3_PSIL_DST_THREAD_ID_OFFSET;
48 if (soc_ep_map->src) {
49 for (i = 0; i < soc_ep_map->src_count; i++) {
50 if (soc_ep_map->src[i].thread_id == thread_id)
51 return &soc_ep_map->src[i].ep_config;
52 }
53 }
54
55 return ERR_PTR(-ENOENT);
56}