blob: 7c54b65c1dc0a68244b784b0547566b2b7517f5a [file] [log] [blame]
Roy Zang3e9ecf82011-06-09 11:30:52 +08001/*
ramneek mehresh3d339632012-04-18 19:39:53 +00002 * Copyright 2010-2012 Freescale Semiconductor, Inc.
Roy Zang3e9ecf82011-06-09 11:30:52 +08003 *
4 * Authors: Roy Zang <tie-fei.zang@freescale.com>
5 * Chunhe Lan <b25806@freescale.com>
6 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Roy Zang3e9ecf82011-06-09 11:30:52 +08008 */
9
10#include <common.h>
11#include <command.h>
12#include <pci.h>
13#include <asm/io.h>
14#include <asm/cache.h>
15#include <asm/processor.h>
16#include <asm/mmu.h>
17#include <asm/immap_85xx.h>
18#include <asm/fsl_pci.h>
19#include <asm/fsl_ddr_sdram.h>
20#include <asm/fsl_portals.h>
21#include <libfdt.h>
22#include <fdt_support.h>
23#include <netdev.h>
24#include <malloc.h>
Roy Zang6c6752d2011-02-04 13:42:45 -060025#include <fm_eth.h>
26#include <fsl_mdio.h>
27#include <miiphy.h>
28#include <phy.h>
29#include <asm/fsl_dtsec.h>
Roy Zang3e9ecf82011-06-09 11:30:52 +080030
31#include "bcsr.h"
32
33DECLARE_GLOBAL_DATA_PTR;
34
35int board_early_init_f(void)
36{
37 fsl_lbc_t *lbc = LBC_BASE_ADDR;
38
39 /* Set ABSWP to implement conversion of addresses in the LBC */
40 setbits_be32(&lbc->lbcr, CONFIG_SYS_LBC_LBCR);
41
42 return 0;
43}
44
45int checkboard(void)
46{
47 u8 *bcsr = (u8 *)BCSR_ACCESS_REG_ADDR;
48
49 printf("Board: P1023 RDS\n");
50
51 clrbits_8(&bcsr[15], BCSR15_I2C_BUS0_SEG_CLR);
52 setbits_8(&bcsr[15], BCSR15_I2C_BUS0_SEG0);
53
54 return 0;
55}
56
57/* Fixed sdram init -- doesn't use serial presence detect. */
58phys_size_t fixed_sdram(void)
59{
60#ifndef CONFIG_SYS_RAMBOOT
Andy Fleming992562c2012-10-23 19:03:46 -050061 ccsr_ddr_t *ddr = (ccsr_ddr_t *)CONFIG_SYS_MPC8xxx_DDR_ADDR;
Roy Zang3e9ecf82011-06-09 11:30:52 +080062
63 set_next_law(0, LAW_SIZE_2G, LAW_TRGT_IF_DDR_1);
64
65 out_be32(&ddr->cs0_bnds, CONFIG_SYS_DDR_CS0_BNDS);
66 out_be32(&ddr->cs0_config, CONFIG_SYS_DDR_CS0_CONFIG);
67 out_be32(&ddr->cs1_bnds, CONFIG_SYS_DDR_CS1_BNDS);
68 out_be32(&ddr->cs1_config, CONFIG_SYS_DDR_CS1_CONFIG);
69 out_be32(&ddr->timing_cfg_3, CONFIG_SYS_DDR_TIMING_3);
70 out_be32(&ddr->timing_cfg_0, CONFIG_SYS_DDR_TIMING_0);
71 out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1);
72 out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2);
73 out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_CONTROL2);
74 out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_MODE_1);
75 out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_MODE_2);
76 out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_INTERVAL);
77 out_be32(&ddr->sdram_data_init, CONFIG_SYS_DDR_DATA_INIT);
78 out_be32(&ddr->sdram_clk_cntl, CONFIG_SYS_DDR_CLK_CTRL);
79 out_be32(&ddr->timing_cfg_4, CONFIG_SYS_DDR_TIMING_4);
80 out_be32(&ddr->timing_cfg_5, CONFIG_SYS_DDR_TIMING_5);
81 out_be32(&ddr->ddr_zq_cntl, CONFIG_SYS_DDR_ZQ_CNTL);
82 out_be32(&ddr->ddr_wrlvl_cntl, CONFIG_SYS_DDR_WRLVL_CNTL);
83 out_be32(&ddr->ddr_cdr1, CONFIG_SYS_DDR_CDR_1);
84 out_be32(&ddr->ddr_cdr2, CONFIG_SYS_DDR_CDR_2);
85 out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL);
86#endif
87 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024ul;
88}
89
90#ifdef CONFIG_PCI
91void pci_init_board(void)
92{
93 fsl_pcie_init_board(0);
94}
95#endif
96
97int board_early_init_r(void)
98{
99 const unsigned int flashbase = CONFIG_SYS_BCSR_BASE;
100 const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
101
102 /*
103 * Remap Boot flash + BCSR region to caching-inhibited
104 * so that flash can be erased properly.
105 */
106
107 /* Flush d-cache and invalidate i-cache of any FLASH data */
108 flush_dcache();
109 invalidate_icache();
110
111 /* invalidate existing TLB entry for flash + bcsr */
112 disable_tlb(flash_esel);
113
114 set_tlb(1, flashbase, CONFIG_SYS_BCSR_BASE_PHYS,
115 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
116 0, flash_esel, BOOKE_PAGESZ_256M, 1);
117
118 setup_portals();
119
120 return 0;
121}
122
123unsigned long get_board_sys_clk(ulong dummy)
124{
125 return gd->bus_clk;
126}
127
128unsigned long get_board_ddr_clk(ulong dummy)
129{
130 return gd->mem_clk;
131}
132
133int board_eth_init(bd_t *bis)
134{
Roy Zang6c6752d2011-02-04 13:42:45 -0600135 u8 *bcsr = (u8 *)BCSR_ACCESS_REG_ADDR;
136 ccsr_gur_t *gur = (ccsr_gur_t *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
137 struct fsl_pq_mdio_info dtsec_mdio_info;
138
139 /*
140 * Need to set dTSEC 1 pin multiplexing to TSEC. The default setting
141 * is not correct.
142 */
143 setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TSEC1_1);
144
145 dtsec_mdio_info.regs =
146 (struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR;
147 dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
148
149 /* Register the 1G MDIO bus */
150 fsl_pq_mdio_init(bis, &dtsec_mdio_info);
151
152 fm_info_set_phy_address(FM1_DTSEC1, CONFIG_SYS_FM1_DTSEC1_PHY_ADDR);
153 fm_info_set_phy_address(FM1_DTSEC2, CONFIG_SYS_FM1_DTSEC2_PHY_ADDR);
154
155 fm_info_set_mdio(FM1_DTSEC1,
156 miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
157 fm_info_set_mdio(FM1_DTSEC2,
158 miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
159
160 /* Make SERDES connected to SGMII by cleaing bcsr19[7] */
161 if (fm_info_get_enet_if(FM1_DTSEC1) == PHY_INTERFACE_MODE_SGMII)
162 clrbits_8(&bcsr[19], BCSR19_SGMII_SEL_L);
163
164#ifdef CONFIG_FMAN_ENET
165 cpu_eth_init(bis);
166#endif
167
Roy Zang3e9ecf82011-06-09 11:30:52 +0800168 return pci_eth_init(bis);
169}
170
171#if defined(CONFIG_OF_BOARD_SETUP)
172void ft_board_setup(void *blob, bd_t *bd)
173{
174 phys_addr_t base;
175 phys_size_t size;
176
177 ft_cpu_setup(blob, bd);
178
179 base = getenv_bootm_low();
180 size = getenv_bootm_size();
181
182 fdt_fixup_memory(blob, (u64)base, (u64)size);
Roy Zang6c6752d2011-02-04 13:42:45 -0600183
Chunhe Lanb1272d62012-04-18 15:58:56 -0500184 /* By default NOR is on, and NAND is disabled */
185#ifdef CONFIG_NAND_U_BOOT
186 do_fixup_by_path_string(blob, "nor_flash", "status", "disabled");
187 do_fixup_by_path_string(blob, "nand_flash", "status", "okay");
188#endif
ramneek mehresh3d339632012-04-18 19:39:53 +0000189#ifdef CONFIG_HAS_FSL_DR_USB
190 fdt_fixup_dr_usb(blob, bd);
191#endif
Chunhe Lanb1272d62012-04-18 15:58:56 -0500192
Roy Zang6c6752d2011-02-04 13:42:45 -0600193 fdt_fixup_fman_ethernet(blob);
Roy Zang3e9ecf82011-06-09 11:30:52 +0800194}
195#endif