~ubuntu-branches/ubuntu/maverick/uboot-imx/maverick

« back to all changes in this revision

Viewing changes to cpu/ppc4xx/start.S

  • Committer: Bazaar Package Importer
  • Author(s): Oliver Grawert
  • Date: 2010-01-20 15:41:26 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100120154126-7bha1jeyjegu7xm5
Tags: 2009.08+really2009.01-0ubuntu1
* revert to the 2009.01 upstream version, 2009.08 has still to 
  many work in progress items in the freescale patchset (MMC and NIC
  dont work at all)
* add the latest patchset from freescale for 2009.01
* add 1002_enable_hush_shell_and_ext2.patch to enable hush shell and ext2 
* add 1003_fix_board_revision_numbers to make sure babbage 2.5 boards have 
  revision 51120 and babbage 3.0 boards have revision 51130 properly set in 
  their cpuinfo

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 * MA 02111-1307 USA
26
26
 */
27
27
/*------------------------------------------------------------------------------+
28
 
 *   This source code is dual-licensed.  You may use it under the terms of the
29
 
 *   GNU General Public License version 2, or under the license below.
30
28
 *
31
29
 *       This source code has been made available to you by IBM on an AS-IS
32
30
 *       basis.  Anyone receiving this source is licensed under IBM
259
257
        bl      board_init_f
260
258
#endif
261
259
 
262
 
#if defined(CONFIG_SYS_RAMBOOT)
263
 
        /*
264
 
         * 4xx RAM-booting U-Boot image is started from offset 0
265
 
         */
266
 
        .text
267
 
        bl      _start_440
268
 
#endif
269
 
 
270
260
/*
271
261
 * 440 Startup -- on reset only the top 4k of the effective
272
262
 * address space is mapped in by an entry in the instruction
299
289
        | Core bug fix.  Clear the esr
300
290
        +-----------------------------------------------------------------*/
301
291
        li      r0,0
302
 
        mtspr   SPRN_ESR,r0
 
292
        mtspr   esr,r0
303
293
        /*----------------------------------------------------------------*/
304
294
        /* Clear and set up some registers. */
305
295
        /*----------------------------------------------------------------*/
307
297
        dccci   r0,r0           /* NOTE: operands not used for 440 */
308
298
        sync
309
299
        li      r0,0
310
 
        mtspr   SPRN_SRR0,r0
311
 
        mtspr   SPRN_SRR1,r0
312
 
        mtspr   SPRN_CSRR0,r0
313
 
        mtspr   SPRN_CSRR1,r0
 
300
        mtspr   srr0,r0
 
301
        mtspr   srr1,r0
 
302
        mtspr   csrr0,r0
 
303
        mtspr   csrr1,r0
314
304
        /* NOTE: 440GX adds machine check status regs */
315
305
#if defined(CONFIG_440) && !defined(CONFIG_440GP)
316
 
        mtspr   SPRN_MCSRR0,r0
317
 
        mtspr   SPRN_MCSRR1,r0
318
 
        mfspr   r1,SPRN_MCSR
319
 
        mtspr   SPRN_MCSR,r1
 
306
        mtspr   mcsrr0,r0
 
307
        mtspr   mcsrr1,r0
 
308
        mfspr   r1,mcsr
 
309
        mtspr   mcsr,r1
320
310
#endif
321
311
 
322
312
        /*----------------------------------------------------------------*/
328
318
        */
329
319
        lis     r1,0x0030       /* store gathering & broadcast disable */
330
320
        ori     r1,r1,0x6000    /* cache touch */
331
 
        mtspr   SPRN_CCR0,r1
 
321
        mtspr   ccr0,r1
332
322
 
333
323
        /*----------------------------------------------------------------*/
334
324
        /* Initialize debug */
335
325
        /*----------------------------------------------------------------*/
336
 
        mfspr   r1,SPRN_DBCR0
 
326
        mfspr   r1,dbcr0
337
327
        andis.  r1, r1, 0x8000  /* test DBCR0[EDM] bit                  */
338
328
        bne     skip_debug_init /* if set, don't clear debug register   */
339
 
        mtspr   SPRN_DBCR0,r0
