Haavard Skinnemoen | e71259e | 2008-04-30 14:19:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Atmel Corporation |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Haavard Skinnemoen | e71259e | 2008-04-30 14:19:28 +0200 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __ASM_AVR32_HMATRIX_COMMON_H__ |
| 7 | #define __ASM_AVR32_HMATRIX_COMMON_H__ |
| 8 | |
| 9 | /* HMATRIX register offsets */ |
| 10 | struct hmatrix_regs { |
| 11 | u32 MCFG[16]; |
| 12 | u32 SCFG[16]; |
| 13 | struct { |
| 14 | u32 A; |
| 15 | u32 B; |
| 16 | } PRS[16]; |
| 17 | u32 MRCR; |
| 18 | u32 __reserved[3]; |
| 19 | u32 SFR[16]; |
| 20 | }; |
| 21 | |
| 22 | /* Bitfields in MCFG */ |
| 23 | #define HMATRIX_ULBT_OFFSET 0 |
| 24 | #define HMATRIX_ULBT_SIZE 3 |
| 25 | |
| 26 | /* Bitfields in SCFG */ |
| 27 | #define HMATRIX_SLOT_CYCLE_OFFSET 0 |
| 28 | #define HMATRIX_SLOT_CYCLE_SIZE 8 |
| 29 | #define HMATRIX_DEFMSTR_TYPE_OFFSET 16 |
| 30 | #define HMATRIX_DEFMSTR_TYPE_SIZE 2 |
| 31 | #define HMATRIX_FIXED_DEFMSTR_OFFSET 18 |
| 32 | #define HMATRIX_FIXED_DEFMSTR_SIZE 4 |
| 33 | #define HMATRIX_ARBT_OFFSET 24 |
| 34 | #define HMATRIX_ARBT_SIZE 1 |
| 35 | |
| 36 | /* Bitfields in PRS.A */ |
| 37 | #define HMATRIX_M0PR_OFFSET 0 |
| 38 | #define HMATRIX_M0PR_SIZE 4 |
| 39 | #define HMATRIX_M1PR_OFFSET 4 |
| 40 | #define HMATRIX_M1PR_SIZE 4 |
| 41 | #define HMATRIX_M2PR_OFFSET 8 |
| 42 | #define HMATRIX_M2PR_SIZE 4 |
| 43 | #define HMATRIX_M3PR_OFFSET 12 |
| 44 | #define HMATRIX_M3PR_SIZE 4 |
| 45 | #define HMATRIX_M4PR_OFFSET 16 |
| 46 | #define HMATRIX_M4PR_SIZE 4 |
| 47 | #define HMATRIX_M5PR_OFFSET 20 |
| 48 | #define HMATRIX_M5PR_SIZE 4 |
| 49 | #define HMATRIX_M6PR_OFFSET 24 |
| 50 | #define HMATRIX_M6PR_SIZE 4 |
| 51 | #define HMATRIX_M7PR_OFFSET 28 |
| 52 | #define HMATRIX_M7PR_SIZE 4 |
| 53 | |
| 54 | /* Bitfields in PRS.B */ |
| 55 | #define HMATRIX_M8PR_OFFSET 0 |
| 56 | #define HMATRIX_M8PR_SIZE 4 |
| 57 | #define HMATRIX_M9PR_OFFSET 4 |
| 58 | #define HMATRIX_M9PR_SIZE 4 |
| 59 | #define HMATRIX_M10PR_OFFSET 8 |
| 60 | #define HMATRIX_M10PR_SIZE 4 |
| 61 | #define HMATRIX_M11PR_OFFSET 12 |
| 62 | #define HMATRIX_M11PR_SIZE 4 |
| 63 | #define HMATRIX_M12PR_OFFSET 16 |
| 64 | #define HMATRIX_M12PR_SIZE 4 |
| 65 | #define HMATRIX_M13PR_OFFSET 20 |
| 66 | #define HMATRIX_M13PR_SIZE 4 |
| 67 | #define HMATRIX_M14PR_OFFSET 24 |
| 68 | #define HMATRIX_M14PR_SIZE 4 |
| 69 | #define HMATRIX_M15PR_OFFSET 28 |
| 70 | #define HMATRIX_M15PR_SIZE 4 |
| 71 | |
| 72 | /* Constants for ULBT */ |
| 73 | #define HMATRIX_ULBT_INFINITE 0 |
| 74 | #define HMATRIX_ULBT_SINGLE 1 |
| 75 | #define HMATRIX_ULBT_FOUR_BEAT 2 |
| 76 | #define HMATRIX_ULBT_EIGHT_BEAT 3 |
| 77 | #define HMATRIX_ULBT_SIXTEEN_BEAT 4 |
| 78 | |
| 79 | /* Constants for DEFMSTR_TYPE */ |
| 80 | #define HMATRIX_DEFMSTR_TYPE_NO_DEFAULT 0 |
| 81 | #define HMATRIX_DEFMSTR_TYPE_LAST_DEFAULT 1 |
| 82 | #define HMATRIX_DEFMSTR_TYPE_FIXED_DEFAULT 2 |
| 83 | |
| 84 | /* Constants for ARBT */ |
| 85 | #define HMATRIX_ARBT_ROUND_ROBIN 0 |
| 86 | #define HMATRIX_ARBT_FIXED_PRIORITY 1 |
| 87 | |
| 88 | /* Bit manipulation macros */ |
| 89 | #define HMATRIX_BIT(name) \ |
| 90 | (1 << HMATRIX_##name##_OFFSET) |
| 91 | #define HMATRIX_BF(name,value) \ |
| 92 | (((value) & ((1 << HMATRIX_##name##_SIZE) - 1)) \ |
| 93 | << HMATRIX_##name##_OFFSET) |
| 94 | #define HMATRIX_BFEXT(name,value) \ |
| 95 | (((value) >> HMATRIX_##name##_OFFSET) \ |
| 96 | & ((1 << HMATRIX_##name##_SIZE) - 1)) |
| 97 | #define HMATRIX_BFINS(name,value,old) \ |
| 98 | (((old) & ~(((1 << HMATRIX_##name##_SIZE) - 1) \ |
| 99 | << HMATRIX_##name##_OFFSET)) \ |
| 100 | | HMATRIX_BF(name,value)) |
| 101 | |
| 102 | /* Register access macros */ |
| 103 | #define __hmatrix_reg(reg) \ |
Andreas Bießmann | 5807e79 | 2010-11-04 23:15:31 +0000 | [diff] [blame] | 104 | (((volatile struct hmatrix_regs *)ATMEL_BASE_HMATRIX)->reg) |
Haavard Skinnemoen | e71259e | 2008-04-30 14:19:28 +0200 | [diff] [blame] | 105 | #define hmatrix_read(reg) \ |
| 106 | (__hmatrix_reg(reg)) |
| 107 | #define hmatrix_write(reg, value) \ |
| 108 | do { __hmatrix_reg(reg) = (value); } while (0) |
| 109 | |
| 110 | #define hmatrix_slave_read(slave, reg) \ |
| 111 | hmatrix_read(reg[HMATRIX_SLAVE_##slave]) |
| 112 | #define hmatrix_slave_write(slave, reg, value) \ |
| 113 | hmatrix_write(reg[HMATRIX_SLAVE_##slave], value) |
| 114 | |
| 115 | #endif /* __ASM_AVR32_HMATRIX_COMMON_H__ */ |