aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/lasat/prom.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/mips/lasat/prom.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/mips/lasat/prom.c')
-rw-r--r--arch/mips/lasat/prom.c143
1 files changed, 143 insertions, 0 deletions
diff --git a/arch/mips/lasat/prom.c b/arch/mips/lasat/prom.c
new file mode 100644
index 000000000000..ca62881c9e52
--- /dev/null
+++ b/arch/mips/lasat/prom.c
@@ -0,0 +1,143 @@
1/*
2 * PROM interface routines.
3 */
4#include <linux/types.h>
5#include <linux/init.h>
6#include <linux/string.h>
7#include <linux/ctype.h>
8#include <linux/kernel.h>
9#include <linux/mm.h>
10#include <linux/bootmem.h>
11#include <linux/ioport.h>
12#include <asm/bootinfo.h>
13#include <asm/lasat/lasat.h>
14#include <asm/cpu.h>
15
16#include "at93c.h"
17#include <asm/lasat/eeprom.h>
18#include "prom.h"
19
20#define RESET_VECTOR 0xbfc00000
21#define PROM_JUMP_TABLE_ENTRY(n) (*((u32 *)(RESET_VECTOR + 0x20) + n))
22#define PROM_DISPLAY_ADDR PROM_JUMP_TABLE_ENTRY(0)
23#define PROM_PUTC_ADDR PROM_JUMP_TABLE_ENTRY(1)
24#define PROM_MONITOR_ADDR PROM_JUMP_TABLE_ENTRY(2)
25
26static void null_prom_printf(const char * fmt, ...)
27{
28}
29
30static void null_prom_display(const char *string, int pos, int clear)
31{
32}
33
34static void null_prom_monitor(void)
35{
36}
37
38static void null_prom_putc(char c)
39{
40}
41
42/* these are functions provided by the bootloader */
43static void (* prom_putc)(char c) = null_prom_putc;
44void (* prom_printf)(const char * fmt, ...) = null_prom_printf;
45void (* prom_display)(const char *string, int pos, int clear) =
46 null_prom_display;
47void (* prom_monitor)(void) = null_prom_monitor;
48
49unsigned int lasat_ndelay_divider;
50
51#define PROM_PRINTFBUF_SIZE 256
52static char prom_printfbuf[PROM_PRINTFBUF_SIZE];
53
54static void real_prom_printf(const char * fmt, ...)
55{
56 va_list ap;
57 int len;
58 char *c = prom_printfbuf;
59 int i;
60
61 va_start(ap, fmt);
62 len = vsnprintf(prom_printfbuf, PROM_PRINTFBUF_SIZE, fmt, ap);
63 va_end(ap);
64
65 /* output overflowed the buffer */
66 if (len < 0 || len > PROM_PRINTFBUF_SIZE)
67 len = PROM_PRINTFBUF_SIZE;
68
69 for (i=0; i < len; i++) {
70 if (*c == '\n')
71 prom_putc('\r');
72 prom_putc(*c++);
73 }
74}
75
76static void setup_prom_vectors(void)
77{
78 u32 version = *(u32 *)(RESET_VECTOR + 0x90);
79
80 if (version >= 307) {
81 prom_display = (void *)PROM_DISPLAY_ADDR;
82 prom_putc = (void *)PROM_PUTC_ADDR;
83 prom_printf = real_prom_printf;
84 prom_monitor = (void *)PROM_MONITOR_ADDR;
85 }
86 prom_printf("prom vectors set up\n");
87}
88
89static struct at93c_defs at93c_defs[N_MACHTYPES] = {
90 {(void *)AT93C_REG_100, (void *)AT93C_RDATA_REG_100, AT93C_RDATA_SHIFT_100,
91 AT93C_WDATA_SHIFT_100, AT93C_CS_M_100, AT93C_CLK_M_100},
92 {(void *)AT93C_REG_200, (void *)AT93C_RDATA_REG_200, AT93C_RDATA_SHIFT_200,
93 AT93C_WDATA_SHIFT_200, AT93C_CS_M_200, AT93C_CLK_M_200},
94};
95
96void __init prom_init(void)
97{
98 int argc = fw_arg0;
99 char **argv = (char **) fw_arg1;
100
101 setup_prom_vectors();
102
103 if (current_cpu_data.cputype == CPU_R5000) {
104 prom_printf("LASAT 200 board\n");
105 mips_machtype = MACH_LASAT_200;
106 lasat_ndelay_divider = LASAT_200_DIVIDER;
107 } else {
108 prom_printf("LASAT 100 board\n");
109 mips_machtype = MACH_LASAT_100;
110 lasat_ndelay_divider = LASAT_100_DIVIDER;
111 }
112
113 at93c = &at93c_defs[mips_machtype];
114
115 lasat_init_board_info(); /* Read info from EEPROM */
116
117 mips_machgroup = MACH_GROUP_LASAT;
118
119 /* Get the command line */
120 if (argc > 0) {
121 strncpy(arcs_cmdline, argv[0], CL_SIZE-1);
122 arcs_cmdline[CL_SIZE-1] = '\0';
123 }
124
125 /* Set the I/O base address */
126 set_io_port_base(KSEG1);
127
128 /* Set memory regions */
129 ioport_resource.start = 0;
130 ioport_resource.end = 0xffffffff; /* Wrong, fixme. */
131
132 add_memory_region(0, lasat_board_info.li_memsize, BOOT_MEM_RAM);
133}
134
135unsigned long __init prom_free_prom_memory(void)
136{
137 return 0;
138}
139
140const char *get_system_type(void)
141{
142 return lasat_board_info.li_bmstr;
143}