]> Git Repo - u-boot.git/blame - board/freescale/t104xrdb/spl.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[u-boot.git] / board / freescale / t104xrdb / spl.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
18c01445 2/* Copyright 2013 Freescale Semiconductor, Inc.
18c01445
PK
3 */
4
d678a59d 5#include <common.h>
d96c2604 6#include <clock_legacy.h>
24b852a7 7#include <console.h>
f3998fdc 8#include <env_internal.h>
94133872 9#include <init.h>
18c01445
PK
10#include <malloc.h>
11#include <ns16550.h>
12#include <nand.h>
13#include <i2c.h>
14#include <mmc.h>
15#include <fsl_esdhc.h>
16#include <spi_flash.h>
401d1c4f 17#include <asm/global_data.h>
00233528 18#include "../common/sleep.h"
ea022a37 19#include "../common/spl.h"
18c01445
PK
20
21DECLARE_GLOBAL_DATA_PTR;
22
23phys_size_t get_effective_memsize(void)
24{
25 return CONFIG_SYS_L3_SIZE;
26}
27
18c01445
PK
28#define FSL_CORENET_CCSR_PORSR1_RCW_MASK 0xFF800000
29void board_init_f(ulong bootflag)
30{
31 u32 plat_ratio, sys_clk, uart_clk;
9f074e67 32#if defined(CONFIG_SPL_NAND_BOOT) && defined(CONFIG_A008044_WORKAROUND)
18c01445 33 u32 porsr1, pinctl;
31530e0b 34 u32 svr = get_svr();
18c01445 35#endif
5155207a 36 ccsr_gur_t *gur = (void *)CFG_SYS_MPC85xx_GUTS_ADDR;
18c01445 37
9f074e67 38#if defined(CONFIG_SPL_NAND_BOOT) && defined(CONFIG_A008044_WORKAROUND)
31530e0b
PK
39 if (IS_SVR_REV(svr, 1, 0)) {
40 /*
41 * There is T1040 SoC issue where NOR, FPGA are inaccessible
42 * during NAND boot because IFC signals > IFC_AD7 are not
43 * enabled. This workaround changes RCW source to make all
44 * signals enabled.
45 */
46 porsr1 = in_be32(&gur->porsr1);
47 pinctl = ((porsr1 & ~(FSL_CORENET_CCSR_PORSR1_RCW_MASK))
48 | 0x24800000);
65cc0e2a 49 out_be32((unsigned int *)(CFG_SYS_DCSRBAR + 0x20000),
31530e0b
PK
50 pinctl);
51 }
18c01445
PK
52#endif
53
54 /* Memcpy existing GD at CONFIG_SPL_GD_ADDR */
55 memcpy((void *)CONFIG_SPL_GD_ADDR, (void *)gd, sizeof(gd_t));
56
57 /* Update GD pointer */
58 gd = (gd_t *)(CONFIG_SPL_GD_ADDR);
59
ce249d95
TY
60#ifdef CONFIG_DEEP_SLEEP
61 /* disable the console if boot from deep sleep */
00233528
TY
62 if (is_warm_boot())
63 fsl_dp_disable_console();
ce249d95 64#endif
18c01445
PK
65 /* compiler optimization barrier needed for GCC >= 3.4 */
66 __asm__ __volatile__("" : : : "memory");
67
68 console_init_f();
69
70 /* initialize selected port with appropriate baud rate */
2f8a6db5 71 sys_clk = get_board_sys_clk();
18c01445
PK
72 plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
73 uart_clk = sys_clk * plat_ratio / 2;
74
91092132 75 ns16550_init((struct ns16550 *)CFG_SYS_NS16550_COM1,
18c01445
PK
76 uart_clk / 16 / CONFIG_BAUDRATE);
77
78 relocate_code(CONFIG_SPL_RELOC_STACK, (gd_t *)CONFIG_SPL_GD_ADDR, 0x0);
79}
80
81void board_init_r(gd_t *gd, ulong dest_addr)
82{
b75d8dc5 83 struct bd_info *bd;
18c01445 84
b75d8dc5
MY
85 bd = (struct bd_info *)(gd + sizeof(gd_t));
86 memset(bd, 0, sizeof(struct bd_info));
18c01445 87 gd->bd = bd;
18c01445 88
cbcbf71b 89 arch_cpu_init();
18c01445
PK
90 get_clocks();
91 mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
92 CONFIG_SPL_RELOC_MALLOC_SIZE);
ed4708aa 93 gd->flags |= GD_FLG_FULL_MALLOC_INIT;
18c01445
PK
94
95#ifdef CONFIG_SPL_MMC_BOOT
96 mmc_initialize(bd);
97#endif
98
99 /* relocate environment function pointers etc. */
8160c38c
TR
100#if defined(CONFIG_ENV_IS_IN_NAND) || defined(CONFIG_ENV_IS_IN_MMC) || \
101 defined(CONFIG_ENV_IS_IN_SPI_FLASH)
18c01445
PK
102#ifdef CONFIG_SPL_NAND_BOOT
103 nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
a09fea1d 104 (uchar *)SPL_ENV_ADDR);
18c01445
PK
105#endif
106#ifdef CONFIG_SPL_MMC_BOOT
107 mmc_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
a09fea1d 108 (uchar *)SPL_ENV_ADDR);
18c01445
PK
109#endif
110#ifdef CONFIG_SPL_SPI_BOOT
ea022a37 111 fsl_spi_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
a09fea1d 112 (uchar *)SPL_ENV_ADDR);
18c01445 113#endif
a09fea1d 114 gd->env_addr = (ulong)(SPL_ENV_ADDR);
203e94f6 115 gd->env_valid = ENV_VALID;
8160c38c 116#endif
18c01445
PK
117
118 i2c_init_all();
119
120 puts("\n\n");
121
f1683aa7 122 dram_init();
18c01445
PK
123
124#ifdef CONFIG_SPL_MMC_BOOT
125 mmc_boot();
126#elif defined(CONFIG_SPL_SPI_BOOT)
ea022a37 127 fsl_spi_boot();
18c01445
PK
128#elif defined(CONFIG_SPL_NAND_BOOT)
129 nand_boot();
130#endif
131}
This page took 0.308277 seconds and 4 git commands to generate.