a3b62f011447019f32ada4c1af891aea73bea011
[openwrt/svn-archive/archive.git] / target / linux / ifxmips / files / arch / mips / ifxmips / prom.c
1 /*
2 * arch/mips/ifxmips/prom.c
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright (C) 2005 Wu Qi Ming infineon
19 *
20 * Rewrite of Infineon IFXMips code, thanks to infineon for the support,
21 * software and hardware
22 *
23 * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
24 *
25 */
26
27 #include <linux/init.h>
28 #include <linux/bootmem.h>
29 #include <asm/bootinfo.h>
30 #include <asm/ifxmips/ifxmips.h>
31
32 #ifdef CONFIG_IFXMIPS_USE_CONSOLE0
33 #define ASC_OFFSET 0
34 #elif CONFIG_IFXMIPS_USE_CONSOLE1
35 #define ASC_OFFSET IFXMIPS_ASC1_BASE_OFFSET
36 #else
37 #error a tty for the console must be selected
38 #endif
39 static char buf[1024];
40
41 void
42 prom_free_prom_memory (void)
43 {
44 }
45
46 void
47 prom_putchar (char c)
48 {
49 while ((readl(IFXMIPS_ASC0_FSTAT + ASC_OFFSET) & ASCFSTAT_TXFFLMASK) >> ASCFSTAT_TXFFLOFF);
50
51 if (c == '\n')
52 writel('\r', IFXMIPS_ASC0_TBUF + ASC_OFFSET);
53 writel(c, IFXMIPS_ASC0_TBUF + ASC_OFFSET);
54 }
55
56 void
57 prom_printf (const char * fmt, ...)
58 {
59 va_list args;
60 int l;
61 char *p, *buf_end;
62
63 va_start(args, fmt);
64 l = vsprintf(buf, fmt, args);
65 va_end(args);
66 buf_end = buf + l;
67
68 for (p = buf; p < buf_end; p++)
69 {
70 prom_putchar(*p);
71 }
72 }
73
74 void __init
75 prom_init(void)
76 {
77 mips_machgroup = MACH_GROUP_IFXMIPS;
78 mips_machtype = MACH_INFINEON_IFXMIPS;
79
80 strcpy(&(arcs_cmdline[0]), "console=ttyS0,115200 rootfstype=squashfs,jffs2 init=/etc/preinit");
81 add_memory_region (0x00000000, 0x2000000, BOOT_MEM_RAM);
82 }