blob: f9e694988cdf18733682531f0f304321a6cf3635 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Andrew Isaacsonf137e462005-10-19 23:56:38 -07002 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * 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
24#include <linux/config.h>
25#include <linux/spinlock.h>
26#include <linux/mm.h>
27#include <linux/bootmem.h>
28#include <linux/blkdev.h>
29#include <linux/init.h>
30#include <linux/kernel.h>
31#include <linux/tty.h>
32#include <linux/initrd.h>
33
34#include <asm/irq.h>
35#include <asm/io.h>
36#include <asm/bootinfo.h>
37#include <asm/mipsregs.h>
38#include <asm/reboot.h>
39#include <asm/time.h>
40#include <asm/traps.h>
41#include <asm/sibyte/sb1250.h>
Andrew Isaacsonf137e462005-10-19 23:56:38 -070042#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
43#include <asm/sibyte/bcm1480_regs.h>
44#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <asm/sibyte/sb1250_regs.h>
Andrew Isaacsonf137e462005-10-19 23:56:38 -070046#else
47#error invalid SiByte board configuation
48#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#include <asm/sibyte/sb1250_genbus.h>
50#include <asm/sibyte/board.h>
51
Andrew Isaacsonf137e462005-10-19 23:56:38 -070052#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
53extern void bcm1480_setup(void);
54#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055extern void sb1250_setup(void);
Andrew Isaacsonf137e462005-10-19 23:56:38 -070056#else
57#error invalid SiByte board configuation
58#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60extern int xicor_probe(void);
61extern int xicor_set_time(unsigned long);
62extern unsigned long xicor_get_time(void);
63
64extern int m41t81_probe(void);
65extern int m41t81_set_time(unsigned long);
66extern unsigned long m41t81_get_time(void);
67
68const char *get_system_type(void)
69{
70 return "SiByte " SIBYTE_BOARD_NAME;
71}
72
Ralf Baechlea904f742006-03-15 00:03:29 +000073void __init swarm_time_init(void)
74{
Thiemo Seuferb75d4c12006-06-18 05:17:54 +010075#if defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
Ralf Baechlea904f742006-03-15 00:03:29 +000076 /* Setup HPT */
77 sb1250_hpt_setup();
Thiemo Seuferb75d4c12006-06-18 05:17:54 +010078#endif
Ralf Baechlea904f742006-03-15 00:03:29 +000079}
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081void __init swarm_timer_setup(struct irqaction *irq)
82{
83 /*
84 * we don't set up irqaction, because we will deliver timer
85 * interrupts through low-level (direct) meachanism.
86 */
87
88 /* We only need to setup the generic timer */
Andrew Isaacsonf137e462005-10-19 23:56:38 -070089#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
90 bcm1480_time_init();
91#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
92 sb1250_time_init();
93#else
94#error invalid SiByte board configuation
95#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070096}
97
98int swarm_be_handler(struct pt_regs *regs, int is_fixup)
99{
100 if (!is_fixup && (regs->cp0_cause & 4)) {
101 /* Data bus error - print PA */
Ralf Baechle6aaf7782005-10-01 13:14:58 +0100102 printk("DBE physical address: %010Lx\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 __read_64bit_c0_register($26, 1));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 }
105 return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL);
106}
107
Ralf Baechle2925aba2006-06-18 01:32:22 +0100108void __init plat_mem_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109{
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700110#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
111 bcm1480_setup();
112#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 sb1250_setup();
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700114#else
115#error invalid SiByte board configuation
116#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118 panic_timeout = 5; /* For debug. */
119
Ralf Baechlea904f742006-03-15 00:03:29 +0000120 board_time_init = swarm_time_init;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 board_timer_setup = swarm_timer_setup;
122 board_be_handler = swarm_be_handler;
123
124 if (xicor_probe()) {
125 printk("swarm setup: Xicor 1241 RTC detected.\n");
Yoichi Yuasad23ee8f2006-03-27 01:16:33 -0800126 rtc_mips_get_time = xicor_get_time;
127 rtc_mips_set_time = xicor_set_time;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 }
Ralf Baechle42a3b4f2005-09-03 15:56:17 -0700129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 if (m41t81_probe()) {
131 printk("swarm setup: M41T81 RTC detected.\n");
Yoichi Yuasad23ee8f2006-03-27 01:16:33 -0800132 rtc_mips_get_time = m41t81_get_time;
133 rtc_mips_set_time = m41t81_set_time;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 }
135
136 printk("This kernel optimized for "
137#ifdef CONFIG_SIMULATION
138 "simulation"
139#else
140 "board"
141#endif
142 " runs "
143#ifdef CONFIG_SIBYTE_CFE
144 "with"
145#else
146 "without"
147#endif
148 " CFE\n");
149
150#ifdef CONFIG_VT
151 screen_info = (struct screen_info) {
152 0, 0, /* orig-x, orig-y */
153 0, /* unused */
154 52, /* orig_video_page */
155 3, /* orig_video_mode */
156 80, /* orig_video_cols */
157 4626, 3, 9, /* unused, ega_bx, unused */
158 25, /* orig_video_lines */
159 0x22, /* orig_video_isVGA */
160 16 /* orig_video_points */
161 };
162 /* XXXKW for CFE, get lines/cols from environment */
163#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164}
165
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166#ifdef LEDS_PHYS
167
168#ifdef CONFIG_SIBYTE_CARMEL
169/* XXXKW need to detect Monterey/LittleSur/etc */
170#undef LEDS_PHYS
171#define LEDS_PHYS MLEDS_PHYS
172#endif
173
174#define setled(index, c) \
175 ((unsigned char *)(IOADDR(LEDS_PHYS)+0x20))[(3-(index))<<3] = (c)
176void setleds(char *str)
177{
178 int i;
179 for (i = 0; i < 4; i++) {
180 if (!str[i]) {
181 setled(i, ' ');
182 } else {
183 setled(i, str[i]);
184 }
185 }
186}
187#endif