OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [powerpc/] [ts6/] [v2_0/] [src/] [ts6.S] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#==============================================================================
2
##
3
##      ts6.S
4
##
5
##      MPC8260 TS6 board hardware setup
6
##
7
##=============================================================================
8
#####ECOSGPLCOPYRIGHTBEGIN####
9
## -------------------------------------------
10
## This file is part of eCos, the Embedded Configurable Operating System.
11
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12
## Copyright (C) 2002 Gary Thomas
13
##
14
## eCos is free software; you can redistribute it and/or modify it under
15
## the terms of the GNU General Public License as published by the Free
16
## Software Foundation; either version 2 or (at your option) any later version.
17
##
18
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
## for more details.
22
##
23
## You should have received a copy of the GNU General Public License along
24
## with eCos; if not, write to the Free Software Foundation, Inc.,
25
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26
##
27
## As a special exception, if other files instantiate templates or use macros
28
## or inline functions from this file, or you compile this file and link it
29
## with other works to produce a work based on this file, this file does not
30
## by itself cause the resulting work to be covered by the GNU General Public
31
## License. However the source code for this file must still be made available
32
## in accordance with section (3) of the GNU General Public License.
33
##
34
## This exception does not invalidate any other reasons why a work based on
35
## this file might be covered by the GNU General Public License.
36
##
37
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38
## at http://sources.redhat.com/ecos/ecos-license/
39
## -------------------------------------------
40
#####ECOSGPLCOPYRIGHTEND####
41
##=============================================================================
42
#######DESCRIPTIONBEGIN####
43
##
44
## Author(s):   pfine, wpd
45
## Contributors: nickg
46
## Date:        2002-02-27
47
## Purpose:     TigerSHARC-6 board hardware setup
48
## Description: This file contains any code needed to initialize the
49
##              hardware on the Delphi TigerSHARC-6 board.
50
##
51
######DESCRIPTIONEND####
52
##
53
##=============================================================================
54
 
55
#include 
56
 
57
#include 
58
#include                /* on-chip resource layout, special */
59
#------------------------------------------------------------------------------
60
 
61
        .globl  hal_hardware_init
62
hal_hardware_init:
63
// It is possible that the board may experience a soft reset, which
64
// will cause this hal_hardware_init routine to be called.  As a
65
// result of the soft reset, the IMMR, memory controller, system
66
// protection logic, interrupt controller and parallel I/O pins are
67
// NOT reset (MPC8260 User Manual p 5-2), and therefor we do not want to
68
// run the setup in this routine.  Luckily, a hard reset will clear
69
// the NHR bit (bit 15) of the HID0 register.  We will check for this bit
70
// to be 0 (implying a hard reset).  If it is 0, we will run the
71
// initialization.  If non-zero, we will skip the initialization.
72
//
73
// If we do the initialization, then we must set the NHR bit so that
74
// next time we hit this point in the routine, we can determine the type
75
// of reset.
76
 
77
   mfspr  r22,CYGARC_REG_HID0    # Get contents of HID0
78
   rlwinm r23,r22,0,15,15 #shift HID0 by 0, mask with 0x10000, store in r23
79
   cmpwi  r23,0       # Compare r23 with 0
80
   bne    hardware_init_done
81
 
82
   mfspr r31,CYGARC_REG_LR
83
 
84
 
85
   #----------------------------------------------
86
   # Load the IMMR register with the base address
87
   #----------------------------------------------
88
 
89
   addis    r4,0,0x0471   # IMMR base addr = 0x04700000+10000. We add
90
                          # 0x10000 because using relative addressing
91
                          # in load and store instructions only allow a
92
                          # offset from the base of +/-32767.
93
   addis    r5,0,0x0470
94
 
95
   addis    r3,0,0x0F01
96
 
97
# The default IMMR base address was 0x0F0000000 as
98
# originally programmed into the Hard Reset
99
# Configuration Word.
100
   stw      r5,CYGARC_REG_IMM_IMMR(r3)
101
 
102
 
103
 
104
   mfspr    r21,CYGARC_REG_HID0   # get HID0 in R21
105
   oris     r21,r21,0x1     # Set bit 15 of HID0 (NHR)
106
 
107
   mtspr    CYGARC_REG_HID0,r21       # load HID0 with NHR set
108
 
109
 
110
   #*******************************************
111
   # Main System Clock Configuration Registers
112
   #*******************************************
113
 
114
   #-------------------------------------------------------------------------
115
   # We only need to program the System Clock Control Register (SCCR). The
116
   # System Clock Mode Register (SCMR) doesn t need to be programmed here
117
   # because the MODCLK_HI bits in the Hard Reset Configuration Word and the
118
   # MODCK pins dictate the values in the SCCR during power-on reset.
119
   #-------------------------------------------------------------------------
120
 
121
   #-------------------------------------------------------------------------
122
   # Program the System Clock Control Register (SCCR).
123
   #
124
   # - Bits 0 - 28 Reserved. Clear to 0.
125
   #
126
   # - CLPD (CPM Low Power Disable) = 0 =
127
   #
128
   #     CPM does not enter low power mode when the core enters low power
129
   #     mode.
130
   #
131
   # - DFBRG (Division Factor of BRGCLK) = 01 - Divide by 8.
132
   #
133
   #-------------------------------------------------------------------------
134
 
135
 
136
   addis    r3,0,0x0000
137
   ori      r3,r3,0x0001   # SCCR = 0x00000001
138
   stw      r3,CYGARC_REG_IMM_SCCR(r4)
139
 
140
   #~~~~~~~~~~~~~~~~~~~~
141
   # Initialize the SIU
142
   #~~~~~~~~~~~~~~~~~~~~
143
 
144
   bl       init_siu
145
 
146
   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147
   # Initialize the memory controller and SDRAM
148
   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149
 
150
   bl       init_memc
151
 
152
   mtspr    CYGARC_REG_LR,r31      # restore original Link Register value
153
 
154
hardware_init_done:
155
 
156
#define nFLASH_LEDS_FOREVER
157
#ifdef FLASH_LEDS_FOREVER
158
   bl   init_user_leds
159
   b    flash_leds_forever
160
#endif
161
#if 0
162
        b memory_test
163
#endif
164
 
165
 
166
        bclr 20,0
167
 
168
 
169
#########################################################################
170
# Function: init_siu
171
#
172
# Description: Initializes the System Interface Unit
173
#
174
#  History:
175
#
176
#
177
#########################################################################
178
 
179
init_siu:
180
 
181
   #-----------------------------------------------------------------------
182
   # Program the System Protection Control Register with the following
183
   # values:
184
   #
185
   # - SWTC (Software Watchdog Timer Count) = 0xFFFF = programmed to max
186
   #   count value.
187
   #
188
   # - BMT (Bus Monitor Timing) = 0xFF = Set to max timeout period.
189
   #
190
   # - PBME (60x Bus Monitor Enable) = 1 = enabled.
191
   #
192
   # - LBME (Local Bus Monitor Enable) = 1 = enabled.
193
   #
194
   # - Bits 26-28 Reserved. Set to 0.
195
   #
196
   # - SWE (Software Watchdog Enabled) = 0 = disabled for now. User will
197
   #   have to enable this in a non-debug application.
198
   #
199
   # - SWRI (Software Watchdog Reset/Interrupt Select) = 1 = Software
200
   #   watchdog timeout or bus monitor time-out causes a soft reset.
201
   #
202
   # - SWP (Software Watchdog Prescale) = 1 = clock is prescaled.
203
   #-----------------------------------------------------------------------
204
 
205
   addis    r3,0,0xFFFF
206
   ori      r3,r3,0xFFC3   # SYPCR = 0xFFFFFFC3
207
   stw      r3,CYGARC_REG_IMM_SYPCR(r4)
208
 
209
 
210
   #-------------------------------------------------------------------------
211
   # Program the Bus Configuration Register. The details are as follows:
212
   #
213
   # - EBM (External Bus Mode) = 0 = Single MPC8260 bus mode is assumed.
214
   #
215
   # - APD (Address Phase delay) = 001 =
216
   #
217
   #     One address tenure wait states for address operations initiated by
218
   #     a 60x bus master.
219
   #
220
   # - L2C (Secondary Cache Controller) = 0 = No secondary cache controller
221
   #                                          is assumed.
222
   #
223
   # - L2D (L2 cache hit Delay) = 000 = This is a don t care because we re
224
   #                                    not using the L2 cache.
225
   #
226
   # - PLDP (PipeLine maximum Depth) = 0 = The pipeline max depth is one.
227
   #
228
   # - Bits 9-11 = Reserved. Set to 0.
229
   #
230
   # - ETM (Compatibility Mode enable) = 1 = Extended transfer mode is
231
   #                                         enabled.
