Skip to content

Commit 11f46a5

Browse files
dgarskedanielinux
authored andcommitted
Further fixes and improvements with NXP T2080 regression testing. Added required LAW's to startup assembly. Moved LAW definitions to header. Move isr_empty so other boot functions go in the boot section.
1 parent 63766c2 commit 11f46a5

5 files changed

Lines changed: 343 additions & 209 deletions

File tree

hal/nxp_p1021.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -199,51 +199,6 @@ static int test_tpm(void);
199199
#define UART_LSR_TEMT (0x40) /* Transmitter empty */
200200
#define UART_LSR_THRE (0x20) /* Transmitter holding register empty */
201201

202-
203-
/* P1021 LAW - Local Access Window (Memory Map) - RM 2.4 */
204-
#define LAWBAR_BASE(n) (CCSRBAR + 0xC08 + (n * 0x20))
205-
#define LAWBAR(n) ((volatile uint32_t*)(LAWBAR_BASE(n) + 0x0))
206-
#define LAWAR(n) ((volatile uint32_t*)(LAWBAR_BASE(n) + 0x8))
207-
208-
#define LAWAR_ENABLE (1<<31)
209-
#define LAWAR_TRGT_ID(id) (id<<20)
210-
211-
/* P1021 Global Source/Target ID Assignments - RM Table 2-7 */
212-
enum law_target_id {
213-
LAW_TRGT_PCIE2 = 0x01,
214-
LAW_TRGT_PCIE1 = 0x02,
215-
LAW_TRGT_ELBC = 0x4, /* eLBC (Enhanced Local Bus Controller) */
216-
LAW_TRGT_DDR = 0xF, /* DDR Memory Controller */
217-
};
218-
219-
/* P1021 2.4.2 - size is equal to 2^(enum + 1) */
220-
enum law_sizes {
221-
LAW_SIZE_4KB = 0x0B,
222-
LAW_SIZE_8KB,
223-
LAW_SIZE_16KB,
224-
LAW_SIZE_32KB,
225-
LAW_SIZE_64KB,
226-
LAW_SIZE_128KB, /* 0x10 */
227-
LAW_SIZE_256KB,
228-
LAW_SIZE_512KB,
229-
LAW_SIZE_1MB,
230-
LAW_SIZE_2MB,
231-
LAW_SIZE_4MB,
232-
LAW_SIZE_8MB,
233-
LAW_SIZE_16MB,
234-
LAW_SIZE_32MB,
235-
LAW_SIZE_64MB,
236-
LAW_SIZE_128MB,
237-
LAW_SIZE_256MB, /* 0x1B */
238-
LAW_SIZE_512MB,
239-
LAW_SIZE_1GB,
240-
LAW_SIZE_2GB,
241-
LAW_SIZE_4GB,
242-
LAW_SIZE_8GB, /* 0x20 */
243-
LAW_SIZE_16GB,
244-
LAW_SIZE_32GB,
245-
};
246-
247202
/* P1021 eLBC (Enhanced Local Bus Controller) - RM 12.3 */
248203
#define ELBC_BASE (CCSRBAR + 0x5000)
249204
#define ELBC_MAX_BANKS 8

hal/nxp_ppc.h

Lines changed: 182 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
#ifdef PLATFORM_nxp_p1021
2626
/* NXP P1021 */
2727
#define CPU_NUMCORES 2
28+
#define CORE_E500
29+
2830
#define CCSRBAR_DEF (0xFF700000) /* P1021RM 4.3 default base */
2931
#define CCSRBAR_SIZE BOOKE_PAGESZ_1M
30-
#define MMU_V1
3132

3233
#define ENABLE_L1_CACHE
3334