340
 
        mtspr   SPRN_DBCR1,r0
341
 
        mtspr   SPRN_DBCR2,r0
342
 
        mtspr   SPRN_IAC1,r0
343
 
        mtspr   SPRN_IAC2,r0
344
 
        mtspr   SPRN_IAC3,r0
345
 
        mtspr   SPRN_DAC1,r0
346
 
        mtspr   SPRN_DAC2,r0
347
 
        mtspr   SPRN_DVC1,r0
348
 
        mtspr   SPRN_DVC2,r0
 
329
        mtspr   dbcr0,r0
 
330
        mtspr   dbcr1,r0
 
331
        mtspr   dbcr2,r0
 
332
        mtspr   iac1,r0
 
333
        mtspr   iac2,r0
 
334
        mtspr   iac3,r0
 
335
        mtspr   dac1,r0
 
336
        mtspr   dac2,r0
 
337
        mtspr   dvc1,r0
 
338
        mtspr   dvc2,r0
349
339
 
350
 
        mfspr   r1,SPRN_DBSR
351
 
        mtspr   SPRN_DBSR,r1    /* Clear all valid bits */
 
340
        mfspr   r1,dbsr
 
341
        mtspr   dbsr,r1         /* Clear all valid bits */
352
342
skip_debug_init:
353
343
 
354
344
#if defined (CONFIG_440SPE)
366
356
        | j. TCS:    Timebase increments from CPU clock.
367
357
        +-----------------------------------------------------------------*/
368
358
        li      r0,0
369
 
        mtspr   SPRN_CCR1, r0
 
359
        mtspr   ccr1, r0
370
360
 
371
361
        /*----------------------------------------------------------------+
372
362
        | Reset the timebase.
373
363
        | The previous write to CCR1 sets the timebase source.
374
364
        +-----------------------------------------------------------------*/
375
 
        mtspr   SPRN_TBWL, r0
376
 
        mtspr   SPRN_TBWU, r0
 
365
        mtspr   tbl, r0
 
366
        mtspr   tbu, r0
377
367
#endif
378
368
 
379
369
        /*----------------------------------------------------------------*/
380
370
        /* Setup interrupt vectors */
381
371
        /*----------------------------------------------------------------*/
382
 
        mtspr   SPRN_IVPR,r0            /* Vectors start at 0x0000_0000 */
 
372
        mtspr   ivpr,r0         /* Vectors start at 0x0000_0000 */
383
373
        li      r1,0x0100
384
 
        mtspr   SPRN_IVOR0,r1   /* Critical input */
 
374
        mtspr   ivor0,r1        /* Critical input */
385
375
        li      r1,0x0200
386
 
        mtspr   SPRN_IVOR1,r1   /* Machine check */
 
376
        mtspr   ivor1,r1        /* Machine check */
387
377
        li      r1,0x0300
388
 
        mtspr   SPRN_IVOR2,r1   /* Data storage */
 
378
        mtspr   ivor2,r1        /* Data storage */
389
379
        li      r1,0x0400
390
 
        mtspr   SPRN_IVOR3,r1   /* Instruction storage */
 
380
        mtspr   ivor3,r1        /* Instruction storage */
391
381
        li      r1,0x0500
392
 
        mtspr   SPRN_IVOR4,r1   /* External interrupt */
 
382
        mtspr   ivor4,r1        /* External interrupt */
393
383
        li      r1,0x0600
394
 
        mtspr   SPRN_IVOR5,r1   /* Alignment */
 
384
        mtspr   ivor5,r1        /* Alignment */
395
385
        li      r1,0x0700
396
 
        mtspr   SPRN_IVOR6,r1   /* Program check */
 
386
        mtspr   ivor6,r1        /* Program check */
397
387
        li      r1,0x0800
398
 
        mtspr   SPRN_IVOR7,r1   /* Floating point unavailable */
 
388
        mtspr   ivor7,r1        /* Floating point unavailable */
399
389
        li      r1,0x0c00
400
 
        mtspr   SPRN_IVOR8,r1   /* System call */
 
390
        mtspr   ivor8,r1        /* System call */
