1/*
2 * linux/arch/arm/boot/compressed/head-sharpsl.S
3 *
4 * Copyright (C) 2004-2005 Richard Purdie <rpurdie@rpsys.net>
5 *
6 * Sharp's bootloader doesn't pass any kind of machine ID
7 * so we have to figure out the machine for ourselves...
8 *
9 * Support for Poodle, Corgi (SL-C700), Shepherd (SL-C750)
10 * Husky (SL-C760), Tosa (SL-C6000), Spitz (SL-C3000),
11 * Akita (SL-C1000) and Borzoi (SL-C3100).
12 *
13 */
14
15#include <linux/linkage.h>
16#include <asm/mach-types.h>
17
18#ifndef CONFIG_PXA_SHARPSL
19#error What am I doing here...
20#endif
21
22		.section        ".start", "ax"
23
24__SharpSL_start:
25
26/* Check for TC6393 - if found we have a Tosa */
27	ldr	r7, .TOSAID
28	mov	r1, #0x10000000		@ Base address of TC6393 chip
29	mov 	r6, #0x03
30	ldrh	r3, [r1, #8]		@ Load TC6393XB Revison: This is 0x0003
31	cmp	r6, r3
32	beq	.SHARPEND		@ Success -> tosa
33
34/* Check for pxa270 - if found, branch */
35	mrc p15, 0, r4, c0, c0		@ Get Processor ID
36	and	r4, r4, #0xffffff00
37	ldr	r3, .PXA270ID
38	cmp	r4, r3
39	beq	.PXA270
40
41/* Check for w100 - if not found we have a Poodle */
42	ldr	r1, .W100ADDR		@ Base address of w100 chip + regs offset
43
44	mov r6, #0x31			@ Load Magic Init value
45	str	r6, [r1, #0x280]	@ to SCRATCH_UMSK
46	mov r5, #0x3000
47.W100LOOP:
48	subs r5, r5, #1
49	bne .W100LOOP
50	mov r6, #0x30			@ Load 2nd Magic Init value
51	str	r6, [r1, #0x280]	@ to SCRATCH_UMSK
52
53	ldr	r6, [r1, #0]		@ Load Chip ID
54	ldr	r3, .W100ID
55	ldr	r7, .POODLEID
56	cmp	r6, r3
57	bne	.SHARPEND			@ We have no w100 - Poodle
58
59/* Check for pxa250 - if found we have a Corgi */
60	ldr	r7, .CORGIID
61	ldr	r3, .PXA255ID
62	cmp	r4, r3
63	blo	.SHARPEND			@ We have a PXA250 - Corgi
64
65/* Check for 64MiB flash - if found we have a Shepherd */
66	bl	get_flash_ids
67	ldr	r7, .SHEPHERDID
68	cmp	r3, #0x76			@ 64MiB flash
69	beq	.SHARPEND			@ We have Shepherd
70
71/* Must be a Husky */
72	ldr	r7, .HUSKYID		@ Must be Husky
73	b .SHARPEND
74
75.PXA270:
76/* Check for 16MiB flash - if found we have Spitz */
77	bl	get_flash_ids
78	ldr	r7, .SPITZID
79	cmp	r3, #0x73			@ 16MiB flash
80	beq	.SHARPEND			@ We have Spitz
81
82/* Check for a second SCOOP chip - if found we have Borzoi */
83	ldr	r1, .SCOOP2ADDR
84	ldr	r7, .BORZOIID
85	mov 	r6, #0x0140
86	strh	r6, [r1]
87	ldrh	r6, [r1]
88	cmp	r6, #0x0140
89	beq	.SHARPEND			@ We have Borzoi
90
91/* Must be Akita */
92	ldr	r7, .AKITAID
93	b	.SHARPEND			@ We have Borzoi
94
95.PXA255ID:
96	.word	0x69052d00		@ PXA255 Processor ID
97.PXA270ID:
98	.word	0x69054100		@ PXA270 Processor ID
99.W100ID:
100	.word	0x57411002		@ w100 Chip ID
101.W100ADDR:
102	.word 	0x08010000		@ w100 Chip ID Reg Address
103.SCOOP2ADDR:
104	.word	0x08800040
105.POODLEID:
106	.word	MACH_TYPE_POODLE
107.CORGIID:
108	.word	MACH_TYPE_CORGI
109.SHEPHERDID:
110	.word	MACH_TYPE_SHEPHERD
111.HUSKYID:
112	.word	MACH_TYPE_HUSKY
113.TOSAID:
114	.word	MACH_TYPE_TOSA
115.SPITZID:
116	.word	MACH_TYPE_SPITZ
117.AKITAID:
118	.word	MACH_TYPE_AKITA
119.BORZOIID:
120	.word	MACH_TYPE_BORZOI
121
122/*
123 * Return: r2 - NAND Manufacturer ID
124 *         r3 - NAND Chip ID
125 * Corrupts: r1
126 */
127get_flash_ids:
128	mov	r1, #0x0c000000		@ Base address of NAND chip
129	ldrb	r3, [r1, #24]		@ Load FLASHCTL
130	bic	r3, r3, #0x11		@ SET NCE
131	orr	r3, r3, #0x0a		@ SET CLR + FLWP
132	strb	r3, [r1, #24]		@ Save to FLASHCTL
133	mov 	r2, #0x90		@ Command "readid"
134	strb	r2, [r1, #20]		@ Save to FLASHIO
135	bic	r3, r3, #2		@ CLR CLE
136	orr	r3, r3, #4		@ SET ALE
137	strb	r3, [r1, #24]		@ Save to FLASHCTL
138	mov	r2, #0			@ Address 0x00
139	strb	r2, [r1, #20]		@ Save to FLASHIO
140	bic	r3, r3, #4		@ CLR ALE
141	strb	r3, [r1, #24]		@ Save to FLASHCTL
142.fids1:
143	ldrb	r3, [r1, #24]		@ Load FLASHCTL
144	tst	r3, #32			@ Is chip ready?
145	beq	.fids1
146	ldrb	r2, [r1, #20]		@ NAND Manufacturer ID
147	ldrb	r3, [r1, #20]		@ NAND Chip ID
148	mov	pc, lr
149
150.SHARPEND:
151