1/*
2 * linux/arch/m68knommu/platform/68328/head-pilot.S
3 * - A startup file for the MC68328
4 *
5 * Copyright (C) 1998  D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>,
6 *                     Kenneth Albanowski <kjahds@kjahds.com>,
7 *                     The Silver Hammer Group, Ltd.
8 *
9 * (c) 1995, Dionne & Associates
10 * (c) 1995, DKG Display Tech.
11 */
12
13#define ASSEMBLY
14
15#define IMMED #
16#define	DBG_PUTC(x)	moveb IMMED x, 0xfffff907
17
18
19.global _stext
20.global _start
21
22.global _rambase
23.global _ramvec
24.global _ramstart
25.global _ramend
26
27.global penguin_bits
28
29#ifdef CONFIG_PILOT
30
31#define IMR 0xFFFFF304
32
33	.data
34	.align 16
35
36penguin_bits:
37#include "bootlogo.rh"
38
39#endif
40
41/*****************************************************************************/
42
43.data
44
45/*
46 *      Set up the usable of RAM stuff. Size of RAM is determined then
47 *      an initial stack set up at the end.
48 */
49.align 4
50_ramvec:
51.long   0
52_rambase:
53.long   0
54_ramstart:
55.long   0
56_ramend:
57.long   0
58
59.text
60
61_start:
62_stext:
63
64
65#ifdef CONFIG_M68328
66
67#ifdef CONFIG_PILOT
68	.byte 0x4e, 0xfa, 0x00, 0x0a /* Jmp +X bytes */
69	.byte 'b', 'o', 'o', 't'
70	.word 10000
71
72	nop
73#endif
74
75	moveq	#0, %d0
76	movew   %d0, 0xfffff618 /* Watchdog off */
77	movel	#0x00011f07, 0xfffff114 /* CS A1 Mask */
78
79	movew	#0x0800, 0xfffff906 /* Ignore CTS */
80	movew	#0x010b, 0xfffff902 /* BAUD to 9600 */
81
82	movew	#0x2410, 0xfffff200 /* PLLCR */
83	movew	#0x123, 0xfffff202 /* PLLFSR */
84
85#ifdef CONFIG_PILOT
86	moveb	#0, 0xfffffA27 /* LCKCON */
87	movel   #_start, 0xfffffA00 /* LSSA */
88	moveb   #0xa, 0xfffffA05 /* LVPW */
89	movew	#0x9f, 0xFFFFFa08 /* LXMAX */
90	movew	#0x9f, 0xFFFFFa0a /* LYMAX */
91	moveb   #9, 0xfffffa29 /* LBAR */
92	moveb   #0, 0xfffffa25 /* LPXCD */
93	moveb	#0x04, 0xFFFFFa20 /* LPICF */
94	moveb	#0x58, 0xfffffA27 /* LCKCON */
95	moveb	#0x85, 0xfffff429 /* PFDATA */
96	moveb	#0xd8, 0xfffffA27 /* LCKCON */
97	moveb	#0xc5, 0xfffff429 /* PFDATA */
98	moveb	#0xd5, 0xfffff429 /* PFDATA */
99
100	moveal	#0x00100000, %a3
101	moveal	#0x100ffc00, %a4
102#endif /* CONFIG_PILOT */
103
104#endif /* CONFIG_M68328 */
105
106	movew   #0x2700, %sr
107	lea	%a4@(-4), %sp
108
109	DBG_PUTC('\r')
110	DBG_PUTC('\n')
111	DBG_PUTC('A')
112
113   	moveq   #0,%d0
114	movew	#16384, %d0  /* PLL settle wait loop */
115L0:
116	subw	#1, %d0
117	bne	L0
118
119	DBG_PUTC('B')
120
121	/* Copy command line from beginning of RAM (+16) to end of bss */
122	movel	#CONFIG_VECTORBASE, %d7
123	addl	#16, %d7
124	moveal	%d7, %a0
125	moveal	#_ebss, %a1
126	lea	%a1@(512), %a2
127
128	DBG_PUTC('C')
129
130	/* Copy %a0 to %a1 until %a1 == %a2 */
131L2:
132	movel	%a0@+, %d0
133	movel	%d0, %a1@+
134	cmpal	%a1, %a2
135	bhi	L2
136
137	/* Copy data+init segment from ROM to RAM */
138	moveal	#_etext, %a0
139	moveal	#_sdata, %a1
140	moveal	#__init_end, %a2
141
142	DBG_PUTC('D')
143
144	/* Copy %a0 to %a1 until %a1 == %a2 */
145LD1:
146	movel	%a0@+, %d0
147	movel	%d0, %a1@+
148	cmpal	%a1, %a2
149	bhi	LD1
150
151	DBG_PUTC('E')
152
153	moveal	#_sbss, %a0
154	moveal	#_ebss, %a1
155
156	/* Copy 0 to %a0 until %a0 == %a1 */
157L1:
158	movel	#0, %a0@+
159	cmpal	%a0, %a1
160	bhi	L1
161
162	DBG_PUTC('F')
163
164	/* Copy command line from end of bss to command line */
165	moveal	#_ebss, %a0
166	moveal	#command_line, %a1
167	lea	%a1@(512), %a2
168
169	DBG_PUTC('G')
170
171	/* Copy %a0 to %a1 until %a1 == %a2 */
172L3:
173	movel	%a0@+, %d0
174	movel	%d0, %a1@+
175	cmpal	%a1, %a2
176	bhi	L3
177
178	movel	#_sdata, %d0
179	movel	%d0, _rambase
180	movel	#_ebss,	%d0
181	movel	%d0, _ramstart
182
183	movel	%a4, %d0
184	subl	#4096, %d0	/* Reserve 4K of stack */
185	moveq	#79, %d7
186	movel	%d0, _ramend
187
188	movel	%a3, %d0
189	movel	%d0, rom_length
190
191	pea	0
192	pea	env
193	pea	%sp@(4)
194	pea	0
195
196	DBG_PUTC('H')
197
198#ifdef CONFIG_PILOT
199	movel	#penguin_bits, 0xFFFFFA00
200	moveb	#10, 0xFFFFFA05
201	movew	#160, 0xFFFFFA08
202	movew	#160, 0xFFFFFA0A
203#endif /* CONFIG_PILOT */
204
205	DBG_PUTC('I')
206
207	lea	init_thread_union, %a0
208	lea	0x2000(%a0), %sp
209
210	DBG_PUTC('J')
211	DBG_PUTC('\r')
212	DBG_PUTC('\n')
213
214	jsr	start_kernel
215_exit:
216
217	jmp	_exit
218
219
220	.data
221env:
222	.long	0
223