232
   #
233
   # - LETM (Local Bus Compatibility Mode Enable) = 1 =
234
   #
235
   #     Extended transfer mode is enabled on the local bus.
236
   #
237
   # - EPAR (Even Parity) = 0 = This is a do not care.
238
   #
239
   # - LEPAR (Local Bus Even Parity) = 0 = This is a do not care.
240
   #
241
   # - Bits 16-20 = Reserved. Set to 0.
242
   #
243
   # - EXDD (External Master Delay Disable) = 0 =
244
   #
245
   #     The memroy controller inserts one wait state between the assertion
246
   #     of TS and the assertion of CS when an external master accesses an
247
   #     address space controlled by the memory controller.
248
   #
249
   # - Bits 22-26 = Reserved. Set to 0.
250
   #
251
   # - ISPS (Internal Space Port Size) = 0 =
252
   #
253
   #     MPC8260 acts as a 64-bit slave to external master accesses to its
254
   #     internal space.
255
   #
256
   # - Bits 28-31 = Reserved. Set to 0.
257
   #
258
   #-------------------------------------------------------------------------
259
 
260
   addis    r3,0,0x100c
261
   stw      r3,CYGARC_REG_IMM_BCR(r4)
262
 
263
   #-------------------------------------------------------------------------
264
   # Program the 60x Bus Arbiter Configuration Register. The details are as
265
   # follows:
266
   #
267
   # - Bits 0-1 = Reserved. Set to 0.
268
   #
269
   # - DBGD (Data Bus Grant Delay) = Minimum of zero wait states for PowerPC
270
   #                                 master-initiated data operations. This
271
   #                                 is the minimum delay between TS/ and
272
   #                                 DBG/.
273
   #
274
   # - Bits 3 = Reserved. Set to 0.
275
   #
276
   # - PRKM (Parking Master) = 0010 = CPM is at a low request level for the
277
   #                                  parked master.
278
   #
279
   #-------------------------------------------------------------------------
280
 
281
   addi     r3,0,0x0002
282
   stb      r3,CYGARC_REG_IMM_PPC_ACR(r4)
283
 
284
 
285
   #-------------------------------------------------------------------------
286
   # Program the 60x Bus Arbitration-Level[High] Register. The priority for
287
   # potential bus masters are defined by locating the value associated with
288
   # a particular master from the PRKM field in the PPC_ACR register and
289
   # inserting its value in the priority field. Priority field 0 is the
290
   # highest priority and the lowest is Priority field 15 in the PPC_ALRH
291
   # register.
292
   #
293
   # - Priority Field 0 = 0000 = CPM high request level
294
   #
295
   # - Priority Field 1 = 0001 = CPM middle request level
296
   #
297
   # - Priority Field 2 = 0010 = CPM low request level
298
   #
299
   # - Priority Field 3 = 0110 = Internal Core
300
   #
301
   # - Priority Field 4 = 0111 = External Master 1
302
   #
303
   # - Priority Field 5 = 1000 = External Master 2
304
   #
305
   # - Priority Field 6 = 1001 = External Master 3
306
   #
307
   # - Priority Field 7 = 0011 = Reserved
308
   #
309
   #-------------------------------------------------------------------------
310
 
311
   addis    r3,0,0x0126
312
   ori      r3,r3,0x7893
313
   stw      r3,CYGARC_REG_IMM_PPC_ALRH(r4)
314
 
315
 
316
   #------------------------------------------------------------------------
317
   #
318
   # First program the SIUMCR. The details are as follows:
319
   #
320
   # - BBD (Bus Busy Disable) = 0 = [ABB/]/[IRQ2] pin is ABB/ and [DBB/]/IRQ2
321
   #                                pin is DBB/.
322
   #
323
   # - ESE (External Snoop Enable = 0 = [GPL/]/[IRQ1/] pin is IRQ1/
324
   #
325
   # - PBSE (Parity Byte Select Enable) = 0 = Parity byte select is disabled.
326
   #
327
   # - CDIS (Core DISable) = 0 = The PowerQUICCII CPU core is enabled.
328
   #
329
   # - DPPC (Data Parity Pins Configuration) = 10 =
330
   #
331
   #    Gives the following pin meanings:   DP(0)|RSRV/|EXT_BR2/  = RSRV/
332
   #                                        DP(1)|IRQ1/|EXT_BG2/  = IRQ1/
333
   #                                        DP(2)|TLBISYNC/|IRQ2/ = TLBISYNC/
334
   #                                        DP(3)|IRQ3/           = IRQ3/
335
   #                                        DP(4)|IRQ4/           = IRQ4/
336
   #                                        DP(5)|TBEN/|IRQ5      = TBEN/
337
   #                                        DP(6)|CSE(0)|IRQ6/    = CSE(0)
338
   #                                        DP(7)|CSE(1)|IRQ7/    = CSE(1)
339
   #
340
   # - L2CPC (L2 Cache Pins Configuration) = 00 =
341
   #
342
   #    Gives the following pin meanings:   CI/|BADDR(29)|IRQ2/ = CI/
343
   #                                        WT/|BADDR(30)|IRQ3/ = WT/
344
   #                                        L2_HIT/|IRQ4        = L2_HIT/
345
   #
346
   #                                        CPU_BG/|BADDR(31)
347
   #                                        |IRQ5/              = CPU_BG/
348
   #
349
   # - LBPC (Local Bus Pins Configuration) = 00 =
350
   #
351
   #    Local Bus pins function as local bus.
352
   #
353
   # - APPC (Address Parity Pins Configuration) = 11 =
354
   #
355
   #    Gives the following pin meanings: MODCK1|AP(1)|TC(0)  = -
356
   #                                      MODCK2|AP(2)|TC(1)  = -
357
   #                                      MODCK3|AP(3)|TC(2)  = -
358
   #                                      IRQ7/|APE/|INT_OUT/ = IRQ7/+INT_OUT/
359
   #                                      CS11/|AP(0)         = -
360
   #
361
   # - CS10PC (Chip Select 10-pin Configuration) = 00 =
362
   #
363
   #    CS10/|BCTL1/|DBG_DIS/ = CS10/
364
   #
365
   # - BCTLC (Buffer Control Configuration) = 00 =
366
   #
367
   #    BCTL0 pin is used as W|R/ control. BCTL1 is used as OE/ control if
368
   #    BCTL1 was connected to its alternate pin.
369
   #
370
   # - MMR (Mask Masters Requests) = 00 = No masking on bus request lines.
371
   #
372
   # - LPBSE (Local Bus Parity Byte Select Enable) = 0
373
   #
374
   #    Parity byte select is disabled.
375
   #
376
   # Bits 19-31 are reserved and set to 0.
377
   #
378
   #------------------------------------------------------------------------
379
 
380
   #--------------------------------------------------------------------------
381
   # Program the 60x Bus Transfer Error Status and Control Register 1. The
382
   # details are as follows:
383
   #
384
   # - DMD (Data Errors Disable) = 1 =
385
   #
386
   #     Disable all data errors on the 60x bus. Also parity single and double
387
   #     ECC error.
388
   #
389
   # - All other bits are either status or reserved bits. All reserved bits
390
   #   should be set to 0.
391
   #--------------------------------------------------------------------------
392
 
393
   addis    r3,0,0x0000
394
   ori      r3,r3,0x4000
395
   stw      r3,CYGARC_REG_IMM_TESCR1(r4)
396
 
397
   #--------------------------------------------------------------------------
398
   # Program the Local Bus Transfer Error Status and Control Register 1. The
399
   # details are as follows:
400
   #
401
   # - DMD (Data Errors Disable) = 1 =
402
   #
403
   #     Disable parity errors on the Local bus.
404
   #
405
   # - All other bits are either status or reserved bits. All reserved bits
406
   #   should be set to 0.
407
   #--------------------------------------------------------------------------
408
 
409
   addis    r3,0,0x0E30
410
   ori      r3,r3,0x0000
411
   stw      r3,CYGARC_REG_IMM_SIUMCR(r4)
412
 
413
   # FIXME - What is this programming from??????
414
   addis    r3,0,0x0000
415
   ori      r3,r3,0x4000
416
   stw      r3,CYGARC_REG_IMM_LTESCR1(r4)
417
 
418
 
419
   #-------------------------------------------------------------------------
420
   # First, program the Memory Periodic Timer Prescaler Register (MPTPR).
421
   # Finding the value to this ties in with the desired SDRAM Refresh
422
   # Timer (PSRT) value and the required Refresh Command interval for
423
   # refreshing each row. The Refresh Command interval is found by
424
   # determining the number of rows on the SDRAM device. In this case
425
   # its 4096 (12 bits to address rows). The "Refresh Period" value in the
426
   # AC characteristic section of the data sheet is 64 msec. This value
