Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / dma / ti / k3-udma-private.c
blob05228bf00033329f9e466d3492ea7a26358f5f3c
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 #include <linux/of.h>
7 #include <linux/of_platform.h>
9 int xudma_navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread)
11 return navss_psil_pair(ud, src_thread, dst_thread);
13 EXPORT_SYMBOL(xudma_navss_psil_pair);
15 int xudma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, u32 dst_thread)
17 return navss_psil_unpair(ud, src_thread, dst_thread);
19 EXPORT_SYMBOL(xudma_navss_psil_unpair);
21 struct udma_dev *of_xudma_dev_get(struct device_node *np, const char *property)
23 struct device_node *udma_node = np;
24 struct platform_device *pdev;
25 struct udma_dev *ud;
27 if (property) {
28 udma_node = of_parse_phandle(np, property, 0);
29 if (!udma_node) {
30 pr_err("UDMA node is not found\n");
31 return ERR_PTR(-ENODEV);
35 pdev = of_find_device_by_node(udma_node);
36 if (np != udma_node)
37 of_node_put(udma_node);
39 if (!pdev) {
40 pr_debug("UDMA device not found\n");
41 return ERR_PTR(-EPROBE_DEFER);
44 ud = platform_get_drvdata(pdev);
45 if (!ud) {
46 pr_debug("UDMA has not been probed\n");
47 put_device(&pdev->dev);
48 return ERR_PTR(-EPROBE_DEFER);
51 return ud;
53 EXPORT_SYMBOL(of_xudma_dev_get);
55 struct device *xudma_get_device(struct udma_dev *ud)
57 return ud->dev;
59 EXPORT_SYMBOL(xudma_get_device);
61 struct k3_ringacc *xudma_get_ringacc(struct udma_dev *ud)
63 return ud->ringacc;
65 EXPORT_SYMBOL(xudma_get_ringacc);
67 u32 xudma_dev_get_psil_base(struct udma_dev *ud)
69 return ud->psil_base;
71 EXPORT_SYMBOL(xudma_dev_get_psil_base);
73 struct udma_tisci_rm *xudma_dev_get_tisci_rm(struct udma_dev *ud)
75 return &ud->tisci_rm;
77 EXPORT_SYMBOL(xudma_dev_get_tisci_rm);
79 int xudma_alloc_gp_rflow_range(struct udma_dev *ud, int from, int cnt)
81 return __udma_alloc_gp_rflow_range(ud, from, cnt);
83 EXPORT_SYMBOL(xudma_alloc_gp_rflow_range);
85 int xudma_free_gp_rflow_range(struct udma_dev *ud, int from, int cnt)
87 return __udma_free_gp_rflow_range(ud, from, cnt);
89 EXPORT_SYMBOL(xudma_free_gp_rflow_range);
91 bool xudma_rflow_is_gp(struct udma_dev *ud, int id)
93 if (!ud->rflow_gp_map)
94 return false;
96 return !test_bit(id, ud->rflow_gp_map);
98 EXPORT_SYMBOL(xudma_rflow_is_gp);
100 #define XUDMA_GET_PUT_RESOURCE(res) \
101 struct udma_##res *xudma_##res##_get(struct udma_dev *ud, int id) \
103 return __udma_reserve_##res(ud, UDMA_TP_NORMAL, id); \
105 EXPORT_SYMBOL(xudma_##res##_get); \
107 void xudma_##res##_put(struct udma_dev *ud, struct udma_##res *p) \
109 clear_bit(p->id, ud->res##_map); \
111 EXPORT_SYMBOL(xudma_##res##_put)
112 XUDMA_GET_PUT_RESOURCE(tchan);
113 XUDMA_GET_PUT_RESOURCE(rchan);
115 struct udma_rflow *xudma_rflow_get(struct udma_dev *ud, int id)
117 return __udma_get_rflow(ud, id);
119 EXPORT_SYMBOL(xudma_rflow_get);
121 void xudma_rflow_put(struct udma_dev *ud, struct udma_rflow *p)
123 __udma_put_rflow(ud, p);
125 EXPORT_SYMBOL(xudma_rflow_put);
127 int xudma_get_rflow_ring_offset(struct udma_dev *ud)
129 return ud->tflow_cnt;
131 EXPORT_SYMBOL(xudma_get_rflow_ring_offset);
133 #define XUDMA_GET_RESOURCE_ID(res) \
134 int xudma_##res##_get_id(struct udma_##res *p) \
136 return p->id; \
138 EXPORT_SYMBOL(xudma_##res##_get_id)
139 XUDMA_GET_RESOURCE_ID(tchan);
140 XUDMA_GET_RESOURCE_ID(rchan);
141 XUDMA_GET_RESOURCE_ID(rflow);
143 /* Exported register access functions */
144 #define XUDMA_RT_IO_FUNCTIONS(res) \
145 u32 xudma_##res##rt_read(struct udma_##res *p, int reg) \
147 if (!p) \
148 return 0; \
149 return udma_read(p->reg_rt, reg); \
151 EXPORT_SYMBOL(xudma_##res##rt_read); \
153 void xudma_##res##rt_write(struct udma_##res *p, int reg, u32 val) \
155 if (!p) \
156 return; \
157 udma_write(p->reg_rt, reg, val); \
159 EXPORT_SYMBOL(xudma_##res##rt_write)
160 XUDMA_RT_IO_FUNCTIONS(tchan);
161 XUDMA_RT_IO_FUNCTIONS(rchan);
163 int xudma_is_pktdma(struct udma_dev *ud)
165 return ud->match_data->type == DMA_TYPE_PKTDMA;
167 EXPORT_SYMBOL(xudma_is_pktdma);
169 int xudma_pktdma_tflow_get_irq(struct udma_dev *ud, int udma_tflow_id)
171 const struct udma_oes_offsets *oes = &ud->soc_data->oes;
173 return msi_get_virq(ud->dev, udma_tflow_id + oes->pktdma_tchan_flow);
175 EXPORT_SYMBOL(xudma_pktdma_tflow_get_irq);
177 int xudma_pktdma_rflow_get_irq(struct udma_dev *ud, int udma_rflow_id)
179 const struct udma_oes_offsets *oes = &ud->soc_data->oes;
181 return msi_get_virq(ud->dev, udma_rflow_id + oes->pktdma_rchan_flow);
183 EXPORT_SYMBOL(xudma_pktdma_rflow_get_irq);