blob: 5375d36c9b580d1d5b757692a8b1a67aa02dbf52 [file] [log] [blame]
Stefan Roesefdf21b12007-03-21 13:39:57 +01001/*
2 * (C) Copyright 2007
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
Stefan Roesef6c7b762007-03-24 15:45:34 +010024/* define DEBUG for debugging output (obviously ;-)) */
25#if 0
26#define DEBUG
27#endif
28
Stefan Roesefdf21b12007-03-21 13:39:57 +010029#include <common.h>
30#include <asm/processor.h>
Stefan Roesef6c7b762007-03-24 15:45:34 +010031#include <asm/io.h>
32#include <asm/gpio.h>
Stefan Roesefdf21b12007-03-21 13:39:57 +010033
Stefan Roesef6c7b762007-03-24 15:45:34 +010034/*
35 * sdram_init - Dummy implementation for start.S, spd_sdram used on this board!
36 */
Stefan Roesefdf21b12007-03-21 13:39:57 +010037void sdram_init(void)
38{
Stefan Roesefdf21b12007-03-21 13:39:57 +010039 return;
40}
41
42static void cram_bcr_write(u32 wr_val)
43{
Stefan Roesef6c7b762007-03-24 15:45:34 +010044 wr_val <<= 2;
Stefan Roesefdf21b12007-03-21 13:39:57 +010045
Stefan Roesef6c7b762007-03-24 15:45:34 +010046 /* set CRAM_CRE to 1 */
47 gpio_write_bit(CFG_GPIO_CRAM_CRE, 1);
Stefan Roesefdf21b12007-03-21 13:39:57 +010048
Stefan Roesef6c7b762007-03-24 15:45:34 +010049 /* Write BCR to CRAM on CS1 */
50 out32(wr_val + 0x00200000, 0);
51 debug("CRAM VAL: %08x for CS1 ", wr_val + 0x00200000);
Stefan Roesefdf21b12007-03-21 13:39:57 +010052
Stefan Roesef6c7b762007-03-24 15:45:34 +010053 /* Write BCR to CRAM on CS2 */
54 out32(wr_val + 0x02200000, 0);
55 debug("CRAM VAL: %08x for CS2\n", wr_val + 0x02200000);
Stefan Roesefdf21b12007-03-21 13:39:57 +010056
Stefan Roesef6c7b762007-03-24 15:45:34 +010057 sync();
58 eieio();
Stefan Roesefdf21b12007-03-21 13:39:57 +010059
Stefan Roesef6c7b762007-03-24 15:45:34 +010060 /* set CRAM_CRE back to 0 (normal operation) */
61 gpio_write_bit(CFG_GPIO_CRAM_CRE, 0);
Stefan Roesefdf21b12007-03-21 13:39:57 +010062
Stefan Roesefdf21b12007-03-21 13:39:57 +010063 return;
64}
65
Stefan Roesef6c7b762007-03-24 15:45:34 +010066long int initdram(int board_type)
Stefan Roesefdf21b12007-03-21 13:39:57 +010067{
Stefan Roesef6c7b762007-03-24 15:45:34 +010068 u32 val;
Stefan Roesefdf21b12007-03-21 13:39:57 +010069
Stefan Roesef6c7b762007-03-24 15:45:34 +010070 /* 1. EBC need to program READY, CLK, ADV for ASync mode */
71 gpio_config(CFG_GPIO_CRAM_CLK, GPIO_OUT, GPIO_SEL, GPIO_OUT_0);
72 gpio_config(CFG_GPIO_CRAM_ADV, GPIO_OUT, GPIO_SEL, GPIO_OUT_0);
73 gpio_config(CFG_GPIO_CRAM_CRE, GPIO_OUT, GPIO_SEL, GPIO_OUT_0);
74 gpio_config(CFG_GPIO_CRAM_WAIT, GPIO_IN, GPIO_SEL, GPIO_OUT_NO_CHG);
Stefan Roesefdf21b12007-03-21 13:39:57 +010075
Stefan Roesef6c7b762007-03-24 15:45:34 +010076 /* 2. EBC in Async mode */
77 mtebc(pb1ap, 0x078F1EC0);
78 mtebc(pb2ap, 0x078F1EC0);
79 mtebc(pb1cr, 0x000BC000);
80 mtebc(pb2cr, 0x020BC000);
Stefan Roesefdf21b12007-03-21 13:39:57 +010081
Stefan Roesef6c7b762007-03-24 15:45:34 +010082 /* 3. Set CRAM in Sync mode */
83 cram_bcr_write(0x7012); /* CRAM burst setting */
Stefan Roesefdf21b12007-03-21 13:39:57 +010084
Stefan Roesef6c7b762007-03-24 15:45:34 +010085 /* 4. EBC in Sync mode */
86 mtebc(pb1ap, 0x9C0201C0);
87 mtebc(pb2ap, 0x9C0201C0);
Stefan Roesefdf21b12007-03-21 13:39:57 +010088
Stefan Roesef6c7b762007-03-24 15:45:34 +010089 /* Set GPIO pins back to alternate function */
90 gpio_config(CFG_GPIO_CRAM_CLK, GPIO_OUT, GPIO_ALT1, GPIO_OUT_NO_CHG);
91 gpio_config(CFG_GPIO_CRAM_ADV, GPIO_OUT, GPIO_ALT1, GPIO_OUT_NO_CHG);
Stefan Roesefdf21b12007-03-21 13:39:57 +010092
Stefan Roesef6c7b762007-03-24 15:45:34 +010093 /* Config EBC to use RDY */
94 mfsdr(sdrultra0, val);
95 mtsdr(sdrultra0, val | 0x04000000);
Stefan Roesefdf21b12007-03-21 13:39:57 +010096
Stefan Roesef6c7b762007-03-24 15:45:34 +010097 return (CFG_MBYTES_RAM << 20);
Stefan Roesefdf21b12007-03-21 13:39:57 +010098}
99
100int testdram(void)
101{
102 return (0);
103}