1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef __PPC4XX_H__
25#define __PPC4XX_H__
26
27
28
29
30#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405EP) || \
31 defined(CONFIG_AP1000) || defined(CONFIG_ML2)
32#define CONFIG_SDRAM_PPC4xx_IBM_SDRAM
33#endif
34
35#if defined(CONFIG_440GP) || defined(CONFIG_440GX) || \
36 defined(CONFIG_440EP) || defined(CONFIG_440GR)
37#define CONFIG_SDRAM_PPC4xx_IBM_DDR
38#endif
39
40#if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
41#define CONFIG_SDRAM_PPC4xx_DENALI_DDR2
42#endif
43
44#if defined(CONFIG_405EX) || \
45 defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
46 defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
47 defined(CONFIG_460SX)
48#define CONFIG_SDRAM_PPC4xx_IBM_DDR2
49#endif
50
51#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
52 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
53 defined(CONFIG_405EZ) || defined(CONFIG_405EX) || \
54 defined(CONFIG_460EX) || defined(CONFIG_460GT)
55#define CONFIG_NAND_NDFC
56#endif
57
58
59#if defined(CONFIG_405EX) || \
60 defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
61 defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
62 defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
63 defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
64 defined(CONFIG_460SX)
65
66#define PLB_ARBITER_BASE 0x80
67
68#define plb0_revid (PLB_ARBITER_BASE + 0x00)
69#define plb0_acr (PLB_ARBITER_BASE + 0x01)
70#define plb0_acr_ppm_mask 0xF0000000
71#define plb0_acr_ppm_fixed 0x00000000
72#define plb0_acr_ppm_fair 0xD0000000
73#define plb0_acr_hbu_mask 0x08000000
74#define plb0_acr_hbu_disabled 0x00000000
75#define plb0_acr_hbu_enabled 0x08000000
76#define plb0_acr_rdp_mask 0x06000000
77#define plb0_acr_rdp_disabled 0x00000000
78#define plb0_acr_rdp_2deep 0x02000000
79#define plb0_acr_rdp_3deep 0x04000000
80#define plb0_acr_rdp_4deep 0x06000000
81#define plb0_acr_wrp_mask 0x01000000
82#define plb0_acr_wrp_disabled 0x00000000
83#define plb0_acr_wrp_2deep 0x01000000
84
85#define plb0_besrl (PLB_ARBITER_BASE + 0x02)
86#define plb0_besrh (PLB_ARBITER_BASE + 0x03)
87#define plb0_bearl (PLB_ARBITER_BASE + 0x04)
88#define plb0_bearh (PLB_ARBITER_BASE + 0x05)
89#define plb0_ccr (PLB_ARBITER_BASE + 0x08)
90
91#define plb1_acr (PLB_ARBITER_BASE + 0x09)
92#define plb1_acr_ppm_mask 0xF0000000
93#define plb1_acr_ppm_fixed 0x00000000
94#define plb1_acr_ppm_fair 0xD0000000
95#define plb1_acr_hbu_mask 0x08000000
96#define plb1_acr_hbu_disabled 0x00000000
97#define plb1_acr_hbu_enabled 0x08000000
98#define plb1_acr_rdp_mask 0x06000000
99#define plb1_acr_rdp_disabled 0x00000000
100#define plb1_acr_rdp_2deep 0x02000000
101#define plb1_acr_rdp_3deep 0x04000000
102#define plb1_acr_rdp_4deep 0x06000000
103#define plb1_acr_wrp_mask 0x01000000
104#define plb1_acr_wrp_disabled 0x00000000
105#define plb1_acr_wrp_2deep 0x01000000
106
107#define plb1_besrl (PLB_ARBITER_BASE + 0x0A)
108#define plb1_besrh (PLB_ARBITER_BASE + 0x0B)
109#define plb1_bearl (PLB_ARBITER_BASE + 0x0C)
110#define plb1_bearh (PLB_ARBITER_BASE + 0x0D)
111
112#endif
113
114#if defined(CONFIG_440)
115
116
117
118
119#define CONFIG_SYS_64BIT_VSPRINTF
120#define CONFIG_SYS_64BIT_STRTOUL
121#include <ppc440.h>
122#else
123#include <ppc405.h>
124#endif
125
126#include <asm/ppc4xx-sdram.h>
127#include <asm/ppc4xx-ebc.h>
128#if !defined(CONFIG_XILINX_440)
129#include <asm/ppc4xx-uic.h>
130#endif
131
132
133
134
135#define PPC_REG_BITS 32
136#define PPC_REG_VAL(bit, value) ((value) << ((PPC_REG_BITS - 1) - (bit)))
137
138
139
140
141#ifndef __ASSEMBLY__
142#define static_cast(type, val) (type)(val)
143#else
144#define static_cast(type, val) (val)
145#endif
146
147
148
149
150
151#define EXC_OFF_SYS_RESET 0x0100
152#define _START_OFFSET (EXC_OFF_SYS_RESET + 0x2000)
153
154#define RESET_VECTOR 0xfffffffc
155#define CACHELINE_MASK (CONFIG_SYS_CACHELINE_SIZE - 1)
156
157
158#define CPR0_DCR_BASE 0x0C
159#define cprcfga (CPR0_DCR_BASE+0x0)
160#define cprcfgd (CPR0_DCR_BASE+0x1)
161
162#define SDR_DCR_BASE 0x0E
163#define sdrcfga (SDR_DCR_BASE+0x0)
164#define sdrcfgd (SDR_DCR_BASE+0x1)
165
166#define SDRAM_DCR_BASE 0x10
167#define memcfga (SDRAM_DCR_BASE+0x0)
168#define memcfgd (SDRAM_DCR_BASE+0x1)
169
170#define EBC_DCR_BASE 0x12
171#define ebccfga (EBC_DCR_BASE+0x0)
172#define ebccfgd (EBC_DCR_BASE+0x1)
173
174
175
176
177#define mtcpr(reg, d) do { mtdcr(cprcfga,reg);mtdcr(cprcfgd,d); } while (0)
178#define mfcpr(reg, d) do { mtdcr(cprcfga,reg);d = mfdcr(cprcfgd); } while (0)
179
180#define mtebc(reg, d) do { mtdcr(ebccfga,reg);mtdcr(ebccfgd,d); } while (0)
181#define mfebc(reg, d) do { mtdcr(ebccfga,reg);d = mfdcr(ebccfgd); } while (0)
182
183#define mtsdram(reg, d) do { mtdcr(memcfga,reg);mtdcr(memcfgd,d); } while (0)
184#define mfsdram(reg, d) do { mtdcr(memcfga,reg);d = mfdcr(memcfgd); } while (0)
185
186#define mtsdr(reg, d) do { mtdcr(sdrcfga,reg);mtdcr(sdrcfgd,d); } while (0)
187#define mfsdr(reg, d) do { mtdcr(sdrcfga,reg);d = mfdcr(sdrcfgd); } while (0)
188
189#ifndef __ASSEMBLY__
190
191typedef struct
192{
193 unsigned long freqDDR;
194 unsigned long freqEBC;
195 unsigned long freqOPB;
196 unsigned long freqPCI;
197 unsigned long freqPLB;
198 unsigned long freqTmrClk;
199 unsigned long freqUART;
200 unsigned long freqProcessor;
201 unsigned long freqVCOHz;
202 unsigned long freqVCOMhz;
203 unsigned long pciClkSync;
204 unsigned long pciIntArbEn;
205 unsigned long pllExtBusDiv;
206 unsigned long pllFbkDiv;
207 unsigned long pllFwdDiv;
208 unsigned long pllFwdDivA;
209 unsigned long pllFwdDivB;
210 unsigned long pllOpbDiv;
211 unsigned long pllPciDiv;
212 unsigned long pllPlbDiv;
213} PPC4xx_SYS_INFO;
214
215static inline u32 get_mcsr(void)
216{
217 u32 val;
218
219 asm volatile("mfspr %0, 0x23c" : "=r" (val) :);
220 return val;
221}
222
223static inline void set_mcsr(u32 val)
224{
225 asm volatile("mtspr 0x23c, %0" : "=r" (val) :);
226}
227
228#endif
229
230
231#define NA_OR_UNKNOWN_CPU -1
232
233#endif
234