427
   # is divided by the number of rows to give the number of Refresh
428
   # commands that needs to be sent in a 64 msec interval. This value
429
   # is 64 msec/4096 = 15.625 usec.
430
   # Due to probable contention from time to time with other memory
431
   # controller bus requests, lets make the refresh command interval to be
432
   # around 15.5 usec.
433
   #
434
   # Using the calculation found in the MPC8260 User Manual errata, the
435
   # timer period is
436
   #
437
   #        Timer Period = (PSRT + 1) * (MPTPR[PTP] + 1)
438
   #                       ----------------------------
439
   #                              Bus Frequency
440
   #
441
   #        - Set PSRT       = 16
442
   #        - Set MPTPR[PTP] = 40
443
   #        - Use 45 MHz as Bus Frequency
444
   #
445
   #
446
   #        - Timer Period = 15.489 usec
447
   #
448
   #
449
   # The clock distribution block diagram looks like this:
450
   #
451
   #   ----------      -------------         -----------    -------------
452
   #   | Clock   |     |   MPT     |         | SDRAM   |    | Refresh   |
453
   #   | Gen.    |-----| Prescaler |---------| Refresh |----| Command   |
454
   #   | 45 Mhz  |     -------------         | Timer   |    | Logic in  |
455
   #   | on Ts6 |                           -----------    | Mem.Cont. |
456
   #   | Board   |                                          -------------
457
   #   -----------
458
   #
459
   #-------------------------------------------------------------------------
460
 
461
#   addi     r5,0,0x4000      # load 0x40 or 64 into the PTP field of MPTPR
462
   addi     r5,0,0x2800      # load 0x28 or 40 into the PTP field of MPTPR
463
   sth      r5,CYGARC_REG_IMM_MPTPR(r4)     # store half word - bits[16-31]
464
 
465
 
466
 
467
   #-----------------------
468
   # return from init_siu
469
   #-----------------------
470
 
471
   bclr  20,0           # jump unconditionally to effective address in Link
472
                        # register
473
 
474
 
475
#########################################################################
476
# Function: init_memc
477
#
478
# Description:
479
#
480
#  The following registers directly control the memory controllers
481
#  operation:
482
#
483
#  BR0-BR11 - Base Register Banks 0-11
484
#  OR0-OR11 - Option Register Banks 0-11
485
#  PSDMR    - 60x bus SDRAM machine mode register
486
#  LSDMR    - Local bus SDRAM machine mode register
487
#  MAMR     - UPMA mode register
488
#  MBMR     - UPMB mode register
489
#  MCMR     - UPMC mode register
490
#  MDR      - Memory data register
491
#  MAR      - Memory address register
492
#  MPTPR    - Memory periodic timer pre-scaler register
493
#  PURT     - 60x bus assigned UPM refresh timer
494
#  PSRT     - 60x bus assigned SDRAM refresh timer
495
#  LURT     - Local Bus assigned UPM refresh timer
496
#  LSRT     - Local Bus assigned SDRAM refresh timer
497
#
498
#  This example will program the following registers. The rest will remain at
499
#  their default values.
500
#
501
#  BR0      - Base Register for Flash Memory
502
#  OR0      - Option Register for Flash Memory
503
#  BR1      - Base Register for BCSR (Board Control and Status Registers)
504
#  OR1      - Option Register for BCSR
505
#  BR2      - Base Register for 60x SDRAM
506
#  OR2      - Option Register for 60x SDRAM
507
#  BR3      - Base Register for 60x Local Bus SDRAM
508
#  OR3      - Option Register for 60x Local Bus SDRAM
509
#  PSDMR    - 60x bus SDRAM machine mode register
510
#  LSDMR    - Local bus SDRAM machine mode register
511
#  MPTPR    - Memory periodic timer pre-scaler register
512
#  PSRT     - 60x bus assigned SDRAM refresh timer
513
#  LSRT     - Local Bus assigned SDRAM refresh timer
514
#
515
#
516
#  History:
517
#
518
#########################################################################
519
 
520
init_memc:
521
 
522
   mfspr    r30,CYGARC_REG_LR        # Save the Link Register value. The link registers
523
                          # value will be restored so that this function
524
                          # can return to the calling address.
525
 
526
   bl    init_flash       # 8 Mbyte of flash memory
527
 
528
   bl    init_fpga_mem    # 64 KByte memory map for FPGA access
529
 
530
   bl    init_cluster_bus # 256 MByte Memory mapped for Tiger Sharc cluster bus
531
 
532
#ifdef MORE_FLASH
533
#endif
534
#if 0 // The Delphi TS6 Digital Board does not have BCSR
535
   bl    init_bcsr         # Board Control and Status Registers
536
#endif
537
 
538
   bl    init_60x_sdram    # Main 60x Bus SDRAM
539
 
540
   #-----------------------
541
   # return from init_memc
542
   #-----------------------
543
 
544
   mtspr    CYGARC_REG_LR,r30      # restore original Link Register value
545
 
546
   bclr  20,0           # jump unconditionally to effective address in Link
547
                        # register
548
 
549
 
550
 
551
############################################################################
552
# Function: init_flash
553
#
554
# Description: This function programs Base Register 0 and Option Register 0
555
#              designating bank 0 for the 8Mbyte flash SIMM on the TS6
556
#              board. Programming these two registers describes how the
557
#              MPC8260 will inter-operate with this memory space and thus
558
#              this memory device.
559
#
560
#  History:
561
#
562
############################################################################
563
 
564
init_flash:
565
 
566
   #-------------------------------------------------------------------------
567
   # Base Register 0 (BR0): Bank 0 is assigned to the 8Mbyte (2M X 32)
568
   #                        flash that resides on the MPC8260 TS6 board.
569
   #                        The particulars are defined here.
570
   #
571
   # BA (Base Address) = 0xFF80+0b for a total of 17 address bits. This value
572
   #                     represents the upper 17 bits of the base address.
573
   #
574
   # Bits 17-18 reserved. = 00
575
   #
576
   # PS (Port Size) = 11b = 32 bit port size
577
   #
578
   # DECC (Data Error Correction and Checking) = 00 = Data errors checking
579
   #                                                  Disabled.
580
   #
581
   # WP (Write Protect) = 0 = both read and write accesses are allowed
582
   #
583
   # MS (Machine Select) = 000 = General Purpose Chip Select Machine (GPCM)
584
   #                             for 60x bus Selected
585
   #
586
   # EMEMC (External Memory Controller Enable) = 0 = Accesses are handled by
587
   #                                                 the memory controller
588
   #                                                 according to MSEL.
589
   #
590
   # ATOM (Atomic Operation) = 00 = The address space controlled by the
591
   #                                memory controller bank is not used for
592
   #                                atomic operations.
593
   #
594
   # DR (Delayed Read) = 0 = Normal operation.
595
   #
596
   # V (Valid Bit) =  1 = Valid bit set
597
   #-------------------------------------------------------------------------
598
   addis    r3,0,0xFF80   # R3 holds the value temporarily
599
   ori      r3,r3,0x1801
600
   #-------------------------------------------------------------------------
601
   # Option Register 0 (OR0) for GPCM use: further flash definitions
602
   #
603
   # AM (Address Mask) = 0xFF80+0b = We have masked the upper 9 bits which
604
   #                                 defines a 8 Mbyte memory block.
605
   #
606
   # Bits 17-19 Reserved - set to 000.
607
   #
608
   # CSNT (Chip Select Negation Time) = 1 = CS/|WE/ are negated a quarter
609
   #                                        of a clock early.
610
   #
611
   # ACS (Address To Chip-Select Setup) = 00 = CS/ is output the same time as
612
   #                                           the addr lines.
613
   #
614
   # Bit 23 Reserved - set to 0.
615
   #
616
   # SCY (Cycle Length In Clocks) = 0011 = Add a 3 clock cycle wait state
617
   #
618
   # SETA (External Transfer Acknowledge) = 0 = PSDVAL/ is generated
619
   #                                            internally by the memory
620
   #                                            controller unless GTA/ is
621
   #                                            asserted earlier externally.
622
   #
623
   # TRLX (Timing Relaxed) = 1 = Relaxed timing is generated by the GPCM.
624
   #
625
   # EHTR (Extended Hold Time On Read Accesses) = 1 =
626
   #
627
   #     Extended hold time is generated by the memory controller. An idle
628
   #     clock cycle is inserted between a read access from the current bank
629
   #     and any write or read access to a different bank.
630
   #
631
   # Bit 31 Reserved - set to 0.
632
   #-------------------------------------------------------------------------
633
 
634
   addis    r5,0,0xFF80     # R5 holds the value temporarily
635
   ori      r5,r5,0x0836
636
 
637
   #------------------------------------------------------------------------
