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