summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/Drivers/PL301Axi/PL301Axi.c
blob: 7241f5cef228e9815e728526b55862e48d77c7f1 (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
/** @file
*
*  Copyright (c) 2011, ARM Limited. All rights reserved.
*  
*  This program and the accompanying materials                          
*  are licensed and made available under the terms and conditions of the BSD License         
*  which accompanies this distribution.  The full text of the license may be found at        
*  http://opensource.org/licenses/bsd-license.php                                            
*
*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
*
**/

#include <Library/IoLib.h>
#include <Library/DebugLib.h>

#define PL301_QOS_TIDEMARK_MI_0                  0x400
#define PL301_QOS_ACCESSCONTROL_MI_0             0x404

#define PL301_QOS_TIDEMARK_MI_1                  0x420
#define PL301_QOS_ACCESSCONTROL_MI_1             0x424

#define PL301_QOS_TIDEMARK_MI_2                  0x440
#define PL301_QOS_ACCESSCONTROL_MI_2             0x444

#define PL301_AR_ARB_MI_0                        0x408
#define PL301_AW_ARB_MI_0                        0x40C

#define PL301_AR_ARB_MI_1                        0x428
#define PL301_AW_ARB_MI_1                        0x42C

#define PL301_AR_ARB_MI_2                        0x448
#define PL301_AW_ARB_MI_2                        0x44C

#define PL301_MI_1_OFFSET                        0x20
#define PL301_MI_2_OFFSET                        0x40
#define PL301_MI_3_OFFSET                        0x60
#define PL301_MI_4_OFFSET                        0x80
#define PL301_MI_5_OFFSET                        0xa0

#define V2P_CA9_FAXI_MI0_TIDEMARK_VAL            0x6
#define V2P_CA9_FAXI_MI0_ACCESSCNTRL_VAL         0x1

#define V2P_CA9_FAXI_MI1_TIDEMARK_VAL            0x6
#define V2P_CA9_FAXI_MI1_ACCESSCNTRL_VAL         0x1

#define V2P_CA9_FAXI_MI2_TIDEMARK_VAL            0x6
#define V2P_CA9_FAXI_MI2_ACCESSCNTRL_VAL         0x1


#define FAxiWriteReg(reg,val)                    MmioWrite32(FAxiBase + reg, val)
#define FAxiReadReg(reg)                         MmioRead32(FAxiBase + reg)

// IN FAxiBase
// Initialize PL301 Dynamic Memory Controller
VOID PL301AxiInit(UINTN FAxiBase) {
    // Configure Tidemark Register for Master Port 0 (MI 0)
    FAxiWriteReg(PL301_QOS_TIDEMARK_MI_0, V2P_CA9_FAXI_MI0_TIDEMARK_VAL);

    // Configure the Access Control Register (MI 0)
    FAxiWriteReg(PL301_QOS_ACCESSCONTROL_MI_0, V2P_CA9_FAXI_MI0_ACCESSCNTRL_VAL);

    // MP0 
    // Set priority for Read
    FAxiWriteReg(PL301_AR_ARB_MI_0, 0x00000100);
    FAxiWriteReg(PL301_AR_ARB_MI_0, 0x01000200);
    FAxiWriteReg(PL301_AR_ARB_MI_0, 0x02000200);
    FAxiWriteReg(PL301_AR_ARB_MI_0, 0x03000200);
    FAxiWriteReg(PL301_AR_ARB_MI_0, 0x04000200);
  
    // Set priority for Write
    FAxiWriteReg(PL301_AW_ARB_MI_0, 0x00000100);
    FAxiWriteReg(PL301_AW_ARB_MI_0, 0x01000200);
    FAxiWriteReg(PL301_AW_ARB_MI_0, 0x02000200);
    FAxiWriteReg(PL301_AW_ARB_MI_0, 0x03000200);
    FAxiWriteReg(PL301_AW_ARB_MI_0, 0x04000200);

    // MP1
    // Set priority for Read
    FAxiWriteReg(PL301_AR_ARB_MI_1, 0x00000100);
    FAxiWriteReg(PL301_AR_ARB_MI_1, 0x01000200);
    FAxiWriteReg(PL301_AR_ARB_MI_1, 0x02000200);
    FAxiWriteReg(PL301_AR_ARB_MI_1, 0x03000200);
    FAxiWriteReg(PL301_AR_ARB_MI_1, 0x04000200);

    // Set priority for Write
    FAxiWriteReg(PL301_AW_ARB_MI_1, 0x00000100);
    FAxiWriteReg(PL301_AW_ARB_MI_1, 0x01000200);
    FAxiWriteReg(PL301_AW_ARB_MI_1, 0x02000200);
    FAxiWriteReg(PL301_AW_ARB_MI_1, 0x03000200);
    FAxiWriteReg(PL301_AW_ARB_MI_1, 0x04000200);

    // MP2
    // Set priority for Read
    FAxiWriteReg(PL301_AR_ARB_MI_2, 0x00000100);
    FAxiWriteReg(PL301_AR_ARB_MI_2, 0x01000100);
    FAxiWriteReg(PL301_AR_ARB_MI_2, 0x02000100);
    FAxiWriteReg(PL301_AR_ARB_MI_2, 0x03000100);
    FAxiWriteReg(PL301_AR_ARB_MI_2, 0x04000100);
  
    // Set priority for Write
    FAxiWriteReg(PL301_AW_ARB_MI_2, 0x00000100);
    FAxiWriteReg(PL301_AW_ARB_MI_2, 0x01000200);
    FAxiWriteReg(PL301_AW_ARB_MI_2, 0x02000200);
    FAxiWriteReg(PL301_AW_ARB_MI_2, 0x03000200);
    FAxiWriteReg(PL301_AW_ARB_MI_2, 0x04000200);
}