1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <common.h>
21#include <ioports.h>
22#include <mpc83xx.h>
23#include <i2c.h>
24#include <miiphy.h>
25#include <asm/io.h>
26#include <asm/mmu.h>
27#include <asm/processor.h>
28#include <pci.h>
29#include <libfdt.h>
30
31#include "../common/common.h"
32
33extern void disable_addr_trans (void);
34extern void enable_addr_trans (void);
35const qe_iop_conf_t qe_iop_conf_tab[] = {
36
37
38
39 {0, 1, 3, 0, 2},
40 {0, 2, 1, 0, 1},
41
42
43 {1, 14, 1, 0, 1},
44 {1, 15, 1, 0, 1},
45 {1, 20, 2, 0, 1},
46 {1, 21, 2, 0, 1},
47 {1, 18, 1, 0, 1},
48 {1, 26, 2, 0, 1},
49 {1, 27, 2, 0, 1},
50 {1, 24, 2, 0, 1},
51 {1, 25, 2, 0, 1},
52 {2, 15, 2, 0, 1},
53 {2, 16, 2, 0, 1},
54
55
56 {5, 0, 1, 0, 2},
57 {5, 2, 1, 0, 1},
58 {5, 3, 2, 0, 2},
59 {5, 1, 2, 0, 3},
60
61
62 {0, 0, 0, 0, QE_IOP_TAB_END},
63};
64
65static int board_init_i2c_busses (void)
66{
67 I2C_MUX_DEVICE *dev = NULL;
68 uchar *buf;
69
70
71 buf = (unsigned char *) getenv ("dtt_bus");
72 if (buf != NULL)
73 dev = i2c_mux_ident_muxstring (buf);
74 if (dev == NULL) {
75 printf ("Error couldn't add Bus for DTT\n");
76 printf ("please setup dtt_bus to where your\n");
77 printf ("DTT is found.\n");
78 }
79 return 0;
80}
81
82int board_early_init_r (void)
83{
84 unsigned short svid;
85
86
87
88
89
90 svid = SVR_REV(mfspr (SVR));
91 switch (svid) {
92 case 0x0020:
93 setbits_be32((void *)(CONFIG_SYS_IMMR + 0x14a8), 0x0c003000);
94 break;
95 case 0x0021:
96 clrsetbits_be32((void *)(CONFIG_SYS_IMMR + 0x14ac),
97 0x00000050, 0x000000a0);
98 break;
99 }
100
101 setbits (8, (void *)(CONFIG_SYS_PIGGY_BASE + 0x10003), 0x01);
102
103 setbits (8, (void *)(CONFIG_SYS_PIGGY_BASE + 0x00002), 0x01);
104
105 setbits (8, (void *)(CONFIG_SYS_PIGGY_BASE + 0x0000f), 0x1c);
106
107 return 0;
108}
109
110int misc_init_r (void)
111{
112
113 board_init_i2c_busses ();
114 return 0;
115}
116
117int fixed_sdram(void)
118{
119 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
120 u32 msize = 0;
121 u32 ddr_size;
122 u32 ddr_size_log2;
123
124 im->sysconf.ddrlaw[0].ar = LAWAR_EN | 0x1e;
125 im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
126 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
127 im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
128 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
129 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
130 im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
131 im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
132 im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
133 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
134 im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
135 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
136 im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
137 udelay (200);
138 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
139
140 msize = CONFIG_SYS_DDR_SIZE << 20;
141 disable_addr_trans ();
142 msize = get_ram_size (CONFIG_SYS_DDR_BASE, msize);
143 enable_addr_trans ();
144 msize /= (1024 * 1024);
145 if (CONFIG_SYS_DDR_SIZE != msize) {
146 for (ddr_size = msize << 20, ddr_size_log2 = 0;
147 (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++)
148 if (ddr_size & 1)
149 return -1;
150 im->sysconf.ddrlaw[0].ar =
151 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
152 im->ddr.csbnds[0].csbnds = (((msize / 16) - 1) & 0xff);
153 }
154
155 return msize;
156}
157
158phys_size_t initdram (int board_type)
159{
160#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
161 extern void ddr_enable_ecc (unsigned int dram_size);
162#endif
163 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
164 u32 msize = 0;
165
166 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
167 return -1;
168
169
170 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
171 msize = fixed_sdram ();
172
173#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
174
175
176
177 ddr_enable_ecc (msize * 1024 * 1024);
178#endif
179
180
181 return (msize * 1024 * 1024);
182}
183
184int checkboard (void)
185{
186 puts ("Board: Keymile kmeter1");
187 if (ethernet_present ())
188 puts (" with PIGGY.");
189 puts ("\n");
190 return 0;
191}
192
193#if defined(CONFIG_OF_BOARD_SETUP)
194
195
196
197void ft_blob_update (void *blob, bd_t *bd)
198{
199
200}
201
202
203void ft_board_setup (void *blob, bd_t *bd)
204{
205 ft_cpu_setup (blob, bd);
206 ft_blob_update (blob, bd);
207}
208#endif
209
210#if defined(CONFIG_HUSH_INIT_VAR)
211extern int ivm_read_eeprom (void);
212int hush_init_var (void)
213{
214 ivm_read_eeprom ();
215 return 0;
216}
217#endif
218