blob: f2b8750a3f385a5df9e244b3d422faa775cbfce2 [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/*
Gaurav Jain476c6392022-03-24 11:50:35 +05303 * Copyright 2017-2018, 2021 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>
Simon Glass97589732020-05-10 11:40:02 -060010#include <init.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060011#include <asm/global_data.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053012#include <asm/io.h>
13#include <asm/arch/clock.h>
14#include <asm/arch/fsl_serdes.h>
Prabhakar Kushwaha74d129b2017-01-30 17:05:35 +053015#ifdef CONFIG_FSL_LS_PPA
16#include <asm/arch/ppa.h>
17#endif
York Sun729f2d12017-03-06 09:02:34 -080018#include <asm/arch/mmu.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053019#include <asm/arch/soc.h>
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053020#include <fsl_esdhc.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053021#include <hwconfig.h>
Simon Glass9d1f6192019-08-02 09:44:25 -060022#include <env_internal.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053023#include <fsl_mmdc.h>
24#include <netdev.h>
Mian Yousaf Kaukab2529deae2021-04-14 12:33:58 +020025#include <net/pfe_eth/pfe/pfe_hw.h>
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053026
27DECLARE_GLOBAL_DATA_PTR;
28
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053029static inline int get_board_version(void)
30{
Pramod Kumar46d752a2018-08-14 09:49:55 +053031 uint32_t val;
32#ifdef CONFIG_TARGET_LS1012AFRDM
33 val = 0;
34#else
35 struct ccsr_gpio *pgpio = (void *)(GPIO2_BASE_ADDR);
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053036
Pramod Kumar46d752a2018-08-14 09:49:55 +053037 val = in_be32(&pgpio->gpdat) & BOARD_REV_MASK;/*Get GPIO2 11,12,14*/
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053038
Pramod Kumar46d752a2018-08-14 09:49:55 +053039#endif
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053040 return val;
41}
42
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053043int checkboard(void)
44{
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053045#ifdef CONFIG_TARGET_LS1012AFRDM
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053046 puts("Board: LS1012AFRDM ");
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053047#else
48 int rev;
49
50 rev = get_board_version();
51
52 puts("Board: FRWY-LS1012A ");
53
54 puts("Version");
55
56 switch (rev) {
Pramod Kumar46d752a2018-08-14 09:49:55 +053057 case BOARD_REV_A_B:
58 puts(": RevA/B ");
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053059 break;
Pramod Kumar46d752a2018-08-14 09:49:55 +053060 case BOARD_REV_C:
61 puts(": RevC ");
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053062 break;
63 default:
64 puts(": unknown");
65 break;
66 }
67#endif
68
69 return 0;
70}
71
72#ifdef CONFIG_TARGET_LS1012AFRWY
73int esdhc_status_fixup(void *blob, const char *compat)
74{
75 char esdhc0_path[] = "/soc/esdhc@1560000";
76 char esdhc1_path[] = "/soc/esdhc@1580000";
77
78 do_fixup_by_path(blob, esdhc0_path, "status", "okay",
79 sizeof("okay"), 1);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053080
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053081 do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
82 sizeof("disabled"), 1);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053083 return 0;
84}
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053085#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053086
Rajesh Bhagat487084e2018-11-05 18:03:08 +000087#ifdef CONFIG_TFABOOT
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053088int dram_init(void)
89{
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053090#ifdef CONFIG_TARGET_LS1012AFRWY
91 int board_rev;
92#endif
Rajesh Bhagat487084e2018-11-05 18:03:08 +000093
94 gd->ram_size = tfa_get_dram_size();
95
96 if (!gd->ram_size) {
97#ifdef CONFIG_TARGET_LS1012AFRWY
98 board_rev = get_board_version();
99
100 if (board_rev & BOARD_REV_C)
101 gd->ram_size = SYS_SDRAM_SIZE_1024;
102 else
103 gd->ram_size = SYS_SDRAM_SIZE_512;
104#else
Tom Rinibb4dd962022-11-16 13:10:37 -0500105 gd->ram_size = CFG_SYS_SDRAM_SIZE;
Rajesh Bhagat487084e2018-11-05 18:03:08 +0000106#endif
107 }
108 return 0;
109}
110#else
111int dram_init(void)
112{
113#ifdef CONFIG_TARGET_LS1012AFRWY
114 int board_rev;
115#endif
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530116 struct fsl_mmdc_info mparam = {
York Sunc1e979b2016-09-26 08:09:25 -0700117 0x04180000, /* mdctl */
118 0x00030035, /* mdpdc */
119 0x12554000, /* mdotc */
120 0xbabf7954, /* mdcfg0 */
121 0xdb328f64, /* mdcfg1 */
122 0x01ff00db, /* mdcfg2 */
123 0x00001680, /* mdmisc */
124 0x0f3c8000, /* mdref */
125 0x00002000, /* mdrwd */
126 0x00bf1023, /* mdor */
127 0x0000003f, /* mdasp */
128 0x0000022a, /* mpodtctrl */
129 0xa1390003, /* mpzqhwctrl */
130 };
131
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530132#ifdef CONFIG_TARGET_LS1012AFRWY
133 board_rev = get_board_version();
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530134
Pramod Kumar46d752a2018-08-14 09:49:55 +0530135 if (board_rev == BOARD_REV_C) {
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530136 mparam.mdctl = 0x05180000;
137 gd->ram_size = SYS_SDRAM_SIZE_1024;
138 } else {
139 gd->ram_size = SYS_SDRAM_SIZE_512;
140 }
141#else
Tom Rinibb4dd962022-11-16 13:10:37 -0500142 gd->ram_size = CFG_SYS_SDRAM_SIZE;
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530143#endif
144 mmdc_init(&mparam);
145
York Sun729f2d12017-03-06 09:02:34 -0800146#if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
147 /* This will break-before-make MMU for DDR */
148 update_early_mmu_table();
149#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530150
151 return 0;
152}
Rajesh Bhagat487084e2018-11-05 18:03:08 +0000153#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530154
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530155int board_early_init_f(void)
156{
157 fsl_lsch2_early_init_f();
158
159 return 0;
160}
161
162int board_init(void)
163{
Ashish Kumar11234062017-08-11 11:09:14 +0530164 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
165 CONFIG_SYS_CCI400_OFFSET);
166
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530167 /*
168 * Set CCI-400 control override register to enable barrier
169 * transaction
170 */
Rajesh Bhagat487084e2018-11-05 18:03:08 +0000171 if (current_el() == 3)
172 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530173
Prabhakar Kushwaha74d129b2017-01-30 17:05:35 +0530174#ifdef CONFIG_FSL_LS_PPA
175 ppa_init();
176#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530177 return 0;
178}
179
Mian Yousaf Kaukab2529deae2021-04-14 12:33:58 +0200180#ifdef CONFIG_FSL_PFE
181void board_quiesce_devices(void)
182{
183 pfe_command_stop(0, NULL);
184}
185#endif
186
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +0900187int ft_board_setup(void *blob, struct bd_info *bd)
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530188{
189 arch_fixup_fdt(blob);
190
191 ft_cpu_setup(blob, bd);
192
193 return 0;
194}