summaryrefslogtreecommitdiff
path: root/arch/sparc/cpu/leon3/ambapp_low_c.S
blob: 42288fac598f08fbd419cd44fc1b33d6bf8f5e5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/* C-interface for AMBA PnP scanning functions implemented in
 * ambapp_low.S. At the point the memory and stack can be
 * used.
 *
 * (C) Copyright 2010, 2015
 * Daniel Hellstrom, Cobham Gaisler, daniel@gaisler.com.
 *
 * SPDX-License-Identifier:	GPL-2.0+
 */


	.seg	"text"
	.extern	_nomem_ambapp_find_buses
	.extern	_nomem_find_apb
	.extern	_nomem_find_ahb

	.globl	ambapp_find_buses
	.globl	ambapp_find_apb
	.globl	ambapp_find_ahb


/* C-interface for _nomem_ambapp_find_buses used when memory is available.
 */
ambapp_find_buses:
	save	%sp, -104, %sp
	mov	%i1, %l7	/* Save second argument */
	call _nomem_ambapp_find_buses
	 mov	%i0, %o0

	/* Store result */
	st	%g0, [%l7+0x00]
	st	%i0, [%l7+0x04]
	st	%i1, [%l7+0x08]
	st	%i2, [%l7+0x0c]
	st	%i3, [%l7+0x10]
	st	%i4, [%l7+0x14]
	st	%i5, [%l7+0x18]

	ret
	 restore

/* C-interface for _nomem_find_apb used when memory is available.
 *
 * void ambapp_find_apb(
 *	struct ambapp_bus *abus,
 *	unsigned int dev_vend,
 *	int index,
 *	struct ambapp_find_apb_info *result
 *	);
 *
 */
ambapp_find_apb:
	save	%sp, -104, %sp

	mov	%i3, %l7	/* Save second argument */
	mov	%i1, %o1
	mov	%i2, %o2

	/* Initialize buses available in system */
	ld	[%i0+0x08], %i1
	ld	[%i0+0x0c], %i2
	ld	[%i0+0x10], %i3
	ld	[%i0+0x14], %i4
	ld	[%i0+0x18], %i5

	call _nomem_find_apb
	 ld	[%i0+0x04], %i0

	st	%o2, [%l7+0x08]	/* Decremented Index */
	st	%o3, [%l7]	/* PnP configuration address of APB Device */
	st	%o4, [%l7+0x04]	/* AHB Bus Index of AHB/APB bridge and APB Device */
	mov	%o0, %i0
	ret
	 restore

/* C-interface for _nomem_find_ahb used when memory is available.
 *
 * void ambapp_find_ahb(
 *	struct ambapp_bus *abus,
 *	unsigned int dev_vend,
 *	int index,
 *	int type,
 *	struct ambapp_find_ahb_info *result
 *	);
 *
 */
ambapp_find_ahb:
	save	%sp, -104, %sp

	mov	%i4, %l7	/* Save second argument */
	clr	%o0
	mov	%i1, %o1
	mov	%i2, %o2
	clr	%o3
	clr	%o4
	mov	%i3, %o5

	/* Initialize buses available in system */
	ld	[%i0+0x08], %i1
	ld	[%i0+0x0c], %i2
	ld	[%i0+0x10], %i3
	ld	[%i0+0x14], %i4
	ld	[%i0+0x18], %i5

	call _nomem_find_ahb
	 ld	[%i0+0x04], %i0

	st	%o2, [%l7+0x08]	/* Decremented Index */
	st	%o3, [%l7]	/* PnP configuration address of AHB Device */
	st	%o4, [%l7+0x04]	/* AHB Bus Index of AHB Device */
	mov	%o0, %i0
	ret
	 restore