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 int 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 } 11 EXPORT_SYMBOL(xudma_navss_psil_pair); 12 13 int 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 } 17 EXPORT_SYMBOL(xudma_navss_psil_unpair); 18 19 struct 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"); 45 return ERR_PTR(-EPROBE_DEFER); 46 } 47 48 return ud; 49 } 50 EXPORT_SYMBOL(of_xudma_dev_get); 51 52 u32 xudma_dev_get_psil_base(struct udma_dev *ud) 53 { 54 return ud->psil_base; 55 } 56 EXPORT_SYMBOL(xudma_dev_get_psil_base); 57 58 struct udma_tisci_rm *xudma_dev_get_tisci_rm(struct udma_dev *ud) 59 { 60 return &ud->tisci_rm; 61 } 62 EXPORT_SYMBOL(xudma_dev_get_tisci_rm); 63 64 int xudma_alloc_gp_rflow_range(struct udma_dev *ud, int from, int cnt) 65 { 66 return __udma_alloc_gp_rflow_range(ud, from, cnt); 67 } 68 EXPORT_SYMBOL(xudma_alloc_gp_rflow_range); 69 70 int xudma_free_gp_rflow_range(struct udma_dev *ud, int from, int cnt) 71 { 72 return __udma_free_gp_rflow_range(ud, from, cnt); 73 } 74 EXPORT_SYMBOL(xudma_free_gp_rflow_range); 75 76 bool xudma_rflow_is_gp(struct udma_dev *ud, int id) 77 { 78 return !test_bit(id, ud->rflow_gp_map); 79 } 80 EXPORT_SYMBOL(xudma_rflow_is_gp); 81 82 #define XUDMA_GET_PUT_RESOURCE(res) \ 83 struct udma_##res *xudma_##res##_get(struct udma_dev *ud, int id) \ 84 { \ 85 return __udma_reserve_##res(ud, false, id); \ 86 } \ 87 EXPORT_SYMBOL(xudma_##res##_get); \ 88 \ 89 void xudma_##res##_put(struct udma_dev *ud, struct udma_##res *p) \ 90 { \ 91 clear_bit(p->id, ud->res##_map); \ 92 } \ 93 EXPORT_SYMBOL(xudma_##res##_put) 94 XUDMA_GET_PUT_RESOURCE(tchan); 95 XUDMA_GET_PUT_RESOURCE(rchan); 96 97 struct udma_rflow *xudma_rflow_get(struct udma_dev *ud, int id) 98 { 99 return __udma_get_rflow(ud, id); 100 } 101 EXPORT_SYMBOL(xudma_rflow_get); 102 103 void xudma_rflow_put(struct udma_dev *ud, struct udma_rflow *p) 104 { 105 __udma_put_rflow(ud, p); 106 } 107 EXPORT_SYMBOL(xudma_rflow_put); 108 109 #define XUDMA_GET_RESOURCE_ID(res) \ 110 int xudma_##res##_get_id(struct udma_##res *p) \ 111 { \ 112 return p->id; \ 113 } \ 114 EXPORT_SYMBOL(xudma_##res##_get_id) 115 XUDMA_GET_RESOURCE_ID(tchan); 116 XUDMA_GET_RESOURCE_ID(rchan); 117 XUDMA_GET_RESOURCE_ID(rflow); 118 119 /* Exported register access functions */ 120 #define XUDMA_RT_IO_FUNCTIONS(res) \ 121 u32 xudma_##res##rt_read(struct udma_##res *p, int reg) \ 122 { \ 123 return udma_##res##rt_read(p, reg); \ 124 } \ 125 EXPORT_SYMBOL(xudma_##res##rt_read); \ 126 \ 127 void xudma_##res##rt_write(struct udma_##res *p, int reg, u32 val) \ 128 { \ 129 udma_##res##rt_write(p, reg, val); \ 130 } \ 131 EXPORT_SYMBOL(xudma_##res##rt_write) 132 XUDMA_RT_IO_FUNCTIONS(tchan); 133 XUDMA_RT_IO_FUNCTIONS(rchan); 134