401
391
        li      r1,0x0a00
402
 
        mtspr   SPRN_IVOR9,r1   /* Auxiliary Processor unavailable */
 
392
        mtspr   ivor9,r1        /* Auxiliary Processor unavailable */
403
393
        li      r1,0x0900
404
 
        mtspr   SPRN_IVOR10,r1  /* Decrementer */
 
394
        mtspr   ivor10,r1       /* Decrementer */
405
395
        li      r1,0x1300
406
 
        mtspr   SPRN_IVOR13,r1  /* Data TLB error */
 
396
        mtspr   ivor13,r1       /* Data TLB error */
407
397
        li      r1,0x1400
408
 
        mtspr   SPRN_IVOR14,r1  /* Instr TLB error */
 
398
        mtspr   ivor14,r1       /* Instr TLB error */
409
399
        li      r1,0x2000
410
 
        mtspr   SPRN_IVOR15,r1  /* Debug */
 
400
        mtspr   ivor15,r1       /* Debug */
411
401
 
412
402
        /*----------------------------------------------------------------*/
413
403
        /* Configure cache regions  */
414
404
        /*----------------------------------------------------------------*/
415
 
        mtspr   SPRN_INV0,r0
416
 
        mtspr   SPRN_INV1,r0
417
 
        mtspr   SPRN_INV2,r0
418
 
        mtspr   SPRN_INV3,r0
419
 
        mtspr   SPRN_DNV0,r0
420
 
        mtspr   SPRN_DNV1,r0
421
 
        mtspr   SPRN_DNV2,r0
422
 
        mtspr   SPRN_DNV3,r0
423
 
        mtspr   SPRN_ITV0,r0
424
 
        mtspr   SPRN_ITV1,r0
425
 
        mtspr   SPRN_ITV2,r0
426
 
        mtspr   SPRN_ITV3,r0
427
 
        mtspr   SPRN_DTV0,r0
428
 
        mtspr   SPRN_DTV1,r0
429
 
        mtspr   SPRN_DTV2,r0
430
 
        mtspr   SPRN_DTV3,r0
 
405
        mtspr   inv0,r0
 
406
        mtspr   inv1,r0
 
407
        mtspr   inv2,r0
 
408
        mtspr   inv3,r0
 
409
        mtspr   dnv0,r0
 
410
        mtspr   dnv1,r0
 
411
        mtspr   dnv2,r0
 
412
        mtspr   dnv3,r0
 
413
        mtspr   itv0,r0
 
414
        mtspr   itv1,r0
 
415
        mtspr   itv2,r0
 
416
        mtspr   itv3,r0
 
417
        mtspr   dtv0,r0
 
418
        mtspr   dtv1,r0
 
419
        mtspr   dtv2,r0
 
420
        mtspr   dtv3,r0
431
421
 
432
422
        /*----------------------------------------------------------------*/
433
423
        /* Cache victim limits */
436
426
        */
437
427
        lis     r1,0x0001
438
428
        ori     r1,r1,0xf800
439
 
        mtspr   SPRN_IVLIM,r1
440
 
        mtspr   SPRN_DVLIM,r1
 
429
        mtspr   ivlim,r1
 
430
        mtspr   dvlim,r1
441
431
 
442
432
        /*----------------------------------------------------------------+
443
433
        |Initialize MMUCR[STID] = 0.
444
434
        +-----------------------------------------------------------------*/
445
 
        mfspr   r0,SPRN_MMUCR
 
435
        mfspr   r0,mmucr
446
436
        addis   r1,0,0xFFFF
447
437
        ori     r1,r1,0xFF00
448
438
        and     r0,r0,r1
449
 
        mtspr   SPRN_MMUCR,r0
 
439
        mtspr   mmucr,r0
450
440
 
451
441
        /*----------------------------------------------------------------*/
452
442
        /* Clear all TLB entries -- TID = 0, TS = 0 */
453
443
        /*----------------------------------------------------------------*/
454
444
        addis   r0,0,0x0000
455
 
#ifdef CONFIG_SYS_RAMBOOT
456
 
        li      r4,0            /* Start with TLB #0 */
