Merge tag 'v5.15.57' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / drivers / usb / host / dwc_otg / dwc_otg_fiq_stub.S
1 /*
2  * dwc_otg_fiq_fsm.S - assembly stub for the FSM FIQ
3  *
4  * Copyright (c) 2013 Raspberry Pi Foundation
5  *
6  * Author: Jonathan Bell <jonathan@raspberrypi.org>
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *      * Redistributions of source code must retain the above copyright
12  *        notice, this list of conditions and the following disclaimer.
13  *      * Redistributions in binary form must reproduce the above copyright
14  *        notice, this list of conditions and the following disclaimer in the
15  *        documentation and/or other materials provided with the distribution.
16  *      * Neither the name of Raspberry Pi nor the
17  *        names of its contributors may be used to endorse or promote products
18  *        derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
24  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31
32
33 #include <asm/assembler.h>
34 #include <linux/linkage.h>
35
36
37 .text
38
39 .global _dwc_otg_fiq_stub_end;
40
41 /**
42   * _dwc_otg_fiq_stub() - entry copied to the FIQ vector page to allow
43   * a C-style function call with arguments from the FIQ banked registers.
44   * r0 = &hcd->fiq_state
45   * r1 = &hcd->num_channels
46   * r2 = &hcd->dma_buffers
47   * Tramples: r0, r1, r2, r4, fp, ip
48   */
49
50 ENTRY(_dwc_otg_fiq_stub)
51         /* Stash unbanked regs - SP will have been set up for us */
52         mov ip, sp;
53         stmdb sp!, {r0-r12, lr};
54 #ifdef FIQ_DEBUG
55         // Cycle profiling - read cycle counter at start
56         mrc p15, 0, r5, c15, c12, 1;
57 #endif
58         /* r11 = fp, don't trample it */
59         mov r4, fp;
60         /* set EABI frame size */
61         sub fp, ip, #512;
62
63         /* for fiq NOP mode - just need state */
64         mov r0, r8;
65         /* r9 = num_channels */
66         mov r1, r9;
67         /* r10 = struct *dma_bufs */
68 //      mov r2, r10;
69
70         /* r4 = &fiq_c_function */
71         blx r4;
72 #ifdef FIQ_DEBUG
73         mrc p15, 0, r4, c15, c12, 1;
74         subs r5, r5, r4;
75         // r5 is now the cycle count time for executing the FIQ. Store it somewhere?
76 #endif
77         ldmia sp!, {r0-r12, lr};
78         subs pc, lr, #4;
79 _dwc_otg_fiq_stub_end:
80 END(_dwc_otg_fiq_stub)