blob: 207fcdf8be3853d287a38fefa6d1960e1563c22b [file] [log] [blame]
Dave Liu24c3aca2006-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 Phillips3fde9e82007-08-15 22:30:33 -050032#elif defined(CONFIG_OF_LIBFDT)
33#include <libfdt.h>
Dave Liu24c3aca2006-12-07 21:13:15 +080034#endif
Tony Li14778582007-08-17 10:35:59 +080035#if defined(CONFIG_PQ_MDS_PIB)
36#include "../freescale/common/pq-mds-pib.h"
37#endif
Dave Liu24c3aca2006-12-07 21:13:15 +080038
39const qe_iop_conf_t qe_iop_conf_tab[] = {
40 /* ETH3 */
41 {1, 0, 1, 0, 1}, /* TxD0 */
42 {1, 1, 1, 0, 1}, /* TxD1 */
43 {1, 2, 1, 0, 1}, /* TxD2 */
44 {1, 3, 1, 0, 1}, /* TxD3 */
45 {1, 9, 1, 0, 1}, /* TxER */
46 {1, 12, 1, 0, 1}, /* TxEN */
47 {3, 24, 2, 0, 1}, /* TxCLK->CLK10 */
48
49 {1, 4, 2, 0, 1}, /* RxD0 */
50 {1, 5, 2, 0, 1}, /* RxD1 */
51 {1, 6, 2, 0, 1}, /* RxD2 */
52 {1, 7, 2, 0, 1}, /* RxD3 */
53 {1, 8, 2, 0, 1}, /* RxER */
54 {1, 10, 2, 0, 1}, /* RxDV */
55 {0, 13, 2, 0, 1}, /* RxCLK->CLK9 */
56 {1, 11, 2, 0, 1}, /* COL */
57 {1, 13, 2, 0, 1}, /* CRS */
58
59 /* ETH4 */
60 {1, 18, 1, 0, 1}, /* TxD0 */
61 {1, 19, 1, 0, 1}, /* TxD1 */
62 {1, 20, 1, 0, 1}, /* TxD2 */
63 {1, 21, 1, 0, 1}, /* TxD3 */
64 {1, 27, 1, 0, 1}, /* TxER */
65 {1, 30, 1, 0, 1}, /* TxEN */
66 {3, 6, 2, 0, 1}, /* TxCLK->CLK8 */
67
68 {1, 22, 2, 0, 1}, /* RxD0 */
69 {1, 23, 2, 0, 1}, /* RxD1 */
70 {1, 24, 2, 0, 1}, /* RxD2 */
71 {1, 25, 2, 0, 1}, /* RxD3 */
72 {1, 26, 1, 0, 1}, /* RxER */
73 {1, 28, 2, 0, 1}, /* Rx_DV */
74 {3, 31, 2, 0, 1}, /* RxCLK->CLK7 */
75 {1, 29, 2, 0, 1}, /* COL */
76 {1, 31, 2, 0, 1}, /* CRS */
77
78 {3, 4, 3, 0, 2}, /* MDIO */
79 {3, 5, 1, 0, 2}, /* MDC */
80
81 {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
82};
83
84int board_early_init_f(void)
85{
86 volatile u8 *bcsr = (volatile u8 *)CFG_BCSR;
87
88 /* Enable flash write */
89 bcsr[9] &= ~0x08;
90
91 return 0;
92}
93
Tony Li14778582007-08-17 10:35:59 +080094int board_early_init_r(void)
95{
96#ifdef CONFIG_PQ_MDS_PIB
97 pib_init();
98#endif
99 return 0;
100}
101
Dave Liu24c3aca2006-12-07 21:13:15 +0800102int fixed_sdram(void);
103
104long int initdram(int board_type)
105{
106 volatile immap_t *im = (immap_t *) CFG_IMMR;
107 u32 msize = 0;
108
109 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
110 return -1;
111
112 /* DDR SDRAM - Main SODIMM */
113 im->sysconf.ddrlaw[0].bar = CFG_DDR_BASE & LAWBAR_BAR;
114
115 msize = fixed_sdram();
116
117 puts("\n DDR RAM: ");
118
119 /* return total bus SDRAM size(bytes) -- DDR */
120 return (msize * 1024 * 1024);
121}
122
123/*************************************************************************
124 * fixed sdram init -- doesn't use serial presence detect.
125 ************************************************************************/
126int fixed_sdram(void)
127{
128 volatile immap_t *im = (immap_t *) CFG_IMMR;
129 u32 msize = 0;
130 u32 ddr_size;
131 u32 ddr_size_log2;
132
133 msize = CFG_DDR_SIZE;
134 for (ddr_size = msize << 20, ddr_size_log2 = 0;
135 (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
136 if (ddr_size & 1) {
137 return -1;
138 }
139 }
140 im->sysconf.ddrlaw[0].ar =
141 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
142#if (CFG_DDR_SIZE != 128)
143#warning Currenly any ddr size other than 128 is not supported
144#endif
145 im->ddr.sdram_clk_cntl = CFG_DDR_CLK_CNTL;
146 im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
147 im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
148 im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
149 im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
150 im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
151 im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
152 im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
153 im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
154 im->ddr.sdram_mode = CFG_DDR_MODE;
155 im->ddr.sdram_mode2 = CFG_DDR_MODE2;
156 im->ddr.sdram_interval = CFG_DDR_INTERVAL;
157 __asm__ __volatile__ ("sync");
158 udelay(200);
159
160 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
161 __asm__ __volatile__ ("sync");
162 return msize;
163}
164
165int checkboard(void)
166{
167 puts("Board: Freescale MPC832XEMDS\n");
168 return 0;
169}
170
Kim Phillips3fde9e82007-08-15 22:30:33 -0500171#if defined(CONFIG_OF_BOARD_SETUP)
172void ft_board_setup(void *blob, bd_t *bd)
Dave Liu24c3aca2006-12-07 21:13:15 +0800173{
Kim Phillips3fde9e82007-08-15 22:30:33 -0500174#if defined(CONFIG_OF_FLAT_TREE)
Dave Liu24c3aca2006-12-07 21:13:15 +0800175 u32 *p;
176 int len;
177
Dave Liu24c3aca2006-12-07 21:13:15 +0800178 p = ft_get_prop(blob, "/memory/reg", &len);
179 if (p != NULL) {
180 *p++ = cpu_to_be32(bd->bi_memstart);
181 *p = cpu_to_be32(bd->bi_memsize);
182 }
Kim Phillips3fde9e82007-08-15 22:30:33 -0500183#endif
184 ft_cpu_setup(blob, bd);
185#ifdef CONFIG_PCI
186 ft_pci_setup(blob, bd);
187#endif
Dave Liu24c3aca2006-12-07 21:13:15 +0800188}
189#endif