blob: f70783e73ab3b0e9b72e4d160c829e4c58addaba [file] [log] [blame]
Dave Liue740c462006-12-07 21:13:15 +08001/*
2 * Copyright (C) 2006 Freescale Semiconductor, Inc.
3 *
4 * Dave Liu <daveliu@freescale.com>
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 */
14
15#include <common.h>
16#include <ioports.h>
17#include <mpc83xx.h>
18#include <i2c.h>
19#include <spd.h>
20#include <miiphy.h>
21#include <command.h>
22#if defined(CONFIG_PCI)
23#include <pci.h>
24#endif
25#if defined(CONFIG_SPD_EEPROM)
26#include <spd_sdram.h>
27#else
28#include <asm/mmu.h>
29#endif
30#if defined(CONFIG_OF_FLAT_TREE)
31#include <ft_build.h>
Kim Phillips21416812007-08-15 22:30:33 -050032#elif defined(CONFIG_OF_LIBFDT)
33#include <libfdt.h>
Dave Liue740c462006-12-07 21:13:15 +080034#endif
35
36const qe_iop_conf_t qe_iop_conf_tab[] = {
37 /* ETH3 */
38 {1, 0, 1, 0, 1}, /* TxD0 */
39 {1, 1, 1, 0, 1}, /* TxD1 */
40 {1, 2, 1, 0, 1}, /* TxD2 */
41 {1, 3, 1, 0, 1}, /* TxD3 */
42 {1, 9, 1, 0, 1}, /* TxER */
43 {1, 12, 1, 0, 1}, /* TxEN */
44 {3, 24, 2, 0, 1}, /* TxCLK->CLK10 */
45
46 {1, 4, 2, 0, 1}, /* RxD0 */
47 {1, 5, 2, 0, 1}, /* RxD1 */
48 {1, 6, 2, 0, 1}, /* RxD2 */
49 {1, 7, 2, 0, 1}, /* RxD3 */
50 {1, 8, 2, 0, 1}, /* RxER */
51 {1, 10, 2, 0, 1}, /* RxDV */
52 {0, 13, 2, 0, 1}, /* RxCLK->CLK9 */
53 {1, 11, 2, 0, 1}, /* COL */
54 {1, 13, 2, 0, 1}, /* CRS */
55
56 /* ETH4 */
57 {1, 18, 1, 0, 1}, /* TxD0 */
58 {1, 19, 1, 0, 1}, /* TxD1 */
59 {1, 20, 1, 0, 1}, /* TxD2 */
60 {1, 21, 1, 0, 1}, /* TxD3 */
61 {1, 27, 1, 0, 1}, /* TxER */
62 {1, 30, 1, 0, 1}, /* TxEN */
63 {3, 6, 2, 0, 1}, /* TxCLK->CLK8 */
64
65 {1, 22, 2, 0, 1}, /* RxD0 */
66 {1, 23, 2, 0, 1}, /* RxD1 */
67 {1, 24, 2, 0, 1}, /* RxD2 */
68 {1, 25, 2, 0, 1}, /* RxD3 */
69 {1, 26, 1, 0, 1}, /* RxER */
70 {1, 28, 2, 0, 1}, /* Rx_DV */
71 {3, 31, 2, 0, 1}, /* RxCLK->CLK7 */
72 {1, 29, 2, 0, 1}, /* COL */
73 {1, 31, 2, 0, 1}, /* CRS */
74
75 {3, 4, 3, 0, 2}, /* MDIO */
76 {3, 5, 1, 0, 2}, /* MDC */
77
78 {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
79};
80
81int board_early_init_f(void)
82{
83 volatile u8 *bcsr = (volatile u8 *)CFG_BCSR;
84
85 /* Enable flash write */
86 bcsr[9] &= ~0x08;
87
88 return 0;
89}
90
91int fixed_sdram(void);
92
93long int initdram(int board_type)
94{
95 volatile immap_t *im = (immap_t *) CFG_IMMR;
96 u32 msize = 0;
97
98 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
99 return -1;
100
101 /* DDR SDRAM - Main SODIMM */
102 im->sysconf.ddrlaw[0].bar = CFG_DDR_BASE & LAWBAR_BAR;
103
104 msize = fixed_sdram();
105
106 puts("\n DDR RAM: ");
107
108 /* return total bus SDRAM size(bytes) -- DDR */
109 return (msize * 1024 * 1024);
110}
111
112/*************************************************************************
113 * fixed sdram init -- doesn't use serial presence detect.
114 ************************************************************************/
115int fixed_sdram(void)
116{
117 volatile immap_t *im = (immap_t *) CFG_IMMR;
118 u32 msize = 0;
119 u32 ddr_size;
120 u32 ddr_size_log2;
121
122 msize = CFG_DDR_SIZE;
123 for (ddr_size = msize << 20, ddr_size_log2 = 0;
124 (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
125 if (ddr_size & 1) {
126 return -1;
127 }
128 }
129 im->sysconf.ddrlaw[0].ar =
130 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
131#if (CFG_DDR_SIZE != 128)
132#warning Currenly any ddr size other than 128 is not supported
133#endif
134 im->ddr.sdram_clk_cntl = CFG_DDR_CLK_CNTL;
135 im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
136 im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
137 im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
138 im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
139 im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
140 im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
141 im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
142 im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
143 im->ddr.sdram_mode = CFG_DDR_MODE;
144 im->ddr.sdram_mode2 = CFG_DDR_MODE2;
145 im->ddr.sdram_interval = CFG_DDR_INTERVAL;
146 __asm__ __volatile__ ("sync");
147 udelay(200);
148
149 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
150 __asm__ __volatile__ ("sync");
151 return msize;
152}
153
154int checkboard(void)
155{
156 puts("Board: Freescale MPC832XEMDS\n");
157 return 0;
158}
159
Kim Phillips21416812007-08-15 22:30:33 -0500160#if defined(CONFIG_OF_BOARD_SETUP)
161void ft_board_setup(void *blob, bd_t *bd)
Dave Liue740c462006-12-07 21:13:15 +0800162{
Kim Phillips21416812007-08-15 22:30:33 -0500163#if defined(CONFIG_OF_FLAT_TREE)
Dave Liue740c462006-12-07 21:13:15 +0800164 u32 *p;
165 int len;
166
Dave Liue740c462006-12-07 21:13:15 +0800167 p = ft_get_prop(blob, "/memory/reg", &len);
168 if (p != NULL) {
169 *p++ = cpu_to_be32(bd->bi_memstart);
170 *p = cpu_to_be32(bd->bi_memsize);
171 }
Kim Phillips21416812007-08-15 22:30:33 -0500172#endif
173 ft_cpu_setup(blob, bd);
174#ifdef CONFIG_PCI
175 ft_pci_setup(blob, bd);
176#endif
Dave Liue740c462006-12-07 21:13:15 +0800177}
178#endif