]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - board/voiceblue/voiceblue.c
* Patch by Ladislav Michl, 05 Apr 2005:
[karo-tx-uboot.git] / board / voiceblue / voiceblue.c
1 /*
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
24 int board_init(void)
25 {
26         DECLARE_GLOBAL_DATA_PTR;
27         unsigned int val;
28
29         *((volatile unsigned char *) VOICEBLUE_LED_REG) = 0xaa;
30
31         /* arch number of VoiceBlue board */
32         /* TODO: use define from asm/mach-types.h */
33         gd->bd->bi_arch_number = 218;
34
35         /* adress of boot parameters */
36         gd->bd->bi_boot_params = 0x10000100;
37
38         return 0;
39 }
40
41 int dram_init(void)
42 {
43         DECLARE_GLOBAL_DATA_PTR;
44
45         *((volatile unsigned short *) VOICEBLUE_LED_REG) = 0xff;
46
47         /* Take the Ethernet controller out of reset and wait
48          * for the EEPROM load to complete. */
49         *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) |= 0x80;
50         udelay(10);     /* doesn't work before interrupt_init call */
51         *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) &= ~0x80;
52         udelay(500);
53
54         gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
55         gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
56
57         return 0;
58 }
59
60 #ifndef VOICEBLUE_SMALL_FLASH
61
62 #include <jffs2/jffs2.h>
63
64 extern flash_info_t flash_info[];
65 static struct part_info partinfo;
66 static int current_part = -1;
67
68 /* Partition table (Linux MTD see it this way)
69  *
70  * 0 - U-Boot
71  * 1 - env
72  * 2 - redundant env
73  * 3 - data1 (jffs2)
74  * 4 - data2 (jffs2)
75  */
76
77 static struct {
78         ulong offset;
79         ulong size;
80 } part[5];
81
82 static void partition_flash(flash_info_t *info)
83 {
84         char mtdparts[128];
85         int i, n, size, psize;
86         const ulong plen[3] = { CFG_MONITOR_LEN, CFG_ENV_SIZE, CFG_ENV_SIZE };
87
88         size = n = 0;
89         for (i = 0; i < 4; i++) {
90                 part[i].offset = info->start[n];
91                 psize = i < 3 ? plen[i] : (info->size - size) / 2;
92                 while (part[i].size < psize) {
93                         if (++n > info->sector_count) {
94                                 printf("Partitioning error. System halted.\n");
95                                 while (1) ;
96                         }
97                         part[i].size += info->start[n] - info->start[n - 1];
98                 }
99                 size += part[i].size;
100         }
101         part[4].offset = info->start[n];
102         part[4].size = info->start[info->sector_count - 1] - info->start[n];
103
104         sprintf(mtdparts, "omapflash.0:"
105                         "%dk(U-Boot)ro,%dk(env),%dk(r_env),%dk(data1),-(data2)",
106                         part[0].size >> 10, part[1].size >> 10,
107                         part[2].size >> 10, part[3].size >> 10);
108         setenv ("mtdparts", mtdparts);
109 }
110
111 struct part_info* jffs2_part_info(int part_num)
112 {
113         void *jffs2_priv_saved = partinfo.jffs2_priv;
114
115         if (part_num != 3 && part_num != 4)
116                 return NULL;
117
118         if (current_part != part_num) {
119                 memset(&partinfo, 0, sizeof(partinfo));
120                 current_part = part_num;
121                 partinfo.offset = (char*) part[part_num].offset;
122                 partinfo.size = part[part_num].size;
123                 partinfo.usr_priv = &current_part;
124                 partinfo.jffs2_priv = jffs2_priv_saved;
125         }
126
127         return &partinfo;
128 }
129
130 #endif
131
132 int misc_init_r(void)
133 {
134         *((volatile unsigned short *) VOICEBLUE_LED_REG) = 0x55;
135
136 #ifndef VOICEBLUE_SMALL_FLASH
137         if (flash_info[0].flash_id == FLASH_UNKNOWN) {
138                 printf("Unknown flash. System halted.\n");
139                 while (1) ;
140         }
141         partition_flash(&flash_info[0]);
142 #endif
143
144         return 0;
145 }
146
147 int board_late_init(void)
148 {
149         *((volatile unsigned char *) VOICEBLUE_LED_REG) = 0x00;
150
151         return 0;
152 }