| 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 | 
| Maciej W. Rozycki | 03dbd2e | 2006-11-30 13:45:32 +0000 | [diff] [blame] | 46 | #error invalid SiByte board configuration | 
| Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 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 | 
| Maciej W. Rozycki | 03dbd2e | 2006-11-30 13:45:32 +0000 | [diff] [blame] | 56 | #error invalid SiByte board configuration | 
| Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 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 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 */ | 
| Ralf Baechle | 6aaf778 | 2005-10-01 13:14:58 +0100 | [diff] [blame] | 76 | printk("DBE physical address: %010Lx\n", | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | __read_64bit_c0_register($26, 1)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | } | 
|  | 79 | return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL); | 
|  | 80 | } | 
|  | 81 |  | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 82 | enum swarm_rtc_type { | 
|  | 83 | RTC_NONE, | 
|  | 84 | RTC_XICOR, | 
| Ralf Baechle | 2b3e502 | 2010-11-02 19:38:53 +0000 | [diff] [blame] | 85 | RTC_M41T81, | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 86 | }; | 
|  | 87 |  | 
|  | 88 | enum swarm_rtc_type swarm_rtc_type; | 
|  | 89 |  | 
| Martin Schwidefsky | d4f587c | 2009-08-14 15:47:31 +0200 | [diff] [blame] | 90 | void read_persistent_clock(struct timespec *ts) | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 91 | { | 
| Martin Schwidefsky | d4f587c | 2009-08-14 15:47:31 +0200 | [diff] [blame] | 92 | unsigned long sec; | 
|  | 93 |  | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 94 | switch (swarm_rtc_type) { | 
|  | 95 | case RTC_XICOR: | 
| Martin Schwidefsky | d4f587c | 2009-08-14 15:47:31 +0200 | [diff] [blame] | 96 | sec = xicor_get_time(); | 
|  | 97 | break; | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 98 |  | 
| Ralf Baechle | 2b3e502 | 2010-11-02 19:38:53 +0000 | [diff] [blame] | 99 | case RTC_M41T81: | 
| Martin Schwidefsky | d4f587c | 2009-08-14 15:47:31 +0200 | [diff] [blame] | 100 | sec = m41t81_get_time(); | 
|  | 101 | break; | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 102 |  | 
|  | 103 | case RTC_NONE: | 
|  | 104 | default: | 
| Martin Schwidefsky | d4f587c | 2009-08-14 15:47:31 +0200 | [diff] [blame] | 105 | sec = mktime(2000, 1, 1, 0, 0, 0); | 
|  | 106 | break; | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 107 | } | 
| Martin Schwidefsky | d4f587c | 2009-08-14 15:47:31 +0200 | [diff] [blame] | 108 | ts->tv_sec = sec; | 
| Mark Mason | a648e81 | 2009-09-23 13:35:09 -0700 | [diff] [blame] | 109 | ts->tv_nsec = 0; | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 110 | } | 
|  | 111 |  | 
|  | 112 | int rtc_mips_set_time(unsigned long sec) | 
|  | 113 | { | 
|  | 114 | switch (swarm_rtc_type) { | 
|  | 115 | case RTC_XICOR: | 
|  | 116 | return xicor_set_time(sec); | 
|  | 117 |  | 
| Ralf Baechle | 2b3e502 | 2010-11-02 19:38:53 +0000 | [diff] [blame] | 118 | case RTC_M41T81: | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 119 | return m41t81_set_time(sec); | 
|  | 120 |  | 
|  | 121 | case RTC_NONE: | 
|  | 122 | default: | 
|  | 123 | return -1; | 
|  | 124 | } | 
|  | 125 | } | 
|  | 126 |  | 
| Ralf Baechle | 2925aba | 2006-06-18 01:32:22 +0100 | [diff] [blame] | 127 | void __init plat_mem_setup(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | { | 
| Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 129 | #if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80) | 
|  | 130 | bcm1480_setup(); | 
|  | 131 | #elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | sb1250_setup(); | 
| Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 133 | #else | 
| Maciej W. Rozycki | 03dbd2e | 2006-11-30 13:45:32 +0000 | [diff] [blame] | 134 | #error invalid SiByte board configuration | 
| Andrew Isaacson | f137e46 | 2005-10-19 23:56:38 -0700 | [diff] [blame] | 135 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 |  | 
|  | 137 | panic_timeout = 5;  /* For debug.  */ | 
|  | 138 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | board_be_handler = swarm_be_handler; | 
|  | 140 |  | 
| Ralf Baechle | 4b55048 | 2007-10-11 23:46:08 +0100 | [diff] [blame] | 141 | if (xicor_probe()) | 
|  | 142 | swarm_rtc_type = RTC_XICOR; | 
|  | 143 | if (m41t81_probe()) | 
| Ralf Baechle | 2b3e502 | 2010-11-02 19:38:53 +0000 | [diff] [blame] | 144 | swarm_rtc_type = RTC_M41T81; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | #ifdef CONFIG_VT | 
|  | 147 | screen_info = (struct screen_info) { | 
| Sebastian Andrzej Siewior | b20947a | 2010-04-21 22:36:47 +0200 | [diff] [blame] | 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, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | }; | 
|  | 157 | /* XXXKW for CFE, get lines/cols from environment */ | 
|  | 158 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | } | 
|  | 160 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | void setleds(char *str) | 
|  | 170 | { | 
| Ralf Baechle | 8fb303c | 2007-03-24 14:26:13 +0000 | [diff] [blame] | 171 | void *reg; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | int i; | 
| Ralf Baechle | 8fb303c | 2007-03-24 14:26:13 +0000 | [diff] [blame] | 173 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | for (i = 0; i < 4; i++) { | 
| Ralf Baechle | 8fb303c | 2007-03-24 14:26:13 +0000 | [diff] [blame] | 175 | reg = IOADDR(LEDS_PHYS) + 0x20 + ((3 - i) << 3); | 
|  | 176 |  | 
|  | 177 | if (!str[i]) | 
|  | 178 | writeb(' ', reg); | 
|  | 179 | else | 
|  | 180 | writeb(str[i], reg); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | } | 
|  | 182 | } | 
| Ralf Baechle | 8fb303c | 2007-03-24 14:26:13 +0000 | [diff] [blame] | 183 |  | 
|  | 184 | #endif /* LEDS_PHYS */ |