wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
| 9 | * Yoo. Jonghoon, IPone, yooth@ipone.co.kr |
wdenk | 3bac351 | 2003-03-12 10:41:04 +0000 | [diff] [blame] | 10 | * U-Boot port on RPXlite board |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 11 | * |
| 12 | * DRAM related UPMA register values are modified. |
| 13 | * See RPXLite engineering note : 50MHz/60ns - UPM RAM WORDS |
| 14 | */ |
| 15 | |
| 16 | #include <common.h> |
| 17 | #include "mpc8xx.h" |
| 18 | |
| 19 | /* ------------------------------------------------------------------------- */ |
| 20 | |
| 21 | static long int dram_size (void); |
| 22 | |
| 23 | /* ------------------------------------------------------------------------- */ |
| 24 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 25 | #define MBYTE (1024*1024) |
| 26 | #define DRAM_DELAY 0x00000379 /* DRAM delay count */ |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 27 | #define _NOT_USED_ 0xFFFFCC25 |
| 28 | |
| 29 | const uint sdram_table[] = |
| 30 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 31 | /* single read. (offset 0 in upm RAM) */ |
| 32 | 0x1F07D004, 0xEEAEE004, 0x11ADD004, 0xEFBBA000, |
| 33 | 0x1FF75447, 0x1FF77C34, 0xEFEABC34, 0x1FB57C35, |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 34 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 35 | /* burst read. (Offset 8 in upm RAM) */ |
| 36 | 0x1F07D004, 0xEEAEE004, 0x00ADC004, 0x00AFC000, |
| 37 | 0x00AFC000, 0x01AFC000, 0x0FBB8000, 0x1FF75447, |
| 38 | 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, |
| 39 | 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 40 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 41 | /* single write. (Offset 0x18 in upm RAM) */ |
| 42 | 0x1F27D004, 0xEEAEA000, 0x01B90004, 0x1FF75447, |
| 43 | 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 44 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 45 | /* burst write. (Offset 0x20 in upm RAM) */ |
| 46 | 0x1F07D004, 0xEEAEA000, 0x00AD4000, 0x00AFC000, |
| 47 | 0x00AFC000, 0x01BB8004, 0x1FF75447, 0xFFFFFFFF, |
| 48 | 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, |
| 49 | 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 50 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 51 | /* Refresh cycle, offset 0x30 */ |
| 52 | 0x1FF5DC84, 0xFFFFFC04, 0xFFFFFC04, 0xFFFFFC04, |
| 53 | 0xFFFFFC84, 0xFFFFFC07, 0xFFFFFFFF, 0xFFFFFFFF, |
| 54 | 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 55 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 56 | /* Exception, 0ffset 0x3C */ |
| 57 | 0x7FFFFC07, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 58 | }; |
| 59 | /* ------------------------------------------------------------------------- */ |
| 60 | |
| 61 | |
| 62 | /* |
| 63 | * Check Board Identity: |
| 64 | * |
| 65 | * Return 1 for now. |
| 66 | * |
| 67 | */ |
| 68 | |
| 69 | int checkboard (void) |
| 70 | { |
| 71 | printf("Marel V37\n") ; |
| 72 | return (0) ; |
| 73 | } |
| 74 | |
| 75 | /* ------------------------------------------------------------------------- */ |
| 76 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 77 | phys_size_t initdram (int board_type) |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 78 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 79 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 80 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 81 | unsigned long temp; |
| 82 | volatile int delay_cnt; |
| 83 | long int ramsize; |
| 84 | |
| 85 | ramsize = dram_size(); |
| 86 | |
| 87 | /* Refresh clock prescalar */ |
| 88 | memctl->memc_mptpr = 0x400 ; |
| 89 | |
| 90 | if( ramsize == 32*MBYTE ) |
| 91 | temp = 0xd0904110; |
| 92 | else /* 16MB */ |
| 93 | temp = 0xd0802110; |
| 94 | |
| 95 | memctl->memc_mbmr = temp; |
| 96 | |
| 97 | upmconfig(UPMB, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint)); |
| 98 | |
| 99 | /* Map controller banks 2 to the SDRAM bank */ |
| 100 | memctl->memc_or2 = 0xA00 | (0 - ramsize); |
| 101 | memctl->memc_br2 = 0xC1; |
| 102 | |
| 103 | memctl->memc_mbmr = temp | 0x08; |
| 104 | memctl->memc_mcr = 0x80804130; |
| 105 | |
| 106 | delay_cnt = 0; |
| 107 | while( delay_cnt++ < DRAM_DELAY ) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 108 | ; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 109 | |
| 110 | /* Run MRS command in location 5-8 of UPMB */ |
| 111 | |
| 112 | memctl->memc_mbmr = temp | 0x04; |
| 113 | memctl->memc_mar = 0x88; |
| 114 | |
| 115 | memctl->memc_mcr = 0x80804105; |
| 116 | |
| 117 | delay_cnt = 0; |
| 118 | while( delay_cnt++ < DRAM_DELAY ) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 119 | ; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 120 | |
| 121 | #ifdef CONFIG_CAN_DRIVER |
| 122 | /* Initialize OR3 / BR3 */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 123 | memctl->memc_or3 = CONFIG_SYS_OR3_CAN; |
| 124 | memctl->memc_br3 = CONFIG_SYS_BR3_CAN; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 125 | |
| 126 | /* Initialize MBMR */ |
wdenk | 2535d60 | 2003-07-17 23:16:40 +0000 | [diff] [blame] | 127 | memctl->memc_mamr = MAMR_GPL_A4DIS; /* GPL_A4 ouput line Disable */ |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 128 | |
| 129 | /* Initialize UPMB for CAN: single read */ |
| 130 | memctl->memc_mdr = 0xFFFFC004; |
| 131 | memctl->memc_mcr = 0x0100 | UPMA; |
| 132 | |
| 133 | memctl->memc_mdr = 0x0FFFD004; |
| 134 | memctl->memc_mcr = 0x0101 | UPMA; |
| 135 | |
| 136 | memctl->memc_mdr = 0x0FFFC000; |
| 137 | memctl->memc_mcr = 0x0102 | UPMA; |
| 138 | |
| 139 | memctl->memc_mdr = 0x3FFFC004; |
| 140 | memctl->memc_mcr = 0x0103 | UPMA; |
| 141 | |
| 142 | memctl->memc_mdr = 0xFFFFDC05; |
| 143 | memctl->memc_mcr = 0x0104 | UPMA; |
| 144 | |
| 145 | /* Initialize UPMB for CAN: single write */ |
| 146 | memctl->memc_mdr = 0xFFFCC004; |
| 147 | memctl->memc_mcr = 0x0118 | UPMA; |
| 148 | |
| 149 | memctl->memc_mdr = 0xCFFCD004; |
| 150 | memctl->memc_mcr = 0x0119 | UPMA; |
| 151 | |
| 152 | memctl->memc_mdr = 0x0FFCC000; |
| 153 | memctl->memc_mcr = 0x011A | UPMA; |
| 154 | |
| 155 | memctl->memc_mdr = 0x7FFCC004; |
| 156 | memctl->memc_mcr = 0x011B | UPMA; |
| 157 | |
| 158 | memctl->memc_mdr = 0xFFFDCC05; |
| 159 | memctl->memc_mcr = 0x011C | UPMA; |
| 160 | #endif /* CONFIG_CAN_DRIVER */ |
| 161 | |
| 162 | return (dram_size()); |
| 163 | } |
| 164 | |
| 165 | /* ------------------------------------------------------------------------- */ |
| 166 | |
| 167 | /* |
| 168 | * Find size of RAM from configuration pins. |
| 169 | * The input pins that contain the memory size are also the debug port |
| 170 | * pins. Normally they are configured as debug port pins. To be able |
| 171 | * to read the memory configuration, we must deactivate the debug port |
| 172 | * and enable the pcmcia input pins. Then return the register to |
| 173 | * previous state. |
| 174 | */ |
| 175 | |
| 176 | static long int dram_size () |
| 177 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 178 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 179 | volatile sysconf8xx_t *siu = &immap->im_siu_conf; |
| 180 | volatile pcmconf8xx_t *pcm = &immap->im_pcmcia; |
| 181 | long int i, memory=1; |
| 182 | unsigned long siu_mcr; |
| 183 | |
| 184 | siu_mcr = siu->sc_siumcr; |
| 185 | siu->sc_siumcr = siu_mcr & 0xFF9FFFFF; |
| 186 | for(i=0; i<10; i++) i = i; |
| 187 | |
| 188 | memory = (pcm->pcmc_pipr>>12) & 0x3; |
| 189 | |
| 190 | siu->sc_siumcr = siu_mcr; |
| 191 | |
| 192 | switch( memory ) |
| 193 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 194 | case 1: |
| 195 | return( 32*MBYTE ); |
| 196 | case 2: |
| 197 | return( 64*MBYTE ); |
| 198 | default: |
| 199 | break; |
wdenk | 608c914 | 2003-01-13 23:54:46 +0000 | [diff] [blame] | 200 | } |
| 201 | return( 16*MBYTE ); |
| 202 | } |