blob: b49e03e4f973f95c8a6e49e87ba04d9f77b9ddb6 [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 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Dave Liu24c3aca2006-12-07 21:13:15 +08007 */
8
9#include <common.h>
10#include <ioports.h>
11#include <mpc83xx.h>
12#include <i2c.h>
Dave Liu24c3aca2006-12-07 21:13:15 +080013#include <miiphy.h>
14#include <command.h>
15#if defined(CONFIG_PCI)
16#include <pci.h>
17#endif
Dave Liu24c3aca2006-12-07 21:13:15 +080018#include <asm/mmu.h>
Kim Phillipsb3458d22007-12-20 15:57:28 -060019#if defined(CONFIG_OF_LIBFDT)
Kim Phillips3fde9e82007-08-15 22:30:33 -050020#include <libfdt.h>
Dave Liu24c3aca2006-12-07 21:13:15 +080021#endif
Tony Li14778582007-08-17 10:35:59 +080022#if defined(CONFIG_PQ_MDS_PIB)
Kim Phillipse58fe952007-08-16 22:53:09 -050023#include "../common/pq-mds-pib.h"
Tony Li14778582007-08-17 10:35:59 +080024#endif
Dave Liu24c3aca2006-12-07 21:13:15 +080025
Simon Glass088454c2017-03-31 08:40:25 -060026DECLARE_GLOBAL_DATA_PTR;
27
Dave Liu24c3aca2006-12-07 21:13:15 +080028const qe_iop_conf_t qe_iop_conf_tab[] = {
29 /* ETH3 */
30 {1, 0, 1, 0, 1}, /* TxD0 */
31 {1, 1, 1, 0, 1}, /* TxD1 */
32 {1, 2, 1, 0, 1}, /* TxD2 */
33 {1, 3, 1, 0, 1}, /* TxD3 */
34 {1, 9, 1, 0, 1}, /* TxER */
35 {1, 12, 1, 0, 1}, /* TxEN */
36 {3, 24, 2, 0, 1}, /* TxCLK->CLK10 */
37
38 {1, 4, 2, 0, 1}, /* RxD0 */
39 {1, 5, 2, 0, 1}, /* RxD1 */
40 {1, 6, 2, 0, 1}, /* RxD2 */
41 {1, 7, 2, 0, 1}, /* RxD3 */
42 {1, 8, 2, 0, 1}, /* RxER */
43 {1, 10, 2, 0, 1}, /* RxDV */
44 {0, 13, 2, 0, 1}, /* RxCLK->CLK9 */
45 {1, 11, 2, 0, 1}, /* COL */
46 {1, 13, 2, 0, 1}, /* CRS */
47
48 /* ETH4 */
49 {1, 18, 1, 0, 1}, /* TxD0 */
50 {1, 19, 1, 0, 1}, /* TxD1 */
51 {1, 20, 1, 0, 1}, /* TxD2 */
52 {1, 21, 1, 0, 1}, /* TxD3 */
53 {1, 27, 1, 0, 1}, /* TxER */
54 {1, 30, 1, 0, 1}, /* TxEN */
55 {3, 6, 2, 0, 1}, /* TxCLK->CLK8 */
56
57 {1, 22, 2, 0, 1}, /* RxD0 */
58 {1, 23, 2, 0, 1}, /* RxD1 */
59 {1, 24, 2, 0, 1}, /* RxD2 */
60 {1, 25, 2, 0, 1}, /* RxD3 */
61 {1, 26, 1, 0, 1}, /* RxER */
62 {1, 28, 2, 0, 1}, /* Rx_DV */
63 {3, 31, 2, 0, 1}, /* RxCLK->CLK7 */
64 {1, 29, 2, 0, 1}, /* COL */
65 {1, 31, 2, 0, 1}, /* CRS */
66
67 {3, 4, 3, 0, 2}, /* MDIO */
68 {3, 5, 1, 0, 2}, /* MDC */
69
70 {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
71};
72
73int board_early_init_f(void)
74{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020075 volatile u8 *bcsr = (volatile u8 *)CONFIG_SYS_BCSR;
Dave Liu24c3aca2006-12-07 21:13:15 +080076
77 /* Enable flash write */
78 bcsr[9] &= ~0x08;
79
80 return 0;
81}
82
Tony Li14778582007-08-17 10:35:59 +080083int board_early_init_r(void)
84{
85#ifdef CONFIG_PQ_MDS_PIB
86 pib_init();
87#endif
88 return 0;
89}
90
Dave Liu24c3aca2006-12-07 21:13:15 +080091int fixed_sdram(void);
92
Simon Glassf1683aa2017-04-06 12:47:05 -060093int dram_init(void)
Dave Liu24c3aca2006-12-07 21:13:15 +080094{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020095 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
Dave Liu24c3aca2006-12-07 21:13:15 +080096 u32 msize = 0;
97
98 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
Simon Glass088454c2017-03-31 08:40:25 -060099 return -ENXIO;
Dave Liu24c3aca2006-12-07 21:13:15 +0800100
101 /* DDR SDRAM - Main SODIMM */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200102 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
Dave Liu24c3aca2006-12-07 21:13:15 +0800103
104 msize = fixed_sdram();
105
Simon Glass088454c2017-03-31 08:40:25 -0600106 /* set total bus SDRAM size(bytes) -- DDR */
107 gd->ram_size = msize * 1024 * 1024;
108
109 return 0;
Dave Liu24c3aca2006-12-07 21:13:15 +0800110}
111
112/*************************************************************************
113 * fixed sdram init -- doesn't use serial presence detect.
114 ************************************************************************/
115int fixed_sdram(void)
116{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200117 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
Dave Liu24c3aca2006-12-07 21:13:15 +0800118 u32 msize = 0;
119 u32 ddr_size;
120 u32 ddr_size_log2;
121
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200122 msize = CONFIG_SYS_DDR_SIZE;
Dave Liu24c3aca2006-12-07 21:13:15 +0800123 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);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200131#if (CONFIG_SYS_DDR_SIZE != 128)
Dave Liu24c3aca2006-12-07 21:13:15 +0800132#warning Currenly any ddr size other than 128 is not supported
133#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200134 im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
135 im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
136 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
137 im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
138 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
139 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
140 im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
141 im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
142 im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
143 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
144 im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
145 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
Dave Liu24c3aca2006-12-07 21:13:15 +0800146 __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 Phillips3fde9e82007-08-15 22:30:33 -0500160#if defined(CONFIG_OF_BOARD_SETUP)
Simon Glasse895a4b2014-10-23 18:58:47 -0600161int ft_board_setup(void *blob, bd_t *bd)
Dave Liu24c3aca2006-12-07 21:13:15 +0800162{
Kim Phillips3fde9e82007-08-15 22:30:33 -0500163 ft_cpu_setup(blob, bd);
164#ifdef CONFIG_PCI
165 ft_pci_setup(blob, bd);
166#endif
Simon Glasse895a4b2014-10-23 18:58:47 -0600167
168 return 0;
Dave Liu24c3aca2006-12-07 21:13:15 +0800169}
170#endif