blob: c9557b465f24525d05673c0188c469519c9373b2 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Priyanka Jain062ef1a2013-10-18 17:19:06 +05302/*
3 * Copyright 2013 Freescale Semiconductor, Inc.
Priyanka Jain062ef1a2013-10-18 17:19:06 +05304 */
5
6#include <common.h>
7#include <command.h>
Zhao Qiangd4683772015-08-28 10:31:50 +08008#include <hwconfig.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +05309#include <netdev.h>
10#include <linux/compiler.h>
11#include <asm/mmu.h>
12#include <asm/processor.h>
13#include <asm/cache.h>
14#include <asm/immap_85xx.h>
Zhao Qiangd4683772015-08-28 10:31:50 +080015#include <asm/fsl_fdt.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +053016#include <asm/fsl_law.h>
17#include <asm/fsl_serdes.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +053018#include <asm/fsl_liodn.h>
19#include <fm_eth.h>
Tang Yuantian00233522014-11-21 11:17:16 +080020#include "../common/sleep.h"
Priyanka Jain062ef1a2013-10-18 17:19:06 +053021#include "t104xrdb.h"
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053022#include "cpld.h"
Priyanka Jain062ef1a2013-10-18 17:19:06 +053023
24DECLARE_GLOBAL_DATA_PTR;
25
26int checkboard(void)
27{
28 struct cpu_type *cpu = gd->arch.cpu;
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053029 u8 sw;
Priyanka Jain062ef1a2013-10-18 17:19:06 +053030
York Sun78e56992016-11-21 11:25:26 -080031#if defined(CONFIG_TARGET_T1040D4RDB) || defined(CONFIG_TARGET_T1042D4RDB)
Priyanka Jain4b6067a2015-06-05 15:29:02 +053032 printf("Board: %sD4RDB\n", cpu->name);
33#else
Priyanka Jain062ef1a2013-10-18 17:19:06 +053034 printf("Board: %sRDB\n", cpu->name);
Priyanka Jain4b6067a2015-06-05 15:29:02 +053035#endif
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053036 printf("Board rev: 0x%02x CPLD ver: 0x%02x, ",
37 CPLD_READ(hw_ver), CPLD_READ(sw_ver));
38
39 sw = CPLD_READ(flash_ctl_status);
40 sw = ((sw & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT);
41
Priyanka Jainf2af1c32015-07-30 10:20:18 +053042 printf("vBank: %d\n", sw);
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053043
Priyanka Jain062ef1a2013-10-18 17:19:06 +053044 return 0;
45}
46
Tang Yuantian00233522014-11-21 11:17:16 +080047int board_early_init_f(void)
48{
49#if defined(CONFIG_DEEP_SLEEP)
50 if (is_warm_boot())
51 fsl_dp_disable_console();
52#endif
53
54 return 0;
55}
56
Priyanka Jain062ef1a2013-10-18 17:19:06 +053057int board_early_init_r(void)
58{
59#ifdef CONFIG_SYS_FLASH_BASE
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);
Priyanka Jain062ef1a2013-10-18 17:19:06 +053062
63 /*
64 * Remap Boot flash 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 */
78 disable_tlb(flash_esel);
79 }
Priyanka Jain062ef1a2013-10-18 17:19:06 +053080
81 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
82 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
83 0, flash_esel, BOOKE_PAGESZ_256M, 1);
84#endif
Priyanka Jain062ef1a2013-10-18 17:19:06 +053085 return 0;
86}
87
88int misc_init_r(void)
89{
Priyanka Jain4b6067a2015-06-05 15:29:02 +053090 ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
91 u32 srds_s1;
92
93 srds_s1 = in_be32(&gur->rcwsr[4]) >> 24;
94
95 printf("SERDES Reference : 0x%X\n", srds_s1);
96
97 /* select SGMII*/
98 if (srds_s1 == 0x86)
99 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
100 MISC_CTL_SG_SEL);
101
102 /* select SGMII and Aurora*/
103 if (srds_s1 == 0x8E)
104 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
105 MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL);
106
York Suna0167352016-11-21 10:46:53 -0800107#if defined(CONFIG_TARGET_T1040D4RDB)
Zhao Qiangd4683772015-08-28 10:31:50 +0800108 if (hwconfig("qe-tdm")) {
109 CPLD_WRITE(sfp_ctl_status, CPLD_READ(sfp_ctl_status) |
110 MISC_MUX_QE_TDM);
111 printf("QECSR : 0x%02x, mux to qe-tdm\n",
112 CPLD_READ(sfp_ctl_status));
113 }
Priyanka Jain4b6067a2015-06-05 15:29:02 +0530114 /* Mask all CPLD interrupt sources, except QSGMII interrupts */
115 if (CPLD_READ(sw_ver) < 0x03) {
116 debug("CPLD SW version 0x%02x doesn't support int_mask\n",
117 CPLD_READ(sw_ver));
118 } else {
119 CPLD_WRITE(int_mask, CPLD_INT_MASK_ALL &
120 ~(CPLD_INT_MASK_QSGMII1 | CPLD_INT_MASK_QSGMII2));
121 }
122#endif
123
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530124 return 0;
125}
126
Simon Glasse895a4b2014-10-23 18:58:47 -0600127int ft_board_setup(void *blob, bd_t *bd)
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530128{
129 phys_addr_t base;
130 phys_size_t size;
131
132 ft_cpu_setup(blob, bd);
133
Simon Glass723806c2017-08-03 12:22:15 -0600134 base = env_get_bootm_low();
135 size = env_get_bootm_size();
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530136
137 fdt_fixup_memory(blob, (u64)base, (u64)size);
138
139#ifdef CONFIG_PCI
140 pci_of_setup(blob, bd);
141#endif
142
143 fdt_fixup_liodn(blob);
144
145#ifdef CONFIG_HAS_FSL_DR_USB
Sriram Dasha5c289b2016-09-16 17:12:15 +0530146 fsl_fdt_fixup_dr_usb(blob, bd);
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530147#endif
148
149#ifdef CONFIG_SYS_DPAA_FMAN
150 fdt_fixup_fman_ethernet(blob);
151#endif
Simon Glasse895a4b2014-10-23 18:58:47 -0600152
Zhao Qiangd4683772015-08-28 10:31:50 +0800153 if (hwconfig("qe-tdm"))
154 fdt_del_diu(blob);
Simon Glasse895a4b2014-10-23 18:58:47 -0600155 return 0;
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530156}