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