Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 2 | * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #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 Smirl | 894673e | 2006-07-10 04:44:13 -0700 | [diff] [blame^] | 30 | #include <linux/screen_info.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 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) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <asm/sibyte/sb1250_regs.h> |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 45 | #else |
| 46 | #error invalid SiByte board configuation |
| 47 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #include <asm/sibyte/sb1250_genbus.h> |
| 49 | #include <asm/sibyte/board.h> |
| 50 | |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 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) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | extern void sb1250_setup(void); |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 55 | #else |
| 56 | #error invalid SiByte board configuation |
| 57 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | extern int xicor_probe(void); |
| 60 | extern int xicor_set_time(unsigned long); |
| 61 | extern unsigned long xicor_get_time(void); |
| 62 | |
| 63 | extern int m41t81_probe(void); |
| 64 | extern int m41t81_set_time(unsigned long); |
| 65 | extern unsigned long m41t81_get_time(void); |
| 66 | |
| 67 | const char *get_system_type(void) |
| 68 | { |
| 69 | return "SiByte " SIBYTE_BOARD_NAME; |
| 70 | } |
| 71 | |
Ralf Baechle | a904f74 | 2006-03-15 00:03:29 +0000 | [diff] [blame] | 72 | void __init swarm_time_init(void) |
| 73 | { |
Thiemo Seufer | b75d4c1 | 2006-06-18 05:17:54 +0100 | [diff] [blame] | 74 | #if defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) |
Ralf Baechle | a904f74 | 2006-03-15 00:03:29 +0000 | [diff] [blame] | 75 | /* Setup HPT */ |
| 76 | sb1250_hpt_setup(); |
Thiemo Seufer | b75d4c1 | 2006-06-18 05:17:54 +0100 | [diff] [blame] | 77 | #endif |
Ralf Baechle | a904f74 | 2006-03-15 00:03:29 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | void __init swarm_timer_setup(struct irqaction *irq) |
| 81 | { |
| 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 Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 88 | #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 |
| 93 | #error invalid SiByte board configuation |
| 94 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | int 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 Baechle | 6aaf778 | 2005-10-01 13:14:58 +0100 | [diff] [blame] | 101 | printk("DBE physical address: %010Lx\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | __read_64bit_c0_register($26, 1)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } |
| 104 | return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL); |
| 105 | } |
| 106 | |
Ralf Baechle | 2925aba | 2006-06-18 01:32:22 +0100 | [diff] [blame] | 107 | void __init plat_mem_setup(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | { |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 109 | #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) |
| 110 | bcm1480_setup(); |
| 111 | #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | sb1250_setup(); |
Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 113 | #else |
| 114 | #error invalid SiByte board configuation |
| 115 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | panic_timeout = 5; /* For debug. */ |
| 118 | |
Ralf Baechle | a904f74 | 2006-03-15 00:03:29 +0000 | [diff] [blame] | 119 | board_time_init = swarm_time_init; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | board_timer_setup = swarm_timer_setup; |
| 121 | board_be_handler = swarm_be_handler; |
| 122 | |
| 123 | if (xicor_probe()) { |
| 124 | printk("swarm setup: Xicor 1241 RTC detected.\n"); |
Yoichi Yuasa | d23ee8f | 2006-03-27 01:16:33 -0800 | [diff] [blame] | 125 | rtc_mips_get_time = xicor_get_time; |
| 126 | rtc_mips_set_time = xicor_set_time; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | } |
Ralf Baechle | 42a3b4f | 2005-09-03 15:56:17 -0700 | [diff] [blame] | 128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | if (m41t81_probe()) { |
| 130 | printk("swarm setup: M41T81 RTC detected.\n"); |
Yoichi Yuasa | d23ee8f | 2006-03-27 01:16:33 -0800 | [diff] [blame] | 131 | rtc_mips_get_time = m41t81_get_time; |
| 132 | rtc_mips_set_time = m41t81_set_time; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | printk("This kernel optimized for " |
| 136 | #ifdef CONFIG_SIMULATION |
| 137 | "simulation" |
| 138 | #else |
| 139 | "board" |
| 140 | #endif |
| 141 | " runs " |
| 142 | #ifdef CONFIG_SIBYTE_CFE |
| 143 | "with" |
| 144 | #else |
| 145 | "without" |
| 146 | #endif |
| 147 | " CFE\n"); |
| 148 | |
| 149 | #ifdef CONFIG_VT |
| 150 | screen_info = (struct screen_info) { |
| 151 | 0, 0, /* orig-x, orig-y */ |
| 152 | 0, /* unused */ |
| 153 | 52, /* orig_video_page */ |
| 154 | 3, /* orig_video_mode */ |
| 155 | 80, /* orig_video_cols */ |
| 156 | 4626, 3, 9, /* unused, ega_bx, unused */ |
| 157 | 25, /* orig_video_lines */ |
| 158 | 0x22, /* orig_video_isVGA */ |
| 159 | 16 /* orig_video_points */ |
| 160 | }; |
| 161 | /* XXXKW for CFE, get lines/cols from environment */ |
| 162 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | #ifdef LEDS_PHYS |
| 166 | |
| 167 | #ifdef CONFIG_SIBYTE_CARMEL |
| 168 | /* XXXKW need to detect Monterey/LittleSur/etc */ |
| 169 | #undef LEDS_PHYS |
| 170 | #define LEDS_PHYS MLEDS_PHYS |
| 171 | #endif |
| 172 | |
| 173 | #define setled(index, c) \ |
| 174 | ((unsigned char *)(IOADDR(LEDS_PHYS)+0x20))[(3-(index))<<3] = (c) |
| 175 | void setleds(char *str) |
| 176 | { |
| 177 | int i; |
| 178 | for (i = 0; i < 4; i++) { |
| 179 | if (!str[i]) { |
| 180 | setled(i, ' '); |
| 181 | } else { |
| 182 | setled(i, str[i]); |
| 183 | } |
| 184 | } |
| 185 | } |
| 186 | #endif |