638
   # It is important to note the order in which OR0 and BR0 are programmed.
639
   # When coming out of reset and CS0 is the global chip select, OR0 MUST be
640
   # programmed AFTER BR0. In all other cases BRx would be programmed after
641
   # ORx.
642
   #------------------------------------------------------------------------
643
 
644
   #------------------
645
   # Write the values
646
   #------------------
647
 
648
   stw        r3,CYGARC_REG_IMM_BR0(r4)
649
   stw        r5,CYGARC_REG_IMM_OR0(r4)
650
 
651
 
652
   bclr  20,0           # jump unconditionally to effective address in Link
653
                        # register
654
 
655
 
656
#########################################################################
657
# Function: init_bcsr
658
#
659
# Description: This function programs Base Register 1 and Option Register 1
660
#              designating bank 1 for BCSR0, BCSR1, and BCSR2 on the TS6
661
#              board. BCSR stands for Board Control and Status Register.
662
#              This space is treated as general I/O. Programming the
663
#              following 2 registers describes how the MPC8260 will inter-
664
#              operate with this memory space.
665
#
666
#  History:
667
#
668
#  Jan 9/99    jay
669
#
670
#########################################################################
671
 
672
init_bcsr:
673
 
674
 
675
   #-------------------------------------------------------------------------
676
   # Base Register 1 (BR1): Bank 1 is assigned to the Board Control and
677
   #                        Status Registers (BCSRs). There are 3
678
   #                        that resides on the MPC8260 TS6 board.
679
   #                        The particulars are defined here.
680
   #
681
   # BA (Base Address) = 0x0450+0b for a total of 17 address bits. This value
682
   #                     represents the upper 17 bits of the base address.
683
   #
684
   # Bits 17-18 reserved. = 00
685
   #
686
   # PS (Port Size) = 11b = 32 bit port size
687
   #
688
   # DECC (Data Error Correction and Checking) = 00 = Data errors checking
689
   #                                                  Disabled.
690
   #
691
   # WP (Write Protect) = 0 = both read and write accesses are allowed
692
   #
693
   # MS (Machine Select) = 000 = General Purpose Chip Select Machine (GPCM)
694
   #                             for 60x bus Selected
695
   #
696
   # EMEMC (External Memory Controller Enable) = 0 = Accesses are handled by
697
   #                                                 the memory controller
698
   #                                                 according to MSEL.
699
   #
700
   # ATOM (Atomic Operation) = 00 = The address space controlled by the
701
   #                                memory controller bank is not used for
702
   #                                atomic operations.
703
   #
704
   # DR (Delayed Read) = 0 = Normal operation.
705
   #
706
   # V (Valid Bit) =  1 = Valid bit set
707
   #-------------------------------------------------------------------------
708
 
709
   addis    r3,0,0x0450     # R3 holds the value temporarily
710
   ori      r3,r3,0x1801
711
 
712
   #-------------------------------------------------------------------------
713
   # Option Register 1 (OR1) for GPCM use: further BCSR definitions
714
   #
715
   # AM (Address Mask) = 0xFFFF +1b = We have masked the upper 17 bits which
716
   #                                  which defines a 32 Kbyte memory block.
717
   #
718
   # Bits 17-19 Reserved - set to 000.
719
   #
720
   # CSNT (Chip Select Negation Time) = 0 = CS/|WE/ are negated normally.
721
   #
722
   # ACS (Address To Chip-Select Setup) = 00 = CS/ is output at the same
723
   #                                           time as the addr lines.
724
   #
725
   # Bit 23 Reserved - set to 0.
726
   #
727
   # SCY (Cycle Length In Clocks) = 0001 = Add a 1 clock cycle wait state
728
   #
729
   # SETA (External Transfer Acknowledge) = 0 = PSDVAL/ is generated
730
   #                                            internally by the memory
731
   #                                            controller unless GTA/ is
732
   #                                            asserted earlier externally.
733
   #
734
   # TRLX (Timing Relaxed) = 0 = Normal timing is generated by the GPCM.
735
   #
736
   # EHTR (Extended Hold Time On Read Accesses) = 0 = Normal timing is
737
   #                                                  generated by the memory
738
   #                                                  controller
739
   #
740
   # Bit 31 Reserved - set to 0.
741
   #-------------------------------------------------------------------------
742
 
743
   addis    r5,0,0xFFFF     # R5 holds the value temporarily
744
   ori      r5,r5,0x8010
745
 
746
   #------------------
747
   # Write the values
748
   #------------------
749
 
750
   stw        r5,CYGARC_REG_IMM_OR1(r4)
751
   stw        r3,CYGARC_REG_IMM_BR1(r4)
752
 
753
 
754
   bclr  20,0    # jump unconditionally to effective address in Link
755
                 # register
756
 
757
 
758
#########################################################################
759
# Function: init_fpga_mem
760
#
761
# Description: This function programs Base Register 4 and Option Register 4
762
#              designating bank 4 for the FPGA control space on the TS6
763
#              board.
764
#
765
#  History:
766
#
767
#
768
#########################################################################
769
 
770
init_fpga_mem:
771
 
772
 
773
   #-------------------------------------------------------------------------
774
   # Base Register 4 (BR4): Bank 4 is assigned to FPGA control memory map.
775
   #
776
   # BA (Base Address) = 0x0450+0b for a total of 17 address bits. This value
777
   #                     represents the upper 17 bits of the base address.
778
   #
779
   # Bits 17-18 reserved. = 00
780
   #
781
   # PS (Port Size) = 11b = 32 bit port size
782
   #
783
   # DECC (Data Error Correction and Checking) = 00 = Data errors checking
784
   #                                                  Disabled.
785
   #
786
   # WP (Write Protect) = 0 = both read and write accesses are allowed
787
   #
788
   # MS (Machine Select) = 000 = General Purpose Chip Select Machine (GPCM)
789
   #                             for 60x bus Selected
790
   #
791
   # EMEMC (External Memory Controller Enable) = 0 = Accesses are handled by
792
   #                                                 the memory controller
793
   #                                                 according to MSEL.
794
   #
795
   # ATOM (Atomic Operation) = 00 = The address space controlled by the
796
   #                                memory controller bank is not used for
797
   #                                atomic operations.
798
   #
799
   # DR (Delayed Read) = 0 = Normal operation.
800
   #
801
   # V (Valid Bit) =  1 = Valid bit set
802
   #-------------------------------------------------------------------------
803
 
804
   addis    r3,0,0x0450     # R3 holds the value temporarily
805
   ori      r3,r3,0x1801
806
 
807
   #-------------------------------------------------------------------------
808
   # Option Register 1 (OR1) for GPCM use: further BCSR definitions
809
   #
810
   # AM (Address Mask) = 0xFFFF +0b = We have masked the upper 16 bits which
811
   #                                  which defines a 64 Kbyte memory block.
812
   #
813
   # Bits 17-19 Reserved - set to 000.
814
   #
815
   # CSNT (Chip Select Negation Time) = 1 = CS/|WE/ are negated a quarter cycle
816
   #                                        early.  For now, put in all delay
817
   #                                        possible.
818
   #
819
   # ACS (Address To Chip-Select Setup) = 11 = CS/ is output one half clock
820
   #                                           after the addr lines.
821
   #
822
   # Bit 23 Reserved - set to 0.
823
   #
824
   # SCY (Cycle Length In Clocks) = 0000 = The SETA bit is set, therefore
825
   #                                       SCY is not used.
826
   #
827
   # SETA (External Transfer Acknowledge) = 1 = PSDVAL/ is generated
828
   #                                            by external logic, is this
829
   #                                            case, the FPGA.
830
   #
831
   # TRLX (Timing Relaxed) = 1 = Relaxed timing is generated by the GPCM.
832
   #
833
   # EHTR (Extended Hold Time On Read Accesses) = 1 = Eight idle cycle inserted
834
   #                                                  between a read access from
835
   #                                                  the current bank and
836
   #                                                  next access.
837
   #
838
   # Bit 31 Reserved - set to 0.
839
   #-------------------------------------------------------------------------
840
 
841
   addis    r5,0,0xFFFF     # R5 holds the value temporarily
842
   ori      r5,r5,0x0E0E
843
 
844
   #------------------
845
   # Write the values
846
   #------------------
847
 
848
   stw        r5,CYGARC_REG_IMM_OR4(r4)
849
   stw        r3,CYGARC_REG_IMM_BR4(r4)
850
 
851
 
852
   bclr  20,0    # jump unconditionally to effective address in Link
853
                 # register
854
 
855
#########################################################################
856
# Function: init_cluster_bus
857
#
858
# Description: This function programs Base Register 8 and Option Register 8
859
#              designating bank 8 for the Cluster Bus space on the TS6
860
#              board.
861
#
862
#  History:
863
#
864
#
865
#########################################################################
866
 
