blob: f9a59a6443e43d3efea5862966193547d5bd60f3 [file] [log] [blame]
Heiko Schocherde044362008-11-20 09:57:47 +01001/*
2 * Copyright (C) 2006 Freescale Semiconductor, Inc.
3 * Dave Liu <daveliu@freescale.com>
4 *
5 * Copyright (C) 2007 Logic Product Development, Inc.
6 * Peter Barada <peterb@logicpd.com>
7 *
8 * Copyright (C) 2007 MontaVista Software, Inc.
9 * Anton Vorontsov <avorontsov@ru.mvista.com>
10 *
11 * (C) Copyright 2008
12 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 */
19
20#include <common.h>
21#include <ioports.h>
22#include <mpc83xx.h>
23#include <i2c.h>
24#include <miiphy.h>
25#include <asm/io.h>
26#include <asm/mmu.h>
27#include <pci.h>
28#include <libfdt.h>
29
30const qe_iop_conf_t qe_iop_conf_tab[] = {
31 /* port pin dir open_drain assign */
32
33 /* MDIO */
34 {0, 1, 3, 0, 2}, /* MDIO */
35 {0, 2, 1, 0, 1}, /* MDC */
36
37 /* UCC4 - UEC */
38 {1, 14, 1, 0, 1}, /* TxD0 */
39 {1, 15, 1, 0, 1}, /* TxD1 */
40 {1, 20, 2, 0, 1}, /* RxD0 */
41 {1, 21, 2, 0, 1}, /* RxD1 */
42 {1, 18, 1, 0, 1}, /* TX_EN */
43 {1, 26, 2, 0, 1}, /* RX_DV */
44 {1, 27, 2, 0, 1}, /* RX_ER */
45 {1, 24, 2, 0, 1}, /* COL */
46 {1, 25, 2, 0, 1}, /* CRS */
47 {2, 15, 2, 0, 1}, /* TX_CLK - CLK16 */
48 {2, 16, 2, 0, 1}, /* RX_CLK - CLK17 */
49
50 /* DUART - UART2 */
51 {5, 0, 1, 0, 2}, /* UART2_SOUT */
52 {5, 2, 1, 0, 1}, /* UART2_RTS */
53 {5, 3, 2, 0, 2}, /* UART2_SIN */
54 {5, 1, 2, 0, 3}, /* UART2_CTS */
55
56 /* END of table */
57 {0, 0, 0, 0, QE_IOP_TAB_END},
58};
59
60int board_early_init_r (void)
61{
62 void *reg = (void *)(CONFIG_SYS_IMMR + 0x14a8);
63 u32 val;
64
65 /*
66 * Because of errata in the UCCs, we have to write to the reserved
67 * registers to slow the clocks down.
68 */
69 val = in_be32 (reg);
70 /* UCC1 */
71 val |= 0x00003000;
72 /* UCC2 */
73 val |= 0x0c000000;
74 out_be32 (reg, val);
75 /* enable the PHY on the PIGGY */
76 setbits (8, (void *)(CONFIG_SYS_PIGGY_BASE + 0x10003), 0x01);
77
78 return 0;
79}
80
81int fixed_sdram(void)
82{
83 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
84 u32 msize = 0;
85 u32 ddr_size;
86 u32 ddr_size_log2;
87
88 msize = CONFIG_SYS_DDR_SIZE;
89 for (ddr_size = msize << 20, ddr_size_log2 = 0;
90 (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
91 if (ddr_size & 1)
92 return -1;
93 }
94
95 im->sysconf.ddrlaw[0].ar =
96 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
97
98 im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
99 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
100 im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
101 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
102 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
103 im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
104 im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
105 im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
106 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
107 im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
108 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
109 im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
110 udelay (200);
111 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
112
113 return msize;
114}
115
116phys_size_t initdram (int board_type)
117{
118#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
119 extern void ddr_enable_ecc (unsigned int dram_size);
120#endif
121 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
122 u32 msize = 0;
123
124 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
125 return -1;
126
127 /* DDR SDRAM - Main SODIMM */
128 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
129 msize = fixed_sdram ();
130
131#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
132 /*
133 * Initialize DDR ECC byte
134 */
135 ddr_enable_ecc (msize * 1024 * 1024);
136#endif
137
138 /* return total bus SDRAM size(bytes) -- DDR */
139 return (msize * 1024 * 1024);
140}
141
142int checkboard (void)
143{
144 puts ("Board: Keymile kmeter1\n");
145 return 0;
146}
147
148#if defined(CONFIG_OF_BOARD_SETUP)
149void ft_board_setup (void *blob, bd_t *bd)
150{
151 ft_cpu_setup (blob, bd);
152}
153#endif