@@ -58,46 +59,74 @@
5859
#elif defined(PLATFORM_nxp_t2080)
5960
/* NXP T0280 */
6061
#define CPU_NUMCORES 4
61-
#define CCSRBAR_DEF (0xFE000000) /* T2080RM 4.3.1 default base */
62+
#define CORE_E6500
63+
64+
#define CCSRBAR_DEF (0xFE000000) /* T2080RM 4.3.1 default base - 0xFF000000 */
6265
#define CCSRBAR_SIZE BOOKE_PAGESZ_16M
63-
#define MMU_V2
66+
67+
/* relocate to 64-bit 0xE_ */
68+
//#define CCSRBAR_PHYS_HIGH 0xE
69+
//#define CCSRBAR_PHYS (CCSRBAR_PHYS_HIGH + CCSRBAR_DEF)
70+
6471
#define ENABLE_L1_CACHE
6572
#define ENABLE_L2_CACHE
66-
#define L2SRAM_ADDR (0xFEC20000) /* L2 as SRAM */
73+
#define L2SRAM_ADDR (0xF8F80000) /* L2 as SRAM */
6774
#define L2SRAM_SIZE (256 * 1024)
6875
#define ENABLE_INTERRUPTS
6976

7077
#define ENABLE_DDR
7178

72-
/* This flash mapping window is automatically enabled
73-
* T2080RM: 4.3.3 Boot Space Translation:
74-
* default boot window (8 MB at 0x0_FF80_0000 to 0x0_FFFF_FFFF)
75-
*/
76-
#define FLASH_BASE_ADDR 0xEF800000
79+
#define FLASH_BASE_ADDR 0xE8000000
80+
#define FLASH_BASE_PHYS_HIGH 0x0
7781

82+
#define USE_LONG_JUMP
7883
#else
79-
#error Please define MMU version and CCSRBAR for platform
84+
#error Please define platform PowerPC core version and CCSRBAR
8085
#endif
8186

87+
88+
8289
/* boot address */
90+
#ifndef BOOT_ROM_ADDR
8391
#define BOOT_ROM_ADDR 0xFFFFF000
92+
#endif
93+
#ifndef BOOT_ROM_SIZE
8494
#define BOOT_ROM_SIZE (4*1024)
95+
#endif
8596

97+
/* reset vector */
8698
#define RESET_VECTOR (BOOT_ROM_ADDR + (BOOT_ROM_SIZE - 4))
8799

100+
/* CCSRBAR */
88101
#ifndef CCSRBAR_DEF
89102
#define CCSRBAR_DEF 0xFE000000
90103
#endif
91104
#ifndef CCSRBAR
92105
#define CCSRBAR CCSRBAR_DEF
93106
#endif
107+
#ifndef CCSRBAR_PHYS
108+
#define CCSRBAR_PHYS CCSRBAR
109+
#endif
110+
#ifndef CCSRBAR_PHYS_HIGH
111+
#define CCSRBAR_PHYS_HIGH 0
112+
#endif
94113

114+
/* DDR */
95115
#ifndef DDR_ADDRESS
96-
#define DDR_ADDRESS 0x00000000
116+
#define DDR_ADDRESS 0x00000000
117+
#endif
118+
119+
/* L1 */
120+
#ifndef L1_CACHE_ADDR
121+
#define L1_CACHE_ADDR 0xFFD00000
122+
#endif
123+
#ifndef L1_CACHE_SZ
124+
#define L1_CACHE_SZ (32 * 1024)
97125
#endif
98126

99-
#ifdef MMU_V1
100-
/* MMU V1 - e500 */
127+
128+
#ifdef CORE_E500
129+
/* PowerPC e500 */
101130
/* EREF: 7.5.3.2 - TLB Entry Page Size */
102131
#define BOOKE_PAGESZ_4K 1
103132
#define BOOKE_PAGESZ_16K 2
@@ -116,8 +145,53 @@
116145

117146
#define L1_CACHE_LINE_SHIFT 5 /* 32 bytes per L1 cache line */
118147

