1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
8 * Setup code for the SWARM board
11 #include <linux/spinlock.h>
13 #include <linux/memblock.h>
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/screen_info.h>
17 #include <linux/initrd.h>
21 #include <asm/bootinfo.h>
22 #include <asm/mipsregs.h>
23 #include <asm/reboot.h>
25 #include <asm/traps.h>
26 #include <asm/sibyte/sb1250.h>
27 #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
28 #include <asm/sibyte/bcm1480_regs.h>
29 #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
30 #include <asm/sibyte/sb1250_regs.h>
32 #error invalid SiByte board configuration
34 #include <asm/sibyte/sb1250_genbus.h>
35 #include <asm/sibyte/board.h>
37 #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
38 extern void bcm1480_setup(void);
39 #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
40 extern void sb1250_setup(void);
42 #error invalid SiByte board configuration
45 extern int xicor_probe(void);
46 extern int xicor_set_time(time64_t);
47 extern time64_t xicor_get_time(void);
49 extern int m41t81_probe(void);
50 extern int m41t81_set_time(time64_t);
51 extern time64_t m41t81_get_time(void);
53 const char *get_system_type(void)
55 return "SiByte " SIBYTE_BOARD_NAME;
58 int swarm_be_handler(struct pt_regs *regs, int is_fixup)
60 if (!is_fixup && (regs->cp0_cause & 4)) {
61 /* Data bus error - print PA */
62 printk("DBE physical address: %010Lx\n",
63 __read_64bit_c0_register($26, 1));
65 return is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL;
74 enum swarm_rtc_type swarm_rtc_type;
76 void read_persistent_clock64(struct timespec64 *ts)
80 switch (swarm_rtc_type) {
82 sec = xicor_get_time();
86 sec = m41t81_get_time();
91 sec = mktime64(2000, 1, 1, 0, 0, 0);
98 int update_persistent_clock64(struct timespec64 now)
100 time64_t sec = now.tv_sec;
102 switch (swarm_rtc_type) {
104 return xicor_set_time(sec);
107 return m41t81_set_time(sec);
115 void __init plat_mem_setup(void)
117 #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
119 #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
122 #error invalid SiByte board configuration
125 mips_set_be_handler(swarm_be_handler);
128 swarm_rtc_type = RTC_XICOR;
130 swarm_rtc_type = RTC_M41T81;
133 screen_info = (struct screen_info) {
134 .orig_video_page = 52,
135 .orig_video_mode = 3,
136 .orig_video_cols = 80,
138 .orig_video_ega_bx = 3,
139 .orig_video_lines = 25,
140 .orig_video_isVGA = 0x22,
141 .orig_video_points = 16,
143 /* XXXKW for CFE, get lines/cols from environment */
149 #ifdef CONFIG_SIBYTE_CARMEL
150 /* XXXKW need to detect Monterey/LittleSur/etc */
152 #define LEDS_PHYS MLEDS_PHYS
155 void setleds(char *str)
160 for (i = 0; i < 4; i++) {
161 reg = IOADDR(LEDS_PHYS) + 0x20 + ((3 - i) << 3);
170 #endif /* LEDS_PHYS */