42288fac598f08fbd419cd44fc1b33d6bf8f5e5e
[oweals/u-boot.git] / arch / sparc / cpu / leon3 / ambapp_low_c.S
1 /* C-interface for AMBA PnP scanning functions implemented in
2  * ambapp_low.S. At the point the memory and stack can be
3  * used.
4  *
5  * (C) Copyright 2010, 2015
6  * Daniel Hellstrom, Cobham Gaisler, daniel@gaisler.com.
7  *
8  * SPDX-License-Identifier:     GPL-2.0+
9  */
10
11
12         .seg    "text"
13         .extern _nomem_ambapp_find_buses
14         .extern _nomem_find_apb
15         .extern _nomem_find_ahb
16
17         .globl  ambapp_find_buses
18         .globl  ambapp_find_apb
19         .globl  ambapp_find_ahb
20
21
22 /* C-interface for _nomem_ambapp_find_buses used when memory is available.
23  */
24 ambapp_find_buses:
25         save    %sp, -104, %sp
26         mov     %i1, %l7        /* Save second argument */
27         call _nomem_ambapp_find_buses
28          mov    %i0, %o0
29
30         /* Store result */
31         st      %g0, [%l7+0x00]
32         st      %i0, [%l7+0x04]
33         st      %i1, [%l7+0x08]
34         st      %i2, [%l7+0x0c]
35         st      %i3, [%l7+0x10]
36         st      %i4, [%l7+0x14]
37         st      %i5, [%l7+0x18]
38
39         ret
40          restore
41
42 /* C-interface for _nomem_find_apb used when memory is available.
43  *
44  * void ambapp_find_apb(
45  *      struct ambapp_bus *abus,
46  *      unsigned int dev_vend,
47  *      int index,
48  *      struct ambapp_find_apb_info *result
49  *      );
50  *
51  */
52 ambapp_find_apb:
53         save    %sp, -104, %sp
54
55         mov     %i3, %l7        /* Save second argument */
56         mov     %i1, %o1
57         mov     %i2, %o2
58
59         /* Initialize buses available in system */
60         ld      [%i0+0x08], %i1
61         ld      [%i0+0x0c], %i2
62         ld      [%i0+0x10], %i3
63         ld      [%i0+0x14], %i4
64         ld      [%i0+0x18], %i5
65
66         call _nomem_find_apb
67          ld     [%i0+0x04], %i0
68
69         st      %o2, [%l7+0x08] /* Decremented Index */
70         st      %o3, [%l7]      /* PnP configuration address of APB Device */
71         st      %o4, [%l7+0x04] /* AHB Bus Index of AHB/APB bridge and APB Device */
72         mov     %o0, %i0
73         ret
74          restore
75
76 /* C-interface for _nomem_find_ahb used when memory is available.
77  *
78  * void ambapp_find_ahb(
79  *      struct ambapp_bus *abus,
80  *      unsigned int dev_vend,
81  *      int index,
82  *      int type,
83  *      struct ambapp_find_ahb_info *result
84  *      );
85  *
86  */
87 ambapp_find_ahb:
88         save    %sp, -104, %sp
89
90         mov     %i4, %l7        /* Save second argument */
91         clr     %o0
92         mov     %i1, %o1
93         mov     %i2, %o2
94         clr     %o3
95         clr     %o4
96         mov     %i3, %o5
97
98         /* Initialize buses available in system */
99         ld      [%i0+0x08], %i1
100         ld      [%i0+0x0c], %i2
101         ld      [%i0+0x10], %i3
102         ld      [%i0+0x14], %i4
103         ld      [%i0+0x18], %i5
104
105         call _nomem_find_ahb
106          ld     [%i0+0x04], %i0
107
108         st      %o2, [%l7+0x08] /* Decremented Index */
109         st      %o3, [%l7]      /* PnP configuration address of AHB Device */
110         st      %o4, [%l7+0x04] /* AHB Bus Index of AHB Device */
111         mov     %o0, %i0
112         ret
113          restore