summaryrefslogtreecommitdiff
path: root/board/voiceblue/voiceblue.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/voiceblue/voiceblue.c')
-rw-r--r--board/voiceblue/voiceblue.c152
1 files changed, 152 insertions, 0 deletions
diff --git a/board/voiceblue/voiceblue.c b/board/voiceblue/voiceblue.c
new file mode 100644
index 0000000..2501622
--- /dev/null
+++ b/board/voiceblue/voiceblue.c
@@ -0,0 +1,152 @@
+/*
+ * (C) Copyright 2005 2N TELEKOMUNIKACE, Ladislav Michl
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+
+int board_init(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ unsigned int val;
+
+ *((volatile unsigned char *) VOICEBLUE_LED_REG) = 0xaa;
+
+ /* arch number of VoiceBlue board */
+ /* TODO: use define from asm/mach-types.h */
+ gd->bd->bi_arch_number = 218;
+
+ /* adress of boot parameters */
+ gd->bd->bi_boot_params = 0x10000100;
+
+ return 0;
+}
+
+int dram_init(void)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+
+ *((volatile unsigned short *) VOICEBLUE_LED_REG) = 0xff;
+
+ /* Take the Ethernet controller out of reset and wait
+ * for the EEPROM load to complete. */
+ *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) |= 0x80;
+ udelay(10); /* doesn't work before interrupt_init call */
+ *((volatile unsigned short *) GPIO_DATA_OUTPUT_REG) &= ~0x80;
+ udelay(500);
+
+ gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
+ gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
+
+ return 0;
+}
+
+#ifndef VOICEBLUE_SMALL_FLASH
+
+#include <jffs2/jffs2.h>
+
+extern flash_info_t flash_info[];
+static struct part_info partinfo;
+static int current_part = -1;
+
+/* Partition table (Linux MTD see it this way)
+ *
+ * 0 - U-Boot
+ * 1 - env
+ * 2 - redundant env
+ * 3 - data1 (jffs2)
+ * 4 - data2 (jffs2)
+ */
+
+static struct {
+ ulong offset;
+ ulong size;
+} part[5];
+
+static void partition_flash(flash_info_t *info)
+{
+ char mtdparts[128];
+ int i, n, size, psize;
+ const ulong plen[3] = { CFG_MONITOR_LEN, CFG_ENV_SIZE, CFG_ENV_SIZE };
+
+ size = n = 0;
+ for (i = 0; i < 4; i++) {
+ part[i].offset = info->start[n];
+ psize = i < 3 ? plen[i] : (info->size - size) / 2;
+ while (part[i].size < psize) {
+ if (++n > info->sector_count) {
+ printf("Partitioning error. System halted.\n");
+ while (1) ;
+ }
+ part[i].size += info->start[n] - info->start[n - 1];
+ }
+ size += part[i].size;
+ }
+ part[4].offset = info->start[n];
+ part[4].size = info->start[info->sector_count - 1] - info->start[n];
+
+ sprintf(mtdparts, "omapflash.0:"
+ "%dk(U-Boot)ro,%dk(env),%dk(r_env),%dk(data1),-(data2)",
+ part[0].size >> 10, part[1].size >> 10,
+ part[2].size >> 10, part[3].size >> 10);
+ setenv ("mtdparts", mtdparts);
+}
+
+struct part_info* jffs2_part_info(int part_num)
+{
+ void *jffs2_priv_saved = partinfo.jffs2_priv;
+
+ if (part_num != 3 && part_num != 4)
+ return NULL;
+
+ if (current_part != part_num) {
+ memset(&partinfo, 0, sizeof(partinfo));
+ current_part = part_num;
+ partinfo.offset = (char*) part[part_num].offset;
+ partinfo.size = part[part_num].size;
+ partinfo.usr_priv = &current_part;
+ partinfo.jffs2_priv = jffs2_priv_saved;
+ }
+
+ return &partinfo;
+}
+
+#endif
+
+int misc_init_r(void)
+{
+ *((volatile unsigned short *) VOICEBLUE_LED_REG) = 0x55;
+
+#ifndef VOICEBLUE_SMALL_FLASH
+ if (flash_info[0].flash_id == FLASH_UNKNOWN) {
+ printf("Unknown flash. System halted.\n");
+ while (1) ;
+ }
+ partition_flash(&flash_info[0]);
+#endif
+
+ return 0;
+}
+
+int board_late_init(void)
+{
+ *((volatile unsigned char *) VOICEBLUE_LED_REG) = 0x00;
+
+ return 0;
+}