wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004 |
| 3 | * Texas Instruments, <www.ti.com> |
| 4 | * Richard Woodruff <r-woodruff2@ti.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; either version 2 of |
| 9 | * the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 19 | * MA 02111-1307 USA |
| 20 | */ |
| 21 | |
| 22 | #include <common.h> |
| 23 | #include <asm/arch/omap2420.h> |
| 24 | #include <asm/io.h> |
| 25 | #include <asm/arch/bits.h> |
| 26 | #include <asm/arch/mux.h> |
| 27 | #include <asm/arch/mem.h> |
| 28 | #include <asm/arch/clocks.h> |
| 29 | #include <asm/arch/sys_proto.h> |
| 30 | #include <asm/arch/sys_info.h> |
| 31 | |
| 32 | /************************************************************ |
| 33 | * sdelay() - simple spin loop. Will be constant time as |
| 34 | * its generally used in 12MHz bypass conditions only. This |
| 35 | * is necessary until timers are accessible. |
| 36 | * |
| 37 | * not inline to increase chances its in cache when called |
| 38 | *************************************************************/ |
| 39 | void sdelay (unsigned long loops) |
| 40 | { |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 41 | __asm__ volatile ("1:\n" "subs %0, %1, #1\n" |
| 42 | "bne 1b":"=r" (loops):"0" (loops)); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | /********************************************************************************* |
| 46 | * prcm_init() - inits clocks for PRCM as defined in clocks.h (config II default). |
| 47 | * -- called from SRAM, or Flash (using temp SRAM stack). |
| 48 | *********************************************************************************/ |
| 49 | void prcm_init(void) |
| 50 | { |
| 51 | u32 rev,div; |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 52 | void (*f_lock_pll) (u32, u32, u32, u32); |
| 53 | extern void *_end_vect, *_start; |
| 54 | |
| 55 | f_lock_pll = (void *)((u32)&_end_vect - (u32)&_start + SRAM_VECT_CODE); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 56 | |
| 57 | __raw_writel(0, CM_FCLKEN1_CORE); /* stop all clocks to reduce ringing */ |
| 58 | __raw_writel(0, CM_FCLKEN2_CORE); /* may not be necessary */ |
| 59 | __raw_writel(0, CM_ICLKEN1_CORE); |
| 60 | __raw_writel(0, CM_ICLKEN2_CORE); |
| 61 | |
| 62 | __raw_writel(DPLL_OUT, CM_CLKSEL2_PLL); /* set DPLL out */ |
| 63 | __raw_writel(MPU_DIV, CM_CLKSEL_MPU); /* set MPU divider */ |
| 64 | __raw_writel(DSP_DIV, CM_CLKSEL_DSP); /* set dsp and iva dividers */ |
| 65 | __raw_writel(GFX_DIV, CM_CLKSEL_GFX); /* set gfx dividers */ |
| 66 | |
| 67 | rev = get_cpu_rev(); |
| 68 | if (rev == CPU_2420_ES1 || rev == CPU_2422_ES1) |
| 69 | div = BUS_DIV_ES1; |
| 70 | else |
| 71 | div = BUS_DIV; |
| 72 | __raw_writel(div, CM_CLKSEL1_CORE);/* set L3/L4/USB/Display/Vlnc/SSi dividers */ |
| 73 | sdelay(1000); |
| 74 | |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 75 | if(running_in_sram()){ |
| 76 | /* If running fully from SRAM this is OK. The Flash bus drops out for just a little. |
wdenk | 5a95f6f | 2005-01-12 00:38:03 +0000 | [diff] [blame] | 77 | * but then comes back. If running from Flash this sequence kills you, thus you need |
| 78 | * to run it using CONFIG_PARTIAL_SRAM. |
| 79 | */ |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 80 | __raw_writel(MODE_BYPASS_FAST, CM_CLKEN_PLL); /* go to bypass, fast relock */ |
| 81 | wait_on_value(BIT0|BIT1, BIT0, CM_IDLEST_CKGEN, LDELAY); /* wait till in bypass */ |
| 82 | sdelay(1000); |
| 83 | /* set clock selection and dpll dividers. */ |
| 84 | __raw_writel(DPLL_VAL, CM_CLKSEL1_PLL); /* set pll for target rate */ |
| 85 | __raw_writel(COMMIT_DIVIDERS, PRCM_CLKCFG_CTRL); /* commit dividers */ |
| 86 | sdelay(10000); |
| 87 | __raw_writel(DPLL_LOCK, CM_CLKEN_PLL); /* enable dpll */ |
| 88 | sdelay(10000); |
| 89 | wait_on_value(BIT0|BIT1, BIT1, CM_IDLEST_CKGEN, LDELAY); /*wait for dpll lock */ |
| 90 | }else if(running_in_flash()){ |
| 91 | /* if running from flash, need to jump to small relocated code area in SRAM. |
| 92 | * This is the only safe spot to do configurations from. |
| 93 | */ |
| 94 | (*f_lock_pll)(PRCM_CLKCFG_CTRL, CM_CLKEN_PLL, DPLL_LOCK, CM_IDLEST_CKGEN); |
| 95 | } |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 96 | |
| 97 | __raw_writel(DPLL_LOCK|APLL_LOCK, CM_CLKEN_PLL); /* enable apll */ |
| 98 | wait_on_value(BIT8, BIT8, CM_IDLEST_CKGEN, LDELAY); /* wait for apll lock */ |
| 99 | sdelay(1000); |
| 100 | } |
| 101 | |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 102 | |
| 103 | /******************************************************** |
| 104 | * mem_ok() - test used to see if timings are correct |
| 105 | * for a part. Helps in gussing which part |
| 106 | * we are currently using. |
| 107 | *******************************************************/ |
| 108 | u32 mem_ok(void) |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 109 | { |
| 110 | u32 val1, val2; |
| 111 | u32 pattern = 0x12345678; |
| 112 | |
| 113 | __raw_writel(0x0,OMAP2420_SDRC_CS0+0x400); /* clear pos A */ |
| 114 | __raw_writel(pattern, OMAP2420_SDRC_CS0); /* pattern to pos B */ |
| 115 | __raw_writel(0x0,OMAP2420_SDRC_CS0+4); /* remove pattern off the bus */ |
| 116 | val1 = __raw_readl(OMAP2420_SDRC_CS0+0x400); /* get pos A value */ |
| 117 | val2 = __raw_readl(OMAP2420_SDRC_CS0); /* get val2 */ |
| 118 | |
| 119 | if ((val1 != 0) || (val2 != pattern)) /* see if pos A value changed*/ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 120 | return(0); |
| 121 | else |
| 122 | return(1); |
| 123 | } |
| 124 | |
| 125 | /******************************************************** |
| 126 | * sdrc_init() - init the sdrc chip selects CS0 and CS1 |
| 127 | * - early init routines, called from flash or |
| 128 | * SRAM. |
| 129 | *******************************************************/ |
| 130 | void sdrc_init(void) |
| 131 | { |
| 132 | #define EARLY_INIT 1 |
| 133 | do_sdrc_init(SDRC_CS0_OSET, EARLY_INIT); /* only init up first bank here */ |
| 134 | } |
| 135 | |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 136 | /************************************************************************* |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 137 | * do_sdrc_init(): initialize the SDRAM for use. |
| 138 | * -called from low level code with stack only. |
| 139 | * -code sets up SDRAM timing and muxing for 2422 or 2420. |
| 140 | * -optimal settings can be placed here, or redone after i2c |
| 141 | * inspection of board info |
| 142 | * |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 143 | * This is a bit ugly, but should handle all memory moduels |
| 144 | * used with the H4. The first time though this code from s_init() |
| 145 | * we configure the first chip select. Later on we come back and |
| 146 | * will configure the 2nd chip select if it exists. |
| 147 | * |
| 148 | **************************************************************************/ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 149 | void do_sdrc_init(u32 offset, u32 early) |
| 150 | { |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 151 | u32 cpu, bug=0, rev, common=0, cs0=0, pmask=0, pass_type; |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 152 | sdrc_data_t *sdata; /* do not change type */ |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 153 | u32 a, b, r; |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 154 | |
| 155 | static const sdrc_data_t sdrc_2422 = |
| 156 | { |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 157 | H4_2422_SDRC_SHARING, H4_2422_SDRC_MDCFG_0_DDR, 0 , H4_2422_SDRC_ACTIM_CTRLA_0, |
| 158 | H4_2422_SDRC_ACTIM_CTRLB_0, H4_2422_SDRC_RFR_CTRL_ES1, H4_2422_SDRC_MR_0_DDR, |
| 159 | 0, H4_2422_SDRC_DLLA_CTRL, H4_2422_SDRC_DLLB_CTRL |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 160 | }; |
| 161 | static const sdrc_data_t sdrc_2420 = |
| 162 | { |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 163 | H4_2420_SDRC_SHARING, H4_2420_SDRC_MDCFG_0_DDR, H4_2420_SDRC_MDCFG_0_SDR, |
| 164 | H4_2420_SDRC_ACTIM_CTRLA_0, H4_2420_SDRC_ACTIM_CTRLB_0, |
| 165 | H4_2420_SDRC_RFR_CTRL_ES1, H4_2420_SDRC_MR_0_DDR, H4_2420_SDRC_MR_0_SDR, |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 166 | H4_2420_SDRC_DLLA_CTRL, H4_2420_SDRC_DLLB_CTRL |
| 167 | }; |
| 168 | |
| 169 | if (offset == SDRC_CS0_OSET) |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 170 | cs0 = common = 1; /* int regs shared between both chip select */ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 171 | |
| 172 | cpu = get_cpu_type(); |
| 173 | |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 174 | /* warning generated, though code generation is correct. this may bite later, |
wdenk | 5a95f6f | 2005-01-12 00:38:03 +0000 | [diff] [blame] | 175 | * but is ok for now. there is only so much C code you can do on stack only |
| 176 | * operation. |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 177 | */ |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 178 | if (cpu == CPU_2422){ |
| 179 | sdata = (sdrc_data_t *)&sdrc_2422; |
| 180 | pass_type = STACKED; |
wdenk | 5a95f6f | 2005-01-12 00:38:03 +0000 | [diff] [blame] | 181 | } else{ |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 182 | sdata = (sdrc_data_t *)&sdrc_2420; |
| 183 | pass_type = IP_DDR; |
| 184 | } |
| 185 | |
| 186 | __asm__ __volatile__("": : :"memory"); /* limit compiler scope */ |
| 187 | |
| 188 | /* u-boot is compiled to run in DDR or SRAM at 8xxxxxxx or 4xxxxxxx. |
wdenk | 5a95f6f | 2005-01-12 00:38:03 +0000 | [diff] [blame] | 189 | * If we are running in flash prior to relocation and we use data |
| 190 | * here which is not pc relative we need to get the address correct. |
| 191 | * We need to find the current flash mapping to dress up the initial |
| 192 | * pointer load. As long as this is const data we should be ok. |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 193 | */ |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 194 | if((early) && running_in_flash()){ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 195 | sdata = (sdrc_data_t *)(((u32)sdata & 0x0003FFFF) | get_gpmc0_base()); |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 196 | /* NOR internal boot offset is 0x4000 from xloader signature */ |
| 197 | if(running_from_internal_boot()) |
| 198 | sdata = (sdrc_data_t *)((u32)sdata + 0x4000); |
| 199 | } |
| 200 | if (!early && (get_mem_type() == DDR_COMBO)) {/* combo part has a shared CKE signal, can't use feature */ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 201 | pmask = BIT2; |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 202 | pass_type = COMBO_DDR; /* CS1 config */ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 203 | } |
| 204 | |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 205 | next_mem_type: |
| 206 | if (common) { /* do a SDRC reset between types to clear regs*/ |
| 207 | __raw_writel(SOFTRESET, SDRC_SYSCONFIG); /* reset sdrc */ |
| 208 | wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000);/* wait till reset done set */ |
| 209 | __raw_writel(0, SDRC_SYSCONFIG); /* clear soft reset */ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 210 | __raw_writel(sdata->sdrc_sharing, SDRC_SHARING); |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 211 | __raw_writel((__raw_readl(SDRC_POWER)) & ~pmask, SDRC_POWER); |
| 212 | #ifdef POWER_SAVE |
| 213 | __raw_writel(__raw_readl(SMS_SYSCONFIG)|SMART_IDLE, SMS_SYSCONFIG); |
| 214 | __raw_writel(sdata->sdrc_sharing|SMART_IDLE, SDRC_SHARING); |
| 215 | __raw_writel((__raw_readl(SDRC_POWER)|BIT6) & ~pmask, SDRC_POWER); |
| 216 | #endif |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 217 | } |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 218 | |
| 219 | if ((pass_type == IP_DDR) || (pass_type == STACKED)) /* (IP ddr-CS0),(2422-CS0/CS1) */ |
| 220 | __raw_writel(sdata->sdrc_mdcfg_0_ddr, SDRC_MCFG_0+offset); |
| 221 | else if (pass_type == COMBO_DDR){ /* (combo-CS0/CS1) */ |
| 222 | __raw_writel(H4_2420_COMBO_MDCFG_0_DDR,SDRC_MCFG_0+offset); |
| 223 | } else if (pass_type == IP_SDR){ /* ip sdr-CS0 */ |
| 224 | __raw_writel(sdata->sdrc_mdcfg_0_sdr, SDRC_MCFG_0+offset); |
| 225 | } |
| 226 | |
| 227 | if(pass_type == IP_SDR){ /* SDRAM can run full speed only rated for 105MHz*/ |
| 228 | a = H4_242X_SDRC_ACTIM_CTRLA_0_100MHz; |
| 229 | b = H4_242X_SDRC_ACTIM_CTRLB_0_100MHz; |
| 230 | r = H4_2420_SDRC_RFR_CTRL; |
| 231 | } else { |
| 232 | a = sdata->sdrc_actim_ctrla_0; |
| 233 | b = sdata->sdrc_actim_ctrlb_0; |
| 234 | r = sdata->sdrc_rfr_ctrl; |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | if (cs0) { |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 238 | __raw_writel(a, SDRC_ACTIM_CTRLA_0); |
| 239 | __raw_writel(b, SDRC_ACTIM_CTRLB_0); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 240 | } else { |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 241 | __raw_writel(a, SDRC_ACTIM_CTRLA_1); |
| 242 | __raw_writel(b, SDRC_ACTIM_CTRLB_1); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 243 | } |
| 244 | |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 245 | __raw_writel(r, SDRC_RFR_CTRL+offset); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 246 | |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 247 | /* init sequence for mDDR/mSDR using manual commands (DDR is a bit different) */ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 248 | __raw_writel(CMD_NOP, SDRC_MANUAL_0+offset); |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 249 | sdelay(5000); /* susposed to be 100us per design spec for mddr/msdr */ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 250 | __raw_writel(CMD_PRECHARGE, SDRC_MANUAL_0+offset); |
| 251 | __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0+offset); |
| 252 | __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0+offset); |
| 253 | |
| 254 | /* |
| 255 | * CSx SDRC Mode Register |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 256 | * Burst length = (4 - DDR) (2-SDR) |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 257 | * Serial mode |
| 258 | * CAS latency = x |
| 259 | */ |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 260 | if(pass_type == IP_SDR) |
| 261 | __raw_writel(sdata->sdrc_mr_0_sdr, SDRC_MR_0+offset); |
| 262 | else |
| 263 | __raw_writel(sdata->sdrc_mr_0_ddr, SDRC_MR_0+offset); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 264 | |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 265 | /* NOTE: ES1 242x _BUG_ DLL + External Bandwidth fix*/ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 266 | rev = get_cpu_rev(); |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 267 | if (rev == CPU_2420_ES1 || rev == CPU_2422_ES1){ |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 268 | bug = BIT0; |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 269 | __raw_writel((__raw_readl(SMS_CLASS_ARB0)|BURSTCOMPLETE_GROUP7) |
| 270 | ,SMS_CLASS_ARB0);/* enable bust complete for lcd */ |
| 271 | } |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 272 | /* enable & load up DLL with good value for 75MHz, and set phase to 90% */ |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 273 | if (common && (pass_type != IP_SDR)) { |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 274 | __raw_writel(sdata->sdrc_dlla_ctrl, SDRC_DLLA_CTRL); |
| 275 | __raw_writel(sdata->sdrc_dlla_ctrl & ~(BIT2|bug), SDRC_DLLA_CTRL); |
| 276 | __raw_writel(sdata->sdrc_dllb_ctrl, SDRC_DLLB_CTRL); |
| 277 | __raw_writel(sdata->sdrc_dllb_ctrl & ~(BIT2|bug) , SDRC_DLLB_CTRL); |
| 278 | } |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 279 | sdelay(90000); |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 280 | |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 281 | if(mem_ok()) |
| 282 | return; /* STACKED, other configued type */ |
| 283 | ++pass_type; /* IPDDR->COMBODDR->IPSDR for CS0 */ |
| 284 | goto next_mem_type; |
| 285 | } |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 286 | |
| 287 | /***************************************************** |
| 288 | * gpmc_init(): init gpmc bus |
| 289 | * Init GPMC for x16, MuxMode (SDRAM in x32). |
| 290 | * This code can only be executed from SRAM or SDRAM. |
| 291 | *****************************************************/ |
| 292 | void gpmc_init(void) |
| 293 | { |
| 294 | u32 mux=0, mtype, mwidth; |
| 295 | |
| 296 | /* global settings */ |
| 297 | __raw_writel(0x10, GPMC_SYSCONFIG); /* smart idle */ |
| 298 | __raw_writel(0x0, GPMC_IRQENABLE); /* isr's sources masked */ |
| 299 | __raw_writel(0x1, GPMC_TIMEOUT_CONTROL);/* timeout disable */ |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 300 | #ifdef CFG_NAND_BOOT |
| 301 | __raw_writel(0x001, GPMC_CONFIG); /* set nWP, disable limited addr */ |
| 302 | #else |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 303 | __raw_writel(0x111, GPMC_CONFIG); /* set nWP, disable limited addr */ |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 304 | #endif |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 305 | |
| 306 | /* discover bus connection from sysboot */ |
| 307 | if (is_gpmc_muxed() == GPMC_MUXED) |
| 308 | mux = BIT9; |
| 309 | mtype = get_gpmc0_type(); |
| 310 | mwidth = get_gpmc0_width(); |
| 311 | |
| 312 | /* setup cs0 */ |
| 313 | __raw_writel(0x0, GPMC_CONFIG7_0); /* disable current map */ |
| 314 | sdelay(1000); |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 315 | |
| 316 | #ifdef CFG_NAND_BOOT |
| 317 | __raw_writel(H4_24XX_GPMC_CONFIG1_0|mtype|mwidth, GPMC_CONFIG1_0); |
| 318 | #else |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 319 | __raw_writel(H4_24XX_GPMC_CONFIG1_0|mux|mtype|mwidth, GPMC_CONFIG1_0); |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 320 | #endif |
| 321 | |
| 322 | #ifdef PRCM_CONFIG_III |
| 323 | __raw_writel(H4_24XX_GPMC_CONFIG2_0, GPMC_CONFIG2_0); |
| 324 | #endif |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 325 | __raw_writel(H4_24XX_GPMC_CONFIG3_0, GPMC_CONFIG3_0); |
| 326 | __raw_writel(H4_24XX_GPMC_CONFIG4_0, GPMC_CONFIG4_0); |
wdenk | 289f932 | 2005-01-12 00:15:14 +0000 | [diff] [blame] | 327 | #ifdef PRCM_CONFIG_III |
| 328 | __raw_writel(H4_24XX_GPMC_CONFIG5_0, GPMC_CONFIG5_0); |
| 329 | __raw_writel(H4_24XX_GPMC_CONFIG6_0, GPMC_CONFIG6_0); |
| 330 | #endif |
wdenk | 8ed9604 | 2005-01-09 23:16:25 +0000 | [diff] [blame] | 331 | __raw_writel(H4_24XX_GPMC_CONFIG7_0, GPMC_CONFIG7_0);/* enable new mapping */ |
| 332 | sdelay(2000); |
| 333 | |
| 334 | /* setup cs1 */ |
| 335 | __raw_writel(0, GPMC_CONFIG7_1); /* disable any mapping */ |
| 336 | sdelay(1000); |
| 337 | __raw_writel(H4_24XX_GPMC_CONFIG1_1|mux, GPMC_CONFIG1_1); |
| 338 | __raw_writel(H4_24XX_GPMC_CONFIG2_1, GPMC_CONFIG2_1); |
| 339 | __raw_writel(H4_24XX_GPMC_CONFIG3_1, GPMC_CONFIG3_1); |
| 340 | __raw_writel(H4_24XX_GPMC_CONFIG4_1, GPMC_CONFIG4_1); |
| 341 | __raw_writel(H4_24XX_GPMC_CONFIG5_1, GPMC_CONFIG5_1); |
| 342 | __raw_writel(H4_24XX_GPMC_CONFIG6_1, GPMC_CONFIG6_1); |
| 343 | __raw_writel(H4_24XX_GPMC_CONFIG7_1, GPMC_CONFIG7_1); /* enable mapping */ |
| 344 | sdelay(2000); |
| 345 | } |