blob: 8b3ef0e4cd555c735bf3cfe60c5a42110fc0ac9e [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/spinlock.h>
25#include <linux/mm.h>
26#include <linux/bootmem.h>
27#include <linux/blkdev.h>
28#include <linux/init.h>
29#include <linux/kernel.h>
Jon Smirl894673e2006-07-10 04:44:13 -070030#include <linux/screen_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#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>
Andrew Isaacsonf137e462005-10-19 23:56:38 -070041#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)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <asm/sibyte/sb1250_regs.h>
Andrew Isaacsonf137e462005-10-19 23:56:38 -070045#else
Maciej W. Rozycki03dbd2e2006-11-30 13:45:32 +000046#error invalid SiByte board configuration
Andrew Isaacsonf137e462005-10-19 23:56:38 -070047#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <asm/sibyte/sb1250_genbus.h>
49#include <asm/sibyte/board.h>
50
Andrew Isaacsonf137e462005-10-19 23:56:38 -070051#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
52extern void bcm1480_setup(void);
53#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054extern void sb1250_setup(void);
Andrew Isaacsonf137e462005-10-19 23:56:38 -070055#else
Maciej W. Rozycki03dbd2e2006-11-30 13:45:32 +000056#error invalid SiByte board configuration
Andrew Isaacsonf137e462005-10-19 23:56:38 -070057#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59extern int xicor_probe(void);
60extern int xicor_set_time(unsigned long);
61extern unsigned long xicor_get_time(void);
62
63extern int m41t81_probe(void);
64extern int m41t81_set_time(unsigned long);
65extern unsigned long m41t81_get_time(void);
66
67const char *get_system_type(void)
68{
69 return "SiByte " SIBYTE_BOARD_NAME;
70}
71
Ralf Baechle4b550482007-10-11 23:46:08 +010072void __init plat_time_init(void)
Ralf Baechlea904f742006-03-15 00:03:29 +000073{
Thiemo Seuferb75d4c12006-06-18 05:17:54 +010074#if defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
Ralf Baechlea904f742006-03-15 00:03:29 +000075 /* Setup HPT */
76 sb1250_hpt_setup();
Thiemo Seuferb75d4c12006-06-18 05:17:54 +010077#endif
Ralf Baechlea904f742006-03-15 00:03:29 +000078}
79
Ralf Baechle54d0a212006-07-09 21:38:56 +010080void __init plat_timer_setup(struct irqaction *irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081{
82 /*
83 * we don't set up irqaction, because we will deliver timer
84 * interrupts through low-level (direct) meachanism.
85 */
86
87 /* We only need to setup the generic timer */
Andrew Isaacsonf137e462005-10-19 23:56:38 -070088#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
89 bcm1480_time_init();
90#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
91 sb1250_time_init();
92#else
Maciej W. Rozycki03dbd2e2006-11-30 13:45:32 +000093#error invalid SiByte board configuration
Andrew Isaacsonf137e462005-10-19 23:56:38 -070094#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070095}
96
97int swarm_be_handler(struct pt_regs *regs, int is_fixup)
98{
99 if (!is_fixup && (regs->cp0_cause & 4)) {
100 /* Data bus error - print PA */
Ralf Baechle6aaf7782005-10-01 13:14:58 +0100101 printk("DBE physical address: %010Lx\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 __read_64bit_c0_register($26, 1));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 }
104 return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL);
105}
106
Ralf Baechle4b550482007-10-11 23:46:08 +0100107enum swarm_rtc_type {
108 RTC_NONE,
109 RTC_XICOR,
110 RTC_M4LT81
111};
112
113enum swarm_rtc_type swarm_rtc_type;
114
115unsigned long read_persistent_clock(void)
116{
117 switch (swarm_rtc_type) {
118 case RTC_XICOR:
119 return xicor_get_time();
120
121 case RTC_M4LT81:
122 return m41t81_get_time();
123
124 case RTC_NONE:
125 default:
126 return mktime(2000, 1, 1, 0, 0, 0);
127 }
128}
129
130int rtc_mips_set_time(unsigned long sec)
131{
132 switch (swarm_rtc_type) {
133 case RTC_XICOR:
134 return xicor_set_time(sec);
135
136 case RTC_M4LT81:
137 return m41t81_set_time(sec);
138
139 case RTC_NONE:
140 default:
141 return -1;
142 }
143}
144
Ralf Baechle2925aba2006-06-18 01:32:22 +0100145void __init plat_mem_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146{
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700147#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
148 bcm1480_setup();
149#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 sb1250_setup();
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700151#else
Maciej W. Rozycki03dbd2e2006-11-30 13:45:32 +0000152#error invalid SiByte board configuration
Andrew Isaacsonf137e462005-10-19 23:56:38 -0700153#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155 panic_timeout = 5; /* For debug. */
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 board_be_handler = swarm_be_handler;
158
Ralf Baechle4b550482007-10-11 23:46:08 +0100159 if (xicor_probe())
160 swarm_rtc_type = RTC_XICOR;
161 if (m41t81_probe())
162 swarm_rtc_type = RTC_M4LT81;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164 printk("This kernel optimized for "
165#ifdef CONFIG_SIMULATION
166 "simulation"
167#else
168 "board"
169#endif
170 " runs "
171#ifdef CONFIG_SIBYTE_CFE
172 "with"
173#else
174 "without"
175#endif
176 " CFE\n");
177
178#ifdef CONFIG_VT
179 screen_info = (struct screen_info) {
180 0, 0, /* orig-x, orig-y */
181 0, /* unused */
182 52, /* orig_video_page */
183 3, /* orig_video_mode */
184 80, /* orig_video_cols */
185 4626, 3, 9, /* unused, ega_bx, unused */
186 25, /* orig_video_lines */
187 0x22, /* orig_video_isVGA */
188 16 /* orig_video_points */
189 };
190 /* XXXKW for CFE, get lines/cols from environment */
191#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192}
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194#ifdef LEDS_PHYS
195
196#ifdef CONFIG_SIBYTE_CARMEL
197/* XXXKW need to detect Monterey/LittleSur/etc */
198#undef LEDS_PHYS
199#define LEDS_PHYS MLEDS_PHYS
200#endif
201
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202void setleds(char *str)
203{
Ralf Baechle8fb303c2007-03-24 14:26:13 +0000204 void *reg;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 int i;
Ralf Baechle8fb303c2007-03-24 14:26:13 +0000206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 for (i = 0; i < 4; i++) {
Ralf Baechle8fb303c2007-03-24 14:26:13 +0000208 reg = IOADDR(LEDS_PHYS) + 0x20 + ((3 - i) << 3);
209
210 if (!str[i])
211 writeb(' ', reg);
212 else
213 writeb(str[i], reg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 }
215}
Ralf Baechle8fb303c2007-03-24 14:26:13 +0000216
217#endif /* LEDS_PHYS */