867
init_cluster_bus:
868
 
869
 
870
   #-------------------------------------------------------------------------
871
   # Base Register 8 (BR8): Bank 8 is assigned to Cluster Bus  memory map.
872
   #
873
   # BA (Base Address) = 0xe000+0b for a total of 17 address bits. This value
874
   #                     represents the upper 17 bits of the base address.
875
   #
876
   # Bits 17-18 reserved. = 00
877
   #
878
   # PS (Port Size) = 00b = 64 bit port size (use 64 bit port size)
879
   # PS (Port Size) = 11b = 32 bit port size
880
   #
881
   # DECC (Data Error Correction and Checking) = 00 = Data errors checking
882
   #                                                  Disabled.
883
   #
884
   # WP (Write Protect) = 0 = both read and write accesses are allowed
885
   #
886
   # MS (Machine Select) = 000 = General Purpose Chip Select Machine (GPCM)
887
   #                             for 60x bus Selected
888
   #
889
   # EMEMC (External Memory Controller Enable) = 0 = Accesses are handled by
890
   #                                                 the memory controller
891
   #                                                 according to MSEL.
892
   #
893
   # ATOM (Atomic Operation) = 00 = The address space controlled by the
894
   #                                memory controller bank is not used for
895
   #                                atomic operations.
896
   #
897
   # DR (Delayed Read) = 0 = Normal operation.
898
   #
899
   # V (Valid Bit) =  1 = Valid bit set
900
   #-------------------------------------------------------------------------
901
 
902
   addis    r3,0,0xE000     # R3 holds the value temporarily
903
   ori      r3,r3,0x0001
904
 
905
   #-------------------------------------------------------------------------
906
   # Option Register 8 (OR8) for GPCM use: further BCSR definitions
907
   #
908
   # AM (Address Mask) = 0xF000 +0b = We have masked the upper 4 bits which
909
   #                                  which defines a 256 Mbyte memory block.
910
   #
911
   # Bits 17-19 Reserved - set to 000.
912
   #
913
   # CSNT (Chip Select Negation Time) = 1 = CS/|WE/ are negated a quarter cycle
914
   #                                        early.  For now, put in all delay
915
   #                                        possible.
916
   #
917
   # ACS (Address To Chip-Select Setup) = 11 = CS/ is output one half clock
918
   #                                           after the addr lines.
919
   #
920
   # Bit 23 Reserved - set to 0.
921
   #
922
   # SCY (Cycle Length In Clocks) = 0000 = The SETA bit is set, therefore
923
   #                                       SCY is not used.
924
   #
925
   # SETA (External Transfer Acknowledge) = 1 = PSDVAL/ is generated
926
   #                                            by external logic, is this
927
   #                                            case, the FPGA.
928
   #
929
   # TRLX (Timing Relaxed) = 1 = Relaxed timing is generated by the GPCM.
930
   #
931
   # EHTR (Extended Hold Time On Read Accesses) = 1 = Eight idle cycle inserted
932
   #                                                  between a read access from
933
   #                                                  the current bank and
934
   #                                                  next access.
935
   #
936
   # Bit 31 Reserved - set to 0.
937
   #-------------------------------------------------------------------------
938
 
939
   addis    r5,0,0xF000     # R5 holds the value temporarily
940
   ori      r5,r5,0x0E0E
941
 
942
   #------------------
943
   # Write the values
944
   #------------------
945
 
946
   stw        r5,CYGARC_REG_IMM_OR8(r4)
947
   stw        r3,CYGARC_REG_IMM_BR8(r4)
948
 
949
 
950
   bclr  20,0    # jump unconditionally to effective address in Link
951
                 # register
952
 
953
 
954
 
955
#########################################################################
956
# Function: init_60x_sdram
957
#
958
# Description: This function programs the 64 Mbyte SDRAM DIMM on the TS6
959
#              board. This memory functions as the RAM for the 603 core and
960
#              is connected to the 60x bus. Base and Option Register 5 are
961
#              used as well as the SDRAM Machine #1 and Chip Select #5.
962
#
963
#  History:
964
#
965
#  Apr /10/02   pfine    Modified so that all 64 MBytes are addressable.
966
#
967
#  Feb /27/02   pfine    Modified the Motorola code to work for the TS6
968
#                        board.
969
#  Jan /9/99    jay      Initial Release
970
#
971
#########################################################################
972
 
973
init_60x_sdram:
974
 
975
 
976
   # The Delphi MPC8260 TigerSHARC-6 Board is stocked with a 64 MByte
977
   # SDRAM DIMM module (WINTEC W9Q308647PA-222H).  The DIMM module consists
978
   # of 4 Micron Technology 128 Mbit SDRAM modules, each having 12 row
979
   # by 9 columns by 4 banks.  The part number for the Micron SDRAM
980
   # is 48LC8M16A2.  The Refresh Period is 64 milliseconds for all 4096
981
   # rows, or 15.625 usec per row.
982
   #
983
   # NOTE - The spec sheet for the WINTEC DIMM claims that the device
984
   #        has 12/11/2 rows/columns/banks, but the spec sheet for the Micron
985
   #        SDRAM chips says 12/9/4.  The 4 Banks seems to work.
986
 
987
   # The TS6 board has the 60x Bus SDRAM connected to CS5, so use BR5, OR5.
988
 
989
   #-------------------------------------------------------------------------
990
   # Program the 60x Bus Assigned SDRAM Refresh Timer (PSRT).
991
   # See SIU initialization programming for details of why 16 is the
992
   # value for the PSRT.
993
   #-------------------------------------------------------------------------
994
 
995
   addi     r5,0,0x0010      # load 0x10 or 16
996
   stb      r5,CYGARC_REG_IMM_PSRT(r4)      # store byte - bits[24-31]
997
 
998
 
999
   #########################
1000
   # Program Bank Registers
1001
   #########################
1002
 
1003
 
1004
   #-------------------------------------------------------------------------
1005
   # Base Register 5 (BR5): Bank 5 is assigned to the 64 Mbyte 60x SDRAM DIMM
1006
   #                        that resides on the MPC8260 TS6 board. The
1007
   #                        particulars are defined here.
1008
   #
1009
   # - BA (Base Address) = 0x0000+0b for a total of 17 address bits. This
1010
   #                       value represents the upper 17 bits of the base
1011
   #                       address.
1012
   #
1013
   # - Bits 17-18 reserved. = 00 = cleared to 0.
1014
   #
1015
   # - PS (Port Size) = 00b = 64 bit port size
1016
   #
1017
   # - DECC (Data Error Correction and Checking) = 00 = Data errors checking
1018
   #                                                    Disabled.
1019
   #
1020
   # - WP (Write Protect) = 0 = both read and write accesses are allowed
1021
   #
1022
   # - MS (Machine Select) = 010 = SDRAM Machine for 60x bus Selected
1023
   #
1024
   # - EMEMC (External Memory Controller Enable) = 0 =
1025
   #
1026
   #    Accesses are handled by the memory controller according to MSEL.
1027
   #
1028
   # - ATOM (Atomic Operation) = 00 = The address space controlled by the
1029
   #                                  memory controller bank is not used for
1030
   #                                  atomic operations.
1031
   #
1032
   # - DR (Delayed Read) = 0 = Normal operation.
1033
   #
1034
   # - V (Valid Bit) =  1 = Valid bit set
1035
   #-------------------------------------------------------------------------
1036
 
1037
   addis    r3,0,0x0000     # R3 holds the value temporarily
1038
   ori      r3,r3,0x0041
1039
 
1040
   #-------------------------------------------------------------------------
1041
   # Option Register 5 (OR5) for SDRAM Machine use: further SDRAM definitions
1042
   #
1043
   # - SDAM (SDRAM Address Mask) = 1111 1100 0000b = 0xFC0
1044
   #      As per the errata to the MPC8260 Users Manual, the SDAM value
1045
   #      is a 12 bit field (0-11).  The 64 MByte block is specified.
1046
   #
1047
   # - LSDAM (Lower SDRAM Address Mask) = 00000b = Minimum of 1 Mbyte size.
1048
   #
1049
   # - BPD (Banks Per Device) = 01b = 4 internal banks per device.
1050
   #
1051
   #
1052
   #
1053
   # -- The SDRAM is set up to operate in Page Based Interleaving Mode.
1054
   #
1055
   # - ROWST (Row Start Address Bit) = 0110b = A6 being the row start address
1056
   #                                           bit.  See the PSDMR programming
1057
   #                                           explanation below for details
1058
   #                                           of how A6 was determined to be
1059
   #                                           the starting row.
1060
   #       As per the errata to the MPC8260 Users Manual, the ROWST field
