blob: 562360de5291c41d9e6cbd423cbffe11cbc3ad08 [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>
Simon Glass7b51b572019-08-01 09:46:52 -06008#include <env.h>
Simon Glass807765b2019-12-28 10:44:54 -07009#include <fdt_support.h>
Zhao Qiangd4683772015-08-28 10:31:50 +080010#include <hwconfig.h>
Simon Glass4d72caa2020-05-10 11:40:01 -060011#include <image.h>
Simon Glass52559322019-11-14 12:57:46 -070012#include <init.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -060013#include <log.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +053014#include <netdev.h>
Simon Glass401d1c42020-10-30 21:38:53 -060015#include <asm/global_data.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +053016#include <linux/compiler.h>
17#include <asm/mmu.h>
18#include <asm/processor.h>
19#include <asm/cache.h>
20#include <asm/immap_85xx.h>
Zhao Qiangd4683772015-08-28 10:31:50 +080021#include <asm/fsl_fdt.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +053022#include <asm/fsl_law.h>
23#include <asm/fsl_serdes.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +053024#include <asm/fsl_liodn.h>
25#include <fm_eth.h>
Tang Yuantian00233522014-11-21 11:17:16 +080026#include "../common/sleep.h"
Priyanka Jain062ef1a2013-10-18 17:19:06 +053027#include "t104xrdb.h"
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053028#include "cpld.h"
Priyanka Jain062ef1a2013-10-18 17:19:06 +053029
30DECLARE_GLOBAL_DATA_PTR;
31
32int checkboard(void)
33{
34 struct cpu_type *cpu = gd->arch.cpu;
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053035 u8 sw;
Priyanka Jain062ef1a2013-10-18 17:19:06 +053036
Tom Rini8214b772022-12-02 16:42:51 -050037#if defined(CONFIG_TARGET_T1042D4RDB)
Priyanka Jain4b6067a2015-06-05 15:29:02 +053038 printf("Board: %sD4RDB\n", cpu->name);
39#else
Priyanka Jain062ef1a2013-10-18 17:19:06 +053040 printf("Board: %sRDB\n", cpu->name);
Priyanka Jain4b6067a2015-06-05 15:29:02 +053041#endif
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053042 printf("Board rev: 0x%02x CPLD ver: 0x%02x, ",
43 CPLD_READ(hw_ver), CPLD_READ(sw_ver));
44
45 sw = CPLD_READ(flash_ctl_status);
46 sw = ((sw & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT);
47
Priyanka Jainf2af1c32015-07-30 10:20:18 +053048 printf("vBank: %d\n", sw);
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053049
Priyanka Jain062ef1a2013-10-18 17:19:06 +053050 return 0;
51}
52
Tang Yuantian00233522014-11-21 11:17:16 +080053int board_early_init_f(void)
54{
55#if defined(CONFIG_DEEP_SLEEP)
56 if (is_warm_boot())
57 fsl_dp_disable_console();
58#endif
59
60 return 0;
61}
62
Priyanka Jain062ef1a2013-10-18 17:19:06 +053063int board_early_init_r(void)
64{
Tom Rini65cc0e22022-11-16 13:10:41 -050065#ifdef CFG_SYS_FLASH_BASE
66 const unsigned int flashbase = CFG_SYS_FLASH_BASE;
York Sun9d045682014-06-24 21:16:20 -070067 int flash_esel = find_tlb_idx((void *)flashbase, 1);
Priyanka Jain062ef1a2013-10-18 17:19:06 +053068
69 /*
70 * Remap Boot flash region to caching-inhibited
71 * so that flash can be erased properly.
72 */
73
74 /* Flush d-cache and invalidate i-cache of any FLASH data */
75 flush_dcache();
76 invalidate_icache();
77
York Sun9d045682014-06-24 21:16:20 -070078 if (flash_esel == -1) {
79 /* very unlikely unless something is messed up */
80 puts("Error: Could not find TLB for FLASH BASE\n");
81 flash_esel = 2; /* give our best effort to continue */
82 } else {
83 /* invalidate existing TLB entry for flash */
84 disable_tlb(flash_esel);
85 }
Priyanka Jain062ef1a2013-10-18 17:19:06 +053086
Tom Rini65cc0e22022-11-16 13:10:41 -050087 set_tlb(1, flashbase, CFG_SYS_FLASH_BASE_PHYS,
Priyanka Jain062ef1a2013-10-18 17:19:06 +053088 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
89 0, flash_esel, BOOKE_PAGESZ_256M, 1);
90#endif
Camelia Groza4e69a442023-07-11 15:49:24 +030091
92 pci_init();
93
Priyanka Jain062ef1a2013-10-18 17:19:06 +053094 return 0;
95}
96
97int misc_init_r(void)
98{
Tom Rini51552072022-10-28 20:27:12 -040099 ccsr_gur_t __iomem *gur = (void *)(CFG_SYS_MPC85xx_GUTS_ADDR);
Priyanka Jain4b6067a2015-06-05 15:29:02 +0530100 u32 srds_s1;
101
102 srds_s1 = in_be32(&gur->rcwsr[4]) >> 24;
103
104 printf("SERDES Reference : 0x%X\n", srds_s1);
105
106 /* select SGMII*/
107 if (srds_s1 == 0x86)
108 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
109 MISC_CTL_SG_SEL);
110
111 /* select SGMII and Aurora*/
112 if (srds_s1 == 0x8E)
113 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
114 MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL);
115
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530116 return 0;
117}
118
Masahiro Yamadab75d8dc2020-06-26 15:13:33 +0900119int ft_board_setup(void *blob, struct bd_info *bd)
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530120{
121 phys_addr_t base;
122 phys_size_t size;
123
124 ft_cpu_setup(blob, bd);
125
Simon Glass723806c2017-08-03 12:22:15 -0600126 base = env_get_bootm_low();
127 size = env_get_bootm_size();
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530128
129 fdt_fixup_memory(blob, (u64)base, (u64)size);
130
131#ifdef CONFIG_PCI
132 pci_of_setup(blob, bd);
133#endif
134
135 fdt_fixup_liodn(blob);
136
137#ifdef CONFIG_HAS_FSL_DR_USB
Sriram Dasha5c289b2016-09-16 17:12:15 +0530138 fsl_fdt_fixup_dr_usb(blob, bd);
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530139#endif
140
141#ifdef CONFIG_SYS_DPAA_FMAN
Madalin Bucur564637a2020-04-30 15:59:58 +0300142#ifndef CONFIG_DM_ETH
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530143 fdt_fixup_fman_ethernet(blob);
144#endif
Madalin Bucur564637a2020-04-30 15:59:58 +0300145#endif
Simon Glasse895a4b2014-10-23 18:58:47 -0600146
Zhao Qiangd4683772015-08-28 10:31:50 +0800147 if (hwconfig("qe-tdm"))
148 fdt_del_diu(blob);
Simon Glasse895a4b2014-10-23 18:58:47 -0600149 return 0;
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530150}