blob: 346a4dd9640a29448a3770a4eccf87fc135cd501 [file] [log] [blame]
Grygorii Strashkod7024192019-12-23 13:04:51 +02001// 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
7int xudma_navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread)
8{
9 return navss_psil_pair(ud, src_thread, dst_thread);
10}
11EXPORT_SYMBOL(xudma_navss_psil_pair);
12
13int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, u32 dst_thread)
14{
15 return navss_psil_unpair(ud, src_thread, dst_thread);
16}
17EXPORT_SYMBOL(xudma_navss_psil_unpair);
18
19struct udma_dev *of_xudma_dev_get(struct device_node *np, const char *property)
20{
21 struct device_node *udma_node = np;
22 struct platform_device *pdev;
23 struct udma_dev *ud;
24
25 if (property) {
26 udma_node = of_parse_phandle(np, property, 0);
27 if (!udma_node) {
28 pr_err("UDMA node is not found\n");
29 return ERR_PTR(-ENODEV);
30 }
31 }
32
33 pdev = of_find_device_by_node(udma_node);
34 if (!pdev) {
35 pr_debug("UDMA device not found\n");
36 return ERR_PTR(-EPROBE_DEFER);
37 }
38
39 if (np != udma_node)
40 of_node_put(udma_node);
41
42 ud = platform_get_drvdata(pdev);
43 if (!ud) {
44 pr_debug("UDMA has not been probed\n");
Yu Kuai1438cde2020-06-18 21:01:10 +080045 put_device(&pdev->dev);
Grygorii Strashkod7024192019-12-23 13:04:51 +020046 return ERR_PTR(-EPROBE_DEFER);
47 }
48
49 return ud;
50}
51EXPORT_SYMBOL(of_xudma_dev_get);
52
Peter Ujfalusi426506a2020-12-08 11:04:24 +020053struct device *xudma_get_device(struct udma_dev *ud)
54{
55 return ud->dev;
56}
57EXPORT_SYMBOL(xudma_get_device);
58
Peter Ujfalusiaa8a4c42020-12-08 11:04:25 +020059struct k3_ringacc *xudma_get_ringacc(struct udma_dev *ud)
60{
61 return ud->ringacc;
62}
63EXPORT_SYMBOL(xudma_get_ringacc);
64
Grygorii Strashkod7024192019-12-23 13:04:51 +020065u32 xudma_dev_get_psil_base(struct udma_dev *ud)
66{
67 return ud->psil_base;
68}
69EXPORT_SYMBOL(xudma_dev_get_psil_base);
70
71struct udma_tisci_rm *xudma_dev_get_tisci_rm(struct udma_dev *ud)
72{
73 return &ud->tisci_rm;
74}
75EXPORT_SYMBOL(xudma_dev_get_tisci_rm);
76
77int xudma_alloc_gp_rflow_range(struct udma_dev *ud, int from, int cnt)
78{
79 return __udma_alloc_gp_rflow_range(ud, from, cnt);
80}
81EXPORT_SYMBOL(xudma_alloc_gp_rflow_range);
82
83int xudma_free_gp_rflow_range(struct udma_dev *ud, int from, int cnt)
84{
85 return __udma_free_gp_rflow_range(ud, from, cnt);
86}
87EXPORT_SYMBOL(xudma_free_gp_rflow_range);
88
89bool xudma_rflow_is_gp(struct udma_dev *ud, int id)
90{
91 return !test_bit(id, ud->rflow_gp_map);
92}
93EXPORT_SYMBOL(xudma_rflow_is_gp);
94
95#define XUDMA_GET_PUT_RESOURCE(res) \
96struct udma_##res *xudma_##res##_get(struct udma_dev *ud, int id) \
97{ \
98 return __udma_reserve_##res(ud, false, id); \
99} \
100EXPORT_SYMBOL(xudma_##res##_get); \
101 \
102void xudma_##res##_put(struct udma_dev *ud, struct udma_##res *p) \
103{ \
104 clear_bit(p->id, ud->res##_map); \
105} \
106EXPORT_SYMBOL(xudma_##res##_put)
107XUDMA_GET_PUT_RESOURCE(tchan);
108XUDMA_GET_PUT_RESOURCE(rchan);
109
110struct udma_rflow *xudma_rflow_get(struct udma_dev *ud, int id)
111{
112 return __udma_get_rflow(ud, id);
113}
114EXPORT_SYMBOL(xudma_rflow_get);
115
116void xudma_rflow_put(struct udma_dev *ud, struct udma_rflow *p)
117{
118 __udma_put_rflow(ud, p);
119}
120EXPORT_SYMBOL(xudma_rflow_put);
121
122#define XUDMA_GET_RESOURCE_ID(res) \
123int xudma_##res##_get_id(struct udma_##res *p) \
124{ \
125 return p->id; \
126} \
127EXPORT_SYMBOL(xudma_##res##_get_id)
128XUDMA_GET_RESOURCE_ID(tchan);
129XUDMA_GET_RESOURCE_ID(rchan);
130XUDMA_GET_RESOURCE_ID(rflow);
131
132/* Exported register access functions */
133#define XUDMA_RT_IO_FUNCTIONS(res) \
134u32 xudma_##res##rt_read(struct udma_##res *p, int reg) \
135{ \
Peter Ujfalusi67414f82020-07-07 13:23:51 +0300136 if (!p) \
137 return 0; \
138 return udma_read(p->reg_rt, reg); \
Grygorii Strashkod7024192019-12-23 13:04:51 +0200139} \
140EXPORT_SYMBOL(xudma_##res##rt_read); \
141 \
142void xudma_##res##rt_write(struct udma_##res *p, int reg, u32 val) \
143{ \
Peter Ujfalusi67414f82020-07-07 13:23:51 +0300144 if (!p) \
145 return; \
146 udma_write(p->reg_rt, reg, val); \
Grygorii Strashkod7024192019-12-23 13:04:51 +0200147} \
148EXPORT_SYMBOL(xudma_##res##rt_write)
149XUDMA_RT_IO_FUNCTIONS(tchan);
150XUDMA_RT_IO_FUNCTIONS(rchan);