InitModule 6.65 KB
Newer Older
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
;
; Copyright (c) 2011, Tank Stage Lighting
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;     * Redistributions of source code must retain the above copyright
;       notice, this list of conditions and the following disclaimer.
;     * Redistributions in binary form must reproduce the above copyright
;       notice, this list of conditions and the following disclaimer in the
;       documentation and/or other materials provided with the distribution.
;     * Neither the name of the copyright holder nor the names of their
;       contributors may be used to endorse or promote products derived from
;       this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;

;s.InitModule

Ben Avison's avatar
Ben Avison committed
30 31 32 33
 [ :LNOT::DEF: ROM
        GBLL    ROM
ROM     SETL    {FALSE}
 ]
34

Ben Avison's avatar
Ben Avison committed
35
 [ :LNOT: ROM
36
	IMPORT	|__RelocCode|		; Link symbol for relocation routine
Ben Avison's avatar
Ben Avison committed
37
 ]
38 39 40 41 42 43 44 45 46


;******************************************************************************
;
;       RM_Init - Initialisation entry point
;


RM_Init
Robert Sprowson's avatar
Robert Sprowson committed
47
        Push	"r0-r11,lr"
Ben Avison's avatar
Ben Avison committed
48
 [ :LNOT: ROM
49
        BL      |__RelocCode|		; initialise absolute code pointers
Ben Avison's avatar
Ben Avison committed
50
 ]
Robert Sprowson's avatar
Robert Sprowson committed
51
        MOV     r0,#ModHandReason_Claim	;
52 53 54 55 56 57 58 59 60 61 62 63
        LDR     r3,maxRMA		;
        SWI     XOS_Module		;
	BVS	initerror		;
        STR     r2,[r12]		; save RMA pointer
	MOV	r12,r2			;
	ADD	r0,r2,#MainTemp		; Clear only lower bits
        MOV     r1,#0			;
10					; clear memory
        STR	r1,[r2],#4		;
        CMP     r2,r0			;end ?
        BLT     %BT10
;get board type for maps
Robert Sprowson's avatar
Robert Sprowson committed
64 65
	MOV	r0,#HALDeviceType_Comms	;comms
	ADD	r0,r0,#HALDeviceComms_GPIO	;gpio
