aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ifxmips/files-2.6.33/arch/mips/ifxmips/danube/setup.c
blob: 35e6fd9645b4b36803939baf454ec13ff2447135 (plain)
1
2
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <linux/cpu.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/pm.h>
#include <linux/io.h>
#include <linux/ioport.h>
#include <asm/reboot.h>
#include <asm/system.h>
#include <ifxmips.h>
#include <ifxmips_cgu.h>

#define SYSTEM_DANUBE			"Danube"
#define SYSTEM_DANUBE_CHIPID1	0x00129083
#define SYSTEM_DANUBE_CHIPID2	0x0012B083

#define SYSTEM_TWINPASS			"Twinpass"
#define SYSTEM_TWINPASS_CHIPID	0x0012D083

static unsigned int chiprev = 0;
unsigned char ifxmips_sys_type[IFXMIPS_SYS_TYPE_LEN];

unsigned int
ifxmips_get_cpu_ver(void)
{
	return (ifxmips_r32(IFXMIPS_MPS_CHIPID) & 0xF0000000) >> 28;
}
EXPORT_SYMBOL(ifxmips_get_cpu_ver);

const char*
get_system_type(void)
{
	return ifxmips_sys_type;
}

static void
ifxmips_machine_restart(char *command)
{
	printk(KERN_NOTICE "System restart\n");
	local_irq_disable();
	ifxmips_w32(ifxmips_r32(IFXMIPS_RCU_RST) | IFXMIPS_RCU_RST_ALL,
		IFXMIPS_RCU_RST);
	for(;;);
}

static void
ifxmips_machine_halt(void)
{
	printk(KERN_NOTICE "System halted.\n");
	local_irq_disable();
	for(;;);
}

static void
ifxmips_machine_power_off(void)
{
	printk(KERN_NOTICE "Please turn off the power now.\n");
	local_irq_disable();
	for(;;);
}

void __init
ifxmips_soc_setup(void)
{
	char *name = SYSTEM_DANUBE;
	ioport_resource.start = IOPORT_RESOURCE_START;
	ioport_resource.end = IOPORT_RESOURCE_END;
	iomem_resource.start = IOMEM_RESOURCE_START;
	iomem_resource.end = IOMEM_RESOURCE_END;

	_machine_restart = ifxmips_machine_restart;
	_machine_halt = ifxmips_machine_halt;
	pm_power_off = ifxmips_machine_power_off;

	chiprev = (ifxmips_r32(IFXMIPS_MPS_CHIPID) & 0x0FFFFFFF);

	switch (chiprev)
	{
	case SYSTEM_DANUBE_CHIPID1:
	case SYSTEM_DANUBE_CHIPID2:
		name = SYSTEM_DANUBE;
		break;

	case SYSTEM_TWINPASS_CHIPID:
		name = SYSTEM_TWINPASS;
		break;

	default:
		printk(KERN_ERR "This is not a danube chiprev : 0x%08X\n", chiprev);
		BUG();
		break;
	}
	snprintf(ifxmips_sys_type, IFXMIPS_SYS_TYPE_LEN - 1, "%s rev1.%d %dMhz",
		name, ifxmips_get_cpu_ver(),
		ifxmips_get_cpu_hz() / 1000000);
	ifxmips_sys_type[IFXMIPS_SYS_TYPE_LEN - 1] = '\0';
}