blob: dc3b59d26f9d10b967dacb92968153d5d8db5818 [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 Glass52559322019-11-14 12:57:46 -070011#include <init.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +053012#include <netdev.h>
13#include <linux/compiler.h>
14#include <asm/mmu.h>
15#include <asm/processor.h>
16#include <asm/cache.h>
17#include <asm/immap_85xx.h>
Zhao Qiangd4683772015-08-28 10:31:50 +080018#include <asm/fsl_fdt.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +053019#include <asm/fsl_law.h>
20#include <asm/fsl_serdes.h>
Priyanka Jain062ef1a2013-10-18 17:19:06 +053021#include <asm/fsl_liodn.h>
22#include <fm_eth.h>
Tang Yuantian00233522014-11-21 11:17:16 +080023#include "../common/sleep.h"
Priyanka Jain062ef1a2013-10-18 17:19:06 +053024#include "t104xrdb.h"
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053025#include "cpld.h"
Priyanka Jain062ef1a2013-10-18 17:19:06 +053026
27DECLARE_GLOBAL_DATA_PTR;
28
29int checkboard(void)
30{
31 struct cpu_type *cpu = gd->arch.cpu;
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053032 u8 sw;
Priyanka Jain062ef1a2013-10-18 17:19:06 +053033
York Sun78e56992016-11-21 11:25:26 -080034#if defined(CONFIG_TARGET_T1040D4RDB) || defined(CONFIG_TARGET_T1042D4RDB)
Priyanka Jain4b6067a2015-06-05 15:29:02 +053035 printf("Board: %sD4RDB\n", cpu->name);
36#else
Priyanka Jain062ef1a2013-10-18 17:19:06 +053037 printf("Board: %sRDB\n", cpu->name);
Priyanka Jain4b6067a2015-06-05 15:29:02 +053038#endif
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053039 printf("Board rev: 0x%02x CPLD ver: 0x%02x, ",
40 CPLD_READ(hw_ver), CPLD_READ(sw_ver));
41
42 sw = CPLD_READ(flash_ctl_status);
43 sw = ((sw & CPLD_LBMAP_MASK) >> CPLD_LBMAP_SHIFT);
44
Priyanka Jainf2af1c32015-07-30 10:20:18 +053045 printf("vBank: %d\n", sw);
Prabhakar Kushwaha55153d62014-04-03 16:50:05 +053046
Priyanka Jain062ef1a2013-10-18 17:19:06 +053047 return 0;
48}
49
Tang Yuantian00233522014-11-21 11:17:16 +080050int board_early_init_f(void)
51{
52#if defined(CONFIG_DEEP_SLEEP)
53 if (is_warm_boot())
54 fsl_dp_disable_console();
55#endif
56
57 return 0;
58}
59
Priyanka Jain062ef1a2013-10-18 17:19:06 +053060int board_early_init_r(void)
61{
62#ifdef CONFIG_SYS_FLASH_BASE
63 const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
York Sun9d045682014-06-24 21:16:20 -070064 int flash_esel = find_tlb_idx((void *)flashbase, 1);
Priyanka Jain062ef1a2013-10-18 17:19:06 +053065
66 /*
67 * Remap Boot flash region to caching-inhibited
68 * so that flash can be erased properly.
69 */
70
71 /* Flush d-cache and invalidate i-cache of any FLASH data */
72 flush_dcache();
73 invalidate_icache();
74
York Sun9d045682014-06-24 21:16:20 -070075 if (flash_esel == -1) {
76 /* very unlikely unless something is messed up */
77 puts("Error: Could not find TLB for FLASH BASE\n");
78 flash_esel = 2; /* give our best effort to continue */
79 } else {
80 /* invalidate existing TLB entry for flash */
81 disable_tlb(flash_esel);
82 }
Priyanka Jain062ef1a2013-10-18 17:19:06 +053083
84 set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
85 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
86 0, flash_esel, BOOKE_PAGESZ_256M, 1);
87#endif
Priyanka Jain062ef1a2013-10-18 17:19:06 +053088 return 0;
89}
90
91int misc_init_r(void)
92{
Priyanka Jain4b6067a2015-06-05 15:29:02 +053093 ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
94 u32 srds_s1;
95
96 srds_s1 = in_be32(&gur->rcwsr[4]) >> 24;
97
98 printf("SERDES Reference : 0x%X\n", srds_s1);
99
100 /* select SGMII*/
101 if (srds_s1 == 0x86)
102 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
103 MISC_CTL_SG_SEL);
104
105 /* select SGMII and Aurora*/
106 if (srds_s1 == 0x8E)
107 CPLD_WRITE(misc_ctl_status, CPLD_READ(misc_ctl_status) |
108 MISC_CTL_SG_SEL | MISC_CTL_AURORA_SEL);
109
York Suna0167352016-11-21 10:46:53 -0800110#if defined(CONFIG_TARGET_T1040D4RDB)
Zhao Qiangd4683772015-08-28 10:31:50 +0800111 if (hwconfig("qe-tdm")) {
112 CPLD_WRITE(sfp_ctl_status, CPLD_READ(sfp_ctl_status) |
113 MISC_MUX_QE_TDM);
114 printf("QECSR : 0x%02x, mux to qe-tdm\n",
115 CPLD_READ(sfp_ctl_status));
116 }
Priyanka Jain4b6067a2015-06-05 15:29:02 +0530117 /* Mask all CPLD interrupt sources, except QSGMII interrupts */
118 if (CPLD_READ(sw_ver) < 0x03) {
119 debug("CPLD SW version 0x%02x doesn't support int_mask\n",
120 CPLD_READ(sw_ver));
121 } else {
122 CPLD_WRITE(int_mask, CPLD_INT_MASK_ALL &
123 ~(CPLD_INT_MASK_QSGMII1 | CPLD_INT_MASK_QSGMII2));
124 }
125#endif
126
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530127 return 0;
128}
129
Simon Glasse895a4b2014-10-23 18:58:47 -0600130int ft_board_setup(void *blob, bd_t *bd)
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530131{
132 phys_addr_t base;
133 phys_size_t size;
134
135 ft_cpu_setup(blob, bd);
136
Simon Glass723806c2017-08-03 12:22:15 -0600137 base = env_get_bootm_low();
138 size = env_get_bootm_size();
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530139
140 fdt_fixup_memory(blob, (u64)base, (u64)size);
141
142#ifdef CONFIG_PCI
143 pci_of_setup(blob, bd);
144#endif
145
146 fdt_fixup_liodn(blob);
147
148#ifdef CONFIG_HAS_FSL_DR_USB
Sriram Dasha5c289b2016-09-16 17:12:15 +0530149 fsl_fdt_fixup_dr_usb(blob, bd);
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530150#endif
151
152#ifdef CONFIG_SYS_DPAA_FMAN
153 fdt_fixup_fman_ethernet(blob);
154#endif
Simon Glasse895a4b2014-10-23 18:58:47 -0600155
Zhao Qiangd4683772015-08-28 10:31:50 +0800156 if (hwconfig("qe-tdm"))
157 fdt_del_diu(blob);
Simon Glasse895a4b2014-10-23 18:58:47 -0600158 return 0;
Priyanka Jain062ef1a2013-10-18 17:19:06 +0530159}