Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
f137e463 | 2 | * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation |
1da177e4 LT |
3 | * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org) |
4 | * | |
5 | * This program is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU General Public License | |
7 | * as published by the Free Software Foundation; either version 2 | |
8 | * of the License, or (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | */ | |
19 | ||
20 | /* | |
21 | * Setup code for the SWARM board | |
22 | */ | |
23 | ||
1da177e4 LT |
24 | #include <linux/spinlock.h> |
25 | #include <linux/mm.h> | |
57c8a661 | 26 | #include <linux/memblock.h> |
1da177e4 LT |
27 | #include <linux/blkdev.h> |
28 | #include <linux/init.h> | |
29 | #include <linux/kernel.h> | |
894673ee | 30 | #include <linux/screen_info.h> |
1da177e4 LT |
31 | #include <linux/initrd.h> |
32 | ||
33 | #include <asm/irq.h> | |
34 | #include <asm/io.h> | |
35 | #include <asm/bootinfo.h> | |
36 | #include <asm/mipsregs.h> | |
37 | #include <asm/reboot.h> | |
38 | #include <asm/time.h> | |
39 | #include <asm/traps.h> | |
40 | #include <asm/sibyte/sb1250.h> | |
f137e463 AI |
41 | #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) |
42 | #include <asm/sibyte/bcm1480_regs.h> | |
43 | #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) | |
1da177e4 | 44 | #include <asm/sibyte/sb1250_regs.h> |
f137e463 | 45 | #else |
03dbd2e0 | 46 | #error invalid SiByte board configuration |
f137e463 | 47 | #endif |
1da177e4 LT |
48 | #include <asm/sibyte/sb1250_genbus.h> |
49 | #include <asm/sibyte/board.h> | |
50 | ||
f137e463 AI |
51 | #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) |
52 | extern void bcm1480_setup(void); | |
53 | #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) | |
1da177e4 | 54 | extern void sb1250_setup(void); |
f137e463 | 55 | #else |
03dbd2e0 | 56 | #error invalid SiByte board configuration |
f137e463 | 57 | #endif |
1da177e4 LT |
58 | |
59 | extern int xicor_probe(void); | |
f06e7aa4 | 60 | extern int xicor_set_time(time64_t); |
09adad17 | 61 | extern time64_t xicor_get_time(void); |
1da177e4 LT |
62 | |
63 | extern int m41t81_probe(void); | |
f06e7aa4 | 64 | extern int m41t81_set_time(time64_t); |
09adad17 | 65 | extern time64_t m41t81_get_time(void); |
1da177e4 LT |
66 | |
67 | const char *get_system_type(void) | |
68 | { | |
69 | return "SiByte " SIBYTE_BOARD_NAME; | |
70 | } | |
71 | ||
1da177e4 LT |
72 | int swarm_be_handler(struct pt_regs *regs, int is_fixup) |
73 | { | |
74 | if (!is_fixup && (regs->cp0_cause & 4)) { | |
75 | /* Data bus error - print PA */ | |
6aaf7786 | 76 | printk("DBE physical address: %010Lx\n", |
1da177e4 | 77 | __read_64bit_c0_register($26, 1)); |
1da177e4 | 78 | } |
635c9907 | 79 | return is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL; |
1da177e4 LT |
80 | } |
81 | ||
4b550488 RB |
82 | enum swarm_rtc_type { |
83 | RTC_NONE, | |
84 | RTC_XICOR, | |
2b3e5023 | 85 | RTC_M41T81, |
4b550488 RB |
86 | }; |
87 | ||
88 | enum swarm_rtc_type swarm_rtc_type; | |
89 | ||
09adad17 | 90 | void read_persistent_clock64(struct timespec64 *ts) |
4b550488 | 91 | { |
09adad17 | 92 | time64_t sec; |
d4f587c6 | 93 | |
4b550488 RB |
94 | switch (swarm_rtc_type) { |
95 | case RTC_XICOR: | |
d4f587c6 MS |
96 | sec = xicor_get_time(); |
97 | break; | |
4b550488 | 98 | |
2b3e5023 | 99 | case RTC_M41T81: |
d4f587c6 MS |
100 | sec = m41t81_get_time(); |
101 | break; | |
4b550488 RB |
102 | |
103 | case RTC_NONE: | |
104 | default: | |
09adad17 | 105 | sec = mktime64(2000, 1, 1, 0, 0, 0); |
d4f587c6 | 106 | break; |
4b550488 | 107 | } |
d4f587c6 | 108 | ts->tv_sec = sec; |
a648e811 | 109 | ts->tv_nsec = 0; |
4b550488 RB |
110 | } |
111 | ||
f06e7aa4 | 112 | int update_persistent_clock64(struct timespec64 now) |
4b550488 | 113 | { |
f06e7aa4 BW |
114 | time64_t sec = now.tv_sec; |
115 | ||
4b550488 RB |
116 | switch (swarm_rtc_type) { |
117 | case RTC_XICOR: | |
118 | return xicor_set_time(sec); | |
119 | ||
2b3e5023 | 120 | case RTC_M41T81: |
4b550488 RB |
121 | return m41t81_set_time(sec); |
122 | ||
123 | case RTC_NONE: | |
124 | default: | |
125 | return -1; | |
126 | } | |
127 | } | |
128 | ||
2925aba4 | 129 | void __init plat_mem_setup(void) |
1da177e4 | 130 | { |
f137e463 AI |
131 | #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) |
132 | bcm1480_setup(); | |
133 | #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) | |
1da177e4 | 134 | sb1250_setup(); |
f137e463 | 135 | #else |
03dbd2e0 | 136 | #error invalid SiByte board configuration |
f137e463 | 137 | #endif |
1da177e4 | 138 | |
1da177e4 LT |
139 | board_be_handler = swarm_be_handler; |
140 | ||
4b550488 RB |
141 | if (xicor_probe()) |
142 | swarm_rtc_type = RTC_XICOR; | |
143 | if (m41t81_probe()) | |
2b3e5023 | 144 | swarm_rtc_type = RTC_M41T81; |
1da177e4 | 145 | |
1da177e4 LT |
146 | #ifdef CONFIG_VT |
147 | screen_info = (struct screen_info) { | |
b20947aa SAS |
148 | .orig_video_page = 52, |
149 | .orig_video_mode = 3, | |
150 | .orig_video_cols = 80, | |
151 | .flags = 12, | |
152 | .orig_video_ega_bx = 3, | |
153 | .orig_video_lines = 25, | |
154 | .orig_video_isVGA = 0x22, | |
155 | .orig_video_points = 16, | |
1da177e4 LT |
156 | }; |
157 | /* XXXKW for CFE, get lines/cols from environment */ | |
158 | #endif | |
1da177e4 LT |
159 | } |
160 | ||
1da177e4 LT |
161 | #ifdef LEDS_PHYS |
162 | ||
163 | #ifdef CONFIG_SIBYTE_CARMEL | |
164 | /* XXXKW need to detect Monterey/LittleSur/etc */ | |
165 | #undef LEDS_PHYS | |
166 | #define LEDS_PHYS MLEDS_PHYS | |
167 | #endif | |
168 | ||
1da177e4 LT |
169 | void setleds(char *str) |
170 | { | |
8fb303c7 | 171 | void *reg; |
1da177e4 | 172 | int i; |
8fb303c7 | 173 | |
1da177e4 | 174 | for (i = 0; i < 4; i++) { |
8fb303c7 RB |
175 | reg = IOADDR(LEDS_PHYS) + 0x20 + ((3 - i) << 3); |
176 | ||
177 | if (!str[i]) | |
178 | writeb(' ', reg); | |
179 | else | |
180 | writeb(str[i], reg); | |
1da177e4 LT |
181 | } |
182 | } | |
8fb303c7 RB |
183 | |
184 | #endif /* LEDS_PHYS */ |