summaryrefslogtreecommitdiffstats
path: root/arch/avr32/include/asm/hmatrix-common.h
blob: 9a86fe4baa09840c5ed8f666d20294b60930bda2 (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
123
124
125
126
127
128
129
130
131
/*
 * Copyright (C) 2008 Atmel Corporation
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */
#ifndef __ASM_AVR32_HMATRIX_COMMON_H__
#define __ASM_AVR32_HMATRIX_COMMON_H__

/* HMATRIX register offsets */
struct hmatrix_regs {
	u32	MCFG[16];
	u32	SCFG[16];
	struct {
		u32	A;
		u32	B;
	} PRS[16];
	u32	MRCR;
	u32	__reserved[3];
	u32	SFR[16];
};

/* Bitfields in MCFG */
#define HMATRIX_ULBT_OFFSET			0
#define HMATRIX_ULBT_SIZE			3

/* Bitfields in SCFG */
#define HMATRIX_SLOT_CYCLE_OFFSET		0
#define HMATRIX_SLOT_CYCLE_SIZE			8
#define HMATRIX_DEFMSTR_TYPE_OFFSET		16
#define HMATRIX_DEFMSTR_TYPE_SIZE		2
#define HMATRIX_FIXED_DEFMSTR_OFFSET		18
#define HMATRIX_FIXED_DEFMSTR_SIZE		4
#define HMATRIX_ARBT_OFFSET			24
#define HMATRIX_ARBT_SIZE			1

/* Bitfields in PRS.A */
#define HMATRIX_M0PR_OFFSET			0
#define HMATRIX_M0PR_SIZE			4
#define HMATRIX_M1PR_OFFSET			4
#define HMATRIX_M1PR_SIZE			4
#define HMATRIX_M2PR_OFFSET			8
#define HMATRIX_M2PR_SIZE			4
#define HMATRIX_M3PR_OFFSET			12
#define HMATRIX_M3PR_SIZE			4
#define HMATRIX_M4PR_OFFSET			16
#define HMATRIX_M4PR_SIZE			4
#define HMATRIX_M5PR_OFFSET			20
#define HMATRIX_M5PR_SIZE			4
#define HMATRIX_M6PR_OFFSET			24
#define HMATRIX_M6PR_SIZE			4
#define HMATRIX_M7PR_OFFSET			28
#define HMATRIX_M7PR_SIZE			4

/* Bitfields in PRS.B */
#define HMATRIX_M8PR_OFFSET			0
#define HMATRIX_M8PR_SIZE			4
#define HMATRIX_M9PR_OFFSET			4
#define HMATRIX_M9PR_SIZE			4
#define HMATRIX_M10PR_OFFSET			8
#define HMATRIX_M10PR_SIZE			4
#define HMATRIX_M11PR_OFFSET			12
#define HMATRIX_M11PR_SIZE			4
#define HMATRIX_M12PR_OFFSET			16
#define HMATRIX_M12PR_SIZE			4
#define HMATRIX_M13PR_OFFSET			20
#define HMATRIX_M13PR_SIZE			4
#define HMATRIX_M14PR_OFFSET			24
#define HMATRIX_M14PR_SIZE			4
#define HMATRIX_M15PR_OFFSET			28
#define HMATRIX_M15PR_SIZE			4

/* Constants for ULBT */
#define HMATRIX_ULBT_INFINITE			0
#define HMATRIX_ULBT_SINGLE			1
#define HMATRIX_ULBT_FOUR_BEAT			2
#define HMATRIX_ULBT_EIGHT_BEAT			3
#define HMATRIX_ULBT_SIXTEEN_BEAT		4

/* Constants for DEFMSTR_TYPE */
#define HMATRIX_DEFMSTR_TYPE_NO_DEFAULT		0
#define HMATRIX_DEFMSTR_TYPE_LAST_DEFAULT	1
#define HMATRIX_DEFMSTR_TYPE_FIXED_DEFAULT	2

/* Constants for ARBT */
#define HMATRIX_ARBT_ROUND_ROBIN		0
#define HMATRIX_ARBT_FIXED_PRIORITY		1

/* Bit manipulation macros */
#define HMATRIX_BIT(name)					\
	(1 << HMATRIX_##name##_OFFSET)
#define HMATRIX_BF(name,value)					\
	(((value) & ((1 << HMATRIX_##name##_SIZE) - 1))		\
	 << HMATRIX_##name##_OFFSET)
#define HMATRIX_BFEXT(name,value)				\
	(((value) >> HMATRIX_##name##_OFFSET)			\
	 & ((1 << HMATRIX_##name##_SIZE) - 1))
#define HMATRIX_BFINS(name,value,old)				\
	(((old) & ~(((1 << HMATRIX_##name##_SIZE) - 1)		\
		    << HMATRIX_##name##_OFFSET))		\
	 | HMATRIX_BF(name,value))

/* Register access macros */
#define __hmatrix_reg(reg)					\
	(((volatile struct hmatrix_regs *)ATMEL_BASE_HMATRIX)->reg)
#define hmatrix_read(reg)					\
	(__hmatrix_reg(reg))
#define hmatrix_write(reg, value)				\
	do { __hmatrix_reg(reg) = (value); } while (0)

#define hmatrix_slave_read(slave, reg)				\
	hmatrix_read(reg[HMATRIX_SLAVE_##slave])
#define hmatrix_slave_write(slave, reg, value)			\
	hmatrix_write(reg[HMATRIX_SLAVE_##slave], value)

#endif /* __ASM_AVR32_HMATRIX_COMMON_H__ */
OpenPOWER on IntegriCloud