457
 
#else
458
 
        li      r4,1            /* Start with TLB #1 */
459
 
#endif
460
 
        li      r1,64           /* 64 TLB entries */
461
 
        sub     r1,r1,r4        /* calculate last TLB # */
 
445
        li      r1,0x003f       /* 64 TLB entries */
462
446
        mtctr   r1
463
 
rsttlb:
464
 
#ifdef CONFIG_SYS_RAMBOOT
465
 
        tlbre   r3,r4,0         /* Read contents from TLB word #0 to get EPN */
466
 
        rlwinm. r3,r3,0,0xfffffc00      /* Mask EPN */
467
 
        beq     tlbnxt          /* Skip EPN=0 TLB, this is the SDRAM TLB */
468
 
#endif
469
 
        tlbwe   r0,r4,0         /* Invalidate all entries (V=0)*/
470
 
        tlbwe   r0,r4,1
471
 
        tlbwe   r0,r4,2
472
 
tlbnxt: addi    r4,r4,1         /* Next TLB */
 
447
rsttlb: tlbwe   r0,r1,0x0000    /* Invalidate all entries (V=0)*/
 
448
        tlbwe   r0,r1,0x0001
 
449
        tlbwe   r0,r1,0x0002
 
450
        subi    r1,r1,0x0001
473
451
        bdnz    rsttlb
474
452
 
475
453
        /*----------------------------------------------------------------*/
498
476
        li      r4,0            /* TLB # */
499
477
 
500
478
        addi    r5,r5,-4
501
 
1:
502
 
#ifdef CONFIG_SYS_RAMBOOT
503
 
        tlbre   r3,r4,0         /* Read contents from TLB word #0 */
504
 
        rlwinm. r3,r3,0,0x00000200      /* Mask V (valid) bit */
505
 
        bne     tlbnx2          /* Skip V=1 TLB, this is the SDRAM TLB */
506
 
#endif
507
 
        lwzu    r0,4(r5)
 
479
1:      lwzu    r0,4(r5)
508
480
        cmpwi   r0,0
509
481
        beq     2f              /* 0 marks end */
510
482
        lwzu    r1,4(r5)
512
484
        tlbwe   r0,r4,0         /* TLB Word 0 */
513
485
        tlbwe   r1,r4,1         /* TLB Word 1 */
514
486
        tlbwe   r2,r4,2         /* TLB Word 2 */
515
 
tlbnx2: addi    r4,r4,1         /* Next TLB */
 
487
        addi    r4,r4,1         /* Next TLB */
516
488
        bdnz    1b
517
489
 
518
490
        /*----------------------------------------------------------------*/
523
495
        b       _start
524
496
 
525
497
3:      li      r0,0
526
 
        mtspr   SPRN_SRR1,r0            /* Keep things disabled for now */
 
498
        mtspr   srr1,r0         /* Keep things disabled for now */
527
499
        mflr    r1
528
 
        mtspr   SPRN_SRR0,r1
 
500
        mtspr   srr0,r1
529
501
        rfi
530
502
#endif /* CONFIG_440 */
531
503
 
629
601
        /*----------------------------------------------------------------*/
630
602
        li      r0,0x0000
631
603
        lis     r1,0xffff
632
 
        mtspr   SPRN_DEC,r0                     /* prevent dec exceptions */
633
 
        mtspr   SPRN_TBWL,r0                    /* prevent fit & wdt exceptions */
634
 
        mtspr   SPRN_TBWU,r0
635
 
        mtspr   SPRN_TSR,r1                     /* clear all timer exception status */
636
 
        mtspr   SPRN_TCR,r0                     /* disable all */
637
 
        mtspr   SPRN_ESR,r0                     /* clear exception syndrome register */
 
604
        mtspr   dec,r0                  /* prevent dec exceptions */
 
605
        mtspr   tbl,r0                  /* prevent fit & wdt exceptions */
 
606
        mtspr   tbu,r0
 
607
        mtspr   tsr,r1                  /* clear all timer exception status */
 
608
        mtspr   tcr,r0                  /* disable all */
 
609
        mtspr   esr,r0                  /* clear exception syndrome register */
