blob: e30ad6edcf505c2511c1d204db04e3bcfe85a3b7 [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>
21
22DECLARE_GLOBAL_DATA_PTR;
23
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053024static inline int get_board_version(void)
25{
26 struct ccsr_gpio *pgpio = (void *)(GPIO1_BASE_ADDR);
27 int val;
28
29 val = in_be32(&pgpio->gpdat);
30
31 return val;
32}
33
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053034int checkboard(void)
35{
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053036#ifdef CONFIG_TARGET_LS1012AFRDM
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053037 puts("Board: LS1012AFRDM ");
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053038#else
39 int rev;
40
41 rev = get_board_version();
42
43 puts("Board: FRWY-LS1012A ");
44
45 puts("Version");
46
47 switch (rev) {
48 case BOARD_REV_A:
49 puts(": RevA ");
50 break;
51 case BOARD_REV_B:
52 puts(": RevB ");
53 break;
54 default:
55 puts(": unknown");
56 break;
57 }
58#endif
59
60 return 0;
61}
62
63#ifdef CONFIG_TARGET_LS1012AFRWY
64int esdhc_status_fixup(void *blob, const char *compat)
65{
66 char esdhc0_path[] = "/soc/esdhc@1560000";
67 char esdhc1_path[] = "/soc/esdhc@1580000";
68
69 do_fixup_by_path(blob, esdhc0_path, "status", "okay",
70 sizeof("okay"), 1);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053071
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053072 do_fixup_by_path(blob, esdhc1_path, "status", "disabled",
73 sizeof("disabled"), 1);
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053074 return 0;
75}
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053076#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053077
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +053078int dram_init(void)
79{
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053080#ifdef CONFIG_TARGET_LS1012AFRWY
81 int board_rev;
82#endif
83 struct fsl_mmdc_info mparam = {
York Sunc1e979b2016-09-26 08:09:25 -070084 0x04180000, /* mdctl */
85 0x00030035, /* mdpdc */
86 0x12554000, /* mdotc */
87 0xbabf7954, /* mdcfg0 */
88 0xdb328f64, /* mdcfg1 */
89 0x01ff00db, /* mdcfg2 */
90 0x00001680, /* mdmisc */
91 0x0f3c8000, /* mdref */
92 0x00002000, /* mdrwd */
93 0x00bf1023, /* mdor */
94 0x0000003f, /* mdasp */
95 0x0000022a, /* mpodtctrl */
96 0xa1390003, /* mpzqhwctrl */
97 };
98
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +053099#ifdef CONFIG_TARGET_LS1012AFRWY
100 board_rev = get_board_version();
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530101
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530102 if (board_rev & BOARD_REV_B) {
103 mparam.mdctl = 0x05180000;
104 gd->ram_size = SYS_SDRAM_SIZE_1024;
105 } else {
106 gd->ram_size = SYS_SDRAM_SIZE_512;
107 }
108#else
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530109 gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
Bhaskar Upadhaya5e6f5982018-05-23 11:03:30 +0530110#endif
111 mmdc_init(&mparam);
112
York Sun729f2d12017-03-06 09:02:34 -0800113#if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
114 /* This will break-before-make MMU for DDR */
115 update_early_mmu_table();
116#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530117
118 return 0;
119}
120
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530121int board_early_init_f(void)
122{
123 fsl_lsch2_early_init_f();
124
125 return 0;
126}
127
128int board_init(void)
129{
Ashish Kumar11234062017-08-11 11:09:14 +0530130 struct ccsr_cci400 *cci = (struct ccsr_cci400 *)(CONFIG_SYS_IMMR +
131 CONFIG_SYS_CCI400_OFFSET);
132
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530133 /*
134 * Set CCI-400 control override register to enable barrier
135 * transaction
136 */
137 out_le32(&cci->ctrl_ord, CCI400_CTRLORD_EN_BARRIER);
138
139#ifdef CONFIG_ENV_IS_NOWHERE
140 gd->env_addr = (ulong)&default_environment[0];
141#endif
142
Prabhakar Kushwaha74d129b2017-01-30 17:05:35 +0530143#ifdef CONFIG_FSL_LS_PPA
144 ppa_init();
145#endif
Prabhakar Kushwaha9e7ee7b2016-06-03 18:41:36 +0530146 return 0;
147}
148
149int ft_board_setup(void *blob, bd_t *bd)
150{
151 arch_fixup_fdt(blob);
152
153 ft_cpu_setup(blob, bd);
154
155 return 0;
156}