summaryrefslogtreecommitdiffstats
path: root/arch/blackfin/lib/cpu.c
blob: e75c0372a9f3f1a99a4b2240879f0ca96cef01e9 (plain) (blame)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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
/*
 * U-boot - cpu.c CPU specific functions
 *
 * Copyright (c) 2005 blackfin.uclinux.org
 *
 * (C) Copyright 2000-2004
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <common.h>
#include <asm/blackfin.h>
#include <command.h>
#include <asm/entry.h>
#include <asm/cpu/defBF561_extn.h> /* FIXME */

#define SSYNC() asm("ssync;")
#define CACHE_ON 1
#define CACHE_OFF 0

/* Data Attibutes*/

#define SDRAM_IGENERIC		(PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID)
#define SDRAM_IKERNEL		(PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_LOCK)
#define L1_IMEMORY            	(PAGE_SIZE_1MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_LOCK)
#define SDRAM_INON_CHBL		(PAGE_SIZE_4MB | CPLB_USER_RD | CPLB_VALID)

#define ANOMALY_05000158		0x200
#define SDRAM_DGENERIC          (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_WT | CPLB_L1_AOW | CPLB_SUPV_WR | CPLB_USER_RD | CPLB_USER_WR | CPLB_VALID | ANOMALY_05000158)
#define SDRAM_DNON_CHBL         (PAGE_SIZE_4MB | CPLB_WT | CPLB_L1_AOW | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_USER_RD | CPLB_VALID | ANOMALY_05000158)
#define SDRAM_DKERNEL           (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_WT | CPLB_L1_AOW | CPLB_USER_RD | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_VALID | CPLB_LOCK | ANOMALY_05000158)
#define L1_DMEMORY              (PAGE_SIZE_4KB | CPLB_L1_CHBL | CPLB_L1_AOW | CPLB_WT | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_VALID | ANOMALY_05000158)
#define SDRAM_EBIU              (PAGE_SIZE_4MB | CPLB_WT | CPLB_L1_AOW | CPLB_USER_RD | CPLB_USER_WR | CPLB_SUPV_WR | CPLB_VALID | ANOMALY_05000158)

static unsigned int icplb_table[16][2]={
			{0xFFA00000, L1_IMEMORY},
			{0x00000000, SDRAM_IKERNEL},	/*SDRAM_Page1*/
			{0x00400000, SDRAM_IKERNEL},	/*SDRAM_Page1*/
			{0x07C00000, SDRAM_IKERNEL},    /*SDRAM_Page14*/
			{0x00800000, SDRAM_IGENERIC},	/*SDRAM_Page2*/
			{0x00C00000, SDRAM_IGENERIC},	/*SDRAM_Page2*/
			{0x01000000, SDRAM_IGENERIC},	/*SDRAM_Page4*/
			{0x01400000, SDRAM_IGENERIC},	/*SDRAM_Page5*/
			{0x01800000, SDRAM_IGENERIC},	/*SDRAM_Page6*/
			{0x01C00000, SDRAM_IGENERIC},	/*SDRAM_Page7*/
			{0x02000000, SDRAM_IGENERIC},	/*SDRAM_Page8*/
			{0x02400000, SDRAM_IGENERIC},	/*SDRAM_Page9*/
			{0x02800000, SDRAM_IGENERIC},	/*SDRAM_Page10*/
			{0x02C00000, SDRAM_IGENERIC},	/*SDRAM_Page11*/
			{0x03000000, SDRAM_IGENERIC},	/*SDRAM_Page12*/
			{0x03400000, SDRAM_IGENERIC},	/*SDRAM_Page13*/
};

static unsigned int dcplb_table[16][2]={
			{0xFFA00000,L1_DMEMORY},
			{0x00000000,SDRAM_DKERNEL},	/*SDRAM_Page1*/
			{0x00400000,SDRAM_DKERNEL},	/*SDRAM_Page1*/
			{0x07C00000,SDRAM_DKERNEL},	/*SDRAM_Page15*/
			{0x00800000,SDRAM_DGENERIC},	/*SDRAM_Page2*/
			{0x00C00000,SDRAM_DGENERIC},	/*SDRAM_Page3*/
			{0x01000000,SDRAM_DGENERIC},	/*SDRAM_Page4*/
			{0x01400000,SDRAM_DGENERIC},	/*SDRAM_Page5*/
			{0x01800000,SDRAM_DGENERIC},	/*SDRAM_Page6*/
			{0x01C00000,SDRAM_DGENERIC},	/*SDRAM_Page7*/
			{0x02000000,SDRAM_DGENERIC},	/*SDRAM_Page8*/
			{0x02400000,SDRAM_DGENERIC},	/*SDRAM_Page9*/
			{0x02800000,SDRAM_DGENERIC},	/*SDRAM_Page10*/
			{0x02C00000,SDRAM_DGENERIC},	/*SDRAM_Page11*/
			{0x03000000,SDRAM_DGENERIC},	/*SDRAM_Page12*/
			{0x20000000,SDRAM_EBIU},	/*For Network */
};

int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	__asm__ __volatile__
	("cli r3;"
	"P0 = %0;"
	"JUMP (P0);"
	:
	: "r" (L1_ISRAM)
	);

	return 0;
}

/* These functions are just used to satisfy the linker */
int cpu_init(void)
{
	return 0;
}

int cleanup_before_linux(void)
{
	return 0;
}

void icache_enable(void)
{
	unsigned int *I0,*I1;
	int i;

	I0 = (unsigned int *)ICPLB_ADDR0;
	I1 = (unsigned int *)ICPLB_DATA0;

	for(i=0;i<16;i++){
		*I0++ = icplb_table[i][0];
		*I1++ = icplb_table[i][1];
		}
	SSYNC();
	*(unsigned int *)IMEM_CONTROL = IMC | ENICPLB;
	SSYNC();
}

void icache_disable(void)
{
	SSYNC();
	*(unsigned int *)IMEM_CONTROL &= ~(IMC | ENICPLB);
	SSYNC();
}

int icache_status(void)
{
	unsigned int value;
	value = *(unsigned int *)IMEM_CONTROL;

	if( value & (IMC|ENICPLB) )
		return CACHE_ON;
	else
		return CACHE_OFF;
}

void dcache_enable(void)
{
	unsigned int *I0,*I1;
	unsigned int temp;
	int i;
	I0 = (unsigned int *)DCPLB_ADDR0;
	I1 = (unsigned int *)DCPLB_DATA0;

	for(i=0;i<16;i++){
		*I0++ = dcplb_table[i][0];
		*I1++ = dcplb_table[i][1];
		}

	temp = *(unsigned int *)DMEM_CONTROL;
	SSYNC();
	*(unsigned int *)DMEM_CONTROL = ACACHE_BCACHE |ENDCPLB |PORT_PREF0|temp;
	SSYNC();
}

void dcache_disable(void)
{
	SSYNC();
	*(unsigned int *)DMEM_CONTROL &= ~(ACACHE_BCACHE |ENDCPLB |PORT_PREF0);
	SSYNC();
}

int dcache_status(void)
{
	unsigned int value;
	value = *(unsigned int *)DMEM_CONTROL;
	if( value & (ENDCPLB))
		return CACHE_ON;
	else
		return CACHE_OFF;
}