1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include <common.h>
24#include <mpc8xx.h>
25#include <net.h>
26#include <asm/io.h>
27
28#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
29#include <libfdt.h>
30#endif
31
32#include "../common/common.h"
33
34DECLARE_GLOBAL_DATA_PTR;
35
36const uint sdram_table[] =
37{
38 0x0f07fc04, 0x0ffffc04, 0x00bdfc04, 0x0ff77c00,
39 0x1ffffc05, 0xfffffc04, 0xfffffc04, 0xfffffc04,
40
41 0x0f07fc04, 0x0ffffc04, 0x00bdfc04, 0x00fffc00,
42 0x00fffc00, 0x00fffc00, 0x0ff77c00, 0x1ffffc05,
43
44 0x0ffffc34, 0x0ff57c04, 0x0ffffc04, 0x1ffffc05,
45 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04,
46
47 0x0f07fc04, 0x0ffffc00, 0x00bd7c04, 0x0ffffc04,
48 0x0ff77c04, 0x1ffffc05, 0xfffffc04, 0xfffffc04,
49
50 0x0f07fc04, 0x0ffffc00, 0x00bd7c00, 0x00fffc00,
51 0x00fffc00, 0x00fffc04, 0x0ffffc04, 0x0ff77c04,
52 0x1ffffc05, 0xfffffc04, 0xfffffc04, 0xfffffc04,
53 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04,
54
55 0x0ff77c04, 0x0ffffc04, 0x0ff5fc84, 0x0ffffc04,
56 0x0ffffc04, 0x0ffffc84, 0x1ffffc05, 0xfffffc04,
57 0xfffffc04, 0xfffffc04, 0xfffffc04, 0xfffffc04,
58
59 0x7ffffc04, 0xfffffc07, 0xfffffc04, 0xfffffc04,
60};
61
62int checkboard (void)
63{
64 puts ("Board: Keymile ");
65#if defined(CONFIG_KMSUPX4)
66 puts ("kmsupx4");
67#else
68 puts ("mgsuvd");
69#endif
70 if (ethernet_present ())
71 puts (" with PIGGY.");
72 puts ("\n");
73 return (0);
74}
75
76phys_size_t initdram (int board_type)
77{
78 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
79 volatile memctl8xx_t *memctl = &immap->im_memctl;
80 long int size;
81
82 upmconfig (UPMB, (uint *) sdram_table,
83 sizeof (sdram_table) / sizeof (uint));
84
85
86
87
88
89
90
91 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106 memctl->memc_mar = CONFIG_SYS_MAR;
107
108
109
110
111
112
113 memctl->memc_or1 = CONFIG_SYS_OR1_PRELIM;
114 memctl->memc_br1 = CONFIG_SYS_BR1_PRELIM;
115
116 memctl->memc_mbmr = CONFIG_SYS_MBMR & (~(MBMR_PTBE));
117
118 udelay (200);
119
120
121
122 memctl->memc_mcr = 0x80802830;
123 udelay (1);
124 memctl->memc_mcr = 0x80802110;
125 udelay (1);
126
127 memctl->memc_mbmr |= MBMR_PTBE;
128
129 udelay (1000);
130
131
132
133
134
135 size = get_ram_size(SDRAM_BASE1_PRELIM, SDRAM_MAX_SIZE);
136
137 udelay (1000);
138
139 debug ("SDRAM Bank 0: %ld MB\n", size >> 20);
140
141 return (size);
142}
143
144
145
146
147int board_early_init_r(void)
148{
149
150 out_8((u8 *)(CONFIG_SYS_PIGGY_BASE + 0x02), 0xc0);
151 out_8((u8 *)(CONFIG_SYS_PIGGY_BASE + 0x03), 0x35);
152 return 0;
153}
154
155int hush_init_var (void)
156{
157 ivm_read_eeprom ();
158 return 0;
159}
160
161#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
162
163
164
165void ft_blob_update (void *blob, bd_t *bd)
166{
167 ulong brg_data[1] = {0};
168 ulong memory_data[2] = {0};
169 ulong *flash_data = NULL;
170 ulong flash_reg[3] = {0};
171 flash_info_t *info;
172 int len;
173 int i = 0;
174
175 memory_data[0] = cpu_to_be32 (bd->bi_memstart);
176 memory_data[1] = cpu_to_be32 (bd->bi_memsize);
177 fdt_set_node_and_value (blob, "/memory", "reg", memory_data,
178 sizeof (memory_data));
179
180 len = fdt_get_node_and_value (blob, "/localbus", "ranges",
181 (void *)&flash_data);
182
183 if (flash_data == NULL) {
184 printf ("%s: error /localbus/ranges entry\n", __FUNCTION__);
185 return;
186 }
187
188
189 while ( i < (len / 4)) {
190 switch (flash_data[i]) {
191 case 0:
192 info = flash_get_info(CONFIG_SYS_FLASH_BASE);
193 flash_data[i + 1] = 0;
194 flash_data[i + 2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
195 flash_data[i + 3] = cpu_to_be32 (info->size);
196 break;
197 default:
198 break;
199 }
200 i += 4;
201 }
202 fdt_set_node_and_value (blob, "/localbus", "ranges", flash_data,
203 len);
204
205 flash_reg[2] = cpu_to_be32 (bd->bi_flashsize);
206 fdt_set_node_and_value (blob, "/localbus/flash@0,0", "reg", flash_reg,
207 sizeof (flash_reg));
208
209 brg_data[0] = cpu_to_be32 (bd->bi_busfreq);
210 fdt_set_node_and_value (blob, "/soc/cpm", "brg-frequency", brg_data,
211 sizeof (brg_data));
212
213
214 fdt_set_node_and_value (blob, "/soc/cpm/ethernet", "mac-address",
215 bd->bi_enetaddr, sizeof (u8) * 6);
216}
217
218void ft_board_setup(void *blob, bd_t *bd)
219{
220 ft_cpu_setup (blob, bd);
221 ft_blob_update (blob, bd);
222}
223#endif
224
225int i2c_soft_read_pin (void)
226{
227 int val;
228
229 *(unsigned short *)(I2C_BASE_DIR) &= ~SDA_CONF;
230 udelay(1);
231 val = *(unsigned char *)(I2C_BASE_PORT);
232
233 return ((val & SDA_BIT) == SDA_BIT);
234}
235