blob: 9691106581b04f72079c61c72a1cfb1e14c01ef6 [file] [log] [blame]
wdenk3c2b3d42005-04-05 23:32:21 +00001/*
2 * (C) Copyright 2005 2N TELEKOMUNIKACE, Ladislav Michl
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19 * MA 02111-1307 USA
20 */
21
22#include <common.h>
23
24int board_init(void)
25{
26 DECLARE_GLOBAL_DATA_PTR;
wdenk3c2b3d42005-04-05 23:32:21 +000027
28 *((volatile unsigned char *) VOICEBLUE_LED_REG) = 0xaa;
29
30 /* arch number of VoiceBlue board */
31 /* TODO: use define from asm/mach-types.h */
32 gd->bd->bi_arch_number = 218;
33
34 /* adress of boot parameters */
35 gd->bd->bi_boot_params = 0x10000100;
36
37 return 0;
38}
39
40int dram_init(void)
41{
42 DECLARE_GLOBAL_DATA_PTR;
43
44 *((volatile unsigned short *) VOICEBLUE_LED_REG) = 0xff;
45
46 /* Take the Ethernet controller out of reset and wait
47 * for the EEPROM load to complete. */
48 *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) |= 0x80;
49 udelay(10); /* doesn't work before interrupt_init call */
50 *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) &= ~0x80;
51 udelay(500);
52
53 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
54 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
55
56 return 0;
57}
58
59#ifndef VOICEBLUE_SMALL_FLASH
60
61#include <jffs2/jffs2.h>
62
63extern flash_info_t flash_info[];
64static struct part_info partinfo;
65static int current_part = -1;
66
67/* Partition table (Linux MTD see it this way)
68 *
69 * 0 - U-Boot
70 * 1 - env
71 * 2 - redundant env
72 * 3 - data1 (jffs2)
73 * 4 - data2 (jffs2)
74 */
75
76static struct {
77 ulong offset;
78 ulong size;
79} part[5];
80
81static void partition_flash(flash_info_t *info)
82{
83 char mtdparts[128];
84 int i, n, size, psize;
85 const ulong plen[3] = { CFG_MONITOR_LEN, CFG_ENV_SIZE, CFG_ENV_SIZE };
86
87 size = n = 0;
88 for (i = 0; i < 4; i++) {
89 part[i].offset = info->start[n];
90 psize = i < 3 ? plen[i] : (info->size - size) / 2;
91 while (part[i].size < psize) {
92 if (++n > info->sector_count) {
93 printf("Partitioning error. System halted.\n");
94 while (1) ;
95 }
96 part[i].size += info->start[n] - info->start[n - 1];
97 }
98 size += part[i].size;
99 }
100 part[4].offset = info->start[n];
101 part[4].size = info->start[info->sector_count - 1] - info->start[n];
102
103 sprintf(mtdparts, "omapflash.0:"
104 "%dk(U-Boot)ro,%dk(env),%dk(r_env),%dk(data1),-(data2)",
105 part[0].size >> 10, part[1].size >> 10,
106 part[2].size >> 10, part[3].size >> 10);
107 setenv ("mtdparts", mtdparts);
108}
109
110struct part_info* jffs2_part_info(int part_num)
111{
112 void *jffs2_priv_saved = partinfo.jffs2_priv;
113
114 if (part_num != 3 && part_num != 4)
115 return NULL;
116
117 if (current_part != part_num) {
118 memset(&partinfo, 0, sizeof(partinfo));
119 current_part = part_num;
120 partinfo.offset = (char*) part[part_num].offset;
121 partinfo.size = part[part_num].size;
122 partinfo.usr_priv = &current_part;
123 partinfo.jffs2_priv = jffs2_priv_saved;
124 }
125
126 return &partinfo;
127}
128
129#endif
130
131int misc_init_r(void)
132{
133 *((volatile unsigned short *) VOICEBLUE_LED_REG) = 0x55;
134
135#ifndef VOICEBLUE_SMALL_FLASH
136 if (flash_info[0].flash_id == FLASH_UNKNOWN) {
137 printf("Unknown flash. System halted.\n");
138 while (1) ;
139 }
140 partition_flash(&flash_info[0]);
141#endif
142
143 return 0;
144}
145
146int board_late_init(void)
147{
148 *((volatile unsigned char *) VOICEBLUE_LED_REG) = 0x00;
149
150 return 0;
151}