Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 Nobuhiro Iwamatsu |
| 3 | * Copyright (C) 2008 Renesas Solutions Corp. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 6 | */ |
| 7 | #include <config.h> |
| 8 | #include <version.h> |
| 9 | |
| 10 | #include <asm/processor.h> |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 11 | #include <asm/macro.h> |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 12 | |
| 13 | .global lowlevel_init |
| 14 | |
| 15 | .text |
| 16 | .align 2 |
| 17 | |
| 18 | lowlevel_init: |
| 19 | /* Cache setting */ |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 20 | write32 CCR1_A ,CCR1_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 21 | |
| 22 | /* ConfigurePortPins */ |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 23 | write16 PECRL3_A, PECRL3_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 24 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 25 | write16 PCCRL4_A, PCCRL4_D0 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 26 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 27 | write16 PECRL4_A, PECRL4_D0 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 28 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 29 | write16 PEIORL_A, PEIORL_D0 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 30 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 31 | write16 PCIORL_A, PCIORL_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 32 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 33 | write16 PFCRH2_A, PFCRH2_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 34 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 35 | write16 PFCRH3_A, PFCRH3_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 36 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 37 | write16 PFCRH1_A, PFCRH1_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 38 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 39 | write16 PFIORH_A, PFIORH_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 40 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 41 | write16 PECRL1_A, PECRL1_D0 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 42 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 43 | write16 PEIORL_A, PEIORL_D1 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 44 | |
| 45 | /* Configure Operating Frequency */ |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 46 | write16 WTCSR_A, WTCSR_D0 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 47 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 48 | write16 WTCSR_A, WTCSR_D1 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 49 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 50 | write16 WTCNT_A, WTCNT_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 51 | |
| 52 | /* Set clock mode*/ |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 53 | write16 FRQCR_A, FRQCR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 54 | |
| 55 | /* Configure Bus And Memory */ |
| 56 | init_bsc_cs0: |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 57 | write16 PCCRL4_A, PCCRL4_D1 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 58 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 59 | write16 PECRL1_A, PECRL1_D1 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 60 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 61 | write32 CMNCR_A, CMNCR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 62 | |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 63 | write32 CS0BCR_A, CS0BCR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 64 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 65 | write32 CS0WCR_A, CS0WCR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 66 | |
| 67 | init_bsc_cs1: |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 68 | write16 PECRL4_A, PECRL4_D1 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 69 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 70 | write32 CS1WCR_A, CS1WCR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 71 | |
| 72 | init_sdram: |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 73 | write16 PCCRL2_A, PCCRL2_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 74 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 75 | write16 PCCRL4_A, PCCRL4_D2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 76 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 77 | write16 PCCRL1_A, PCCRL1_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 78 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 79 | write16 PCCRL3_A, PCCRL3_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 80 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 81 | write32 CS3BCR_A, CS3BCR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 82 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 83 | write32 CS3WCR_A, CS3WCR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 84 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 85 | write32 SDCR_A, SDCR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 86 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 87 | write32 RTCOR_A, RTCOR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 88 | |
Jean-Christophe PLAGNIOL-VILLARD | f7e78f3 | 2008-12-20 19:29:49 +0100 | [diff] [blame] | 89 | write32 RTCSR_A, RTCSR_D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 90 | |
| 91 | /* wait 200us */ |
Jean-Christophe PLAGNIOL-VILLARD | e443077 | 2008-12-20 19:29:48 +0100 | [diff] [blame] | 92 | mov.l REPEAT_D, r3 |
| 93 | mov #0, r2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 94 | repeat0: |
Jean-Christophe PLAGNIOL-VILLARD | e443077 | 2008-12-20 19:29:48 +0100 | [diff] [blame] | 95 | add #1, r2 |
| 96 | cmp/hs r3, r2 |
| 97 | bf repeat0 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 98 | nop |
| 99 | |
Jean-Christophe PLAGNIOL-VILLARD | e443077 | 2008-12-20 19:29:48 +0100 | [diff] [blame] | 100 | mov.l SDRAM_MODE, r1 |
| 101 | mov #0, r0 |
| 102 | mov.l r0, @r1 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 103 | |
| 104 | nop |
| 105 | rts |
| 106 | |
| 107 | .align 4 |
| 108 | |
| 109 | CCR1_A: .long CCR1 |
| 110 | CCR1_D: .long 0x0000090B |
| 111 | PCCRL4_A: .long 0xFFFE3910 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 112 | PCCRL4_D0: .word 0x0000 |
| 113 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 114 | PECRL4_A: .long 0xFFFE3A10 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 115 | PECRL4_D0: .word 0x0000 |
| 116 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 117 | PECRL3_A: .long 0xFFFE3A12 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 118 | PECRL3_D: .word 0x0000 |
| 119 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 120 | PEIORL_A: .long 0xFFFE3A06 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 121 | PEIORL_D0: .word 0x1C00 |
| 122 | PEIORL_D1: .word 0x1C02 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 123 | PCIORL_A: .long 0xFFFE3906 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 124 | PCIORL_D: .word 0x4000 |
| 125 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 126 | PFCRH2_A: .long 0xFFFE3A8C |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 127 | PFCRH2_D: .word 0x0000 |
| 128 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 129 | PFCRH3_A: .long 0xFFFE3A8A |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 130 | PFCRH3_D: .word 0x0000 |
| 131 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 132 | PFCRH1_A: .long 0xFFFE3A8E |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 133 | PFCRH1_D: .word 0x0000 |
| 134 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 135 | PFIORH_A: .long 0xFFFE3A84 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 136 | PFIORH_D: .word 0x0729 |
| 137 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 138 | PECRL1_A: .long 0xFFFE3A16 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 139 | PECRL1_D0: .word 0x0033 |
| 140 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 141 | |
| 142 | |
| 143 | WTCSR_A: .long 0xFFFE0000 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 144 | WTCSR_D0: .word 0xA518 |
| 145 | WTCSR_D1: .word 0xA51D |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 146 | WTCNT_A: .long 0xFFFE0002 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 147 | WTCNT_D: .word 0x5A84 |
| 148 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 149 | FRQCR_A: .long 0xFFFE0010 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 150 | FRQCR_D: .word 0x0104 |
| 151 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 152 | |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 153 | PCCRL4_D1: .word 0x0010 |
| 154 | PECRL1_D1: .word 0x0133 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 155 | |
| 156 | CMNCR_A: .long 0xFFFC0000 |
| 157 | CMNCR_D: .long 0x00001810 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 158 | CS0BCR_A: .long 0xFFFC0004 |
| 159 | CS0BCR_D: .long 0x10000400 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 160 | CS0WCR_A: .long 0xFFFC0028 |
| 161 | CS0WCR_D: .long 0x00000B41 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 162 | PECRL4_D1: .word 0x0100 |
| 163 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 164 | CS1WCR_A: .long 0xFFFC002C |
| 165 | CS1WCR_D: .long 0x00000B01 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 166 | PCCRL4_D2: .word 0x0011 |
| 167 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 168 | PCCRL3_A: .long 0xFFFE3912 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 169 | PCCRL3_D: .word 0x0011 |
| 170 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 171 | PCCRL2_A: .long 0xFFFE3914 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 172 | PCCRL2_D: .word 0x1111 |
| 173 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 174 | PCCRL1_A: .long 0xFFFE3916 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 175 | PCCRL1_D: .word 0x1010 |
Phil Edworthy | c4f07be | 2011-05-31 01:51:42 -0700 | [diff] [blame] | 176 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 177 | PDCRL4_A: .long 0xFFFE3990 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 178 | PDCRL4_D: .word 0x0011 |
| 179 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 180 | PDCRL3_A: .long 0xFFFE3992 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 181 | PDCRL3_D: .word 0x00011 |
| 182 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 183 | PDCRL2_A: .long 0xFFFE3994 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 184 | PDCRL2_D: .word 0x1111 |
| 185 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 186 | PDCRL1_A: .long 0xFFFE3996 |
Nobuhiro Iwamatsu | ed56fb1 | 2010-07-22 11:19:17 +0900 | [diff] [blame] | 187 | PDCRL1_D: .word 0x1000 |
| 188 | .align 2 |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 189 | CS3BCR_A: .long 0xFFFC0010 |
| 190 | CS3BCR_D: .long 0x00004400 |
| 191 | CS3WCR_A: .long 0xFFFC0034 |
| 192 | CS3WCR_D: .long 0x00002892 |
| 193 | SDCR_A: .long 0xFFFC004C |
| 194 | SDCR_D: .long 0x00000809 |
| 195 | RTCOR_A: .long 0xFFFC0058 |
| 196 | RTCOR_D: .long 0xA55A0041 |
| 197 | RTCSR_A: .long 0xFFFC0050 |
| 198 | RTCSR_D: .long 0xa55a0010 |
| 199 | |
Nobuhiro Iwamatsu | c655fad | 2008-08-31 23:02:04 +0900 | [diff] [blame] | 200 | SDRAM_MODE: .long 0xFFFC5040 |
| 201 | REPEAT_D: .long 0x00009C40 |