1061
   #       bits 19-22.
1062
   #
1063
   # - NUMR (Number of Row Address Lines) = 011b = 12 row address lines.
1064
   #
1065
   # - PMSEL (Page Mode Select) = 1
1066
   #
1067
   # - IBID (Internal bank interleaving within same device disable) = 1
1068
   #
1069
   #    As per MPC8260 Users Manual, if the SDRAM device is not connected
1070
   #    to the BNKSEL pins, then this bit should be set.  The BNKSEL pins
1071
   #    are not connected on the TS6 platform.
1072
   #
1073
   # - Bits 28-31 Reserved - set to 0.
1074
   #-------------------------------------------------------------------------
1075
 
1076
   addis    r5,0,0xFC00     # R5 holds the value temporarily
1077
   ori      r5,r5,0x2CF0
1078
 
1079
   #------------------
1080
   # Write the values
1081
   #------------------
1082
   stw        r5,CYGARC_REG_IMM_OR5(r4)
1083
   stw        r3,CYGARC_REG_IMM_BR5(r4)
1084
 
1085
   ###########################################
1086
   # Perform Initialization sequence to SDRAM
1087
   ###########################################
1088
 
1089
   #-------------------------------------------------------------------------
1090
   # Program the PowerPC SDRAM Mode Registr (PSDMR). This register is used
1091
   # to configure operations pertaining to SDRAM. Program the PSDMR, turning
1092
   # off refresh services and changing the SDRAM operation to "Precharge all
1093
   # banks". Then do a single write to an arbitrary location. Writing 0xFF
1094
   # to address 0 will do the trick.
1095
   #
1096
   # - PBI (Page Based Interleaving) = 1
1097
   #
1098
   # - RFEN (Refresh Enable) = 0 = Refresh services not required. This bit
1099
   #                               will be set later in this function as a
1100
   #                               last step.
1101
   #
1102
   # - OP (SDRAM Operation) = xxx  Precharge all banks 101b
1103
   #                               CBR Refresh         001b
1104
   #                               Mode register write 011b
1105
   #                               Normal operation    000b
1106
   #
1107
   # - SDAM (Address Multiplex Size = 011 =
1108
   #
1109
   #   FIXME - This explanation needs to updated.
1110
   #   The 64 MByte SDRAM DIMM used on the TS6 platform has only 12 address
1111
   #   pins and 2 bank select pins.  The MPC8260 SDRAM memory controller
1112
   #   must multiplex the 23 MPC8260 address bits (64 MBytes = 2^26, but
1113
   #   the 3 lsbs are ignored due to the 64 bit depth of the SDRAM) onto
1114
   #   the available SDRAM pins.
1115
 
1116
   #   The following explanation will explain (hopefully) how the 23 bits
1117
   #   of the effective address (as seen from the MPC8260) will be remapped
1118
   #   onto the physical pins of the SDRAM device.  It is expected that
1119
   #   the MPC8260 Users Manual (Chapter 10) is necessary to understand
1120
   #   this explanation.
1121
   #
1122
   #   Page Based Interleaving is chosen as the address multiplexing method.
1123
   #   The SDRAM device architecture is 12 rows, 9 columns, 4 banks.
1124
   #
1125
   #   The effective address space as seen from the MPC8260 is partitioned
1126
   #   as follows to map to the architecture of the SDRAM device.
1127
   #
1128
   #      addresses ignored by SDRAM : A29 A30 A31
1129
   #
1130
   #      column addresses: A20 A21 A22 A23 A24 A25 A26 A27 A28
1131
   #
1132
   #      bank select addresses:  A18 A19
1133
   #
1134
   #      row addresses:  A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17
1135
   #
1136
   #   These address bits correspond to the effective address which the MPC8260
1137
   #   is attempting to access.  The MPC8260 memory controller, through
1138
   #   the settings of the BR5/OR5 and PSDMR registers, will remap these
1139
   #   effective addresses bits onto the physical address pins of the SDRAM
1140
   #   DIMM.
1141
   #
1142
   #  -1) The SDRAM has a data width of 64 bits, which means that each
1143
   #      read or write consists of 8 8-bit bytes aligned on an 8 byte
1144
   #      boundary.  Therefore, the lowest three address bits (A29 A30 A31)
1145
   #      are always ignored, and not physically connected to the SDRAM.
1146
   #
1147
   #  -2) The 9 column address bits select one column of 512 for
1148
   #      SDRAM read or write.  These bits are mapped directly to the
1149
   #      physical pins on the SDRAM DIMM.
1150
   #
1151
   #  -3) In Page Based Interleaving mode (PSDMR[PBI] = 1) the bank select
1152
   #      lines are assigned the address lines between the column addresses
1153
   #      and the row addresses.  By setting OR5[BPD] = 01, the memory
1154
   #      controller knows that there are 4 banks, and therefore 2 bank
1155
   #      select lines (A18 A19).  The TS6 platform has MPC8260 address
1156
   #      lines A14 and A15 connected to the two bank select pins on the
1157
   #      DIMM, and therefore PSDMR[BSMA] = 001.
1158
   #
1159
   #      PSDMR[PBI] = 1
1160
   #      OR5[BPD] = 01
1161
   #
1162
   #      To clarify, selecting PSDMR[BSMA] = 001 tells the memory
1163
   #      controller to put out the bits corresponding to the bank select
1164
   #      address bits on the address lines named A14 and A15.
1165
   #      Those bank select lines correspond to effective address bits
1166
   #      A18 and A19.  So the effective address bits A18 and A19 actually
1167
   #      are put out onto the A14 and A15 address lines, which are, in
1168
   #      turn, connected to BA1 and BA0 on the SDRAM DIMM.
1169
   #
1170
   #      PSDMR[BSMA] = 001
1171
   #
1172
   #  -4) The remaining 12 address bits are the row addresses. Simple
1173
   #      subtraction says that the starting row address bit
1174
   #      (OR5[ROWST]) is A6 (3 bits not connected, 9 column bits, 2
1175
   #      bank select bits, 12 row bits).
1176
   #
1177
   #      OR5[NUMR]  = 011b  ==> 12 rows
1178
   #      OR5[ROWST] = 0110b ==> A6 is row start address bit
1179
   #
1180
   #  -5) The memory controller must be told how to multiplex the row
1181
   #      address bits onto the physical pins of the SDRAM device.  This
1182
   #      is accomplished through the PSDMR[SDAM] field.
1183
   #      Lining up the column and row addresses so that the
1184
   #      lsb of the row addresses lines up with the lsb of the column
1185
   #      addresses gives the following arrangemnt:
1186
   #
1187
   #      column addresses:          A20 A21 A22 A23 A24 A25 A26 A27 A28
1188
   #      row addresses:  A6  A7  A8  A9 A10 A11 A12 A13 A14 A15 A16 A17
1189
   #
1190
   #      The MPC8260 Users Manual, Table 10-20 shows that PSDMR[SDAM] = 011b
1191
   #      provides the proper alignment for this multiplexing scheme.
1192
   #
1193
   #      PSDMR[SDAM] = 011b
1194
   #
1195
   #  -6) The final complication in the SDRAM configuration is the SDA10
1196
   #      control.  SDRAM is accessed in a two stage process.  In the
1197
   #      first stage, the row address and bank selects are loaded to the
1198
   #      SDRAM device.  In the second stage, the column address is loaded.
1199
   #      SDRAM devices multiplex the A10/AP pin for two purposes.  In the
1200
   #      first stage, A10/AP is an address pin.  In the second stage, the
1201
   #      pin is used to determine how precharging is done (this
1202
   #      explanation will not go into this aspect).  Because the A10/AP
1203
   #      pin is special, the pin is connected physically to a special
1204
   #      pin on the MPC8260, the PSDA10 pin.  The memory controller must
1205
   #      be told how which address bit is being multiplexed on PSDA10.
1206
   #
1207
   #      The row address bit which is multplexed onto the pin between
1208
   #      A9 and A11 physical pins on the SDRAM device is this special bit.
1209
   #      Lining up the physical pins and the MPC8260 address lines (from
1210
   #      sheet 15 of the TS6 platform schematics) and the line of Table 20
1211
   #      corresponding to SDAM = 011b
1212
   #
1213
   #      SDRAM physical pins:  A11 A10  A9  A8  A7  A6  A5  A4  A3  A2  A1  A0
1214
   #      MPC8260 address lines:A17 A18 A19 A20 A21 A22 A23 A24 A25 A26 A27 A28
1215
   #      row address:           A6  A7  A8  A9 A10 A11 A12 A13 A14 A15 A16 A17
1216
   #
1217
   #      It is seen that the row address bit which will appear on the A10
1218
   #      physical pin is A7 and therefore
1219
   #
