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#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
44
45static unsigned long flash_addr_table[1][CONFIG_SYS_MAX_FLASH_BANKS] = {
46 {0xff900000, 0xff980000, 0xffc00000},
47};
48
49
50
51
52#include "../common/flash.c"
53
54
55
56
57static ulong flash_get_size(vu_long * addr, flash_info_t * info);
58
59unsigned long flash_init(void)
60{
61 unsigned long total_b = 0;
62 unsigned long size_b[CONFIG_SYS_MAX_FLASH_BANKS];
63 unsigned short index = 0;
64 int i;
65
66
67
68 DEBUGF("\n");
69 DEBUGF("FLASH: Index: %d\n", index);
70
71
72 for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
73 flash_info[i].flash_id = FLASH_UNKNOWN;
74 flash_info[i].sector_count = -1;
75 flash_info[i].size = 0;
76
77
78 if (flash_addr_table[index][i] == 0) {
79 continue;
80 }
81
82
83 size_b[i] = flash_get_size((vu_long *)
84 flash_addr_table[index][i],
85 &flash_info[i]);
86 flash_info[i].size = size_b[i];
87 if (flash_info[i].flash_id == FLASH_UNKNOWN) {
88 printf("## Unknown FLASH on Bank %d - Size = 0x%08lx = %ld MB\n",
89 i, size_b[i], size_b[i] << 20);
90 flash_info[i].sector_count = -1;
91 flash_info[i].size = 0;
92 }
93
94
95 (void)flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_MONITOR_BASE,
96 CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1,
97 &flash_info[2]);
98#ifdef CONFIG_ENV_IS_IN_FLASH
99 (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR,
100 CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
101 &flash_info[2]);
102 (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR_REDUND,
103 CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
104 &flash_info[2]);
105#endif
106
107 total_b += flash_info[i].size;
108 }
109
110 return total_b;
111}
112