638
610
        mtxer   r0                      /* clear integer exception register */
639
611
 
640
612
        /*----------------------------------------------------------------*/
645
617
#if defined(CONFIG_SYS_INIT_DBCR)
646
618
        lis     r1,0xffff
647
619
        ori     r1,r1,0xffff
648
 
        mtspr   SPRN_DBSR,r1                    /* Clear all status bits */
 
620
        mtspr   dbsr,r1                 /* Clear all status bits */
649
621
        lis     r0,CONFIG_SYS_INIT_DBCR@h
650
622
        ori     r0,r0,CONFIG_SYS_INIT_DBCR@l
651
 
        mtspr   SPRN_DBCR0,r0
 
623
        mtspr   dbcr0,r0
652
624
        isync
653
625
#endif
654
626
 
687
659
        /* 8. set TFLOOR/NFLOOR to 8 (-> 8*16*32 bytes locked -> 4k) */
688
660
        lis     r1,0x0201
689
661
        ori     r1,r1,0xf808
690
 
        mtspr   SPRN_DVLIM,r1
 
662
        mtspr   dvlim,r1
691
663
        lis     r1,0x0808
692
664
        ori     r1,r1,0x0808
693
 
        mtspr   SPRN_DNV0,r1
694
 
        mtspr   SPRN_DNV1,r1
695
 
        mtspr   SPRN_DNV2,r1
696
 
        mtspr   SPRN_DNV3,r1
697
 
        mtspr   SPRN_DTV0,r1
698
 
        mtspr   SPRN_DTV1,r1
699
 
        mtspr   SPRN_DTV2,r1
700
 
        mtspr   SPRN_DTV3,r1
 
665
        mtspr   dnv0,r1
 
666
        mtspr   dnv1,r1
 
667
        mtspr   dnv2,r1
 
668
        mtspr   dnv3,r1
 
669
        mtspr   dtv0,r1
 
670
        mtspr   dtv1,r1
 
671
        mtspr   dtv2,r1
 
672
        mtspr   dtv3,r1
701
673
        msync
702
674
        isync
703
675
#endif /* CONFIG_SYS_INIT_RAM_DCACHE */
816
788
        /* Set up some machine state registers. */
817
789
        /*----------------------------------------------------------------------- */
818
790
        addi    r0,r0,0x0000            /* initialize r0 to zero */
819
 
        mtspr   SPRN_ESR,r0             /* clear Exception Syndrome Reg */
 
791
        mtspr   esr,r0                  /* clear Exception Syndrome Reg */
820
792
        mttcr   r0                      /* timer control register */
821
793
        mtexier r0                      /* disable all interrupts */
822
794
        addis   r4,r0,0xFFFF            /* set r4 to 0xFFFFFFFF (status in the */
926
898
        /*----------------------------------------------------------------------- */
927
899
        addi    r4,r0,0x0000
928
900
#if !defined(CONFIG_405EX)
929
 
        mtspr   SPRN_SGR,r4
 
901
        mtspr   sgr,r4
930
902
#else
931
903
        /*
932
904
         * On 405EX, completely clearing the SGR leads to PPC hangup
935
907
         */
936
908
        lis     r3,0x0000
937
909
        ori     r3,r3,0x7FFC
938
 
        mtspr   SPRN_SGR,r3
 
910
        mtspr   sgr,r3
939
911
#endif
940
 
        mtspr   SPRN_DCWR,r4
 
912
        mtspr   dcwr,r4
941
913
        mtesr   r4                      /* clear Exception Syndrome Reg */
942
914
        mttcr   r4                      /* clear Timer Control Reg */
943
915
        mtxer   r4                      /* clear Fixed-Point Exception Reg */
1273
1245
        REST_GPR(31, r1)
1274
1246
        lwz     r2,_NIP(r1)     /* Restore environment */
1275
1247
        lwz     r0,_MSR(r1)
1276
 
        mtspr   SPRN_CSRR0,r2
1277
 
        mtspr   SPRN_CSRR1,r0
 
1248
        mtspr   csrr0,r2
 
1249
        mtspr   csrr1,r0