1220
   #      PSDMR[SDA10] = 011b ==> Address bit A7 (for PBI = 1)
1221
   #
1222
   # - BSMA (Bank Select Multiplexed Address line) = 001 = A13-A15
1223
   #
1224
   # - SDA10 ("A10 Control") = 011 =
1225
   #
1226
   # FIXME - The following timing values are not optimized.  They are the
1227
   #         same values as were used in the MPC8260 TS6 board, with
1228
   #         the 16 MByte DIMM and a 66 MHz Bus Frequency.
1229
   #
1230
   # - RFRC (ReFresh ReCovery) = 101 =
1231
   #
1232
   #   Once a  refresh request is granted, the memory controller begins
1233
   #   issuing auto-refresh commands to each device associated with the
1234
   #   refresh timer in one clock intervals. After the last REFRESH
1235
   #   command is issued, the memory controller waits for 7 clocks before
1236
   #   the ACTIVATE command and before normal read/write operations can
1237
   #   resume.
1238
   #
1239
   # - PRETOACT (PREcharge TO ACTivate interval) = 011 =
1240
   #
1241
   #   Wait 3 clock cycles before an activate command. This parameter is
1242
   #   determined by the requirements of the SDRAM at a particular clock
1243
   #   speed.
1244
   #
1245
   # - ACTTORW (ACTivate TO Read/Write interval) = 010 = 2 clock cycles.
1246
   #
1247
   # - BL (Burst Length) = 0 = SDRAM burst length is 4. This is programmed
1248
   #                          into the SDRAM via the MRS commmand.
1249
   #
1250
   # - LDOTOPRE (Last Data Out TO PREcharge) = 01 =
1251
   #
1252
   #   The delay required from the last data out to precharge state is 1 clock
1253
   #   cycle. This parameter is determined by the requirements of the SDRAM at
1254
   #   a particular clock speed.
1255
   #
1256
   # - WRC (Write Recovery Time) = 01 =
1257
   #
1258
   #   Time needed to elapse before another operation is 1 clock cycle. This
1259
   #   parameter is determined by the requirements of the SDRAM at a
1260
   #   particular clock speed.
1261
   #
1262
   # - EAMUX (External Address MUltipleXing) = 0 No external address
1263
   #                                             multiplexing.
1264
   #
1265
   # - BUFCMD (Buffer Control Lines) = 0 = Normal timing for the control
1266
   #                                       lines.
1267
   #
1268
   # - CL (CAS Latency) = 10 =
1269
   #
1270
   #    CAS latency is 2. Two cycles after column address is registered, data
1271
   #    is valid. This parameter is determined by the requirements of the
1272
   #    SDRAM at a particular clock speed.
1273
   #
1274
   #-------------------------------------------------------------------------
1275
 
1276
   ##################
1277
   # Precharge all banks
1278
   ##################
1279
 
1280
   # Clear refresh enable bit (bit 1 = 0)
1281
   # Set OP mode to Precharge (bits 2-4 = 101b)
1282
 
1283
   addis    r3,0,0x8B2E
1284
   ori      r3,r3,0xB452
1285
 
1286
   stw      r3,CYGARC_REG_IMM_PSDMR(r4)
1287
   addis    r0,0,0
1288
 
1289
   addi     r3,0,0x00FF      # Load 0x000000FF into r3
1290
   stb      r3,0(r0)         # Write 0xFF to address 0 - bits [24-31]
1291
 
1292
 
1293
   #-------------------------------------------------------------------------
1294
   # Program the PSDMR keeping refresh services off and changing the
1295
   # SDRAM operation to "CBR Refresh". This step is responsible for issuing
1296
   # a minimum of 8 auto-refresh commands. This is done by the SDRAM machine
1297
   # by issuing the CBR Refresh command by programming the OP field of the
1298
   # PSDMR register and writing 0xFF 8 times to an arbitrary address.
1299
   #-------------------------------------------------------------------------
1300
 
1301
   # Clear refresh enable bit (bit 1 = 0)
1302
   # Set OP mode to CBR Refresh (bits 2-4 = 001b)
1303
 
1304
   addis    r3,0,0x8B2E
1305
   ori      r3,r3,0xB452
1306
 
1307
   stw      r3,CYGARC_REG_IMM_PSDMR(r4)
1308
 
1309
   #------------------------------------------
1310
   # Loop 8 times, writing 0xFF to address 0
1311
   #------------------------------------------
1312
 
1313
   addi  r6,0,0x0008
1314
   mtspr CYGARC_REG_CTR,r6             # Load CTR with 8. The CTR special purpose
1315
                            # is spr 9
1316
 
1317
   addi  r3,0,0x00FF      # Load 0x000000FF into r3
1318
 
1319
write_loop:
1320
 
1321
   stb   r3,0(r0)         # Write 0xFF to address 0 - bits [24-31]
1322
 
1323
   bc    16,0,write_loop  # Decrement CTR, then branch if the decremented CTR
1324
                          # is not equal to 0
1325
 
1326
   #-------------------------------------------------------------------------
1327
   # Program the PSDMR again turning off refresh services and changing the
1328
   # SDRAM operation to "Mode Register Write". Then do a single write to an
1329
   # arbitrary location. The various fields that will be programmed in the
1330
   # mode register on the SDRAM were specified in fields of the PSDMR, like
1331
   # the BR (burst length) and the CL (CAS Latency) field.
1332
   #-------------------------------------------------------------------------
1333
 
1334
   # Clear refresh enable bit (bit 1 = 0)
1335
   # Set OP mode to Mode Register Write (bits 2-4 = 011b)
1336
 
1337
   addis    r3,0,0x9B2E
1338
   ori      r3,r3,0xB452
1339
 
1340
   stw      r3,CYGARC_REG_IMM_PSDMR(r4)
1341
 
1342
   addi     r3,0,0x00FF      # Load 0x000000FF into r3
1343
   stb      r3,0(r0)         # Write 0xFF to address 0 - bits [24-31]
1344
 
1345
   #-------------------------------------------------------------------------
1346
   # Program the PSDMR one last time turning on refresh services and changing
1347
   # the SDRAM operation to "Normal Operation".
1348
   #-------------------------------------------------------------------------
1349
 
1350
   # Set refresh enable bit (bit 1 = 1)
1351
   # Set OP mode to Normal Operation (bits 2-4 = 000b)
1352
 
1353
   addis    r3,0,0xC32E
1354
   ori      r3,r3,0xB452
1355
 
1356
   stw      r3,CYGARC_REG_IMM_PSDMR(r4)
1357
 
1358
   #----------------------------
1359
   # return from init_60x_sdram
1360
   #----------------------------
1361
 
1362
   bclr  20,0    # jump unconditionally to effective address in Link
1363
                 # register
1364
 
1365
init_user_leds:
1366
 
1367
   # Initialize Port A pins
1368
   # Pin 30-31 GPIO wires to RF board
1369
   # Pin 29 TS_RESET_L, output, Tiger Sharc Reset line, drive low on
1370
   #                    initialization.
1371
   # Pin 28 LB_ENB_L, output, Link Port Buffer enable, drive high on
1372
   #                  initialization.
1373
   # Pin 26-27 GPIO wires to RF board
1374
   # Pin 18-23 GPIO wires, one each to Tiger Sharc
1375
   # Pin 12-17 Interrupt wires to Sharc, output, drive high on
1376
   #                  initialization.
1377
 
1378
   # Set Port A pins 12-31 for general purpose, i.e., to 0
1379
   # Set Port A pins 12-17, 28, 29 (add more later) for output (set to 1)
1380
   #     for lines that we do not know, set to 0 (input)
1381
   # Set Port A output pins High or Low, as specified
1382
#define TS6_PPARA_INIT_MASK 0xFFF00000
1383
#define TS6_PDIRA_INIT_MASK 0x3003F000
1384
#define TS6_PDATA_INIT_MASK 0x1003F000
1385
 
1386
   # Initialize Port B Pins 4,5,6,7 general purpose IO
1387
   # Pin 4 LED 18, Red
1388
   # Pin 5 LED 18, Green
1389
   # Pin 6 LED 17, Red
1390
   # Pin 7 LED 17, Green
1391
 
1392
   mfspr    r30,CYGARC_REG_LR        # Save the Link Register value. The link registers
1393
                          # value will be restored so that this function
1394
                          # can return to the calling address.
1395
 
1396
   addis    r4,0,0x0471   # IMMR base addr = 0x04700000+10000. We
1397
                          # add 0x10000 because using relative addressing
1398
                          # in load and store instructions only allow a
1399
                          # offset from the base of +/-32767.
1400
 
1401
   addi     r6,0,0        # R6 = 0
1402
   lwz      r3,0x0D24(r4) # R3 = PPARB
