aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/tx4938/common/setup.c
blob: ef59a5cffc691e9001c1a9dafb7676189ecca214 (plain) (blame)
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
/*
 * linux/arch/mips/tx4938/common/setup.c
 *
 * common tx4938 setup routines
 *
 * 2003-2005 (c) MontaVista Software, Inc. This file is licensed under the
 * terms of the GNU General Public License version 2. This program is
 * licensed "as is" without any warranty of any kind, whether express
 * or implied.
 *
 * Support for TX4938 in 2.6 - Manish Lachwani (mlachwani@mvista.com)
 */

#include <linux/errno.h>
#include <linux/init.h>
#include <linux/kernel_stat.h>
#include <linux/module.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/timex.h>
#include <linux/slab.h>
#include <linux/random.h>
#include <linux/irq.h>
#include <asm/bitops.h>
#include <asm/bootinfo.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/mipsregs.h>
#include <asm/system.h>
#include <asm/time.h>
#include <asm/time.h>
#include <asm/tx4938/rbtx4938.h>

extern void toshiba_rbtx4938_setup(void);
extern void rbtx4938_time_init(void);

void __init tx4938_setup(void);
void __init tx4938_time_init(void);
void __init tx4938_timer_setup(struct irqaction *irq);
void dump_cp0(char *key);

void (*__wbflush) (void);

static void
tx4938_write_buffer_flush(void)
{
	mmiowb();

	__asm__ __volatile__(
		".set	push\n\t"
		".set	noreorder\n\t"
		"lw	$0,%0\n\t"
		"nop\n\t"
		".set	pop"
		: /* no output */
		: "m" (*(int *)KSEG1)
		: "memory");
}

void __init
plat_mem_setup(void)
{
	board_time_init = tx4938_time_init;
	board_timer_setup = tx4938_timer_setup;
	__wbflush = tx4938_write_buffer_flush;
	toshiba_rbtx4938_setup();
}

void __init
tx4938_time_init(void)
{
	rbtx4938_time_init();
}

void __init
tx4938_timer_setup(struct irqaction *irq)
{
	u32 count;
	u32 c1;
	u32 c2;

	setup_irq(TX4938_IRQ_CPU_TIMER, irq);

	c1 = read_c0_count();
	count = c1 + (mips_hpt_frequency / HZ);
	write_c0_compare(count);
	c2 = read_c0_count();
}