119-
#else
120-
/* MMU V2 - e6500 */
148+
/* P1021 LAW - Local Access Window (Memory Map) - RM 2.4 */
149+
#define LAWBAR_BASE(n) (0xC08 + (n * 0x20))
150+
#define LAWBAR(n) ((volatile uint32_t*)(CCSRBAR + LAWBAR_BASE(n) + 0x0))
151+
#define LAWAR(n) ((volatile uint32_t*)(CCSRBAR + LAWBAR_BASE(n) + 0x8))
152+
153+
#define LAWAR_ENABLE (1<<31)
154+
#define LAWAR_TRGT_ID(id) (id<<20)
155+
156+
/* P1021 Global Source/Target ID Assignments - RM Table 2-7 */
157+
#define LAW_TRGT_PCIE2 0x01
158+
#define LAW_TRGT_PCIE1 0x02
159+
#define LAW_TRGT_ELBC 0x04 /* eLBC (Enhanced Local Bus Controller) */
160+
#define LAW_TRGT_DDR 0x0F /* DDR Memory Controller */
161+
162+
/* P1021 2.4.2 - size is equal to 2^(enum + 1) */
163+
#define LAW_SIZE_4KB 0x0B
164+
#define LAW_SIZE_8KB 0x0C
165+
#define LAW_SIZE_16KB 0x0D
166+
#define LAW_SIZE_32KB 0x0E
167+
#define LAW_SIZE_64KB 0x0F
168+
#define LAW_SIZE_128KB 0x10
169+
#define LAW_SIZE_256KB 0x11
170+
#define LAW_SIZE_512KB 0x12
171+
#define LAW_SIZE_1MB 0x13
172+
#define LAW_SIZE_2MB 0x14
173+
#define LAW_SIZE_4MB 0x15
174+
#define LAW_SIZE_8MB 0x16
175+
#define LAW_SIZE_16MB 0x17
176+
#define LAW_SIZE_32MB 0x18
177+
#define LAW_SIZE_64MB 0x19
178+
#define LAW_SIZE_128MB 0x1A
179+
#define LAW_SIZE_256MB 0x1B
180+
#define LAW_SIZE_512MB 0x1C
181+
#define LAW_SIZE_1GB 0x1D
182+
#define LAW_SIZE_2GB 0x1E
183+
#define LAW_SIZE_4GB 0x1F
184+
#define LAW_SIZE_8GB 0x20
185+
#define LAW_SIZE_16GB 0x21
186+
#define LAW_SIZE_32GB 0x22
187+
188+
189+
#elif defined(CORE_E6500)
190+
/* PowerPC e6500 */
191+
192+
/* CoreNet on-chip interface between the core cluster and rest of SoC */
193+
#define USE_CORENET_INTERFACE
194+
121195
/* EREF 2.0: 6.5.3.2 - TLB Entry Page Size */
122196
#define BOOKE_PAGESZ_4K 2
123197
#define BOOKE_PAGESZ_8K 3
@@ -144,24 +218,68 @@
144218
#define MAS1_TSIZE_MASK 0x00000F80
145219
#define MAS1_TSIZE(x) (((x) << 7) & MAS1_TSIZE_MASK)
146220

147-
#define L1_CACHE_LINE_SHIFT 4 /* 64 bytes per L1 cache line */
148-
#endif /* MMU V1/V2 */
221+
#define L1_CACHE_LINE_SHIFT 6 /* 64 bytes per L1 cache line */
149222

150-
#ifndef L1_CACHE_ADDR
151-
#define L1_CACHE_ADDR 0xFFD00000
152-
#endif
153-
#ifndef L1_CACHE_SZ
154-
#define L1_CACHE_SZ (32 * 1024)
155-
#endif
223+
/* CoreNet Platform Cache Base */
224+
#define CPC_BASE (CCSRBAR + 0x10000)
156225