66 67 68 69 70 71 72 73 74 75 76 77 78
	MOV	r1,#0			;first call
	MOV	r8,#4			;OS_Hardware 4
	SWI	XOS_Hardware		;call it
	BVS	initerror1		;
	CMP	r1,#-1			;bad call ?
	MOVEQ	r1,#hal_dummy		;
	STREQ	r1,[r12,#halproc]	;
	MOVEQ	r1,#hal_dummy		;
	STREQ	r1,[r12,#halboard]	;
	MOVEQ	r1,#1			;
	STREQ	r1,[r12,#halrevision]	;
	MOVEQ	r0,#hal_rev_dummy	;board type default
	BEQ	%FT100			;
79 80 81 82
;check API matches our assumption
	LDR	r1,[r2,#HALDevice_Version]
	TEQ	r1,#0
	BNE	initerror1		;want API 0.00
83
;find real board type
Robert Sprowson's avatar
Robert Sprowson committed
84
	LDR	r1,[r2,#HALDevice_GPIORevision]
85
	STR	r1,[r12,#halrevision]	;
Robert Sprowson's avatar
Robert Sprowson committed
86
	LDR	r0,[r2,#HALDevice_GPIOType]
87
	STR	r0,[r12,#halboard]	;
Robert Sprowson's avatar
Robert Sprowson committed
88
	LDRH	r3,[r2,#HALDevice_ID]
89
	STR	r3,[r12,#halproc]	;
90 91 92
;omap3 section
	CMP	r3,#HALDeviceID_GPIO_OMAP3
	BNE	%FT400			;not omap3 try something else
93
	ADR	r2,omap3_gpio_tables	;pointer to board table
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
	CMP	r0,#GPIOType_OMAP3_BeagleBoard
	BNE	%FT20
	CMP	r1,#GPIORevision_BeagleBoard_xMC
	BLE	%FT99			;
20	CMP	r0,#GPIOType_OMAP3_DevKit8000
	BNE	%FT21
	CMP	r1,#GPIORevision_DevKit8000_Unknown
	BLE	%FT99			;
21	CMP	r0,#GPIOType_OMAP3_IGEPv2
	BNE	%FT22
	CMP	r1,#GPIORevision_IGEPv2_C
	BLE	%FT99			;
22	CMP	r0,#GPIOType_OMAP3_Pandora
	BNE	%FT23
	CMP	r1,#GPIORevision_Pandora_Unknown
	BLE	%FT99			;
23	ADR	r2,dummy_gpio_table	;pointer to board table
111 112
	MOV	r0,#hal_rev_dummy	;board type default if it falls through
	B	%FT100			;default if not any
113
;omap4 section
ROOL's avatar
ROOL committed
114 115
400
	CMP	r3,#HALDeviceID_GPIO_OMAP4
116 117 118 119 120 121 122 123 124
	BNE	%FT500			;not omap4 try something else
	ADR	r2,omap4_gpio_tables	;pointer to board table
	CMP	r0,#GPIOType_OMAP4_Panda
	BNE	%FT24
	CMP	r1,#GPIORevision_PandaES
	BLE	%FT99			;
24	ADR	r2,dummy_gpio_table	;pointer to board table
	MOV	r0,#hal_rev_dummy	;board type default if it falls through
	B	%FT100			;default if not any
125
;bcm section
ROOL's avatar
ROOL committed
126 127 128
500
	[ {FALSE}
	CMP	r3,#HALDeviceID_GPIO_BCM2835
129 130
	BNE	%FT600			;not pi try something else
	ADR	r2,bcm2835_gpio_tables	;pointer to board table
131 132
	CMP	r0,#GPIOType_BCM2835_RaspberryPi
	BNE	%FT28
133
	CMP	r1,#GPIORevision_RaspberryPi_Mk2_B_1
134 135
	BLE	%FT99			;
28	ADR	r2,dummy_gpio_table	;pointer to board table
136 137
	MOV	r0,#hal_rev_dummy	;board type default if it falls through
	B	%FT100			;default if not any
ROOL's avatar
ROOL committed
138
	]
139
;xxxx section
ROOL's avatar
ROOL committed
140 141
600
	ADR	r2,dummy_gpio_table	;pointer to board table
142 143
	MOV	r0,#hal_rev_dummy	;board type default if it falls through
	B	%FT100			;default if not any
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
;add more if needed
99	LDR	r0,[r2,r0, LSL #2]	;
	ADD	r0,r0,r1		;add revision to base
100	STR	r0,[r12,#machine]	;
	BL	Get_Board		;get name
;map in our memory
	MOV	r0,#-1			;setup logical store
	ADD	r5,r12,#logicalstore	;store for logical address
	ADD	r4,r12,#logicalstore1	;
101	STR	r0,[r5],#4		;
	CMP	r5,r4			;
	BLO	%BT101
	BL	get_table		;setup pointer
	LDR	r4,[r1,#physical_table]	;pointer to Physical memory
	CMP	r4,#-1			;no maps
	MOVEQ	r1,r4			;end table
	ADD	r5,r12,#logicalstore	;store for logical address
	BEQ	%FT30			;
20	MOV	r2,#mapsize		;size to map in
	MOV	r0,#13			;map in permanent
	LDR	r1,[r4],#4		;get first map
	CMP	r1,#-1			;last one ?
	BEQ	%FT30			;
	SWI	XOS_Memory		;
	BVS	initerror2		;
	STR	r3,[r5],#4		;store logical address
	B	%BT20			;next
30	STR	r1,[r5]			;store end flag
	BL	get_table		;setup pointer
	LDR	r4,[r1,#map]		;main control
	CMP	r4,#-1			;no map
	ADD	r5,r12,#logicalstore1	;store for logical address
	STREQ	r4,[r5]			;store logical address
	BEQ	%FT40			;
	MOV	r2,#padsize		;
	LDR	r1,[r4]			;
	SWINE	XOS_Memory		;
	BVS	initerror3		;
	STR	r3,[r5]			;store logical address
40	BL	get_table		;setup pointer
	LDR	r4,[r1,#srambase]	;map in sram
	CMP	r4,#-1			;no sram
	ADD	r5,r12,#logicalsram	;store for logical address
	STREQ	r4,[r5]			;store logical address
	BEQ	%FT50			;
	MOV	r2,#sramsize		;
	LDR	r1,[r4]			;
	SWI	XOS_Memory		;
	BVS	initerror4		;
	STR	r3,[r5]			;store logical address
50
Robert Sprowson's avatar
Robert Sprowson committed
195
	MOV	r0,#TickerV
196 197
	ADRL	r1,FlashVector		;
	MOV	r2,r12			;
Robert Sprowson's avatar
Robert Sprowson committed
198 199
	SWI	XOS_Claim		;
	BVS	initerrortick
200 201 202 203 204

	MOV	r0,#1			;protect i2c
	LDR	r10,[r12,#machine]	;get board type
	CMP	r10,#hal_rev_dummy	;is it unkown
	BEQ	%FT60
ROOL's avatar
ROOL committed
205
	[ {FALSE}
206 207 208 209
	CMP	r10,#hal_rev_pi		;is it a Pi
	BLGE	Pi_Enable_I2C		;
	BLLT	Enable_I2C		;
	BL	get_i2c_info		;get extender info
ROOL's avatar
ROOL committed
210
	]
Robert Sprowson's avatar
Robert Sprowson committed
211 212
60
	CLRV
Robert Sprowson's avatar
Robert Sprowson committed
213
	Pull	"r0-r11,pc"		;
214 215 216 217 218 219 220 221

maxRMA	DCD	RMAlimit
dummy_gpio_table
	DCD	hal_rev_dummy
omap3_gpio_tables
	DCD	hal_rev_beagle
	DCD	hal_rev_dev
	DCD	hal_rev_igep
222 223
	DCD	hal_rev_pandora
omap4_gpio_tables
224
	DCD	hal_rev_panda
ROOL's avatar
ROOL committed
225
	[ {FALSE}
226 227
bcm2835_gpio_tables
	DCD	hal_rev_pi
ROOL's avatar
ROOL committed
228
	]
229 230 231

;******************************************************************************
	END