1 /********************************************************************
3 * Unless otherwise specified, Copyright (C) 2004-2005 Barco Control Rooms
5 * $Source: /home/services/cvs/firmware/ppc/u-boot-1.1.2/board/barco/barco.c,v $
8 * $Date: 2005/03/02 16:40:20 $
10 * Last ChangeLog Entry
12 * Revision 1.4 2005/03/02 16:40:20 mleeman
13 * remove empty labels (3.4 complains)
15 * Revision 1.3 2005/02/21 12:48:58 mleeman
16 * update of copyright years (feedback wd)
18 * Revision 1.2 2005/02/21 10:10:53 mleeman
19 * - split up switch statement to a function call (Linux kernel coding guidelines)
22 * Revision 1.1 2005/02/14 09:31:07 mleeman
25 * Revision 1.1 2005/02/14 09:23:46 mleeman
26 * - moved 'barcohydra' directory to a more generic barco; since we will be
27 * supporting and adding multiple boards
29 * Revision 1.3 2005/02/10 13:57:32 mleeman
30 * fixed flash corruption: I should exit from the moment I find the correct value
32 * Revision 1.2 2005/02/09 12:56:23 mleeman
33 * add generic header to track changes in sources
36 *******************************************************************/
40 * Marc Leeman <marc.leeman@barco.com>
42 * This program is free software; you can redistribute it and/or
43 * modify it under the terms of the GNU General Public License as
44 * published by the Free Software Foundation; either version 2 of
45 * the License, or (at your option) any later version.
47 * This program is distributed in the hope that it will be useful,
48 * but WITHOUT ANY WARRANTY; without even the implied warranty of
49 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50 * GNU General Public License for more details.
52 * You should have received a copy of the GNU General Public License
53 * along with this program; if not, write to the Free Software
54 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
65 #include "barco_svc.h"
67 #define TRY_WORKING (3)
68 #define BOOT_DEFAULT (2)
69 #define BOOT_WORKING (1)
73 /*TODO: Check processor type */
75 puts ( "Board: Streaming Video Card for Hydra systems "
82 " Unity ##Test not implemented yet##\n");
86 phys_size_t initdram (int board_type)
93 size = get_ram_size (CONFIG_SYS_SDRAM_BASE, CONFIG_SYS_MAX_RAM_SIZE);
95 new_bank0_end = size - 1;
96 mear1 = mpc824x_mpc107_getreg (MEAR1);
97 emear1 = mpc824x_mpc107_getreg (EMEAR1);
98 mear1 = (mear1 & 0xFFFFFF00) |
99 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
100 emear1 = (emear1 & 0xFFFFFF00) |
101 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
102 mpc824x_mpc107_setreg (MEAR1, mear1);
103 mpc824x_mpc107_setreg (EMEAR1, emear1);
109 * Initialize PCI Devices, report devices found.
111 #ifndef CONFIG_PCI_PNP
112 static struct pci_config_table pci_barcohydra_config_table[] = {
113 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x0f, PCI_ANY_ID,
114 pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
116 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER } },
117 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0x10, PCI_ANY_ID,
118 pci_cfgfunc_config_device, { PCI_ENET1_IOADDR,
120 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER } },
125 struct pci_controller hose = {
126 #ifndef CONFIG_PCI_PNP
127 config_table: pci_barcohydra_config_table,
131 void pci_init_board (void)
133 pci_mpc824x_init (&hose);
136 int write_flash (char *addr, char value)
138 char *adr = (char *)0xFF800000;
140 char status,oldstatus;
142 *(adr+0x55) = 0xAA; udelay (1);
143 *(adr+0xAA) = 0x55; udelay (1);
144 *(adr+0x55) = 0xA0; udelay (1);
152 if ((oldstatus & 0x40) == (status & 0x40)) {
159 } while ( (status & 0x20) == 0 );
164 if ((oldstatus & 0x40) == (status & 0x40)) {
172 unsigned update_flash (unsigned char *buf)
174 switch ((*buf) & 0x3) {
176 printf ("found 3 and converted it to 2\n");
177 write_flash ((char *)buf, (*buf) & 0xFE);
178 *((unsigned char *)0xFF800000) = 0xF0;
180 printf ("buf [%#010x] %#010x\n", (unsigned)buf, (*buf));
181 /* XXX - fall through??? */
188 unsigned scan_flash (void)
190 char section[] = "kernel";
191 int cfgFileLen = (CONFIG_SYS_FLASH_ERASE_SECTOR_LENGTH >> 1);
193 int foundItem = 0; /* 0: None, 1: section found, 2: "=" found */
197 buf = (unsigned char*)(CONFIG_SYS_FLASH_RANGE_BASE + CONFIG_SYS_FLASH_RANGE_SIZE \
198 - CONFIG_SYS_FLASH_ERASE_SECTOR_LENGTH);
199 for (bufPtr = 0; bufPtr < cfgFileLen; ++bufPtr) {
200 if ((buf[bufPtr]==0xFF) && (*(int*)(buf+bufPtr)==0xFFFFFFFF)) {
203 /* This is the scanning loop, we try to find a particular
208 if ((section[sectionPtr] == 0)) {
210 } else if (buf[bufPtr] == section[sectionPtr]) {
224 return update_flash (&buf[bufPtr - 1]);
228 printf ("Failed to read %s\n",section);
232 TSBootInfo* find_boot_info (void)
234 unsigned bootimage = scan_flash ();
235 TSBootInfo* info = (TSBootInfo*)malloc (sizeof(TSBootInfo));
239 info->address = CONFIG_SYS_WORKING_KERNEL_ADDRESS;
242 info->address = CONFIG_SYS_WORKING_KERNEL_ADDRESS;
246 info->address= CONFIG_SYS_DEFAULT_KERNEL_ADDRESS;
249 info->size = *((unsigned int *)(info->address ));
254 void barcobcd_boot (void)
260 extern int do_bootm (cmd_tbl_t *, int, int, char *[]);
262 buf = (char *)(0x00800000);
263 /* make certain there are enough chars to print the command line here!
265 bootm_args[0] = (char *)malloc (16*sizeof(char));
266 bootm_args[1] = (char *)malloc (16*sizeof(char));
268 start = find_boot_info ();
270 printf ("Booting kernel at address %#10x with size %#10x\n",
271 start->address, start->size);
273 /* give length of the kernel image to bootm */
274 sprintf (bootm_args[0],"%x",start->size);
275 /* give address of the kernel image to bootm */
276 sprintf (bootm_args[1],"%x",(unsigned)buf);
278 printf ("flash address: %#10x\n",start->address+8);
279 printf ("buf address: %#10x\n",(unsigned)buf);
281 /* aha, we reserve 8 bytes here... */
282 for (cnt = 0; cnt < start->size ; cnt++) {
283 buf[cnt] = ((char *)start->address)[cnt+8];
286 /* initialise RAM memory */
287 *((unsigned int *)0xFEC00000) = 0x00141A98;
288 do_bootm (NULL,0,2,bootm_args);
291 int barcobcd_boot_image (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
304 /* Currently, boot_working and boot_default are the same command. This is
305 * left in here to see what we'll do in the future */
308 try_working, 1, 1, barcobcd_boot_image,
309 "check flash value and boot the appropriate image",
314 boot_working, 1, 1, barcobcd_boot_image,
315 "check flash value and boot the appropriate image",
320 boot_default, 1, 1, barcobcd_boot_image,
321 "check flash value and boot the appropriate image",
325 * We are not using serial communication, so just provide empty functions
327 int serial_init (void)
331 void serial_setbrg (void)
335 void serial_putc (const char c)
339 void serial_puts (const char *c)
343 void serial_addr (unsigned int i)
347 int serial_getc (void)
351 int serial_tstc (void)
356 unsigned long post_word_load (void)
360 void post_word_store (unsigned long val)