blob: 8260e7f7974457e315c4f49a736429561a03f221 [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>
Simon Glass3bbe70c2019-12-28 10:44:54 -07007#include <fdt_support.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +05308#include <i2c.h>
Simon Glass274e0b02020-05-10 11:39:56 -06009#include <asm/cache.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053010#include <asm/io.h>
11#include <asm/arch/clock.h>
12#include <asm/arch/fsl_serdes.h>
Prabhakar Kushwaha74d129b2017-01-30 17:05:35 +053013#ifdef CONFIG_FSL_LS_PPA
14#include <asm/arch/ppa.h>
15#endif
York Sun729f2d12017-03-06 09:02:34 -080016#include <asm/arch/mmu.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053017#include <asm/arch/soc.h>
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053018#include <fsl_esdhc.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053019#include <hwconfig.h>
Simon Glass9d1f6192019-08-02 09:44:25 -060020#include <env_internal.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053021#include <fsl_mmdc.h>
22#include <netdev.h>
Vinitha V Pillaiad698c32018-05-23 11:03:31 +053023#include <fsl_sec.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053024
25DECLARE_GLOBAL_DATA_PTR;
26
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053027static inline int get_board_version(void)
28{
Pramod Kumar46d752a2018-08-14 09:49:55 +053029 uint32_t val;
30#ifdef CONFIG_TARGET_LS1012AFRDM
31 val = 0;
32#else
33 struct ccsr_gpio *pgpio = (void *)(GPIO2_BASE_ADDR);
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053034
Pramod Kumar46d752a2018-08-14 09:49:55 +053035 val = in_be32(&pgpio->gpdat) & BOARD_REV_MASK;/*Get GPIO2 11,12,14*/
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053036
Pramod Kumar46d752a2018-08-14 09:49:55 +053037#endif
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053038 return val;
39}
40
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053041int checkboard(void)
42{
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053043#ifdef CONFIG_TARGET_LS1012AFRDM
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053044 puts("Board: LS1012AFRDM ");
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053045#else
46 int rev;
47
48 rev = get_board_version();
49
50 puts("Board: FRWY-LS1012A ");
51
52 puts("Version");
53
54 switch (rev) {
Pramod Kumar46d752a2018-08-14 09:49:55 +053055 case BOARD_REV_A_B:
56 puts(": RevA/B ");
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053057 break;
Pramod Kumar46d752a2018-08-14 09:49:55 +053058 case BOARD_REV_C:
59 puts(": RevC ");
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053060 break;
61 default:
62 puts(": unknown");
63 break;
64 }
65#endif
66
67 return 0;
68}
69
70#ifdef CONFIG_TARGET_LS1012AFRWY
71int esdhc_status_fixup(void *blob, const char *compat)
72{
73 char esdhc0_path[] = "/soc/esdhc@1560000";
74 char esdhc1_path[] = "/soc/esdhc@1580000";
75
76 do_fixup_by_path(blob, esdhc0_path, "status", "okay",
77 sizeof("okay"), 1);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053078
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053079 do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
80 sizeof("disabled"), 1);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053081 return 0;
82}
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053083#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053084
Rajesh Bhagat487084e2018-11-05 18:03:08 +000085#ifdef CONFIG_TFABOOT
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053086int dram_init(void)
87{
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053088#ifdef CONFIG_TARGET_LS1012AFRWY
89 int board_rev;
90#endif
Rajesh Bhagat487084e2018-11-05 18:03:08 +000091
92 gd->ram_size = tfa_get_dram_size();
93
94 if (!gd->ram_size) {
95#ifdef CONFIG_TARGET_LS1012AFRWY
96 board_rev = get_board_version();
97
98 if (board_rev & BOARD_REV_C)
99 gd->ram_size = SYS_SDRAM_SIZE_1024;
100 else
101 gd->ram_size = SYS_SDRAM_SIZE_512;
102#else
103 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
104#endif
105 }
106 return 0;
107}
108#else
109int dram_init(void)
110{
111#ifdef CONFIG_TARGET_LS1012AFRWY
112 int board_rev;
113#endif
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530114 struct fsl_mmdc_info mparam = {
York Sunc1e979b2016-09-26 08:09:25 -0700115 0x04180000, /* mdctl */
116 0x00030035, /* mdpdc */
117 0x12554000, /* mdotc */
118 0xbabf7954, /* mdcfg0 */
119 0xdb328f64, /* mdcfg1 */
120 0x01ff00db, /* mdcfg2 */
121 0x00001680, /* mdmisc */
122 0x0f3c8000, /* mdref */
123 0x00002000, /* mdrwd */
124 0x00bf1023, /* mdor */
125 0x0000003f, /* mdasp */
126 0x0000022a, /* mpodtctrl */
127 0xa1390003, /* mpzqhwctrl */
128 };
129
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530130#ifdef CONFIG_TARGET_LS1012AFRWY
131 board_rev = get_board_version();
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530132
Pramod Kumar46d752a2018-08-14 09:49:55 +0530133 if (board_rev == BOARD_REV_C) {
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530134 mparam.mdctl = 0x05180000;
135 gd->ram_size = SYS_SDRAM_SIZE_1024;
136 } else {
137 gd->ram_size = SYS_SDRAM_SIZE_512;
138 }
139#else
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530140 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530141#endif
142 mmdc_init(&mparam);
143
York Sun729f2d12017-03-06 09:02:34 -0800144#if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
145 /* This will break-before-make MMU for DDR */
146 update_early_mmu_table();
147#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530148
149 return 0;
150}
Rajesh Bhagat487084e2018-11-05 18:03:08 +0000151#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530152
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530153int board_early_init_f(void)
154{
155 fsl_lsch2_early_init_f();
156
157 return 0;
158}
159
160int board_init(void)
161{
Ashish Kumar11234062017-08-11 11:09:14 +0530162 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
163 CONFIG_SYS_CCI400_OFFSET);
164
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530165 /*
166 * Set CCI-400 control override register to enable barrier
167 * transaction
168 */
Rajesh Bhagat487084e2018-11-05 18:03:08 +0000169 if (current_el() == 3)
170 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530171
172#ifdef CONFIG_ENV_IS_NOWHERE
173 gd->env_addr = (ulong)&default_environment[0];
174#endif
175
Vinitha V Pillaiad698c32018-05-23 11:03:31 +0530176#ifdef CONFIG_FSL_CAAM
177 sec_init();
178#endif
179
Prabhakar Kushwaha74d129b2017-01-30 17:05:35 +0530180#ifdef CONFIG_FSL_LS_PPA
181 ppa_init();
182#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530183 return 0;
184}
185
186int ft_board_setup(void *blob, bd_t *bd)
187{
188 arch_fixup_fdt(blob);
189
190 ft_cpu_setup(blob, bd);
191
192 return 0;
193}