blob: 5ce1407de2d592861fb95d172aef46ef3017a77e [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Brian Murphy1f21d2b2007-08-21 22:34:16 +02002/*
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>
Mike Rapoport57c8a662018-10-30 15:09:49 -070011#include <linux/memblock.h>
Brian Murphy1f21d2b2007-08-21 22:34:16 +020012#include <linux/ioport.h>
13#include <asm/bootinfo.h>
14#include <asm/lasat/lasat.h>
15#include <asm/cpu.h>
Alexander Sverdlin5c933162018-07-13 17:51:56 +020016#include <asm/setup.h>
Brian Murphy1f21d2b2007-08-21 22:34:16 +020017
18#include "at93c.h"
19#include <asm/lasat/eeprom.h>
20#include "prom.h"
21
22#define RESET_VECTOR 0xbfc00000
23#define PROM_JUMP_TABLE_ENTRY(n) (*((u32 *)(RESET_VECTOR + 0x20) + n))
24#define PROM_DISPLAY_ADDR PROM_JUMP_TABLE_ENTRY(0)
25#define PROM_PUTC_ADDR PROM_JUMP_TABLE_ENTRY(1)
26#define PROM_MONITOR_ADDR PROM_JUMP_TABLE_ENTRY(2)
27
28static void null_prom_display(const char *string, int pos, int clear)
29{
30}
31
32static void null_prom_monitor(void)
33{
34}
35
36static void null_prom_putc(char c)
37{
38}
39
40/* these are functions provided by the bootloader */
41static void (*__prom_putc)(char c) = null_prom_putc;
42
43void prom_putchar(char c)
44{
45 __prom_putc(c);
46}
47
48void (*prom_display)(const char *string, int pos, int clear) =
49 null_prom_display;
50void (*prom_monitor)(void) = null_prom_monitor;
51
52unsigned int lasat_ndelay_divider;
53
54static void setup_prom_vectors(void)
55{
56 u32 version = *(u32 *)(RESET_VECTOR + 0x90);
57
58 if (version >= 307) {
59 prom_display = (void *)PROM_DISPLAY_ADDR;
60 __prom_putc = (void *)PROM_PUTC_ADDR;
61 prom_monitor = (void *)PROM_MONITOR_ADDR;
62 }
63 printk(KERN_DEBUG "prom vectors set up\n");
64}
65
66static struct at93c_defs at93c_defs[N_MACHTYPES] = {
67 {
68 .reg = (void *)AT93C_REG_100,
69 .rdata_reg = (void *)AT93C_RDATA_REG_100,
70 .rdata_shift = AT93C_RDATA_SHIFT_100,
71 .wdata_shift = AT93C_WDATA_SHIFT_100,
72 .cs = AT93C_CS_M_100,
73 .clk = AT93C_CLK_M_100
74 }, {
75 .reg = (void *)AT93C_REG_200,
76 .rdata_reg = (void *)AT93C_RDATA_REG_200,
77 .rdata_shift = AT93C_RDATA_SHIFT_200,
78 .wdata_shift = AT93C_WDATA_SHIFT_200,
79 .cs = AT93C_CS_M_200,
80 .clk = AT93C_CLK_M_200
81 },
82};
83
84void __init prom_init(void)
85{
86 int argc = fw_arg0;
87 char **argv = (char **) fw_arg1;
88
89 setup_prom_vectors();
90
Thomas Bogendoerferb27418a2008-07-14 16:58:47 +020091 if (IS_LASAT_200()) {
Brian Murphy1f21d2b2007-08-21 22:34:16 +020092 printk(KERN_INFO "LASAT 200 board\n");
Brian Murphy1f21d2b2007-08-21 22:34:16 +020093 lasat_ndelay_divider = LASAT_200_DIVIDER;
Thomas Bogendoerferb27418a2008-07-14 16:58:47 +020094 at93c = &at93c_defs[1];
Brian Murphy1f21d2b2007-08-21 22:34:16 +020095 } else {
96 printk(KERN_INFO "LASAT 100 board\n");
Brian Murphy1f21d2b2007-08-21 22:34:16 +020097 lasat_ndelay_divider = LASAT_100_DIVIDER;
Thomas Bogendoerferb27418a2008-07-14 16:58:47 +020098 at93c = &at93c_defs[0];
Brian Murphy1f21d2b2007-08-21 22:34:16 +020099 }
100
Brian Murphy1f21d2b2007-08-21 22:34:16 +0200101 lasat_init_board_info(); /* Read info from EEPROM */
102
Brian Murphy1f21d2b2007-08-21 22:34:16 +0200103 /* Get the command line */
104 if (argc > 0) {
Dmitri Vorobiev7580c9c2009-10-13 23:43:24 +0300105 strncpy(arcs_cmdline, argv[0], COMMAND_LINE_SIZE-1);
106 arcs_cmdline[COMMAND_LINE_SIZE-1] = '\0';
Brian Murphy1f21d2b2007-08-21 22:34:16 +0200107 }
108
109 /* Set the I/O base address */
110 set_io_port_base(KSEG1);
111
112 /* Set memory regions */
113 ioport_resource.start = 0;
114 ioport_resource.end = 0xffffffff; /* Wrong, fixme. */
115
116 add_memory_region(0, lasat_board_info.li_memsize, BOOT_MEM_RAM);
117}
118
119void __init prom_free_prom_memory(void)
120{
121}
122
123const char *get_system_type(void)
124{
125 return lasat_board_info.li_bmstr;
126}