1278
1250
        lwz     r0,GPR0(r1)
1279
1251
        lwz     r2,GPR2(r1)
1280
1252
        lwz     r1,GPR1(r1)
1304
1276
        REST_GPR(31, r1)
1305
1277
        lwz     r2,_NIP(r1)     /* Restore environment */
1306
1278
        lwz     r0,_MSR(r1)
1307
 
        mtspr   SPRN_MCSRR0,r2
1308
 
        mtspr   SPRN_MCSRR1,r0
 
1279
        mtspr   mcsrr0,r2
 
1280
        mtspr   mcsrr1,r0
1309
1281
        lwz     r0,GPR0(r1)
1310
1282
        lwz     r2,GPR2(r1)
1311
1283
        lwz     r1,GPR1(r1)
1455
1427
        /* set TFLOOR/NFLOOR to 0 again */
1456
1428
        lis     r6,0x0001
1457
1429
        ori     r6,r6,0xf800
1458
 
        mtspr   SPRN_DVLIM,r6
 
1430
        mtspr   dvlim,r6
1459
1431
        lis     r6,0x0000
1460
1432
        ori     r6,r6,0x0000
1461
 
        mtspr   SPRN_DNV0,r6
1462
 
        mtspr   SPRN_DNV1,r6
1463
 
        mtspr   SPRN_DNV2,r6
1464
 
        mtspr   SPRN_DNV3,r6
1465
 
        mtspr   SPRN_DTV0,r6
1466
 
        mtspr   SPRN_DTV1,r6
1467
 
        mtspr   SPRN_DTV2,r6
1468
 
        mtspr   SPRN_DTV3,r6
 
1433
        mtspr   dnv0,r6
 
1434
        mtspr   dnv1,r6
 
1435
        mtspr   dnv2,r6
 
1436
        mtspr   dnv3,r6
 
1437
        mtspr   dtv0,r6
 
1438
        mtspr   dtv1,r6
 
1439
        mtspr   dtv2,r6
 
1440
        mtspr   dtv3,r6
1469
1441
        msync
1470
1442
        isync
1471
1443
#endif /* CONFIG_SYS_INIT_RAM_DCACHE */
1485
1457
        isync
1486
1458
 
1487
1459
        /* Clear all potential pending exceptions */
1488
 
        mfspr   r1,SPRN_MCSR
1489
 
        mtspr   SPRN_MCSR,r1
 
1460
        mfspr   r1,mcsr
 
1461
        mtspr   mcsr,r1
1490
1462
#ifdef CONFIG_SYS_TLB_FOR_BOOT_FLASH
1491
1463
        addi    r1,r0,CONFIG_SYS_TLB_FOR_BOOT_FLASH     /* Use defined TLB */
1492
1464
#else
1730
1702
__440_msr_set:
1731
1703
        addi    r7,r0,0x1000            /* set ME bit (Machine Exceptions) */
1732
1704
        oris    r7,r7,0x0002            /* set CE bit (Critical Exceptions) */
1733
 
        mtspr   SPRN_SRR1,r7
 
1705
        mtspr   srr1,r7
1734
1706
        mflr    r7
1735
 
        mtspr   SPRN_SRR0,r7
 
1707
        mtspr   srr0,r7
1736
1708
        rfi
1737
1709
__440_msr_continue:
1738
1710
#endif
2028
2000
! Output r3 = none
2029
2001
!-----------------------------------------------------------------------------
2030
2002
*/
2031
 
        .globl  pll_write
2032
2003
pll_write:
2033
2004
        mfdcr  r5, CPC0_UCR
2034
2005
        andis. r5,r5,0xFFFF
2066
2037
         * Not sure if this is needed...
2067
2038
         */
2068
2039
        addis r3,0,0x1000
2069
 
        mtspr SPRN_DBCR0,r3             /* This will cause a CPU core reset, and */
 
2040
        mtspr dbcr0,r3                  /* This will cause a CPU core reset, and */
2070
2041
                                        /* execution will continue from the poweron */
2071
2042
                                        /* vector of 0xfffffffc */
2072
2043
#endif /* CONFIG_405EP */