]>
Commit | Line | Data |
---|---|---|
8a316c9b SR |
1 | /* |
2 | * (C) Copyright 2002 | |
3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
4 | * | |
5 | * (C) Copyright 2002 Jun Gu <jung@artesyncp.com> | |
6 | * Add support for Am29F016D and dynamic switch setting. | |
7 | * | |
8 | * See file CREDITS for list of people who contributed to this | |
9 | * project. | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or | |
12 | * modify it under the terms of the GNU General Public License as | |
13 | * published by the Free Software Foundation; either version 2 of | |
14 | * the License, or (at your option) any later version. | |
15 | * | |
16 | * This program is distributed in the hope that it will be useful, | |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 | * GNU General Public License for more details. | |
20 | * | |
21 | * You should have received a copy of the GNU General Public License | |
22 | * along with this program; if not, write to the Free Software | |
23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
24 | * MA 02111-1307 USA | |
25 | */ | |
26 | ||
27 | /* | |
28 | * Modified 4/5/2001 | |
29 | * Wait for completion of each sector erase command issued | |
30 | * 4/5/2001 | |
31 | * Chris Hallinan - DS4.COM, Inc. - clh@net1plus.com | |
32 | */ | |
33 | ||
34 | #include <common.h> | |
35 | #include <ppc4xx.h> | |
36 | #include <asm/processor.h> | |
37 | ||
38 | #undef DEBUG | |
39 | #ifdef DEBUG | |
40 | #define DEBUGF(x...) printf(x) | |
41 | #else | |
42 | #define DEBUGF(x...) | |
43 | #endif /* DEBUG */ | |
44 | ||
45 | #define BOOT_SMALL_FLASH 32 /* 00100000 */ | |
46 | #define FLASH_ONBD_N 2 /* 00000010 */ | |
47 | #define FLASH_SRAM_SEL 1 /* 00000001 */ | |
48 | ||
49 | #define BOOT_SMALL_FLASH_VAL 4 | |
50 | #define FLASH_ONBD_N_VAL 2 | |
51 | #define FLASH_SRAM_SEL_VAL 1 | |
52 | ||
6d0f6bcf | 53 | static unsigned long flash_addr_table[8][CONFIG_SYS_MAX_FLASH_BANKS] = { |
8a316c9b SR |
54 | {0xffc00000, 0xffe00000, 0xff880000}, /* 0:000: configuraton 3 */ |
55 | {0xffc00000, 0xffe00000, 0xff800000}, /* 1:001: configuraton 4 */ | |
56 | {0xffc00000, 0xffe00000, 0x00000000}, /* 2:010: configuraton 7 */ | |
57 | {0xffc00000, 0xffe00000, 0x00000000}, /* 3:011: configuraton 8 */ | |
58 | {0xff800000, 0xffa00000, 0xfff80000}, /* 4:100: configuraton 1 */ | |
59 | {0xff800000, 0xffa00000, 0xfff00000}, /* 5:101: configuraton 2 */ | |
60 | {0xffc00000, 0xffe00000, 0x00000000}, /* 6:110: configuraton 5 */ | |
61 | {0xffc00000, 0xffe00000, 0x00000000} /* 7:111: configuraton 6 */ | |
62 | }; | |
63 | ||
64 | /* | |
65 | * include common flash code (for amcc boards) | |
66 | */ | |
67 | #include "../common/flash.c" | |
68 | ||
69 | /*----------------------------------------------------------------------- | |
70 | * Functions | |
71 | */ | |
72 | static ulong flash_get_size(vu_long * addr, flash_info_t * info); | |
73 | ||
74 | unsigned long flash_init(void) | |
75 | { | |
76 | unsigned long total_b = 0; | |
6d0f6bcf JCPV |
77 | unsigned long size_b[CONFIG_SYS_MAX_FLASH_BANKS]; |
78 | unsigned char *fpga_base = (unsigned char *)CONFIG_SYS_FPGA_BASE; | |
8a316c9b SR |
79 | unsigned char switch_status; |
80 | unsigned short index = 0; | |
81 | int i; | |
82 | ||
83 | /* read FPGA base register FPGA_REG0 */ | |
84 | switch_status = *fpga_base; | |
85 | ||
86 | /* check the bitmap of switch status */ | |
87 | if (switch_status & BOOT_SMALL_FLASH) { | |
88 | index += BOOT_SMALL_FLASH_VAL; | |
89 | } | |
90 | if (switch_status & FLASH_ONBD_N) { | |
91 | index += FLASH_ONBD_N_VAL; | |
92 | } | |
93 | if (switch_status & FLASH_SRAM_SEL) { | |
94 | index += FLASH_SRAM_SEL_VAL; | |
95 | } | |
96 | ||
97 | DEBUGF("\n"); | |
98 | DEBUGF("FLASH: Index: %d\n", index); | |
99 | ||
100 | /* Init: no FLASHes known */ | |
6d0f6bcf | 101 | for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) { |
8a316c9b SR |
102 | flash_info[i].flash_id = FLASH_UNKNOWN; |
103 | flash_info[i].sector_count = -1; | |
104 | flash_info[i].size = 0; | |
105 | ||
106 | /* check whether the address is 0 */ | |
107 | if (flash_addr_table[index][i] == 0) { | |
108 | continue; | |
109 | } | |
110 | ||
111 | /* call flash_get_size() to initialize sector address */ | |
112 | size_b[i] = flash_get_size((vu_long *) | |
113 | flash_addr_table[index][i], | |
114 | &flash_info[i]); | |
115 | flash_info[i].size = size_b[i]; | |
116 | if (flash_info[i].flash_id == FLASH_UNKNOWN) { | |
117 | printf("## Unknown FLASH on Bank %d - Size = 0x%08lx = %ld MB\n", | |
118 | i, size_b[i], size_b[i] << 20); | |
119 | flash_info[i].sector_count = -1; | |
120 | flash_info[i].size = 0; | |
121 | } | |
122 | ||
123 | /* Monitor protection ON by default */ | |
6d0f6bcf JCPV |
124 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_MONITOR_BASE, |
125 | CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1, | |
8a316c9b | 126 | &flash_info[2]); |
5a1aceb0 | 127 | #ifdef CONFIG_ENV_IS_IN_FLASH |
0e8d1586 JCPV |
128 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR, |
129 | CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1, | |
8a316c9b | 130 | &flash_info[2]); |
0e8d1586 JCPV |
131 | (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR_REDUND, |
132 | CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1, | |
8a316c9b SR |
133 | &flash_info[2]); |
134 | #endif | |
135 | ||
136 | total_b += flash_info[i].size; | |
137 | } | |
138 | ||
139 | return total_b; | |
140 | } |