blob: 7db04043ca51a7c9da3d483bf36f92087559e29f [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Chunhe Lan57072332013-06-14 16:21:48 +08002/*
3 * Copyright 2013 Freescale Semiconductor, Inc.
4 *
5 * Authors: Roy Zang <tie-fei.zang@freescale.com>
6 * Chunhe Lan <Chunhe.Lan@freescale.com>
Chunhe Lan57072332013-06-14 16:21:48 +08007 */
8
9#include <common.h>
10#include <command.h>
Simon Glass7b51b572019-08-01 09:46:52 -060011#include <env.h>
Chunhe Lan57072332013-06-14 16:21:48 +080012#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>
Chunhe Lan57072332013-06-14 16:21:48 +080020#include <asm/fsl_portals.h>
Ahmed Mansour44262322017-12-15 16:01:00 -050021#include <fsl_qbman.h>
Masahiro Yamadab08c8c42018-03-05 01:20:11 +090022#include <linux/libfdt.h>
Chunhe Lan57072332013-06-14 16:21:48 +080023#include <fdt_support.h>
24#include <netdev.h>
25#include <malloc.h>
26#include <fm_eth.h>
27#include <fsl_mdio.h>
28#include <miiphy.h>
29#include <phy.h>
Shaohui Xie8225b2f2015-10-26 19:47:47 +080030#include <fsl_dtsec.h>
Chunhe Lan57072332013-06-14 16:21:48 +080031
32DECLARE_GLOBAL_DATA_PTR;
33
34int board_early_init_f(void)
35{
36 fsl_lbc_t *lbc = LBC_BASE_ADDR;
37
38 /* Set ABSWP to implement conversion of addresses in the LBC */
39 setbits_be32(&lbc->lbcr, CONFIG_SYS_LBC_LBCR);
40
41 return 0;
42}
43
44int checkboard(void)
45{
46 printf("Board: P1023 RDB\n");
47
48 return 0;
49}
50
51#ifdef CONFIG_PCI
52void pci_init_board(void)
53{
54 fsl_pcie_init_board(0);
55}
56#endif
57
58int board_early_init_r(void)
59{
60 const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
York Sun9d045682014-06-24 21:16:20 -070061 int flash_esel = find_tlb_idx((void *)flashbase, 1);
Chunhe Lan57072332013-06-14 16:21:48 +080062
63 /*
64 * Remap Boot flash + PROMJET region to caching-inhibited
65 * so that flash can be erased properly.
66 */
67
68 /* Flush d-cache and invalidate i-cache of any FLASH data */
69 flush_dcache();
70 invalidate_icache();
71
York Sun9d045682014-06-24 21:16:20 -070072 if (flash_esel == -1) {
73 /* very unlikely unless something is messed up */
74 puts("Error: Could not find TLB for FLASH BASE\n");
75 flash_esel = 2; /* give our best effort to continue */
76 } else {
77 /* invalidate existing TLB entry for flash + promjet */
78 disable_tlb(flash_esel);
79 }
Chunhe Lan57072332013-06-14 16:21:48 +080080
81 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
82 MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
83 0, flash_esel, BOOKE_PAGESZ_256M, 1);
84
Ahmed Mansour44262322017-12-15 16:01:00 -050085 setup_qbman_portals();
Chunhe Lan57072332013-06-14 16:21:48 +080086
87 return 0;
88}
89
90unsigned long get_board_sys_clk(ulong dummy)
91{
92 return gd->bus_clk;
93}
94
95unsigned long get_board_ddr_clk(ulong dummy)
96{
97 return gd->mem_clk;
98}
99
100int board_eth_init(bd_t *bis)
101{
102 ccsr_gur_t *gur = (ccsr_gur_t *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
103 struct fsl_pq_mdio_info dtsec_mdio_info;
104
105 /*
106 * Need to set dTSEC 1 pin multiplexing to TSEC. The default setting
107 * is not correct.
108 */
109 setbits_be32(&gur->pmuxcr, MPC85xx_PMUXCR_TSEC1_1);
110
111 dtsec_mdio_info.regs =
112 (struct tsec_mii_mng *)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR;
113 dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
114
115 /* Register the 1G MDIO bus */
116 fsl_pq_mdio_init(bis, &dtsec_mdio_info);
117
118 fm_info_set_phy_address(FM1_DTSEC1, CONFIG_SYS_FM1_DTSEC1_PHY_ADDR);
119 fm_info_set_phy_address(FM1_DTSEC2, CONFIG_SYS_FM1_DTSEC2_PHY_ADDR);
120
121 fm_info_set_mdio(FM1_DTSEC1,
122 miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
123 fm_info_set_mdio(FM1_DTSEC2,
124 miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
125
126#ifdef CONFIG_FMAN_ENET
127 cpu_eth_init(bis);
128#endif
129
130 return pci_eth_init(bis);
131}
132
133#if defined(CONFIG_OF_BOARD_SETUP)
Simon Glasse895a4b2014-10-23 18:58:47 -0600134int ft_board_setup(void *blob, bd_t *bd)
Chunhe Lan57072332013-06-14 16:21:48 +0800135{
136 phys_addr_t base;
137 phys_size_t size;
138
139 ft_cpu_setup(blob, bd);
140
Simon Glass723806c2017-08-03 12:22:15 -0600141 base = env_get_bootm_low();
142 size = env_get_bootm_size();
Chunhe Lan57072332013-06-14 16:21:48 +0800143
144 fdt_fixup_memory(blob, (u64)base, (u64)size);
145
146#ifdef CONFIG_HAS_FSL_DR_USB
Sriram Dasha5c289b2016-09-16 17:12:15 +0530147 fsl_fdt_fixup_dr_usb(blob, bd);
Chunhe Lan57072332013-06-14 16:21:48 +0800148#endif
149
150 fdt_fixup_fman_ethernet(blob);
Simon Glasse895a4b2014-10-23 18:58:47 -0600151
152 return 0;
Chunhe Lan57072332013-06-14 16:21:48 +0800153}
154#endif