blob: 2c139f547dabce02f27a6209a4f8d43bd4612f9e [file] [log] [blame]
Wolfgang Denk97caf672006-03-12 02:12:27 +01001/*
2 * U-boot - cpu.c CPU specific functions
3 *
4 * Copyright (c) 2005 blackfin.uclinux.org
5 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28#include <common.h>
29#include <asm/blackfin.h>
30#include <command.h>
31#include <asm/entry.h>
32
33#define SSYNC() asm("ssync;")
34#define CACHE_ON 1
35#define CACHE_OFF 0
36
37/* Data Attibutes*/
38
39#define SDRAM_IGENERIC (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID)
40#define SDRAM_IKERNEL (PAGE_SIZE_4MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_LOCK)
41#define L1_IMEMORY (PAGE_SIZE_1MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_LOCK)
42#define SDRAM_INON_CHBL (PAGE_SIZE_4MB | CPLB_USER_RD | CPLB_VALID)
43
44#define ANOMALY_05000158 0x200
45#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)
46#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)
47#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)
48#define L1_DMEMORY (PAGE_SIZE_4KB | CPLB_L1_CHBL | CPLB_L1_AOW | CPLB_WT | CPLB_SUPV_WR | CPLB_USER_WR | CPLB_VALID | ANOMALY_05000158)
49#define SDRAM_EBIU (PAGE_SIZE_4MB | CPLB_WT | CPLB_L1_AOW | CPLB_USER_RD | CPLB_USER_WR | CPLB_SUPV_WR | CPLB_VALID | ANOMALY_05000158)
50
51static unsigned int icplb_table[16][2]={
52 {0xFFA00000, L1_IMEMORY},
53 {0x00000000, SDRAM_IKERNEL}, /*SDRAM_Page1*/
54 {0x00400000, SDRAM_IKERNEL}, /*SDRAM_Page1*/
55 {0x07C00000, SDRAM_IKERNEL}, /*SDRAM_Page14*/
56 {0x00800000, SDRAM_IGENERIC}, /*SDRAM_Page2*/
57 {0x00C00000, SDRAM_IGENERIC}, /*SDRAM_Page2*/
58 {0x01000000, SDRAM_IGENERIC}, /*SDRAM_Page4*/
59 {0x01400000, SDRAM_IGENERIC}, /*SDRAM_Page5*/
60 {0x01800000, SDRAM_IGENERIC}, /*SDRAM_Page6*/
61 {0x01C00000, SDRAM_IGENERIC}, /*SDRAM_Page7*/
62 {0x02000000, SDRAM_IGENERIC}, /*SDRAM_Page8*/
63 {0x02400000, SDRAM_IGENERIC}, /*SDRAM_Page9*/
64 {0x02800000, SDRAM_IGENERIC}, /*SDRAM_Page10*/
65 {0x02C00000, SDRAM_IGENERIC}, /*SDRAM_Page11*/
66 {0x03000000, SDRAM_IGENERIC}, /*SDRAM_Page12*/
67 {0x03400000, SDRAM_IGENERIC}, /*SDRAM_Page13*/
68};
69
70static unsigned int dcplb_table[16][2]={
71 {0xFFA00000,L1_DMEMORY},
72 {0x00000000,SDRAM_DKERNEL}, /*SDRAM_Page1*/
73 {0x00400000,SDRAM_DKERNEL}, /*SDRAM_Page1*/
74 {0x07C00000,SDRAM_DKERNEL}, /*SDRAM_Page15*/
75 {0x00800000,SDRAM_DGENERIC}, /*SDRAM_Page2*/
76 {0x00C00000,SDRAM_DGENERIC}, /*SDRAM_Page3*/
77 {0x01000000,SDRAM_DGENERIC}, /*SDRAM_Page4*/
78 {0x01400000,SDRAM_DGENERIC}, /*SDRAM_Page5*/
79 {0x01800000,SDRAM_DGENERIC}, /*SDRAM_Page6*/
80 {0x01C00000,SDRAM_DGENERIC}, /*SDRAM_Page7*/
81 {0x02000000,SDRAM_DGENERIC}, /*SDRAM_Page8*/
82 {0x02400000,SDRAM_DGENERIC}, /*SDRAM_Page9*/
83 {0x02800000,SDRAM_DGENERIC}, /*SDRAM_Page10*/
84 {0x02C00000,SDRAM_DGENERIC}, /*SDRAM_Page11*/
85 {0x03000000,SDRAM_DGENERIC}, /*SDRAM_Page12*/
86 {0x20000000,SDRAM_EBIU}, /*For Network */
87};
88
89
90
91
92
93int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
94{
95 __asm__ __volatile__
96 ("cli r3;"
97 "P0 = %0;"
98 "JUMP (P0);"
99 :
100 : "r" (L1_ISRAM)
101 );
102
103 return 0;
104}
105
106/* These functions are just used to satisfy the linker */
107int cpu_init(void)
108{
109 return 0;
110}
111
112int cleanup_before_linux(void)
113{
114 return 0;
115}
116
117void icache_enable(void)
118{
119 unsigned int *I0,*I1;
120 int i;
121
122 I0 = (unsigned int *)ICPLB_ADDR0;
123 I1 = (unsigned int *)ICPLB_DATA0;
124
125 for(i=0;i<16;i++){
126 *I0++ = icplb_table[i][0];
127 *I1++ = icplb_table[i][1];
128 }
129 cli();
130 SSYNC();
131 *(unsigned int *)IMEM_CONTROL = IMC | ENICPLB;
132 SSYNC();
133 sti();
134}
135
136void icache_disable(void)
137{
138 cli();
139 SSYNC();
140 *(unsigned int *)IMEM_CONTROL &= ~(IMC | ENICPLB);
141 SSYNC();
142 sti();
143}
144
145int icache_status(void)
146{
147 unsigned int value;
148 value = *(unsigned int *)IMEM_CONTROL;
149
150 if( value & (IMC|ENICPLB) )
151 return CACHE_ON;
152 else
153 return CACHE_OFF;
154}
155
156void dcache_enable(void)
157{
158 unsigned int *I0,*I1;
159 unsigned int temp;
160 int i;
161 I0 = (unsigned int *)DCPLB_ADDR0;
162 I1 = (unsigned int *)DCPLB_DATA0;
163
164 for(i=0;i<16;i++){
165 *I0++ = dcplb_table[i][0];
166 *I1++ = dcplb_table[i][1];
167 }
168 cli();
169 temp = *(unsigned int *)DMEM_CONTROL;
170 SSYNC();
171 *(unsigned int *)DMEM_CONTROL = ACACHE_BCACHE |ENDCPLB |PORT_PREF0|temp;
172 SSYNC();
173 sti();
174}
175
176
177void dcache_disable(void)
178{
179 cli();
180 SSYNC();
181 *(unsigned int *)DMEM_CONTROL &= ~(ACACHE_BCACHE |ENDCPLB |PORT_PREF0);
182 SSYNC();
183 sti();
184}
185
186int dcache_status(void)
187{
188 unsigned int value;
189 value = *(unsigned int *)DMEM_CONTROL;
190 if( value & (ENDCPLB))
191 return CACHE_ON;
192 else
193 return CACHE_OFF;
194}