setup.c 3.27 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
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)
Linus Torvalds's avatar
Linus Torvalds committed
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>
Linus Torvalds's avatar
Linus Torvalds committed
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>
23
#include <irq.h>
Linus Torvalds's avatar
Linus Torvalds committed
24 25 26 27 28 29 30

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)
{
31 32 33 34 35 36 37 38 39 40
	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";
	}
Linus Torvalds's avatar
Linus Torvalds committed
41 42 43
	return "MIPS Cobalt";
}

44
void __init plat_timer_setup(struct irqaction *irq)
Linus Torvalds's avatar
Linus Torvalds committed
45
{
46
	/* Load timer value for HZ (TCLK is 50MHz) */
47
	GT_WRITE(GT_TC0_OFS, 50*1000*1000 / HZ);
Linus Torvalds's avatar
Linus Torvalds committed
48

49
	/* Enable timer0 */
50
	GT_WRITE(GT_TC_CONTROL_OFS, GT_TC_CONTROL_ENTC0_MSK | GT_TC_CONTROL_SELTC0_MSK);
Linus Torvalds's avatar
Linus Torvalds committed
51

52
	setup_irq(GT641XX_TIMER0_IRQ, irq);
Linus Torvalds's avatar
Linus Torvalds committed
53 54
}

55 56 57 58 59 60 61
/*
 * 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 */
62 63
		.start	= 0x00,
		.end	= 0x1f,
64 65 66 67
		.name	= "reserved",
		.flags	= IORESOURCE_BUSY | IORESOURCE_IO,
	},
	{	/* keyboard */
68 69
		.start	= 0x60,
		.end	= 0x6f,
70 71 72 73
		.name	= "reserved",
		.flags	= IORESOURCE_BUSY | IORESOURCE_IO,
	},
	{	/* dma page reg */
74 75
		.start	= 0x80,
		.end	= 0x8f,
76 77 78 79
		.name	= "reserved",
		.flags	= IORESOURCE_BUSY | IORESOURCE_IO,
	},
	{	/* dma2 */
80 81
		.start	= 0xc0,
		.end	= 0xdf,
82 83
		.name	= "reserved",
		.flags	= IORESOURCE_BUSY | IORESOURCE_IO,
84
	},
Linus Torvalds's avatar
Linus Torvalds committed
85 86
};

87
void __init plat_mem_setup(void)
Linus Torvalds's avatar
Linus Torvalds committed
88 89 90 91 92
{
	int i;

	_machine_restart = cobalt_machine_restart;
	_machine_halt = cobalt_machine_halt;
93
	pm_power_off = cobalt_machine_power_off;
Linus Torvalds's avatar
Linus Torvalds committed
94

95
	set_io_port_base(CKSEG1ADDR(GT_DEF_PCI0_IO_BASE));
96

97
	/* I/O port resource must include LCD/buttons */
98
	ioport_resource.end = 0x0fffffff;
Linus Torvalds's avatar
Linus Torvalds committed
99

100 101 102
	/* 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);
Linus Torvalds's avatar
Linus Torvalds committed
103 104 105 106
}

/*
 * Prom init. We read our one and only communication with the firmware.
107 108
 * Grab the amount of installed memory.
 * Better boot loaders (CoLo) pass a command line too :-)
Linus Torvalds's avatar
Linus Torvalds committed
109 110 111 112
 */

void __init prom_init(void)
{
113 114 115
	int narg, indx, posn, nchr;
	unsigned long memsz;
	char **argv;
Linus Torvalds's avatar
Linus Torvalds committed
116 117 118

	mips_machgroup = MACH_GROUP_COBALT;

119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
	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);
Linus Torvalds's avatar
Linus Torvalds committed
138 139
}

140
void __init prom_free_prom_memory(void)
Linus Torvalds's avatar
Linus Torvalds committed
141 142 143
{
	/* Nothing to do! */
}