PageRenderTime 27ms CodeModel.GetById 18ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/arch/mips/sibyte/swarm/setup.c

https://bitbucket.org/evzijst/gittest
C | 163 lines | 112 code | 22 blank | 29 comment | 7 complexity | 17cd7bdeb50be9d67b62fb91f01df02e MD5 | raw file
  1/*
  2 * Copyright (C) 2000, 2001, 2002, 2003 Broadcom Corporation
  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
 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>
 42#include <asm/sibyte/sb1250_regs.h>
 43#include <asm/sibyte/sb1250_genbus.h>
 44#include <asm/sibyte/board.h>
 45
 46extern void sb1250_setup(void);
 47
 48extern int xicor_probe(void);
 49extern int xicor_set_time(unsigned long);
 50extern unsigned long xicor_get_time(void);
 51
 52extern int m41t81_probe(void);
 53extern int m41t81_set_time(unsigned long);
 54extern unsigned long m41t81_get_time(void);
 55
 56const char *get_system_type(void)
 57{
 58	return "SiByte " SIBYTE_BOARD_NAME;
 59}
 60
 61void __init swarm_timer_setup(struct irqaction *irq)
 62{
 63        /*
 64         * we don't set up irqaction, because we will deliver timer
 65         * interrupts through low-level (direct) meachanism.
 66         */
 67
 68        /* We only need to setup the generic timer */
 69        sb1250_time_init();
 70}
 71
 72int 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 */
 76#ifdef CONFIG_MIPS64
 77		printk("DBE physical address: %010lx\n",
 78		       __read_64bit_c0_register($26, 1));
 79#else
 80		printk("DBE physical address: %010llx\n",
 81		       __read_64bit_c0_split($26, 1));
 82#endif
 83	}
 84	return (is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL);
 85}
 86
 87static int __init swarm_setup(void)
 88{
 89	sb1250_setup();
 90
 91	panic_timeout = 5;  /* For debug.  */
 92
 93	board_timer_setup = swarm_timer_setup;
 94	board_be_handler = swarm_be_handler;
 95
 96	if (xicor_probe()) {
 97		printk("swarm setup: Xicor 1241 RTC detected.\n");
 98		rtc_get_time = xicor_get_time;
 99		rtc_set_time = xicor_set_time;
100	}
101 
102	if (m41t81_probe()) {
103		printk("swarm setup: M41T81 RTC detected.\n");
104		rtc_get_time = m41t81_get_time;
105		rtc_set_time = m41t81_set_time;
106	}
107
108	printk("This kernel optimized for "
109#ifdef CONFIG_SIMULATION
110	       "simulation"
111#else
112	       "board"
113#endif
114	       " runs "
115#ifdef CONFIG_SIBYTE_CFE
116	       "with"
117#else
118	       "without"
119#endif
120	       " CFE\n");
121
122#ifdef CONFIG_VT
123	screen_info = (struct screen_info) {
124		0, 0,           /* orig-x, orig-y */
125		0,              /* unused */
126		52,             /* orig_video_page */
127		3,              /* orig_video_mode */
128		80,             /* orig_video_cols */
129		4626, 3, 9,     /* unused, ega_bx, unused */
130		25,             /* orig_video_lines */
131		0x22,           /* orig_video_isVGA */
132		16              /* orig_video_points */
133       };
134       /* XXXKW for CFE, get lines/cols from environment */
135#endif
136
137	return 0;
138}
139
140early_initcall(swarm_setup);
141
142#ifdef LEDS_PHYS
143
144#ifdef CONFIG_SIBYTE_CARMEL
145/* XXXKW need to detect Monterey/LittleSur/etc */
146#undef LEDS_PHYS
147#define LEDS_PHYS MLEDS_PHYS
148#endif
149
150#define setled(index, c) \
151  ((unsigned char *)(IOADDR(LEDS_PHYS)+0x20))[(3-(index))<<3] = (c)
152void setleds(char *str)
153{
154	int i;
155	for (i = 0; i < 4; i++) {
156		if (!str[i]) {
157			setled(i, ' ');
158		} else {
159			setled(i, str[i]);
160		}
161	}
162}
163#endif