GNU Linux-libre 4.14.328-gnu1
[releases.git] / arch / mips / lasat / prom.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * PROM interface routines.
4  */
5 #include <linux/types.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
27 static void null_prom_display(const char *string, int pos, int clear)
28 {
29 }
30
31 static void null_prom_monitor(void)
32 {
33 }
34
35 static void null_prom_putc(char c)
36 {
37 }
38
39 /* these are functions provided by the bootloader */
40 static void (*__prom_putc)(char c) = null_prom_putc;
41
42 void prom_putchar(char c)
43 {
44         __prom_putc(c);
45 }
46
47 void (*prom_display)(const char *string, int pos, int clear) =
48                 null_prom_display;
49 void (*prom_monitor)(void) = null_prom_monitor;
50
51 unsigned int lasat_ndelay_divider;
52
53 static void setup_prom_vectors(void)
54 {
55         u32 version = *(u32 *)(RESET_VECTOR + 0x90);
56
57         if (version >= 307) {
58                 prom_display = (void *)PROM_DISPLAY_ADDR;
59                 __prom_putc = (void *)PROM_PUTC_ADDR;
60                 prom_monitor = (void *)PROM_MONITOR_ADDR;
61         }
62         printk(KERN_DEBUG "prom vectors set up\n");
63 }
64
65 static struct at93c_defs at93c_defs[N_MACHTYPES] = {
66         {
67                 .reg            = (void *)AT93C_REG_100,
68                 .rdata_reg      = (void *)AT93C_RDATA_REG_100,
69                 .rdata_shift    = AT93C_RDATA_SHIFT_100,
70                 .wdata_shift    = AT93C_WDATA_SHIFT_100,
71                 .cs             = AT93C_CS_M_100,
72                 .clk            = AT93C_CLK_M_100
73         }, {
74                 .reg            = (void *)AT93C_REG_200,
75                 .rdata_reg      = (void *)AT93C_RDATA_REG_200,
76                 .rdata_shift    = AT93C_RDATA_SHIFT_200,
77                 .wdata_shift    = AT93C_WDATA_SHIFT_200,
78                 .cs             = AT93C_CS_M_200,
79                 .clk            = AT93C_CLK_M_200
80         },
81 };
82
83 void __init prom_init(void)
84 {
85         int argc = fw_arg0;
86         char **argv = (char **) fw_arg1;
87
88         setup_prom_vectors();
89
90         if (IS_LASAT_200()) {
91                 printk(KERN_INFO "LASAT 200 board\n");
92                 lasat_ndelay_divider = LASAT_200_DIVIDER;
93                 at93c = &at93c_defs[1];
94         } else {
95                 printk(KERN_INFO "LASAT 100 board\n");
96                 lasat_ndelay_divider = LASAT_100_DIVIDER;
97                 at93c = &at93c_defs[0];
98         }
99
100         lasat_init_board_info();                /* Read info from EEPROM */
101
102         /* Get the command line */
103         if (argc > 0) {
104                 strncpy(arcs_cmdline, argv[0], COMMAND_LINE_SIZE-1);
105                 arcs_cmdline[COMMAND_LINE_SIZE-1] = '\0';
106         }
107
108         /* Set the I/O base address */
109         set_io_port_base(KSEG1);
110
111         /* Set memory regions */
112         ioport_resource.start = 0;
113         ioport_resource.end = 0xffffffff;       /* Wrong, fixme.  */
114
115         add_memory_region(0, lasat_board_info.li_memsize, BOOT_MEM_RAM);
116 }
117
118 void __init prom_free_prom_memory(void)
119 {
120 }
121
122 const char *get_system_type(void)
123 {
124         return lasat_board_info.li_bmstr;
125 }