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 <asm/ppc4xx.h>
36#include <asm/processor.h>
37#include <asm/ppc440.h>
38#include "bamboo.h"
39
40#undef DEBUG
41
42#ifdef DEBUG
43#define DEBUGF(x...) printf(x)
44#else
45#define DEBUGF(x...)
46#endif
47
48flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
49
50
51
52
53static unsigned long flash_addr_table[][CONFIG_SYS_MAX_FLASH_BANKS] = {
54 {0x87800001, 0xFFF00000, 0xFFF80000},
55 {0x00000000, 0x00000000, 0x00000000},
56 {0x87800001, 0x00000000, 0x00000000},
57 {0x87F00000, 0x87F80000, 0xFFC00001},
58 {0x87F00000, 0x87F80000, 0xFFC00001},
59 {0x00000000, 0x00000000, 0x00000000},
60 {0x00000000, 0x00000000, 0x00000000},
61 {0x00000000, 0x00000000, 0x00000000},
62 {0x87C00001, 0xFFF00000, 0xFFF80000},
63};
64
65
66
67
68#include "../common/flash.c"
69
70
71
72
73static ulong flash_get_size(vu_long * addr, flash_info_t * info);
74static int write_word(flash_info_t * info, ulong dest, ulong data);
75
76
77
78
79unsigned long flash_init(void)
80{
81 unsigned long total_b = 0;
82 unsigned long size_b[CONFIG_SYS_MAX_FLASH_BANKS];
83 unsigned short index = 0;
84 int i;
85 unsigned long val;
86 unsigned long ebc_boot_size;
87 unsigned long boot_selection;
88
89 mfsdr(SDR0_PINSTP, val);
90 index = (val & SDR0_PSTRP0_BOOTSTRAP_MASK) >> 29;
91
92 if ((index == 5) || (index == 7)) {
93
94
95
96
97 mfsdr(SDR0_SDSTP1, val);
98 boot_selection = val & SDR0_SDSTP1_BOOT_SEL_MASK;
99 ebc_boot_size = val & SDR0_SDSTP1_EBC_ROM_BS_MASK;
100
101 switch(boot_selection) {
102 case SDR0_SDSTP1_BOOT_SEL_EBC:
103 switch(ebc_boot_size) {
104 case SDR0_SDSTP1_EBC_ROM_BS_16BIT:
105 index = 3;
106 break;
107 case SDR0_SDSTP1_EBC_ROM_BS_8BIT:
108 index = 0;
109 break;
110 }
111 break;
112
113 case SDR0_SDSTP1_BOOT_SEL_PCI:
114 index = 1;
115 break;
116
117 case SDR0_SDSTP1_BOOT_SEL_NDFC:
118 index = 2;
119 break;
120 }
121 } else if (index == 0) {
122 if (in8(FPGA_SETTING_REG) & FPGA_SET_REG_OP_CODE_FLASH_ABOVE) {
123 index = 8;
124 }
125 }
126
127 DEBUGF("\n");
128 DEBUGF("FLASH: Index: %d\n", index);
129
130
131 for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
132 flash_info[i].flash_id = FLASH_UNKNOWN;
133 flash_info[i].sector_count = -1;
134 flash_info[i].size = 0;
135
136
137 if (flash_addr_table[index][i] == 0)
138 continue;
139
140 DEBUGF("Detection bank %d...\n", i);
141
142 size_b[i] = flash_get_size((vu_long *) flash_addr_table[index][i],
143 &flash_info[i]);
144 flash_info[i].size = size_b[i];
145 if (flash_info[i].flash_id == FLASH_UNKNOWN) {
146 printf("## Unknown FLASH on Bank %d - Size = 0x%08lx = %ld MB\n",
147 i, size_b[i], size_b[i] << 20);
148 flash_info[i].sector_count = -1;
149 flash_info[i].size = 0;
150 }
151
152
153 (void)flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_MONITOR_BASE,
154 CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN - 1,
155 &flash_info[i]);
156#if defined(CONFIG_ENV_IS_IN_FLASH)
157 (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR,
158 CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1,
159 &flash_info[i]);
160#if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR_REDUND)
161 (void)flash_protect(FLAG_PROTECT_SET, CONFIG_ENV_ADDR_REDUND,
162 CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1,
163 &flash_info[i]);
164#endif
165#endif
166
167 total_b += flash_info[i].size;
168 }
169
170 return total_b;
171}
172