blob: 7dacd0c5f1f829995ba31dd9b08d90669a1197c1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Priyanka Jain8b1a60e2013-10-18 17:19:06 +05302/*
3 * Copyright 2013 Freescale Semiconductor, Inc.
Priyanka Jain8b1a60e2013-10-18 17:19:06 +05304 */
5
6#include <common.h>
7#include <command.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -06008#include <env.h>
Zhao Qiang81136a12015-08-28 10:31:50 +08009#include <hwconfig.h>
Simon Glassa7b51302019-11-14 12:57:46 -070010#include <init.h>
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053011#include <netdev.h>
12#include <linux/compiler.h>
13#include <asm/mmu.h>
14#include <asm/processor.h>
15#include <asm/cache.h>
16#include <asm/immap_85xx.h>
Zhao Qiang81136a12015-08-28 10:31:50 +080017#include <asm/fsl_fdt.h>
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053018#include <asm/fsl_law.h>
19#include <asm/fsl_serdes.h>
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053020#include <asm/fsl_liodn.h>
21#include <fm_eth.h>
Tang Yuantian760eafc2014-11-21 11:17:16 +080022#include "../common/sleep.h"
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053023#include "t104xrdb.h"
Prabhakar Kushwahae5e66332014-04-03 16:50:05 +053024#include "cpld.h"
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053025
26DECLARE_GLOBAL_DATA_PTR;
27
28int checkboard(void)
29{
30 struct cpu_type *cpu = gd->arch.cpu;
Prabhakar Kushwahae5e66332014-04-03 16:50:05 +053031 u8 sw;
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053032
York Sun097aa602016-11-21 11:25:26 -080033#if defined(CONFIG_TARGET_T1040D4RDB) || defined(CONFIG_TARGET_T1042D4RDB)
Priyanka Jaine7597fe2015-06-05 15:29:02 +053034 printf("Board: %sD4RDB\n", cpu->name);
35#else
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053036 printf("Board: %sRDB\n", cpu->name);
Priyanka Jaine7597fe2015-06-05 15:29:02 +053037#endif
Prabhakar Kushwahae5e66332014-04-03 16:50:05 +053038 printf("Board rev: 0x%02x CPLD ver: 0x%02x, ",
39 CPLD_READ(hw_ver), CPLD_READ(sw_ver));
40
41 sw = CPLD_READ(flash_ctl_status);
42 sw = ((sw & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT);
43
Priyanka Jain86c6bfe2015-07-30 10:20:18 +053044 printf("vBank: %d\n", sw);
Prabhakar Kushwahae5e66332014-04-03 16:50:05 +053045
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053046 return 0;
47}
48
Tang Yuantian760eafc2014-11-21 11:17:16 +080049int board_early_init_f(void)
50{
51#if defined(CONFIG_DEEP_SLEEP)
52 if (is_warm_boot())
53 fsl_dp_disable_console();
54#endif
55
56 return 0;
57}
58
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053059int board_early_init_r(void)
60{
61#ifdef CONFIG_SYS_FLASH_BASE
62 const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
York Sun220c3462014-06-24 21:16:20 -070063 int flash_esel = find_tlb_idx((void *)flashbase, 1);
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053064
65 /*
66 * Remap Boot flash region to caching-inhibited
67 * so that flash can be erased properly.
68 */
69
70 /* Flush d-cache and invalidate i-cache of any FLASH data */
71 flush_dcache();
72 invalidate_icache();
73
York Sun220c3462014-06-24 21:16:20 -070074 if (flash_esel == -1) {
75 /* very unlikely unless something is messed up */
76 puts("Error: Could not find TLB for FLASH BASE\n");
77 flash_esel = 2; /* give our best effort to continue */
78 } else {
79 /* invalidate existing TLB entry for flash */
80 disable_tlb(flash_esel);
81 }
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053082
83 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
84 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
85 0, flash_esel, BOOKE_PAGESZ_256M, 1);
86#endif
Priyanka Jain8b1a60e2013-10-18 17:19:06 +053087 return 0;
88}
89
90int misc_init_r(void)
91{
Priyanka Jaine7597fe2015-06-05 15:29:02 +053092 ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
93 u32 srds_s1;
94
95 srds_s1 = in_be32(&gur->rcwsr[4]) >> 24;
96
97 printf("SERDES Reference : 0x%X\n", srds_s1);
98
99 /* select SGMII*/
100 if (srds_s1 == 0x86)
101 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
102 MISC_CTL_SG_SEL);
103
104 /* select SGMII and Aurora*/
105 if (srds_s1 == 0x8E)
106 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
107 MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL);
108
York Sun2c156012016-11-21 10:46:53 -0800109#if defined(CONFIG_TARGET_T1040D4RDB)
Zhao Qiang81136a12015-08-28 10:31:50 +0800110 if (hwconfig("qe-tdm")) {
111 CPLD_WRITE(sfp_ctl_status, CPLD_READ(sfp_ctl_status) |
112 MISC_MUX_QE_TDM);
113 printf("QECSR : 0x%02x, mux to qe-tdm\n",
114 CPLD_READ(sfp_ctl_status));
115 }
Priyanka Jaine7597fe2015-06-05 15:29:02 +0530116 /* Mask all CPLD interrupt sources, except QSGMII interrupts */
117 if (CPLD_READ(sw_ver) < 0x03) {
118 debug("CPLD SW version 0x%02x doesn't support int_mask\n",
119 CPLD_READ(sw_ver));
120 } else {
121 CPLD_WRITE(int_mask, CPLD_INT_MASK_ALL &
122 ~(CPLD_INT_MASK_QSGMII1 | CPLD_INT_MASK_QSGMII2));
123 }
124#endif
125
Priyanka Jain8b1a60e2013-10-18 17:19:06 +0530126 return 0;
127}
128
Simon Glass2aec3cc2014-10-23 18:58:47 -0600129int ft_board_setup(void *blob, bd_t *bd)
Priyanka Jain8b1a60e2013-10-18 17:19:06 +0530130{
131 phys_addr_t base;
132 phys_size_t size;
133
134 ft_cpu_setup(blob, bd);
135
Simon Glassda1a1342017-08-03 12:22:15 -0600136 base = env_get_bootm_low();
137 size = env_get_bootm_size();
Priyanka Jain8b1a60e2013-10-18 17:19:06 +0530138
139 fdt_fixup_memory(blob, (u64)base, (u64)size);
140
141#ifdef CONFIG_PCI
142 pci_of_setup(blob, bd);
143#endif
144
145 fdt_fixup_liodn(blob);
146
147#ifdef CONFIG_HAS_FSL_DR_USB
Sriram Dash9fd465c2016-09-16 17:12:15 +0530148 fsl_fdt_fixup_dr_usb(blob, bd);
Priyanka Jain8b1a60e2013-10-18 17:19:06 +0530149#endif
150
151#ifdef CONFIG_SYS_DPAA_FMAN
152 fdt_fixup_fman_ethernet(blob);
153#endif
Simon Glass2aec3cc2014-10-23 18:58:47 -0600154
Zhao Qiang81136a12015-08-28 10:31:50 +0800155 if (hwconfig("qe-tdm"))
156 fdt_del_diu(blob);
Simon Glass2aec3cc2014-10-23 18:58:47 -0600157 return 0;
Priyanka Jain8b1a60e2013-10-18 17:19:06 +0530158}