blob: 812c6ac366bea2571933732fc86f5035197b6e28 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070026static void null_prom_display(const char *string, int pos, int clear)
27{
28}
29
30static void null_prom_monitor(void)
31{
32}
33
34static void null_prom_putc(char c)
35{
36}
37
38/* these are functions provided by the bootloader */
Ralf Baechle36a88532007-03-01 11:56:43 +000039static void (* __prom_putc)(char c) = null_prom_putc;
40
41void prom_putchar(char c)
42{
43 __prom_putc(c);
44}
45
Ralf Baechle42a3b4f2005-09-03 15:56:17 -070046void (* prom_display)(const char *string, int pos, int clear) =
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 null_prom_display;
48void (* prom_monitor)(void) = null_prom_monitor;
49
50unsigned int lasat_ndelay_divider;
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052static void setup_prom_vectors(void)
53{
54 u32 version = *(u32 *)(RESET_VECTOR + 0x90);
55
56 if (version >= 307) {
57 prom_display = (void *)PROM_DISPLAY_ADDR;
Ralf Baechle36a88532007-03-01 11:56:43 +000058 __prom_putc = (void *)PROM_PUTC_ADDR;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 prom_monitor = (void *)PROM_MONITOR_ADDR;
60 }
Ralf Baechle36a88532007-03-01 11:56:43 +000061 printk("prom vectors set up\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070062}
63
64static struct at93c_defs at93c_defs[N_MACHTYPES] = {
65 {(void *)AT93C_REG_100, (void *)AT93C_RDATA_REG_100, AT93C_RDATA_SHIFT_100,
66 AT93C_WDATA_SHIFT_100, AT93C_CS_M_100, AT93C_CLK_M_100},
67 {(void *)AT93C_REG_200, (void *)AT93C_RDATA_REG_200, AT93C_RDATA_SHIFT_200,
68 AT93C_WDATA_SHIFT_200, AT93C_CS_M_200, AT93C_CLK_M_200},
69};
70
71void __init prom_init(void)
72{
73 int argc = fw_arg0;
74 char **argv = (char **) fw_arg1;
75
76 setup_prom_vectors();
77
78 if (current_cpu_data.cputype == CPU_R5000) {
Ralf Baechle36a88532007-03-01 11:56:43 +000079 printk("LASAT 200 board\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 mips_machtype = MACH_LASAT_200;
81 lasat_ndelay_divider = LASAT_200_DIVIDER;
82 } else {
Ralf Baechle36a88532007-03-01 11:56:43 +000083 printk("LASAT 100 board\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 mips_machtype = MACH_LASAT_100;
85 lasat_ndelay_divider = LASAT_100_DIVIDER;
86 }
87
88 at93c = &at93c_defs[mips_machtype];
89
90 lasat_init_board_info(); /* Read info from EEPROM */
91
92 mips_machgroup = MACH_GROUP_LASAT;
93
94 /* Get the command line */
95 if (argc > 0) {
96 strncpy(arcs_cmdline, argv[0], CL_SIZE-1);
97 arcs_cmdline[CL_SIZE-1] = '\0';
98 }
99
100 /* Set the I/O base address */
101 set_io_port_base(KSEG1);
102
103 /* Set memory regions */
104 ioport_resource.start = 0;
105 ioport_resource.end = 0xffffffff; /* Wrong, fixme. */
106
107 add_memory_region(0, lasat_board_info.li_memsize, BOOT_MEM_RAM);
108}
109
Atsushi Nemotoc44e8d52006-12-30 00:43:59 +0900110void __init prom_free_prom_memory(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112}
113
114const char *get_system_type(void)
115{
116 return lasat_board_info.li_bmstr;
117}