1403
   rlwimi   r3,r6,0,4,7
1404
#   and      r3,r3,r6      # Clear bits 4,5,6,7
1405
   stw      r3,0x0D24(r4) # Store 0 to PPARB to set 4 bits to general
1406
                          # purpose.
1407
 
1408
   addis    r6,0,0x0F00   # R6 = 0x0F000000
1409
   lwz      r3,0x0D20(r4) # R3 = PDIRB
1410
   or       r3,r3,r6      # Set bits 4,5,6,7
1411
   stw      r3,0x0D20(r4) # Store r3 to PDIRB to set 4 bits as outputs.
1412
 
1413
   #-----------------------
1414
   # return from init_user_leds
1415
   #-----------------------
1416
   mtspr    CYGARC_REG_LR,r30      # restore original Link Register value
1417
 
1418
   bclr  20,0           # jump unconditionally to effective address in Link
1419
                        # register
1420
 
1421
 
1422
flash_leds_forever:
1423
   # This function assumes that the Port B registers have been properly
1424
   # initialized so the LEDs will function.  See init_user_leds.
1425
 
1426
   addis    r4,0,0x0471   # IMMR base addr = 0x04700000+10000. We
1427
                          # add 0x10000 because using relative addressing
1428
                          # in load and store instructions only allow a
1429
                          # offset from the base of +/-32767.
1430
 
1431
 
1432
 
1433
   addi     r3,0,0x000F      # R3 will hold value of LEDs, start with all off
1434
 
1435
flash_again:
1436
   #~~~~~~~~~~~~~~~~~~~~~~~~~~
1437
   # Load count of 0x0040000
1438
   #~~~~~~~~~~~~~~~~~~~~~~~~~~
1439
 
1440
        addis           r5,r0,4
1441
 
1442
   #~~~~~~~~~~~~~~~~~
1443
   # Delay Loop here
1444
   #~~~~~~~~~~~~~~~~~
1445
 
1446
check_count:
1447
 
1448
   #-------------------------
1449
   # while (count != 0)
1450
   #-------------------------
1451
 
1452
        cmpi    0,0,r5,0
1453
        bc              12,2,count_done   # if zero branch to count_done
1454
 
1455
   #-----------
1456
   # count--;
1457
   #-----------
1458
 
1459
        addi            r5,r5,-1
1460
        b               check_count
1461
 
1462
count_done:
1463
   #increment r3
1464
        addi            r3,r3,1
1465
        rlwinm          r6,r3,24,4,7 # left shift r3 by 24, mask r3 so
1466
                                     # so bits 4 -7 are all thats left,
1467
                                     # and store result in r6
1468
        stw         r6,0x0D30(r4)    # Store new value to PDATB Register
1469
        b           flash_again
1470
 
1471
 
1472
#ifdef CYG_HAL_STARTUP_ROM
1473
   # This routine will test the memory from address 0x0
1474
   # thru 0x03ffffff (64MByte) by writing the address to the address
1475
   # for all addresses, and then reading each of those values.
1476
   #
1477
   # Use two loops, the outer loop goes from 0 to 0x3ff and counts
1478
   # by 1.  The inner loop goes from 0 to 0xfffc and counts by 4.
1479
memory_test:
1480
 
1481
   #Turn on Green Led
1482
   # For TS6 board, LD17 will signal running status
1483
   # LD17 == GREEN ==> writing data to memory
1484
   # LD17 == RED   ==> reading data from memory and comparing
1485
   # LD17 == OFF   ==> test completed
1486
   # For TS6 board, LD18 will test status
1487
   # LD18 == GREEN ==> all memory location contained expected values
1488
   # LD18 == RED   ==> error reading memory location,
1489
   #                   r6  contains address and expected value
1490
   #                   r10 contains actual value read
1491
   # LD18 == OFF   ==> test not completed
1492
   #
1493
   # r23 will hold the largest memory value to test
1494
   # r29 will hold the smallest memory value (0x0 <= r29 < 0x10000)
1495
   # NOTE read the code to find out exactly how the test is run.
1496
   bl       init_user_leds
1497
 
1498
   addis     r23, 0, 0x0400   # Initialize r23 to 64 MBytes
1499
   addis     r29, 0, 0x0      # Initialize r29 to 0
1500
 
1501
   addis    r4,0,0x0471   # IMMR base addr = 0x04700000+10000. We
1502
                          # add 0x10000 because using relative addressing
1503
                          # in load and store instructions only allow a
1504
                          # offset from the base of +/-32767.
1505
   # LD18 off, LED17 Green
1506
   lwz      r3,0x0D30(r4) # r3 = PDATB value
1507
   addis    r5,0,0x0d00   # LD18 off, LED17 Green
1508
   rlwimi   r3,r5,0,4,7
1509
   stw      r3,0x0D30(r4)
1510
 
1511
   #addis    r3,0,0x0200   # r3 will hold the outer counter, start at 0x3ff0000
1512
   #addis    r9,0,0x0000   # r9 will hold the stop address
1513
 
1514
   mr        r3, r23       # r23 holds the start value, set with debugger
1515
   mr        r9, r29       # r29 holds the stop value, set with debugger
1516
 
1517
memwrite_loop1:
1518
   addis    r3,r3,-1      # subtract 0x10000 from r3
1519
   addis    r5,0,0x1      # r5 will hold inner counter, start at 0xfffc
1520
 
1521
   # generate the value to store in the address.  It is the value in r3
1522
   # shifted by 16 plus the vale in r5.
1523
 
1524
memwrite_loop2:
1525
   addi     r5,r5,-4      # subtract 1 from r5
1526
 
1527
   add      r6,r3,r5
1528
   stwx     r6,r5,r3      # Store the value at r6 in the memory addressed
1529
                          # by the sum of r3 and r5
1530
   cmpi     0,0,r5,0
1531
   bne      memwrite_loop2 # branch if r5 != 0
1532
 
1533
# Check if r3 is 0
1534
   cmp      0,0,r3,r9
1535
   bne      memwrite_loop1 # branch if r3 != 0
1536
 
1537
# Writing to memory complete, start reading and validating
1538
   # LD18 off, LED17 Red
1539
   lwz      r3,0x0D30(r4) # r3 = PDATB value
1540
   addis    r5,0,0x0e00   # LD18 off, LED17 Red
1541
   rlwimi   r3,r5,0,4,7
1542
   stw      r3,0x0D30(r4)
1543
 
1544
   #addis    r3,0,0x0200   # r3 will hold the outer counter, start at 0x3ff0000
1545
   #addis    r9,0,0x0000   # r9 will hold the stop address
1546
   mr        r3, r23       # r23 holds the start value, set with debugger
1547
   mr        r9, r29       # r29 holds the stop value, set with debugger
1548
 
1549
 
1550
memread_loop1:
1551
   addis    r3,r3,-1      # subtract 0x10000 from r3
1552
   addis    r5,0,0x1      # r5 will hold inner counter, start at 0xfffc
1553
 
1554
   # generate the value to store in the address.  It is the value in r3
1555
   # shifted by 16 plus the vale in r5.
1556
 
1557
memread_loop2:
1558
   addi     r5,r5,-4      # subtract 1 from r5
1559
 
1560
   add      r6,r3,r5
1561
   lwzx     r10,r5,r3     # Read the value into r10 from the memory addressed
1562
                          # by the sum of r3 and r5
1563
   cmpw     r6,r10        # compare values
1564
   bne      mem_error
1565
 
1566
   cmpi     0,0,r5,0
1567
   bne      memread_loop2 # branch if r5 != 0
1568
 
1569
# Check if r3 is 0
1570
   cmp      0,0,r3,r9
1571
   bne      memread_loop1 # branch if r3 != 0
1572
 
1573
 
1574
   # We get here if memory test passes
1575
   # LD18 Green, LED17 Off
1576
   lwz      r3,0x0D30(r4) # r3 = PDATB value
1577
   addis    r5,0,0x0700   # LD18 Green, LED17 Off
1578
   rlwimi   r3,r5,0,4,7
1579
   stw      r3,0x0D30(r4)
1580
 
1581
   addis    r7,0,0x0E00
1582
   stw      r7,0(r8)
1583
   b        branch_to_dot
1584
 
1585
mem_error:
1586
   # We get here if a memory error was detected
1587
   # LD18 Red, LED17 Off
1588
   lwz      r3,0x0D30(r4) # r3 = PDATB value
1589
   addis    r5,0,0x0b00   # LD18 off, LED17 Red
1590
   rlwimi   r3,r5,0,4,7
1591
   stw      r3,0x0D30(r4)
1592
#endif
1593
branch_to_dot:
1594
   b        branch_to_dot
1595
 
1596
 
1597
#------------------------------------------------------------------------------
1598
# end of ts6.S

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.