setup.c 3.4 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7
/*
 * Setup pointers to hardware dependent routines.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
8
 * Copyright (C) 1996, 1997, 2004, 05 by Ralf Baechle (ralf@linux-mips.org)
L
Linus Torvalds 已提交
9 10 11 12 13
 * Copyright (C) 2001, 2002, 2003 by Liam Davies (ldavies@agile.tv)
 *
 */
#include <linux/interrupt.h>
#include <linux/init.h>
14
#include <linux/pm.h>
L
Linus Torvalds 已提交
15 16 17 18 19 20 21

#include <asm/bootinfo.h>
#include <asm/time.h>
#include <asm/io.h>
#include <asm/reboot.h>
#include <asm/gt64120.h>

22
#include <cobalt.h>
L
Linus Torvalds 已提交
23 24 25 26 27 28 29

extern void cobalt_machine_restart(char *command);
extern void cobalt_machine_halt(void);
extern void cobalt_machine_power_off(void);

const char *get_system_type(void)
{
R
Ralf Baechle 已提交
30 31 32 33 34 35 36 37 38 39
	switch (cobalt_board_id) {
		case COBALT_BRD_ID_QUBE1:
			return "Cobalt Qube";
		case COBALT_BRD_ID_RAQ1:
			return "Cobalt RaQ";
		case COBALT_BRD_ID_QUBE2:
			return "Cobalt Qube2";
		case COBALT_BRD_ID_RAQ2:
			return "Cobalt RaQ2";
	}
L
Linus Torvalds 已提交
40 41 42
	return "MIPS Cobalt";
}

43
void __init plat_timer_setup(struct irqaction *irq)
L
Linus Torvalds 已提交
44
{
45
	/* Load timer value for HZ (TCLK is 50MHz) */
46
	GT_WRITE(GT_TC0_OFS, 50*1000*1000 / HZ);
L
Linus Torvalds 已提交
47

R
Ralf Baechle 已提交
48
	/* Enable timer */
49
	GT_WRITE(GT_TC_CONTROL_OFS, GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK);
L
Linus Torvalds 已提交
50

R
Ralf Baechle 已提交
51 52 53 54
	/* Register interrupt */
	setup_irq(COBALT_GALILEO_IRQ, irq);

	/* Enable interrupt */
55
	GT_WRITE(GT_INTRMASK_OFS, GT_INTR_T0EXP_MSK | GT_READ(GT_INTRMASK_OFS));
L
Linus Torvalds 已提交
56 57
}

58 59 60 61 62 63 64
/*
 * Cobalt doesn't have PS/2 keyboard/mouse interfaces,
 * keyboard conntroller is never used.
 * Also PCI-ISA bridge DMA contoroller is never used.
 */
static struct resource cobalt_reserved_resources[] = {
	{	/* dma1 */
65 66
		.start	= 0x00,
		.end	= 0x1f,
67 68 69 70
		.name	= "reserved",
		.flags	= IORESOURCE_BUSY | IORESOURCE_IO,
	},
	{	/* keyboard */
71 72
		.start	= 0x60,
		.end	= 0x6f,
73 74 75 76
		.name	= "reserved",
		.flags	= IORESOURCE_BUSY | IORESOURCE_IO,
	},
	{	/* dma page reg */
77 78
		.start	= 0x80,
		.end	= 0x8f,
79 80 81 82
		.name	= "reserved",
		.flags	= IORESOURCE_BUSY | IORESOURCE_IO,
	},
	{	/* dma2 */
83 84
		.start	= 0xc0,
		.end	= 0xdf,
85 86
		.name	= "reserved",
		.flags	= IORESOURCE_BUSY | IORESOURCE_IO,
87
	},
L
Linus Torvalds 已提交
88 89
};

90
void __init plat_mem_setup(void)
L
Linus Torvalds 已提交
91 92 93 94 95
{
	int i;

	_machine_restart = cobalt_machine_restart;
	_machine_halt = cobalt_machine_halt;
96
	pm_power_off = cobalt_machine_power_off;
L
Linus Torvalds 已提交
97

98
	set_io_port_base(CKSEG1ADDR(GT_DEF_PCI0_IO_BASE));
R
Ralf Baechle 已提交
99

Y
Yoichi Yuasa 已提交
100
	/* I/O port resource must include LCD/buttons */
R
Ralf Baechle 已提交
101
	ioport_resource.end = 0x0fffffff;
L
Linus Torvalds 已提交
102

103 104 105
	/* These resources have been reserved by VIA SuperI/O chip. */
	for (i = 0; i < ARRAY_SIZE(cobalt_reserved_resources); i++)
		request_resource(&ioport_resource, cobalt_reserved_resources + i);
L
Linus Torvalds 已提交
106 107 108 109
}

/*
 * Prom init. We read our one and only communication with the firmware.
R
Ralf Baechle 已提交
110 111
 * Grab the amount of installed memory.
 * Better boot loaders (CoLo) pass a command line too :-)
L
Linus Torvalds 已提交
112 113 114 115
 */

void __init prom_init(void)
{
R
Ralf Baechle 已提交
116 117 118
	int narg, indx, posn, nchr;
	unsigned long memsz;
	char **argv;
L
Linus Torvalds 已提交
119 120 121

	mips_machgroup = MACH_GROUP_COBALT;

R
Ralf Baechle 已提交
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
	memsz = fw_arg0 & 0x7fff0000;
	narg = fw_arg0 & 0x0000ffff;

	if (narg) {
		arcs_cmdline[0] = '\0';
		argv = (char **) fw_arg1;
		posn = 0;
		for (indx = 1; indx < narg; ++indx) {
			nchr = strlen(argv[indx]);
			if (posn + 1 + nchr + 1 > sizeof(arcs_cmdline))
				break;
			if (posn)
				arcs_cmdline[posn++] = ' ';
			strcpy(arcs_cmdline + posn, argv[indx]);
			posn += nchr;
		}
	}

	add_memory_region(0x0, memsz, BOOT_MEM_RAM);
L
Linus Torvalds 已提交
141 142
}

143
void __init prom_free_prom_memory(void)
L
Linus Torvalds 已提交
144 145 146
{
	/* Nothing to do! */
}