1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
4 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
8 * Setup code for the SWARM board
11 #include <linux/spinlock.h>
13 #include <linux/memblock.h>
14 #include <linux/blkdev.h>
15 #include <linux/init.h>
16 #include <linux/kernel.h>
17 #include <linux/screen_info.h>
18 #include <linux/initrd.h>
22 #include <asm/bootinfo.h>
23 #include <asm/mipsregs.h>
24 #include <asm/reboot.h>
26 #include <asm/traps.h>
27 #include <asm/sibyte/sb1250.h>
28 #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
29 #include <asm/sibyte/bcm1480_regs.h>
30 #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
31 #include <asm/sibyte/sb1250_regs.h>
33 #error invalid SiByte board configuration
35 #include <asm/sibyte/sb1250_genbus.h>
36 #include <asm/sibyte/board.h>
38 #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
39 extern void bcm1480_setup(void);
40 #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
41 extern void sb1250_setup(void);
43 #error invalid SiByte board configuration
46 extern int xicor_probe(void);
47 extern int xicor_set_time(time64_t
);
48 extern time64_t
xicor_get_time(void);
50 extern int m41t81_probe(void);
51 extern int m41t81_set_time(time64_t
);
52 extern time64_t
m41t81_get_time(void);
54 const char *get_system_type(void)
56 return "SiByte " SIBYTE_BOARD_NAME
;
59 int swarm_be_handler(struct pt_regs
*regs
, int is_fixup
)
61 if (!is_fixup
&& (regs
->cp0_cause
& 4)) {
62 /* Data bus error - print PA */
63 printk("DBE physical address: %010Lx\n",
64 __read_64bit_c0_register($
26, 1));
66 return is_fixup
? MIPS_BE_FIXUP
: MIPS_BE_FATAL
;
75 enum swarm_rtc_type swarm_rtc_type
;
77 void read_persistent_clock64(struct timespec64
*ts
)
81 switch (swarm_rtc_type
) {
83 sec
= xicor_get_time();
87 sec
= m41t81_get_time();
92 sec
= mktime64(2000, 1, 1, 0, 0, 0);
99 int update_persistent_clock64(struct timespec64 now
)
101 time64_t sec
= now
.tv_sec
;
103 switch (swarm_rtc_type
) {
105 return xicor_set_time(sec
);
108 return m41t81_set_time(sec
);
116 void __init
plat_mem_setup(void)
118 #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
120 #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
123 #error invalid SiByte board configuration
126 board_be_handler
= swarm_be_handler
;
129 swarm_rtc_type
= RTC_XICOR
;
131 swarm_rtc_type
= RTC_M41T81
;
134 screen_info
= (struct screen_info
) {
135 .orig_video_page
= 52,
136 .orig_video_mode
= 3,
137 .orig_video_cols
= 80,
139 .orig_video_ega_bx
= 3,
140 .orig_video_lines
= 25,
141 .orig_video_isVGA
= 0x22,
142 .orig_video_points
= 16,
144 /* XXXKW for CFE, get lines/cols from environment */
150 #ifdef CONFIG_SIBYTE_CARMEL
151 /* XXXKW need to detect Monterey/LittleSur/etc */
153 #define LEDS_PHYS MLEDS_PHYS
156 void setleds(char *str
)
161 for (i
= 0; i
< 4; i
++) {
162 reg
= IOADDR(LEDS_PHYS
) + 0x20 + ((3 - i
) << 3);
171 #endif /* LEDS_PHYS */