setup.c 4.3 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2
 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Broadcom Corporation
L
Linus Torvalds 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

/*
 * Setup code for the SWARM board
 */

#include <linux/spinlock.h>
#include <linux/mm.h>
#include <linux/bootmem.h>
#include <linux/blkdev.h>
#include <linux/init.h>
#include <linux/kernel.h>
30
#include <linux/screen_info.h>
L
Linus Torvalds 已提交
31 32 33 34 35 36 37 38 39 40
#include <linux/initrd.h>

#include <asm/irq.h>
#include <asm/io.h>
#include <asm/bootinfo.h>
#include <asm/mipsregs.h>
#include <asm/reboot.h>
#include <asm/time.h>
#include <asm/traps.h>
#include <asm/sibyte/sb1250.h>
41 42 43
#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
#include <asm/sibyte/bcm1480_regs.h>
#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
L
Linus Torvalds 已提交
44
#include <asm/sibyte/sb1250_regs.h>
45
#else
46
#error invalid SiByte board configuration
47
#endif
L
Linus Torvalds 已提交
48 49 50
#include <asm/sibyte/sb1250_genbus.h>
#include <asm/sibyte/board.h>

51 52 53
#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
extern void bcm1480_setup(void);
#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
L
Linus Torvalds 已提交
54
extern void sb1250_setup(void);
55
#else
56
#error invalid SiByte board configuration
57
#endif
L
Linus Torvalds 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75

extern int xicor_probe(void);
extern int xicor_set_time(unsigned long);
extern unsigned long xicor_get_time(void);

extern int m41t81_probe(void);
extern int m41t81_set_time(unsigned long);
extern unsigned long m41t81_get_time(void);

const char *get_system_type(void)
{
	return "SiByte " SIBYTE_BOARD_NAME;
}

int swarm_be_handler(struct pt_regs *regs, int is_fixup)
{
	if (!is_fixup && (regs->cp0_cause & 4)) {
		/* Data bus error - print PA */
76
		printk("DBE physical address: %010Lx\n",
L
Linus Torvalds 已提交
77 78 79 80 81
		       __read_64bit_c0_register($26, 1));
	}
	return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL);
}

82 83 84 85 86 87 88 89
enum swarm_rtc_type {
	RTC_NONE,
	RTC_XICOR,
	RTC_M4LT81
};

enum swarm_rtc_type swarm_rtc_type;

90
void read_persistent_clock(struct timespec *ts)
91
{
92 93
	unsigned long sec;

94 95
	switch (swarm_rtc_type) {
	case RTC_XICOR:
96 97
		sec = xicor_get_time();
		break;
98 99

	case RTC_M4LT81:
100 101
		sec = m41t81_get_time();
		break;
102 103 104

	case RTC_NONE:
	default:
105 106
		sec = mktime(2000, 1, 1, 0, 0, 0);
		break;
107
	}
108 109
	ts->tv_sec = sec;
	tv->tv_nsec = 0;
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
}

int rtc_mips_set_time(unsigned long sec)
{
	switch (swarm_rtc_type) {
	case RTC_XICOR:
		return xicor_set_time(sec);

	case RTC_M4LT81:
		return m41t81_set_time(sec);

	case RTC_NONE:
	default:
		return -1;
	}
}

127
void __init plat_mem_setup(void)
L
Linus Torvalds 已提交
128
{
129 130 131
#if defined(CONFIG_SIBYTE_BCM1x55) || defined(CONFIG_SIBYTE_BCM1x80)
	bcm1480_setup();
#elif defined(CONFIG_SIBYTE_SB1250) || defined(CONFIG_SIBYTE_BCM112X)
L
Linus Torvalds 已提交
132
	sb1250_setup();
133
#else
134
#error invalid SiByte board configuration
135
#endif
L
Linus Torvalds 已提交
136 137 138 139 140

	panic_timeout = 5;  /* For debug.  */

	board_be_handler = swarm_be_handler;

141 142 143 144
	if (xicor_probe())
		swarm_rtc_type = RTC_XICOR;
	if (m41t81_probe())
		swarm_rtc_type = RTC_M4LT81;
L
Linus Torvalds 已提交
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171

#ifdef CONFIG_VT
	screen_info = (struct screen_info) {
		0, 0,           /* orig-x, orig-y */
		0,              /* unused */
		52,             /* orig_video_page */
		3,              /* orig_video_mode */
		80,             /* orig_video_cols */
		4626, 3, 9,     /* unused, ega_bx, unused */
		25,             /* orig_video_lines */
		0x22,           /* orig_video_isVGA */
		16              /* orig_video_points */
       };
       /* XXXKW for CFE, get lines/cols from environment */
#endif
}

#ifdef LEDS_PHYS

#ifdef CONFIG_SIBYTE_CARMEL
/* XXXKW need to detect Monterey/LittleSur/etc */
#undef LEDS_PHYS
#define LEDS_PHYS MLEDS_PHYS
#endif

void setleds(char *str)
{
172
	void *reg;
L
Linus Torvalds 已提交
173
	int i;
174

L
Linus Torvalds 已提交
175
	for (i = 0; i < 4; i++) {
176 177 178 179 180 181
		reg = IOADDR(LEDS_PHYS) + 0x20 + ((3 - i) << 3);

		if (!str[i])
			writeb(' ', reg);
		else
			writeb(str[i], reg);
L
Linus Torvalds 已提交
182 183
	}
}
184 185

#endif /* LEDS_PHYS */