aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/rb532/files/include/asm-mips/rc32434/rc32434.h
blob: 848fc86b3a04140350689788fc71b7b9a9286d90 (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 ***************************************************************************
 * Definitions for IDT RC323434 CPU.
 *
 ****************************************************************************
 * Kiran Rao
 * 
 * Original form
 ****************************************************************************
 * P. Sadik   Oct 08, 2003
 *
 * Started revision history
 * Made IDT_BUS_FREQ a kernel configuration parameter
 ****************************************************************************
 * P. Sadik   Oct 10, 2003
 *
 * Removed IDT_BUS_FREQ, since this parameter is no longer required. Instead
 * idt_cpu_freq is used everywhere
 ****************************************************************************
 * P. Sadik   Oct 20, 2003
 *
 * Removed RC32434_BASE_BAUD
 ****************************************************************************
*/
#ifndef _RC32434_H_
#define _RC32434_H_

#include <linux/autoconf.h>
#include <linux/delay.h>
#include <asm/io.h>

#define RC32434_REG_BASE   0x18000000

#define interrupt ((volatile INT_t ) INT0_VirtualAddress)
#define gpio	  ((volatile GPIO_t) GPIO0_VirtualAddress)


#define IDT_CLOCK_MULT 2
#define MIPS_CPU_TIMER_IRQ 7
/* Interrupt Controller */
#define IC_GROUP0_PEND     (RC32434_REG_BASE + 0x38000)
#define IC_GROUP0_MASK     (RC32434_REG_BASE + 0x38008)
#define IC_GROUP_OFFSET    0x0C

#define NUM_INTR_GROUPS    5
/* 16550 UARTs */

#define GROUP0_IRQ_BASE 8		/* GRP2 IRQ numbers start here */
#define GROUP1_IRQ_BASE (GROUP0_IRQ_BASE + 32) /* GRP3 IRQ numbers start here */
#define GROUP2_IRQ_BASE (GROUP1_IRQ_BASE + 32) /* GRP4 IRQ numbers start here */
#define GROUP3_IRQ_BASE (GROUP2_IRQ_BASE + 32)	/* GRP5 IRQ numbers start here */
#define GROUP4_IRQ_BASE (GROUP3_IRQ_BASE + 32)


#ifdef __MIPSEB__
#define RC32434_UART0_BASE (RC32434_REG_BASE + 0x58003)
#else
#define RC32434_UART0_BASE (RC32434_REG_BASE + 0x58000)
#endif

#define RC32434_UART0_IRQ  GROUP3_IRQ_BASE + 0
// #define EB434_UART1_IRQ    GROUP4_IRQ_BASE + 11

#define local_readl(addr) __raw_readl(addr)
#define local_writel(l,addr) __raw_writel(l,addr)

/* cpu pipeline flush */
static inline void rc32434_sync(void)
{
        __asm__ volatile ("sync");
}

static inline void rc32434_sync_udelay(int us)
{
        __asm__ volatile ("sync");
        udelay(us);
}

static inline void rc32434_sync_delay(int ms)
{
        __asm__ volatile ("sync");
        mdelay(ms);
}

/*
 * C access to CLZ and CLO instructions
 * (count leading zeroes/ones).
 */
static inline int rc32434_clz(unsigned long val)
{
	int ret;
        __asm__ volatile (
		".set\tnoreorder\n\t"
		".set\tnoat\n\t"
		".set\tmips32\n\t"
		"clz\t%0,%1\n\t"
                ".set\tmips0\n\t"
                ".set\tat\n\t"
                ".set\treorder"
                : "=r" (ret)
		: "r" (val));

	return ret;
}
static inline int rc32434_clo(unsigned long val)
{
	int ret;
        __asm__ volatile (
		".set\tnoreorder\n\t"
		".set\tnoat\n\t"
		".set\tmips32\n\t"
		"clo\t%0,%1\n\t"
                ".set\tmips0\n\t"
                ".set\tat\n\t"
                ".set\treorder"
                : "=r" (ret)
		: "r" (val));

	return ret;
}

#endif /* _RC32434_H_ */