1 ;
2 ; TEXAS INSTRUMENTS TEXT FILE LICENSE
3 ;
4 ; Copyright (c) 2018-2019 Texas Instruments Incorporated
5 ;
6 ; All rights reserved not granted herein.
7 ;
8 ; Limited License.
9 ;
10 ; Texas Instruments Incorporated grants a world-wide, royalty-free, non-exclusive
11 ; license under copyrights and patents it now or hereafter owns or controls to
12 ; make, have made, use, import, offer to sell and sell ("Utilize") this software
13 ; subject to the terms herein. With respect to the foregoing patent license,
14 ; such license is granted solely to the extent that any such patent is necessary
15 ; to Utilize the software alone. The patent license shall not apply to any
16 ; combinations which include this software, other than combinations with devices
17 ; manufactured by or for TI (“TI Devices”). No hardware patent is licensed hereunder.
18 ;
19 ; Redistributions must preserve existing copyright notices and reproduce this license
20 ; (including the above copyright notice and the disclaimer and (if applicable) source
21 ; code license limitations below) in the documentation and/or other materials provided
22 ; with the distribution.
23 ;
24 ; Redistribution and use in binary form, without modification, are permitted provided
25 ; that the following conditions are met:
26 ; No reverse engineering, decompilation, or disassembly of this software is
27 ; permitted with respect to any software provided in binary form.
28 ; Any redistribution and use are licensed by TI for use only with TI Devices.
29 ; Nothing shall obligate TI to provide you with source code for the software
30 ; licensed and provided to you in object code.
31 ;
32 ; If software source code is provided to you, modification and redistribution of the
33 ; source code are permitted provided that the following conditions are met:
34 ; Any redistribution and use of the source code, including any resulting derivative
35 ; works, are licensed by TI for use only with TI Devices.
36 ; Any redistribution and use of any object code compiled from the source code
37 ; and any resulting derivative works, are licensed by TI for use only with TI Devices.
38 ;
39 ; Neither the name of Texas Instruments Incorporated nor the names of its suppliers
40 ; may be used to endorse or promote products derived from this software without
41 ; specific prior written permission.
42 ;
43 ; DISCLAIMER.
44 ;
45 ; THIS SOFTWARE IS PROVIDED BY TI AND TI’S LICENSORS "AS IS" AND ANY EXPRESS OR IMPLIED
46 ; WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
47 ; AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL TI AND TI’S
48 ; LICENSORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49 ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
50 ; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
51 ; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
53 ; EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 ;---------------------
56 ; File:psiloop.h
57 ;PSI LOOPBACK ROUTINES
58 ; (diagnostics)
59 ; PSI LOOPBACK runs on
60 ; BG on PRU, but looks
61 ; like a tx task
62 ; (e.g. will use
63 ; tx task registers)
64 ; if this runs, no TX Will run
65 ; and no RX should run since this is
66 ; grabing PSI widget for its use
67 ; always uses unit 0
68 ;---------------------
70 ;'tx' init for psi loopback
71 PSILOOP_TX_INIT .macro r_d, runit
72 flip_tx_r10_r23
73 mov TxRegs.ds_flags, r_d.w2 ;descriptor2(flags, etc)
74 mov GRegs.tx.b.len, r_d.w0 ;save length we are expecting to transmit
75 ldi GRegs.tx.b.state, TX_S_LOOP
76 PSILOOP_TX_POLL runit, nd_lab?, eop_lab?
77 nd_lab?:
78 eop_lab?:
79 flip_tx_r10_r23
80 .endm
82 ;poll routine for bg. If dma present, it will process it
83 PSILOOP_TX_POLL .macro runit, no_data_label,eop_label
84 XFR2VBUS_POLL_READ runit
85 qbbc no_data_label, r18, 2
87 ;have data ready
88 qbge tx_cont1a?, GRegs.tx.b.len, 64
89 ;read the 64 bytes & write to PSI in 4 transactions
90 XFR2VBUS_READ64_RESULT runit
91 ldi32 r1, MD_DATA0
92 PSI_WRITE
93 LEBE2_5_swap_6_9
94 PSI_WRITE
95 LEBE2_9_swap_10_17
96 LEBE2_5_swap_6_9
97 PSI_WRITE
98 LEBE2_5_swap_6_9
99 PSI_WRITE
100 sub GRegs.tx.b.len, GRegs.tx.b.len, 64
101 jmp tx_done?
103 tx_cont1a?: ;eop, (again always using unit a)
104 XFR2VBUS_CANCEL_READ_AUTO_64_CMD (runit)
105 XFR2VBUS_READ64_RESULT (runit)
106 qble mt16?, GRegs.tx.b.len, 16
107 ;just have 16bytes or less
108 ldi32 r1, MD_DATA1
109 add r0.b0, GRegs.tx.b.len, 4
110 PSI_WRITE_N
111 jmp tx_done2?
112 mt16?:
113 qble mt32?, GRegs.tx.b.len, 32
114 ;just have 32bytes or less
115 ldi32 r0, MD_DATA0
116 PSI_WRITE
117 LEBE2_5_swap_6_9
118 ldi32 r1, MD_DATA1
119 sub GRegs.tx.b.len, GRegs.tx.b.len,16
120 add r0.b0, GRegs.tx.b.len, 4
121 PSI_WRITE_N
122 jmp tx_done2?
123 mt32?:
124 qble mt48?, GRegs.tx.b.len, 48
125 ;just have 48bytes or less
126 ldi32 r0, MD_DATA0
127 PSI_WRITE
128 LEBE2_5_swap_6_9
129 PSI_WRITE
130 LEBE2_9_swap_10_17
131 LEBE2_5_swap_6_9
132 ldi32 r1, MD_DATA1
133 sub GRegs.tx.b.len, GRegs.tx.b.len,32
134 add r0.b0, GRegs.tx.b.len, 4
135 PSI_WRITE_N
136 jmp tx_done2?
137 mt48?:
138 ;have more than 48
139 ldi32 r0, MD_DATA0
140 PSI_WRITE
141 LEBE2_5_swap_6_9
142 PSI_WRITE
143 LEBE2_9_swap_10_17
144 LEBE2_5_swap_6_9
145 PSI_WRITE
146 LEBE2_5_swap_6_9
147 ldi32 r1, MD_DATA1
148 sub GRegs.tx.b.len, GRegs.tx.b.len,48
149 add r0.b0, GRegs.tx.b.len, 4
150 PSI_WRITE_N
151 tx_done2?:
152 ;say we are done
153 SPIN_SET_LOCK_LOC PRU_RTU_EOD_P_FLAG
154 SPIN_CLR_LOCK_LOC PRU_RTU_EOD_P_FLAG
155 ;set tx state
156 ldi GRegs.tx.b.state, TX_S_IDLE
157 jmp eop_label
158 tx_done?:
159 .endm