1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * ip22-setup.c: SGI specific setup, including init of the feature struct.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
6*4882a593Smuzhiyun * Copyright (C) 1997, 1998 Ralf Baechle (ralf@gnu.org)
7*4882a593Smuzhiyun */
8*4882a593Smuzhiyun #include <linux/init.h>
9*4882a593Smuzhiyun #include <linux/kernel.h>
10*4882a593Smuzhiyun #include <linux/kdev_t.h>
11*4882a593Smuzhiyun #include <linux/types.h>
12*4882a593Smuzhiyun #include <linux/console.h>
13*4882a593Smuzhiyun #include <linux/sched.h>
14*4882a593Smuzhiyun #include <linux/tty.h>
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun #include <asm/addrspace.h>
17*4882a593Smuzhiyun #include <asm/bcache.h>
18*4882a593Smuzhiyun #include <asm/bootinfo.h>
19*4882a593Smuzhiyun #include <asm/irq.h>
20*4882a593Smuzhiyun #include <asm/reboot.h>
21*4882a593Smuzhiyun #include <asm/time.h>
22*4882a593Smuzhiyun #include <asm/io.h>
23*4882a593Smuzhiyun #include <asm/traps.h>
24*4882a593Smuzhiyun #include <asm/sgialib.h>
25*4882a593Smuzhiyun #include <asm/sgi/mc.h>
26*4882a593Smuzhiyun #include <asm/sgi/hpc3.h>
27*4882a593Smuzhiyun #include <asm/sgi/ip22.h>
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun extern void ip22_be_init(void) __init;
30*4882a593Smuzhiyun
plat_mem_setup(void)31*4882a593Smuzhiyun void __init plat_mem_setup(void)
32*4882a593Smuzhiyun {
33*4882a593Smuzhiyun char *ctype;
34*4882a593Smuzhiyun char *cserial;
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun board_be_init = ip22_be_init;
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun /* Init the INDY HPC I/O controller. Need to call this before
39*4882a593Smuzhiyun * fucking with the memory controller because it needs to know the
40*4882a593Smuzhiyun * boardID and whether this is a Guiness or a FullHouse machine.
41*4882a593Smuzhiyun */
42*4882a593Smuzhiyun sgihpc_init();
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun /* Init INDY memory controller. */
45*4882a593Smuzhiyun sgimc_init();
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun #ifdef CONFIG_BOARD_SCACHE
48*4882a593Smuzhiyun /* Now enable boardcaches, if any. */
49*4882a593Smuzhiyun indy_sc_init();
50*4882a593Smuzhiyun #endif
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun /* Set EISA IO port base for Indigo2
53*4882a593Smuzhiyun * ioremap cannot fail */
54*4882a593Smuzhiyun set_io_port_base((unsigned long)ioremap(0x00080000,
55*4882a593Smuzhiyun 0x1fffffff - 0x00080000));
56*4882a593Smuzhiyun /* ARCS console environment variable is set to "g?" for
57*4882a593Smuzhiyun * graphics console, it is set to "d" for the first serial
58*4882a593Smuzhiyun * line and "d2" for the second serial line.
59*4882a593Smuzhiyun *
60*4882a593Smuzhiyun * Need to check if the case is 'g' but no keyboard:
61*4882a593Smuzhiyun * (ConsoleIn/Out = serial)
62*4882a593Smuzhiyun */
63*4882a593Smuzhiyun ctype = ArcGetEnvironmentVariable("console");
64*4882a593Smuzhiyun cserial = ArcGetEnvironmentVariable("ConsoleOut");
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun if ((ctype && *ctype == 'd') || (cserial && *cserial == 's')) {
67*4882a593Smuzhiyun static char options[8] __initdata;
68*4882a593Smuzhiyun char *baud = ArcGetEnvironmentVariable("dbaud");
69*4882a593Smuzhiyun if (baud)
70*4882a593Smuzhiyun strcpy(options, baud);
71*4882a593Smuzhiyun add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0,
72*4882a593Smuzhiyun baud ? options : NULL);
73*4882a593Smuzhiyun } else if (!ctype || *ctype != 'g') {
74*4882a593Smuzhiyun /* Use ARC if we don't want serial ('d') or graphics ('g'). */
75*4882a593Smuzhiyun prom_flags |= PROM_FLAG_USE_AS_CONSOLE;
76*4882a593Smuzhiyun add_preferred_console("arc", 0, NULL);
77*4882a593Smuzhiyun }
78*4882a593Smuzhiyun }
79