]> Git Repo - J-u-boot.git/blame - board/freescale/mpc832xemds/mpc832xemds.c
common: Drop linux/delay.h from common header
[J-u-boot.git] / board / freescale / mpc832xemds / mpc832xemds.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
24c3aca3
DL
2/*
3 * Copyright (C) 2006 Freescale Semiconductor, Inc.
4 *
5 * Dave Liu <[email protected]>
24c3aca3
DL
6 */
7
8#include <common.h>
807765b0 9#include <fdt_support.h>
5255932f 10#include <init.h>
24c3aca3
DL
11#include <ioports.h>
12#include <mpc83xx.h>
13#include <i2c.h>
24c3aca3
DL
14#include <miiphy.h>
15#include <command.h>
16#if defined(CONFIG_PCI)
17#include <pci.h>
18#endif
24c3aca3 19#include <asm/mmu.h>
b3458d2c 20#if defined(CONFIG_OF_LIBFDT)
b08c8c48 21#include <linux/libfdt.h>
24c3aca3 22#endif
14778585 23#if defined(CONFIG_PQ_MDS_PIB)
e58fe957 24#include "../common/pq-mds-pib.h"
14778585 25#endif
c05ed00a 26#include <linux/delay.h>
24c3aca3 27
088454cd
SG
28DECLARE_GLOBAL_DATA_PTR;
29
24c3aca3
DL
30const qe_iop_conf_t qe_iop_conf_tab[] = {
31 /* ETH3 */
32 {1, 0, 1, 0, 1}, /* TxD0 */
33 {1, 1, 1, 0, 1}, /* TxD1 */
34 {1, 2, 1, 0, 1}, /* TxD2 */
35 {1, 3, 1, 0, 1}, /* TxD3 */
36 {1, 9, 1, 0, 1}, /* TxER */
37 {1, 12, 1, 0, 1}, /* TxEN */
38 {3, 24, 2, 0, 1}, /* TxCLK->CLK10 */
39
40 {1, 4, 2, 0, 1}, /* RxD0 */
41 {1, 5, 2, 0, 1}, /* RxD1 */
42 {1, 6, 2, 0, 1}, /* RxD2 */
43 {1, 7, 2, 0, 1}, /* RxD3 */
44 {1, 8, 2, 0, 1}, /* RxER */
45 {1, 10, 2, 0, 1}, /* RxDV */
46 {0, 13, 2, 0, 1}, /* RxCLK->CLK9 */
47 {1, 11, 2, 0, 1}, /* COL */
48 {1, 13, 2, 0, 1}, /* CRS */
49
50 /* ETH4 */
51 {1, 18, 1, 0, 1}, /* TxD0 */
52 {1, 19, 1, 0, 1}, /* TxD1 */
53 {1, 20, 1, 0, 1}, /* TxD2 */
54 {1, 21, 1, 0, 1}, /* TxD3 */
55 {1, 27, 1, 0, 1}, /* TxER */
56 {1, 30, 1, 0, 1}, /* TxEN */
57 {3, 6, 2, 0, 1}, /* TxCLK->CLK8 */
58
59 {1, 22, 2, 0, 1}, /* RxD0 */
60 {1, 23, 2, 0, 1}, /* RxD1 */
61 {1, 24, 2, 0, 1}, /* RxD2 */
62 {1, 25, 2, 0, 1}, /* RxD3 */
63 {1, 26, 1, 0, 1}, /* RxER */
64 {1, 28, 2, 0, 1}, /* Rx_DV */
65 {3, 31, 2, 0, 1}, /* RxCLK->CLK7 */
66 {1, 29, 2, 0, 1}, /* COL */
67 {1, 31, 2, 0, 1}, /* CRS */
68
69 {3, 4, 3, 0, 2}, /* MDIO */
70 {3, 5, 1, 0, 2}, /* MDC */
71
72 {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
73};
74
75int board_early_init_f(void)
76{
6d0f6bcf 77 volatile u8 *bcsr = (volatile u8 *)CONFIG_SYS_BCSR;
24c3aca3
DL
78
79 /* Enable flash write */
80 bcsr[9] &= ~0x08;
81
82 return 0;
83}
84
14778585
TL
85int board_early_init_r(void)
86{
87#ifdef CONFIG_PQ_MDS_PIB
88 pib_init();
89#endif
90 return 0;
91}
92
24c3aca3
DL
93int fixed_sdram(void);
94
f1683aa7 95int dram_init(void)
24c3aca3 96{
6d0f6bcf 97 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
24c3aca3
DL
98 u32 msize = 0;
99
100 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
088454cd 101 return -ENXIO;
24c3aca3
DL
102
103 /* DDR SDRAM - Main SODIMM */
8a81bfd2 104 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_SDRAM_BASE & LAWBAR_BAR;
24c3aca3
DL
105
106 msize = fixed_sdram();
107
088454cd
SG
108 /* set total bus SDRAM size(bytes) -- DDR */
109 gd->ram_size = msize * 1024 * 1024;
110
111 return 0;
24c3aca3
DL
112}
113
114/*************************************************************************
115 * fixed sdram init -- doesn't use serial presence detect.
116 ************************************************************************/
117int fixed_sdram(void)
118{
6d0f6bcf 119 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
24c3aca3
DL
120 u32 msize = 0;
121 u32 ddr_size;
122 u32 ddr_size_log2;
123
6d0f6bcf 124 msize = CONFIG_SYS_DDR_SIZE;
24c3aca3
DL
125 for (ddr_size = msize << 20, ddr_size_log2 = 0;
126 (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
127 if (ddr_size & 1) {
128 return -1;
129 }
130 }
131 im->sysconf.ddrlaw[0].ar =
132 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
6d0f6bcf 133#if (CONFIG_SYS_DDR_SIZE != 128)
24c3aca3
DL
134#warning Currenly any ddr size other than 128 is not supported
135#endif
6d0f6bcf
JCPV
136 im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
137 im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
138 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
139 im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
140 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
141 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
142 im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
143 im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
144 im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
145 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
146 im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
147 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
24c3aca3
DL
148 __asm__ __volatile__ ("sync");
149 udelay(200);
150
151 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
152 __asm__ __volatile__ ("sync");
153 return msize;
154}
155
156int checkboard(void)
157{
158 puts("Board: Freescale MPC832XEMDS\n");
159 return 0;
160}
161
3fde9e8b 162#if defined(CONFIG_OF_BOARD_SETUP)
e895a4b0 163int ft_board_setup(void *blob, bd_t *bd)
24c3aca3 164{
3fde9e8b
KP
165 ft_cpu_setup(blob, bd);
166#ifdef CONFIG_PCI
167 ft_pci_setup(blob, bd);
168#endif
e895a4b0
SG
169
170 return 0;
24c3aca3
DL
171}
172#endif
This page took 0.554325 seconds and 4 git commands to generate.