blob: d4922fe1e123f372dd00e9bfc059d9d84258e1cb [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dave Liue740c462006-12-07 21:13:15 +08002/*
3 * Copyright (C) 2006 Freescale Semiconductor, Inc.
4 *
5 * Dave Liu <daveliu@freescale.com>
Dave Liue740c462006-12-07 21:13:15 +08006 */
7
8#include <common.h>
Simon Glass3bbe70c2019-12-28 10:44:54 -07009#include <fdt_support.h>
Simon Glassa7b51302019-11-14 12:57:46 -070010#include <init.h>
Dave Liue740c462006-12-07 21:13:15 +080011#include <ioports.h>
12#include <mpc83xx.h>
13#include <i2c.h>
Dave Liue740c462006-12-07 21:13:15 +080014#include <miiphy.h>
15#include <command.h>
16#if defined(CONFIG_PCI)
17#include <pci.h>
18#endif
Dave Liue740c462006-12-07 21:13:15 +080019#include <asm/mmu.h>
Kim Phillips3204c7c2007-12-20 15:57:28 -060020#if defined(CONFIG_OF_LIBFDT)
Masahiro Yamada75f82d02018-03-05 01:20:11 +090021#include <linux/libfdt.h>
Dave Liue740c462006-12-07 21:13:15 +080022#endif
Tony Lic8b57f12007-08-17 10:35:59 +080023#if defined(CONFIG_PQ_MDS_PIB)
Kim Phillipsd8ded962007-08-16 22:53:09 -050024#include "../common/pq-mds-pib.h"
Tony Lic8b57f12007-08-17 10:35:59 +080025#endif
Dave Liue740c462006-12-07 21:13:15 +080026
Simon Glass39f90ba2017-03-31 08:40:25 -060027DECLARE_GLOBAL_DATA_PTR;
28
Dave Liue740c462006-12-07 21:13:15 +080029const qe_iop_conf_t qe_iop_conf_tab[] = {
30 /* ETH3 */
31 {1, 0, 1, 0, 1}, /* TxD0 */
32 {1, 1, 1, 0, 1}, /* TxD1 */
33 {1, 2, 1, 0, 1}, /* TxD2 */
34 {1, 3, 1, 0, 1}, /* TxD3 */
35 {1, 9, 1, 0, 1}, /* TxER */
36 {1, 12, 1, 0, 1}, /* TxEN */
37 {3, 24, 2, 0, 1}, /* TxCLK->CLK10 */
38
39 {1, 4, 2, 0, 1}, /* RxD0 */
40 {1, 5, 2, 0, 1}, /* RxD1 */
41 {1, 6, 2, 0, 1}, /* RxD2 */
42 {1, 7, 2, 0, 1}, /* RxD3 */
43 {1, 8, 2, 0, 1}, /* RxER */
44 {1, 10, 2, 0, 1}, /* RxDV */
45 {0, 13, 2, 0, 1}, /* RxCLK->CLK9 */
46 {1, 11, 2, 0, 1}, /* COL */
47 {1, 13, 2, 0, 1}, /* CRS */
48
49 /* ETH4 */
50 {1, 18, 1, 0, 1}, /* TxD0 */
51 {1, 19, 1, 0, 1}, /* TxD1 */
52 {1, 20, 1, 0, 1}, /* TxD2 */
53 {1, 21, 1, 0, 1}, /* TxD3 */
54 {1, 27, 1, 0, 1}, /* TxER */
55 {1, 30, 1, 0, 1}, /* TxEN */
56 {3, 6, 2, 0, 1}, /* TxCLK->CLK8 */
57
58 {1, 22, 2, 0, 1}, /* RxD0 */
59 {1, 23, 2, 0, 1}, /* RxD1 */
60 {1, 24, 2, 0, 1}, /* RxD2 */
61 {1, 25, 2, 0, 1}, /* RxD3 */
62 {1, 26, 1, 0, 1}, /* RxER */
63 {1, 28, 2, 0, 1}, /* Rx_DV */
64 {3, 31, 2, 0, 1}, /* RxCLK->CLK7 */
65 {1, 29, 2, 0, 1}, /* COL */
66 {1, 31, 2, 0, 1}, /* CRS */
67
68 {3, 4, 3, 0, 2}, /* MDIO */
69 {3, 5, 1, 0, 2}, /* MDC */
70
71 {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
72};
73
74int board_early_init_f(void)
75{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020076 volatile u8 *bcsr = (volatile u8 *)CONFIG_SYS_BCSR;
Dave Liue740c462006-12-07 21:13:15 +080077
78 /* Enable flash write */
79 bcsr[9] &= ~0x08;
80
81 return 0;
82}
83
Tony Lic8b57f12007-08-17 10:35:59 +080084int board_early_init_r(void)
85{
86#ifdef CONFIG_PQ_MDS_PIB
87 pib_init();
88#endif
89 return 0;
90}
91
Dave Liue740c462006-12-07 21:13:15 +080092int fixed_sdram(void);
93
Simon Glassd35f3382017-04-06 12:47:05 -060094int dram_init(void)
Dave Liue740c462006-12-07 21:13:15 +080095{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020096 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
Dave Liue740c462006-12-07 21:13:15 +080097 u32 msize = 0;
98
99 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
Simon Glass39f90ba2017-03-31 08:40:25 -0600100 return -ENXIO;
Dave Liue740c462006-12-07 21:13:15 +0800101
102 /* DDR SDRAM - Main SODIMM */
Mario Sixc9f92772019-01-21 09:18:15 +0100103 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_SDRAM_BASE & LAWBAR_BAR;
Dave Liue740c462006-12-07 21:13:15 +0800104
105 msize = fixed_sdram();
106
Simon Glass39f90ba2017-03-31 08:40:25 -0600107 /* set total bus SDRAM size(bytes) -- DDR */
108 gd->ram_size = msize * 1024 * 1024;
109
110 return 0;
Dave Liue740c462006-12-07 21:13:15 +0800111}
112
113/*************************************************************************
114 * fixed sdram init -- doesn't use serial presence detect.
115 ************************************************************************/
116int fixed_sdram(void)
117{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200118 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
Dave Liue740c462006-12-07 21:13:15 +0800119 u32 msize = 0;
120 u32 ddr_size;
121 u32 ddr_size_log2;
122
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200123 msize = CONFIG_SYS_DDR_SIZE;
Dave Liue740c462006-12-07 21:13:15 +0800124 for (ddr_size = msize << 20, ddr_size_log2 = 0;
125 (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
126 if (ddr_size & 1) {
127 return -1;
128 }
129 }
130 im->sysconf.ddrlaw[0].ar =
131 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200132#if (CONFIG_SYS_DDR_SIZE != 128)
Dave Liue740c462006-12-07 21:13:15 +0800133#warning Currenly any ddr size other than 128 is not supported
134#endif
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200135 im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
136 im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
137 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
138 im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
139 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
140 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
141 im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
142 im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
143 im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
144 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
145 im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
146 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
Dave Liue740c462006-12-07 21:13:15 +0800147 __asm__ __volatile__ ("sync");
148 udelay(200);
149
150 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
151 __asm__ __volatile__ ("sync");
152 return msize;
153}
154
155int checkboard(void)
156{
157 puts("Board: Freescale MPC832XEMDS\n");
158 return 0;
159}
160
Kim Phillips21416812007-08-15 22:30:33 -0500161#if defined(CONFIG_OF_BOARD_SETUP)
Simon Glass2aec3cc2014-10-23 18:58:47 -0600162int ft_board_setup(void *blob, bd_t *bd)
Dave Liue740c462006-12-07 21:13:15 +0800163{
Kim Phillips21416812007-08-15 22:30:33 -0500164 ft_cpu_setup(blob, bd);
165#ifdef CONFIG_PCI
166 ft_pci_setup(blob, bd);
167#endif
Simon Glass2aec3cc2014-10-23 18:58:47 -0600168
169 return 0;
Dave Liue740c462006-12-07 21:13:15 +0800170}
171#endif