blob: d8c87458e89ca3f986d6b735ce9cfb62b3ac9585 [file] [log] [blame]
Roy Zang3f7f6b82011-06-09 11:30:52 +08001/*
ramneek mehresh3d7506f2012-04-18 19:39:53 +00002 * Copyright 2010-2012 Freescale Semiconductor, Inc.
Roy Zang3f7f6b82011-06-09 11:30:52 +08003 *
4 * Authors: Roy Zang <tie-fei.zang@freescale.com>
5 * Chunhe Lan <b25806@freescale.com>
6 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Roy Zang3f7f6b82011-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>
York Sun5614e712013-09-30 09:22:09 -070019#include <fsl_ddr_sdram.h>
Roy Zang3f7f6b82011-06-09 11:30:52 +080020#include <asm/fsl_portals.h>
21#include <libfdt.h>
22#include <fdt_support.h>
23#include <netdev.h>
24#include <malloc.h>
Roy Zangfe1a1da2011-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 Zang3f7f6b82011-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
York Sun9a17eb52013-11-18 10:29:32 -080061 struct ccsr_ddr __iomem *ddr =
62 (struct ccsr_ddr __iomem *)CONFIG_SYS_FSL_DDR_ADDR;
Roy Zang3f7f6b82011-06-09 11:30:52 +080063
64 set_next_law(0, LAW_SIZE_2G, LAW_TRGT_IF_DDR_1);
65
66 out_be32(&ddr->cs0_bnds, CONFIG_SYS_DDR_CS0_BNDS);
67 out_be32(&ddr->cs0_config, CONFIG_SYS_DDR_CS0_CONFIG);
68 out_be32(&ddr->cs1_bnds, CONFIG_SYS_DDR_CS1_BNDS);
69 out_be32(&ddr->cs1_config, CONFIG_SYS_DDR_CS1_CONFIG);
70 out_be32(&ddr->timing_cfg_3, CONFIG_SYS_DDR_TIMING_3);
71 out_be32(&ddr->timing_cfg_0, CONFIG_SYS_DDR_TIMING_0);
72 out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1);
73 out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2);
74 out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_CONTROL2);
75 out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_MODE_1);
76 out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_MODE_2);
77 out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_INTERVAL);
78 out_be32(&ddr->sdram_data_init, CONFIG_SYS_DDR_DATA_INIT);
79 out_be32(&ddr->sdram_clk_cntl, CONFIG_SYS_DDR_CLK_CTRL);
80 out_be32(&ddr->timing_cfg_4, CONFIG_SYS_DDR_TIMING_4);
81 out_be32(&ddr->timing_cfg_5, CONFIG_SYS_DDR_TIMING_5);
82 out_be32(&ddr->ddr_zq_cntl, CONFIG_SYS_DDR_ZQ_CNTL);
83 out_be32(&ddr->ddr_wrlvl_cntl, CONFIG_SYS_DDR_WRLVL_CNTL);
84 out_be32(&ddr->ddr_cdr1, CONFIG_SYS_DDR_CDR_1);
85 out_be32(&ddr->ddr_cdr2, CONFIG_SYS_DDR_CDR_2);
86 out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL);
87#endif
88 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024ul;
89}
90
91#ifdef CONFIG_PCI
92void pci_init_board(void)
93{
94 fsl_pcie_init_board(0);
95}
96#endif
97
98int board_early_init_r(void)
99{
100 const unsigned int flashbase = CONFIG_SYS_BCSR_BASE;
101 const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
102
103 /*
104 * Remap Boot flash + BCSR region to caching-inhibited
105 * so that flash can be erased properly.
106 */
107
108 /* Flush d-cache and invalidate i-cache of any FLASH data */
109 flush_dcache();
110 invalidate_icache();
111
112 /* invalidate existing TLB entry for flash + bcsr */
113 disable_tlb(flash_esel);
114
115 set_tlb(1, flashbase, CONFIG_SYS_BCSR_BASE_PHYS,
116 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
117 0, flash_esel, BOOKE_PAGESZ_256M, 1);
118
119 setup_portals();
120
121 return 0;
122}
123
124unsigned long get_board_sys_clk(ulong dummy)
125{
126 return gd->bus_clk;
127}
128
129unsigned long get_board_ddr_clk(ulong dummy)
130{
131 return gd->mem_clk;
132}
133
134int board_eth_init(bd_t *bis)
135{
Roy Zangfe1a1da2011-02-04 13:42:45 -0600136 u8 *bcsr = (u8 *)BCSR_ACCESS_REG_ADDR;
137 ccsr_gur_t *gur = (ccsr_gur_t *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
138 struct fsl_pq_mdio_info dtsec_mdio_info;
139
140 /*
141 * Need to set dTSEC 1 pin multiplexing to TSEC. The default setting
142 * is not correct.
143 */
144 setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TSEC1_1);
145
146 dtsec_mdio_info.regs =
147 (struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR;
148 dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
149
150 /* Register the 1G MDIO bus */
151 fsl_pq_mdio_init(bis, &dtsec_mdio_info);
152
153 fm_info_set_phy_address(FM1_DTSEC1, CONFIG_SYS_FM1_DTSEC1_PHY_ADDR);
154 fm_info_set_phy_address(FM1_DTSEC2, CONFIG_SYS_FM1_DTSEC2_PHY_ADDR);
155
156 fm_info_set_mdio(FM1_DTSEC1,
157 miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
158 fm_info_set_mdio(FM1_DTSEC2,
159 miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
160
161 /* Make SERDES connected to SGMII by cleaing bcsr19[7] */
162 if (fm_info_get_enet_if(FM1_DTSEC1) == PHY_INTERFACE_MODE_SGMII)
163 clrbits_8(&bcsr[19], BCSR19_SGMII_SEL_L);
164
165#ifdef CONFIG_FMAN_ENET
166 cpu_eth_init(bis);
167#endif
168
Roy Zang3f7f6b82011-06-09 11:30:52 +0800169 return pci_eth_init(bis);
170}
171
172#if defined(CONFIG_OF_BOARD_SETUP)
173void ft_board_setup(void *blob, bd_t *bd)
174{
175 phys_addr_t base;
176 phys_size_t size;
177
178 ft_cpu_setup(blob, bd);
179
180 base = getenv_bootm_low();
181 size = getenv_bootm_size();
182
183 fdt_fixup_memory(blob, (u64)base, (u64)size);
Roy Zangfe1a1da2011-02-04 13:42:45 -0600184
Chunhe Lan617e46e2012-04-18 15:58:56 -0500185 /* By default NOR is on, and NAND is disabled */
186#ifdef CONFIG_NAND_U_BOOT
187 do_fixup_by_path_string(blob, "nor_flash", "status", "disabled");
188 do_fixup_by_path_string(blob, "nand_flash", "status", "okay");
189#endif
ramneek mehresh3d7506f2012-04-18 19:39:53 +0000190#ifdef CONFIG_HAS_FSL_DR_USB
191 fdt_fixup_dr_usb(blob, bd);
192#endif
Chunhe Lan617e46e2012-04-18 15:58:56 -0500193
Roy Zangfe1a1da2011-02-04 13:42:45 -0600194 fdt_fixup_fman_ethernet(blob);
Roy Zang3f7f6b82011-06-09 11:30:52 +0800195}
196#endif