blob: 315da8b866d3703025108d58a1a36793344634b3 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +05302/*
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +05303 * Copyright 2017-2018 NXP
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +05304 */
5
6#include <common.h>
7#include <i2c.h>
8#include <asm/io.h>
9#include <asm/arch/clock.h>
10#include <asm/arch/fsl_serdes.h>
Prabhakar Kushwaha74d129b2017-01-30 17:05:35 +053011#ifdef CONFIG_FSL_LS_PPA
12#include <asm/arch/ppa.h>
13#endif
York Sun729f2d12017-03-06 09:02:34 -080014#include <asm/arch/mmu.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053015#include <asm/arch/soc.h>
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053016#include <fsl_esdhc.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053017#include <hwconfig.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053018#include <environment.h>
19#include <fsl_mmdc.h>
20#include <netdev.h>
Vinitha V Pillaiad698c32018-05-23 11:03:31 +053021#include <fsl_sec.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053022
23DECLARE_GLOBAL_DATA_PTR;
24
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053025static inline int get_board_version(void)
26{
27 struct ccsr_gpio *pgpio = (void *)(GPIO1_BASE_ADDR);
28 int val;
29
30 val = in_be32(&pgpio->gpdat);
31
32 return val;
33}
34
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053035int checkboard(void)
36{
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053037#ifdef CONFIG_TARGET_LS1012AFRDM
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053038 puts("Board: LS1012AFRDM ");
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053039#else
40 int rev;
41
42 rev = get_board_version();
43
44 puts("Board: FRWY-LS1012A ");
45
46 puts("Version");
47
48 switch (rev) {
49 case BOARD_REV_A:
50 puts(": RevA ");
51 break;
52 case BOARD_REV_B:
53 puts(": RevB ");
54 break;
55 default:
56 puts(": unknown");
57 break;
58 }
59#endif
60
61 return 0;
62}
63
64#ifdef CONFIG_TARGET_LS1012AFRWY
65int esdhc_status_fixup(void *blob, const char *compat)
66{
67 char esdhc0_path[] = "/soc/esdhc@1560000";
68 char esdhc1_path[] = "/soc/esdhc@1580000";
69
70 do_fixup_by_path(blob, esdhc0_path, "status", "okay",
71 sizeof("okay"), 1);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053072
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053073 do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
74 sizeof("disabled"), 1);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053075 return 0;
76}
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053077#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053078
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053079int dram_init(void)
80{
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053081#ifdef CONFIG_TARGET_LS1012AFRWY
82 int board_rev;
83#endif
84 struct fsl_mmdc_info mparam = {
York Sunc1e979b2016-09-26 08:09:25 -070085 0x04180000, /* mdctl */
86 0x00030035, /* mdpdc */
87 0x12554000, /* mdotc */
88 0xbabf7954, /* mdcfg0 */
89 0xdb328f64, /* mdcfg1 */
90 0x01ff00db, /* mdcfg2 */
91 0x00001680, /* mdmisc */
92 0x0f3c8000, /* mdref */
93 0x00002000, /* mdrwd */
94 0x00bf1023, /* mdor */
95 0x0000003f, /* mdasp */
96 0x0000022a, /* mpodtctrl */
97 0xa1390003, /* mpzqhwctrl */
98 };
99
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530100#ifdef CONFIG_TARGET_LS1012AFRWY
101 board_rev = get_board_version();
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530102
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530103 if (board_rev & BOARD_REV_B) {
104 mparam.mdctl = 0x05180000;
105 gd->ram_size = SYS_SDRAM_SIZE_1024;
106 } else {
107 gd->ram_size = SYS_SDRAM_SIZE_512;
108 }
109#else
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530110 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530111#endif
112 mmdc_init(&mparam);
113
York Sun729f2d12017-03-06 09:02:34 -0800114#if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
115 /* This will break-before-make MMU for DDR */
116 update_early_mmu_table();
117#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530118
119 return 0;
120}
121
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530122int board_early_init_f(void)
123{
124 fsl_lsch2_early_init_f();
125
126 return 0;
127}
128
129int board_init(void)
130{
Ashish Kumar11234062017-08-11 11:09:14 +0530131 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
132 CONFIG_SYS_CCI400_OFFSET);
133
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530134 /*
135 * Set CCI-400 control override register to enable barrier
136 * transaction
137 */
138 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
139
140#ifdef CONFIG_ENV_IS_NOWHERE
141 gd->env_addr = (ulong)&default_environment[0];
142#endif
143
Vinitha V Pillaiad698c32018-05-23 11:03:31 +0530144#ifdef CONFIG_FSL_CAAM
145 sec_init();
146#endif
147
Prabhakar Kushwaha74d129b2017-01-30 17:05:35 +0530148#ifdef CONFIG_FSL_LS_PPA
149 ppa_init();
150#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530151 return 0;
152}
153
154int ft_board_setup(void *blob, bd_t *bd)
155{
156 arch_fixup_fdt(blob);
157
158 ft_cpu_setup(blob, bd);
159
160 return 0;
161}