157-
#ifndef L1_CACHE_LINE_SIZE
158-
#define L1_CACHE_LINE_SIZE (1 << L1_CACHE_LINE_SHIFT)
226+
/* T2080 LAW - Local Access Window (Memory Map) - RM 2.4 */
227+
#define LAWBAR_BASE(n) (0xC00 + (n * 0x10))
228+
#define LAWBARH(n) *((volatile uint32_t*)(CCSRBAR + LAWBAR_BASE(n) + 0x0))
229+
#define LAWBARL(n) *((volatile uint32_t*)(CCSRBAR + LAWBAR_BASE(n) + 0x4))
230+
#define LAWAR(n) *((volatile uint32_t*)(CCSRBAR + LAWBAR_BASE(n) + 0x8))
231+
232+
#define LAWAR_ENABLE (1<<31)
233+
#define LAWAR_TRGT_ID(id) (id<<20)
234+
235+
/* T2080 Global Source/Target ID Assignments - RM Table 2-1 */
236+
#define LAW_TRGT_DDR_1 0x10
237+
#define LAW_TRGT_BMAN 0x18 /* Buffer Manager (BMan) (control) */
238+
#define LAW_TRGT_CORENET 0x1E
239+
#define LAW_TRGT_IFC 0x1F /* Integrated Flash Controller */
240+
241+
/* T2080 2.4.3 - size is equal to 2^(enum + 1) */
242+
#define LAW_SIZE_4KB 0x0B
243+
#define LAW_SIZE_8KB 0x0C
244+
#define LAW_SIZE_16KB 0x0D
245+
#define LAW_SIZE_32KB 0x0E
246+
#define LAW_SIZE_64KB 0x0F
247+
#define LAW_SIZE_128KB 0x10
248+
#define LAW_SIZE_256KB 0x11
249+
#define LAW_SIZE_512KB 0x12
250+
#define LAW_SIZE_1MB 0x13
251+
#define LAW_SIZE_2MB 0x14
252+
#define LAW_SIZE_4MB 0x15
253+
#define LAW_SIZE_8MB 0x16
254+
#define LAW_SIZE_16MB 0x17
255+
#define LAW_SIZE_32MB 0x18
256+
#define LAW_SIZE_64MB 0x19
257+
#define LAW_SIZE_128MB 0x1A
258+
#define LAW_SIZE_256MB 0x1B
259+
#define LAW_SIZE_512MB 0x1C
260+
#define LAW_SIZE_1GB 0x1D
261+
#define LAW_SIZE_2GB 0x1E
262+
#define LAW_SIZE_4GB 0x1F
263+
#define LAW_SIZE_8GB 0x20
264+
#define LAW_SIZE_16GB 0x21
265+
#define LAW_SIZE_32GB 0x22
266+
#define LAW_SIZE_64GB 0x23
267+
#define LAW_SIZE_128GB 0x24
268+
#define LAW_SIZE_256GB 0x25
269+
#define LAW_SIZE_512GB 0x26
270+
#define LAW_SIZE_1TB 0x27
159271

160-
#define CPC_BASE (CCSRBAR + 0x10000)
272+
#endif
273+
274+
#ifndef L1_CACHE_LINE_SIZE
275+
#define L1_CACHE_LINE_SIZE (1 << L1_CACHE_LINE_SHIFT)
161276
#endif
162277

163278

164-
/* MMU Assist Registers */
279+
/* MMU Assist Registers
280+
* E6500RM 2.13.10
281+
* E500CORERM 2.12.5
282+
*/
165283
#define MAS0 0x270
166284
#define MAS1 0x271
167285
#define MAS2 0x272
@@ -170,6 +288,43 @@
170288
#define MAS7 0x3B0
171289
#define MMUCSR0 0x3F4 /* MMU control and status register 0 */
172290

