Haavard Skinnemoen | e71259e | 2008-04-30 14:19:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Atmel Corporation |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | #ifndef __ASM_AVR32_HMATRIX_COMMON_H__ |
| 23 | #define __ASM_AVR32_HMATRIX_COMMON_H__ |
| 24 | |
| 25 | /* HMATRIX register offsets */ |
| 26 | struct hmatrix_regs { |
| 27 | u32 MCFG[16]; |
| 28 | u32 SCFG[16]; |
| 29 | struct { |
| 30 | u32 A; |
| 31 | u32 B; |
| 32 | } PRS[16]; |
| 33 | u32 MRCR; |
| 34 | u32 __reserved[3]; |
| 35 | u32 SFR[16]; |
| 36 | }; |
| 37 | |
| 38 | /* Bitfields in MCFG */ |
| 39 | #define HMATRIX_ULBT_OFFSET 0 |
| 40 | #define HMATRIX_ULBT_SIZE 3 |
| 41 | |
| 42 | /* Bitfields in SCFG */ |
| 43 | #define HMATRIX_SLOT_CYCLE_OFFSET 0 |
| 44 | #define HMATRIX_SLOT_CYCLE_SIZE 8 |
| 45 | #define HMATRIX_DEFMSTR_TYPE_OFFSET 16 |
| 46 | #define HMATRIX_DEFMSTR_TYPE_SIZE 2 |
| 47 | #define HMATRIX_FIXED_DEFMSTR_OFFSET 18 |
| 48 | #define HMATRIX_FIXED_DEFMSTR_SIZE 4 |
| 49 | #define HMATRIX_ARBT_OFFSET 24 |
| 50 | #define HMATRIX_ARBT_SIZE 1 |
| 51 | |
| 52 | /* Bitfields in PRS.A */ |
| 53 | #define HMATRIX_M0PR_OFFSET 0 |
| 54 | #define HMATRIX_M0PR_SIZE 4 |
| 55 | #define HMATRIX_M1PR_OFFSET 4 |
| 56 | #define HMATRIX_M1PR_SIZE 4 |
| 57 | #define HMATRIX_M2PR_OFFSET 8 |
| 58 | #define HMATRIX_M2PR_SIZE 4 |
| 59 | #define HMATRIX_M3PR_OFFSET 12 |
| 60 | #define HMATRIX_M3PR_SIZE 4 |
| 61 | #define HMATRIX_M4PR_OFFSET 16 |
| 62 | #define HMATRIX_M4PR_SIZE 4 |
| 63 | #define HMATRIX_M5PR_OFFSET 20 |
| 64 | #define HMATRIX_M5PR_SIZE 4 |
| 65 | #define HMATRIX_M6PR_OFFSET 24 |
| 66 | #define HMATRIX_M6PR_SIZE 4 |
| 67 | #define HMATRIX_M7PR_OFFSET 28 |
| 68 | #define HMATRIX_M7PR_SIZE 4 |
| 69 | |
| 70 | /* Bitfields in PRS.B */ |
| 71 | #define HMATRIX_M8PR_OFFSET 0 |
| 72 | #define HMATRIX_M8PR_SIZE 4 |
| 73 | #define HMATRIX_M9PR_OFFSET 4 |
| 74 | #define HMATRIX_M9PR_SIZE 4 |
| 75 | #define HMATRIX_M10PR_OFFSET 8 |
| 76 | #define HMATRIX_M10PR_SIZE 4 |
| 77 | #define HMATRIX_M11PR_OFFSET 12 |
| 78 | #define HMATRIX_M11PR_SIZE 4 |
| 79 | #define HMATRIX_M12PR_OFFSET 16 |
| 80 | #define HMATRIX_M12PR_SIZE 4 |
| 81 | #define HMATRIX_M13PR_OFFSET 20 |
| 82 | #define HMATRIX_M13PR_SIZE 4 |
| 83 | #define HMATRIX_M14PR_OFFSET 24 |
| 84 | #define HMATRIX_M14PR_SIZE 4 |
| 85 | #define HMATRIX_M15PR_OFFSET 28 |
| 86 | #define HMATRIX_M15PR_SIZE 4 |
| 87 | |
| 88 | /* Constants for ULBT */ |
| 89 | #define HMATRIX_ULBT_INFINITE 0 |
| 90 | #define HMATRIX_ULBT_SINGLE 1 |
| 91 | #define HMATRIX_ULBT_FOUR_BEAT 2 |
| 92 | #define HMATRIX_ULBT_EIGHT_BEAT 3 |
| 93 | #define HMATRIX_ULBT_SIXTEEN_BEAT 4 |
| 94 | |
| 95 | /* Constants for DEFMSTR_TYPE */ |
| 96 | #define HMATRIX_DEFMSTR_TYPE_NO_DEFAULT 0 |
| 97 | #define HMATRIX_DEFMSTR_TYPE_LAST_DEFAULT 1 |
| 98 | #define HMATRIX_DEFMSTR_TYPE_FIXED_DEFAULT 2 |
| 99 | |
| 100 | /* Constants for ARBT */ |
| 101 | #define HMATRIX_ARBT_ROUND_ROBIN 0 |
| 102 | #define HMATRIX_ARBT_FIXED_PRIORITY 1 |
| 103 | |
| 104 | /* Bit manipulation macros */ |
| 105 | #define HMATRIX_BIT(name) \ |
| 106 | (1 << HMATRIX_##name##_OFFSET) |
| 107 | #define HMATRIX_BF(name,value) \ |
| 108 | (((value) & ((1 << HMATRIX_##name##_SIZE) - 1)) \ |
| 109 | << HMATRIX_##name##_OFFSET) |
| 110 | #define HMATRIX_BFEXT(name,value) \ |
| 111 | (((value) >> HMATRIX_##name##_OFFSET) \ |
| 112 | & ((1 << HMATRIX_##name##_SIZE) - 1)) |
| 113 | #define HMATRIX_BFINS(name,value,old) \ |
| 114 | (((old) & ~(((1 << HMATRIX_##name##_SIZE) - 1) \ |
| 115 | << HMATRIX_##name##_OFFSET)) \ |
| 116 | | HMATRIX_BF(name,value)) |
| 117 | |
| 118 | /* Register access macros */ |
| 119 | #define __hmatrix_reg(reg) \ |
Andreas Bießmann | 5807e79 | 2010-11-04 23:15:31 +0000 | [diff] [blame^] | 120 | (((volatile struct hmatrix_regs *)ATMEL_BASE_HMATRIX)->reg) |
Haavard Skinnemoen | e71259e | 2008-04-30 14:19:28 +0200 | [diff] [blame] | 121 | #define hmatrix_read(reg) \ |
| 122 | (__hmatrix_reg(reg)) |
| 123 | #define hmatrix_write(reg, value) \ |
| 124 | do { __hmatrix_reg(reg) = (value); } while (0) |
| 125 | |
| 126 | #define hmatrix_slave_read(slave, reg) \ |
| 127 | hmatrix_read(reg[HMATRIX_SLAVE_##slave]) |
| 128 | #define hmatrix_slave_write(slave, reg, value) \ |
| 129 | hmatrix_write(reg[HMATRIX_SLAVE_##slave], value) |
| 130 | |
| 131 | #endif /* __ASM_AVR32_HMATRIX_COMMON_H__ */ |