1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <linux/spinlock.h>
25#include <linux/mm.h>
26#include <linux/memblock.h>
27#include <linux/blkdev.h>
28#include <linux/init.h>
29#include <linux/kernel.h>
30#include <linux/screen_info.h>
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>
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)
44#include <asm/sibyte/sb1250_regs.h>
45#else
46#error invalid SiByte board configuration
47#endif
48#include <asm/sibyte/sb1250_genbus.h>
49#include <asm/sibyte/board.h>
50
51#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
52extern void bcm1480_setup(void);
53#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
54extern void sb1250_setup(void);
55#else
56#error invalid SiByte board configuration
57#endif
58
59extern int xicor_probe(void);
60extern int xicor_set_time(time64_t);
61extern time64_t xicor_get_time(void);
62
63extern int m41t81_probe(void);
64extern int m41t81_set_time(time64_t);
65extern time64_t m41t81_get_time(void);
66
67const char *get_system_type(void)
68{
69 return "SiByte " SIBYTE_BOARD_NAME;
70}
71
72int swarm_be_handler(struct pt_regs *regs, int is_fixup)
73{
74 if (!is_fixup && (regs->cp0_cause & 4)) {
75
76 printk("DBE physical address: %010Lx\n",
77 __read_64bit_c0_register($26, 1));
78 }
79 return is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL;
80}
81
82enum swarm_rtc_type {
83 RTC_NONE,
84 RTC_XICOR,
85 RTC_M41T81,
86};
87
88enum swarm_rtc_type swarm_rtc_type;
89
90void read_persistent_clock64(struct timespec64 *ts)
91{
92 time64_t sec;
93
94 switch (swarm_rtc_type) {
95 case RTC_XICOR:
96 sec = xicor_get_time();
97 break;
98
99 case RTC_M41T81:
100 sec = m41t81_get_time();
101 break;
102
103 case RTC_NONE:
104 default:
105 sec = mktime64(2000, 1, 1, 0, 0, 0);
106 break;
107 }
108 ts->tv_sec = sec;
109 ts->tv_nsec = 0;
110}
111
112int update_persistent_clock64(struct timespec64 now)
113{
114 time64_t sec = now.tv_sec;
115
116 switch (swarm_rtc_type) {
117 case RTC_XICOR:
118 return xicor_set_time(sec);
119
120 case RTC_M41T81:
121 return m41t81_set_time(sec);
122
123 case RTC_NONE:
124 default:
125 return -1;
126 }
127}
128
129void __init plat_mem_setup(void)
130{
131#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
132 bcm1480_setup();
133#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
134 sb1250_setup();
135#else
136#error invalid SiByte board configuration
137#endif
138
139 board_be_handler = swarm_be_handler;
140
141 if (xicor_probe())
142 swarm_rtc_type = RTC_XICOR;
143 if (m41t81_probe())
144 swarm_rtc_type = RTC_M41T81;
145
146#ifdef CONFIG_VT
147 screen_info = (struct screen_info) {
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,
156 };
157
158#endif
159}
160
161#ifdef LEDS_PHYS
162
163#ifdef CONFIG_SIBYTE_CARMEL
164
165#undef LEDS_PHYS
166#define LEDS_PHYS MLEDS_PHYS
167#endif
168
169void setleds(char *str)
170{
171 void *reg;
172 int i;
173
174 for (i = 0; i < 4; i++) {
175 reg = IOADDR(LEDS_PHYS) + 0x20 + ((3 - i) << 3);
176
177 if (!str[i])
178 writeb(' ', reg);
179 else
180 writeb(str[i], reg);
181 }
182}
183
184#endif
185