291+
#define MAS0_TLBSEL_MSK 0x30000000
292+
#define MAS0_TLBSEL(x) (((x) << 28) & MAS0_TLBSEL_MSK)
293+
#define MAS0_ESEL_MSK 0x0FFF0000
294+
#define MAS0_ESEL(x) (((x) << 16) & MAS0_ESEL_MSK)
295+
#define MAS0_NV(x) ((x) & 0x00000FFF)
296+
297+
#define MAS1_VALID 0x80000000
298+
#define MAS1_IPROT 0x40000000 /* can not be invalidated by tlbivax */
299+
#define MAS1_TID(x) (((x) << 16) & 0x3FFF0000)
300+
#define MAS1_TS 0x00001000
301+
302+
#define MAS2_EPN 0xFFFFF000 /* Effective page number */
303+
#define MAS2_X0 0x00000040
304+
#define MAS2_X1 0x00000020
305+
#define MAS2_W 0x00000010 /* Write-through */
306+
#define MAS2_I 0x00000008 /* Caching-inhibited */
307+
#define MAS2_M 0x00000004 /* Memory coherency required */
308+
#define MAS2_G 0x00000002 /* Guarded */
309+
#define MAS2_E 0x00000001 /* Endianness - 0=big, 1=little */
310+
311+
#define MAS3_RPN 0xFFFFF000 /* Real page number */
312+
/* User attribute bits */
313+
#define MAS3_U0 0x00000200
314+
#define MAS3_U1 0x00000100
315+
#define MAS3_U2 0x00000080
316+
#define MAS3_U3 0x00000040
317+
#define MAS3_UX 0x00000020
318+
/* User and supervisor read, write, and execute permission bits */
319+
#define MAS3_SX 0x00000010
320+
#define MAS3_UW 0x00000008
321+
#define MAS3_SW 0x00000004
322+
#define MAS3_UR 0x00000002
323+
#define MAS3_SR 0x00000001
324+
325+
#define MAS7_RPN 0xFF000000 /* Real page number - upper 8-bits */
326+
327+
173328
/* L1 Cache */
174329
#define L1CFG0 0x203 /* L1 Cache Configuration Register 0 */
175330
#define L1CSR0 0x3F2 /* L1 Data */
@@ -245,47 +400,6 @@
245400
#define SPRN_TBWL 0x11C /* Time Base Write Lower Register */
246401
#define SPRN_TBWU 0x11D /* Time Base Write Upper Register */
247402

248-
249-
/* MMU Assist Registers
250-
* E6500RM 2.13.10
251-
* E500CORERM 2.12.5
252-
*/
253-
#define MAS0_TLBSEL_MSK 0x30000000
254-
#define MAS0_TLBSEL(x) (((x) << 28) & MAS0_TLBSEL_MSK)
255-
#define MAS0_ESEL_MSK 0x0FFF0000
256-
#define MAS0_ESEL(x) (((x) << 16) & MAS0_ESEL_MSK)
257-
#define MAS0_NV(x) ((x) & 0x00000FFF)
258-
259-
#define MAS1_VALID 0x80000000
260-
#define MAS1_IPROT 0x40000000 /* can not be invalidated by tlbivax */
261-
#define MAS1_TID(x) (((x) << 16) & 0x3FFF0000)
262-
#define MAS1_TS 0x00001000
263-
264-
#define MAS2_EPN 0xFFFFF000 /* Effective page number */
265-
#define MAS2_X0 0x00000040
266-
#define MAS2_X1 0x00000020
267-
#define MAS2_W 0x00000010 /* Write-through */
268-
#define MAS2_I 0x00000008 /* Caching-inhibited */
269-
#define MAS2_M 0x00000004 /* Memory coherency required */
270-
#define MAS2_G 0x00000002 /* Guarded */
271-
#define MAS2_E 0x00000001 /* Endianness - 0=big, 1=little */
272-
273-
#define MAS3_RPN 0xFFFFF000 /* Real page number */
274-
/* User attribute bits */
275-
#define MAS3_U0 0x00000200
276-
#define MAS3_U1 0x00000100
277-
#define MAS3_U2 0x00000080
278-
#define MAS3_U3 0x00000040
279-
#define MAS3_UX 0x00000020
280-
/* User and supervisor read, write, and execute permission bits */
281-
#define MAS3_SX 0x00000010
282-
#define MAS3_UW 0x00000008
283-
#define MAS3_SW 0x00000004
284-
#define MAS3_UR 0x00000002
285-
#define MAS3_SR 0x00000001
286-
287-
#define MAS7_RPN 0xFF000000 /* Real page number - upper 8-bits */
288-
289403
#define SPRN_TLB0CFG 0x2B0 /* TLB 0 Config Register */
290404
#define SPRN_TLB1CFG 0x2B1 /* TLB 1 Config Register */
291405
#define TLBNCFG_NENTRY_MASK 0x00000FFF

0 commit comments

Comments
 (0)