1 /*
2 * PROM interface routines.
3 */
4 #include <linux/types.h>
5 #include <linux/config.h>
6 #include <linux/init.h>
7 #include <linux/string.h>
8 #include <linux/ctype.h>
9 #include <linux/kernel.h>
10 #include <linux/mm.h>
11 #include <linux/bootmem.h>
12 #include <linux/ioport.h>
13 #include <asm/bootinfo.h>
14 #include <asm/lasat/lasat.h>
15 #include <asm/cpu.h>
16
17 #include "at93c.h"
18 #include <asm/lasat/eeprom.h>
19 #include "prom.h"
20
21 #define RESET_VECTOR 0xbfc00000
22 #define PROM_JUMP_TABLE_ENTRY(n) (*((u32 *)(RESET_VECTOR + 0x20) + n))
23 #define PROM_DISPLAY_ADDR PROM_JUMP_TABLE_ENTRY(0)
24 #define PROM_PUTC_ADDR PROM_JUMP_TABLE_ENTRY(1)
25 #define PROM_MONITOR_ADDR PROM_JUMP_TABLE_ENTRY(2)
26
null_prom_printf(const char * fmt,...)27 static void null_prom_printf(const char * fmt, ...)
28 {
29 }
30
null_prom_display(const char * string,int pos,int clear)31 static void null_prom_display(const char *string, int pos, int clear)
32 {
33 }
34
null_prom_monitor(void)35 static void null_prom_monitor(void)
36 {
37 }
38
null_prom_putc(char c)39 static void null_prom_putc(char c)
40 {
41 }
42
43 /* these are functions provided by the bootloader */
44 static void (* prom_putc)(char c) = null_prom_putc;
45 void (* prom_printf)(const char * fmt, ...) = null_prom_printf;
46 void (* prom_display)(const char *string, int pos, int clear) =
47 null_prom_display;
48 void (* prom_monitor)(void) = null_prom_monitor;
49
50 unsigned int lasat_ndelay_divider;
51
52 #define PROM_PRINTFBUF_SIZE 256
53 static char prom_printfbuf[PROM_PRINTFBUF_SIZE];
54
real_prom_printf(const char * fmt,...)55 static void real_prom_printf(const char * fmt, ...)
56 {
57 va_list ap;
58 int len;
59 char *c = prom_printfbuf;
60 int i;
61
62 va_start(ap, fmt);
63 len = vsnprintf(prom_printfbuf, PROM_PRINTFBUF_SIZE, fmt, ap);
64 va_end(ap);
65
66 /* output overflowed the buffer */
67 if (len < 0 || len > PROM_PRINTFBUF_SIZE)
68 len = PROM_PRINTFBUF_SIZE;
69
70 for (i=0; i < len; i++) {
71 if (*c == '\n')
72 prom_putc('\r');
73 prom_putc(*c++);
74 }
75 }
76
setup_prom_vectors(void)77 static void setup_prom_vectors(void)
78 {
79 u32 version = *(u32 *)(RESET_VECTOR + 0x90);
80
81 if (version >= 306) {
82 prom_display = (void *)PROM_DISPLAY_ADDR;
83 prom_putc = (void *)PROM_PUTC_ADDR;
84 prom_printf = real_prom_printf;
85 prom_monitor = (void *)PROM_MONITOR_ADDR;
86 }
87 prom_printf("prom vectors set up\n");
88 }
89
90 char arcs_cmdline[CL_SIZE];
91
92 static struct at93c_defs at93c_defs[N_MACHTYPES] = {
93 {(void *)AT93C_REG_100, (void *)AT93C_RDATA_REG_100, AT93C_RDATA_SHIFT_100,
94 AT93C_WDATA_SHIFT_100, AT93C_CS_M_100, AT93C_CLK_M_100},
95 {(void *)AT93C_REG_200, (void *)AT93C_RDATA_REG_200, AT93C_RDATA_SHIFT_200,
96 AT93C_WDATA_SHIFT_200, AT93C_CS_M_200, AT93C_CLK_M_200},
97 };
98
prom_init(int argc,char ** argv,char ** envp,int * prom_vec)99 void __init prom_init(int argc, char **argv, char **envp, int *prom_vec)
100 {
101 setup_prom_vectors();
102
103 if (current_cpu_data.cputype == CPU_R5000) {
104 mips_machtype = MACH_LASAT_200;
105 lasat_ndelay_divider = 8;
106 } else {
107 mips_machtype = MACH_LASAT_100;
108 lasat_ndelay_divider = 20;
109 }
110
111 at93c = &at93c_defs[mips_machtype];
112
113 lasat_init_board_info(); /* Read info from EEPROM */
114
115 mips_machgroup = MACH_GROUP_LASAT;
116
117 /* Get the command line */
118 if (argc>0) {
119 strncpy(arcs_cmdline, argv[0], CL_SIZE-1);
120 arcs_cmdline[CL_SIZE-1] = '\0';
121 }
122
123 /* Set the I/O base address */
124 set_io_port_base(KSEG1);
125
126 /* Set memory regions */
127 ioport_resource.start = 0; /* Should be KSEGx ??? */
128 ioport_resource.end = 0xffffffff; /* Should be ??? */
129
130 add_memory_region(0, lasat_board_info.li_memsize, BOOT_MEM_RAM);
131 }
132
prom_free_prom_memory(void)133 void prom_free_prom_memory(void)
134 {
135 }
136
get_system_type(void)137 const char *get_system_type(void)
138 {
139 return lasat_board_info.li_bmstr;
140 }
141